import{z as b,ag as g,G as f,H as v,I as y,J as w,ab as N,cv as m,b as P,an as B,j as e,aw as C,r as I,T as a,t as p,v as F}from"./main-D6SjkSWq.js";import{A as S,B as T}from"./billing-plan-panel-DOh_cx8-.js";import{u as x}from"./useSuspenseQuery-Xmh5uCOE.js";import{B as Q,a as c}from"./breadcrumb-Pvuej4Ko.js";import{F as k}from"./formatted-date-BIydE9wI.js";import{F as E}from"./formatted-price-BMjupemv.js";import"./section-helper-C-cn6F19.js";import"./useEffectEvent-Bb2YhEEQ.js";import"./ChevronRight-BN6UJOeQ.js";import"./MoreHoriz-Bms6kOtf.js";import"./use-date-formatter-DZ85Tkvk.js";import"./DateFormatter-Dix9bfnP.js";function $(){const{trans:t}=b(),n=g();return f({mutationFn:s=>q(s),onSuccess:()=>{y(t(w("Plan changed."))),N.invalidateQueries({queryKey:m.user().queryKey}),n("/billing")},onError:s=>v(s)})}function q({subscriptionId:t,...n}){return P.post(`billing/subscriptions/${t}/change-plan`,n).then(s=>s.data)}const d="/billing/change-plan";function Y(){const{productId:t,priceId:n}=B(),s=g(),j=x(m.products.index()),r=x(m.user()),u=$();if(`${r.data.subscription.price_id}`==n)return e.jsx(C,{to:"/billing/change-plan",replace:!0});const i=j.data.products.find(l=>`${l.id}`===t),o=i==null?void 0:i.prices.find(l=>`${l.id}`===n);if(!i||!o)return s(d),null;const h=e.jsxs("span",{className:"whitespace-nowrap",children:[e.jsx(k,{date:r.data.subscription.renews_at,preset:"long"}),";"]});return e.jsxs(I.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(c,{isLink:!0,onSelected:()=>s("/billing"),children:e.jsx(a,{message:"Billing"})}),e.jsx(c,{onSelected:()=>s(d),children:e.jsx(a,{message:"Plans"})}),e.jsx(c,{children:e.jsx(a,{message:"Confirm"})})]}),e.jsx(S,{className:"mb-24"}),e.jsx("h1",{className:"my-32 text-3xl font-bold md:my-64",children:e.jsx(a,{message:"Confirm your new plan"})}),e.jsx(T,{title:e.jsx(a,{message:"Changing to"}),children:e.jsxs("div",{className:"max-w-[464px]",children:[e.jsx("div",{className:"text-xl font-bold",children:i.name}),e.jsx(E,{price:o,className:"text-lg"}),e.jsx("div",{className:"mb-48 mt-12 border-b pb-24 text-base",children:e.jsx(a,{message:"You will be charged the new price starting :date",values:{date:h}})}),e.jsxs("div",{children:[e.jsx("div",{children:e.jsx(p,{variant:"flat",color:"primary",size:"md",className:"mb-16 w-full",onClick:()=>{u.mutate({subscriptionId:r.data.subscription.id,newProductId:i.id,newPriceId:o.id})},disabled:u.isPending,children:e.jsx(a,{message:"Confirm"})})}),e.jsx("div",{children:e.jsx(p,{variant:"outline",className:"w-full",to:d,elementType:F,children:e.jsx(a,{message:"Go back"})})}),e.jsx("div",{className:"mt-12 text-xs text-muted",children:e.jsx(a,{message:"By confirming your new plan, you agree to our terms of Service and privacy policy."})})]})]})})]})}export{Y as Component};
