1import{d as Ue,r as a,c as V,w as He,o as Qe,a as $e,Z as Ge,D as me,K as ye,B as l,z as v,G as r,u as o,H as ne,k as P,E as ie,Q as Ke,W as Ye,A as Ze,U as je,C as d}from"./vendor-vue-Dzwqm9Y9.js";import"./AppHeader.vue_vue_type_style_index_0_scoped_80f3916c_lang-CWJeTQGo.js";import{u as Xe,a as et,J as tt,P as at,Q as nt,_ as j,f as it,R as lt,s as ot,D as rt}from"./index-BB-1BiLf.js";import"./vendor-misc-B-nM3tYW.js";import"./useClipboard-00CrFCqB.js";/* empty css */import{A as st}from"./AuthLayout-DBu6UiEG.js";import{_ as ge}from"./CaptchaChallenge.vue_vue_type_script_setup_true_lang-CagJo7ro.js";import{b as ut}from"./authError-Ch9RozGZ.js";import{e as ct}from"./apiError-BcAuv_LF.js";import{n as ke,i as xe,f as dt}from"./registrationEmailPolicy-BIuq-4e8.js";import{a as be,o as vt,c as pt}from"./oauthAffiliate-CrlUwkd1.js";import{u as ft}from"./vendor-i18n-BuoWFzps.js";const _t={class:"space-y-6"},ht={class:"text-center"},mt={class:"text-2xl font-bold text-gray-900 dark:text-white"},yt={class:"mt-2 text-sm text-gray-500 dark:text-dark-400"},gt={class:"font-medium text-gray-700 dark:text-gray-300"},kt={key:0,class:"rounded-xl border border-amber-200 bg-amber-50 p-4 dark:border-amber-800/50 dark:bg-amber-900/20"},xt={class:"flex items-start gap-3"},bt={class:"flex-shrink-0"},Ct={class:"text-sm text-amber-700 dark:text-amber-400"},wt={class:"font-medium"},At={class:"mt-1"},Et={for:"code",class:"input-label text-center"},St=["disabled"],Rt={class:"input-hint text-center"},Tt={key:0,class:"rounded-xl border border-green-200 bg-green-50 p-4 dark:border-green-800/50 dark:bg-green-900/20"},It={class:"flex items-start gap-3"},Dt={class:"flex-shrink-0"},Vt={class:"text-sm text-green-700 dark:text-green-400"},Nt={key:1},Bt={key:2,class:"space-y-2"},Ot=["disabled"],Mt={key:0,class:"-ml-1 mr-2 h-4 w-4 animate-spin text-white",fill:"none",viewBox:"0 0 24 24"},Pt={class:"text-center"},zt={key:0,type:"button",disabled:"",class:"cursor-not-allowed text-sm text-gray-400 dark:text-dark-500"},Ft=["disabled"],Lt={key:0},qt={key:1},Wt={key:2},Jt=Ue({__name:"EmailVerifyView",setup(Ut){const{t:i,locale:Ce}=ft(),z=Ge(),x=Xe(),S=et(),R=a(!1),F=a(!1),p=a(""),le=a(!1),b=a(""),N=a(0);let h=null;const g=a(""),L=a(""),C=a(""),B=a(""),oe=a(""),q=a(""),W=a(""),O=a(""),J=a("pending_auth_token"),k=a(""),U=a(""),M=a(null),H=a(!1),s=a(!1),T=a(""),m=a(!1),Q=a(""),X=a("cn"),w=a(!1),$=a(""),G=a(""),ee=a("cn"),re=a("Sub2API"),K=a([]),se=a(!1),te=a(null),ae=a(null),y=a(""),I=a(""),f=a(""),D=a(""),A=a(!1),we=V(()=>w.value&&!!$.value&&!!G.value),Y=V(()=>m.value&&!!Q.value||we.value),ue=V(()=>s.value&&!!T.value||Y.value),u=a({code:"",turnstile:""}),Ae=V(()=>u.value.code||u.value.turnstile||""),Ee=V(()=>E()&&s.value),ce=V(()=>E()&&ue.value);He(Ae,(e,n)=>{e&&e!==n&&S.showError(e)}),Qe(async()=>{const e=x.pendingAuthSession,n=sessionStorage.getItem("register_data");if(n)try{const t=JSON.parse(n);g.value=t.email||"",L.value=t.password||"",C.value=t.tencent_captcha_ticket||t.turnstile_token||"",B.value=t.tencent_captcha_randstr||"",oe.value=t.promo_code||"",q.value=t.invitation_code||"",W.value=t.aff_code||be(),O.value=t.pending_auth_token||(e==null?void 0:e.token)||"",J.value=t.pending_auth_token_field||(e==null?void 0:e.token_field)||"pending_auth_token",k.value=t.pending_provider||(e==null?void 0:e.provider)||"",U.value=t.pending_redirect||(e==null?void 0:e.redirect)||"",M.value=t.pending_adoption_decision?{adoptDisplayName:t.pending_adoption_decision.adopt_display_name===!0,adoptAvatar:t.pending_adoption_decision.adopt_avatar===!0}:null,H.value=!!(g.value&&L.value)}catch{H.value=!1}else e&&(O.value=e.token,J.value=e.token_field,k.value=e.provider,U.value=e.redirect||"");try{const t=await tt();s.value=t.turnstile_enabled,T.value=t.turnstile_site_key||"",m.value=t.tencent_captcha_enabled===!0,Q.value=t.tencent_captcha_app_id||"",X.value=t.tencent_captcha_region||"cn",w.value=t.aliyun_captcha_enabled===!0,$.value=t.aliyun_captcha_scene_id||"",G.value=t.aliyun_captcha_prefix||"",ee.value=t.aliyun_captcha_region||"cn",re.value=t.site_name||"Sub2API",K.value=ke(t.registration_email_suffix_whitelist||[]),se.value=t.registration_email_domain_quota_enabled===!0}catch(t){console.error("Failed to load public settings:",t)}H.value&&await fe()}),$e(()=>{h&&(clearInterval(h),h=null)});function Se(e){N.value=e,h&&clearInterval(h),h=setInterval(()=>{N.value>0?N.value--:h&&(clearInterval(h),h=null)},1e3)}function Re(e,n=""){y.value=e,I.value=n,u.value.turnstile=""}function Te(){y.value="",I.value="",u.value.turnstile=i("auth.turnstileExpired")}function Ie(){y.value="",I.value="",u.value.turnstile=i("auth.turnstileFailed")}function De(e,n=""){f.value=e,D.value=n,u.value.turnstile=""}function Ve(){f.value="",D.value="",u.value.turnstile=i("auth.turnstileExpired")}function Ne(){f.value="",D.value="",u.value.turnstile=i("auth.turnstileFailed")}function Be(){var e;f.value="",D.value="",(e=ae.value)==null||e.reset()}async function Oe(){var n;if(!Y.value)return!0;const e=await((n=te.value)==null?void 0:n.verifyAction());return e?(y.value=e.token,I.value=e.randstr,!0):!1}async function Me(){var n;if(!E()||!Y.value)return!0;const e=await((n=ae.value)==null?void 0:n.verifyAction());return e?(f.value=e.token,D.value=e.randstr,!0):!1}function E(){return!!k.value.trim()}function de(){return se.value||E()||!!O.value.trim()}function ve(e){switch(e.trim().toLowerCase()){case"linuxdo":return"/auth/linuxdo/callback";case"oidc":return"/auth/oidc/callback";case"wechat":return"/auth/wechat/callback";default:return"/auth/callback"}}function Pe(e){return e.auth_result==="pending_session"}function ze(e){return e.auth_result==="pending_session"?e:null}function pe(e,n){x.setPendingAuthSession({token:O.value,token_field:J.value,provider:e.trim()||k.value.trim(),redirect:n||U.value||void 0})}async function fe(){var t;F.value=!0,p.value="";let e=!1,n=!1;try{if(!de()&&!xe(g.value,K.value)){p.value=_e(),S.showError(p.value);return}const c={email:g.value,[J.value]:O.value||void 0,turnstile_token:(s.value||w.value)&&(y.value||C.value)||void 0,tencent_captcha_ticket:m.value&&(y.value||C.value)||void 0,tencent_captcha_randstr:m.value&&(I.value||B.value)||void 0};n=!!(c.turnstile_token||c.tencent_captcha_ticket);const _=E()?await at(c):await nt(c);e=!0;const Z=E()?ze(_):null;if(Z){sessionStorage.removeItem("register_data"),pe(Z.provider||k.value,Z.redirect),await z.push(ve(Z.provider||k.value));return}le.value=!0,Se(_.countdown),A.value=!1}catch(c){p.value=he(c,i("auth.sendCodeFailed")),S.showError(p.value)}finally{n&&(Fe(),C.value="",B.value="",y.value="",I.value="",(t=te.value)==null||t.reset(),!e&&s.value&&(A.value=!0)),F.value=!1}}function Fe(){const e=sessionStorage.getItem("register_data");if(e)try{const n=JSON.parse(e);delete n.turnstile_token,delete n.tencent_captcha_ticket,delete n.tencent_captcha_randstr,sessionStorage.setItem("register_data",JSON.stringify(n))}catch{}}async function Le(){if(s.value&&!A.value){A.value=!0;return}if(s.value&&!y.value){u.value.turnstile=i("auth.completeVerification");return}await Oe()&&await fe()}function qe(){return u.value.code="",b.value.trim()?/^\d{6}$/.test(b.value.trim())?!0:(u.value.code=i("auth.invalidCode"),!1):(u.value.code=i("auth.codeRequired"),!1)}async function We(){var e,n,t;if(p.value="",!!qe()){if(!de()&&!xe(g.value,K.value)){p.value=_e(),S.showError(p.value);return}if(await Me()){R.value=!0;try{if(E()){const c={email:g.value,password:L.value,verify_code:b.value.trim(),...(s.value||w.value)&&f.value?{turnstile_token:f.value}:{},...m.value&&f.value?{tencent_captcha_ticket:f.value,tencent_captcha_randstr:D.value}:{},...vt(W.value||be())};q.value&&(c.invitation_code=q.value),((e=M.value)==null?void 0:e.adoptDisplayName)!==void 0&&(c.adopt_display_name=M.value.adoptDisplayName),((n=M.value)==null?void 0:n.adoptAvatar)!==void 0&&(c.adopt_avatar=M.value.adoptAvatar);const{data:_}=await it.post("/auth/oauth/pending/create-account",c);if(Pe(_)){sessionStorage.removeItem("register_data"),pe(_.provider||k.value,_.redirect),await z.push(ve(_.provider||k.value));return}if(!lt(_))throw new Error(i("auth.verifyFailed"));ot(_),await x.setToken(_.access_token),(t=x.clearPendingAuthSession)==null||t.call(x)}else await x.register({email:g.value,password:L.value,verify_code:b.value.trim(),turnstile_token:(s.value||w.value)&&C.value||void 0,tencent_captcha_ticket:m.value&&C.value||void 0,tencent_captcha_randstr:m.value&&B.value||void 0,promo_code:oe.value||void 0,invitation_code:q.value||void 0,...W.value?{aff_code:W.value}:{}});sessionStorage.removeItem("register_data"),pt(),S.showSuccess(i("auth.accountCreatedSuccess",{siteName:re.value})),await z.push(U.value||"/dashboard")}catch(c){p.value=he(c,i("auth.verifyFailed")),S.showError(p.value)}finally{C.value="",B.value="",ce.value&&Be(),R.value=!1}}}}function Je(){sessionStorage.removeItem("register_data"),z.push("/register")}function _e(){const e=ke(K.value);if(e.length===0)return i("auth.emailSuffixNotAllowed");const n=String(Ce.value||"").toLowerCase().startsWith("zh")?"ã":", ";return i("auth.emailSuffixNotAllowedWithAllowed",{suffixes:dt(e,{separator:n,more:t=>i("auth.emailSuffixAllowedMore",{count:t})})})}function he(e,n){return ct(e)==="EMAIL_DOMAIN_REGISTRATION_LIMIT"?i("auth.emailDomainRegistrationLimit"):ut(e,{fallback:n})}return(e,n)=>(d(),me(o(st),null,{footer:ye(()=>[l("button",{onClick:Je,class:"flex items-center gap-2 text-gray-500 transition-colors hover:text-gray-700 dark:text-dark-400 dark:hover:text-gray-300"},[P(j,{name:"arrowLeft",size:"sm"}),ne(" "+r(o(i)("auth.backToRegistration")),1)])]),default:ye(()=>[l("div",_t,[l("div",ht,[l("h2",mt,r(o(i)("auth.verifyYourEmail")),1),l("p",yt,[ne(r(o(i)("auth.sendCodeDesc"))+" ",1),l("span",gt,r(g.value),1)])]),H.value?(d(),v("form",{key:1,onSubmit:je(We,["prevent"]),class:"space-y-5"},[l("div",null,[l("label",Et,r(o(i)("auth.verificationCode")),1),Ke(l("input",{id:"code","onUpdate:modelValue":n[0]||(n[0]=t=>b.value=t),type:"text",required:"",autocomplete:"one-time-code",inputmode:"numeric",maxlength:"6",disabled:R.value,class:Ze(["input py-3 text-center font-mono text-xl tracking-[0.5em]",{"input-error":u.value.code}]),placeholder:"000000"},null,10,St),[[Ye,b.value]]),l("p",Rt,r(o(i)("auth.verificationCodeHint")),1)]),le.value?(d(),v("div",Tt,[l("div",It,[l("div",Dt,[P(j,{name:"checkCircle",size:"md",class:"text-green-500"})]),l("p",Vt,r(o(i)("auth.codeSentSuccess")),1)])])):ie("",!0),Y.value||s.value&&A.value?(d(),v("div",Nt,[P(ge,{ref_key:"turnstileRef",ref:te,"site-key":T.value,"turnstile-enabled":s.value,"turnstile-site-key":T.value,"tencent-enabled":m.value,"tencent-app-id":Q.value,"tencent-region":X.value,"aliyun-enabled":w.value,"aliyun-scene-id":$.value,"aliyun-prefix":G.value,"aliyun-region":ee.value,onVerify:Re,onExpire:Te,onError:Ie},null,8,["site-key","turnstile-enabled","turnstile-site-key","tencent-enabled","tencent-app-id","tencent-region","aliyun-enabled","aliyun-scene-id","aliyun-prefix","aliyun-region"])])):ie("",!0),ce.value?(d(),v("div",Bt,[P(ge,{ref_key:"createAccountTurnstileRef",ref:
1ae,"site-key":T.value,"turnstile-enabled":s.value,"turnstile-site-key":T.value,"tencent-enabled":m.value,"tencent-app-id":Q.value,"tencent-region":X.value,"aliyun-enabled":w.value,"aliyun-scene-id":$.value,"aliyun-prefix":G.value,"aliyun-region":ee.value,onVerify:De,onExpire:Ve,onError:Ne},null,8,["site-key","turnstile-enabled","turnstile-site-key","tencent-enabled","tencent-app-id","tencent-region","aliyun-enabled","aliyun-scene-id","aliyun-prefix","aliyun-region"])])):ie("",!0),l("button",{type:"submit",disabled:R.value||!b.value||Ee.value&&!f.value,class:"btn btn-primary w-full"},[R.value?(d(),v("svg",Mt,[...n[1]||(n[1]=[l("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),l("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):(d(),me(j,{key:1,name:"checkCircle",size:"md",class:"mr-2"})),ne(" "+r(R.value?o(i)("auth.verifying"):o(i)("auth.verifyAndCreate")),1)],8,Ot),l("div",Pt,[N.value>0?(d(),v("button",zt,r(o(i)("auth.resendCountdown",{countdown:N.value})),1)):(d(),v("button",{key:1,type:"button",onClick:Le,disabled:F.value||s.value&&A.value&&!y.value,class:"text-sm text-primary-600 transition-colors hover:text-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:text-primary-400 dark:hover:text-primary-300"},[F.value?(d(),v("span",Lt,r(o(i)("auth.sendingCode")),1)):ue.value&&!A.value?(d(),v("span",qt,r(o(i)("auth.clickToResend")),1)):(d(),v("span",Wt,r(o(i)("auth.resendCode")),1))],8,Ft))])],32)):(d(),v("div",kt,[l("div",xt,[l("div",bt,[P(j,{name:"exclamationCircle",size:"md",class:"text-amber-500"})]),l("div",Ct,[l("p",wt,r(o(i)("auth.sessionExpired")),1),l("p",At,r(o(i)("auth.sessionExpiredDesc")),1)])])]))])]),_:1}))}}),ia=rt(Jt,[["__scopeId","data-v-a6151754"]]);export{ia 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.