import{B as C}from"./Button-LyDQSUp0.js";import{d as E,n as r,L as N,b3 as _,c as i,O as c,x as a,B as o,aG as R,aj as m,w as g,ae as D,o as u,aZ as G,a_ as b,a$ as M}from"./index-BXlk60bP.js";import{E as P,b as S}from"./el-radio-group-BiLdIdUt.js";import{a7 as j,a3 as O,S as W,$ as n,a1 as Y,as as $,at as K}from"./common-vYHpopNV.js";import"./_commonjsHelpers-BosuxZz1.js";const L={class:"flex flex-col space-y-2",md:"w-500px"},Z={key:0,class:"flex flex-row items-center space-x-1 px-3 py-2 bg-blue-100 text-blue-500 text-xs border border-blue-200 rounded-md"},q={key:1,class:""},z={key:2,class:"step"},A={key:3,class:"step"},F={class:"button-group"},H=E({__name:"Unsubscribe",setup(J){const l=j(),f=r(()=>{var t;return((t=l.value)==null?void 0:t.email)||""}),w=r(()=>{var t;return((t=l.value)==null?void 0:t.token)||""}),k=r(()=>{var t;return((t=l.value)==null?void 0:t.grade)||""}),v=r(()=>{var t;return((t=l.value)==null?void 0:t.member_time)||""});N(async()=>{const t=await O();l.value=t.value}),_("unsubscribe_page");const h=r(()=>Math.ceil((new Date(v.value).getTime()-new Date().getTime())/(1e3*60*60*24))),e=W({index:1,hasTips:!0,reason:"",feedback:""});async function V(){switch(e.index){case 1:e.index++;break;case 2:if(e.reason.length===0){b({type:"warning",message:"Please select the reason for unsubscribe."});return}e.hasTips=!1,e.index++;break;case 3:e.feedback!=""&&await $({email:f.value,message:e.feedback}),await _({name:"unsubscribe_button",data:{reason:e.reason,feedback:e.feedback}});try{await K({grade:k.value,email:f.value,token:w.value}),b({type:"success",message:"Unsubscribed successfully."}),y.push("/")}catch{b({type:"error",message:"Network error, please try again later."})}break}}const y=G();function B(){y.push("/subscribe")}return(t,s)=>{const I=R("ant-design:bell-twotone"),d=S,T=P,U=D,x=C;return u(),i("div",L,[n(e).hasTips?(u(),i("div",Z,[o(I),a("p",null,[s[2]||(s[2]=m(" You still have ")),a("strong",null,Y(n(h))+" days left",1),s[3]||(s[3]=m(" in your Pro period. "))])])):c("",!0),n(e).index==1?(u(),i("div",q,s[4]||(s[4]=[a("h2",{class:"text-base font-bold"},"You'll miss out on...",-1),a("ul",{class:"flex flex-col justify-center items-center text-gray-600 text-sm list-circle"},[a("li",null,"Bulk download images and videos.")],-1)]))):c("",!0),n(e).index==2?(u(),i("div",z,[s[5]||(s[5]=a("h2",null,"Why do you want to cancel?",-1)),o(T,{modelValue:n(e).reason,"onUpdate:modelValue":s[0]||(s[0]=p=>n(e).reason=p)},{default:g(()=>[o(d,{label:"I don't use all of the feature"}),o(d,{label:"It doesn't work properly"}),o(d,{label:"I want to change to a yearly subscription"}),o(d,{label:"Other"})]),_:1},8,["modelValue"])])):c("",!0),n(e).index==3?(u(),i("div",A,[s[6]||(s[6]=a("h2",null,"Why do you want to cancel?",-1)),o(U,{modelValue:n(e).feedback,"onUpdate:modelValue":s[1]||(s[1]=p=>n(e).feedback=p),rows:4,type:"textarea",maxlength:"200",placeholder:"Tell us why you're canceling...","show-word-limit":""},null,8,["modelValue"])])):c("",!0),a("div",F,[o(x,{icon:"i-ant-design:crown-twotone",type:"success",onClick:B},{default:g(()=>s[7]||(s[7]=[a("span",null,[m(" Keep Pro "),a("sup",null,"+")],-1)])),_:1}),o(x,{icon:"i-ant-design:alert-twotone",type:"danger",text:"Canceled subscription",onclick:V})])])}}}),ae=M(H,[["__scopeId","data-v-4fa51fef"]]);export{ae as default};
