import{aD as x,e as p,j as e,r as j,T as a,B as o,L as g}from"./main-TIUJvpaR.js";import{b}from"./billing-queries-D1QXfRse.js";import{B as h,a as c}from"./breadcrumb-B7oVkzG6.js";import{F as f}from"./formatted-date-CsxGDhkC.js";import{F as v}from"./formatted-price-BnJL0Dzb.js";import{B as y}from"./billing-plan-panel-DBYIXcfr.js";import{u as B}from"./use-cancel-subscription-DNh-nvw2.js";import{u as N,i as w}from"./use-billing-user-De1g37WG.js";import"./useEffectEvent-Bgk8rSJ3.js";import"./ChevronRight-BaJkMP9s.js";import"./MoreHoriz-Cm8ZCxuL.js";import"./use-date-formatter-hhGEq_P-.js";const i="/billing";function q(){const r=x(),m=p(b.products.index()),{subscription:s}=N(),n=B(),l=s==null?void 0:s.product,t=s==null?void 0:s.price;if(!m.data)return null;if(!s||!l||!t)return r(i),null;const d=e.jsx("span",{className:"whitespace-nowrap",children:e.jsx(f,{date:s.renews_at,preset:"long"})}),u=()=>{n.mutate({subscriptionId:s.id},{onSuccess:()=>{w(),r("/billing")}})};return e.jsxs(j.Fragment,{children:[e.jsxs(h,{children:[e.jsx(c,{isLink:!0,onSelected:()=>r(i),children:e.jsx(a,{message:"Billing"})}),e.jsx(c,{children:e.jsx(a,{message:"Cancel"})})]}),e.jsx("h1",{className:"my-32 text-3xl font-bold md:my-64",children:e.jsx(a,{message:"Cancel your plan"})}),e.jsx(y,{title:e.jsx(a,{message:"Current plan"}),children:e.jsxs("div",{className:"max-w-[464px]",children:[e.jsx("div",{className:"text-xl font-bold",children:l.name}),e.jsx(v,{price:t,className:"text-lg"}),e.jsxs("div",{className:"mb-48 mt-12 border-b pb-24 text-base",children:[e.jsx(a,{message:"Your plan will be canceled, but is still available until the end of your billing period on :date",values:{date:d}}),e.jsx("div",{className:"mt-20",children:e.jsx(a,{message:"If you change your mind, you can renew your subscription."})})]}),e.jsxs("div",{children:[e.jsx("div",{children:e.jsx(o,{variant:"flat",color:"primary",size:"md",className:"mb-16 w-full",onClick:u,disabled:n.isPending,children:e.jsx(a,{message:"Cancel plan"})})}),e.jsx("div",{children:e.jsx(o,{variant:"outline",className:"w-full",to:i,elementType:g,children:e.jsx(a,{message:"Go back"})})}),e.jsx("div",{className:"mt-12 text-xs text-muted",children:e.jsx(a,{message:"By cancelling your plan, you agree to our terms of service and privacy policy."})})]})]})})]})}export{q as Component};
