(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[520],{1396:(e,a,t)=>{Promise.resolve().then(t.bind(t,8111)),Promise.resolve().then(t.bind(t,670))},8111:(e,a,t)=>{"use strict";t.d(a,{As:()=>d,AuthShell:()=>h});var s=t(5155),r=t(8173),n=t.n(r);let i="AI Trading Coach";function l(){return(0,s.jsxs)(n(),{href:"/workspace",className:"auth-brand","aria-label":i,children:[(0,s.jsx)("div",{className:"brand-mark","aria-hidden":"true",children:"AI"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"brand-name",children:i}),(0,s.jsx)("div",{className:"brand-sub",children:"Discretionary trading, refined."})]})]})}function o(e){let{rightLink:a}=e;return(0,s.jsxs)("header",{className:"auth-topbar",children:[(0,s.jsx)(l,{}),(0,s.jsx)("span",{className:"topbar-spacer"}),a&&(0,s.jsxs)(n(),{className:"topbar-link",href:a.href,children:[a.label," →"]})]})}function c(){return(0,s.jsxs)("footer",{className:"auth-footer",children:[(0,s.jsx)("span",{children:"\xa9 2026 aitrading.coach"}),(0,s.jsx)("span",{className:"sep",children:"\xb7"}),(0,s.jsx)(n(),{href:"/legal/privacy",children:"Privacy"}),(0,s.jsx)("span",{className:"sep",children:"\xb7"}),(0,s.jsx)(n(),{href:"/legal/terms",children:"Terms"}),(0,s.jsx)("span",{className:"sep",children:"\xb7"}),(0,s.jsxs)("a",{href:"https://status.aitrading.coach",target:"_blank",rel:"noreferrer",children:[(0,s.jsx)("span",{className:"status-dot"}),"Status \xb7 all systems normal"]}),(0,s.jsx)("span",{className:"spacer"}),(0,s.jsx)("span",{children:"v1.4.2"})]})}function d(){return(0,s.jsxs)("span",{className:"trust-pill",children:[(0,s.jsx)("span",{className:"dot"}),"MT5 EA \xb7 ",(0,s.jsx)("strong",{children:"authenticated"})," \xb7 14ms"]})}function u(){return(0,s.jsxs)("div",{className:"auth-illust",style:{flexDirection:"column",gap:24},children:[(0,s.jsxs)("div",{style:{fontFamily:"var(--font-mono)",fontSize:9.5,textTransform:"uppercase",letterSpacing:"0.2em",color:"var(--accent)"},children:["\xa7 ",i]}),(0,s.jsxs)("div",{style:{fontFamily:"var(--font-display)",fontSize:38,lineHeight:1.1,letterSpacing:"-0.025em",color:"var(--ink)",maxWidth:380,fontWeight:400},children:["An AI coach that ",(0,s.jsx)("em",{style:{color:"var(--accent-2)"},children:"draws"})," on your chart."]}),(0,s.jsx)("div",{style:{fontFamily:"var(--font-display)",fontStyle:"italic",fontSize:16,color:"var(--ink-3)",maxWidth:380,lineHeight:1.55,fontWeight:350},children:"Discretionary trading, refined. Mark supply zones, FVG, and Wyckoff phases — without leaving the chart."}),(0,s.jsx)("div",{style:{marginTop:20},children:(0,s.jsx)(d,{})})]})}function h(e){let{children:a,rightLink:t}=e;return(0,s.jsxs)("div",{className:"auth-page",children:[(0,s.jsx)(o,{rightLink:t}),(0,s.jsxs)("main",{className:"auth-main",children:[(0,s.jsx)(u,{}),a]}),(0,s.jsx)(c,{})]})}},670:(e,a,t)=>{"use strict";t.d(a,{LoginForm:()=>d});var s=t(5155),r=t(2115),n=t(8173),i=t.n(n),l=t(6046),o=t(3745),c=t(1069);function d(){let e=(0,l.useRouter)(),{login:a,status:t}=(0,c.A)(),[n,d]=(0,r.useState)("credentials"),[u,h]=(0,r.useState)(""),[m,f]=(0,r.useState)(""),[p,g]=(0,r.useState)(""),[x,v]=(0,r.useState)(!1),[j,y]=(0,r.useState)(null);(0,r.useEffect)(()=>{"authenticated"===t&&e.replace("/workspace")},[t,e]);let b=async t=>{t.preventDefault(),y(null),v(!0);try{if((await a({email:u.trim(),password:m,twoFactorCode:"twofactor"===n?p.replace(/\s/g,""):void 0})).requiresTwoFactor){d("twofactor");return}e.replace("/workspace")}catch(a){let e=a instanceof o.UJ?Array.isArray(a.body.message)?a.body.message.join("; "):a.body.message:"Something went wrong. Try again.";y(e),"twofactor"===n&&/code/i.test(e)&&g("")}finally{v(!1)}};return(0,s.jsxs)("form",{className:"auth-card",onSubmit:b,noValidate:!0,children:[(0,s.jsxs)("div",{className:"auth-eyebrow",children:[(0,s.jsx)("span",{className:"sigil","aria-hidden":"true",children:"\xa7"})," Sign in"]}),(0,s.jsxs)("h1",{className:"auth-title",children:["Welcome ",(0,s.jsx)("em",{children:"back"}),"."]}),(0,s.jsx)("p",{className:"auth-sub",children:"Pick up where the chart left off."}),j&&(0,s.jsxs)("div",{className:"alert alert-error",role:"alert",children:[(0,s.jsx)("span",{className:"alert-icon","aria-hidden":"true",children:"!"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"twofactor"===n?"Code rejected.":"Sign-in failed."})," ",j,"credentials"===n&&(0,s.jsxs)(s.Fragment,{children:[" ",(0,s.jsx)(i(),{href:"/forgot",children:"Reset your password"}),"."]})]})]}),"credentials"===n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"field",children:[(0,s.jsx)("label",{className:"field-label",htmlFor:"login-email",children:"Email"}),(0,s.jsx)("input",{id:"login-email",className:"input",type:"email",autoComplete:"email",placeholder:"you@example.com",required:!0,value:u,onChange:e=>h(e.target.value),disabled:x})]}),(0,s.jsxs)("div",{className:"field",children:[(0,s.jsxs)("label",{className:"field-label",htmlFor:"login-password",children:["Password",(0,s.jsx)("span",{className:"helper",children:(0,s.jsx)(i(),{href:"/forgot",children:"Forgot?"})})]}),(0,s.jsx)("input",{id:"login-password",className:"input",type:"password",autoComplete:"current-password",placeholder:"••••••••••",required:!0,minLength:10,value:m,onChange:e=>f(e.target.value),disabled:x})]}),(0,s.jsxs)("button",{type:"submit",className:"btn btn-primary",disabled:x||!u.trim()||m.length<10,children:[x?"Signing in…":"Log in",(0,s.jsx)("span",{className:"kbd","aria-hidden":"true",children:"↵"})]}),(0,s.jsx)("div",{className:"or-divider","aria-hidden":"true",children:"or"}),(0,s.jsxs)("a",{className:"btn btn-google",href:"/api/auth/google","aria-disabled":"true",children:[(0,s.jsx)("span",{className:"g-logo","aria-hidden":"true"}),"Sign in with Google"]})]}),"twofactor"===n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"alert alert-info",children:[(0,s.jsx)("span",{className:"alert-icon","aria-hidden":"true",children:"2"}),(0,s.jsx)("div",{children:"Two-factor required. Enter the 6-digit code from your authenticator."})]}),(0,s.jsxs)("div",{className:"field",children:[(0,s.jsx)("label",{className:"field-label",htmlFor:"login-otp",children:"Authentication code"}),(0,s.jsx)("input",{id:"login-otp",className:"input input-otp",type:"text",inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9 ]*",placeholder:"000 000",maxLength:7,autoFocus:!0,value:p,onChange:e=>g(e.target.value),disabled:x})]}),(0,s.jsxs)("button",{type:"submit",className:"btn btn-primary",disabled:x||6!==p.replace(/\s/g,"").length,children:[x?"Verifying…":"Verify & continue",(0,s.jsx)("span",{className:"kbd","aria-hidden":"true",children:"↵"})]}),(0,s.jsx)("div",{style:{textAlign:"center",marginTop:14,fontSize:12,color:"var(--ink-4)"},children:(0,s.jsx)("button",{type:"button",onClick:()=>{d("credentials"),g(""),y(null)},style:{background:"none",border:0,color:"var(--accent-2)",cursor:"pointer"},children:"← Use a different account"})})]}),(0,s.jsxs)("div",{className:"auth-meta",children:["Don't have an account? ",(0,s.jsx)(i(),{href:"/signup",children:"Start free trial"})]})]})}},3745:(e,a,t)=>{"use strict";t.d(a,{FH:()=>u,UJ:()=>r,ki:()=>l});let s="https://api.aitrading.coach";class r extends Error{constructor(e,a){super((Array.isArray(a.message)?a.message.join("; "):a.message)||"HTTP ".concat(e)),this.status=e,this.body=a,this.name="ApiException"}}let n=null,i=null;function l(e){n=e}async function o(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{method:t="GET",body:r,signal:i,noRefresh:l,authenticated:o=!0}=a,u={};void 0!==r&&(u["Content-Type"]="application/json"),o&&n&&(u.Authorization="Bearer ".concat(n));let h=await fetch("".concat(s).concat(e),{method:t,headers:u,body:void 0===r?void 0:JSON.stringify(r),credentials:"include",signal:i});if(401===h.status&&o&&!l){let a=await d();if(a)return u.Authorization="Bearer ".concat(a),c(await fetch("".concat(s).concat(e),{method:t,headers:u,body:void 0===r?void 0:JSON.stringify(r),credentials:"include",signal:i}))}return c(h)}async function c(e){let a=await e.text(),t=a?JSON.parse(a):null;if(!e.ok){var s;let n=null!==(s=null==t?void 0:t.error)&&void 0!==s?s:{code:"unknown",message:a||e.statusText,statusCode:e.status};throw new r(e.status,n)}return t}async function d(){return i||(i=(async()=>{try{let e=await o("/v1/auth/refresh",{method:"POST",noRefresh:!0,authenticated:!1});return n=e.accessToken,e.accessToken}catch(e){return n=null,null}finally{i=null}})())}let u={signup:e=>o("/v1/auth/signup",{method:"POST",body:e,authenticated:!1}),verifyEmail:e=>o("/v1/auth/verify-email",{method:"POST",body:e,authenticated:!1}),login:e=>o("/v1/auth/login",{method:"POST",body:e,authenticated:!1}),refresh:()=>o("/v1/auth/refresh",{method:"POST",noRefresh:!0,authenticated:!1}),logout:()=>o("/v1/auth/logout",{method:"POST",noRefresh:!0,authenticated:!1}),forgot:e=>o("/v1/auth/forgot",{method:"POST",body:e,authenticated:!1}),reset:e=>o("/v1/auth/reset",{method:"POST",body:e,authenticated:!1}),enroll2fa:()=>o("/v1/auth/2fa/enroll",{method:"POST"}),verify2fa:e=>o("/v1/auth/2fa/verify",{method:"POST",body:e}),me:()=>o("/v1/auth/me"),health:()=>o("/v1/health",{authenticated:!1,noRefresh:!0})}},1069:(e,a,t)=>{"use strict";t.d(a,{A:()=>o,AuthProvider:()=>l});var s=t(5155),r=t(2115),n=t(3745);let i=(0,r.createContext)(null);function l(e){let{children:a}=e,[t,l]=(0,r.useState)({status:"loading",user:null}),o=(0,r.useCallback)(async()=>{try{let{accessToken:e}=await n.FH.refresh();(0,n.ki)(e);let a=await n.FH.me();l({status:"authenticated",user:a})}catch(e){(0,n.ki)(null),l({status:"anonymous",user:null})}},[]);(0,r.useEffect)(()=>{o()},[o]);let c=(0,r.useCallback)(async e=>{let a=await n.FH.login(e);if("requiresTwoFactor"in a&&a.requiresTwoFactor)return{requiresTwoFactor:!0};if(!("accessToken"in a))throw new n.UJ(500,{code:"unexpected",message:"Login response missing access token",statusCode:500});return(0,n.ki)(a.accessToken),l({status:"authenticated",user:await n.FH.me()}),{}},[]),d=(0,r.useCallback)(async e=>{await n.FH.signup(e),l({status:"anonymous",user:null})},[]),u=(0,r.useCallback)(async()=>{try{await n.FH.logout()}finally{(0,n.ki)(null),l({status:"anonymous",user:null})}},[]),h=(0,r.useMemo)(()=>({...t,login:c,signup:d,logout:u,refresh:o}),[t,c,d,u,o]);return(0,s.jsx)(i.Provider,{value:h,children:a})}function o(){let e=(0,r.useContext)(i);if(!e)throw Error("useAuth must be used inside ");return e}},6046:(e,a,t)=>{"use strict";var s=t(6658);t.o(s,"useRouter")&&t.d(a,{useRouter:function(){return s.useRouter}}),t.o(s,"useSearchParams")&&t.d(a,{useSearchParams:function(){return s.useSearchParams}})}},e=>{var a=a=>e(e.s=a);e.O(0,[173,441,517,358],()=>a(1396)),_N_E=e.O()}]);