1import{r as v,j as e}from"./chunk-OIYGIGL5-oEnNm_jQ.js";import{t as u}from"./index-BIX-387d.js";import{B as f}from"./button-Cp_Fm57Y.js";import{D as y,a as w,e as D}from"./dialog-aLydnsbF.js";import{q as U}from"./graphql-operations-Cu3pfN9U.js";import{a as k}from"./error-utils-BzLJ5f8S.js";import{g as E,f as d,a as T}from"./plan-helpers-Bn-fE3sG.js";import{s as $}from"./meta-cookies-DibNNTWH.js";import{u as _}from"./useTranslation-usccM3xj.js";import{u as z}from"./useMutation-CcEZtSf1.js";import{S as M}from"./sparkles-DrZP2Uyo.js";import{T as S}from"./tag-DELeCe0G.js";import{C as A}from"./circle-check-big-DioOMIhi.js";import{A as h}from"./arrow-right-CnfL2EnW.js";import{L as I}from"./loader-circle-CGzxeu2x.js";const F=3.6;function R(n,o){const r=Math.max(0,Math.round(n*F)),i=Math.max(0,o-r),s=n>0&&r>0;return{discountCents:r,finalPriceCents:i,hasDiscount:s}}function ee({open:n,onOpenChange:o,targetPlan:r,currentCredits:i}){const{t:s}=_(),[t,l]=v.useState(!1),{discountCents:x,finalPriceCents:p,hasDiscount:c}=R(i,r.priceCents),g=x/100,[j]=z(U,{onError:a=>{const m=k(a);u.error(m),l(!1)},onCompleted:a=>{a.createUpgradeCheckout.success&&a.createUpgradeCheckout.checkoutUrl?($(),window.location.href=a.createUpgradeCheckout.checkoutUrl):(u.error(s("membership.upgradeError")),l(!1))}}),N=async()=>{l(!0);const a=typeof window<"u"?window.location.origin:"",m=`${a}/my-subscription?upgrade=success&plan_id=${r.id}&session_id={CHECKOUT_SESSION_ID}&discount=${x}`,C=`${a}/membership`;await j({variables:{input:{targetPlanId:r.id,successUrl:m,cancelUrl:C}}})},b=()=>{t||o(!1)};return e.jsx(y,{open:n,onOpenChange:t?void 0:o,children:e.jsxs(w,{className:"w-[90vw] max-w-[512px] gap-0 overflow-hidden rounded-[10px] border p-0 shadow-lg sm:max-w-[512px]",children:[e.jsxs("div",{className:"relative overflow-hidden border-b px-6 pt-8 pb-6",children:[e.jsx("div",{className:"pointer-events-none absolute -top-8 right-[80px] size-32 rounded-full bg-primary/20 blur-3xl"}),e.jsxs("div",{className:"mb-[16px] inline-flex items-center gap-2 rounded-full border border-primary/30 bg-background px-3 py-[6px]",children:[e.jsx(M,{className:"size-4 text-primary"}),e.jsx("span",{className:"text-sm leading-5 text-primary",children:s("membership.upgradeTo",{plan:E(r.tier,s)})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h2",{className:"text-lg font-semibold leading-[18px] tracking-tight text-foreground",children:s("membership.upgradeConfirmTitle")}),e.jsx("p",{className:"text-sm leading-5 text-muted-foreground",children:s(c?"membership.upgradeConfirmDescription":"membership.upgradeConfirmDescriptionNoDiscount")})]})]}),e.jsxs("div",{className:"flex flex-col gap-6 px-6 pt-6 pb-6",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[c&&e.jsx("div",{className:"rounded-[10px] border border-primary/30 px-4 py-[17px]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S,{className:"mt-0.5 size-5 shrink-0 text-primary"}),e.jsxs("div",{className:"flex flex-col gap-2 flex-1",children:[e.jsx("span",{className:"text-sm leading-5 text-muted-foreground",children:s("membership.yourDiscount")}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("membership.remainingCredits",{count:i})})}),e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i," Ã $0.036"]}),e.jsxs("span",{className:"text-lg font-semibold text-primary",children:["-$",g.toFixed(2)]})]})]})]})]})}),e.jsx("div",{className:"rounded-[10px] border bg-muted/50 px-4 py-[17px]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(A,{className:"mt-0.5 size-5 shrink-0 text-primary"}),e.jsxs("div",{className:"flex flex-col gap-2 flex-1",children:[e.jsx("span",{className:"text-sm leading-5 text-muted-foreground",children:s("membership.newPlan")}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-base font-semibold text-foreground",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[c&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm text-muted-foreground line-through",children:["$",d(r.priceCents)]}),e.jsx(h,{className:"size-3 text-muted-foreground"})]}),e.jsxs("span",{className:"text-lg font-semibold text-foreground",children:["$",d(p)]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["/ ",T(r.interval,s)]})]})]})]})]})}),e.jsxs("div",{className:"rounded-[10px] bg-primary/5 px-4 py-3 text-center",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s("membership.todayYouPay"),":"," "]}),e.jsxs("span",{className:"text-lg font-bold text-primary",children:["$",d(p)]})]})]}),e.jsxs(D,{className:"flex-row gap-3 sm:justify-between",children:[e.jsx(f,{variant:"outline",onClick:b,disabled:t,className:"flex-1",children:s("membership.cancelAction")}),e.jsx(f,{onClick:N,disabled:t,className:"flex-1",children:t?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"size-4 mr-2 animate-spin"}),s("processing")]}):e.jsxs(e.Fragment,{children:[s("membership.upgradeNow"),e.jsx(h,{className:"size-4 ml-2"})]})})]})]})]})})}export{ee as U,R as c};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.