1import{d as L,b as M,f as q,Z as z,by as O,u as D,r,a9 as G,aa as H,J,o as W,e as k,a3 as f,T as F,a1 as Y,b2 as Z,k as j,p as K,ay as I,az as P,t as n,y as c,s as e,c as v,x as w,n as g,m as R,a$ as Q,F as X,af as ee,aB as ae,_ as oe}from"./main.83d599ca.js";import{F as te}from"./vee-validate.esm.a4fb9e07.js";import{_ as se}from"./TextInput.vue_vue_type_script_setup_true_lang.7d3771f4.js";import{_ as ne}from"./Loading.vue_vue_type_script_setup_true_lang.c9cfb698.js";/* empty css */const ie={id:"registration_page_content"},le={id:"email_form_promoCode"},pe=L({__name:"AuthActivationCode",setup(re){const{t:i}=M(),y=q(),C=z(),A=O(),l=D(),B=r(null),_=r(!1),p=r(!1),o=r(""),T=r(!1),d=r(!1),h=r(!1),u=r(!0),U=G({registrationCode:H().required()}),$=J(()=>{if(o.value&&_.value){if(p.value)return i("authentication.form.invalidCode");if(T.value)return i("authentication.form.alreadyUsedCode")}return""});W(()=>{if(l.infos&&l.currentSubscription){C.push({name:k.HOMEPAGE});return}S.selectedPlan=void 0,f("page",{name:"ActivationCode",options:{}});const t=y.query.code;o.value=t,F.toggleBadge(!0),t?setTimeout(()=>{B.value?.$el?.requestSubmit()},200):u.value=!1}),Y(()=>{F.toggleBadge(!1)});const x=t=>{let a="Other";switch(t){case 200:a="ActivationCodeValid",f("track",{name:"ActivationCodeCompleted",options:{ActivationCode:o.value,BackResponse:a,SignedUp:l.infos!==null}});break;case 404:a="ActivationCodeInvalid",f("track",{name:"ActivationCodeFailed",options:{ActivationCode:o.value,BackResponse:a,SignedUp:l.infos!==null}});break}},b=t=>{setTimeout(()=>{if(l.infos===null){A.promoCode={code:o.value,type:"activation"},t&&(A.offerId=t),C.push({name:k.AUTH_SIGNIN,params:{country:y.params.country}});return}if(t){C.push({name:k.PAYMENT,params:{country:y.params.country,offerId:t,code:String(o.value)}});return}C.push({name:"validateCode"})},2500)},S=Z(),E=async()=>{if(f("track",{name:"ButtonClicked",options:{InternalLocation:"ActivationCode",ButtonType:"ActivationCode",Label:i("global.apply")}}),_.value=!1,!o.value)return;h.value=!0;const t=l.infos!==null?l.sendPromoCode:l.checkPromoCode;try{const a=await t(o.value.trim());p.value=!1,d.value=!0,x(a.status),S.selectedPlan={chargeBeeItemPriceId:"",googleBillingId:"",id:a.data.offerId,itunesId:"",name:"",level:0,periodicity:"Monthly",profilNumber:0,type:"Premium",customPlan:a.data},b()}catch(a){const m=a;if(_.value=!0,d.value=!1,x(m.response?.status??0),m.response?.status===409)u.value=!1,T.value=!0;else if(m.response?.status===402){p.value=!1;const s=m.response.data;if(s.offerId&&!s.planId)d.value=!0,b(s.offerId);else if(s.planId)try{await S.setSelectedPlanById(s.planId,s.pspCoupon),d.value=!0,b(String(s.planId))}catch{u.value=!1,p.value=!0}}else u.value=!1,p.value=!0}finally{h.value=!1}},N=()=>{f("track",{name:"FieldCompletionStarted",options:{FieldName:"ActivationCode",InternalLocation:"ActivationCode"}})};return(t,a)=>(j(),K(X,null,[I(n("div",ie,[n("div",null,[n("h1",{id:"registration_page_content_title_code",class:c(e(v)({textStyle:"titleLarge",color:"textPrimaryInvert"}))},w(e(i)("authentication.form.enterCode")),3),n("div",{class:c(e(v)({marginTop:"20"}))},[g(e(te),{ref_key:"formRef",ref:B,class:c(e(Q)({})),id:"promoCodeForm","validation-schema":e(U),"initial-values":{registrationCode:o.value},onSubmit:E},{default:R(({errors:m,meta:s})=>[n("div",le,[g(se,{modelValue:o.value,"onUpdate:modelValue":a[0]||(a[0]=V=>o.value=V),name:"registrationCode",dataTestid:"activation-code-input",placeholder:e(i)("promoCode.activation.placeholder"),label:e(i)("promoCode.activation.placeholder"),disabled:h.value,error:$.value,validate:_.value&&!!o.value,onFocus:N},null,8,["modelValue","placeholder","label","disabled","error","validate"]),n("div",{id:"button-container",class:c(e(v)({marginTop:8}))},[I(n("p",{class:c(e(v)({textStyle:"baseMedium",color:"textSuccess",marginBottom:6}))},w(e(i)("promoCode.activation.codeValid")),3),[[P,d.value]]),n("div",{class:c(e(v)({width:"-webkit-fill-available"}))},[g(ee,{type:"submit",disabled:h.value||!s.valid||!!m.codePromo,id:"email_form_promoCode_validate","data-testid":"activation-code-submit",size:"xl",visual:"brandInvert",label:e(i)("global.apply")},ae({_:2},[d.value?{name:"append",fn:R(()=>[g(oe,{icon:{name:"check.svg",folder:"offer"},class:"icon",fillColor:"iconWhite"},null,8,["icon"])]),key:"0"}
1:void 0]),1032,["disabled","label"])],2)],2)])]),_:1},8,["class","validation-schema","initial-values"])],2)])],512),[[P,!u.value]]),I(n("div",{class:c(e(v)({marginTop:"4xl"}))},[g(ne)],2),[[P,u.value]])],64))}});export{pe 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.