1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[8671],{18482(e,a,s){s.r(a),s.d(a,{component:()=>$});var t=s(72361),n=s(68413),r=s(71114),i=s(6702),l=s(20598),o=s(99170),c=s(30464),d=s(46775),u=s(16272),m=s(23507),h=s(74657),x=s(91835),g=s(64096),p=s(72964),f=s(35491),j=s(88330),C=s(61631),v=s(23780),w=s(1755),y=s(54023),_=s(72982),b=s(61309),N=s(46499),R=s(13805),S=s(17720),U=s(22509),L=s(86832),k=s(48367),z=s(81204),A=s(97077),E=s(10032),P=s(76614),J=s(80211),V=s(88901),F=s(19376),I=s(36375),M=s(23973);function W(e){let a=e.trim().toLowerCase(),s=(a.split("@",1)[0]??"").replace(/[^a-z0-9]/g,"");s||(s="user"),/^[a-z]/.test(s)||(s=`u${s}`);let t=0x811c9dc5;for(let e=0;e<a.length;e+=1)t^=a.charCodeAt(e),t=Math.imul(t,0x1000193);let n=((t>>>0)%0x81bf1000).toString(36).padStart(6,"0");return`${s.slice(0,20-n.length)}${n}`}function q(e){let{className:a,initialEmail:s="",emailFirst:r=!1,...o}=e,{t:h}=(0,i.Bd)(),x=(0,m.rM)(),[g,p]=(0,n.useState)(!1),[_,q]=(0,n.useState)(""),[B,$]=(0,n.useState)(""),[Q,T]=(0,n.use
1State)(!1),[D,G]=(0,n.useState)(""),[H,O]=(0,n.useState)(!1),[K,X]=(0,n.useState)(!1),Y=h("Please agree to the legal terms first"),{status:Z}=(0,c.s)(),{isTurnstileEnabled:ee,turnstileSiteKey:ea,turnstileToken:es,setTurnstileToken:et,validateTurnstile:en}=(0,M.A)(),{isTencentCaptchaEnabled:er}=(0,f.E)(),{redirectToLogin:ei,handleLoginSuccess:el}=(0,S.u)(),{isSending:eo,secondsLeft:ec,isActive:ed,sendCode:eu}=function(e){let[a,s]=(0,n.useState)(!1),{isTencentCaptchaEnabled:t,verify:r}=(0,f.E)(),{secondsLeft:i,isActive:o,start:c}=(0,I.L)({initialSeconds:30});return{isSending:a,secondsLeft:i,isActive:o,sendCode:async a=>{if(!a)return l.oR.error(F.Ay.t("Please enter your email first")),!1;if(!t&&e?.validateTurnstile&&!e.validateTurnstile())return!1;let n=await r();if(null===n)return!1;s(!0);try{let s=await (0,u.gA)(a,e?.turnstileToken,"disabled"===n?void 0:n);if(s?.success)return c(),l.oR.success(F.Ay.t("Verification email sent")),!0;return l.oR.error(s?.message||F.Ay.t("Failed to send verification email")),!1}catch(e){return!1}finally{s(!1)}}}}({turnstileToken:es,validateTurnstile:en}),em=(0,L.mN)({resolver:(0,k.u)(V.Ru),mode:"onTouched",defaultValues:{username:"",companyName:"",email:s,password:"",confirmPassword:""}}),eh=em.watch("email"),ex=em.watch("password"),eg=!!Z?.email_verification,ep=!!Z?.user_agreement_enabled,ef=!!Z?.privacy_policy_enabled,ej=ep||ef,eC=Z?.oauth_register_enabled??Z?.data?.oauth_register_enabled??!0,ev=!!Z?.wechat_login,ew=er||!ee||!!es,ey=[{label:h("8-20 characters"),met:ex.length>=8&&ex.length<=20},{label:h("Use a password you do not use elsewhere"),met:ex.length>=8}],e_=(0,n.useMemo)(()=>Z?.wechat_qrcode||Z?.wechat_qr_code||Z?.wechat_qrcode_image_url||Z?.wechat_qr_code_image_url||Z?.wechat_account_qrcode_image_url||Z?.WeChatAccountQRCodeImageURL||Z?.data?.wechat_qrcode||Z?.data?.WeChatAccountQRCodeImageURL||"",[Z]);async function eb(e){if(ej&&!Q)return void l.oR.error(Y);if(eg){if(!e.email)return void l.oR.error(h("Please enter your email"));if(!_)return void l.oR.error(h("Please enter the verification code"))}if(er||en()){p(!0);try{let a=await (0,u.kz)({username:e.username,company_name:e.companyName?.trim()||void 0,password:e.password,email:e.email||void 0,verification_code:_||void 0,aff_code:B.trim()||(0,U.LC)(),promo_code:(0,U.JF)()||void 0,turnstile:es});a?.success?(e.email?(0,j.zx)(e.email):(0,j.PI)(),l.oR.success(h("Account created! Please sign in")),ei()):l.oR.error(a?.message||h("Failed to create account"))}catch(e){}finally{p(!1)}}}async function eN(){await eu(eh||"")}(0,n.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get("aff")?.trim();e?((0,U.Es)(e),$(e)):$((0,U.LC)());let a=new URLSearchParams(window.location.search).get("promo")?.trim();a&&(0,U.Ec)(a)},[]),(0,n.useEffect)(()=>{s&&(em.setValue("email",s),r&&!em.getValues("username").trim()&&em.setValue("username",W(s)))},[r,em,s]);let eR=e=>{O(e),e||(G(""),X(!1))};async function eS(){if(!D.trim())return void l.oR.error(h("Please enter the verification code"));X(!0);try{let e=await (0,u.Cw)(D);e?.success?(await el(e.data),l.oR.success(h("Signed in via WeChat")),eR(!1)):l.oR.error(e?.message||h("Login failed"))}catch(e){l.oR.error(h("Login failed"))}finally{X(!1)}}let eU=eg?(0,t.jsxs)(t.Fragment,{children:[r?null:(0,t.jsx)(A.zB,{control:em.control,name:"email",render:e=>{let{field:a}=e;return(0,t.jsxs)(A.eI,{children:[(0,t.jsx)(A.lR,{children:h("Email (required for verification)")}),(0,t.jsx)(A.MJ,{children:(0,t.jsx)(N.C,{icon:(0,t.jsx)(C.gE4,{}),children:(0,t.jsx)(y.p,{placeholder:h("[email protected]"),type:"email",autoComplete:"email",...a})})}),(0,t.jsx)(A.C5,{})]})}}),(0,t.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto]",children:[(0,t.jsx)("div",{children:(0,t.jsx)(y.p,{placeholder:h("Verification code"),"aria-label":h("Verification code"),value:_,onChange:e=>q(e.target.value),autoComplete:"one-time-code"})}),(0,t.jsx)(d.$,{variant:"outline",type:"button",className:"h-10 rounded-lg sm:min-w-28",disabled:g||eo||ed||!eh||!ew,onClick:eN,children:ed?h("Resend ({{seconds}}s)",{seconds:ec}):eo?(0,t.jsx)(C.krw,{className:"h-4 w-4 animate-spin"}):h("Send code")})]})]}):null;return(0,t.jsxs)(A.lV,{...em,children:[(0,t.jsxs)("form",{onSubmit:em.handleSubmit(eb),className:(0,z.cn)("grid gap-5",a),...o,children:[r&&eU,(0,t.jsx)("div",{className:"grid gap-3",children:(0,t.jsxs)("div",{className:"grid gap-4",children:[(0,t.jsx)(A.zB,{control:em.control,name:"username",render:e=>{let{field:a}=e;return(0,t.jsxs)(A.eI,{children:[(0,t.jsx)(A.lR,{children:h("Username")}),(0,t.jsx)(A.MJ,{children:(0,t.jsx)(N.C,{icon:(0,t.jsx)(C.KJW,{}),children:(0,t.jsx)(y.p,{placeholder:h("Enter your username"),autoComplete:"username",...a})})}),r?(0,t.jsx)(A.Rr,{children:x.signUp.generatedUsernameHint}):null,(0,t.jsx)(A.C5,{})]})}}),(0,t.jsx)(A.zB,{control:em.control,name:"companyName",render:e=>{let{field:a}=e;return(0,t.jsxs)(A.eI,{children:[(0,t.jsx)(A.lR,{children:h("Company Name")}),(0,t.jsx)(A.MJ,{children:(0,t.jsx)(N.C,{icon:(0,t.jsx)(C.t6i,{}),children:(0,t.jsx)(y.p,{placeholder:h("Optional"),autoComplete:"organization",...a})})}),(0,t.jsx)(A.C5,{})]})}})]})}),(0,t.jsxs)("div",{className:"grid gap-3",children:[(0,t.jsxs)("div",{className:"grid gap-4",children:[(0,t.jsx)(A.zB,{control:em.control,name:"password",render:e=>{let{field:a}=e;return(0,t.jsxs)(A.eI,{children:[(0,t.jsx)(A.lR,{children:h("Password")}),(0,t.jsx)(A.MJ,{children:(0,t.jsx)(N.C,{icon:(0,t.jsx)(C.Uzy,{}),children:(0,t.jsx)(E.y,{placeholder:h("8-20 characters"),autoComplete:"new-password",...a})})}),(0,t.jsx)(A.C5,{})]})}}),(0,t.jsx)(A.zB,{control:em.control,name:"confirmPassword",render:e=>{let{field:a}=e;return(0,t.jsxs)(A.eI,{children:[(0,t.jsx)(A.lR,{children:h("Confirm password")}),(0,t.jsx)(A.MJ,{children:(0,t.jsx)(N.C,{icon:(0,t.jsx)(C.Uzy,{}),children:(0,t.jsx)(E.y,{placeholder:h("Repeat password"),autoComplete:"new-password",...a})})}),(0,t.jsx)(A.C5,{})]})}})]}),ex.length>0&&(0,t.jsx)("ul",{className:"space-y-1",children:ey.map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-1.5 text-xs",children:[(0,t.jsx)(C.Jly,{className:(0,z.cn)("size-3.5 shrink-0",e.met?"text-foreground":"text-muted-foreground
1/40")}),(0,t.jsx)("span",{className:(0,z.cn)("text-muted-foreground",e.met&&"text-foreground"),children:e.label})]},e.label))})]}),!r&&eU,(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(b.J,{htmlFor:"invite-code",children:x.signUp.invitationCodeLabel}),(0,t.jsx)(N.C,{icon:(0,t.jsx)(C.pD,{}),children:(0,t.jsx)(y.p,{id:"invite-code",placeholder:x.signUp.invitationCodePlaceholder,autoComplete:"off",value:B,onChange:e=>$(e.target.value)})})]}),ee&&!er&&(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(P.X,{siteKey:ea,onVerify:et})}),(0,t.jsx)(R.G,{status:Z,checked:Q,onCheckedChange:T,className:"mt-1"}),(0,t.jsxs)(v.o,{type:"submit",size:"lg",loading:g,className:"mt-1 w-full justify-center gap-2",disabled:g||ej&&!Q||!ew,children:[!g&&(0,t.jsx)(C.Qpb,{className:"h-4 w-4"}),h("Create account")]}),eC&&(0,t.jsx)(J.m,{status:Z,disabled:g||ej&&!Q,onWeChatLogin:ev?()=>{ej&&!Q?l.oR.error(Y):O(!0)}:void 0,isWeChatLoading:K,className:"pt-2"})]}),ev&&(0,t.jsx)(w.lG,{open:H,onOpenChange:eR,children:(0,t.jsxs)(w.Cf,{className:"max-w-sm",children:[(0,t.jsxs)(w.c7,{className:"text-left",children:[(0,t.jsx)(w.L3,{children:h("WeChat sign in")}),(0,t.jsx)(w.rr,{children:h("Scan the QR code to follow the official account and reply with âéªè¯ç â to receive your verification code.")})]}),e_?(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)("img",{src:e_,alt:h("WeChat login QR code"),className:"h-40 w-40 rounded-md border object-contain"})}):(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:h("QR code is not configured. Please contact support.")}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(b.J,{htmlFor:"wechat-code",children:h("Verification code")}),(0,t.jsx)(y.p,{id:"wechat-code",placeholder:h("Enter the verification code"),value:D,onChange:e=>G(e.target.value),autoComplete:"one-time-code"})]}),(0,t.jsxs)(w.Es,{children:[(0,t.jsx)(d.$,{type:"button",variant:"outline",onClick:()=>eR(!1),disabled:K,children:h("Cancel")}),(0,t.jsxs)(d.$,{type:"button",onClick:eS,disabled:K||!D.trim()||ej&&!Q,className:"gap-2",children:[K?(0,t.jsx)(C.krw,{className:"h-4 w-4 animate-spin"}):null,h("Confirm")]})]})]})})]})}function B(e){let{open:a,onOpenChange:s,email:r}=e,i=(0,m.rM)(),{status:o}=(0,c.s)(),{handleLoginSuccess:h,redirectToLogin:x}=(0,S.u)(),{verify:g}=(0,f.E)(),[p,L]=(0,n.useState)(""),[k,z]=(0,n.useState)(""),[A,E]=(0,n.useState)(!1),[P,J]=(0,n.useState)(!1),[V,F]=(0,n.useState)(!1),[I,M]=(0,n.useState)(60),q=!!(o?.user_agreement_enabled||o?.privacy_policy_enabled);async function B(e){if(6===e.length&&!P&&(!q||A)){J(!0);try{let a,t,n=W(r),o=(a="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789",t=new Uint8Array(18),crypto.getRandomValues(t),Array.from(t,e=>a[e%a.length]).join("")),c=await (0,u.kz)({username:n,password:o,email:r,verification_code:e,aff_code:k.trim()||(0,U.LC)(),promo_code:(0,U.JF)()||void 0});if(!c?.success){c?.message&&l.oR.error(c.message),L("");return}try{let e=await (0,u.iD)({username:n,password:o});if(e.success&&!e.data?.require_2fa){await h(e.data),(0,j.PI)(),l.oR.success(i.signUp.registerSuccess),s(!1);return}}catch(e){}s(!1),x()}catch(e){L("")}finally{J(!1)}}}async function $(){if(I>0||V)return;let e=await g();if(null!==e){F(!0);try{let a=await (0,u.gA)(r,void 0,"disabled"===e?void 0:e);a.success?(l.oR.success(i.signUp.codeSent),M(60)):a.message&&l.oR.error(a.message)}catch(e){}finally{F(!1)}}}(0,n.useEffect)(()=>{if(!a)return;L(""),M(60);let e=new URLSearchParams(window.location.search).get("aff")?.trim();e?((0,U.Es)(e),z(e)):z((0,U.LC)())},[a]),(0,n.useEffect)(()=>{if(!a||I<=0)return;let e=setInterval(()=>M(e=>e-1),1e3);return()=>clearInterval(e)},[a,I]);let Q=6!==p.length||P||q&&!A;return(0,t.jsx)(w.lG,{open:a,onOpenChange:s,children:(0,t.jsxs)(w.Cf,{className:"max-w-sm",children:[(0,t.jsxs)(w.c7,{className:"text-left",children:[(0,t.jsx)(w.L3,{children:i.signUp.codeTitle}),(0,t.jsx)(w.rr,{className:"break-all",children:i.signUp.codeDescription.replace("{email}",r)})]}),(0,t.jsxs)("div",{className:"grid gap-4 pt-1",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(b.J,{children:i.signUp.codeLabel}),(0,t.jsx)(_.UV,{maxLength:6,value:p,autoFocus:!0,onChange:e=>L(e),containerClassName:"justify-center",disabled:P,children:(0,t.jsx)(_.NV,{children:Array.from({length:6},(e,a)=>(0,t.jsx)(_.sF,{index:a},a))})})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(b.J,{htmlFor:"signup-invite-code",children:i.signUp.invitationCodeLabel}),(0,t.jsx)(N.C,{icon:(0,t.jsx)(C.pD,{}),children:(0,t.jsx)(y.p,{id:"signup-invite-code",placeholder:i.signUp.invitationCodePlaceholder,autoComplete:"off",value:k,onChange:e=>z(e.target.value)})})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs leading-relaxed",children:i.signUp.autoAccountHint}),(0,t.jsx)(R.G,{status:o,checked:A,onCheckedChange:E}),(0,t.jsx)(v.o,{type:"button",size:"lg",loading:P,disabled:Q,onClick:()=>void B(p),className:"w-full justify-center",children:i.signUp.completeLabel}),(0,t.jsx)(d.$,{type:"button",variant:"ghost",size:"sm",className:"mx-auto h-8 px-2",disabled:I>0||V,onClick:$,children:I>0?i.signUp.resendCountdown.replace("{seconds}",String(I)):i.signUp.resendLabel})]})]})})}let $=function(){let{t:e}=(0,i.Bd)(),{status:a}
1=(0,c.s)(),s=(0,m.rM)(),[C,v]=(0,n.useState)("email"),[w,y]=(0,n.useState)(()=>(0,j.SW)()??""),[_,b]=(0,n.useState)(!1),{verify:N}=(0,f.E)();(0,o.H)(e("Create an account"));let R=!!(a?.email_verification??a?.data?.email_verification),S=!!(a?.register_enabled??a?.data?.register_enabled),U=!!(a?.password_register_enabled??a?.data?.password_register_enabled),L=!!(a?.self_use_mode_enabled??a?.data?.self_use_mode_enabled),k=R&&S&&U&&!L,z=k&&"email"===C,A=async e=>{let a=(0,j.zx)(e);y(a);let t=await N();if(null===t)return;let n=await (0,u.gA)(a,void 0,"disabled"===t?void 0:t);if(n.success){l.oR.success(s.signUp.codeSent),b(!0);return}throw n.message&&l.oR.error(n.message),Error(n.message||"send code failed")};return(0,t.jsxs)(h.D,{hideBottomGuide:!0,contentClassName:"mx-auto w-full max-w-[400px] space-y-6",children:[z?(0,t.jsx)(x.L,{title:s.signUp.title,description:s.signUp.description,extraContent:(0,t.jsx)(g.X,{status:a,variant:"sign-up"}),initialEmail:w,submitLabel:s.signUp.continueLabel,onContinue:A,secondaryActions:(0,t.jsx)(d.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{v("classic")},children:s.signUp.classicLabel})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h2",{className:"text-xl font-semibold tracking-tight",children:e("Create an account")}
1),k&&"classic"===C?(0,t.jsx)(d.$,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:()=>{v("email")},children:s.signUp.backToModernLabel}):null,(0,t.jsx)(q,{})]}),(0,t.jsx)(B,{open:_,onOpenChange:b,email:w}),z?(0,t.jsx)(p.N,{variant:"sign-up",status:a,className:"text-center text-xs"}):null,(0,t.jsxs)("p",{className:"text-muted-foreground pt-2 text-center text-sm",children:[k?s.signUp.existingAccountPrompt:e("Already have an account?")," ",(0,t.jsx)(r.N_,{to:"/sign-in",className:"text-foreground font-medium underline underline-offset-4 hover:no-underline",children:k?s.signUp.signInLabel:e("Sign in")})]})]})}}}]);
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.