{"version":3,"file":"accounts-CXjt8lUq.js","sources":["../../../../src/models/components.ts","../../../../src/ts/accounts/main.ts"],"sourcesContent":["import { List } from \"cypress/types/lodash\";\n\nexport type TabItem = {\n  label: string;\n  isActive: boolean;\n};\n\nexport type LanguageItem = {\n  title: string;\n  name: string;\n}\n\nexport enum PlanType {\n  Team = \"team\",\n  Free = \"free\",\n  Enterprise = \"enterprise\",\n}\n\nexport enum BillingFrequency {\n  Monthly = \"monthly\",\n  Annual = \"annually\",\n  None = \"\",\n}\n\nexport class SafetyPlan {\n  planType: PlanType;\n  description: string;\n  features: List<string>;\n  minSeats: number = 1;\n  maxSeats: number = 9999;\n\n  constructor(planType: PlanType, description: string, features: List<string>) {\n    this.planType = planType;\n    this.description = description;\n    this.features = features;\n  }\n}\n\n// Make this class inherit from SafetyPlan\nexport class FreePlan extends SafetyPlan {\n  constructor() {\n    super(\n      PlanType.Free,\n      \"Free plan\",\n      [\"Unlimited public repositories\", \"Unlimited collaborators\"]\n    );\n    this.minSeats = 1\n    this.maxSeats = 1\n  }\n}\nexport class TeamPlan extends SafetyPlan {\n  constructor() {\n    super(\n      PlanType.Team,\n      \"Safety is designed for teams of all sizes, from solo developers to small project teams and beyond.\",\n      [\n        \"Everything in Free, plus:\",\n        \"Up to 20 Developer Seats\",\n        \"Support for up to 25 projects\",\n        \"5,000 scans per month\",\n        \"Customizable policies\",\n        \"System-wide scans\",\n      ]\n    );\n    this.minSeats = 1;\n    this.maxSeats = 20;\n  }\n}\n\n\nexport class EnterprisePlan extends SafetyPlan {\n  constructor() {\n    super(\n      PlanType.Enterprise,\n      \"Our Enterprise plan is designed for larger teams, enterprise and data-sensitive organizations, government and military entities.\",\n      [\n        \"Everything in Team, plus:\",\n        \"Unlimited Developer Seats\",\n        \"Unlimited projects\",\n        \"20,000 scans per month\",\n        \"24/7 support and guaranteed uptime\",\n        \"Enhanced vulnerability data\",\n        \"Integration with identity providers\",\n        \"Dedicated implementation support\",\n        \"On-premises deployment options\"\n      ]\n    );\n    this.minSeats = 20;\n    this.maxSeats = 50;\n  }\n}\n","import { PlanType, BillingFrequency, SafetyPlan, TeamPlan, FreePlan, EnterprisePlan } from \"../../models/components\";\nexport class PlanForm {\n    static currentSelectedPlan: PlanForm | null = null;\n    safetyPlan!: SafetyPlan;\n    seats: number = 0;\n    billingFrequency: BillingFrequency = BillingFrequency.Annual;\n    planType: PlanType;\n    selected: boolean = false;\n    action_text: string = 'Choose';\n    occupiedSeats: number = 0;\n    currentPlanSeats: number = 0;\n    manageText: string = 'Manage Seats';\n    upgradeText: string = 'Upgrade to Enterprise';\n    teamText: string = 'Choose';\n\n    constructor(planType: PlanType,\n                frequency: BillingFrequency = BillingFrequency.Annual,\n                occupiedSeats: number = 0,\n                currentPlanSeats: number = 0,\n                currentPlanType?: PlanType) {\n        this.planType = planType;\n        this.billingFrequency = frequency;\n        this.occupiedSeats = occupiedSeats;\n        this.currentPlanSeats = currentPlanSeats;\n\n        this.setActionText(planType, currentPlanType);\n        this.setSafetyPlan();\n        this.populateSeats();\n    }\n\n    setActionText(planType: PlanType, currentPlanType?: PlanType) {\n        if (currentPlanType) {\n            if (currentPlanType === planType) {\n                this.action_text = this.manageText;\n            } else if (currentPlanType === PlanType.Enterprise && planType === PlanType.Team) {\n                this.action_text = this.teamText;\n            } else if (currentPlanType === PlanType.Team && planType === PlanType.Enterprise) {\n                this.action_text = this.upgradeText;\n            }\n        } else {\n            this.action_text = this.teamText;\n        }\n    }\n\n\n    setSafetyPlan() {\n        if (this.planType === PlanType.Team) {\n            this.safetyPlan = new TeamPlan();\n        } else if (this.planType === PlanType.Enterprise) {\n            this.safetyPlan = new EnterprisePlan();\n        } else {\n            this.safetyPlan = new FreePlan();\n        }\n    }\n\n    populateSeats() {\n        this.seats = Math.min(\n            Math.max(this.occupiedSeats, this.safetyPlan.minSeats, this.currentPlanSeats),\n            this.getMaxSeats()\n        );\n    }\n    select() {\n        if (PlanForm.currentSelectedPlan && PlanForm.currentSelectedPlan !== this) {\n            PlanForm.currentSelectedPlan.resetForm();\n        }\n        this.selected = true;\n        if (this.planType === PlanType.Team) {\n            this.seats = Math.min(this.seats, 20);\n        }\n        PlanForm.currentSelectedPlan = this;\n    }\n\n    getMinSeats(): number {\n        return Math.max(this.occupiedSeats, this.safetyPlan.minSeats);\n    }\n\n    getMaxSeats(): number {\n        return this.safetyPlan.maxSeats;\n    }\n\n    resetForm() {\n        this.populateSeats();\n        this.billingFrequency = BillingFrequency.Annual;\n        this.selected = false;\n        if (PlanForm.currentSelectedPlan === this) {\n            PlanForm.currentSelectedPlan = null;\n        }\n    }\n\n    calculatePrice(): number {\n        const TEAM_MONTHLY_PRICE = 25;\n        const TEAM_ANNUAL_PRICE = 240; // 20 per month * 12\n        const ENTERPRISE_ANNUAL_PRICE = 360; // 30 per month * 12\n\n        if (this.planType === PlanType.Team) {\n            const teamRate = this.billingFrequency === BillingFrequency.Annual\n                ? TEAM_ANNUAL_PRICE\n                : TEAM_MONTHLY_PRICE;\n            return Math.min(this.seats, this.getMaxSeats()) * teamRate;\n        }\n\n        // Calculate price for Enterprise plan\n        // Note: Assumes Enterprise plan only has annual billing\n        return this.seats * ENTERPRISE_ANNUAL_PRICE;\n    }\n\n    submitForm(csrfToken: string) {\n        const form = document.createElement('form');\n        form.action = '';\n        form.method = 'POST';\n\n        form.appendChild(this.createHiddenInput('csrfmiddlewaretoken', csrfToken));\n        form.appendChild(this.createHiddenInput('plan_type', this.planType));\n        form.appendChild(this.createHiddenInput('seats', this.seats.toString()));\n        form.appendChild(this.createHiddenInput('billing_frequency', this.billingFrequency));\n\n        document.body.appendChild(form);\n        form.submit();\n    }\n\n    createHiddenInput(name: string, value: string) {\n        const input = document.createElement('input');\n        input.type = 'hidden';\n        input.name = name;\n        input.value = value;\n        return input;\n    }\n}\n"],"names":["PlanType","BillingFrequency","SafetyPlan","planType","description","features","FreePlan","TeamPlan","EnterprisePlan","PlanForm","frequency","occupiedSeats","currentPlanSeats","currentPlanType","teamRate","csrfToken","form","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