1import{u as v,r as a,c as A,A as R,a as w,j as e,B as p,L as f}from"./index-BrT3F50e.js";import{A as P}from"./AuthPageLayout-DkODiInx.js";import{F as l}from"./index-DObnsLqY.js";import{I as y}from"./index-BI2D8MSW.js";import"./useForm-BVKnLQxW.js";import"./row-D-CZ3Hqh.js";import"./useBreakpoint-FD8ghq8d.js";import"./getAllowClear-C4A34otO.js";import"./Input-DOcZa3u3.js";import"./TextArea-BpydDq59.js";function x(r,u){const s=new URLSearchParams(u),i=s.get("error");if(i)return{token:null,workspaceId:null,error:i};const c=new URLSearchParams(r.replace(/^#/,"")).get("token");return c?{token:c,workspaceId:null,error:null}:{token:s.get("token"),workspaceId:s.get("workspace"),error:null}}function D(){const{signin:r}=v(),[u,s]=a.useState(!1),[i,c]=a.useState(()=>!!x(window.location.hash,window.location.search).token);A(i,"Signing you inâ¦");const{message:n}=R.useApp(),[k]=l.useForm(),d=a.useCallback((o,t)=>{t?window.location.href=`/workspace/${t}/create`:o.length>0?window.location.href=`/workspace/${o[0].id}/create`:window.location.href="/"},[]),j=a.useCallback(async o=>{try{s(!0);const t=await w.signIn(o),h=await r(t.token);n.success("Successfully signed in"),d(h)}catch(t){n.error(t?.message||"Failed to sign in")}finally{s(!1)}},[r,n,d]);a.useEffect(()=>{(async()=>{const{token:t,workspaceId:h,error:m}=x(window.location.hash,window.location.search);if(m){n.error(m),window.history.replaceState(null,"",window.location.pathname);return}if(t)try{const g=await r(t);n.success("Successfully signed in"),d(g,h||void 0)}catch(g){n.error(g?.message||"Could not finish signing in"),c(!1)}finally{window.history.replaceState(null,"",window.location.pathname)}})()},[r,n,d]);const b=window.GOOGLE_CLIENT_ID,S=window.GOOGLE_REDIRECT_URL,E=["openid","email","profile","https://www.googleapis.com/auth/contacts.readonly","https://www.googleapis.com/auth/contacts.other.readonly"].join(" "),I=()=>{const o=`https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=${b}&redirect_uri=${S}&scope=${E}&access_type=offline&prompt=consent`;window.location.href=o},L=async()=>{try{const o=await w.appleLogin();o.redirectUrl&&(window.location.href=o.redirectUrl.toString())}catch(o){n.error(o?.message||"Failed to start Apple login")}};return i?null:e.jsxs(P,{title:"Welcome back",subtitle:"Sign in to your account to continue.",children:[e.jsxs(l,{form:k,name:"signin",onFinish:j,layout:"vertical",children:[e.jsx(l.Item,{name:"email",label:"Email",rules:[{required:!0,message:"Please enter your email"},{type:"email",message:"Please enter a valid email"}],children:e.jsx(y,{placeholder:"Enter your email",style:{height:44,borderRadius:10}})}),e.jsx(l.Item,{name:"password",label:"Password",rules:[{required:!0,message:"Please enter your password"}],children:e.jsx(y.Password,{placeholder:"Enter your password",style:{height:44,borderRadius:10}})}),e.jsx(l.Item,{style:{marginBottom:12},children:e.jsx(p,{type:"primary",htmlType:"submit",block:!0,loading:u,style:{height:48,borderRadius:10,fontWeight:600,fontSize:16},children:"Sign In"})}),e.jsx("div",{style:{textAlign:"center",marginBottom:20},children:e.jsx(f,{to:"/restore-password",style:{fontSize:13,color:"rgba(28, 29, 31, 0.5)"},children:"Forgot password?"})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,margin:"4px 0 20px"},children:[e.jsx("div",{style:{flex:1,height:1,background:"#E4E4E4"}}),e.jsx("span",{style:{fontSize:12,color:"rgba(28, 29, 31, 0.35)",fontWeight:500},children:"or"}),e.jsx("div",{style:{flex:1,height:1,background:"#E4E4E4"}})]}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20},children:[e.jsx(p,{block:!0,onClick:I,style:{height:44,borderRadius:10,fontWeight:500},children:"Google"}),e.jsx(p,{block:!0,onClick:L,style:{height:44,borderRadius:10,fontWeight:500},children:"Apple"})]}),e.jsx("div",{style:{textAlign:"center"},children:e.jsxs("span",{style:{fontSize:13,color:"rgba(28, 29, 31, 0.5)"},children:["Don't have an account?"," ",e.jsx(f,{to:"/registration",style:{color:"#2F6DFB",fontWeight:500},children:"Sign Up"})]})})]})}export{D as SignInPage};
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.