1import{a4 as V,l as i,y as g,z as p,q as t,m as k,v as E,F as H,B as u,H as w,u as r,X as L,Y as h,J as n,K as _,aa as N,ac as W,p as C,W as j,e as S,r as P,a6 as M,a9 as X,D as G}from"./vue-vendor-c0W5WEtO.js";import{u as J,b as O,c as v}from"./query-vendor-BMwEzNLN.js";import{_ as Z}from"./AgencyPermissionGate-DeHFMo-x.js";import{f as ee,G as te,H as ae,I as se}from"./index-COv0RcNg.js";import{_ as re,u as oe,t as c}from"./index-B2Yag7Gu.js";import{X as ne,ac as ie,R as le,aT as de,b$ as ue,bg as ce,aj as ge,bc as pe,ai as ye}from"./ui-vendor-B7SopUXd.js";import"./rewardful-2QOTUYRt.js";import"./date-vendor-HBGOQ70J.js";import"./twilio-DAuME2Y9.js";import"./charts-BVdrK9wF.js";import"./socket-Kk_l3rvZ.js";const be={class:"scrollbar-hide mb-4 flex gap-1 overflow-x-auto rounded-xl border border-gray-200 bg-gray-100 p-1 md:mb-6 dark:border-gray-700 dark:bg-gray-800"},me={class:"w-full max-w-lg rounded-xl bg-white p-6 dark:bg-gray-800"},ve={class:"mb-4 flex items-center justify-between"},xe=["disabled"],fe={class:"mb-4 rounded-lg bg-gray-100 p-4 dark:bg-gray-700"},ke={class:"mb-3 text-sm text-gray-600 dark:text-gray-300"},we={class:"mb-4"},he={class:"flex flex-wrap gap-3"},_e=["disabled"],Ce=["disabled"],Se={__name:"SubscriptionManagement",setup(Pe){const A=X(),y=oe(),{agency:x,user:R}=V(y),m=J(),D=[{id:"plans",label:"Plans",icon:de,to:{name:"agency-subscription-plans"}},{id:"overview",label:"Current Plan",icon:ue,to:{name:"agency-subscription-overview"}},{id:"addons",label:"Add-ons",icon:ce,to:{name:"agency-subscription-addons"}},{id:"wallet",label:"Wallet",icon:ge,to:{name:"agency-subscription-wallet"}},{id:"history",label:"Payment History",icon:pe,to:{name:"agency-subscription-history"}},{id:"payment",label:"Payment Method",icon:ye,to:{name:"agency-subscription-payment"}}],F=a=>A.meta?.tab===a,l=P(!1),d=P(""),o=S(()=>x.value?.subscription),{data:q}=O({queryKey:["agency","packages"],queryFn:ee}),I=S(()=>{const a=o.value?.package_id?._id||o.value?.package_id;return a?q.value?.results?.find(e=>e._id===a)||o.value?.package_id:null}),{mutate:T,isPending:b}=v({mutationFn:te,onSuccess:()=>{c.success("Subscription cancelled successfully"),l.value=!1,d.value="",m.invalidateQueries({queryKey:["agency"]}),y.loadUserInfo()},onError:a=>{c.error(a.response?.data?.message||"Failed to cancel subscription")}}),{mutate:Y}=v({mutationFn:()=>ae(o.value?._id),onSuccess:()=>{c.success("Payment retry initiated"),m.invalidateQueries({queryKey:["agency"]}),y.loadUserInfo()},onError:a=>{c.error(a.response?.data?.message||"Failed to retry payment")}}),{mutate:z}=v({mutationFn:()=>se(o.value?._id),onSuccess:()=>{c.success("Subscription reactivated successfully"),m.invalidateQueries({queryKey:["agency"]}),y.loadUserInfo()},onError:a=>{c.error(a.response?.data?.message||"Failed to reactivate subscription")}}),K=()=>{d.value&&T({cancel_reason:d.value})},$=()=>{Y()},B=()=>{confirm("Are you sure you want to reactivate your subscription?")&&z()},Q=a=>a?new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"-";return(a,e)=>{const f=M("router-link"),U=M("router-view");return i(),g(Z,{permission:"agency.subscription_payments"},{default:p(()=>[t("div",null,[e[15]||(e[15]=t("div",{class:"mb-4 md:mb-6"},[t("h1",{class:"text-xl font-bold text-gray-900 md:text-2xl dark:text-white"}," Subscription Management "),t("p",{class:"mt-1 hidden text-sm text-gray-600 sm:block dark:text-gray-400"}," Manage your subscription, view plans, purchase add-ons, and review billing history. ")],-1)),t("div",be,[(i(),k(H,null,E(D,s=>u(f,{key:s.id,to:s.to,class:G(["flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-xs font-medium whitespace-nowrap transition-all md:gap-2 md:px-4 md:py-2.5 md:text-sm",F(s.id)?"bg-white text-teal-600 shadow-sm dark:bg-teal-600 dark:text-white":"text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"])},{default:p(()=>[(i(),g(w(s.icon),{size:16,class:"shrink-0"})),n(" "+_(s.label),1)]),_:2},1032,["to","class"])),64))]),u(U,null,{default:p(({Component:s})=>[(i(),g(w(s),{subscription:o.value,agency:r(x),user:r(R),"current-plan":I.value,"has-subscription":!!o.value,onCancel:e[0]||(e[0]=Me=>l.value=!0),onRetry:$,onReactivate:B},null,40,["subscription","agency","user","current-plan","has-subscription"]))]),_:1}),(i(),g(L,{to:"body"},[u(j,{name:"fade"},{default:p(()=>[l.value?(i(),k("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e[4]||(e[4]=h(s=>l.value=!1,["self"]))}
1,[t("div",me,[t("div",ve,[e[5]||(e[5]=t("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white"}," Cancel Subscription ",-1)),t("button",{onClick:e[1]||(e[1]=s=>l.value=!1),disabled:r(b),class:"rounded-full p-1 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-gray-700"},[u(r(ne),{size:20,class:"text-gray-500 dark:text-gray-400"})],8,xe)]),t("form",{onSubmit:h(K,["prevent"])},[e[12]||(e[12]=t("div",{class:"mb-4"},[t("p",{class:"font-bold text-teal-600 dark:text-teal-400"},"Thinking of Cancelling?"),t("p",{class:"mt-2 text-sm text-gray-600 dark:text-gray-300"},[n(" We'd hate to see you go! If you're having any issues, our team can help you troubleshoot or even "),t("strong",null,"pause your subscription"),n(" so you won't be billed, but can still come back anytime. ")])],-1)),t("div",fe,[e[7]||(e[7]=t("p",{class:"mb-4 text-sm text-gray-600 dark:text-gray-300"}," Pausing means: You keep your account and settings, but billing stops until you're ready to return. ",-1)),u(f,{to:"/support",class:"inline-flex rounded-lg bg-teal-500 px-4 py-2 text-sm font-bold text-white hover:bg-teal-600 dark:bg-teal-600 dark:hover:bg-teal-500"},{default:p(()=>[...e[6]||(e[6]=[n(" Contact Support to Pause ",-1)])]),_:1})]),t("p",ke,[e[8]||(e[8]=n(" Your subscription will remain active until ",-1)),t("strong",null,_(Q(o.value?.expiry_date)),1),e[9]||(e[9]=n(". ",-1))]),e[13]||(e[13]=t("p",{class:"mb-3 font-bold text-red-500"},"After this date:",-1)),e[14]||(e[14]=t("ul",{class:"mb-4 list-disc pl-4 text-sm text-gray-600 dark:text-gray-300"},[t("li",{class:"mb-2"},"Your clients won't be able to call to your live visitors."),t("li",{class:"mb-2"},"Your analytics, leads, and chats will no longer be tracked."),t("li",{class:"mb-2"},"Your dashboard will be limited."),t("li",{class:"mb-2"},"Your AI credits will be lost.")],-1)),t("div",we,[N(t("textarea",{"onUpdate:modelValue":e[2]||(e[2]=s=>d.value=s),placeholder:"Reason for cancellation",required:"",rows:"3",class:"w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-gray-900 placeholder-gray-500 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400"},null,512),[[W,d.value]])]),t("div",he,[t("button",{type:"button",onClick:e[3]||(e[3]=s=>l.value=!1),disabled:r(b),class:"flex items-center gap-2 rounded-lg bg-gray-200 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-300 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-600 dark:text-gray-200 dark:hover:bg-gray-500"},[u(r(ie),{size:16}),e[10]||(e[10]=n(" Keep Subscription ",-1))],8,_e),t("button",{type:"submit",disabled:r(b)||!d.value,class:"flex items-center gap-2 rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-50"},[r(b)?(i(),g(r(le),{key:0,size:16,class:"animate-spin"})):C("",!0),e[11]||(e[11]=n(" Yes, Cancel ",-1))],8,Ce)])],32)])])):C("",!0)]),_:1})]))])]),_:1})}}},Be=re(Se,[["__scopeId","data-v-c1b059a6"]]);export{Be as default};
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.