@wacht/jsx 0.0.1-alpha.53 → 0.0.1-alpha.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -204,7 +204,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
204
204
  *
205
205
  * This source code is licensed under the ISC license.
206
206
  * See the LICENSE file in the root directory of this source tree.
207
- */const Nh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],yt=je("LoaderCircle",Nh);/**
207
+ */const Nh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],wt=je("LoaderCircle",Nh);/**
208
208
  * @license lucide-react v0.474.0 - ISC
209
209
  *
210
210
  * This source code is licensed under the ISC license.
@@ -926,7 +926,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
926
926
  `,wr=l.span`
927
927
  color: var(--color-danger);
928
928
  margin-left: 2px;
929
- `;function Gf(){var B,H,G,X,oe,te,ce,Q,me,xe,de,U,le,K,Z,re,ge;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=Wc(),{signIn:s}=zr("oauth"),{deployment:a}=we(),{navigate:h}=rt(),{session:f,refetch:c,loading:u}=Qe(),[d,p]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,b]=i.useState(!1),[k,$]=i.useState(void 0),[S,C]=i.useState(null),[z,w]=i.useState(null),[y,g]=i.useState(!1),_=((B=a==null?void 0:a.restrictions)==null?void 0:B.sign_up_mode)==="restricted",E=((H=a==null?void 0:a.restrictions)==null?void 0:H.sign_up_mode)==="waitlist",j=((X=(G=a==null?void 0:a.auth_settings)==null?void 0:G.multi_session_support)==null?void 0:X.enabled)??!1;i.useEffect(()=>{var ue;if(!u&&(f!=null&&f.active_signin)&&!j&&!y){g(!0);let ee=new URLSearchParams(window.location.search).get("redirect_uri");ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee&&h(ee)}},[f,u,j,a,h,y]),i.useEffect(()=>{var V;if(!a)return;const ee=new URLSearchParams(window.location.search).get("invite_token");if(E&&!ee){g(!0);const F=((V=a.ui_settings)==null?void 0:V.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;h(F);return}ee&&!S&&r&&(w(ee),r.validateDeploymentInvitation(ee).then(F=>{C(F),F.valid&&p(ne=>({...ne,first_name:F.first_name||ne.first_name,last_name:F.last_name||ne.last_name,email:F.email||ne.email}))}).catch(F=>{console.error("Failed to validate invitation:",F)}))},[a,E,h,S,r]);const[T,R]=i.useState(!1),[M,I]=i.useState(""),O=ue=>{let{name:ee,value:V}=ue.target;ee==="phone_number"?V=V.replace(/[^0-9-]/g,""):ee==="email"&&(V=V.toLowerCase()),p(F=>({...F,[ee]:V})),x(F=>({...F,[ee]:""}))},N=()=>{p({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),R(!1),I(""),n()},D=async ue=>{if(ue.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",d),t||v)return;const ee={},V=/^[a-zA-Z]{3,30}$/,F=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,ne=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,be=/^\d{7,15}$/,Me=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!d.first_name?ee.first_name="First name is required":d.first_name&&!V.test(d.first_name)&&(ee.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!d.last_name?ee.last_name="Last name is required":d.last_name&&!V.test(d.last_name)&&(ee.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!d.username?ee.username="Username is required":d.username&&!F.test(d.username)&&(ee.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!d.email?ee.email="Email address is required":d.email&&!ne.test(d.email)&&(ee.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!d.phone_number?ee.phone_number="Phone number is required":d.phone_number&&!be.test(d.phone_number)&&(ee.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(d.password?Me.test(d.password)||(ee.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):ee.password="Password is required"),x(ee),Object.keys(ee).length>0){console.log("Signup validation failed. Errors:",ee);return}console.log("Signup validation passed"),b(!0);try{const Ce={...d};d.phone_number&&k&&(Ce.phone_country_code=k),z&&(Ce.invite_token=z),console.log("Submitting signup data:",Ce),console.log("Phone number:",Ce.phone_number),console.log("Phone country code:",Ce.phone_country_code),await r.create(Ce)}catch(Ce){x({submit:Ce.message})}finally{b(!1)}},L=async ue=>{if(!(t||v)){b(!0);try{const V=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:F}=await s.create({provider:ue.provider,redirectUri:V});F&&typeof F=="object"&&"oauth_url"in F&&(window.location.href=F.oauth_url)}catch(ee){x({submit:ee.message})}finally{b(!1)}}},P=(a==null?void 0:a.social_connections.filter(ue=>ue.enabled))||[],A=a==null?void 0:a.auth_settings,q=!!((oe=A==null?void 0:A.first_name)!=null&&oe.enabled&&((te=A==null?void 0:A.last_name)!=null&&te.enabled)),Y=async ue=>{var V;if(ue.preventDefault(),t||v)return;b(!0);const ee={};if(!M){ee.otp="OTP code is required",x(ee),b(!1);return}x(ee);try{const F=await r.completeVerification(M);"data"in F&&((V=F.data)!=null&&V.active_signin)&&await c()}catch(F){console.error("Verification failed:",F)}finally{b(!1)}};return i.useEffect(()=>{var ue;if(o){if(o.completed){let ee=new URLSearchParams(window.location.search).get("redirect_uri");if(ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signup_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee){let V;try{V=new URL(ee)}catch{V=new URL(ee,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&V.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(V.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,T,a,f,h]),u?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(yt,{size:32})})]})}):y?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(yt,{size:32})})]})}):_?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Ln,{children:e.jsx(Dn,{children:"Sign up Restricted!"})}),e.jsx(Ff,{children:e.jsx(Bf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Uf,{children:e.jsxs(Wf,{children:["Need assistance?"," ",e.jsx(Vf,{href:(ce=a==null?void 0:a.ui_settings)!=null&&ce.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(fe,{children:e.jsx(ho,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Ln,{children:[e.jsxs(Dn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(Fa,{children:(o==null?void 0:o.current_step)==="verify_email"?`${d.email} to continue to ${(Q=a==null?void 0:a.ui_settings)==null?void 0:Q.app_name}`:`${d.phone_number} to continue to ${(me=a==null?void 0:a.ui_settings)==null?void 0:me.app_name}`})]}),e.jsxs(Ba,{style:{gap:"15px"},onSubmit:Y,noValidate:!0,children:[e.jsx(qt,{onComplete:async ue=>{I(ue)},onResend:async()=>{const ue=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ue})},error:m.otp,isSubmitting:v}),e.jsx(Ua,{type:"submit",disabled:v||t||!M,children:v?"Verifying...":`Continue to ${(xe=a==null?void 0:a.ui_settings)==null?void 0:xe.app_name}`})]}),e.jsxs(Wa,{children:["Having trouble?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Nn,{onClick:()=>{N()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(Ln,{children:[e.jsx(Dn,{children:"Create your account"}),e.jsx(Fa,{children:S!=null&&S.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),P.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Bs,{connections:P,callback:L}),e.jsx(Af,{children:e.jsx(Lf,{children:"or"})})]}),e.jsxs(Ba,{onSubmit:D,noValidate:!0,children:[(((de=A==null?void 0:A.first_name)==null?void 0:de.enabled)||((U=A==null?void 0:A.last_name)==null?void 0:U.enabled))&&e.jsxs(Df,{$isBothEnabled:q,children:[((le=A==null?void 0:A.first_name)==null?void 0:le.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"first_name",children:["First name",((K=A==null?void 0:A.first_name)==null?void 0:K.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:d.first_name,onChange:O,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Kt,{children:m.first_name})]}),((Z=A==null?void 0:A.last_name)==null?void 0:Z.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"last_name",children:["Last name",((re=A==null?void 0:A.last_name)==null?void 0:re.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:d.last_name,onChange:O,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Kt,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:d.username,onChange:O,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Kt,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",maxLength:320,value:d.email,onChange:O,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(S==null?void 0:S.valid)&&!!(S!=null&&S.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Kt,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(wr,{children:"*"})]}),e.jsx(oo,{value:d.phone_number,onChange:O,error:m.phone_number,countryCode:k,setCountryCode:$}),m.phone_number&&e.jsx(Kt,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(wr,{children:"*"})]}),e.jsx(Nf,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:d.password,onChange:O,placeholder:"Enter your password","aria-invalid":!!m.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),m.password&&e.jsx(Kt,{children:m.password})]}),m.submit&&e.jsx(Kt,{children:m.submit}),e.jsx(Ua,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(Wa,{children:["Already have an account?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:`${(ge=a.ui_settings)==null?void 0:ge.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const Tl=i.createContext(void 0),Ml=()=>{const t=i.useContext(Tl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Hf=l.div`
929
+ `;function Gf(){var B,H,G,X,oe,te,ce,Q,me,xe,de,U,le,K,Z,re,ge;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=Wc(),{signIn:s}=zr("oauth"),{deployment:a}=we(),{navigate:h}=rt(),{session:f,refetch:c,loading:u}=Qe(),[d,p]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,b]=i.useState(!1),[k,$]=i.useState(void 0),[S,C]=i.useState(null),[z,w]=i.useState(null),[y,g]=i.useState(!1),_=((B=a==null?void 0:a.restrictions)==null?void 0:B.sign_up_mode)==="restricted",E=((H=a==null?void 0:a.restrictions)==null?void 0:H.sign_up_mode)==="waitlist",j=((X=(G=a==null?void 0:a.auth_settings)==null?void 0:G.multi_session_support)==null?void 0:X.enabled)??!1;i.useEffect(()=>{var ue;if(!u&&(f!=null&&f.active_signin)&&!j&&!y){g(!0);let ee=new URLSearchParams(window.location.search).get("redirect_uri");ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee&&h(ee)}},[f,u,j,a,h,y]),i.useEffect(()=>{var V;if(!a)return;const ee=new URLSearchParams(window.location.search).get("invite_token");if(E&&!ee){g(!0);const F=((V=a.ui_settings)==null?void 0:V.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;h(F);return}ee&&!S&&r&&(w(ee),r.validateDeploymentInvitation(ee).then(F=>{C(F),F.valid&&p(ne=>({...ne,first_name:F.first_name||ne.first_name,last_name:F.last_name||ne.last_name,email:F.email||ne.email}))}).catch(F=>{console.error("Failed to validate invitation:",F)}))},[a,E,h,S,r]);const[T,R]=i.useState(!1),[M,I]=i.useState(""),O=ue=>{let{name:ee,value:V}=ue.target;ee==="phone_number"?V=V.replace(/[^0-9-]/g,""):ee==="email"&&(V=V.toLowerCase()),p(F=>({...F,[ee]:V})),x(F=>({...F,[ee]:""}))},N=()=>{p({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),R(!1),I(""),n()},D=async ue=>{if(ue.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",d),t||v)return;const ee={},V=/^[a-zA-Z]{3,30}$/,F=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,ne=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,be=/^\d{7,15}$/,Me=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!d.first_name?ee.first_name="First name is required":d.first_name&&!V.test(d.first_name)&&(ee.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!d.last_name?ee.last_name="Last name is required":d.last_name&&!V.test(d.last_name)&&(ee.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!d.username?ee.username="Username is required":d.username&&!F.test(d.username)&&(ee.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!d.email?ee.email="Email address is required":d.email&&!ne.test(d.email)&&(ee.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!d.phone_number?ee.phone_number="Phone number is required":d.phone_number&&!be.test(d.phone_number)&&(ee.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(d.password?Me.test(d.password)||(ee.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):ee.password="Password is required"),x(ee),Object.keys(ee).length>0){console.log("Signup validation failed. Errors:",ee);return}console.log("Signup validation passed"),b(!0);try{const Ce={...d};d.phone_number&&k&&(Ce.phone_country_code=k),z&&(Ce.invite_token=z),console.log("Submitting signup data:",Ce),console.log("Phone number:",Ce.phone_number),console.log("Phone country code:",Ce.phone_country_code),await r.create(Ce)}catch(Ce){x({submit:Ce.message})}finally{b(!1)}},L=async ue=>{if(!(t||v)){b(!0);try{const V=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:F}=await s.create({provider:ue.provider,redirectUri:V});F&&typeof F=="object"&&"oauth_url"in F&&(window.location.href=F.oauth_url)}catch(ee){x({submit:ee.message})}finally{b(!1)}}},P=(a==null?void 0:a.social_connections.filter(ue=>ue.enabled))||[],A=a==null?void 0:a.auth_settings,q=!!((oe=A==null?void 0:A.first_name)!=null&&oe.enabled&&((te=A==null?void 0:A.last_name)!=null&&te.enabled)),Y=async ue=>{var V;if(ue.preventDefault(),t||v)return;b(!0);const ee={};if(!M){ee.otp="OTP code is required",x(ee),b(!1);return}x(ee);try{const F=await r.completeVerification(M);"data"in F&&((V=F.data)!=null&&V.active_signin)&&await c()}catch(F){console.error("Verification failed:",F)}finally{b(!1)}};return i.useEffect(()=>{var ue;if(o){if(o.completed){let ee=new URLSearchParams(window.location.search).get("redirect_uri");if(ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signup_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee){let V;try{V=new URL(ee)}catch{V=new URL(ee,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&V.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(V.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,T,a,f,h]),u?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(wt,{size:32})})]})}):y?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(wt,{size:32})})]})}):_?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Ln,{children:e.jsx(Dn,{children:"Sign up Restricted!"})}),e.jsx(Ff,{children:e.jsx(Bf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Uf,{children:e.jsxs(Wf,{children:["Need assistance?"," ",e.jsx(Vf,{href:(ce=a==null?void 0:a.ui_settings)!=null&&ce.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(fe,{children:e.jsx(ho,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Ln,{children:[e.jsxs(Dn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(Fa,{children:(o==null?void 0:o.current_step)==="verify_email"?`${d.email} to continue to ${(Q=a==null?void 0:a.ui_settings)==null?void 0:Q.app_name}`:`${d.phone_number} to continue to ${(me=a==null?void 0:a.ui_settings)==null?void 0:me.app_name}`})]}),e.jsxs(Ba,{style:{gap:"15px"},onSubmit:Y,noValidate:!0,children:[e.jsx(qt,{onComplete:async ue=>{I(ue)},onResend:async()=>{const ue=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ue})},error:m.otp,isSubmitting:v}),e.jsx(Ua,{type:"submit",disabled:v||t||!M,children:v?"Verifying...":`Continue to ${(xe=a==null?void 0:a.ui_settings)==null?void 0:xe.app_name}`})]}),e.jsxs(Wa,{children:["Having trouble?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Nn,{onClick:()=>{N()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(Ln,{children:[e.jsx(Dn,{children:"Create your account"}),e.jsx(Fa,{children:S!=null&&S.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),P.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Bs,{connections:P,callback:L}),e.jsx(Af,{children:e.jsx(Lf,{children:"or"})})]}),e.jsxs(Ba,{onSubmit:D,noValidate:!0,children:[(((de=A==null?void 0:A.first_name)==null?void 0:de.enabled)||((U=A==null?void 0:A.last_name)==null?void 0:U.enabled))&&e.jsxs(Df,{$isBothEnabled:q,children:[((le=A==null?void 0:A.first_name)==null?void 0:le.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"first_name",children:["First name",((K=A==null?void 0:A.first_name)==null?void 0:K.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:d.first_name,onChange:O,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Kt,{children:m.first_name})]}),((Z=A==null?void 0:A.last_name)==null?void 0:Z.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"last_name",children:["Last name",((re=A==null?void 0:A.last_name)==null?void 0:re.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:d.last_name,onChange:O,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Kt,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:d.username,onChange:O,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Kt,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",maxLength:320,value:d.email,onChange:O,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(S==null?void 0:S.valid)&&!!(S!=null&&S.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Kt,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(wr,{children:"*"})]}),e.jsx(oo,{value:d.phone_number,onChange:O,error:m.phone_number,countryCode:k,setCountryCode:$}),m.phone_number&&e.jsx(Kt,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(wr,{children:"*"})]}),e.jsx(Nf,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:d.password,onChange:O,placeholder:"Enter your password","aria-invalid":!!m.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),m.password&&e.jsx(Kt,{children:m.password})]}),m.submit&&e.jsx(Kt,{children:m.submit}),e.jsx(Ua,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(Wa,{children:["Already have an account?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:`${(ge=a.ui_settings)==null?void 0:ge.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const Tl=i.createContext(void 0),Ml=()=>{const t=i.useContext(Tl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Hf=l.div`
930
930
  position: fixed;
931
931
  inset: 0;
932
932
  background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
@@ -1006,7 +1006,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1006
1006
  height: 1px;
1007
1007
  background-color: var(--color-border);
1008
1008
  width: 100%;
1009
- `,wt=l.form`
1009
+ `,yt=l.form`
1010
1010
  display: flex;
1011
1011
  flex-direction: column;
1012
1012
  gap: var(--space-md);
@@ -1299,7 +1299,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1299
1299
  &:hover {
1300
1300
  text-decoration: underline;
1301
1301
  }
1302
- `;function yg({onBack:t}){const{deployment:r}=we(),{navigate:o}=rt(),[n,s]=i.useState("start"),[a,h]=i.useState(""),[f,c]=i.useState(""),[u,d]=i.useState(""),[p,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:b,verifyOtp:k,resetPassword:$}=Zc(),[S,C]=i.useState(!1),[z,w]=i.useState(null),y=async j=>{if(j.preventDefault(),!!a){C(!0),w(null);try{await b(a),s("otp")}catch(T){w(T)}finally{C(!1)}}},g=async j=>{if(j.preventDefault(),f.length===6){C(!0),w(null);try{const T=await k(a,f);T.data&&(d(T.data.token),s("reset"))}catch(T){w(T)}finally{C(!1)}}},_=async j=>{var T,R;if(j.preventDefault(),p===x&&!(p.length<8)){C(!0),w(null);try{const M=await $(u,p);if(M.data){const I=M.data,O=I.signin_attempts&&I.signin_attempts.length>0?I.signin_attempts[I.signin_attempts.length-1]:null;if(O&&!O.completed){const N=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(N){const D=new URL(N,window.location.origin);D.searchParams.set("signin_attempt_id",O.id),o(D.toString())}else t()}else{const N=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(N)}}}catch(M){w(M)}finally{C(!1)}}},E=()=>e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsx(fo,{children:e.jsx(go,{children:"Forgot Password"})}),e.jsx(xg,{onClick:()=>s("email"),disabled:S,children:"Reset your password"}),e.jsx(vg,{children:e.jsx(bg,{children:"Or, sign in with another method"})}),e.jsx(Hl,{}),e.jsxs(mo,{children:[e.jsxs(Br,{children:["Unable to reset password? ",e.jsx(Ur,{href:"/contact",children:"Get help"})]}),e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(fe,{children:e.jsxs(mg,{children:[n==="start"&&E(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Forgot Password"}),e.jsx(Fn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(wt,{onSubmit:y,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email Address"}),e.jsx(se,{type:"email",id:"email",value:a,onChange:j=>h(j.target.value),placeholder:"Enter your email",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Sending...":"Send Code"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Enter Verification Code"}),e.jsxs(Fn,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(wt,{onSubmit:g,noValidate:!0,children:[e.jsx(qt,{onComplete:j=>c(j),isSubmitting:S,error:z==null?void 0:z.message,onResend:async()=>{await b(a)}}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Verifying...":"Verify"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Reset Password"}),e.jsx(Fn,{children:"Create a new password for your account."})]}),e.jsxs(wt,{onSubmit:_,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"password",children:"New Password"}),e.jsx(se,{type:"password",id:"password",value:p,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(se,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Resetting...":"Reset Password"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const wg=l.div`
1302
+ `;function yg({onBack:t}){const{deployment:r}=we(),{navigate:o}=rt(),[n,s]=i.useState("start"),[a,h]=i.useState(""),[f,c]=i.useState(""),[u,d]=i.useState(""),[p,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:b,verifyOtp:k,resetPassword:$}=Zc(),[S,C]=i.useState(!1),[z,w]=i.useState(null),y=async j=>{if(j.preventDefault(),!!a){C(!0),w(null);try{await b(a),s("otp")}catch(T){w(T)}finally{C(!1)}}},g=async j=>{if(j.preventDefault(),f.length===6){C(!0),w(null);try{const T=await k(a,f);T.data&&(d(T.data.token),s("reset"))}catch(T){w(T)}finally{C(!1)}}},_=async j=>{var T,R;if(j.preventDefault(),p===x&&!(p.length<8)){C(!0),w(null);try{const M=await $(u,p);if(M.data){const I=M.data,O=I.signin_attempts&&I.signin_attempts.length>0?I.signin_attempts[I.signin_attempts.length-1]:null;if(O&&!O.completed){const N=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(N){const D=new URL(N,window.location.origin);D.searchParams.set("signin_attempt_id",O.id),o(D.toString())}else t()}else{const N=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(N)}}}catch(M){w(M)}finally{C(!1)}}},E=()=>e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsx(fo,{children:e.jsx(go,{children:"Forgot Password"})}),e.jsx(xg,{onClick:()=>s("email"),disabled:S,children:"Reset your password"}),e.jsx(vg,{children:e.jsx(bg,{children:"Or, sign in with another method"})}),e.jsx(Hl,{}),e.jsxs(mo,{children:[e.jsxs(Br,{children:["Unable to reset password? ",e.jsx(Ur,{href:"/contact",children:"Get help"})]}),e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(fe,{children:e.jsxs(mg,{children:[n==="start"&&E(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Forgot Password"}),e.jsx(Fn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(yt,{onSubmit:y,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email Address"}),e.jsx(se,{type:"email",id:"email",value:a,onChange:j=>h(j.target.value),placeholder:"Enter your email",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Sending...":"Send Code"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Enter Verification Code"}),e.jsxs(Fn,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(yt,{onSubmit:g,noValidate:!0,children:[e.jsx(qt,{onComplete:j=>c(j),isSubmitting:S,error:z==null?void 0:z.message,onResend:async()=>{await b(a)}}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Verifying...":"Verify"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Reset Password"}),e.jsx(Fn,{children:"Create a new password for your account."})]}),e.jsxs(yt,{onSubmit:_,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"password",children:"New Password"}),e.jsx(se,{type:"password",id:"password",value:p,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(se,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Resetting...":"Reset Password"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const wg=l.div`
1303
1303
  max-width: 360px;
1304
1304
  width: 360px;
1305
1305
  padding: var(--space-2xl);
@@ -1461,7 +1461,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1461
1461
  }
1462
1462
  `,Hg=l(se)`
1463
1463
  padding: var(--space-sm) var(--space-md);
1464
- `;function Yl({onVerify:t,onBack:r,loading:o}){const[n,s]=i.useState(""),[a,h]=i.useState(""),f=u=>{if(u.preventDefault(),n.length!==4){h("Please enter the last 4 digits of your phone number");return}t(n)},c=u=>{const d=u.target.value.replace(/\D/g,"").slice(0,4);s(d),h("")};return e.jsx(fe,{children:e.jsxs(Dg,{children:[e.jsx(Oe,{}),e.jsxs(Ng,{children:[e.jsx(Fg,{children:"Verify your phone number"}),e.jsx(Bg,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(wt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Hg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!a,autoFocus:!0}),a&&e.jsx(Ug,{children:a})]}),e.jsx(Wg,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(Vg,{children:e.jsx(Gg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const qg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Yg=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Zg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),Un=l.div`
1464
+ `;function Yl({onVerify:t,onBack:r,loading:o}){const[n,s]=i.useState(""),[a,h]=i.useState(""),f=u=>{if(u.preventDefault(),n.length!==4){h("Please enter the last 4 digits of your phone number");return}t(n)},c=u=>{const d=u.target.value.replace(/\D/g,"").slice(0,4);s(d),h("")};return e.jsx(fe,{children:e.jsxs(Dg,{children:[e.jsx(Oe,{}),e.jsxs(Ng,{children:[e.jsx(Fg,{children:"Verify your phone number"}),e.jsx(Bg,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(yt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Hg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!a,autoFocus:!0}),a&&e.jsx(Ug,{children:a})]}),e.jsx(Wg,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(Vg,{children:e.jsx(Gg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const qg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Yg=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Zg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),Un=l.div`
1465
1465
  max-width: 380px;
1466
1466
  width: 380px;
1467
1467
  padding: var(--space-3xl);
@@ -1522,7 +1522,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1522
1522
  }
1523
1523
  `,Jg=l(se)`
1524
1524
  padding: var(--space-sm) var(--space-md);
1525
- `;function Zl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=we(),[a,h]=i.useState(""),[f,c]=i.useState({}),[u,d]=i.useState(!1),[p,m]=i.useState(null),[x,v]=i.useState(!0),[b,k]=i.useState(!1),[$,S]=i.useState(""),[C,z]=i.useState(!1),{navigate:w}=rt(),y=(r==null?void 0:r.available_2fa_methods)||[],g=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(qg,{}),available:y.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Yg,{}),available:y.includes("phone_otp"),phoneNumber:$},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Zg,{}),available:y.includes("backup_code")}].filter(R=>R.available),_=async R=>{m(R),v(!1),R==="phone_otp"&&k(!0)},E=async R=>{var M,I;if(r){d(!0);try{const O=await n({strategy:"phone_otp",lastDigits:R});O&&"data"in O&&((M=O.data)!=null&&M.otp_sent)?((I=O.data)!=null&&I.masked_phone&&S(O.data.masked_phone),k(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{d(!1)}}},j=async(R,M)=>{if(R.preventDefault(),u)return;const I=M||a,O={};if(I?p==="authenticator"&&I.length!==6?O.code="Authentication code must be 6 digits":p==="phone_otp"&&I.length!==6&&(O.code="SMS code must be 6 digits"):O.code="Verification code is required",c(O),!(Object.keys(O).length>0)){d(!0);try{await o(I)}catch(N){c({submit:N.message})}finally{d(!1)}}},T=R=>{let M=R.target.value;p!=="backup_code"&&(M=M.replace(/\D/g,"").slice(0,6)),h(M),c(I=>({...I,code:""}))};return i.useEffect(()=>{var R;if(r.completed){z(!0);let M=new URLSearchParams(window.location.search).get("redirect_uri");if(M||(M=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!M&&(s!=null&&s.frontend_host)&&(M=`https://${s.frontend_host}`),M){let I;try{I=new URL(M)}catch{I=new URL(M,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(I.toString())}return}},[r,s]),C?e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsx(Qg,{children:e.jsx(yt,{size:32})})]})}):x?g.length===0?e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Set Up Two-Factor Authentication"}),e.jsx(Ya,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(Ka,{children:[t&&e.jsx("div",{children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(ql,{methods:g,onSelectMethod:_,onBack:t}):b&&p==="phone_otp"?e.jsx(Yl,{onVerify:E,onBack:()=>{k(!1),v(!0),m(null)},loading:u}):e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Two-factor authentication"}),e.jsxs(Ya,{children:[p==="authenticator"&&"Enter the 6-digit code from your authenticator app",p==="phone_otp"&&`Enter the 6-digit code sent to your phone ${$}`,p==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(wt,{onSubmit:j,noValidate:!0,children:[p==="backup_code"?e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"code",children:"Backup code"}),e.jsx(Jg,{type:"text",id:"code",name:"code",value:a,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Za,{children:f.code})]}):e.jsx(qt,{onComplete:async R=>{if(h(R),p!=="backup_code"){const M=new Event("submit",{bubbles:!0,cancelable:!0});await j(M,R)}},onResend:p==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:$.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:f.code,isSubmitting:u}),e.jsxs("div",{children:[f.submit&&e.jsx(Za,{children:f.submit}),e.jsx(Xg,{type:"submit",disabled:u||!a,children:u?"Verifying...":"Verify"})]})]}),e.jsxs(Ka,{children:[e.jsx(Wr,{onClick:()=>{v(!0),m(null),h(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Wn=l.div`
1525
+ `;function Zl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=we(),[a,h]=i.useState(""),[f,c]=i.useState({}),[u,d]=i.useState(!1),[p,m]=i.useState(null),[x,v]=i.useState(!0),[b,k]=i.useState(!1),[$,S]=i.useState(""),[C,z]=i.useState(!1),{navigate:w}=rt(),y=(r==null?void 0:r.available_2fa_methods)||[],g=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(qg,{}),available:y.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Yg,{}),available:y.includes("phone_otp"),phoneNumber:$},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Zg,{}),available:y.includes("backup_code")}].filter(R=>R.available),_=async R=>{m(R),v(!1),R==="phone_otp"&&k(!0)},E=async R=>{var M,I;if(r){d(!0);try{const O=await n({strategy:"phone_otp",lastDigits:R});O&&"data"in O&&((M=O.data)!=null&&M.otp_sent)?((I=O.data)!=null&&I.masked_phone&&S(O.data.masked_phone),k(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{d(!1)}}},j=async(R,M)=>{if(R.preventDefault(),u)return;const I=M||a,O={};if(I?p==="authenticator"&&I.length!==6?O.code="Authentication code must be 6 digits":p==="phone_otp"&&I.length!==6&&(O.code="SMS code must be 6 digits"):O.code="Verification code is required",c(O),!(Object.keys(O).length>0)){d(!0);try{await o(I)}catch(N){c({submit:N.message})}finally{d(!1)}}},T=R=>{let M=R.target.value;p!=="backup_code"&&(M=M.replace(/\D/g,"").slice(0,6)),h(M),c(I=>({...I,code:""}))};return i.useEffect(()=>{var R;if(r.completed){z(!0);let M=new URLSearchParams(window.location.search).get("redirect_uri");if(M||(M=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!M&&(s!=null&&s.frontend_host)&&(M=`https://${s.frontend_host}`),M){let I;try{I=new URL(M)}catch{I=new URL(M,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(I.toString())}return}},[r,s]),C?e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsx(Qg,{children:e.jsx(wt,{size:32})})]})}):x?g.length===0?e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Set Up Two-Factor Authentication"}),e.jsx(Ya,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(Ka,{children:[t&&e.jsx("div",{children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(ql,{methods:g,onSelectMethod:_,onBack:t}):b&&p==="phone_otp"?e.jsx(Yl,{onVerify:E,onBack:()=>{k(!1),v(!0),m(null)},loading:u}):e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Two-factor authentication"}),e.jsxs(Ya,{children:[p==="authenticator"&&"Enter the 6-digit code from your authenticator app",p==="phone_otp"&&`Enter the 6-digit code sent to your phone ${$}`,p==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(yt,{onSubmit:j,noValidate:!0,children:[p==="backup_code"?e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"code",children:"Backup code"}),e.jsx(Jg,{type:"text",id:"code",name:"code",value:a,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Za,{children:f.code})]}):e.jsx(qt,{onComplete:async R=>{if(h(R),p!=="backup_code"){const M=new Event("submit",{bubbles:!0,cancelable:!0});await j(M,R)}},onResend:p==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:$.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:f.code,isSubmitting:u}),e.jsxs("div",{children:[f.submit&&e.jsx(Za,{children:f.submit}),e.jsx(Xg,{type:"submit",disabled:u||!a,children:u?"Verifying...":"Verify"})]})]}),e.jsxs(Ka,{children:[e.jsx(Wr,{onClick:()=>{v(!0),m(null),h(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Wn=l.div`
1526
1526
  max-width: 380px;
1527
1527
  width: 380px;
1528
1528
  padding: var(--space-3xl);
@@ -1587,7 +1587,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1587
1587
  transform: rotate(360deg);
1588
1588
  }
1589
1589
  }
1590
- `;function Kl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var L,P,A,q,Y,B,H,G,X;const{deployment:a}=we(),{navigate:h}=rt(),[f,c]=i.useState({}),[u,d]=i.useState({}),[p,m]=i.useState("US"),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState(null),[C,z]=i.useState(!1),w=$,y=b,g=async oe=>{var te;k(!0),S(null);try{if(await o(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}}catch(ce){const Q=ce;throw S(Q),Q}finally{k(!1)}},_=async oe=>{var te;k(!0),S(null);try{if(await n(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}return!0}catch(ce){return S(ce),!1}finally{k(!1)}};if(C||!t)return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsx(rm,{children:e.jsx(yt,{size:32})})]})});const E=t.missing_fields||[],j="Complete Your Profile",T="Please provide the following information to continue",R=a==null?void 0:a.auth_settings,M=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,I=oe=>{const{name:te,value:ce}=oe.target;c(Q=>({...Q,[te]:ce})),u[te]&&d(Q=>({...Q,[te]:""}))},O=()=>{const oe={};return E.forEach(te=>{var me,xe,de,U,le;const ce=f[te];let Q=!1;switch(te){case"first_name":Q=((me=R==null?void 0:R.first_name)==null?void 0:me.enabled)||!1;break;case"last_name":Q=((xe=R==null?void 0:R.last_name)==null?void 0:xe.enabled)||!1;break;case"username":Q=((de=R==null?void 0:R.username)==null?void 0:de.enabled)||!1;break;case"phone_number":Q=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":Q=((le=R==null?void 0:R.email_address)==null?void 0:le.enabled)||!1;break;default:Q=!0}if(Q&&(!ce||ce.trim()==="")){const K=te.replace("_"," ").replace(/\b\w/g,Z=>Z.toUpperCase());oe[te]=`${K} is required`}}),f.username&&E.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(oe.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&E.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(oe.phone_number="Phone number must contain 7-15 digits")),f.email&&E.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(oe.email_address="Please enter a valid email address")),d(oe),Object.keys(oe).length===0},N=async oe=>{if(oe.preventDefault(),!O())return;const te={...f};f.phone_number&&p&&(te.phone_country_code=p),await g(te)},D=oe=>{const te=oe.target.value;c(ce=>({...ce,phone_number:te})),u.phone_number&&d(ce=>({...ce,phone_number:""}))};if(M){const oe=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",te=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ce=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:oe}),e.jsx(Ja,{children:te})]}),e.jsxs(wt,{onSubmit:Q=>Q.preventDefault(),noValidate:!0,children:[e.jsx(qt,{onComplete:_,onResend:async()=>{await s({strategy:ce})},error:w==null?void 0:w.message,isSubmitting:y}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(ei,{children:[e.jsx("div",{children:e.jsx(xo,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:j}),e.jsx(Ja,{children:T})]}),e.jsxs(wt,{onSubmit:N,noValidate:!0,children:[(E.includes("first_name")||E.includes("last_name"))&&(((L=R==null?void 0:R.first_name)==null?void 0:L.enabled)||((P=R==null?void 0:R.last_name)==null?void 0:P.enabled))&&e.jsxs(em,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((q=R==null?void 0:R.last_name)!=null&&q.enabled)&&E.includes("first_name")&&E.includes("last_name")),children:[E.includes("first_name")&&((Y=R==null?void 0:R.first_name)==null?void 0:Y.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:I,placeholder:"Enter your first name","aria-invalid":!!u.first_name,disabled:y,autoComplete:"given-name"}),u.first_name&&e.jsx(Qt,{children:u.first_name})]}),E.includes("last_name")&&((B=R==null?void 0:R.last_name)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:I,placeholder:"Enter your last name","aria-invalid":!!u.last_name,disabled:y,autoComplete:"family-name"}),u.last_name&&e.jsx(Qt,{children:u.last_name})]})]}),E.includes("username")&&((H=R==null?void 0:R.username)==null?void 0:H.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(se,{type:"text",id:"username",name:"username",value:f.username||"",onChange:I,placeholder:"Choose a username","aria-invalid":!!u.username,disabled:y,autoComplete:"username"}),u.username&&e.jsx(Qt,{children:u.username})]}),E.includes("phone_number")&&((G=R==null?void 0:R.phone_number)==null?void 0:G.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(oo,{value:f.phone_number||"",onChange:D,error:u.phone_number,countryCode:p,setCountryCode:m}),u.phone_number&&e.jsx(Qt,{children:u.phone_number})]}),E.includes("email_address")&&((X=R==null?void 0:R.email_address)==null?void 0:X.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(se,{type:"email",id:"email",name:"email",value:f.email||"",onChange:I,placeholder:"Enter your email address","aria-invalid":!!u.email_address,disabled:y,autoComplete:"email"}),u.email_address&&e.jsx(Qt,{children:u.email_address})]}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(tm,{type:"submit",disabled:y,children:y?"Completing...":"Continue"})]}),e.jsxs(ei,{children:[r&&e.jsx("div",{children:e.jsx(xo,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const om=l.div`
1590
+ `;function Kl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var L,P,A,q,Y,B,H,G,X;const{deployment:a}=we(),{navigate:h}=rt(),[f,c]=i.useState({}),[u,d]=i.useState({}),[p,m]=i.useState("US"),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState(null),[C,z]=i.useState(!1),w=$,y=b,g=async oe=>{var te;k(!0),S(null);try{if(await o(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}}catch(ce){const Q=ce;throw S(Q),Q}finally{k(!1)}},_=async oe=>{var te;k(!0),S(null);try{if(await n(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}return!0}catch(ce){return S(ce),!1}finally{k(!1)}};if(C||!t)return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsx(rm,{children:e.jsx(wt,{size:32})})]})});const E=t.missing_fields||[],j="Complete Your Profile",T="Please provide the following information to continue",R=a==null?void 0:a.auth_settings,M=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,I=oe=>{const{name:te,value:ce}=oe.target;c(Q=>({...Q,[te]:ce})),u[te]&&d(Q=>({...Q,[te]:""}))},O=()=>{const oe={};return E.forEach(te=>{var me,xe,de,U,le;const ce=f[te];let Q=!1;switch(te){case"first_name":Q=((me=R==null?void 0:R.first_name)==null?void 0:me.enabled)||!1;break;case"last_name":Q=((xe=R==null?void 0:R.last_name)==null?void 0:xe.enabled)||!1;break;case"username":Q=((de=R==null?void 0:R.username)==null?void 0:de.enabled)||!1;break;case"phone_number":Q=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":Q=((le=R==null?void 0:R.email_address)==null?void 0:le.enabled)||!1;break;default:Q=!0}if(Q&&(!ce||ce.trim()==="")){const K=te.replace("_"," ").replace(/\b\w/g,Z=>Z.toUpperCase());oe[te]=`${K} is required`}}),f.username&&E.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(oe.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&E.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(oe.phone_number="Phone number must contain 7-15 digits")),f.email&&E.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(oe.email_address="Please enter a valid email address")),d(oe),Object.keys(oe).length===0},N=async oe=>{if(oe.preventDefault(),!O())return;const te={...f};f.phone_number&&p&&(te.phone_country_code=p),await g(te)},D=oe=>{const te=oe.target.value;c(ce=>({...ce,phone_number:te})),u.phone_number&&d(ce=>({...ce,phone_number:""}))};if(M){const oe=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",te=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ce=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:oe}),e.jsx(Ja,{children:te})]}),e.jsxs(yt,{onSubmit:Q=>Q.preventDefault(),noValidate:!0,children:[e.jsx(qt,{onComplete:_,onResend:async()=>{await s({strategy:ce})},error:w==null?void 0:w.message,isSubmitting:y}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(ei,{children:[e.jsx("div",{children:e.jsx(xo,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:j}),e.jsx(Ja,{children:T})]}),e.jsxs(yt,{onSubmit:N,noValidate:!0,children:[(E.includes("first_name")||E.includes("last_name"))&&(((L=R==null?void 0:R.first_name)==null?void 0:L.enabled)||((P=R==null?void 0:R.last_name)==null?void 0:P.enabled))&&e.jsxs(em,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((q=R==null?void 0:R.last_name)!=null&&q.enabled)&&E.includes("first_name")&&E.includes("last_name")),children:[E.includes("first_name")&&((Y=R==null?void 0:R.first_name)==null?void 0:Y.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:I,placeholder:"Enter your first name","aria-invalid":!!u.first_name,disabled:y,autoComplete:"given-name"}),u.first_name&&e.jsx(Qt,{children:u.first_name})]}),E.includes("last_name")&&((B=R==null?void 0:R.last_name)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:I,placeholder:"Enter your last name","aria-invalid":!!u.last_name,disabled:y,autoComplete:"family-name"}),u.last_name&&e.jsx(Qt,{children:u.last_name})]})]}),E.includes("username")&&((H=R==null?void 0:R.username)==null?void 0:H.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(se,{type:"text",id:"username",name:"username",value:f.username||"",onChange:I,placeholder:"Choose a username","aria-invalid":!!u.username,disabled:y,autoComplete:"username"}),u.username&&e.jsx(Qt,{children:u.username})]}),E.includes("phone_number")&&((G=R==null?void 0:R.phone_number)==null?void 0:G.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(oo,{value:f.phone_number||"",onChange:D,error:u.phone_number,countryCode:p,setCountryCode:m}),u.phone_number&&e.jsx(Qt,{children:u.phone_number})]}),E.includes("email_address")&&((X=R==null?void 0:R.email_address)==null?void 0:X.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(se,{type:"email",id:"email",name:"email",value:f.email||"",onChange:I,placeholder:"Enter your email address","aria-invalid":!!u.email_address,disabled:y,autoComplete:"email"}),u.email_address&&e.jsx(Qt,{children:u.email_address})]}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(tm,{type:"submit",disabled:y,children:y?"Completing...":"Continue"})]}),e.jsxs(ei,{children:[r&&e.jsx("div",{children:e.jsx(xo,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const om=l.div`
1591
1591
  text-align: center;
1592
1592
  margin-bottom: var(--space-2xl);
1593
1593
  `,nm=l.div`
@@ -1663,7 +1663,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1663
1663
  `,dm=Ht`
1664
1664
  from { transform: rotate(0deg); }
1665
1665
  to { transform: rotate(360deg); }
1666
- `,um=l(yt)`
1666
+ `,um=l(wt)`
1667
1667
  animation: ${dm} 1s linear infinite;
1668
1668
  `,pm=l.p`
1669
1669
  font-size: var(--font-xs);
@@ -1739,7 +1739,9 @@ margin: 0;
1739
1739
  margin-top: var(--space-2xs);
1740
1740
  `,si=l(J)`
1741
1741
  margin-top: var(--space-lg);
1742
- `,mm=l.button`
1742
+ `,mm=l(wt)`
1743
+ animation: ${Xl} 1s linear infinite;
1744
+ `,xm=l.button`
1743
1745
  display: flex;
1744
1746
  align-items: center;
1745
1747
  justify-content: center;
@@ -1784,23 +1786,23 @@ cursor: pointer;
1784
1786
  &:hover {
1785
1787
  color: var(--color-primary-hover);
1786
1788
  }
1787
- `,xm=l.div`
1789
+ `,vm=l.div`
1788
1790
  background: var(--color-error-background, rgba(239, 68, 68, 0.1));
1789
1791
  border: 1px solid var(--color-error, #ef4444);
1790
1792
  border-radius: var(--radius-md);
1791
1793
  padding: var(--space-md);
1792
1794
  margin-bottom: var(--space-lg);
1793
1795
  text-align: center;
1794
- `,vm=l.div`
1796
+ `,bm=l.div`
1795
1797
  font-weight: 600;
1796
1798
  font-size: var(--font-sm);
1797
1799
  color: var(--color-error, #ef4444);
1798
1800
  margin-bottom: var(--space-xs);
1799
- `,bm=l.div`
1801
+ `,ym=l.div`
1800
1802
  font-size: var(--font-xs);
1801
1803
  color: var(--color-foreground);
1802
1804
  margin-bottom: var(--space-sm);
1803
- `,ym=l.span`
1805
+ `,wm=l.span`
1804
1806
  font-size: var(--font-xs);
1805
1807
  color: var(--color-primary);
1806
1808
  cursor: pointer;
@@ -1809,27 +1811,27 @@ cursor: pointer;
1809
1811
  &:hover {
1810
1812
  color: var(--color-primary-hover);
1811
1813
  }
1812
- `;function wm(){return e.jsx(gg,{children:e.jsx(jm,{})})}function jm(){var K,Z,re,ge,ue,ee,V,F,ne,be,Me,Ce,Se,Ve,Le,Ae;const{deployment:t}=we(),{navigate:r}=rt(),{session:o,loading:n,refetch:s}=Qe(),a=((Z=(K=t==null?void 0:t.auth_settings)==null?void 0:K.multi_session_support)==null?void 0:Z.enabled)??!1,{setEmail:h,otpSent:f,setOtpSent:c,showForgotPassword:u,setShowForgotPassword:d,showOtherOptions:p,setShowOtherOptions:m,enabledSocialsProviders:x,firstFactor:v,signInStep:b,setSignInStep:k}=Gl(),{loading:$,signIn:S,signinAttempt:C,discardSignInAttempt:z,setSignInAttempt:w}=zr("generic"),{signIn:y}=zr("oauth"),{signIn:g}=zr("passkey"),[_,E]=i.useState({email:"",username:"",password:"",phone:""}),[j,T]=i.useState({}),[R,M]=i.useState(!1),[I,O]=i.useState(""),[N,D]=i.useState("US"),[L,P]=i.useState(!1),[A,q]=i.useState(null),[Y,B]=i.useState(!1),[H,G]=i.useState(null);i.useEffect(()=>{const ve=new URLSearchParams(window.location.search),pe=ve.get("error"),ye=ve.get("error_description");if(pe==="access_denied"&&ye){q(ye),ve.delete("error"),ve.delete("error_description");const $e=ve.toString()?`${window.location.pathname}?${ve.toString()}`:window.location.pathname;window.history.replaceState({},"",$e)}},[]),i.useEffect(()=>{var ve,pe,ye,$e;if(!n&&(o!=null&&o.active_signin)&&!a&&!L&&!Y){let Ie=new URLSearchParams(window.location.search).get("redirect_uri");Ie||(Ie=((ve=t==null?void 0:t.ui_settings)==null?void 0:ve.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`);const Ge=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.passkey;(Ge==null?void 0:Ge.enabled)&&(Ge==null?void 0:Ge.prompt_registration_on_auth)&&!(($e=(ye=o.active_signin)==null?void 0:ye.user)!=null&&$e.has_passkeys)?(G(Ie),B(!0)):Ie&&(P(!0),r(Ie))}},[o,n,a,t,r,L]);const X=ve=>{let{name:pe,value:ye}=ve.target;pe==="phone"?ye=ye.replace(/[^0-9]/g,""):pe==="email"&&(h(ye),ye=ye.toLowerCase()),E($e=>({...$e,[pe]:ye})),T($e=>({...$e,[pe]:""}))},oe=()=>{E({email:"",username:"",password:"",phone:""}),T({}),D("US"),k("identifier")},te=async ve=>{if(!ve){T({email:"Email address is required"});return}M(!0),T({});try{const pe=await S.identify(ve);if(pe.strategy==="sso"&&pe.connection_id){const $e=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ie=await S.initEnterpriseSso(pe.connection_id,$e);if(Ie&&Ie.sso_url){P(!0),window.location.href=Ie.sso_url;return}}else if(pe.strategy==="social"&&pe.provider){const ye=x.find($e=>$e.provider===pe.provider);if(ye){const Ie=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Ge}=await y.create({provider:ye.provider,redirectUri:Ie});if(Ge&&typeof Ge=="object"&&"oauth_url"in Ge){P(!0),window.location.href=Ge.oauth_url;return}}else k("password")}else k("password")}catch(pe){T({submit:pe.message})}finally{L||M(!1)}},ce=async ve=>{if(ve.preventDefault(),$||R)return;z();const pe={};if(b==="identifier"&&v==="email_password"){if(!_.email){T({email:"Email address is required"});return}await te(_.email);return}if(v==="email_password"?(_.email||(pe.email="Email address is required"),_.password||(pe.password="Password is required")):v==="username_password"?(_.username||(pe.username="Username is required"),_.password||(pe.password="Password is required")):v==="email_otp"||v==="email_magic_link"?_.email||(pe.email="Email address is required"):v==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(pe.phone="Phone number must contain 7-15 digits"):pe.phone="Phone number is required"),T(pe),Object.keys(pe).length>0)return;let ye="";switch(v){case"email_password":ye="plain_email";break;case"username_password":ye="plain_username";break;case"email_otp":ye="email_otp";break;case"email_magic_link":ye="magic_link";break;case"phone_otp":ye="phone_otp";break}M(!0);try{const $e={..._,strategy:ye};v==="phone_otp"&&N&&($e.phone_country_code=N),await S.create($e)}catch($e){T({submit:$e.message}),M(!1)}},Q=async ve=>{if(ve.preventDefault(),$||R)return;const pe={};if(!I){pe.otp="OTP code is required",T(pe);return}M(!0),T({});try{await S.completeVerification(I),c(!1),O("")}catch(ye){T({otp:ye.message||"Verification failed"})}finally{M(!1)}},me=async ve=>{if(!($||R)){M(!0);try{const ye=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:$e}=await y.create({provider:ve.provider,redirectUri:ye});$e&&typeof $e=="object"&&"oauth_url"in $e&&(window.location.href=$e.oauth_url)}catch(pe){T({submit:pe.message})}finally{M(!1)}}},xe=async()=>{var ve;if(!($||R)){M(!0),T({});try{const pe=await g.create();if("data"in pe&&pe.data){await s();let ye=new URLSearchParams(window.location.search).get("redirect_uri");ye||(ye=((ve=t==null?void 0:t.ui_settings)==null?void 0:ve.after_signin_redirect_url)||null),!ye&&(t!=null&&t.frontend_host)&&(ye=`https://${t.frontend_host}`),P(!0),ye&&r(ye)}}catch(pe){T({submit:pe.message||"Passkey sign-in failed"})}finally{M(!1)}}},de=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const ve=new URLSearchParams(window.location.search),pe=ve.get("impersonation_token");if(pe&&!C&&!$&&!de.current){de.current=!0,ve.delete("impersonation_token");const $e=ve.toString()?`${window.location.pathname}?${ve.toString()} `:window.location.pathname;window.history.replaceState({},"",$e),(async()=>{try{M(!0),await S.create({strategy:"impersonation",token:pe})}catch(Ge){T({submit:Ge.message}),M(!1),de.current=!1}})();return}const ye=ve.get("signin_attempt_id");if(ye&&(o!=null&&o.signin_attempts)&&!C){const $e=o.signin_attempts.find(Ie=>Ie.id===ye);if($e){w($e),ve.delete("signin_attempt_id");const Ie=ve.toString()?`${window.location.pathname}?${ve.toString()} `:window.location.pathname;window.history.replaceState({},"",Ie)}}},[o,n,C,w,$]),i.useEffect(()=>{var $e;if(!C)return;if(C.completed){P(!0);let Ie=new URLSearchParams(window.location.search).get("redirect_uri");if(Ie||(Ie=(($e=t==null?void 0:t.ui_settings)==null?void 0:$e.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`),Ie){let Ge;try{Ge=new URL(Ie)}catch{Ge=new URL(Ie,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Ge.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(Ge.toString())}return}if(!S||f)return;const pe={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[C.current_step];if(!pe)return;(async()=>{try{await S.prepareVerification({strategy:pe}),c(!0)}catch(Ie){console.error("Failed to prepare verification:",Ie),T({submit:"Failed to send verification. Please try again."})}finally{M(!1)}})()},[C,S,f,c,r,t]),i.useEffect(()=>{},[]),p)return e.jsx(Sg,{onBack:()=>m(!1)});if(u)return e.jsx(yg,{onBack:()=>d(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return e.jsx(Zl,{attempt:C,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return e.jsx(Kl,{attempt:C,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if(Y){const ve=()=>{B(!1),H&&(P(!0),r(H))},pe=()=>{B(!1),H&&(P(!0),r(H))};return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:ve,onSkip:pe})]})})}if(n)return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(yt,{size:32})})]})});if(L)return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(yt,{size:32})})]})});const le=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&f;return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),le?e.jsx(e.Fragment,{children:e.jsxs(ri,{children:[e.jsx(oi,{children:v==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ni,{children:v==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:v==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ri,{children:[e.jsx(oi,{children:"Sign in to your account"}),e.jsxs(ni,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),A&&e.jsxs(xm,{children:[e.jsx(vm,{children:"Access Denied"}),e.jsx(bm,{children:A}),e.jsx(ym,{onClick:()=>q(null),children:"Try again"})]}),le?v==="email_magic_link"?e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(wt,{style:{gap:"15px"},onSubmit:Q,noValidate:!0,children:[e.jsx(qt,{onComplete:async ve=>{if(O(ve),ve&&ve.length===6){M(!0),T({});try{await S.completeVerification(ve),c(!1)}catch(pe){T({otp:pe.message||"Verification failed"})}finally{M(!1)}}},onResend:async()=>{const ve=v==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:ve})},error:j.otp,isSubmitting:R}),e.jsx(si,{type:"submit",disabled:R||$||!I,style:{margin:0},children:R?"Verifying...":`Continue to ${(Ae=t==null?void 0:t.ui_settings)==null?void 0:Ae.app_name}`})]}),e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[x.length>0&&e.jsx(e.Fragment,{children:e.jsx(Bs,{connections:x,callback:me})}),((ge=(re=t==null?void 0:t.auth_settings)==null?void 0:re.passkey)==null?void 0:ge.enabled)&&e.jsxs(mm,{type:"button",onClick:xe,disabled:R,children:[e.jsx(zs,{size:18}),"Sign in with Passkey"]}),(x.length>0||((ee=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:ee.enabled))&&e.jsx(hm,{children:e.jsx(fm,{children:"or"})}),e.jsxs(wt,{onSubmit:ce,noValidate:!0,children:[(v==="email_password"||v==="email_otp"||v==="email_magic_link")&&((F=(V=t==null?void 0:t.auth_settings)==null?void 0:V.email_address)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email address"}),e.jsx(se,{type:"email",id:"email",name:"email",value:_.email,onChange:X,placeholder:"Enter your email address","aria-invalid":!!j.email}),j.email&&e.jsx(Vr,{children:j.email})]}),v==="username_password"&&((be=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.username)==null?void 0:be.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{type:"text",id:"username",name:"username",value:_.username,onChange:X,placeholder:"Enter your username","aria-invalid":!!j.username}),j.username&&e.jsx(Vr,{children:j.username})]}),v==="phone_otp"&&((Ce=(Me=t==null?void 0:t.auth_settings)==null?void 0:Me.phone_number)==null?void 0:Ce.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"phone",children:"Phone number"}),e.jsx(oo,{value:_.phone,onChange:X,error:j.phone,countryCode:N,setCountryCode:D}),j.phone&&e.jsx(Vr,{children:j.phone})]}),b==="password"&&(v==="email_password"||v==="username_password")&&((Ve=(Se=t==null?void 0:t.auth_settings)==null?void 0:Se.password)==null?void 0:Ve.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ie,{htmlFor:"password",children:"Password"}),e.jsx(Xt,{style:{fontSize:"12px"},onClick:()=>d(!0),children:"Forgot password?"})]}),e.jsx(gm,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:_.password,onChange:X,placeholder:"Enter your password","aria-invalid":!!j.password})}),j.password&&e.jsx(Vr,{children:j.password})]}),e.jsxs("div",{children:[j.submit&&e.jsx(Vr,{children:j.submit}),e.jsx(si,{type:"submit",disabled:R||$,children:R?e.jsx(yt,{size:16,className:"submit-spinner",style:{animation:`${Xl} 1s linear infinite`}}):b==="identifier"?"Continue":"Sign in"})]}),e.jsx(Xt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>m(!0),children:"Use other methods"})]}),e.jsxs(Vn,{children:["Don't have an account?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:`${(Le=t.ui_settings)==null?void 0:Le.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const ai=l.div`
1814
+ `;function jm(){return e.jsx(gg,{children:e.jsx(km,{})})}function km(){var K,Z,re,ge,ue,ee,V,F,ne,be,Me,Ce,Se,Ve,Le,Ae;const{deployment:t}=we(),{navigate:r}=rt(),{session:o,loading:n,refetch:s}=Qe(),a=((Z=(K=t==null?void 0:t.auth_settings)==null?void 0:K.multi_session_support)==null?void 0:Z.enabled)??!1,{setEmail:h,otpSent:f,setOtpSent:c,showForgotPassword:u,setShowForgotPassword:d,showOtherOptions:p,setShowOtherOptions:m,enabledSocialsProviders:x,firstFactor:v,signInStep:b,setSignInStep:k}=Gl(),{loading:$,signIn:S,signinAttempt:C,discardSignInAttempt:z,setSignInAttempt:w}=zr("generic"),{signIn:y}=zr("oauth"),{signIn:g}=zr("passkey"),[_,E]=i.useState({email:"",username:"",password:"",phone:""}),[j,T]=i.useState({}),[R,M]=i.useState(!1),[I,O]=i.useState(""),[N,D]=i.useState("US"),[L,P]=i.useState(!1),[A,q]=i.useState(null),[Y,B]=i.useState(!1),[H,G]=i.useState(null);i.useEffect(()=>{const ve=new URLSearchParams(window.location.search),pe=ve.get("error"),ye=ve.get("error_description");if(pe==="access_denied"&&ye){q(ye),ve.delete("error"),ve.delete("error_description");const $e=ve.toString()?`${window.location.pathname}?${ve.toString()}`:window.location.pathname;window.history.replaceState({},"",$e)}},[]),i.useEffect(()=>{var ve,pe,ye,$e;if(!n&&(o!=null&&o.active_signin)&&!a&&!L&&!Y){let Ie=new URLSearchParams(window.location.search).get("redirect_uri");Ie||(Ie=((ve=t==null?void 0:t.ui_settings)==null?void 0:ve.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`);const Ge=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.passkey;(Ge==null?void 0:Ge.enabled)&&(Ge==null?void 0:Ge.prompt_registration_on_auth)&&!(($e=(ye=o.active_signin)==null?void 0:ye.user)!=null&&$e.has_passkeys)?(G(Ie),B(!0)):Ie&&(P(!0),r(Ie))}},[o,n,a,t,r,L]);const X=ve=>{let{name:pe,value:ye}=ve.target;pe==="phone"?ye=ye.replace(/[^0-9]/g,""):pe==="email"&&(h(ye),ye=ye.toLowerCase()),E($e=>({...$e,[pe]:ye})),T($e=>({...$e,[pe]:""}))},oe=()=>{E({email:"",username:"",password:"",phone:""}),T({}),D("US"),k("identifier")},te=async ve=>{if(!ve){T({email:"Email address is required"});return}M(!0),T({});try{const pe=await S.identify(ve);if(pe.strategy==="sso"&&pe.connection_id){const $e=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ie=await S.initEnterpriseSso(pe.connection_id,$e);if(Ie&&Ie.sso_url){P(!0),window.location.href=Ie.sso_url;return}}else if(pe.strategy==="social"&&pe.provider){const ye=x.find($e=>$e.provider===pe.provider);if(ye){const Ie=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Ge}=await y.create({provider:ye.provider,redirectUri:Ie});if(Ge&&typeof Ge=="object"&&"oauth_url"in Ge){P(!0),window.location.href=Ge.oauth_url;return}}else k("password")}else k("password")}catch(pe){T({submit:pe.message})}finally{L||M(!1)}},ce=async ve=>{if(ve.preventDefault(),$||R)return;z();const pe={};if(b==="identifier"&&v==="email_password"){if(!_.email){T({email:"Email address is required"});return}await te(_.email);return}if(v==="email_password"?(_.email||(pe.email="Email address is required"),_.password||(pe.password="Password is required")):v==="username_password"?(_.username||(pe.username="Username is required"),_.password||(pe.password="Password is required")):v==="email_otp"||v==="email_magic_link"?_.email||(pe.email="Email address is required"):v==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(pe.phone="Phone number must contain 7-15 digits"):pe.phone="Phone number is required"),T(pe),Object.keys(pe).length>0)return;let ye="";switch(v){case"email_password":ye="plain_email";break;case"username_password":ye="plain_username";break;case"email_otp":ye="email_otp";break;case"email_magic_link":ye="magic_link";break;case"phone_otp":ye="phone_otp";break}M(!0);try{const $e={..._,strategy:ye};v==="phone_otp"&&N&&($e.phone_country_code=N),await S.create($e)}catch($e){T({submit:$e.message}),M(!1)}},Q=async ve=>{if(ve.preventDefault(),$||R)return;const pe={};if(!I){pe.otp="OTP code is required",T(pe);return}M(!0),T({});try{await S.completeVerification(I),c(!1),O("")}catch(ye){T({otp:ye.message||"Verification failed"})}finally{M(!1)}},me=async ve=>{if(!($||R)){M(!0);try{const ye=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:$e}=await y.create({provider:ve.provider,redirectUri:ye});$e&&typeof $e=="object"&&"oauth_url"in $e&&(window.location.href=$e.oauth_url)}catch(pe){T({submit:pe.message})}finally{M(!1)}}},xe=async()=>{var ve;if(!($||R)){M(!0),T({});try{const pe=await g.create();if("data"in pe&&pe.data){await s();let ye=new URLSearchParams(window.location.search).get("redirect_uri");ye||(ye=((ve=t==null?void 0:t.ui_settings)==null?void 0:ve.after_signin_redirect_url)||null),!ye&&(t!=null&&t.frontend_host)&&(ye=`https://${t.frontend_host}`),P(!0),ye&&r(ye)}}catch(pe){T({submit:pe.message||"Passkey sign-in failed"})}finally{M(!1)}}},de=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const ve=new URLSearchParams(window.location.search),pe=ve.get("impersonation_token");if(pe&&!C&&!$&&!de.current){de.current=!0,ve.delete("impersonation_token");const $e=ve.toString()?`${window.location.pathname}?${ve.toString()} `:window.location.pathname;window.history.replaceState({},"",$e),(async()=>{try{M(!0),await S.create({strategy:"impersonation",token:pe})}catch(Ge){T({submit:Ge.message}),M(!1),de.current=!1}})();return}const ye=ve.get("signin_attempt_id");if(ye&&(o!=null&&o.signin_attempts)&&!C){const $e=o.signin_attempts.find(Ie=>Ie.id===ye);if($e){w($e),ve.delete("signin_attempt_id");const Ie=ve.toString()?`${window.location.pathname}?${ve.toString()} `:window.location.pathname;window.history.replaceState({},"",Ie)}}},[o,n,C,w,$]),i.useEffect(()=>{var $e;if(!C)return;if(C.completed){P(!0);let Ie=new URLSearchParams(window.location.search).get("redirect_uri");if(Ie||(Ie=(($e=t==null?void 0:t.ui_settings)==null?void 0:$e.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`),Ie){let Ge;try{Ge=new URL(Ie)}catch{Ge=new URL(Ie,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Ge.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(Ge.toString())}return}if(!S||f)return;const pe={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[C.current_step];if(!pe)return;(async()=>{try{await S.prepareVerification({strategy:pe}),c(!0)}catch(Ie){console.error("Failed to prepare verification:",Ie),T({submit:"Failed to send verification. Please try again."})}finally{M(!1)}})()},[C,S,f,c,r,t]),i.useEffect(()=>{},[]),p)return e.jsx(Sg,{onBack:()=>m(!1)});if(u)return e.jsx(yg,{onBack:()=>d(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return e.jsx(Zl,{attempt:C,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return e.jsx(Kl,{attempt:C,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if(Y){const ve=()=>{B(!1),H&&(P(!0),r(H))},pe=()=>{B(!1),H&&(P(!0),r(H))};return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:ve,onSkip:pe})]})})}if(n)return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(wt,{size:32})})]})});if(L)return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(wt,{size:32})})]})});const le=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&f;return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),le?e.jsx(e.Fragment,{children:e.jsxs(ri,{children:[e.jsx(oi,{children:v==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ni,{children:v==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:v==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ri,{children:[e.jsx(oi,{children:"Sign in to your account"}),e.jsxs(ni,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),A&&e.jsxs(vm,{children:[e.jsx(bm,{children:"Access Denied"}),e.jsx(ym,{children:A}),e.jsx(wm,{onClick:()=>q(null),children:"Try again"})]}),le?v==="email_magic_link"?e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(yt,{style:{gap:"15px"},onSubmit:Q,noValidate:!0,children:[e.jsx(qt,{onComplete:async ve=>{if(O(ve),ve&&ve.length===6){M(!0),T({});try{await S.completeVerification(ve),c(!1)}catch(pe){T({otp:pe.message||"Verification failed"})}finally{M(!1)}}},onResend:async()=>{const ve=v==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:ve})},error:j.otp,isSubmitting:R}),e.jsx(si,{type:"submit",disabled:R||$||!I,style:{margin:0},children:R?"Verifying...":`Continue to ${(Ae=t==null?void 0:t.ui_settings)==null?void 0:Ae.app_name}`})]}),e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[x.length>0&&e.jsx(e.Fragment,{children:e.jsx(Bs,{connections:x,callback:me})}),((ge=(re=t==null?void 0:t.auth_settings)==null?void 0:re.passkey)==null?void 0:ge.enabled)&&e.jsxs(xm,{type:"button",onClick:xe,disabled:R,children:[e.jsx(zs,{size:18}),"Sign in with Passkey"]}),(x.length>0||((ee=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:ee.enabled))&&e.jsx(hm,{children:e.jsx(fm,{children:"or"})}),e.jsxs(yt,{onSubmit:ce,noValidate:!0,children:[(v==="email_password"||v==="email_otp"||v==="email_magic_link")&&((F=(V=t==null?void 0:t.auth_settings)==null?void 0:V.email_address)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email address"}),e.jsx(se,{type:"email",id:"email",name:"email",value:_.email,onChange:X,placeholder:"Enter your email address","aria-invalid":!!j.email}),j.email&&e.jsx(Vr,{children:j.email})]}),v==="username_password"&&((be=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.username)==null?void 0:be.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{type:"text",id:"username",name:"username",value:_.username,onChange:X,placeholder:"Enter your username","aria-invalid":!!j.username}),j.username&&e.jsx(Vr,{children:j.username})]}),v==="phone_otp"&&((Ce=(Me=t==null?void 0:t.auth_settings)==null?void 0:Me.phone_number)==null?void 0:Ce.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"phone",children:"Phone number"}),e.jsx(oo,{value:_.phone,onChange:X,error:j.phone,countryCode:N,setCountryCode:D}),j.phone&&e.jsx(Vr,{children:j.phone})]}),b==="password"&&(v==="email_password"||v==="username_password")&&((Ve=(Se=t==null?void 0:t.auth_settings)==null?void 0:Se.password)==null?void 0:Ve.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ie,{htmlFor:"password",children:"Password"}),e.jsx(Xt,{style:{fontSize:"12px"},onClick:()=>d(!0),children:"Forgot password?"})]}),e.jsx(gm,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:_.password,onChange:X,placeholder:"Enter your password","aria-invalid":!!j.password})}),j.password&&e.jsx(Vr,{children:j.password})]}),e.jsxs("div",{children:[j.submit&&e.jsx(Vr,{children:j.submit}),e.jsx(si,{type:"submit",disabled:R||$,children:R?e.jsx(mm,{size:16}):b==="identifier"?"Continue":"Sign in"})]}),e.jsx(Xt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>m(!0),children:"Use other methods"})]}),e.jsxs(Vn,{children:["Don't have an account?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:`${(Le=t.ui_settings)==null?void 0:Le.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const ai=l.div`
1813
1815
  max-width: 380px;
1814
1816
  width: 380px;
1815
1817
  padding: var(--space-3xl);
1816
1818
  background: var(--color-background);
1817
1819
  border-radius: var(--radius-lg);
1818
1820
  box-shadow: 0 4px 12px var(--color-shadow);
1819
- `,km=l.div`
1821
+ `,_m=l.div`
1820
1822
  text-align: center;
1821
1823
  margin-bottom: var(--space-lg);
1822
- `,_m=l.h1`
1824
+ `,Cm=l.h1`
1823
1825
  font-size: var(--font-lg);
1824
1826
  font-weight: 400;
1825
1827
  color: var(--color-foreground);
1826
1828
  margin-bottom: var(--space-xs);
1827
1829
  margin-top: 0;
1828
- `,Cm=l.p`
1830
+ `,Sm=l.p`
1829
1831
  color: var(--color-secondary-text);
1830
1832
  font-size: var(--font-xs);
1831
1833
  margin: 0;
1832
- `,Sm=l.form`
1834
+ `,$m=l.form`
1833
1835
  display: flex;
1834
1836
  flex-direction: column;
1835
1837
  gap: var(--space-md);
@@ -1837,7 +1839,7 @@ cursor: pointer;
1837
1839
  display: flex;
1838
1840
  flex-direction: column;
1839
1841
  gap: var(--space-xs);
1840
- `,$m=l.div`
1842
+ `,zm=l.div`
1841
1843
  display: grid;
1842
1844
  grid-template-columns: ${t=>t.$isBothEnabled?"1fr 1fr":"1fr"};
1843
1845
  gap: var(--space-md);
@@ -1849,7 +1851,7 @@ cursor: pointer;
1849
1851
  `,qn=l.span`
1850
1852
  color: var(--color-error);
1851
1853
  margin-left: var(--space-2xs);
1852
- `,zm=l.button`
1854
+ `,Em=l.button`
1853
1855
  width: 100%;
1854
1856
  padding: var(--space-sm) var(--space-md);
1855
1857
  border: ${t=>t.$primary?"none":"1px solid var(--color-input-border)"};
@@ -1875,13 +1877,13 @@ cursor: pointer;
1875
1877
  color: var(--color-error);
1876
1878
  font-size: var(--font-2xs);
1877
1879
  margin-top: var(--space-2xs);
1878
- `,Em=l.div`
1880
+ `,Pm=l.div`
1879
1881
  display: flex;
1880
1882
  flex-direction: column;
1881
1883
  align-items: center;
1882
1884
  gap: var(--space-md);
1883
1885
  text-align: center;
1884
- `,Pm=l.div`
1886
+ `,Im=l.div`
1885
1887
  width: 48px;
1886
1888
  height: 48px;
1887
1889
  background: var(--color-success);
@@ -1890,27 +1892,27 @@ cursor: pointer;
1890
1892
  align-items: center;
1891
1893
  justify-content: center;
1892
1894
  color: white;
1893
- `,Im=l.h2`
1895
+ `,Rm=l.h2`
1894
1896
  font-size: var(--font-lg);
1895
1897
  color: var(--color-foreground);
1896
1898
  margin: 0;
1897
- `,Rm=l.p`
1899
+ `,Tm=l.p`
1898
1900
  font-size: var(--font-xs);
1899
1901
  color: var(--color-secondary-text);
1900
1902
  margin: 0;
1901
1903
  line-height: 1.5;
1902
- `,Tm=l.div`
1904
+ `,Mm=l.div`
1903
1905
  text-align: center;
1904
1906
  margin-top: var(--space-lg);
1905
- `,Mm=l.p`
1907
+ `,Om=l.p`
1906
1908
  font-size: var(--font-xs);
1907
1909
  color: var(--color-muted);
1908
1910
  margin: 0;
1909
- `,Om=l.a`
1911
+ `,Am=l.a`
1910
1912
  color: var(--color-primary);
1911
1913
  text-decoration: none;
1912
1914
  cursor: pointer;
1913
- `;function Am(){var k,$,S,C,z,w,y,g,_,E,j,T;const{deployment:t}=we(),{loading:r,joinWaitlist:o}=Gc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,h]=i.useState(!1),[f,c]=i.useState(!1),[u,d]=i.useState(null),p=R=>{if(u)return u.message},m=t==null?void 0:t.auth_settings,x=!!((k=m==null?void 0:m.first_name)!=null&&k.enabled&&(($=m==null?void 0:m.last_name)!=null&&$.enabled)),v=R=>{const{name:M,value:I}=R.target;s(O=>({...O,[M]:I}))},b=async R=>{if(R.preventDefault(),!!m){c(!0),d(null);try{(await o(n)).data&&h(!0)}catch(M){d(M)}finally{c(!1)}}};return a?e.jsx(fe,{children:e.jsx(ai,{children:e.jsxs(Em,{children:[e.jsx(Pm,{children:e.jsx(tt,{size:32})}),e.jsx(Im,{children:"You're on the waitlist!"}),e.jsxs(Rm,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(fe,{children:e.jsxs(ai,{children:[e.jsx(Oe,{}),e.jsxs(km,{children:[e.jsx(_m,{children:"Join the waitlist"}),e.jsx(Cm,{children:"Be the first to know when we launch!"})]}),e.jsxs(Sm,{onSubmit:b,noValidate:!0,children:[(((S=m==null?void 0:m.first_name)==null?void 0:S.enabled)||((C=m==null?void 0:m.last_name)==null?void 0:C.enabled))&&e.jsxs($m,{$isBothEnabled:x,children:[((z=m==null?void 0:m.first_name)==null?void 0:z.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:(y=m==null?void 0:m.first_name)==null?void 0:y.required,minLength:2,maxLength:50,value:n.first_name,onChange:v,placeholder:"First name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),((g=m==null?void 0:m.last_name)==null?void 0:g.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"last_name",children:["Last name",((_=m==null?void 0:m.last_name)==null?void 0:_.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:(E=m==null?void 0:m.last_name)==null?void 0:E.required,minLength:2,maxLength:50,value:n.last_name,onChange:v,placeholder:"Last name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]})]}),e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"email",children:["Email address",((j=m==null?void 0:m.email_address)==null?void 0:j.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",required:(T=m==null?void 0:m.email_address)==null?void 0:T.required,value:n.email,onChange:v,placeholder:"Enter your email address","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),p()&&e.jsx(bo,{children:p()}),e.jsx(zm,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Tm,{children:e.jsxs(Mm,{children:["Need assistance? ",e.jsx(Om,{href:"/contact",children:"Get help"})]})})]})})}const Gr=l.div`
1915
+ `;function Lm(){var k,$,S,C,z,w,y,g,_,E,j,T;const{deployment:t}=we(),{loading:r,joinWaitlist:o}=Gc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,h]=i.useState(!1),[f,c]=i.useState(!1),[u,d]=i.useState(null),p=R=>{if(u)return u.message},m=t==null?void 0:t.auth_settings,x=!!((k=m==null?void 0:m.first_name)!=null&&k.enabled&&(($=m==null?void 0:m.last_name)!=null&&$.enabled)),v=R=>{const{name:M,value:I}=R.target;s(O=>({...O,[M]:I}))},b=async R=>{if(R.preventDefault(),!!m){c(!0),d(null);try{(await o(n)).data&&h(!0)}catch(M){d(M)}finally{c(!1)}}};return a?e.jsx(fe,{children:e.jsx(ai,{children:e.jsxs(Pm,{children:[e.jsx(Im,{children:e.jsx(tt,{size:32})}),e.jsx(Rm,{children:"You're on the waitlist!"}),e.jsxs(Tm,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(fe,{children:e.jsxs(ai,{children:[e.jsx(Oe,{}),e.jsxs(_m,{children:[e.jsx(Cm,{children:"Join the waitlist"}),e.jsx(Sm,{children:"Be the first to know when we launch!"})]}),e.jsxs($m,{onSubmit:b,noValidate:!0,children:[(((S=m==null?void 0:m.first_name)==null?void 0:S.enabled)||((C=m==null?void 0:m.last_name)==null?void 0:C.enabled))&&e.jsxs(zm,{$isBothEnabled:x,children:[((z=m==null?void 0:m.first_name)==null?void 0:z.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:(y=m==null?void 0:m.first_name)==null?void 0:y.required,minLength:2,maxLength:50,value:n.first_name,onChange:v,placeholder:"First name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),((g=m==null?void 0:m.last_name)==null?void 0:g.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"last_name",children:["Last name",((_=m==null?void 0:m.last_name)==null?void 0:_.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:(E=m==null?void 0:m.last_name)==null?void 0:E.required,minLength:2,maxLength:50,value:n.last_name,onChange:v,placeholder:"Last name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]})]}),e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"email",children:["Email address",((j=m==null?void 0:m.email_address)==null?void 0:j.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",required:(T=m==null?void 0:m.email_address)==null?void 0:T.required,value:n.email,onChange:v,placeholder:"Enter your email address","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),p()&&e.jsx(bo,{children:p()}),e.jsx(Em,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Mm,{children:e.jsxs(Om,{children:["Need assistance? ",e.jsx(Am,{href:"/contact",children:"Get help"})]})})]})})}const Gr=l.div`
1914
1916
  max-width: 380px;
1915
1917
  width: 380px;
1916
1918
  padding: var(--space-3xl);
@@ -1934,7 +1936,7 @@ cursor: pointer;
1934
1936
  `,ko=l.div`
1935
1937
  padding-top: var(--space-xl);
1936
1938
  text-align: center;
1937
- `,Lm=l.div`
1939
+ `,Dm=l.div`
1938
1940
  width: calc(var(--space-3xl) * 2);
1939
1941
  height: calc(var(--space-3xl) * 2);
1940
1942
  border-radius: 50%;
@@ -1962,7 +1964,7 @@ cursor: pointer;
1962
1964
  transform: rotate(360deg);
1963
1965
  }
1964
1966
  }
1965
- `,Dm=l.div`
1967
+ `,Nm=l.div`
1966
1968
  width: calc(var(--space-3xl) * 2);
1967
1969
  height: calc(var(--space-3xl) * 2);
1968
1970
  border-radius: 50%;
@@ -1981,12 +1983,12 @@ cursor: pointer;
1981
1983
  font-size: var(--font-xs);
1982
1984
  color: var(--color-secondary-text);
1983
1985
  margin-bottom: var(--space-lg);
1984
- `,Nm=l.div`
1986
+ `,Fm=l.div`
1985
1987
  margin-top: var(--space-xl);
1986
1988
  text-align: center;
1987
1989
  font-size: var(--font-xs);
1988
1990
  color: var(--color-secondary-text);
1989
- `,Fm=l.span`
1991
+ `,Bm=l.span`
1990
1992
  color: var(--color-primary);
1991
1993
  text-decoration: none;
1992
1994
  font-weight: 400;
@@ -1997,30 +1999,30 @@ cursor: pointer;
1997
1999
  color: var(--color-primary-hover);
1998
2000
  text-decoration: underline;
1999
2001
  }
2000
- `;function Bm(){const{deployment:t}=we(),{navigate:r}=rt(),{error:o,session:n,processed:s,signinAttempt:a,redirectUri:h,loading:f}=Hc(),[c,u]=i.useState(!1),[d,p]=i.useState(null),m=()=>{window.location.reload()},x=()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||"/sign-in";r(k)},v=()=>{u(!1),d&&r(d)},b=()=>{u(!1),d&&r(d)};if(i.useEffect(()=>{var k,$,S,C,z;if(!(!s||f||c)){if(a&&!a.completed){const w=(k=t==null?void 0:t.ui_settings)==null?void 0:k.sign_in_page_url;if(w){const y=new URL(w,window.location.origin);y.searchParams.set("signin_attempt_id",a.id),h&&y.searchParams.set("redirect_uri",h),r(y.toString())}return}if(a!=null&&a.completed){const w=h||(($=t==null?void 0:t.ui_settings)==null?void 0:$.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let y;try{y=new URL(w)}catch{y=new URL(w,window.location.origin)}if(y){(t==null?void 0:t.mode)==="staging"&&y.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||"");const g=(S=t==null?void 0:t.auth_settings)==null?void 0:S.passkey;(g==null?void 0:g.enabled)&&(g==null?void 0:g.prompt_registration_on_auth)&&!((z=(C=n==null?void 0:n.active_signin)==null?void 0:C.user)!=null&&z.has_passkeys)?(p(y.toString()),u(!0)):r(y.toString())}}}},[n,s,f,h,t,a,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||(t==null?void 0:t.frontend_host);k&&r(k)},2e3)},[o,t,r]),f&&!s)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})});if(c)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:v,onSkip:b})]})});if(n&&s&&!o)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Success!"}),e.jsx(jo,{children:"Authentication completed successfully"})]}),e.jsxs(ko,{children:[e.jsx(Dm,{children:"✓"}),e.jsx(_o,{children:"Redirecting you now..."}),e.jsx(Co,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const k=o.message.includes("No OAuth callback data found");return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Something went wrong"}),e.jsx(jo,{children:"We couldn't complete your sign in"})]}),e.jsxs(ko,{children:[e.jsx(Lm,{children:"✗"}),e.jsx(_o,{children:"Authentication Failed"}),e.jsx(Co,{children:o.message||"An unexpected error occurred during authentication."}),!k&&e.jsx(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!k&&e.jsx(Nm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Fm,{onClick:x,children:"Return to sign in"})]})})]})})}return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})})}const Um=l.div`
2002
+ `;function Um(){const{deployment:t}=we(),{navigate:r}=rt(),{error:o,session:n,processed:s,signinAttempt:a,redirectUri:h,loading:f}=Hc(),[c,u]=i.useState(!1),[d,p]=i.useState(null),m=()=>{window.location.reload()},x=()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||"/sign-in";r(k)},v=()=>{u(!1),d&&r(d)},b=()=>{u(!1),d&&r(d)};if(i.useEffect(()=>{var k,$,S,C,z;if(!(!s||f||c)){if(a&&!a.completed){const w=(k=t==null?void 0:t.ui_settings)==null?void 0:k.sign_in_page_url;if(w){const y=new URL(w,window.location.origin);y.searchParams.set("signin_attempt_id",a.id),h&&y.searchParams.set("redirect_uri",h),r(y.toString())}return}if(a!=null&&a.completed){const w=h||(($=t==null?void 0:t.ui_settings)==null?void 0:$.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let y;try{y=new URL(w)}catch{y=new URL(w,window.location.origin)}if(y){(t==null?void 0:t.mode)==="staging"&&y.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||"");const g=(S=t==null?void 0:t.auth_settings)==null?void 0:S.passkey;(g==null?void 0:g.enabled)&&(g==null?void 0:g.prompt_registration_on_auth)&&!((z=(C=n==null?void 0:n.active_signin)==null?void 0:C.user)!=null&&z.has_passkeys)?(p(y.toString()),u(!0)):r(y.toString())}}}},[n,s,f,h,t,a,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||(t==null?void 0:t.frontend_host);k&&r(k)},2e3)},[o,t,r]),f&&!s)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})});if(c)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:v,onSkip:b})]})});if(n&&s&&!o)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Success!"}),e.jsx(jo,{children:"Authentication completed successfully"})]}),e.jsxs(ko,{children:[e.jsx(Nm,{children:"✓"}),e.jsx(_o,{children:"Redirecting you now..."}),e.jsx(Co,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const k=o.message.includes("No OAuth callback data found");return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Something went wrong"}),e.jsx(jo,{children:"We couldn't complete your sign in"})]}),e.jsxs(ko,{children:[e.jsx(Dm,{children:"✗"}),e.jsx(_o,{children:"Authentication Failed"}),e.jsx(Co,{children:o.message||"An unexpected error occurred during authentication."}),!k&&e.jsx(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!k&&e.jsx(Fm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Bm,{onClick:x,children:"Return to sign in"})]})})]})})}return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})})}const Wm=l.div`
2001
2003
  max-width: 380px;
2002
2004
  width: 380px;
2003
2005
  padding: var(--space-3xl);
2004
2006
  background: var(--color-background);
2005
2007
  border-radius: var(--radius-lg);
2006
2008
  box-shadow: 0 4px 12px var(--color-shadow);
2007
- `,Wm=l.div`
2009
+ `,Vm=l.div`
2008
2010
  text-align: center;
2009
2011
  position: relative;
2010
- `,Vm=l.h1`
2012
+ `,Gm=l.h1`
2011
2013
  font-size: var(--font-lg);
2012
2014
  font-weight: 400;
2013
2015
  color: var(--color-foreground);
2014
2016
  margin-bottom: var(--space-xs);
2015
2017
  margin-top: 0;
2016
- `,Gm=l.p`
2018
+ `,Hm=l.p`
2017
2019
  color: var(--color-secondary-text);
2018
2020
  font-size: var(--font-xs);
2019
2021
  margin: 0;
2020
- `,Hm=l.div`
2022
+ `,qm=l.div`
2021
2023
  padding-top: var(--space-xl);
2022
2024
  text-align: center;
2023
- `,qm=l.div`
2025
+ `,Ym=l.div`
2024
2026
  width: calc(var(--space-3xl) * 2);
2025
2027
  height: calc(var(--space-3xl) * 2);
2026
2028
  border-radius: 50%;
@@ -2031,7 +2033,7 @@ cursor: pointer;
2031
2033
  margin: 0 auto var(--space-lg) auto;
2032
2034
  color: var(--color-success);
2033
2035
  font-size: var(--font-xl);
2034
- `,Ym=l.div`
2036
+ `,Zm=l.div`
2035
2037
  width: calc(var(--space-3xl) * 2);
2036
2038
  height: calc(var(--space-3xl) * 2);
2037
2039
  border-radius: 50%;
@@ -2042,7 +2044,7 @@ cursor: pointer;
2042
2044
  margin: 0 auto var(--space-lg) auto;
2043
2045
  color: var(--color-error);
2044
2046
  font-size: var(--font-xl);
2045
- `,Zm=l.div`
2047
+ `,Km=l.div`
2046
2048
  width: calc(var(--space-3xl) * 2);
2047
2049
  height: calc(var(--space-3xl) * 2);
2048
2050
  border: 3px solid var(--color-border);
@@ -2062,7 +2064,7 @@ cursor: pointer;
2062
2064
  `,Yn=l.p`
2063
2065
  font-size: var(--font-xs);
2064
2066
  color: var(--color-secondary-text);
2065
- `;function Km({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[s,a]=i.useState(""),{token:h,attempt:f,redirectUri:c}=Yc(),{verifyMagicLink:u}=qc(),{navigate:d}=rt(),{deployment:p}=we(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!h||!f){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await u({token:h,attempt:f,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var k;let b=c;if(b||(b=(k=p==null?void 0:p.ui_settings)==null?void 0:k.after_signin_redirect_url),!b&&(p!=null&&p.frontend_host)&&(b=`https://${p.frontend_host}`),b){const $=new URL(b);(p==null?void 0:p.mode)==="staging"&&$.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d($.toString())}},2e3)}catch(b){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(b.message)}}})()},[h,f]);const x=()=>{var v;(v=p==null?void 0:p.ui_settings)!=null&&v.sign_in_page_url&&d(p.ui_settings.sign_in_page_url)};return e.jsx(fe,{children:e.jsxs(Um,{children:[e.jsxs(Wm,{children:[e.jsx(Vm,{children:"Magic Link Verification"}),e.jsx(Gm,{children:"Verifying your magic link"})]}),e.jsxs(Hm,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(Zm,{}),e.jsx(Yn,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(qm,{children:"✓"}),e.jsx(Yn,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(Ym,{children:"✗"}),e.jsx(Yn,{children:s}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function Qm(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(a=>a.requires_completion&&!a.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(a=>{var h,f;return((h=a.missing_fields)==null?void 0:h.length)>0||((f=a.remaining_steps)==null?void 0:f.length)>0&&!a.completed})):!1}function Xm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Jt=l.div`
2067
+ `;function Qm({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[s,a]=i.useState(""),{token:h,attempt:f,redirectUri:c}=Yc(),{verifyMagicLink:u}=qc(),{navigate:d}=rt(),{deployment:p}=we(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!h||!f){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await u({token:h,attempt:f,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var k;let b=c;if(b||(b=(k=p==null?void 0:p.ui_settings)==null?void 0:k.after_signin_redirect_url),!b&&(p!=null&&p.frontend_host)&&(b=`https://${p.frontend_host}`),b){const $=new URL(b);(p==null?void 0:p.mode)==="staging"&&$.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d($.toString())}},2e3)}catch(b){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(b.message)}}})()},[h,f]);const x=()=>{var v;(v=p==null?void 0:p.ui_settings)!=null&&v.sign_in_page_url&&d(p.ui_settings.sign_in_page_url)};return e.jsx(fe,{children:e.jsxs(Wm,{children:[e.jsxs(Vm,{children:[e.jsx(Gm,{children:"Magic Link Verification"}),e.jsx(Hm,{children:"Verifying your magic link"})]}),e.jsxs(qm,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(Km,{}),e.jsx(Yn,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(Ym,{children:"✓"}),e.jsx(Yn,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(Zm,{children:"✗"}),e.jsx(Yn,{children:s}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function Xm(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(a=>a.requires_completion&&!a.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(a=>{var h,f;return((h=a.missing_fields)==null?void 0:h.length)>0||((f=a.remaining_steps)==null?void 0:f.length)>0&&!a.completed})):!1}function Jm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Jt=l.div`
2066
2068
  max-width: 380px;
2067
2069
  width: 380px;
2068
2070
  padding: var(--space-3xl);
@@ -2086,7 +2088,7 @@ cursor: pointer;
2086
2088
  `,or=l.div`
2087
2089
  padding-top: var(--space-xl);
2088
2090
  text-align: center;
2089
- `,Jm=l.div`
2091
+ `,ex=l.div`
2090
2092
  width: calc(var(--space-3xl) * 2);
2091
2093
  height: calc(var(--space-3xl) * 2);
2092
2094
  border-radius: 50%;
@@ -2119,7 +2121,7 @@ cursor: pointer;
2119
2121
  margin: 0 auto var(--space-lg) auto;
2120
2122
  color: var(--color-info);
2121
2123
  font-size: var(--font-xl);
2122
- `,ex=l.div`
2124
+ `,tx=l.div`
2123
2125
  width: calc(var(--space-3xl) * 2);
2124
2126
  height: calc(var(--space-3xl) * 2);
2125
2127
  border: 3px solid var(--color-border);
@@ -2147,12 +2149,12 @@ cursor: pointer;
2147
2149
  `,li=l.span`
2148
2150
  color: var(--color-primary);
2149
2151
  font-weight: 400;
2150
- `,tx=l.div`
2152
+ `,rx=l.div`
2151
2153
  margin-top: var(--space-xl);
2152
2154
  text-align: center;
2153
2155
  font-size: var(--font-xs);
2154
2156
  color: var(--color-secondary-text);
2155
- `,rx=l.span`
2157
+ `,ox=l.span`
2156
2158
  color: var(--color-primary);
2157
2159
  text-decoration: none;
2158
2160
  font-weight: 400;
@@ -2162,11 +2164,11 @@ cursor: pointer;
2162
2164
  &:hover {
2163
2165
  color: var(--color-primary-hover);
2164
2166
  }
2165
- `;function ox({token:t,onSuccess:r,onError:o}){var b;const{acceptInvitation:n,invitationData:s,loading:a,error:h}=Jc(),{navigate:f}=rt(),{deployment:c}=we(),u=i.useRef(!1),d=()=>{var $;const k=new URLSearchParams(window.location.search);return{token:t||k.get("invite_token")||k.get("token"),redirectUri:k.get("redirect_uri")||(($=c==null?void 0:c.ui_settings)==null?void 0:$.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(u.current)return;const{token:k}=d();k&&(u.current=!0,n(k))},[n]),i.useEffect(()=>{var k;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,(k=s.workspace)==null?void 0:k.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const p=()=>{const{redirectUri:k}=d();f(k)},m=()=>{var g,_;const{token:k}=d(),$=((g=c==null?void 0:c.ui_settings)==null?void 0:g.sign_in_page_url)||"/sign-in",S=((_=c==null?void 0:c.ui_settings)==null?void 0:_.sign_up_page_url)||"/sign-up",C=new URLSearchParams;k&&C.set("invite_token",k),s!=null&&s.invited_email&&C.set("invited_email",s.invited_email);const w=`${window.location.pathname}?token=${k}`;C.set("redirect_uri",w),s!=null&&s.message&&C.set("message",s.message);const y=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${y?S:$}?${C.toString()}`)},x=()=>{const{token:k}=d();k&&(u.current=!1,n(k))},{token:v}=d();if(!v&&!a)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invalid Invitation"}),e.jsx(rr,{children:"No invitation token found"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Missing Invitation Token"}),e.jsx(sr,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(J,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Processing Invitation"}),e.jsx(rr,{children:"Please wait while we verify your invitation"})]}),e.jsxs(or,{children:[e.jsx(ex,{}),e.jsx(nr,{children:"Verifying invitation..."}),e.jsx(sr,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Accepted!"}),e.jsx(rr,{children:"You've successfully joined the organization"})]}),e.jsxs(or,{children:[e.jsx(Jm,{children:"✓"}),e.jsxs(nr,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(sr,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Already a Member"}),e.jsx(rr,{children:"You're already part of this organization"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["You're already a member of ",((b=s.organization)==null?void 0:b.name)||"this organization"]}),e.jsx(sr,{children:"No action needed - you already have access."}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const k=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:k?"Sign Up Required":"Sign In Required"}),e.jsx(rr,{children:"To accept this invitation"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["This invitation is for ",e.jsx(li,{children:s.invited_email})]}),e.jsx(sr,{children:k?"You need to create an account with this email address to accept the invitation.":s.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:k?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Expired"}),e.jsx(rr,{children:"This invitation is no longer valid"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"⏱"}),e.jsxs(nr,{children:["Invitation for ",e.jsx(li,{children:s.invited_email})," has expired"]}),e.jsx(sr,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):h||s!=null&&s.error_code?e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Error"}),e.jsx(rr,{children:"Unable to process invitation"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Something went wrong"}),e.jsx(sr,{children:(s==null?void 0:s.message)||h||"Failed to accept invitation"}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(tx,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(rx,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const Ws=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),Je=()=>{const t=i.useContext(Ws);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},nx=l.div`
2167
+ `;function nx({token:t,onSuccess:r,onError:o}){var b;const{acceptInvitation:n,invitationData:s,loading:a,error:h}=Jc(),{navigate:f}=rt(),{deployment:c}=we(),u=i.useRef(!1),d=()=>{var $;const k=new URLSearchParams(window.location.search);return{token:t||k.get("invite_token")||k.get("token"),redirectUri:k.get("redirect_uri")||(($=c==null?void 0:c.ui_settings)==null?void 0:$.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(u.current)return;const{token:k}=d();k&&(u.current=!0,n(k))},[n]),i.useEffect(()=>{var k;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,(k=s.workspace)==null?void 0:k.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const p=()=>{const{redirectUri:k}=d();f(k)},m=()=>{var g,_;const{token:k}=d(),$=((g=c==null?void 0:c.ui_settings)==null?void 0:g.sign_in_page_url)||"/sign-in",S=((_=c==null?void 0:c.ui_settings)==null?void 0:_.sign_up_page_url)||"/sign-up",C=new URLSearchParams;k&&C.set("invite_token",k),s!=null&&s.invited_email&&C.set("invited_email",s.invited_email);const w=`${window.location.pathname}?token=${k}`;C.set("redirect_uri",w),s!=null&&s.message&&C.set("message",s.message);const y=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${y?S:$}?${C.toString()}`)},x=()=>{const{token:k}=d();k&&(u.current=!1,n(k))},{token:v}=d();if(!v&&!a)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invalid Invitation"}),e.jsx(rr,{children:"No invitation token found"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Missing Invitation Token"}),e.jsx(sr,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(J,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Processing Invitation"}),e.jsx(rr,{children:"Please wait while we verify your invitation"})]}),e.jsxs(or,{children:[e.jsx(tx,{}),e.jsx(nr,{children:"Verifying invitation..."}),e.jsx(sr,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Accepted!"}),e.jsx(rr,{children:"You've successfully joined the organization"})]}),e.jsxs(or,{children:[e.jsx(ex,{children:"✓"}),e.jsxs(nr,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(sr,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Already a Member"}),e.jsx(rr,{children:"You're already part of this organization"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["You're already a member of ",((b=s.organization)==null?void 0:b.name)||"this organization"]}),e.jsx(sr,{children:"No action needed - you already have access."}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const k=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:k?"Sign Up Required":"Sign In Required"}),e.jsx(rr,{children:"To accept this invitation"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["This invitation is for ",e.jsx(li,{children:s.invited_email})]}),e.jsx(sr,{children:k?"You need to create an account with this email address to accept the invitation.":s.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:k?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Expired"}),e.jsx(rr,{children:"This invitation is no longer valid"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"⏱"}),e.jsxs(nr,{children:["Invitation for ",e.jsx(li,{children:s.invited_email})," has expired"]}),e.jsx(sr,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):h||s!=null&&s.error_code?e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Error"}),e.jsx(rr,{children:"Unable to process invitation"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Something went wrong"}),e.jsx(sr,{children:(s==null?void 0:s.message)||h||"Failed to accept invitation"}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(rx,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(ox,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const Ws=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),Je=()=>{const t=i.useContext(Ws);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},sx=l.div`
2166
2168
  display: flex;
2167
2169
  height: 100%;
2168
2170
  min-height: 400px;
2169
- `,sx=l.div`
2171
+ `,ax=l.div`
2170
2172
  width: 35%;
2171
2173
  background: var(--color-background-hover);
2172
2174
  padding: 32px;
@@ -2176,7 +2178,7 @@ cursor: pointer;
2176
2178
  justify-content: center;
2177
2179
  text-align: center;
2178
2180
  border-right: 1px solid var(--color-border);
2179
- `,ax=l.div`
2181
+ `,ix=l.div`
2180
2182
  flex: 1;
2181
2183
  padding: 32px;
2182
2184
  display: flex;
@@ -2200,11 +2202,11 @@ cursor: pointer;
2200
2202
  border-color: var(--color-border-hover);
2201
2203
  transform: scale(1.02);
2202
2204
  }
2203
- `,ix=l.img`
2205
+ `,cx=l.img`
2204
2206
  width: 100%;
2205
2207
  height: 100%;
2206
2208
  object-fit: cover;
2207
- `,cx=l.div`
2209
+ `,lx=l.div`
2208
2210
  font-size: 32px;
2209
2211
  font-weight: 600;
2210
2212
  color: var(--color-muted);
@@ -2214,28 +2216,28 @@ cursor: pointer;
2214
2216
  display: flex;
2215
2217
  align-items: center;
2216
2218
  justify-content: center;
2217
- `,lx=l.h2`
2219
+ `,dx=l.h2`
2218
2220
  font-size: 16px;
2219
2221
  font-weight: 400;
2220
2222
  color: var(--color-foreground);
2221
2223
  margin-bottom: 8px;
2222
- `,dx=l.p`
2224
+ `,ux=l.p`
2223
2225
  font-size: 13px;
2224
2226
  color: var(--color-secondary-text);
2225
2227
  line-height: 1.4;
2226
2228
  max-width: 200px;
2227
- `,ux=l.div`
2229
+ `,px=l.div`
2228
2230
  margin-bottom: 24px;
2229
- `,px=l.h3`
2231
+ `,hx=l.h3`
2230
2232
  font-size: 16px;
2231
2233
  font-weight: 400;
2232
2234
  color: var(--color-foreground);
2233
2235
  margin-bottom: 6px;
2234
- `,hx=l.p`
2236
+ `,fx=l.p`
2235
2237
  font-size: 13px;
2236
2238
  color: var(--color-secondary-text);
2237
2239
  line-height: 1.4;
2238
- `,fx=l.div`
2240
+ `,gx=l.div`
2239
2241
  flex: 1;
2240
2242
  `,di=l.div`
2241
2243
  margin-bottom: 20px;
@@ -2245,7 +2247,7 @@ cursor: pointer;
2245
2247
  font-size: 13px;
2246
2248
  font-weight: 400;
2247
2249
  color: var(--color-foreground);
2248
- `,gx=l.input`
2250
+ `,mx=l.input`
2249
2251
  width: 100%;
2250
2252
  padding: 8px 12px;
2251
2253
  border: 1px solid var(--color-border);
@@ -2265,7 +2267,7 @@ cursor: pointer;
2265
2267
  &::placeholder {
2266
2268
  color: var(--color-muted);
2267
2269
  }
2268
- `,mx=l.textarea`
2270
+ `,xx=l.textarea`
2269
2271
  width: 100%;
2270
2272
  padding: 8px 12px;
2271
2273
  border: 1px solid var(--color-border);
@@ -2288,13 +2290,13 @@ cursor: pointer;
2288
2290
  &::placeholder {
2289
2291
  color: var(--color-muted);
2290
2292
  }
2291
- `,xx=l.div`
2293
+ `,vx=l.div`
2292
2294
  display: flex;
2293
2295
  justify-content: space-between;
2294
2296
  align-items: center;
2295
2297
  margin-top: auto;
2296
2298
  padding-top: 24px;
2297
- `,vx=l.button`
2299
+ `,bx=l.button`
2298
2300
  display: flex;
2299
2301
  align-items: center;
2300
2302
  gap: 6px;
@@ -2310,7 +2312,7 @@ cursor: pointer;
2310
2312
  &:hover {
2311
2313
  color: var(--color-foreground);
2312
2314
  }
2313
- `,bx=l.button`
2315
+ `,yx=l.button`
2314
2316
  padding: 8px 20px;
2315
2317
  border-radius: 6px;
2316
2318
  font-size: 14px;
@@ -2331,9 +2333,9 @@ cursor: pointer;
2331
2333
  opacity: 0.5;
2332
2334
  cursor: not-allowed;
2333
2335
  }
2334
- `,yx=l.input`
2336
+ `,wx=l.input`
2335
2337
  display: none;
2336
- `,wx=l.div`
2338
+ `,jx=l.div`
2337
2339
  position: absolute;
2338
2340
  inset: 0;
2339
2341
  background: var(--color-dialog-backdrop);
@@ -2347,11 +2349,11 @@ cursor: pointer;
2347
2349
  ${Jl}:hover & {
2348
2350
  opacity: 1;
2349
2351
  }
2350
- `,jx=l.div`
2352
+ `,kx=l.div`
2351
2353
  color: white;
2352
2354
  font-size: 12px;
2353
2355
  font-weight: 400;
2354
- `,xn=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[s,a]=i.useState(""),[h,f]=i.useState(),[c,u]=i.useState(null),[d,p]=i.useState(!1),m=i.useRef(null),{createOrganization:x}=on(),{toast:v}=Je(),b=y=>{n(y)},k=y=>{if(y.target.files&&y.target.files[0]){const g=y.target.files[0];if(g.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!g.type.startsWith("image/")){v("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(g),u(URL.createObjectURL(g))}},$=()=>{var y;(y=m.current)==null||y.click()},S=y=>y.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const C=y=>y.trim().replace(/[<>\"'&]/g,""),z=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),w=async()=>{const y=C(o),g=C(s);if(!y){v("Please enter an organization name","error");return}if(!z(y)){v("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(g.length>500){v("Description must be less than 500 characters","error");return}p(!0);try{const _=await x({name:y,description:g,image:h});t==null||t(_)}catch(_){const E=_.message||"Failed to create organization. Please try again.";v(E,"error")}finally{p(!1)}};return e.jsx(fe,{children:e.jsxs(nx,{children:[e.jsxs(sx,{children:[e.jsxs(Jl,{hasImage:!!c,onClick:$,children:[c?e.jsx(ix,{src:c,alt:"Organization logo"}):e.jsx(cx,{children:S(o||"O")}),e.jsx(wx,{children:e.jsx(jx,{children:"Upload Logo"})})]}),e.jsx(yx,{type:"file",ref:m,onChange:k,accept:"image/png, image/jpeg, image/gif",disabled:d}),e.jsx(lx,{children:"Create new organization"}),e.jsx(dx,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(ax,{children:[e.jsxs(ux,{children:[e.jsx(px,{children:"Choose your organization name"}),e.jsx(hx,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(fx,{children:[e.jsxs(di,{children:[e.jsx(ui,{children:"Organization name"}),e.jsx(gx,{type:"text",value:o,onChange:y=>b(y.target.value),placeholder:"Acme Inc.",disabled:d})]}),e.jsxs(di,{children:[e.jsx(ui,{children:"Description (optional)"}),e.jsx(mx,{value:s,onChange:y=>a(y.target.value),placeholder:"What does your organization do?",disabled:d})]})]}),e.jsxs(xx,{children:[r?e.jsxs(vx,{onClick:r,disabled:d,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(bx,{onClick:w,disabled:d||!o.trim(),children:d?"Creating...":"Create"})]})]})]})})},kx=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(fe,{children:e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsx(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ze.Body,{style:{padding:0},children:e.jsx(xn,{onSuccess:n,onCancel:r})})})})})})},_x=l.div`
2356
+ `,xn=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[s,a]=i.useState(""),[h,f]=i.useState(),[c,u]=i.useState(null),[d,p]=i.useState(!1),m=i.useRef(null),{createOrganization:x}=on(),{toast:v}=Je(),b=y=>{n(y)},k=y=>{if(y.target.files&&y.target.files[0]){const g=y.target.files[0];if(g.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!g.type.startsWith("image/")){v("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(g),u(URL.createObjectURL(g))}},$=()=>{var y;(y=m.current)==null||y.click()},S=y=>y.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const C=y=>y.trim().replace(/[<>\"'&]/g,""),z=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),w=async()=>{const y=C(o),g=C(s);if(!y){v("Please enter an organization name","error");return}if(!z(y)){v("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(g.length>500){v("Description must be less than 500 characters","error");return}p(!0);try{const _=await x({name:y,description:g,image:h});t==null||t(_)}catch(_){const E=_.message||"Failed to create organization. Please try again.";v(E,"error")}finally{p(!1)}};return e.jsx(fe,{children:e.jsxs(sx,{children:[e.jsxs(ax,{children:[e.jsxs(Jl,{hasImage:!!c,onClick:$,children:[c?e.jsx(cx,{src:c,alt:"Organization logo"}):e.jsx(lx,{children:S(o||"O")}),e.jsx(jx,{children:e.jsx(kx,{children:"Upload Logo"})})]}),e.jsx(wx,{type:"file",ref:m,onChange:k,accept:"image/png, image/jpeg, image/gif",disabled:d}),e.jsx(dx,{children:"Create new organization"}),e.jsx(ux,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(ix,{children:[e.jsxs(px,{children:[e.jsx(hx,{children:"Choose your organization name"}),e.jsx(fx,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(gx,{children:[e.jsxs(di,{children:[e.jsx(ui,{children:"Organization name"}),e.jsx(mx,{type:"text",value:o,onChange:y=>b(y.target.value),placeholder:"Acme Inc.",disabled:d})]}),e.jsxs(di,{children:[e.jsx(ui,{children:"Description (optional)"}),e.jsx(xx,{value:s,onChange:y=>a(y.target.value),placeholder:"What does your organization do?",disabled:d})]})]}),e.jsxs(vx,{children:[r?e.jsxs(bx,{onClick:r,disabled:d,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(yx,{onClick:w,disabled:d||!o.trim(),children:d?"Creating...":"Create"})]})]})]})})},_x=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(fe,{children:e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsx(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ze.Body,{style:{padding:0},children:e.jsx(xn,{onSuccess:n,onCancel:r})})})})})})},Cx=l.div`
2355
2357
  position: fixed;
2356
2358
  width: 360px;
2357
2359
  max-width: calc(100vw - 48px);
@@ -2400,7 +2402,7 @@ cursor: pointer;
2400
2402
  color: var(--color-foreground);
2401
2403
  background: var(--color-input-background);
2402
2404
  }
2403
- `,xi=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(),[h,f]=i.useState(""),[c,u]=i.useState(!1),[d,p]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:b}=st(),{toast:k}=Je(),$=w=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(w),S=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),C=async()=>{const w=S(h);if(!w){k("Please enter a domain name","error");return}if(!$(w)){k("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){k("Domain name is too long","error");return}try{const y=await v({fqdn:w});k("Domain added successfully","info"),a(y.data)}catch(y){const g=y.message||"Failed to add domain. Please try again.";k(g,"error")}},z=async()=>{if(!(!s||c)){u(!0);try{await b(s),t==null||t(),k("Domain verified successfully","info")}catch(w){const y=w.message||"Failed to verify domain. Please check DNS records and try again.";k(y,"error")}finally{u(!1)}}};return i.useEffect(()=>{p(!0);const w=setTimeout(()=>{if(!n.current)return;const _=o==null?void 0:o.current,E=360,j=250,T=8;let R=0,M=0;if(!_){const D=n.current.getBoundingClientRect(),L=D.width||E,P=D.height||j;R=Math.max(T,(window.innerHeight-P)/2),M=Math.max(T,(window.innerWidth-L)/2),x({top:R,left:M});return}const I=_.getBoundingClientRect(),O=window.innerHeight-I.bottom,N=I.top;O>=j+T?(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):N>=j+T?(R=I.top-j-T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left)),x({top:R,left:M})},10),y=_=>{n.current&&!n.current.contains(_.target)&&(t==null||t())},g=_=>{_.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),d?e.jsx(_x,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(lt,{size:16})})]}),e.jsxs(fi,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Record Type"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Name"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Data"}),e.jsx(se,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"add-domain-title",children:"Add Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(fi,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ie,{children:"Enter FQDN"}),e.jsx(se,{type:"text",placeholder:"Enter your domain",value:h,onChange:w=>f(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Cx=l.div`
2405
+ `,xi=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(),[h,f]=i.useState(""),[c,u]=i.useState(!1),[d,p]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:b}=st(),{toast:k}=Je(),$=w=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(w),S=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),C=async()=>{const w=S(h);if(!w){k("Please enter a domain name","error");return}if(!$(w)){k("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){k("Domain name is too long","error");return}try{const y=await v({fqdn:w});k("Domain added successfully","info"),a(y.data)}catch(y){const g=y.message||"Failed to add domain. Please try again.";k(g,"error")}},z=async()=>{if(!(!s||c)){u(!0);try{await b(s),t==null||t(),k("Domain verified successfully","info")}catch(w){const y=w.message||"Failed to verify domain. Please check DNS records and try again.";k(y,"error")}finally{u(!1)}}};return i.useEffect(()=>{p(!0);const w=setTimeout(()=>{if(!n.current)return;const _=o==null?void 0:o.current,E=360,j=250,T=8;let R=0,M=0;if(!_){const D=n.current.getBoundingClientRect(),L=D.width||E,P=D.height||j;R=Math.max(T,(window.innerHeight-P)/2),M=Math.max(T,(window.innerWidth-L)/2),x({top:R,left:M});return}const I=_.getBoundingClientRect(),O=window.innerHeight-I.bottom,N=I.top;O>=j+T?(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):N>=j+T?(R=I.top-j-T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left)),x({top:R,left:M})},10),y=_=>{n.current&&!n.current.contains(_.target)&&(t==null||t())},g=_=>{_.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),d?e.jsx(Cx,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(lt,{size:16})})]}),e.jsxs(fi,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Record Type"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Name"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Data"}),e.jsx(se,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"add-domain-title",children:"Add Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(fi,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ie,{children:"Enter FQDN"}),e.jsx(se,{type:"text",placeholder:"Enter your domain",value:h,onChange:w=>f(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Sx=l.div`
2404
2406
  position: fixed;
2405
2407
  width: 360px;
2406
2408
  max-width: calc(100vw - 48px);
@@ -2413,27 +2415,27 @@ cursor: pointer;
2413
2415
  @media (max-width: 600px) {
2414
2416
  width: calc(100vw - 48px);
2415
2417
  }
2416
- `,Sx=l.div`
2418
+ `,$x=l.div`
2417
2419
  display: flex;
2418
2420
  justify-content: space-between;
2419
2421
  align-items: center;
2420
2422
  padding: var(--space-sm) var(--space-md);
2421
2423
  border-bottom: 1px solid var(--color-border);
2422
- `,$x=l.h3`
2424
+ `,zx=l.h3`
2423
2425
  margin: 0;
2424
2426
  font-size: var(--font-xs);
2425
2427
  font-weight: 400;
2426
2428
  color: var(--color-foreground);
2427
- `,zx=l.div`
2428
- padding: var(--space-md);
2429
2429
  `,Ex=l.div`
2430
+ padding: var(--space-md);
2431
+ `,Px=l.div`
2430
2432
  display: flex;
2431
2433
  gap: var(--space-xs);
2432
2434
  justify-content: flex-end;
2433
2435
  padding: var(--space-sm) var(--space-md);
2434
2436
  border-top: 1px solid var(--color-border);
2435
2437
  background: var(--color-background-alt);
2436
- `,Px=l.button`
2438
+ `,Ix=l.button`
2437
2439
  background: none;
2438
2440
  border: none;
2439
2441
  padding: var(--space-xs);
@@ -2449,7 +2451,7 @@ cursor: pointer;
2449
2451
  color: var(--color-foreground);
2450
2452
  background: var(--color-input-background);
2451
2453
  }
2452
- `,ed=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=i.useRef(null),[a,h]=i.useState(""),[f,c]=i.useState(null),[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:b}=st(),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name})),S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=a.trim().toLowerCase();if(!(!z||!f)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}d(!0);try{await b({email:z,organizationRole:f}),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{d(!1)}}};return i.useEffect(()=>{m(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const g=n.current;if(g){const _=g.getBoundingClientRect(),E=360,j=250,T=8;let R=0,M=0;const I=window.innerHeight-_.bottom,O=_.top;I>=j+T?(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):O>=j+T?(R=_.top-j-T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left)),v({top:R,left:M})}},10),w=g=>{s.current&&!s.current.contains(g.target)&&(t==null||t())},y=g=>{g.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",y),()=>{clearTimeout(z),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,n]),p?e.jsxs(Cx,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Sx,{children:[e.jsx($x,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Px,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(zx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:a,onChange:z=>h(z.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:f==null?void 0:f.id,onChange:z=>c(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Ex,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a||!f||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Ix=l.div`
2454
+ `,ed=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=i.useRef(null),[a,h]=i.useState(""),[f,c]=i.useState(null),[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:b}=st(),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name})),S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=a.trim().toLowerCase();if(!(!z||!f)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}d(!0);try{await b({email:z,organizationRole:f}),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{d(!1)}}};return i.useEffect(()=>{m(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const g=n.current;if(g){const _=g.getBoundingClientRect(),E=360,j=250,T=8;let R=0,M=0;const I=window.innerHeight-_.bottom,O=_.top;I>=j+T?(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):O>=j+T?(R=_.top-j-T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left)),v({top:R,left:M})}},10),w=g=>{s.current&&!s.current.contains(g.target)&&(t==null||t())},y=g=>{g.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",y),()=>{clearTimeout(z),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,n]),p?e.jsxs(Sx,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs($x,{children:[e.jsx(zx,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Ix,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(Ex,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:a,onChange:z=>h(z.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:f==null?void 0:f.id,onChange:z=>c(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Px,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a||!f||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Rx=l.div`
2453
2455
  position: fixed;
2454
2456
  width: 400px;
2455
2457
  max-width: calc(100vw - 48px);
@@ -2464,27 +2466,27 @@ cursor: pointer;
2464
2466
  @media (max-width: 600px) {
2465
2467
  width: calc(100vw - 48px);
2466
2468
  }
2467
- `,Rx=l.div`
2469
+ `,Tx=l.div`
2468
2470
  display: flex;
2469
2471
  justify-content: space-between;
2470
2472
  align-items: center;
2471
2473
  padding: var(--space-sm) var(--space-md);
2472
2474
  border-bottom: 1px solid var(--color-border);
2473
- `,Tx=l.h3`
2475
+ `,Mx=l.h3`
2474
2476
  margin: 0;
2475
2477
  font-size: var(--font-xs);
2476
2478
  font-weight: 400;
2477
2479
  color: var(--color-foreground);
2478
- `,Mx=l.div`
2479
- padding: var(--space-md);
2480
2480
  `,Ox=l.div`
2481
+ padding: var(--space-md);
2482
+ `,Ax=l.div`
2481
2483
  display: flex;
2482
2484
  gap: var(--space-xs);
2483
2485
  justify-content: flex-end;
2484
2486
  padding: var(--space-sm) var(--space-md);
2485
2487
  border-top: 1px solid var(--color-border);
2486
2488
  background: var(--color-background-alt);
2487
- `,Ax=l.button`
2489
+ `,Lx=l.button`
2488
2490
  background: none;
2489
2491
  border: none;
2490
2492
  padding: var(--space-xs);
@@ -2500,7 +2502,7 @@ cursor: pointer;
2500
2502
  color: var(--color-foreground);
2501
2503
  background: var(--color-input-background);
2502
2504
  }
2503
- `,vi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var y;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);st();const[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:b}=we(),{toast:k}=Je(),$=!!o,S=Array.isArray((y=b==null?void 0:b.b2b_settings)==null?void 0:y.organization_permissions)?b.b2b_settings.organization_permissions.map(g=>({value:g,label:g})):[];i.useEffect(()=>{m(!0);const g=setTimeout(()=>{if(!s.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if($){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let M=0;M<R.length;M++){const I=R[M];if(I.offsetParent!==null){T=I;break}}}else{const R=document.querySelectorAll("button");for(let M=0;M<R.length;M++){const I=R[M];if(I.textContent==="Add role"&&I.offsetParent!==null){T=I;break}}}if(T){const R=T.getBoundingClientRect(),M=400;let I=R.bottom+8,O=R.right-M;O<10&&(O=R.left),I+300>window.innerHeight&&(I=R.top-300-8),v({top:I,left:O})}},10),_=T=>{s.current&&!s.current.contains(T.target)&&(t==null||t())},E=T=>{T.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",_),document.addEventListener("keydown",E)},100);return()=>{clearTimeout(g),clearTimeout(j),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",E)}},[t,$,n]);const C=g=>g.trim().replace(/[<>\"'&]/g,""),z=g=>g.length>=2&&g.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(g),w=async()=>{const g=C(a);if(!g){k("Please enter a role name","error");return}if(!z(g)){k("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){k("Please select at least one permission","error");return}d(!0);try{const _={id:o==null?void 0:o.id,name:g,permissions:f||[]};r==null||r(_)}catch(_){const E=_.message||`Failed to ${$?"update":"create"} role. Please try again.`;k(E,"error")}finally{d(!1)}};return p?e.jsxs(Ix,{ref:s,$isInTable:$,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:g=>g.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Rx,{children:[e.jsx(Tx,{id:"role-dialog-title",children:$?"Edit Role":"Create New Role"}),e.jsx(Ax,{onClick:t,"aria-label":`Close ${$?"edit":"create"} role dialog`,children:e.jsx(lt,{size:16})})]}),e.jsx(Mx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:g=>h(g.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Ox,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:w,disabled:!a||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",$?"Updating...":"Creating..."]}):$?"Update Role":"Create Role"})]})]}):null},_t=l.table`
2505
+ `,vi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var y;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);st();const[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:b}=we(),{toast:k}=Je(),$=!!o,S=Array.isArray((y=b==null?void 0:b.b2b_settings)==null?void 0:y.organization_permissions)?b.b2b_settings.organization_permissions.map(g=>({value:g,label:g})):[];i.useEffect(()=>{m(!0);const g=setTimeout(()=>{if(!s.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if($){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let M=0;M<R.length;M++){const I=R[M];if(I.offsetParent!==null){T=I;break}}}else{const R=document.querySelectorAll("button");for(let M=0;M<R.length;M++){const I=R[M];if(I.textContent==="Add role"&&I.offsetParent!==null){T=I;break}}}if(T){const R=T.getBoundingClientRect(),M=400;let I=R.bottom+8,O=R.right-M;O<10&&(O=R.left),I+300>window.innerHeight&&(I=R.top-300-8),v({top:I,left:O})}},10),_=T=>{s.current&&!s.current.contains(T.target)&&(t==null||t())},E=T=>{T.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",_),document.addEventListener("keydown",E)},100);return()=>{clearTimeout(g),clearTimeout(j),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",E)}},[t,$,n]);const C=g=>g.trim().replace(/[<>\"'&]/g,""),z=g=>g.length>=2&&g.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(g),w=async()=>{const g=C(a);if(!g){k("Please enter a role name","error");return}if(!z(g)){k("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){k("Please select at least one permission","error");return}d(!0);try{const _={id:o==null?void 0:o.id,name:g,permissions:f||[]};r==null||r(_)}catch(_){const E=_.message||`Failed to ${$?"update":"create"} role. Please try again.`;k(E,"error")}finally{d(!1)}};return p?e.jsxs(Rx,{ref:s,$isInTable:$,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:g=>g.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Tx,{children:[e.jsx(Mx,{id:"role-dialog-title",children:$?"Edit Role":"Create New Role"}),e.jsx(Lx,{onClick:t,"aria-label":`Close ${$?"edit":"create"} role dialog`,children:e.jsx(lt,{size:16})})]}),e.jsx(Ox,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:g=>h(g.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Ax,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:w,disabled:!a||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",$?"Updating...":"Creating..."]}):$?"Update Role":"Create Role"})]})]}):null},_t=l.table`
2504
2506
  width: 100%;
2505
2507
  border-collapse: separate;
2506
2508
  border-spacing: 0;
@@ -2558,7 +2560,7 @@ cursor: pointer;
2558
2560
  white-space: nowrap;
2559
2561
  position: relative;
2560
2562
  overflow: visible;
2561
- `,Lx=l.div`
2563
+ `,Dx=l.div`
2562
2564
  display: flex;
2563
2565
  flex-direction: column;
2564
2566
  align-items: center;
@@ -2570,18 +2572,18 @@ cursor: pointer;
2570
2572
  border: 1px dashed var(--color-border);
2571
2573
  height: 100%;
2572
2574
  width: 100%;
2573
- `,Dx=l.h3`
2575
+ `,Nx=l.h3`
2574
2576
  font-size: 16px;
2575
2577
  font-weight: 400;
2576
2578
  color: var(--color-foreground);
2577
2579
  margin: 0 0 8px 0;
2578
- `,Nx=l.p`
2580
+ `,Fx=l.p`
2579
2581
  font-size: 14px;
2580
2582
  color: var(--color-muted);
2581
2583
  margin: 0;
2582
2584
  max-width: 380px;
2583
2585
  line-height: 1.5;
2584
- `,xt=({title:t,description:r,action:o})=>e.jsxs(Lx,{children:[e.jsx(Dx,{children:t}),e.jsx(Nx,{children:r}),o&&e.jsx("div",{style:{marginTop:"24px"},children:o})]}),Fx=l.div`
2586
+ `,xt=({title:t,description:r,action:o})=>e.jsxs(Dx,{children:[e.jsx(Nx,{children:t}),e.jsx(Fx,{children:r}),o&&e.jsx("div",{style:{marginTop:"24px"},children:o})]}),Bx=l.div`
2585
2587
  text-align: left;
2586
2588
  position: fixed;
2587
2589
  background: var(--color-background);
@@ -2591,23 +2593,23 @@ cursor: pointer;
2591
2593
  padding: 16px;
2592
2594
  width: 320px;
2593
2595
  z-index: 1000;
2594
- `,Bx=l.div`
2596
+ `,Ux=l.div`
2595
2597
  font-size: 14px;
2596
2598
  font-weight: 400;
2597
2599
  color: var(--color-foreground);
2598
2600
  margin-bottom: 16px;
2599
2601
  line-height: 1.4;
2600
- `,Ux=l.div`
2602
+ `,Wx=l.div`
2601
2603
  display: flex;
2602
2604
  gap: 8px;
2603
2605
  justify-content: flex-end;
2604
- `,Mr=({title:t,onConfirm:r,onCancel:o})=>{const n=i.useRef(null),[s,a]=i.useState({top:0,left:0});return i.useEffect(()=>{var h;if(n.current){const f=(h=n.current.parentElement)==null?void 0:h.getBoundingClientRect();f&&a({top:f.bottom+8,left:f.right-320})}},[]),i.useEffect(()=>{const h=f=>{n.current&&!n.current.contains(f.target)&&o()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[o]),e.jsxs(Fx,{ref:n,style:{top:`${s.top}px`,left:`${s.left}px`},children:[e.jsx(Bx,{children:t}),e.jsxs(Ux,{children:[e.jsx(J,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(J,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},Wx=l.div`
2606
+ `,Mr=({title:t,onConfirm:r,onCancel:o})=>{const n=i.useRef(null),[s,a]=i.useState({top:0,left:0});return i.useEffect(()=>{var h;if(n.current){const f=(h=n.current.parentElement)==null?void 0:h.getBoundingClientRect();f&&a({top:f.bottom+8,left:f.right-320})}},[]),i.useEffect(()=>{const h=f=>{n.current&&!n.current.contains(f.target)&&o()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[o]),e.jsxs(Bx,{ref:n,style:{top:`${s.top}px`,left:`${s.left}px`},children:[e.jsx(Ux,{children:t}),e.jsxs(Wx,{children:[e.jsx(J,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(J,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},Vx=l.div`
2605
2607
  display: flex;
2606
2608
  align-items: center;
2607
2609
  flex-wrap: wrap;
2608
2610
  gap: 12px;
2609
2611
  margin-bottom: 24px;
2610
- `,Vx=l.div`
2612
+ `,Gx=l.div`
2611
2613
  padding-bottom: 20px;
2612
2614
  margin-bottom: 16px;
2613
2615
  border-bottom: 1px solid var(--color-border);
@@ -2617,11 +2619,11 @@ cursor: pointer;
2617
2619
  margin-bottom: 0;
2618
2620
  padding-bottom: 0;
2619
2621
  }
2620
- `,Gx=l.div`
2622
+ `,Hx=l.div`
2621
2623
  display: flex;
2622
2624
  justify-content: space-between;
2623
2625
  align-items: flex-start;
2624
- `,Hx=l.h3`
2626
+ `,qx=l.h3`
2625
2627
  font-size: 14px;
2626
2628
  font-weight: 500;
2627
2629
  color: var(--color-foreground);
@@ -2629,7 +2631,7 @@ cursor: pointer;
2629
2631
  display: flex;
2630
2632
  align-items: center;
2631
2633
  gap: 8px;
2632
- `,qx=l.span`
2634
+ `,Yx=l.span`
2633
2635
  background: var(--color-primary-background);
2634
2636
  color: var(--color-primary);
2635
2637
  padding: 2px 6px;
@@ -2661,7 +2663,7 @@ cursor: pointer;
2661
2663
  border: 1px solid var(--color-border);
2662
2664
  font-size: 13px;
2663
2665
  color: var(--color-secondary-text);
2664
- `,Yx=l.textarea`
2666
+ `,Zx=l.textarea`
2665
2667
  width: 100%;
2666
2668
  padding: 10px 12px;
2667
2669
  border: 1px solid var(--color-border);
@@ -2726,11 +2728,11 @@ cursor: pointer;
2726
2728
  outline: none;
2727
2729
  border-color: var(--color-primary);
2728
2730
  }
2729
- `,Zx=()=>{const{activeOrganization:t,loading:r,getEnterpriseConnections:o,createEnterpriseConnection:n,deleteEnterpriseConnection:s,testEnterpriseConnection:a,generateSCIMToken:h,getSCIMToken:f,revokeSCIMToken:c}=st(),{toast:u}=Je(),[d,p]=i.useState(!1),[m,x]=i.useState(null),{data:v=[],isLoading:b,mutate:k}=Ze(t!=null&&t.id?`wacht-org-sso:${t.id}`:null,async()=>await(o==null?void 0:o())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),$=async S=>{try{await(s==null?void 0:s(S)),k(),u("SSO connection deleted","info")}catch(C){u(C.message||"Failed to delete connection","error")}x(null)};return r||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):d?e.jsx(e0,{onClose:()=>p(!1),onCreate:async S=>{try{await(n==null?void 0:n(S)),k(),p(!1),u("SSO connection created","info")}catch(C){u(C.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:v.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(pt,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(J,{onClick:()=>p(!0),style:{width:"auto"},children:[e.jsx(it,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wx,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),v.map(S=>e.jsx(Jx,{connection:S,onDelete:C=>x(C),connectionToDelete:m,onConfirmDelete:$,onCancelDelete:()=>x(null),testConnection:a||null,generateSCIMToken:h,getSCIMToken:f,revokeSCIMToken:c,toast:u},S.id))]})})},Kx=l.div`
2731
+ `,Kx=()=>{const{activeOrganization:t,loading:r,getEnterpriseConnections:o,createEnterpriseConnection:n,deleteEnterpriseConnection:s,testEnterpriseConnection:a,generateSCIMToken:h,getSCIMToken:f,revokeSCIMToken:c}=st(),{toast:u}=Je(),[d,p]=i.useState(!1),[m,x]=i.useState(null),{data:v=[],isLoading:b,mutate:k}=Ze(t!=null&&t.id?`wacht-org-sso:${t.id}`:null,async()=>await(o==null?void 0:o())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),$=async S=>{try{await(s==null?void 0:s(S)),k(),u("SSO connection deleted","info")}catch(C){u(C.message||"Failed to delete connection","error")}x(null)};return r||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):d?e.jsx(t0,{onClose:()=>p(!1),onCreate:async S=>{try{await(n==null?void 0:n(S)),k(),p(!1),u("SSO connection created","info")}catch(C){u(C.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:v.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(pt,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(J,{onClick:()=>p(!0),style:{width:"auto"},children:[e.jsx(it,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Vx,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),v.map(S=>e.jsx(e0,{connection:S,onDelete:C=>x(C),connectionToDelete:m,onConfirmDelete:$,onCancelDelete:()=>x(null),testConnection:a||null,generateSCIMToken:h,getSCIMToken:f,revokeSCIMToken:c,toast:u},S.id))]})})},Qx=l.div`
2730
2732
  margin-top: 16px;
2731
2733
  padding-top: 16px;
2732
2734
  border-top: 1px solid var(--color-border);
2733
- `,Qx=l.div`
2735
+ `,Xx=l.div`
2734
2736
  font-size: 12px;
2735
2737
  font-weight: 500;
2736
2738
  color: var(--color-foreground);
@@ -2738,18 +2740,18 @@ cursor: pointer;
2738
2740
  display: flex;
2739
2741
  align-items: center;
2740
2742
  gap: 6px;
2741
- `,Xx=l.div`
2743
+ `,Jx=l.div`
2742
2744
  display: flex;
2743
2745
  gap: 8px;
2744
2746
  flex-wrap: wrap;
2745
- `,Jx=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:s,testConnection:a,generateSCIMToken:h,getSCIMToken:f,revokeSCIMToken:c,toast:u})=>{var j,T,R,M,I;const[d,p]=i.useState(null),[m,x]=i.useState(!1),[v,b]=i.useState(null),[k,$]=i.useState(null),[S,C]=i.useState(!1),[z,w]=i.useState(null);i.useEffect(()=>{f&&t.id&&f(t.id).then(p).catch(()=>{})},[t.id,f]);const y=async()=>{if(a){C(!0),w(null);try{const O=await a(t.id);w(O)}catch(O){w({success:!1,checks:{},errors:{general:O.message||"Test failed"}})}finally{C(!1)}}},g=async()=>{if(h){x(!0);try{const O=await h(t.id);b(O.token),p({exists:!0,token:O}),u("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(O){u(O.message||"Failed to generate token","error")}finally{x(!1)}}},_=async()=>{if(c){x(!0);try{await c(t.id),p({exists:!1,scim_base_url:d==null?void 0:d.scim_base_url}),b(null),u("SCIM token revoked","info")}catch(O){u(O.message||"Failed to revoke token","error")}finally{x(!1)}}},E=(O,N)=>{navigator.clipboard.writeText(O),$(N),setTimeout(()=>$(null),2e3)};return e.jsxs(Vx,{children:[e.jsxs(Gx,{children:[e.jsxs(Hx,{children:[e.jsx(pt,{size:16}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(qx,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(J,{onClick:y,disabled:S,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:S?e.jsx(Re,{size:14}):"Test"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{$outline:!0,onClick:()=>r(t.id),style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Remove"}),o===t.id&&e.jsx(Mr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:s})]})]})]}),z&&e.jsxs("div",{style:{marginBottom:"12px",padding:"8px 12px",background:z.success?"var(--color-success-background, rgba(34, 197, 94, 0.1))":"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"6px",fontSize:"12px",color:z.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:[z.success?"✓ Connection is valid":"✗ Connection failed",z.errors&&Object.entries(z.errors).map(([O,N])=>e.jsxs("div",{style:{fontWeight:400,marginTop:"4px"},children:[O.replace(/_/g," "),": ",N]},O))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 16px",fontSize:"12px",marginBottom:"16px"},children:[t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Entity ID"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_entity_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"SSO URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_sso_url})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Issuer URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.oidc_issuer_url}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Client ID"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_client_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Scopes"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_scopes||"openid profile email"})]}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Created"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:new Date(t.created_at).toLocaleDateString()})]}),e.jsxs(Kx,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs(Qx,{style:{marginBottom:0},children:[e.jsx(pt,{size:14}),"SCIM Provisioning"]}),e.jsx(Xx,{children:!(d!=null&&d.exists)||!((j=d==null?void 0:d.token)!=null&&j.enabled)?e.jsx(J,{onClick:g,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"130px"},children:m?e.jsx(Re,{size:14}):"Generate Token"}):e.jsxs(e.Fragment,{children:[e.jsx(J,{onClick:g,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:m?e.jsx(Re,{size:14}):"Rotate"}),e.jsx(J,{$outline:!0,onClick:_,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Revoke"})]})})]}),(((T=d==null?void 0:d.token)==null?void 0:T.scim_base_url)||v)&&e.jsx("div",{style:{marginBottom:"8px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Base URL:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)"},children:((R=d==null?void 0:d.token)==null?void 0:R.scim_base_url)||"Loading..."}),((M=d==null?void 0:d.token)==null?void 0:M.scim_base_url)&&e.jsx(Qr,{onClick:()=>E(d.token.scim_base_url,"scim-url"),children:k==="scim-url"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]})}),v&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Token:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)",fontFamily:"monospace"},children:v}),e.jsx(Qr,{onClick:()=>E(v,"scim-token"),children:k==="scim-token"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginTop:"6px"},children:"⚠️ Copy this token now. It won't be shown again."})]}),(d==null?void 0:d.exists)&&((I=d==null?void 0:d.token)==null?void 0:I.enabled)&&!v&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-muted)"},children:["Token: ",e.jsxs("code",{style:{color:"var(--color-foreground)",background:"var(--color-background-alt)",padding:"2px 6px",borderRadius:"4px"},children:[d.token.token_prefix,"..."]}),d.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(d.token.last_used_at).toLocaleDateString()]})]})]})]})},Qn=l.h3`
2747
+ `,e0=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:s,testConnection:a,generateSCIMToken:h,getSCIMToken:f,revokeSCIMToken:c,toast:u})=>{var j,T,R,M,I;const[d,p]=i.useState(null),[m,x]=i.useState(!1),[v,b]=i.useState(null),[k,$]=i.useState(null),[S,C]=i.useState(!1),[z,w]=i.useState(null);i.useEffect(()=>{f&&t.id&&f(t.id).then(p).catch(()=>{})},[t.id,f]);const y=async()=>{if(a){C(!0),w(null);try{const O=await a(t.id);w(O)}catch(O){w({success:!1,checks:{},errors:{general:O.message||"Test failed"}})}finally{C(!1)}}},g=async()=>{if(h){x(!0);try{const O=await h(t.id);b(O.token),p({exists:!0,token:O}),u("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(O){u(O.message||"Failed to generate token","error")}finally{x(!1)}}},_=async()=>{if(c){x(!0);try{await c(t.id),p({exists:!1,scim_base_url:d==null?void 0:d.scim_base_url}),b(null),u("SCIM token revoked","info")}catch(O){u(O.message||"Failed to revoke token","error")}finally{x(!1)}}},E=(O,N)=>{navigator.clipboard.writeText(O),$(N),setTimeout(()=>$(null),2e3)};return e.jsxs(Gx,{children:[e.jsxs(Hx,{children:[e.jsxs(qx,{children:[e.jsx(pt,{size:16}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(Yx,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(J,{onClick:y,disabled:S,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:S?e.jsx(Re,{size:14}):"Test"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{$outline:!0,onClick:()=>r(t.id),style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Remove"}),o===t.id&&e.jsx(Mr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:s})]})]})]}),z&&e.jsxs("div",{style:{marginBottom:"12px",padding:"8px 12px",background:z.success?"var(--color-success-background, rgba(34, 197, 94, 0.1))":"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"6px",fontSize:"12px",color:z.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:[z.success?"✓ Connection is valid":"✗ Connection failed",z.errors&&Object.entries(z.errors).map(([O,N])=>e.jsxs("div",{style:{fontWeight:400,marginTop:"4px"},children:[O.replace(/_/g," "),": ",N]},O))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 16px",fontSize:"12px",marginBottom:"16px"},children:[t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Entity ID"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_entity_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"SSO URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_sso_url})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Issuer URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.oidc_issuer_url}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Client ID"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_client_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Scopes"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_scopes||"openid profile email"})]}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Created"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:new Date(t.created_at).toLocaleDateString()})]}),e.jsxs(Qx,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs(Xx,{style:{marginBottom:0},children:[e.jsx(pt,{size:14}),"SCIM Provisioning"]}),e.jsx(Jx,{children:!(d!=null&&d.exists)||!((j=d==null?void 0:d.token)!=null&&j.enabled)?e.jsx(J,{onClick:g,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"130px"},children:m?e.jsx(Re,{size:14}):"Generate Token"}):e.jsxs(e.Fragment,{children:[e.jsx(J,{onClick:g,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:m?e.jsx(Re,{size:14}):"Rotate"}),e.jsx(J,{$outline:!0,onClick:_,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Revoke"})]})})]}),(((T=d==null?void 0:d.token)==null?void 0:T.scim_base_url)||v)&&e.jsx("div",{style:{marginBottom:"8px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Base URL:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)"},children:((R=d==null?void 0:d.token)==null?void 0:R.scim_base_url)||"Loading..."}),((M=d==null?void 0:d.token)==null?void 0:M.scim_base_url)&&e.jsx(Qr,{onClick:()=>E(d.token.scim_base_url,"scim-url"),children:k==="scim-url"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]})}),v&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Token:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)",fontFamily:"monospace"},children:v}),e.jsx(Qr,{onClick:()=>E(v,"scim-token"),children:k==="scim-token"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginTop:"6px"},children:"⚠️ Copy this token now. It won't be shown again."})]}),(d==null?void 0:d.exists)&&((I=d==null?void 0:d.token)==null?void 0:I.enabled)&&!v&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-muted)"},children:["Token: ",e.jsxs("code",{style:{color:"var(--color-foreground)",background:"var(--color-background-alt)",padding:"2px 6px",borderRadius:"4px"},children:[d.token.token_prefix,"..."]}),d.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(d.token.last_used_at).toLocaleDateString()]})]})]})]})},Qn=l.h3`
2746
2748
  margin: 0 0 12px 0;
2747
2749
  font-size: 13px;
2748
2750
  font-weight: 600;
2749
2751
  color: var(--color-foreground);
2750
2752
  text-transform: uppercase;
2751
2753
  letter-spacing: 0.5px;
2752
- `,e0=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=st(),{deployment:n}=we(),{toast:s}=Je(),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState("saml"),[p,m]=i.useState(null),[x,v]=i.useState(!1),[b,k]=i.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[$,S]=i.useState(!1),[C,z]=i.useState(null),{data:w=[],isLoading:y}=Ze("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(O=>O.verified),{revalidateOnFocus:!1}),g=I=>{c(I),d(I.protocol),I.protocol==="saml"?k(O=>{var N,D,L;return{...O,idp_entity_id:I.placeholders.entityId||"",idp_sso_url:I.placeholders.ssoUrl||"",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}}):k(O=>{var N,D,L;return{...O,oidc_issuer_url:I.placeholders.issuerUrl||"",oidc_scopes:I.placeholders.scopes||"openid profile email",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}})},_=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",E=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",j=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",T=(I,O)=>{navigator.clipboard.writeText(I),m(O),setTimeout(()=>m(null),2e3)},R=async I=>{I.preventDefault();const O=N=>N.includes("{")||N.includes("}");if(u==="saml"){if(!b.idp_entity_id||O(b.idp_entity_id)){s("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||O(b.idp_sso_url)){s("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){s("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||O(b.oidc_issuer_url)){s("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||O(b.oidc_client_id)){s("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){s("Please enter the Client Secret","error");return}}h(!0);try{const N={};b.attr_first_name&&(N.first_name=b.attr_first_name),b.attr_last_name&&(N.last_name=b.attr_last_name),b.attr_email&&(N.email=b.attr_email);const D=Object.keys(N).length>0;u==="saml"?await t({protocol:"saml",domain_id:b.domain_id||void 0,idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}}):await t({protocol:"oidc",domain_id:b.domain_id||void 0,oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret,oidc_scopes:b.oidc_scopes,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}})}finally{h(!1)}},M=async()=>{S(!0),z(null);const I=D=>D.includes("{")||D.includes("}"),O={},N={};if(u==="saml"?(b.idp_entity_id?I(b.idp_entity_id)?(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):N.entity_id_valid=!0:(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?I(b.idp_sso_url)?(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):N.sso_url_valid=!0:(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?N.certificate_provided=!0:(N.certificate_provided=!1,O.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?I(b.oidc_issuer_url)?(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):N.issuer_url_valid=!0:(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?I(b.oidc_client_id)?(N.client_id_valid=!1,O.client_id_valid="Client ID contains placeholder values - please replace with actual values"):N.client_id_valid=!0:(N.client_id_valid=!1,O.client_id_valid="Client ID is required")),Object.keys(O).length>0){z({success:!1,checks:N,errors:O}),S(!1);return}try{const D=u==="saml"?{protocol:"saml",idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate}:{protocol:"oidc",oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret},L=await(o==null?void 0:o(D));L&&z(L)}catch(D){z({success:!1,checks:{},errors:{general:"Test failed: "+D.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:R,autoComplete:"off",children:[f?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[f.logo?e.jsx(Kn,{src:f.logo,alt:f.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:f.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:f.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Qn,{children:"SAML Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="saml").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))}),e.jsx(Qn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="oidc").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))})]}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(bi,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:u==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:j}),e.jsx(Qr,{onClick:()=>T(j,"acs"),children:p==="acs"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:E}),e.jsx(Qr,{onClick:()=>T(E,"metadata"),children:p==="metadata"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:_}),e.jsx(Qr,{onClick:()=>T(_,"callback"),children:p==="callback"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Qn,{style:{margin:0},children:f?`${f.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[f&&f.docUrl&&e.jsxs("a",{href:f.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Ns,{size:12})," Docs"]}),e.jsx(J,{type:"button",onClick:M,disabled:$||!f,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Re,{size:16}):"Test Connection"}),e.jsx(J,{type:"submit",disabled:a||w.length===0||!f,style:{width:"auto",padding:"8px 16px"},children:a?e.jsx(Re,{size:16}):"Create Connection"})]})]}),C&&(()=>{const I={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:C.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${C.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:C.success?"#10b981":"#ef4444"},children:C.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(C.checks).map(([O,N])=>{var D;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:N?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:N?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:I[O]||O.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((D=C.errors)==null?void 0:D[O])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:C.errors[O]})]})]},O)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!f&&e.jsxs(he,{children:[e.jsx(ie,{children:"Protocol *"}),e.jsxs(_i,{value:u,onChange:I=>d(I.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"Domain *"}),y?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):w.length===0?e.jsx(bi,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(_i,{value:b.domain_id,onChange:I=>k({...b,domain_id:I.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),w.map(I=>e.jsx("option",{value:I.id,children:I.fqdn},I.id))]})]}),u==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"IdP Entity ID *"}),e.jsx(se,{type:"text",value:b.idp_entity_id,onChange:I=>k({...b,idp_entity_id:I.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"IdP SSO URL *"}),e.jsx(se,{type:"url",value:b.idp_sso_url,onChange:I=>k({...b,idp_sso_url:I.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"X.509 Certificate *"}),e.jsx(Yx,{value:b.idp_certificate,onChange:I=>k({...b,idp_certificate:I.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Issuer URL *"}),e.jsx(se,{type:"url",value:b.oidc_issuer_url,onChange:I=>k({...b,oidc_issuer_url:I.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client ID *"}),e.jsx(se,{type:"text",value:b.oidc_client_id,onChange:I=>k({...b,oidc_client_id:I.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client Secret *"}),e.jsx(se,{type:"password",value:b.oidc_client_secret,onChange:I=>k({...b,oidc_client_secret:I.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Scopes"}),e.jsx(se,{type:"text",value:b.oidc_scopes,onChange:I=>k({...b,oidc_scopes:I.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(he,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsx(mr,{checked:b.jit_enabled,onChange:()=>k({...b,jit_enabled:!b.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>v(!x),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:x?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"First Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_first_name,onChange:I=>k({...b,attr_first_name:I.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Last Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_last_name,onChange:I=>k({...b,attr_last_name:I.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Email Attribute"}),e.jsx(se,{type:"text",value:b.attr_email,onChange:I=>k({...b,attr_email:I.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},Ci=l.div`
2754
+ `,t0=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=st(),{deployment:n}=we(),{toast:s}=Je(),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState("saml"),[p,m]=i.useState(null),[x,v]=i.useState(!1),[b,k]=i.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[$,S]=i.useState(!1),[C,z]=i.useState(null),{data:w=[],isLoading:y}=Ze("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(O=>O.verified),{revalidateOnFocus:!1}),g=I=>{c(I),d(I.protocol),I.protocol==="saml"?k(O=>{var N,D,L;return{...O,idp_entity_id:I.placeholders.entityId||"",idp_sso_url:I.placeholders.ssoUrl||"",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}}):k(O=>{var N,D,L;return{...O,oidc_issuer_url:I.placeholders.issuerUrl||"",oidc_scopes:I.placeholders.scopes||"openid profile email",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}})},_=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",E=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",j=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",T=(I,O)=>{navigator.clipboard.writeText(I),m(O),setTimeout(()=>m(null),2e3)},R=async I=>{I.preventDefault();const O=N=>N.includes("{")||N.includes("}");if(u==="saml"){if(!b.idp_entity_id||O(b.idp_entity_id)){s("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||O(b.idp_sso_url)){s("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){s("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||O(b.oidc_issuer_url)){s("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||O(b.oidc_client_id)){s("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){s("Please enter the Client Secret","error");return}}h(!0);try{const N={};b.attr_first_name&&(N.first_name=b.attr_first_name),b.attr_last_name&&(N.last_name=b.attr_last_name),b.attr_email&&(N.email=b.attr_email);const D=Object.keys(N).length>0;u==="saml"?await t({protocol:"saml",domain_id:b.domain_id||void 0,idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}}):await t({protocol:"oidc",domain_id:b.domain_id||void 0,oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret,oidc_scopes:b.oidc_scopes,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}})}finally{h(!1)}},M=async()=>{S(!0),z(null);const I=D=>D.includes("{")||D.includes("}"),O={},N={};if(u==="saml"?(b.idp_entity_id?I(b.idp_entity_id)?(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):N.entity_id_valid=!0:(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?I(b.idp_sso_url)?(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):N.sso_url_valid=!0:(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?N.certificate_provided=!0:(N.certificate_provided=!1,O.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?I(b.oidc_issuer_url)?(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):N.issuer_url_valid=!0:(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?I(b.oidc_client_id)?(N.client_id_valid=!1,O.client_id_valid="Client ID contains placeholder values - please replace with actual values"):N.client_id_valid=!0:(N.client_id_valid=!1,O.client_id_valid="Client ID is required")),Object.keys(O).length>0){z({success:!1,checks:N,errors:O}),S(!1);return}try{const D=u==="saml"?{protocol:"saml",idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate}:{protocol:"oidc",oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret},L=await(o==null?void 0:o(D));L&&z(L)}catch(D){z({success:!1,checks:{},errors:{general:"Test failed: "+D.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:R,autoComplete:"off",children:[f?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[f.logo?e.jsx(Kn,{src:f.logo,alt:f.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:f.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:f.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Qn,{children:"SAML Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="saml").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))}),e.jsx(Qn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="oidc").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))})]}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(bi,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:u==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:j}),e.jsx(Qr,{onClick:()=>T(j,"acs"),children:p==="acs"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:E}),e.jsx(Qr,{onClick:()=>T(E,"metadata"),children:p==="metadata"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:_}),e.jsx(Qr,{onClick:()=>T(_,"callback"),children:p==="callback"?e.jsx(tt,{size:12}):e.jsx(pr,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Qn,{style:{margin:0},children:f?`${f.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[f&&f.docUrl&&e.jsxs("a",{href:f.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Ns,{size:12})," Docs"]}),e.jsx(J,{type:"button",onClick:M,disabled:$||!f,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Re,{size:16}):"Test Connection"}),e.jsx(J,{type:"submit",disabled:a||w.length===0||!f,style:{width:"auto",padding:"8px 16px"},children:a?e.jsx(Re,{size:16}):"Create Connection"})]})]}),C&&(()=>{const I={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:C.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${C.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:C.success?"#10b981":"#ef4444"},children:C.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(C.checks).map(([O,N])=>{var D;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:N?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:N?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:I[O]||O.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((D=C.errors)==null?void 0:D[O])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:C.errors[O]})]})]},O)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!f&&e.jsxs(he,{children:[e.jsx(ie,{children:"Protocol *"}),e.jsxs(_i,{value:u,onChange:I=>d(I.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"Domain *"}),y?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):w.length===0?e.jsx(bi,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(_i,{value:b.domain_id,onChange:I=>k({...b,domain_id:I.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),w.map(I=>e.jsx("option",{value:I.id,children:I.fqdn},I.id))]})]}),u==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"IdP Entity ID *"}),e.jsx(se,{type:"text",value:b.idp_entity_id,onChange:I=>k({...b,idp_entity_id:I.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"IdP SSO URL *"}),e.jsx(se,{type:"url",value:b.idp_sso_url,onChange:I=>k({...b,idp_sso_url:I.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"X.509 Certificate *"}),e.jsx(Zx,{value:b.idp_certificate,onChange:I=>k({...b,idp_certificate:I.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Issuer URL *"}),e.jsx(se,{type:"url",value:b.oidc_issuer_url,onChange:I=>k({...b,oidc_issuer_url:I.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client ID *"}),e.jsx(se,{type:"text",value:b.oidc_client_id,onChange:I=>k({...b,oidc_client_id:I.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client Secret *"}),e.jsx(se,{type:"password",value:b.oidc_client_secret,onChange:I=>k({...b,oidc_client_secret:I.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Scopes"}),e.jsx(se,{type:"text",value:b.oidc_scopes,onChange:I=>k({...b,oidc_scopes:I.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(he,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsx(mr,{checked:b.jit_enabled,onChange:()=>k({...b,jit_enabled:!b.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>v(!x),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:x?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"First Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_first_name,onChange:I=>k({...b,attr_first_name:I.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Last Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_last_name,onChange:I=>k({...b,attr_last_name:I.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Email Attribute"}),e.jsx(se,{type:"text",value:b.attr_email,onChange:I=>k({...b,attr_email:I.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},Ci=l.div`
2753
2755
  * {
2754
2756
  box-sizing: border-box;
2755
2757
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -2788,14 +2790,14 @@ cursor: pointer;
2788
2790
  pointer-events: none;
2789
2791
  z-index: 1;
2790
2792
  }
2791
- `,t0=l.div`
2793
+ `,r0=l.div`
2792
2794
  padding: 0 24px;
2793
2795
  border-bottom: 1px solid var(--color-border);
2794
2796
 
2795
2797
  @media (max-width: 768px) {
2796
2798
  padding: 0 20px;
2797
2799
  }
2798
- `,r0=l.div`
2800
+ `,o0=l.div`
2799
2801
  display: flex;
2800
2802
  gap: 20px;
2801
2803
  overflow-x: auto;
@@ -2836,7 +2838,7 @@ cursor: pointer;
2836
2838
  display: inline-flex;
2837
2839
  align-items: center;
2838
2840
  gap: 6px;
2839
- `,o0=l.div`
2841
+ `,n0=l.div`
2840
2842
  flex: 1;
2841
2843
  padding: 24px 24px 0 24px;
2842
2844
  overflow-y: auto;
@@ -2851,7 +2853,7 @@ cursor: pointer;
2851
2853
  flex-wrap: wrap;
2852
2854
  gap: 12px;
2853
2855
  margin-bottom: 24px;
2854
- `,n0=()=>{var O,N,D,L;const{activeOrganization:t,loading:r}=st(),{switchOrganization:o,refetch:n}=Qe(),{workspaces:s}=Wt(),{deployment:a}=we(),{deleteOrganization:h,updateOrganization:f}=on(),{toast:c}=Je(),[u,d]=i.useState((t==null?void 0:t.name)||""),[p,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),b=i.useRef(null),[k,$]=i.useState(!1),[S,C]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||k))try{$(!0),await f(t,{name:u,description:p}),c("Changes saved","info")}catch(P){const A=P.message||"Failed to save changes. Please try again.";c(A,"error")}finally{$(!1)}},[t,u,p,x,S,f,c]);i.useEffect(()=>{var P;t&&(d(t.name||""),m(t.description||""),v(t.image_url||null),C({allowed_ips:((P=t.whitelisted_ips)==null?void 0:P.join(`
2856
+ `,s0=()=>{var O,N,D,L;const{activeOrganization:t,loading:r}=st(),{switchOrganization:o,refetch:n}=Qe(),{workspaces:s}=Wt(),{deployment:a}=we(),{deleteOrganization:h,updateOrganization:f}=on(),{toast:c}=Je(),[u,d]=i.useState((t==null?void 0:t.name)||""),[p,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),b=i.useRef(null),[k,$]=i.useState(!1),[S,C]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||k))try{$(!0),await f(t,{name:u,description:p}),c("Changes saved","info")}catch(P){const A=P.message||"Failed to save changes. Please try again.";c(A,"error")}finally{$(!1)}},[t,u,p,x,S,f,c]);i.useEffect(()=>{var P;t&&(d(t.name||""),m(t.description||""),v(t.image_url||null),C({allowed_ips:((P=t.whitelisted_ips)==null?void 0:P.join(`
2855
2857
  `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=i.useMemo(()=>s.filter(A=>A.organization.id===(t==null?void 0:t.id)),[s,t==null?void 0:t.id]),R=async()=>{if(!(!t||z!==t.name))try{g(!0),await o(""),await h(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{g(!1),w("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const M=P=>{var A;if((A=P.target.files)!=null&&A[0]){const q=P.target.files[0];if(q.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!q.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),v(URL.createObjectURL(q)),setTimeout(()=>j(),100)}},I=()=>{b.current&&b.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:I,onMouseEnter:P=>{P.currentTarget.style.borderColor="var(--color-primary)",P.currentTarget.style.transform="scale(1.02)"},onMouseLeave:P=>{P.currentTarget.style.borderColor="var(--color-border)",P.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Jr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:M,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var P;return(P=b.current)==null?void 0:P.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jr,{size:14}),x?"Change":"Upload"]}),e.jsxs(J,{onClick:()=>{v(null),b.current&&(b.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(gn,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"name",children:"Organization Name"}),e.jsx(se,{id:"name",type:"text",value:u,onChange:P=>d(P.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(se,{id:"description",as:"textarea",value:p,onChange:P=>m(P.target.value),onBlur:j,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((O=a==null?void 0:a.b2b_settings)==null?void 0:O.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(mr,{checked:S.mfa_required,onChange:()=>{C(P=>({...P,mfa_required:!P.mfa_required})),setTimeout(()=>j(),100)}})]}),((N=a==null?void 0:a.b2b_settings)==null?void 0:N.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(mr,{checked:S.ip_restrictions,onChange:()=>{C(P=>({...P,ip_restrictions:!P.ip_restrictions})),setTimeout(()=>j(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),S.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(se,{id:"allowed_ips",as:"textarea",value:S.allowed_ips,onChange:P=>C(A=>({...A,allowed_ips:P.target.value})),onBlur:j,placeholder:`192.168.1.1
2856
2858
  10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((D=a==null?void 0:a.b2b_settings)==null?void 0:D.workspaces_enabled)&&T.length>0&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Us,{options:T.map(P=>({value:P.id,label:P.name})),value:S.default_workspace_id,onChange:P=>{C(A=>({...A,default_workspace_id:P})),setTimeout(()=>j(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((L=a==null?void 0:a.b2b_settings)==null?void 0:L.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:_?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(J,{onClick:()=>{_?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:_?"Cancel":"Delete"})]}),_&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(se,{id:"confirm_name",type:"text",value:z,onChange:P=>w(P.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(J,{onClick:R,disabled:z!==(t==null?void 0:t.name)||y,style:{background:z===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:z===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:z===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:y?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})]})})},Si=l.span`
2857
2859
  background: var(--color-primary-background);
@@ -2890,7 +2892,7 @@ cursor: pointer;
2890
2892
  opacity: 0.5;
2891
2893
  cursor: not-allowed;
2892
2894
  }
2893
- `,s0=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=st(),s=i.useRef(null),[a,h]=i.useState(null),{data:f=[],isLoading:c,mutate:u}=Ze(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((E,j)=>({...E,verified:E.verified!==void 0?E.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),d=f,[p,m]=i.useState(!1),[x,v]=i.useState(null),[b,k]=i.useState(""),[$,S]=i.useState(null),C=i.useRef(null),z=i.useRef({}),w=i.useMemo(()=>{let _=d;if(b.trim()!==""){const E=b.toLowerCase();_=_.filter(j=>j.fqdn.toLowerCase().includes(E))}return _},[d,b]),y=async _=>{await n(_),u()},g=async _=>{v(_)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(rd,{children:[e.jsx(At,{value:b,onChange:k,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(J,{ref:C,onClick:()=>m(!p),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),p&&e.jsx(xi,{onClose:()=>{m(!1),u()},triggerRef:C})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),w!=null&&w.length?e.jsxs(_t,{ref:s,children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Domain"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{children:"Date Added"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(_=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:_.fqdn}),e.jsx(Ue,{children:_.verified?e.jsx(Si,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(Si,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(jt,{size:9})," Pending Verification"]})}),e.jsx(Ue,{children:new Date(_.created_at).toLocaleDateString()}),e.jsx($t,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(ft,{style:{marginLeft:"auto"},open:$===_.id,openChange:E=>S(E?_.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{ref:E=>{z.current[_.id]=E},children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{g(_.id),S(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:_.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Be,{onClick:()=>{S(null),navigator.clipboard.writeText(_.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pr,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Be,{onClick:()=>{window.open(`https://${_.fqdn}`,"_blank"),S(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ns,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>{S(null),h(_.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),a===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>y(_),onCancel:()=>h(null)}),x===_.id&&e.jsx(xi,{domain:_,onClose:()=>v(null),triggerRef:{current:z.current[_.id]}})]})})]},_.id))})]}):e.jsx(xt,{title:b!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},a0=l.div`
2895
+ `,a0=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=st(),s=i.useRef(null),[a,h]=i.useState(null),{data:f=[],isLoading:c,mutate:u}=Ze(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((E,j)=>({...E,verified:E.verified!==void 0?E.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),d=f,[p,m]=i.useState(!1),[x,v]=i.useState(null),[b,k]=i.useState(""),[$,S]=i.useState(null),C=i.useRef(null),z=i.useRef({}),w=i.useMemo(()=>{let _=d;if(b.trim()!==""){const E=b.toLowerCase();_=_.filter(j=>j.fqdn.toLowerCase().includes(E))}return _},[d,b]),y=async _=>{await n(_),u()},g=async _=>{v(_)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(rd,{children:[e.jsx(At,{value:b,onChange:k,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(J,{ref:C,onClick:()=>m(!p),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),p&&e.jsx(xi,{onClose:()=>{m(!1),u()},triggerRef:C})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),w!=null&&w.length?e.jsxs(_t,{ref:s,children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Domain"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{children:"Date Added"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(_=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:_.fqdn}),e.jsx(Ue,{children:_.verified?e.jsx(Si,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(Si,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(jt,{size:9})," Pending Verification"]})}),e.jsx(Ue,{children:new Date(_.created_at).toLocaleDateString()}),e.jsx($t,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(ft,{style:{marginLeft:"auto"},open:$===_.id,openChange:E=>S(E?_.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{ref:E=>{z.current[_.id]=E},children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{g(_.id),S(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:_.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Be,{onClick:()=>{S(null),navigator.clipboard.writeText(_.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pr,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Be,{onClick:()=>{window.open(`https://${_.fqdn}`,"_blank"),S(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ns,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>{S(null),h(_.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),a===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>y(_),onCancel:()=>h(null)}),x===_.id&&e.jsx(xi,{domain:_,onClose:()=>v(null),triggerRef:{current:z.current[_.id]}})]})})]},_.id))})]}):e.jsx(xt,{title:b!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},i0=l.div`
2894
2896
  width: 40px;
2895
2897
  height: 40px;
2896
2898
  border-radius: 50%;
@@ -2902,11 +2904,11 @@ cursor: pointer;
2902
2904
  font-weight: 400;
2903
2905
  font-size: 14px;
2904
2906
  overflow: hidden;
2905
- `,i0=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:a,removeMember:h}=st(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),[p,m]=i.useState(!1),x=i.useRef(null),{data:v=[],isLoading:b,mutate:k}=Ze(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:$=[],isLoading:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),C=$,z=i.useMemo(()=>u?v.filter(j=>{var N;const T=j.user;if(!T)return!1;const R=T.first_name||"",M=T.last_name||"",I=((N=T.primary_email_address)==null?void 0:N.email)||"";return`${R} ${M}`.trim().toLowerCase().includes(u.toLowerCase())||I.toLowerCase().includes(u.toLowerCase())}):v,[v,u]),w=async(j,T,R)=>{try{R?(await a(j,T),c("Role removed successfully","info")):(await s(j,T),c("Role added successfully","info")),k()}catch(M){const I=M.message||"Failed to update role. Please try again.";c(I,"error")}},y=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),g=(j,T)=>{var R;return((R=j.roles)==null?void 0:R.some(M=>M.id===T))||!1},_=async j=>{try{await h(j),k(),c("Member removed successfully","info")}catch(T){const R=T.message||"Failed to remove member. Please try again.";c(R,"error")}},E=()=>{m(!1),k(),c("Invitation sent successfully","info")};return r||b||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),e.jsx(J,{ref:x,onClick:()=>m(!p),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),p&&e.jsx(ed,{onClose:()=>m(!1),onSuccess:E,roles:C,triggerRef:x}),z.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Roles"})]})}),e.jsx(St,{children:z.map(j=>{var I,O;const T=j.roles||[],R=j.user,M=(R==null?void 0:R.id)===((I=f==null?void 0:f.active_signin)==null?void 0:I.user_id);return e.jsxs(Ye,{children:[e.jsx(td,{children:e.jsxs("div",{children:[e.jsx(a0,{children:R!=null&&R.profile_picture_url?e.jsx("img",{src:R.profile_picture_url,alt:`${R.first_name||""} ${R.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):y(R==null?void 0:R.first_name,R==null?void 0:R.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var D;if(!R)return"Unknown User";const N=`${R.first_name||""} ${R.last_name||""}`.trim();return N||((D=R.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),M&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(O=R==null?void 0:R.primary_email_address)==null?void 0:O.email})]})]})}),e.jsx(Ue,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[C.map(N=>{const D=g(j,N.id);return e.jsx(Be,{onClick:()=>w(j,N,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:N.name}),D&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},N.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>_(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},c0=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:a}=st(),{toast:h}=Je(),[f,c]=i.useState(!1),[u,d]=i.useState(""),p=i.useRef(null),{data:m=[],isLoading:x,mutate:v}=Ze(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:b=[],isLoading:k}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),$=b,S=i.useMemo(()=>u?m.filter(y=>y.email.toLowerCase().includes(u.toLowerCase())):m,[m,u]),C=()=>{h("Invitation sent successfully","info"),v(),c(!1)},z=async y=>{try{await s(y),v(),h("Invitation cancelled successfully","info")}catch(g){const _=g.message||"Failed to cancel invitation. Please try again.";h(_,"error")}},w=async y=>{try{await a(y),h("Invitation resent successfully","info")}catch(g){const _=g.message||"Failed to resend invitation. Please try again.";h(_,"error")}};return r||x||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search invitations..."})}),e.jsx(J,{ref:p,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(ed,{onClose:()=>c(!1),onSuccess:C,roles:$,triggerRef:p}),S.length===0?e.jsx(xt,{title:u?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:S.map(y=>{var g;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:y.email}),e.jsx(Ue,{children:((g=y.initial_organization_role)==null?void 0:g.name)||"No role"}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(Vs,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>w(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(hn,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>z(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},y.id)})})]})]})},l0=()=>{var y;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=st(),{deployment:s}=we(),[a,h]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[u,d]=i.useState(null),[p,m]=i.useState(""),[x,v]=i.useState(null),b=i.useRef(null),{data:k=[],isLoading:$,mutate:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),C=i.useMemo(()=>p?k.filter(g=>g.name.toLowerCase().includes(p.toLowerCase())):k,[k,p]),z=async g=>{try{g.id?(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role created successfully",type:"success"})),h({isOpen:!1}),S()}catch(_){const E=(_==null?void 0:_.message)||(g.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");g.id?c({text:E,type:"error"}):c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async g=>{try{await n(g),S()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(jt,{size:16}),f.text]}),e.jsxs(rd,{children:[e.jsx(At,{placeholder:"Search roles",onChange:m,value:p}),((y=s==null?void 0:s.b2b_settings)==null?void 0:y.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(J,{ref:b,onClick:()=>h({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(vi,{role:a.role,onClose:()=>h({isOpen:!1}),onSuccess:z,triggerRef:b})]})]}),C.length===0?e.jsx(xt,{title:p?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:C.map(g=>{var _;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:g.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:g.permissions.join(", ")}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:u===g.id,openChange:E=>d(E?g.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{disabled:!g.organization_id,"data-role-dropdown-trigger":g.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{d(null),h({isOpen:!0,role:g})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{d(null),v(g.id)},children:"Remove Role"})]})]}),x===g.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(g),onCancel:()=>v(null)}),a.isOpen&&((_=a.role)==null?void 0:_.id)===g.id&&e.jsx(vi,{role:a.role,onClose:()=>{h({isOpen:!1}),d(null)},onSuccess:z})]})})]},g.id)})})]})]})},od=()=>{var d;const{loading:t,activeOrganization:r}=st(),{deployment:o}=we(),[n,s]=i.useState("general"),[a,h]=i.useState(null),[f,c]=i.useState("info"),u=i.useCallback((p,m="info")=>{h(p),c(m),setTimeout(()=>h(null),3e3)},[h]);return t?e.jsx(Xn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):r?e.jsx(Ci,{children:e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:u},children:e.jsxs(Xn,{children:[e.jsx(t0,{children:e.jsxs(r0,{children:[e.jsx(jr,{$isActive:n==="general",onClick:()=>s("general"),children:e.jsxs(kr,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(jr,{$isActive:n==="domains",onClick:()=>s("domains"),children:e.jsxs(kr,{children:[e.jsx(Ah,{size:16}),"Domains"]})}),e.jsx(jr,{$isActive:n==="members",onClick:()=>s("members"),children:e.jsxs(kr,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(jr,{$isActive:n==="invitations",onClick:()=>s("invitations"),children:e.jsxs(kr,{children:[e.jsx(hn,{size:16}),"Invitations"]})}),e.jsx(jr,{$isActive:n==="roles",onClick:()=>s("roles"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Roles"]})}),((d=o==null?void 0:o.b2b_settings)==null?void 0:d.enterprise_sso_enabled)&&e.jsx(jr,{$isActive:n==="sso",onClick:()=>s("sso"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Single Sign-On"]})})]})}),e.jsxs(o0,{children:[n==="general"&&e.jsx(n0,{}),n==="domains"&&e.jsx(s0,{}),n==="members"&&e.jsx(i0,{}),n==="invitations"&&e.jsx(c0,{}),n==="roles"&&e.jsx(l0,{}),n==="sso"&&e.jsx(Zx,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):e.jsx(Ci,{children:e.jsx(Xn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Jr,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(md,{})]})})})},d0=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(od,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),u0=l.div`
2907
+ `,c0=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:a,removeMember:h}=st(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),[p,m]=i.useState(!1),x=i.useRef(null),{data:v=[],isLoading:b,mutate:k}=Ze(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:$=[],isLoading:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),C=$,z=i.useMemo(()=>u?v.filter(j=>{var N;const T=j.user;if(!T)return!1;const R=T.first_name||"",M=T.last_name||"",I=((N=T.primary_email_address)==null?void 0:N.email)||"";return`${R} ${M}`.trim().toLowerCase().includes(u.toLowerCase())||I.toLowerCase().includes(u.toLowerCase())}):v,[v,u]),w=async(j,T,R)=>{try{R?(await a(j,T),c("Role removed successfully","info")):(await s(j,T),c("Role added successfully","info")),k()}catch(M){const I=M.message||"Failed to update role. Please try again.";c(I,"error")}},y=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),g=(j,T)=>{var R;return((R=j.roles)==null?void 0:R.some(M=>M.id===T))||!1},_=async j=>{try{await h(j),k(),c("Member removed successfully","info")}catch(T){const R=T.message||"Failed to remove member. Please try again.";c(R,"error")}},E=()=>{m(!1),k(),c("Invitation sent successfully","info")};return r||b||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),e.jsx(J,{ref:x,onClick:()=>m(!p),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),p&&e.jsx(ed,{onClose:()=>m(!1),onSuccess:E,roles:C,triggerRef:x}),z.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Roles"})]})}),e.jsx(St,{children:z.map(j=>{var I,O;const T=j.roles||[],R=j.user,M=(R==null?void 0:R.id)===((I=f==null?void 0:f.active_signin)==null?void 0:I.user_id);return e.jsxs(Ye,{children:[e.jsx(td,{children:e.jsxs("div",{children:[e.jsx(i0,{children:R!=null&&R.profile_picture_url?e.jsx("img",{src:R.profile_picture_url,alt:`${R.first_name||""} ${R.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):y(R==null?void 0:R.first_name,R==null?void 0:R.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var D;if(!R)return"Unknown User";const N=`${R.first_name||""} ${R.last_name||""}`.trim();return N||((D=R.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),M&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(O=R==null?void 0:R.primary_email_address)==null?void 0:O.email})]})]})}),e.jsx(Ue,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[C.map(N=>{const D=g(j,N.id);return e.jsx(Be,{onClick:()=>w(j,N,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:N.name}),D&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},N.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>_(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},l0=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:a}=st(),{toast:h}=Je(),[f,c]=i.useState(!1),[u,d]=i.useState(""),p=i.useRef(null),{data:m=[],isLoading:x,mutate:v}=Ze(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:b=[],isLoading:k}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),$=b,S=i.useMemo(()=>u?m.filter(y=>y.email.toLowerCase().includes(u.toLowerCase())):m,[m,u]),C=()=>{h("Invitation sent successfully","info"),v(),c(!1)},z=async y=>{try{await s(y),v(),h("Invitation cancelled successfully","info")}catch(g){const _=g.message||"Failed to cancel invitation. Please try again.";h(_,"error")}},w=async y=>{try{await a(y),h("Invitation resent successfully","info")}catch(g){const _=g.message||"Failed to resend invitation. Please try again.";h(_,"error")}};return r||x||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search invitations..."})}),e.jsx(J,{ref:p,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(ed,{onClose:()=>c(!1),onSuccess:C,roles:$,triggerRef:p}),S.length===0?e.jsx(xt,{title:u?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:S.map(y=>{var g;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:y.email}),e.jsx(Ue,{children:((g=y.initial_organization_role)==null?void 0:g.name)||"No role"}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(Vs,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>w(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(hn,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>z(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},y.id)})})]})]})},d0=()=>{var y;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=st(),{deployment:s}=we(),[a,h]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[u,d]=i.useState(null),[p,m]=i.useState(""),[x,v]=i.useState(null),b=i.useRef(null),{data:k=[],isLoading:$,mutate:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),C=i.useMemo(()=>p?k.filter(g=>g.name.toLowerCase().includes(p.toLowerCase())):k,[k,p]),z=async g=>{try{g.id?(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role created successfully",type:"success"})),h({isOpen:!1}),S()}catch(_){const E=(_==null?void 0:_.message)||(g.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");g.id?c({text:E,type:"error"}):c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async g=>{try{await n(g),S()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(jt,{size:16}),f.text]}),e.jsxs(rd,{children:[e.jsx(At,{placeholder:"Search roles",onChange:m,value:p}),((y=s==null?void 0:s.b2b_settings)==null?void 0:y.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(J,{ref:b,onClick:()=>h({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(vi,{role:a.role,onClose:()=>h({isOpen:!1}),onSuccess:z,triggerRef:b})]})]}),C.length===0?e.jsx(xt,{title:p?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:C.map(g=>{var _;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:g.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:g.permissions.join(", ")}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:u===g.id,openChange:E=>d(E?g.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{disabled:!g.organization_id,"data-role-dropdown-trigger":g.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{d(null),h({isOpen:!0,role:g})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{d(null),v(g.id)},children:"Remove Role"})]})]}),x===g.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(g),onCancel:()=>v(null)}),a.isOpen&&((_=a.role)==null?void 0:_.id)===g.id&&e.jsx(vi,{role:a.role,onClose:()=>{h({isOpen:!1}),d(null)},onSuccess:z})]})})]},g.id)})})]})]})},od=()=>{var d;const{loading:t,activeOrganization:r}=st(),{deployment:o}=we(),[n,s]=i.useState("general"),[a,h]=i.useState(null),[f,c]=i.useState("info"),u=i.useCallback((p,m="info")=>{h(p),c(m),setTimeout(()=>h(null),3e3)},[h]);return t?e.jsx(Xn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):r?e.jsx(Ci,{children:e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:u},children:e.jsxs(Xn,{children:[e.jsx(r0,{children:e.jsxs(o0,{children:[e.jsx(jr,{$isActive:n==="general",onClick:()=>s("general"),children:e.jsxs(kr,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(jr,{$isActive:n==="domains",onClick:()=>s("domains"),children:e.jsxs(kr,{children:[e.jsx(Ah,{size:16}),"Domains"]})}),e.jsx(jr,{$isActive:n==="members",onClick:()=>s("members"),children:e.jsxs(kr,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(jr,{$isActive:n==="invitations",onClick:()=>s("invitations"),children:e.jsxs(kr,{children:[e.jsx(hn,{size:16}),"Invitations"]})}),e.jsx(jr,{$isActive:n==="roles",onClick:()=>s("roles"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Roles"]})}),((d=o==null?void 0:o.b2b_settings)==null?void 0:d.enterprise_sso_enabled)&&e.jsx(jr,{$isActive:n==="sso",onClick:()=>s("sso"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Single Sign-On"]})})]})}),e.jsxs(n0,{children:[n==="general"&&e.jsx(s0,{}),n==="domains"&&e.jsx(a0,{}),n==="members"&&e.jsx(c0,{}),n==="invitations"&&e.jsx(l0,{}),n==="roles"&&e.jsx(d0,{}),n==="sso"&&e.jsx(Kx,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):e.jsx(Ci,{children:e.jsx(Xn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Jr,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(md,{})]})})})},u0=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(od,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),p0=l.div`
2906
2908
  display: flex;
2907
2909
  height: 100%;
2908
2910
  min-height: 400px;
2909
- `,p0=l.div`
2911
+ `,h0=l.div`
2910
2912
  width: 35%;
2911
2913
  background: var(--color-background-hover);
2912
2914
  padding: 32px;
@@ -2916,7 +2918,7 @@ cursor: pointer;
2916
2918
  justify-content: center;
2917
2919
  text-align: center;
2918
2920
  border-right: 1px solid var(--color-border);
2919
- `,h0=l.div`
2921
+ `,f0=l.div`
2920
2922
  flex: 1;
2921
2923
  padding: 32px;
2922
2924
  display: flex;
@@ -2940,11 +2942,11 @@ cursor: pointer;
2940
2942
  border-color: var(--color-border-hover);
2941
2943
  transform: scale(1.02);
2942
2944
  }
2943
- `,f0=l.img`
2945
+ `,g0=l.img`
2944
2946
  width: 100%;
2945
2947
  height: 100%;
2946
2948
  object-fit: cover;
2947
- `,g0=l.div`
2949
+ `,m0=l.div`
2948
2950
  font-size: 32px;
2949
2951
  font-weight: 600;
2950
2952
  color: var(--color-muted);
@@ -2954,28 +2956,28 @@ cursor: pointer;
2954
2956
  display: flex;
2955
2957
  align-items: center;
2956
2958
  justify-content: center;
2957
- `,m0=l.h2`
2959
+ `,x0=l.h2`
2958
2960
  font-size: 16px;
2959
2961
  font-weight: 400;
2960
2962
  color: var(--color-foreground);
2961
2963
  margin-bottom: 8px;
2962
- `,x0=l.p`
2964
+ `,v0=l.p`
2963
2965
  font-size: 13px;
2964
2966
  color: var(--color-secondary-text);
2965
2967
  line-height: 1.4;
2966
2968
  max-width: 200px;
2967
- `,v0=l.div`
2969
+ `,b0=l.div`
2968
2970
  margin-bottom: 24px;
2969
- `,b0=l.h3`
2971
+ `,y0=l.h3`
2970
2972
  font-size: 16px;
2971
2973
  font-weight: 400;
2972
2974
  color: var(--color-foreground);
2973
2975
  margin-bottom: 6px;
2974
- `,y0=l.p`
2976
+ `,w0=l.p`
2975
2977
  font-size: 13px;
2976
2978
  color: var(--color-secondary-text);
2977
2979
  line-height: 1.4;
2978
- `,w0=l.div`
2980
+ `,j0=l.div`
2979
2981
  flex: 1;
2980
2982
  `,Jn=l.div`
2981
2983
  margin-bottom: 20px;
@@ -2985,7 +2987,7 @@ cursor: pointer;
2985
2987
  font-size: 13px;
2986
2988
  font-weight: 400;
2987
2989
  color: var(--color-foreground);
2988
- `,j0=l.input`
2990
+ `,k0=l.input`
2989
2991
  width: 100%;
2990
2992
  padding: 8px 12px;
2991
2993
  border: 1px solid var(--color-border);
@@ -3005,7 +3007,7 @@ cursor: pointer;
3005
3007
  &::placeholder {
3006
3008
  color: var(--color-muted);
3007
3009
  }
3008
- `,k0=l.textarea`
3010
+ `,_0=l.textarea`
3009
3011
  width: 100%;
3010
3012
  padding: 8px 12px;
3011
3013
  border: 1px solid var(--color-border);
@@ -3028,13 +3030,13 @@ cursor: pointer;
3028
3030
  &::placeholder {
3029
3031
  color: var(--color-muted);
3030
3032
  }
3031
- `,_0=l.div`
3033
+ `,C0=l.div`
3032
3034
  display: flex;
3033
3035
  justify-content: space-between;
3034
3036
  align-items: center;
3035
3037
  margin-top: auto;
3036
3038
  padding-top: 24px;
3037
- `,C0=l.button`
3039
+ `,S0=l.button`
3038
3040
  display: flex;
3039
3041
  align-items: center;
3040
3042
  gap: 6px;
@@ -3050,7 +3052,7 @@ cursor: pointer;
3050
3052
  &:hover {
3051
3053
  color: var(--color-foreground);
3052
3054
  }
3053
- `,S0=l.button`
3055
+ `,$0=l.button`
3054
3056
  padding: 8px 20px;
3055
3057
  border-radius: 6px;
3056
3058
  font-size: 14px;
@@ -3071,9 +3073,9 @@ cursor: pointer;
3071
3073
  opacity: 0.5;
3072
3074
  cursor: not-allowed;
3073
3075
  }
3074
- `,$0=l.input`
3076
+ `,z0=l.input`
3075
3077
  display: none;
3076
- `,z0=l.div`
3078
+ `,E0=l.div`
3077
3079
  position: absolute;
3078
3080
  inset: 0;
3079
3081
  background: var(--color-dialog-backdrop);
@@ -3087,13 +3089,13 @@ cursor: pointer;
3087
3089
  ${nd}:hover & {
3088
3090
  opacity: 1;
3089
3091
  }
3090
- `,E0=l.div`
3092
+ `,P0=l.div`
3091
3093
  color: white;
3092
3094
  font-size: 12px;
3093
3095
  font-weight: 400;
3094
- `,P0=l.div`
3096
+ `,I0=l.div`
3095
3097
  position: relative;
3096
- `,I0=l.button`
3098
+ `,R0=l.button`
3097
3099
  width: 100%;
3098
3100
  padding: 8px 12px;
3099
3101
  border: 1px solid var(--color-border);
@@ -3122,7 +3124,7 @@ cursor: pointer;
3122
3124
  background: var(--color-background-hover);
3123
3125
  cursor: not-allowed;
3124
3126
  }
3125
- `,R0=l.div`
3127
+ `,T0=l.div`
3126
3128
  position: absolute;
3127
3129
  top: calc(100% + 4px);
3128
3130
  left: 0;
@@ -3175,7 +3177,7 @@ cursor: pointer;
3175
3177
  width: 100%;
3176
3178
  height: 100%;
3177
3179
  object-fit: cover;
3178
- `,T0=l(sd)`
3180
+ `,M0=l(sd)`
3179
3181
  border-top: 1px solid var(--color-border);
3180
3182
  color: var(--color-primary);
3181
3183
  font-weight: 400;
@@ -3184,7 +3186,7 @@ cursor: pointer;
3184
3186
  &:hover {
3185
3187
  background: var(--color-primary-background);
3186
3188
  }
3187
- `,M0=l.div`
3189
+ `,O0=l.div`
3188
3190
  width: 20px;
3189
3191
  height: 20px;
3190
3192
  border-radius: 50%;
@@ -3193,7 +3195,7 @@ cursor: pointer;
3193
3195
  align-items: center;
3194
3196
  justify-content: center;
3195
3197
  color: var(--color-primary);
3196
- `,Gs=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var I;const[s,a]=i.useState(""),[h,f]=i.useState(""),[c,u]=i.useState(),[d,p]=i.useState(null),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(t),S=i.useRef(null),C=i.useRef(null),{toast:z}=Je(),{createWorkspace:w}=Wt(),{organizationMemberships:y}=Ot(),g=(I=y==null?void 0:y.find(O=>O.organization.id===k))==null?void 0:I.organization,_=O=>{if(O.target.files&&O.target.files[0]){const N=O.target.files[0];if(N.size>2*1024*1024){z("File size cannot exceed 2MB","error");return}if(!N.type.startsWith("image/")){z("Please select a valid image file","error");return}d&&URL.revokeObjectURL(d),u(N),p(URL.createObjectURL(N))}},E=()=>{var O;(O=S.current)==null||O.click()},j=O=>O.split(" ").map(N=>N[0]).join("").toUpperCase().slice(0,2)||"W",T=O=>O.trim().replace(/[<>\"'&]/g,""),R=O=>O.length>=2&&O.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(O),M=async()=>{const O=T(s),N=T(h);if(!O||!k){z("Please enter a workspace name","error");return}if(!R(O)){z("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(N.length>500){z("Description must be less than 500 characters","error");return}x(!0);try{const D=await w(k,O,c,N);r==null||r(D)}catch(D){const L=D.message||"Failed to create workspace. Please try again.";z(L,"error")}finally{x(!1)}};return i.useEffect(()=>()=>{d&&URL.revokeObjectURL(d)},[d]),i.useEffect(()=>{const O=N=>{C.current&&!C.current.contains(N.target)&&b(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]),e.jsx(fe,{children:e.jsxs(u0,{children:[e.jsxs(p0,{children:[e.jsxs(nd,{hasImage:!!d,onClick:E,children:[d?e.jsx(f0,{src:d,alt:"Workspace logo"}):e.jsx(g0,{children:j(s||"W")}),e.jsx(z0,{children:e.jsx(E0,{children:"Upload Logo"})})]}),e.jsx($0,{type:"file",ref:S,onChange:_,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(m0,{children:"Create new workspace"}),e.jsx(x0,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(h0,{children:[e.jsxs(v0,{children:[e.jsx(b0,{children:"Choose your workspace name"}),e.jsx(y0,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(w0,{children:[e.jsxs(Jn,{children:[e.jsx(es,{children:"Organization"}),e.jsxs(P0,{ref:C,children:[e.jsxs(I0,{type:"button",onClick:()=>b(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($i,{children:g!=null&&g.image_url?e.jsx(zi,{src:g.image_url,alt:g.name}):j((g==null?void 0:g.name)||"O").charAt(0)}),e.jsx("span",{children:(g==null?void 0:g.name)||"Select organization"})]}),e.jsx(Ut,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(R0,{children:[y==null?void 0:y.map(O=>e.jsxs(sd,{onClick:()=>{$(O.organization.id),b(!1)},children:[e.jsx($i,{children:O.organization.image_url?e.jsx(zi,{src:O.organization.image_url,alt:O.organization.name}):j(O.organization.name).charAt(0)}),e.jsx("span",{children:O.organization.name})]},O.organization.id)),e.jsxs(T0,{onClick:()=>{b(!1),n==null||n()},children:[e.jsx(M0,{children:e.jsx(it,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Workspace name"}),e.jsx(j0,{type:"text",value:s,onChange:O=>a(O.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Description (optional)"}),e.jsx(k0,{value:h,onChange:O=>f(O.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(_0,{children:[o?e.jsxs(C0,{onClick:o,disabled:m,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(S0,{onClick:M,disabled:m||!s.trim(),children:m?"Creating...":"Create"})]})]})]})})},ad=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[h,f]=i.useState(n),{refetch:c,organizationMemberships:u}=Ot(),d=()=>{o==null||o(),r==null||r()},p=()=>{a(!0)},m=async()=>{await c(),setTimeout(()=>{if(u&&u.length>0){const x=u[u.length-1];f(x.organization.id)}a(!1)},500)};return e.jsx(fe,{children:e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsx(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ze.Body,{style:{padding:0},children:s?e.jsx(xn,{onSuccess:m,onCancel:()=>a(!1)}):e.jsx(Gs,{organizationId:h||n,onSuccess:d,onCancel:r,onCreateOrganization:p})})})})})})},O0=l.div`
3198
+ `,Gs=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var I;const[s,a]=i.useState(""),[h,f]=i.useState(""),[c,u]=i.useState(),[d,p]=i.useState(null),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(t),S=i.useRef(null),C=i.useRef(null),{toast:z}=Je(),{createWorkspace:w}=Wt(),{organizationMemberships:y}=Ot(),g=(I=y==null?void 0:y.find(O=>O.organization.id===k))==null?void 0:I.organization,_=O=>{if(O.target.files&&O.target.files[0]){const N=O.target.files[0];if(N.size>2*1024*1024){z("File size cannot exceed 2MB","error");return}if(!N.type.startsWith("image/")){z("Please select a valid image file","error");return}d&&URL.revokeObjectURL(d),u(N),p(URL.createObjectURL(N))}},E=()=>{var O;(O=S.current)==null||O.click()},j=O=>O.split(" ").map(N=>N[0]).join("").toUpperCase().slice(0,2)||"W",T=O=>O.trim().replace(/[<>\"'&]/g,""),R=O=>O.length>=2&&O.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(O),M=async()=>{const O=T(s),N=T(h);if(!O||!k){z("Please enter a workspace name","error");return}if(!R(O)){z("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(N.length>500){z("Description must be less than 500 characters","error");return}x(!0);try{const D=await w(k,O,c,N);r==null||r(D)}catch(D){const L=D.message||"Failed to create workspace. Please try again.";z(L,"error")}finally{x(!1)}};return i.useEffect(()=>()=>{d&&URL.revokeObjectURL(d)},[d]),i.useEffect(()=>{const O=N=>{C.current&&!C.current.contains(N.target)&&b(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]),e.jsx(fe,{children:e.jsxs(p0,{children:[e.jsxs(h0,{children:[e.jsxs(nd,{hasImage:!!d,onClick:E,children:[d?e.jsx(g0,{src:d,alt:"Workspace logo"}):e.jsx(m0,{children:j(s||"W")}),e.jsx(E0,{children:e.jsx(P0,{children:"Upload Logo"})})]}),e.jsx(z0,{type:"file",ref:S,onChange:_,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(x0,{children:"Create new workspace"}),e.jsx(v0,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(f0,{children:[e.jsxs(b0,{children:[e.jsx(y0,{children:"Choose your workspace name"}),e.jsx(w0,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(j0,{children:[e.jsxs(Jn,{children:[e.jsx(es,{children:"Organization"}),e.jsxs(I0,{ref:C,children:[e.jsxs(R0,{type:"button",onClick:()=>b(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($i,{children:g!=null&&g.image_url?e.jsx(zi,{src:g.image_url,alt:g.name}):j((g==null?void 0:g.name)||"O").charAt(0)}),e.jsx("span",{children:(g==null?void 0:g.name)||"Select organization"})]}),e.jsx(Ut,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(T0,{children:[y==null?void 0:y.map(O=>e.jsxs(sd,{onClick:()=>{$(O.organization.id),b(!1)},children:[e.jsx($i,{children:O.organization.image_url?e.jsx(zi,{src:O.organization.image_url,alt:O.organization.name}):j(O.organization.name).charAt(0)}),e.jsx("span",{children:O.organization.name})]},O.organization.id)),e.jsxs(M0,{onClick:()=>{b(!1),n==null||n()},children:[e.jsx(O0,{children:e.jsx(it,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Workspace name"}),e.jsx(k0,{type:"text",value:s,onChange:O=>a(O.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Description (optional)"}),e.jsx(_0,{value:h,onChange:O=>f(O.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(C0,{children:[o?e.jsxs(S0,{onClick:o,disabled:m,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx($0,{onClick:M,disabled:m||!s.trim(),children:m?"Creating...":"Create"})]})]})]})})},ad=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[h,f]=i.useState(n),{refetch:c,organizationMemberships:u}=Ot(),d=()=>{o==null||o(),r==null||r()},p=()=>{a(!0)},m=async()=>{await c(),setTimeout(()=>{if(u&&u.length>0){const x=u[u.length-1];f(x.organization.id)}a(!1)},500)};return e.jsx(fe,{children:e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsx(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ze.Body,{style:{padding:0},children:s?e.jsx(xn,{onSuccess:m,onCancel:()=>a(!1)}):e.jsx(Gs,{organizationId:h||n,onSuccess:d,onCancel:r,onCreateOrganization:p})})})})})})},A0=l.div`
3197
3199
  position: fixed;
3198
3200
  width: 360px;
3199
3201
  max-width: calc(100vw - 48px);
@@ -3206,27 +3208,27 @@ cursor: pointer;
3206
3208
  @media (max-width: 600px) {
3207
3209
  width: calc(100vw - 48px);
3208
3210
  }
3209
- `,A0=l.div`
3211
+ `,L0=l.div`
3210
3212
  display: flex;
3211
3213
  justify-content: space-between;
3212
3214
  align-items: center;
3213
3215
  padding: var(--space-sm) var(--space-md);
3214
3216
  border-bottom: 1px solid var(--color-border);
3215
- `,L0=l.h3`
3217
+ `,D0=l.h3`
3216
3218
  margin: 0;
3217
3219
  font-size: var(--font-xs);
3218
3220
  font-weight: 400;
3219
3221
  color: var(--color-foreground);
3220
- `,D0=l.div`
3221
- padding: var(--space-md);
3222
3222
  `,N0=l.div`
3223
+ padding: var(--space-md);
3224
+ `,F0=l.div`
3223
3225
  display: flex;
3224
3226
  gap: var(--space-xs);
3225
3227
  justify-content: flex-end;
3226
3228
  padding: var(--space-sm) var(--space-md);
3227
3229
  border-top: 1px solid var(--color-border);
3228
3230
  background: var(--color-background-alt);
3229
- `,F0=l.button`
3231
+ `,B0=l.button`
3230
3232
  background: none;
3231
3233
  border: none;
3232
3234
  padding: var(--space-xs);
@@ -3242,7 +3244,7 @@ cursor: pointer;
3242
3244
  color: var(--color-foreground);
3243
3245
  background: var(--color-input-background);
3244
3246
  }
3245
- `,B0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const a=i.useRef(null),[h,f]=i.useState(""),[c,u]=i.useState(null),[d,p]=i.useState(!1),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name}));i.useEffect(()=>{x(!0);const z=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const _=s.current;if(_){const E=_.getBoundingClientRect(),j=360,T=250,R=8;let M=0,I=0;const O=window.innerHeight-E.bottom,N=E.top;O>=T+R?(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):N>=T+R?(M=E.top-T-R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left)),b({top:M,left:I})}},10),w=_=>{a.current&&!a.current.contains(_.target)&&(t==null||t())},y=_=>{_.key==="Escape"&&(t==null||t())},g=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(z),clearTimeout(g),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,s]);const S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=h.trim().toLowerCase();if(!(!z||!c)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}p(!0);try{await n(z,c.id),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{p(!1)}}};return m?e.jsxs(O0,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(A0,{children:[e.jsx(L0,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(F0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(D0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:h,onChange:z=>f(z.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:c==null?void 0:c.id,onChange:z=>u(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(N0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||!c||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},U0=l.div`
3247
+ `,U0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const a=i.useRef(null),[h,f]=i.useState(""),[c,u]=i.useState(null),[d,p]=i.useState(!1),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name}));i.useEffect(()=>{x(!0);const z=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const _=s.current;if(_){const E=_.getBoundingClientRect(),j=360,T=250,R=8;let M=0,I=0;const O=window.innerHeight-E.bottom,N=E.top;O>=T+R?(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):N>=T+R?(M=E.top-T-R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left)),b({top:M,left:I})}},10),w=_=>{a.current&&!a.current.contains(_.target)&&(t==null||t())},y=_=>{_.key==="Escape"&&(t==null||t())},g=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(z),clearTimeout(g),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,s]);const S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=h.trim().toLowerCase();if(!(!z||!c)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}p(!0);try{await n(z,c.id),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{p(!1)}}};return m?e.jsxs(A0,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(L0,{children:[e.jsx(D0,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(B0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(N0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:h,onChange:z=>f(z.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:c==null?void 0:c.id,onChange:z=>u(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(F0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||!c||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},W0=l.div`
3246
3248
  position: fixed;
3247
3249
  width: 360px;
3248
3250
  max-width: calc(100vw - 48px);
@@ -3255,27 +3257,27 @@ cursor: pointer;
3255
3257
  @media (max-width: 600px) {
3256
3258
  width: calc(100vw - 48px);
3257
3259
  }
3258
- `,W0=l.div`
3260
+ `,V0=l.div`
3259
3261
  display: flex;
3260
3262
  justify-content: space-between;
3261
3263
  align-items: center;
3262
3264
  padding: var(--space-sm) var(--space-md);
3263
3265
  border-bottom: 1px solid var(--color-border);
3264
- `,V0=l.h3`
3266
+ `,G0=l.h3`
3265
3267
  margin: 0;
3266
3268
  font-size: var(--font-xs);
3267
3269
  font-weight: 400;
3268
3270
  color: var(--color-foreground);
3269
- `,G0=l.div`
3270
- padding: var(--space-md);
3271
3271
  `,H0=l.div`
3272
+ padding: var(--space-md);
3273
+ `,q0=l.div`
3272
3274
  display: flex;
3273
3275
  gap: var(--space-xs);
3274
3276
  justify-content: flex-end;
3275
3277
  padding: var(--space-sm) var(--space-md);
3276
3278
  border-top: 1px solid var(--color-border);
3277
3279
  background: var(--color-background-alt);
3278
- `,q0=l.button`
3280
+ `,Y0=l.button`
3279
3281
  background: none;
3280
3282
  border: none;
3281
3283
  padding: var(--space-xs);
@@ -3291,7 +3293,7 @@ cursor: pointer;
3291
3293
  color: var(--color-foreground);
3292
3294
  background: var(--color-input-background);
3293
3295
  }
3294
- `,Ei=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var z;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[u,d]=i.useState(!1),{deployment:p}=we(),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=!!o,S=(((z=p==null?void 0:p.b2b_settings)==null?void 0:z.workspace_permissions)||[]).map(w=>({value:w,label:w}));i.useEffect(()=>{x(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const E=n.current;if(E){const j=E.getBoundingClientRect(),T=360,R=250,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),b({top:I,left:O})}},10),y=E=>{s.current&&!s.current.contains(E.target)&&(t==null||t())},g=E=>{E.key==="Escape"&&(t==null||t())},_=setTimeout(()=>{document.addEventListener("mousedown",y),document.addEventListener("keydown",g)},100);return()=>{clearTimeout(w),clearTimeout(_),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,n]);const C=async()=>{if(a.trim()){d(!0);try{const w={id:o==null?void 0:o.id,name:a.trim(),permissions:f};r==null||r(w)}catch(w){const y=w.message||"Failed to save role. Please try again.";k(y,"error")}finally{d(!1)}}};return m?e.jsxs(U0,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:[e.jsxs(W0,{children:[e.jsx(V0,{children:$?"Edit Role":"Add Role"}),e.jsx(q0,{onClick:t,children:e.jsx(lt,{size:16})})]}),e.jsx(G0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",value:a,onChange:w=>h(w.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(H0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a.trim()||u,style:{width:"auto"},children:u?"Saving...":$?"Update":"Create"})]})]}):null},Y0=l.div`
3296
+ `,Ei=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var z;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[u,d]=i.useState(!1),{deployment:p}=we(),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=!!o,S=(((z=p==null?void 0:p.b2b_settings)==null?void 0:z.workspace_permissions)||[]).map(w=>({value:w,label:w}));i.useEffect(()=>{x(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const E=n.current;if(E){const j=E.getBoundingClientRect(),T=360,R=250,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),b({top:I,left:O})}},10),y=E=>{s.current&&!s.current.contains(E.target)&&(t==null||t())},g=E=>{E.key==="Escape"&&(t==null||t())},_=setTimeout(()=>{document.addEventListener("mousedown",y),document.addEventListener("keydown",g)},100);return()=>{clearTimeout(w),clearTimeout(_),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,n]);const C=async()=>{if(a.trim()){d(!0);try{const w={id:o==null?void 0:o.id,name:a.trim(),permissions:f};r==null||r(w)}catch(w){const y=w.message||"Failed to save role. Please try again.";k(y,"error")}finally{d(!1)}}};return m?e.jsxs(W0,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:[e.jsxs(V0,{children:[e.jsx(G0,{children:$?"Edit Role":"Add Role"}),e.jsx(Y0,{onClick:t,children:e.jsx(lt,{size:16})})]}),e.jsx(H0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",value:a,onChange:w=>h(w.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(q0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a.trim()||u,style:{width:"auto"},children:u?"Saving...":$?"Update":"Create"})]})]}):null},Z0=l.div`
3295
3297
  * {
3296
3298
  box-sizing: border-box;
3297
3299
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -3330,14 +3332,14 @@ cursor: pointer;
3330
3332
  pointer-events: none;
3331
3333
  z-index: 1;
3332
3334
  }
3333
- `,Z0=l.div`
3335
+ `,K0=l.div`
3334
3336
  padding: 0 24px;
3335
3337
  border-bottom: 1px solid var(--color-border);
3336
3338
 
3337
3339
  @media (max-width: 768px) {
3338
3340
  padding: 0 20px;
3339
3341
  }
3340
- `,K0=l.div`
3342
+ `,Q0=l.div`
3341
3343
  display: flex;
3342
3344
  gap: 20px;
3343
3345
  overflow-x: auto;
@@ -3378,7 +3380,7 @@ cursor: pointer;
3378
3380
  display: inline-flex;
3379
3381
  align-items: center;
3380
3382
  gap: 6px;
3381
- `,Q0=l.div`
3383
+ `,X0=l.div`
3382
3384
  flex: 1;
3383
3385
  padding: 24px 24px 0 24px;
3384
3386
  overflow-y: auto;
@@ -3393,7 +3395,7 @@ cursor: pointer;
3393
3395
  flex-wrap: wrap;
3394
3396
  gap: 8px;
3395
3397
  margin-bottom: 20px;
3396
- `,X0=l.div`
3398
+ `,J0=l.div`
3397
3399
  width: 40px;
3398
3400
  height: 40px;
3399
3401
  border-radius: 50%;
@@ -3427,7 +3429,7 @@ cursor: pointer;
3427
3429
  opacity: 0.5;
3428
3430
  cursor: not-allowed;
3429
3431
  }
3430
- `,J0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:s,discardInvitation:a,resendInvitation:h}=Vt(),{toast:f}=Je(),[c,u]=i.useState(!0),[d,p]=i.useState(!0),[m,x]=i.useState(""),[v,b]=i.useState([]),[k,$]=i.useState([]),[S,C]=i.useState(!1),z=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{u(!0),p(!0);try{const[j,T]=await Promise.all([o(),n()]);$(j),b(T)}catch{}finally{u(!1),p(!1)}})()},[t==null?void 0:t.id]);const w=async E=>{try{await a(E.id);const j=await n();b(j)}catch{}},y=async E=>{try{await h(E.id);const j=await n();b(j),f("Invitation resent successfully","info")}catch{}},g=async()=>{C(!1);const E=await n();b(E),f("Invitation sent successfully","info")},_=i.useMemo(()=>m?v.filter(E=>(E.email||"").toLowerCase().includes(m.toLowerCase())):v,[v,m]);return r||c||d?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{value:m,onChange:x,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(J,{ref:z,onClick:()=>C(!S),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),S&&e.jsx(B0,{onClose:()=>C(!1),onSuccess:g,roles:k,createInvitation:s,triggerRef:z})]})]}),e.jsx("div",{children:_.length===0?e.jsx(xt,{title:m?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:_.map(E=>{var j,T;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:E.email}),e.jsx(Ue,{children:((j=E.initial_workspace_role)==null?void 0:j.name)||((T=E.initial_organization_role)==null?void 0:T.name)||"No role"}),e.jsx(Ue,{children:new Date(E.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(id,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>y(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Fs,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>w(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},E.id)})})]})})]})},ev=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:a,removeMemberRole:h}=Vt(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),{data:p=[],isLoading:m,mutate:x}=Ze(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:v=[],isLoading:b}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),k=v,$=i.useMemo(()=>u?p.filter(y=>{var R;const g=y.public_user_data;if(!g)return!1;const _=g.first_name||"",E=g.last_name||"",j=((R=g.primary_email_address)==null?void 0:R.email)||"";return`${_} ${E}`.trim().toLowerCase().includes(u.toLowerCase())||j.toLowerCase().includes(u.toLowerCase())}):p,[p,u]),S=async y=>{try{await s(y),c("Member removed successfully","info"),x()}catch{c("Failed to remove member","error")}},C=async(y,g,_)=>{try{_?(await h(y,g),c("Role removed successfully","info")):(await a(y,g),c("Role added successfully","info")),x()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},z=(y="",g="")=>`${y[0]||""}${g[0]||""}`.toUpperCase(),w=(y,g)=>{var _;return((_=y.roles)==null?void 0:_.some(E=>E.id===g))||!1};return r||m||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Hs,{children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),$.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Role"})]})}),e.jsx(St,{children:$.map(y=>{var j,T;const g=y.public_user_data,_=y.roles||[],E=(g==null?void 0:g.id)===((j=f==null?void 0:f.active_signin)==null?void 0:j.user_id);return e.jsxs(Ye,{children:[e.jsx(td,{children:e.jsxs("div",{children:[e.jsx(X0,{children:g&&g.profile_picture_url?e.jsx("img",{src:g.profile_picture_url,alt:`${g.first_name||""} ${g.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):z(g==null?void 0:g.first_name,g==null?void 0:g.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var M;if(!g)return"Unknown User";const R=`${g.first_name||""} ${g.last_name||""}`.trim();return R||((M=g.primary_email_address)==null?void 0:M.email)||"Unknown User"})()}),E&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=g==null?void 0:g.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:_.length>0?_[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[k.map(R=>{const M=w(y,R.id);return e.jsx(Be,{onClick:()=>C(y.id,R.id,M),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),M&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>S(y.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},y.id)})})]})]})},tv=()=>{var q,Y;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Vt(),{deleteWorkspace:n}=Wt(),{deployment:s}=we(),{toast:a}=Je(),[h,f]=i.useState((t==null?void 0:t.name)||""),[c,u]=i.useState((t==null?void 0:t.description)||""),[d,p]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,x]=i.useState(null),[v,b]=i.useState((t==null?void 0:t.image_url)||null),[k,$]=i.useState(!1),[S,C]=i.useState(!1),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useRef(null),T=i.useRef(null);if(i.useEffect(()=>{var B;t&&(f(t.name||""),u(t.description||""),b(t.image_url||null),p({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((B=t.whitelisted_ips)==null?void 0:B.join(`
3432
+ `,ev=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:s,discardInvitation:a,resendInvitation:h}=Vt(),{toast:f}=Je(),[c,u]=i.useState(!0),[d,p]=i.useState(!0),[m,x]=i.useState(""),[v,b]=i.useState([]),[k,$]=i.useState([]),[S,C]=i.useState(!1),z=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{u(!0),p(!0);try{const[j,T]=await Promise.all([o(),n()]);$(j),b(T)}catch{}finally{u(!1),p(!1)}})()},[t==null?void 0:t.id]);const w=async E=>{try{await a(E.id);const j=await n();b(j)}catch{}},y=async E=>{try{await h(E.id);const j=await n();b(j),f("Invitation resent successfully","info")}catch{}},g=async()=>{C(!1);const E=await n();b(E),f("Invitation sent successfully","info")},_=i.useMemo(()=>m?v.filter(E=>(E.email||"").toLowerCase().includes(m.toLowerCase())):v,[v,m]);return r||c||d?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{value:m,onChange:x,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(J,{ref:z,onClick:()=>C(!S),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),S&&e.jsx(U0,{onClose:()=>C(!1),onSuccess:g,roles:k,createInvitation:s,triggerRef:z})]})]}),e.jsx("div",{children:_.length===0?e.jsx(xt,{title:m?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:_.map(E=>{var j,T;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:E.email}),e.jsx(Ue,{children:((j=E.initial_workspace_role)==null?void 0:j.name)||((T=E.initial_organization_role)==null?void 0:T.name)||"No role"}),e.jsx(Ue,{children:new Date(E.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(id,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>y(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Fs,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>w(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},E.id)})})]})})]})},tv=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:a,removeMemberRole:h}=Vt(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),{data:p=[],isLoading:m,mutate:x}=Ze(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:v=[],isLoading:b}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),k=v,$=i.useMemo(()=>u?p.filter(y=>{var R;const g=y.public_user_data;if(!g)return!1;const _=g.first_name||"",E=g.last_name||"",j=((R=g.primary_email_address)==null?void 0:R.email)||"";return`${_} ${E}`.trim().toLowerCase().includes(u.toLowerCase())||j.toLowerCase().includes(u.toLowerCase())}):p,[p,u]),S=async y=>{try{await s(y),c("Member removed successfully","info"),x()}catch{c("Failed to remove member","error")}},C=async(y,g,_)=>{try{_?(await h(y,g),c("Role removed successfully","info")):(await a(y,g),c("Role added successfully","info")),x()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},z=(y="",g="")=>`${y[0]||""}${g[0]||""}`.toUpperCase(),w=(y,g)=>{var _;return((_=y.roles)==null?void 0:_.some(E=>E.id===g))||!1};return r||m||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Hs,{children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),$.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Role"})]})}),e.jsx(St,{children:$.map(y=>{var j,T;const g=y.public_user_data,_=y.roles||[],E=(g==null?void 0:g.id)===((j=f==null?void 0:f.active_signin)==null?void 0:j.user_id);return e.jsxs(Ye,{children:[e.jsx(td,{children:e.jsxs("div",{children:[e.jsx(J0,{children:g&&g.profile_picture_url?e.jsx("img",{src:g.profile_picture_url,alt:`${g.first_name||""} ${g.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):z(g==null?void 0:g.first_name,g==null?void 0:g.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var M;if(!g)return"Unknown User";const R=`${g.first_name||""} ${g.last_name||""}`.trim();return R||((M=g.primary_email_address)==null?void 0:M.email)||"Unknown User"})()}),E&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=g==null?void 0:g.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:_.length>0?_[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[k.map(R=>{const M=w(y,R.id);return e.jsx(Be,{onClick:()=>C(y.id,R.id,M),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),M&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>S(y.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},y.id)})})]})]})},rv=()=>{var q,Y;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Vt(),{deleteWorkspace:n}=Wt(),{deployment:s}=we(),{toast:a}=Je(),[h,f]=i.useState((t==null?void 0:t.name)||""),[c,u]=i.useState((t==null?void 0:t.description)||""),[d,p]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,x]=i.useState(null),[v,b]=i.useState((t==null?void 0:t.image_url)||null),[k,$]=i.useState(!1),[S,C]=i.useState(!1),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useRef(null),T=i.useRef(null);if(i.useEffect(()=>{var B;t&&(f(t.name||""),u(t.description||""),b(t.image_url||null),p({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((B=t.whitelisted_ips)==null?void 0:B.join(`
3431
3433
  `))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const R=B=>{var H;if((H=B.target.files)!=null&&H[0]){const G=B.target.files[0];x(G),b(URL.createObjectURL(G)),setTimeout(()=>I(),100)}},M=()=>{j.current&&j.current.click()},I=i.useCallback(async()=>{if(!(!t||S))try{C(!0);const B={};m&&(B.image=m,x(null)),h!==t.name&&(B.name=h),c!==t.description&&(B.description=c),d.mfa_required!==t.enforce_2fa&&(B.enforce_2fa=d.mfa_required),d.ip_restrictions!==t.enable_ip_restriction&&(B.enable_ip_restriction=d.ip_restrictions);const H=(t.whitelisted_ips||[]).join(`
3432
3434
  `);d.allowed_ips!==H&&(B.whitelisted_ips=d.allowed_ips.split(`
3433
3435
  `).map(G=>G.trim()).filter(G=>G!=="")),Object.keys(B).length>0&&(await o(B),$(!0),setTimeout(()=>$(!1),3e3))}catch{a("Failed to auto-save workspace","error")}finally{C(!1)}},[t,o,h,c,m,d,S]),O=i.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{I()},1e3)},[I]),N=B=>{f(B.target.value),O()},D=B=>{u(B.target.value),O()},L=()=>{T.current&&clearTimeout(T.current),I()},P=()=>{T.current&&clearTimeout(T.current),I()},A=async()=>{if(!(!t||z!==t.name))try{g(!0),await n(t),a("Workspace deleted successfully","info")}catch(B){a(B.message||"Failed to delete workspace","error")}finally{g(!1),w(""),E(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:B=>{B.currentTarget.style.borderColor="var(--color-primary)",B.currentTarget.style.transform="scale(1.02)"},onMouseLeave:B=>{B.currentTarget.style.borderColor="var(--color-border)",B.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Jr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,style:{display:"none"},accept:"image/*",onChange:R})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var B;return(B=j.current)==null?void 0:B.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jr,{size:14}),v?"Change":"Upload"]}),e.jsxs(J,{onClick:()=>{b(null),x(null),j.current&&(j.current.value=""),setTimeout(()=>I(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(fn,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"name",children:"Workspace Name"}),e.jsx(se,{id:"name",type:"text",value:h,onChange:N,onBlur:L,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(se,{id:"description",as:"textarea",value:c,onChange:D,onBlur:P,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]}),((q=s==null?void 0:s.b2b_settings)==null?void 0:q.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(mr,{checked:d.mfa_required,onChange:()=>{p(B=>({...B,mfa_required:!B.mfa_required})),setTimeout(()=>I(),100)}})]}),((Y=s==null?void 0:s.b2b_settings)==null?void 0:Y.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(mr,{checked:d.ip_restrictions,onChange:()=>{p(B=>({...B,ip_restrictions:!B.ip_restrictions})),setTimeout(()=>I(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),d.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(se,{id:"allowed_ips",as:"textarea",value:d.allowed_ips,onChange:B=>p(H=>({...H,allowed_ips:B.target.value})),onBlur:I,placeholder:`192.168.1.1
@@ -3442,12 +3444,12 @@ cursor: pointer;
3442
3444
  transform: translateX(-50%) translateY(0);
3443
3445
  }
3444
3446
  }
3445
- `})]})},rv=()=>{var g;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Vt(),{toast:a}=Je(),{deployment:h}=we(),[f,c]=i.useState(""),[u,d]=i.useState({isOpen:!1}),[p,m]=i.useState(null),[x,v]=i.useState(null),b=i.useRef(null),k=i.useRef(new Map),{data:$=[],isLoading:S,mutate:C}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),z=i.useMemo(()=>f?$.filter(_=>_.name.toLowerCase().includes(f.toLowerCase())):$,[$,f]),w=async _=>{try{await n(_.name,_.permissions||[]),a("Role created successfully","info"),d({isOpen:!1}),C()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},y=async _=>{try{await s(_),a("Role deleted successfully","info"),v(null),C()}catch{a("Failed to delete role","error"),a("Failed to delete role","error")}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((g=h==null?void 0:h.b2b_settings)==null?void 0:g.custom_workspace_role_enabled)&&e.jsx(J,{ref:b,onClick:()=>d({isOpen:!0,triggerElement:b.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),u.isOpen&&!u.role&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:w})]})]}),z.length===0?e.jsx(xt,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(_=>{var E;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:_.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:_.permissions&&_.permissions.length>0?_.permissions.join(", "):""}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:p===_.id,openChange:j=>m(j?_.id:null),children:[e.jsx(mt,{children:e.jsx(id,{ref:j=>{j&&k.current.set(_.id,j)},disabled:!_.workspace_id,"data-role-dropdown-trigger":_.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{m(null);const j=k.current.get(_.id);d({isOpen:!0,role:_,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{m(null),v(_.id)},children:"Remove Role"})]})]}),x===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>y(_),onCancel:()=>v(null)}),u.isOpen&&((E=u.role)==null?void 0:E.id)===_.id&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>{d({isOpen:!1}),m(null)},onSuccess:w})]})})]},_.id)})})]})})]})},cd=()=>{const{activeWorkspace:t,loading:r}=Vt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((u,d="info")=>{a(u),f(d),setTimeout(()=>a(null),3e3)},[]);return r?e.jsx(Pi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):t?e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(Y0,{children:e.jsxs(Pi,{children:[e.jsx(Z0,{children:e.jsxs(K0,{children:[e.jsx(So,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs($o,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(So,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs($o,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(So,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs($o,{children:[e.jsx(Fs,{size:16}),"Invitations"]})}),e.jsx(So,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs($o,{children:[e.jsx(pt,{size:16}),"Roles"]})})]})}),e.jsxs(Q0,{children:[o==="general"&&e.jsx(tv,{}),o==="members"&&e.jsx(ev,{}),o==="invitations"&&e.jsx(J0,{}),o==="roles"&&e.jsx(rv,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},ld=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(cd,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),dd=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[a,h]=i.useState();return i.useEffect(()=>{if(!r||!t.current){h(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,p=u-c.left,m=c.right,x=d-c.bottom,v=c.top;let b={};p>=o?b.left=c.left:m>=o?b.left=c.right-o:b.left=Math.max(s,Math.min(u-o-s,c.left)),x>=150?(b.top=c.bottom+s,b.maxHeight=Math.min(n,x-s*2)):v>=150?(b.bottom=d-c.top+s,b.maxHeight=Math.min(n,v-s*2)):(b.top=c.bottom+s,b.maxHeight=Math.max(100,x-s*2)),h(b)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,s]),a},ud=["organization:admin"],pd=["organization:admin","organization:manage"],hd=["workspace:admin"],fd=["workspace:admin","workspace:manage"];function qs(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function gd(t){return qs(t,pd)}function ov(t){return qs(t,ud)}function Ys(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Es(t){return Ys(t,fd)}function nv(t){return Ys(t,hd)}const Ii=l.div`
3447
+ `})]})},ov=()=>{var g;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Vt(),{toast:a}=Je(),{deployment:h}=we(),[f,c]=i.useState(""),[u,d]=i.useState({isOpen:!1}),[p,m]=i.useState(null),[x,v]=i.useState(null),b=i.useRef(null),k=i.useRef(new Map),{data:$=[],isLoading:S,mutate:C}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),z=i.useMemo(()=>f?$.filter(_=>_.name.toLowerCase().includes(f.toLowerCase())):$,[$,f]),w=async _=>{try{await n(_.name,_.permissions||[]),a("Role created successfully","info"),d({isOpen:!1}),C()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},y=async _=>{try{await s(_),a("Role deleted successfully","info"),v(null),C()}catch{a("Failed to delete role","error"),a("Failed to delete role","error")}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((g=h==null?void 0:h.b2b_settings)==null?void 0:g.custom_workspace_role_enabled)&&e.jsx(J,{ref:b,onClick:()=>d({isOpen:!0,triggerElement:b.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),u.isOpen&&!u.role&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:w})]})]}),z.length===0?e.jsx(xt,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(_=>{var E;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:_.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:_.permissions&&_.permissions.length>0?_.permissions.join(", "):""}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:p===_.id,openChange:j=>m(j?_.id:null),children:[e.jsx(mt,{children:e.jsx(id,{ref:j=>{j&&k.current.set(_.id,j)},disabled:!_.workspace_id,"data-role-dropdown-trigger":_.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{m(null);const j=k.current.get(_.id);d({isOpen:!0,role:_,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{m(null),v(_.id)},children:"Remove Role"})]})]}),x===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>y(_),onCancel:()=>v(null)}),u.isOpen&&((E=u.role)==null?void 0:E.id)===_.id&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>{d({isOpen:!1}),m(null)},onSuccess:w})]})})]},_.id)})})]})})]})},cd=()=>{const{activeWorkspace:t,loading:r}=Vt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((u,d="info")=>{a(u),f(d),setTimeout(()=>a(null),3e3)},[]);return r?e.jsx(Pi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):t?e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(Z0,{children:e.jsxs(Pi,{children:[e.jsx(K0,{children:e.jsxs(Q0,{children:[e.jsx(So,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs($o,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(So,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs($o,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(So,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs($o,{children:[e.jsx(Fs,{size:16}),"Invitations"]})}),e.jsx(So,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs($o,{children:[e.jsx(pt,{size:16}),"Roles"]})})]})}),e.jsxs(X0,{children:[o==="general"&&e.jsx(rv,{}),o==="members"&&e.jsx(tv,{}),o==="invitations"&&e.jsx(ev,{}),o==="roles"&&e.jsx(ov,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},ld=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(cd,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),dd=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[a,h]=i.useState();return i.useEffect(()=>{if(!r||!t.current){h(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,p=u-c.left,m=c.right,x=d-c.bottom,v=c.top;let b={};p>=o?b.left=c.left:m>=o?b.left=c.right-o:b.left=Math.max(s,Math.min(u-o-s,c.left)),x>=150?(b.top=c.bottom+s,b.maxHeight=Math.min(n,x-s*2)):v>=150?(b.bottom=d-c.top+s,b.maxHeight=Math.min(n,v-s*2)):(b.top=c.bottom+s,b.maxHeight=Math.max(100,x-s*2)),h(b)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,s]),a},ud=["organization:admin"],pd=["organization:admin","organization:manage"],hd=["workspace:admin"],fd=["workspace:admin","workspace:manage"];function qs(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function gd(t){return qs(t,pd)}function nv(t){return qs(t,ud)}function Ys(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Es(t){return Ys(t,fd)}function sv(t){return Ys(t,hd)}const Ii=l.div`
3446
3448
  position: relative;
3447
3449
  display: inline-block;
3448
3450
  width: 100%;
3449
3451
  max-width: 300px;
3450
- `,sv=l.button`
3452
+ `,av=l.button`
3451
3453
  display: flex;
3452
3454
  align-items: center;
3453
3455
  justify-content: space-between;
@@ -3469,7 +3471,7 @@ cursor: pointer;
3469
3471
  cursor: not-allowed;
3470
3472
  opacity: 0.7;
3471
3473
  }
3472
- `,av=l.div`
3474
+ `,iv=l.div`
3473
3475
  width: 20px;
3474
3476
  height: 20px;
3475
3477
  border-radius: 50%;
@@ -3482,7 +3484,7 @@ cursor: pointer;
3482
3484
  font-size: 11px;
3483
3485
  font-weight: 600;
3484
3486
  flex-shrink: 0;
3485
- `,iv=l.img`
3487
+ `,cv=l.img`
3486
3488
  width: 100%;
3487
3489
  height: 100%;
3488
3490
  object-fit: cover;
@@ -3490,14 +3492,14 @@ cursor: pointer;
3490
3492
  display: flex;
3491
3493
  align-items: center;
3492
3494
  gap: 8px;
3493
- `,cv=l.span`
3495
+ `,lv=l.span`
3494
3496
  font-weight: 400;
3495
3497
  font-size: 14px;
3496
3498
  overflow: hidden;
3497
3499
  text-overflow: ellipsis;
3498
3500
  white-space: nowrap;
3499
3501
  color: var(--color-foreground);
3500
- `,lv=l.div`
3502
+ `,dv=l.div`
3501
3503
  position: fixed;
3502
3504
  ${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
3503
3505
  ${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
@@ -3661,7 +3663,7 @@ cursor: pointer;
3661
3663
  left: 8px;
3662
3664
  top: 50%;
3663
3665
  transform: translateY(-50%);
3664
- `,dv=l.div`
3666
+ `,uv=l.div`
3665
3667
  width: 20px;
3666
3668
  height: 20px;
3667
3669
  border-radius: 50%;
@@ -3671,7 +3673,7 @@ cursor: pointer;
3671
3673
  justify-content: center;
3672
3674
  color: var(--color-secondary-text);
3673
3675
  overflow: hidden;
3674
- `,uv=l.img`
3676
+ `,pv=l.img`
3675
3677
  width: 100%;
3676
3678
  height: 100%;
3677
3679
  object-fit: cover;
@@ -3702,7 +3704,7 @@ cursor: pointer;
3702
3704
  display: flex;
3703
3705
  align-items: center;
3704
3706
  gap: 6px;
3705
- `,pv=l.div`
3707
+ `,hv=l.div`
3706
3708
  width: 12px;
3707
3709
  height: 12px;
3708
3710
  border: 2px solid transparent;
@@ -3715,7 +3717,7 @@ cursor: pointer;
3715
3717
  transform: rotate(360deg);
3716
3718
  }
3717
3719
  }
3718
- `,hv=l.div`
3720
+ `,fv=l.div`
3719
3721
  padding: 8px 0;
3720
3722
  `,Ro=l.div`
3721
3723
  display: flex;
@@ -3755,7 +3757,7 @@ cursor: pointer;
3755
3757
  background: var(--color-border);
3756
3758
  border-radius: 4px;
3757
3759
  width: ${t=>t.width||"60%"};
3758
- `,fv=l.div`
3760
+ `,gv=l.div`
3759
3761
  display: flex;
3760
3762
  align-items: center;
3761
3763
  justify-content: space-between;
@@ -3778,22 +3780,22 @@ cursor: pointer;
3778
3780
  opacity: 0.5;
3779
3781
  }
3780
3782
  }
3781
- `,gv=l.div`
3783
+ `,mv=l.div`
3782
3784
  width: 20px;
3783
3785
  height: 20px;
3784
3786
  border-radius: 50%;
3785
3787
  background: var(--color-border);
3786
- `,mv=l.div`
3788
+ `,xv=l.div`
3787
3789
  height: 14px;
3788
3790
  width: 120px;
3789
3791
  background: var(--color-border);
3790
3792
  border-radius: 4px;
3791
- `,xv=l.div`
3793
+ `,vv=l.div`
3792
3794
  width: 16px;
3793
3795
  height: 16px;
3794
3796
  background: var(--color-border);
3795
3797
  border-radius: 2px;
3796
- `,md=({showPersonal:t=!0})=>{var de,U,le,K;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,h]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),u=dd({triggerRef:f,isOpen:r,minWidth:300}),d=Zr(!1),p=Zr(!1),m=Zr(!1),x=Zr(!1),[v,b]=i.useState(null),[k,$]=i.useState(!1),[S,C]=i.useState(null),{organizationMemberships:z,loading:w,refetch:y}=Ot(),{activeOrganization:g,activeMembership:_,leave:E}=st(),{activeWorkspace:j,activeMembership:T,leave:R}=Vt(),{workspaces:M,loading:I}=Wt(),{session:O,loading:N,switchOrganization:D,switchWorkspace:L}=Qe(),{deployment:P}=we(),{toast:A}=Je(),q=P==null?void 0:P.b2b_settings.organizations_enabled,Y=P==null?void 0:P.b2b_settings.workspaces_enabled,B=P==null?void 0:P.b2b_settings.allow_users_to_create_orgs,H=!((de=O==null?void 0:O.active_signin)!=null&&de.active_organization_membership_id),G=i.useMemo(()=>{var re,ge;if(H)return{name:"Personal account",image_url:(ge=(re=O==null?void 0:O.active_signin)==null?void 0:re.user)==null?void 0:ge.profile_picture_url,isPersonal:!0};let Z=(g==null?void 0:g.name)||"";return Y&&j&&(Z=`${g==null?void 0:g.name} / ${j.name}`),{name:Z,image_url:g==null?void 0:g.image_url,isPersonal:!1}},[H,g,j,O,Y]);i.useEffect(()=>{if(!r)return;let Z=null;const re=setTimeout(()=>{const ge=ue=>{var V,F;const ee=ue.target;(V=f.current)!=null&&V.contains(ee)||(F=c.current)!=null&&F.contains(ee)||(o(!1),C(null))};document.addEventListener("mousedown",ge),Z=()=>{document.removeEventListener("mousedown",ge)}},50);return()=>{clearTimeout(re),Z==null||Z()}},[r]),i.useEffect(()=>{if(S){const Z=setTimeout(()=>{C(null)},5e3);return()=>clearTimeout(Z)}},[S]);const X=()=>{y()};if(!q)return null;const oe=Z=>{s(!0),D(Z).finally(()=>{s(!1)})},te=Z=>{s(!0),L(Z).finally(()=>{s(!1)})},ce=Z=>{const re=new Set(a);re.has(Z)?re.delete(Z):re.add(Z),h(re)},Q=Z=>Z.split(" ").map(re=>re[0]).join("").toUpperCase().slice(0,2),me=!!((U=O==null?void 0:O.active_signin)!=null&&U.active_organization_membership_id);return w||N||!z&&me?e.jsx(fe,{children:e.jsx(Ii,{children:e.jsxs(fv,{children:[e.jsxs(Ri,{children:[e.jsx(gv,{}),e.jsx(mv,{})]}),e.jsx(xv,{})]})})}):e.jsx(fe,{children:e.jsxs(Ii,{children:[e.jsxs(sv,{ref:f,onClick:()=>{o(!r),r||C(null)},disabled:n,children:[e.jsxs(Ri,{children:[e.jsx(av,{children:G.image_url?e.jsx(iv,{src:G.image_url,alt:G.name}):G.isPersonal?e.jsx(Ko,{size:12}):Q(G.name)}),e.jsx(cv,{children:G.name})]}),e.jsx(Sh,{size:16})]}),typeof window<"u"&&eo.createPortal(e.jsx(fe,{children:e.jsx(lv,{ref:c,$isOpen:r,$position:u,children:w||I?e.jsxs(hv,{children:[e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"120px"}),e.jsx(Di,{width:"80px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"100px"})})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"140px"}),e.jsx(Di,{width:"60px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:H,onClick:Z=>{Z.stopPropagation(),H||oe()},disabled:n||H,children:[H&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(dv,{children:(K=(le=O==null?void 0:O.active_signin)==null?void 0:le.user)!=null&&K.profile_picture_url?e.jsx(uv,{src:O.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Ko,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Personal account"})})]}),!H&&e.jsx(zo,{className:"hover-arrow",size:14})]}),!H&&g&&e.jsx(_r,{})]}),!H&&g&&e.jsxs(Go,{$isActive:!0,onClick:()=>{Y&&ce(g.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(Po,{}),e.jsxs(zt,{children:[Y&&e.jsx(Ut,{size:12,style:{marginRight:"4px",transform:a.has(g.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Ti,{children:g.image_url?e.jsx(Mi,{src:g.image_url,alt:g.name}):Q(g.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:g.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[gd(_)&&e.jsx(Ho,{onClick:Z=>{Z.stopPropagation(),p.open()},title:"Manage organization",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async Z=>{Z.stopPropagation(),$(!0),C(null);try{await E(),await y(),setTimeout(()=>{$(!1)},500)}catch(re){C(re instanceof Error?re.message:"Failed to leave organization"),$(!1)}},disabled:k,title:"Leave organization",children:e.jsx(Ft,{size:12})})]})]}),g&&Y&&a.has(g.id)&&e.jsxs(e.Fragment,{children:[M==null?void 0:M.filter(Z=>Z.organization.id===g.id).map(Z=>{const re=(j==null?void 0:j.id)===Z.id;return e.jsxs(Io,{as:re?void 0:"button",$isActive:re,onClick:re?void 0:()=>te(Z.id),...re?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[re&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:Z.image_url?e.jsx("img",{src:Z.image_url,alt:Z.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(Z.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:Z.name})})]}),re?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:ge=>{ge.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async ge=>{ge.stopPropagation();try{R&&await R()}catch(ue){const ee=ue.message||"Failed to leave workspace. Please try again.";A(ee,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:14})]},Z.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),(k||S)&&e.jsxs(e.Fragment,{children:[k&&e.jsxs(Li,{children:[e.jsx(pv,{}),"Leaving organization..."]}),S&&e.jsxs(Li,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),S]})]}),e.jsx(_r,{}),z&&z.length>0&&e.jsx(e.Fragment,{children:z.filter(Z=>Z.organization.id!==(g==null?void 0:g.id)).map(Z=>{const re=Z.organization,ge=(M==null?void 0:M.filter(ee=>ee.organization.id===re.id))||[],ue=a.has(re.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:!1,onClick:()=>{Y?ce(re.id):oe(re.id)},disabled:n,children:[e.jsxs(zt,{children:[Y&&e.jsx(Ut,{size:12,style:{marginRight:"4px",transform:ue?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Ti,{children:re.image_url?e.jsx(Mi,{src:re.image_url,alt:re.name}):Q(re.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:re.name})})]}),e.jsx(zo,{className:"hover-arrow",size:14})]}),Y&&ue&&e.jsxs(e.Fragment,{children:[ge.map(ee=>{const V=(j==null?void 0:j.id)===ee.id;return e.jsxs(Io,{as:V?void 0:"button",$isActive:V,onClick:V?void 0:()=>te(ee.id),...V?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[V&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:ee.image_url?e.jsx("img",{src:ee.image_url,alt:ee.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(ee.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:ee.name})})]}),V?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:F=>{F.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async F=>{F.stopPropagation();try{R&&await R()}catch(ne){const be=ne.message||"Failed to leave workspace. Please try again.";A(be,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:16})]},ee.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(re.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:10})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),e.jsx(_r,{})]},re.id)})}),Y?g&&e.jsx(Oi,{onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})}):B&&e.jsx(Oi,{onClick:()=>{d.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create organization"})})]})})]})})}),document.body),q&&B&&e.jsx(kx,{isOpen:d.isOpen,onClose:d.close,onCreated:X}),e.jsx(d0,{isOpen:p.isOpen,onClose:p.close}),e.jsx(ld,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(ad,{isOpen:m.isOpen,onClose:()=>{m.close(),b(null)},organizationId:v})]})})};var vv=Object.defineProperty,en=Object.getOwnPropertySymbols,xd=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,Ni=(t,r,o)=>r in t?vv(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,Ps=(t,r)=>{for(var o in r||(r={}))xd.call(r,o)&&Ni(t,o,r[o]);if(en)for(var o of en(r))vd.call(r,o)&&Ni(t,o,r[o]);return t},Is=(t,r)=>{var o={};for(var n in t)xd.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&en)for(var n of en(t))r.indexOf(n)<0&&vd.call(t,n)&&(o[n]=t[n]);return o};/**
3798
+ `,md=({showPersonal:t=!0})=>{var de,U,le,K;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,h]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),u=dd({triggerRef:f,isOpen:r,minWidth:300}),d=Zr(!1),p=Zr(!1),m=Zr(!1),x=Zr(!1),[v,b]=i.useState(null),[k,$]=i.useState(!1),[S,C]=i.useState(null),{organizationMemberships:z,loading:w,refetch:y}=Ot(),{activeOrganization:g,activeMembership:_,leave:E}=st(),{activeWorkspace:j,activeMembership:T,leave:R}=Vt(),{workspaces:M,loading:I}=Wt(),{session:O,loading:N,switchOrganization:D,switchWorkspace:L}=Qe(),{deployment:P}=we(),{toast:A}=Je(),q=P==null?void 0:P.b2b_settings.organizations_enabled,Y=P==null?void 0:P.b2b_settings.workspaces_enabled,B=P==null?void 0:P.b2b_settings.allow_users_to_create_orgs,H=!((de=O==null?void 0:O.active_signin)!=null&&de.active_organization_membership_id),G=i.useMemo(()=>{var re,ge;if(H)return{name:"Personal account",image_url:(ge=(re=O==null?void 0:O.active_signin)==null?void 0:re.user)==null?void 0:ge.profile_picture_url,isPersonal:!0};let Z=(g==null?void 0:g.name)||"";return Y&&j&&(Z=`${g==null?void 0:g.name} / ${j.name}`),{name:Z,image_url:g==null?void 0:g.image_url,isPersonal:!1}},[H,g,j,O,Y]);i.useEffect(()=>{if(!r)return;let Z=null;const re=setTimeout(()=>{const ge=ue=>{var V,F;const ee=ue.target;(V=f.current)!=null&&V.contains(ee)||(F=c.current)!=null&&F.contains(ee)||(o(!1),C(null))};document.addEventListener("mousedown",ge),Z=()=>{document.removeEventListener("mousedown",ge)}},50);return()=>{clearTimeout(re),Z==null||Z()}},[r]),i.useEffect(()=>{if(S){const Z=setTimeout(()=>{C(null)},5e3);return()=>clearTimeout(Z)}},[S]);const X=()=>{y()};if(!q)return null;const oe=Z=>{s(!0),D(Z).finally(()=>{s(!1)})},te=Z=>{s(!0),L(Z).finally(()=>{s(!1)})},ce=Z=>{const re=new Set(a);re.has(Z)?re.delete(Z):re.add(Z),h(re)},Q=Z=>Z.split(" ").map(re=>re[0]).join("").toUpperCase().slice(0,2),me=!!((U=O==null?void 0:O.active_signin)!=null&&U.active_organization_membership_id);return w||N||!z&&me?e.jsx(fe,{children:e.jsx(Ii,{children:e.jsxs(gv,{children:[e.jsxs(Ri,{children:[e.jsx(mv,{}),e.jsx(xv,{})]}),e.jsx(vv,{})]})})}):e.jsx(fe,{children:e.jsxs(Ii,{children:[e.jsxs(av,{ref:f,onClick:()=>{o(!r),r||C(null)},disabled:n,children:[e.jsxs(Ri,{children:[e.jsx(iv,{children:G.image_url?e.jsx(cv,{src:G.image_url,alt:G.name}):G.isPersonal?e.jsx(Ko,{size:12}):Q(G.name)}),e.jsx(lv,{children:G.name})]}),e.jsx(Sh,{size:16})]}),typeof window<"u"&&eo.createPortal(e.jsx(fe,{children:e.jsx(dv,{ref:c,$isOpen:r,$position:u,children:w||I?e.jsxs(fv,{children:[e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"120px"}),e.jsx(Di,{width:"80px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"100px"})})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"140px"}),e.jsx(Di,{width:"60px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:H,onClick:Z=>{Z.stopPropagation(),H||oe()},disabled:n||H,children:[H&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(uv,{children:(K=(le=O==null?void 0:O.active_signin)==null?void 0:le.user)!=null&&K.profile_picture_url?e.jsx(pv,{src:O.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Ko,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Personal account"})})]}),!H&&e.jsx(zo,{className:"hover-arrow",size:14})]}),!H&&g&&e.jsx(_r,{})]}),!H&&g&&e.jsxs(Go,{$isActive:!0,onClick:()=>{Y&&ce(g.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(Po,{}),e.jsxs(zt,{children:[Y&&e.jsx(Ut,{size:12,style:{marginRight:"4px",transform:a.has(g.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Ti,{children:g.image_url?e.jsx(Mi,{src:g.image_url,alt:g.name}):Q(g.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:g.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[gd(_)&&e.jsx(Ho,{onClick:Z=>{Z.stopPropagation(),p.open()},title:"Manage organization",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async Z=>{Z.stopPropagation(),$(!0),C(null);try{await E(),await y(),setTimeout(()=>{$(!1)},500)}catch(re){C(re instanceof Error?re.message:"Failed to leave organization"),$(!1)}},disabled:k,title:"Leave organization",children:e.jsx(Ft,{size:12})})]})]}),g&&Y&&a.has(g.id)&&e.jsxs(e.Fragment,{children:[M==null?void 0:M.filter(Z=>Z.organization.id===g.id).map(Z=>{const re=(j==null?void 0:j.id)===Z.id;return e.jsxs(Io,{as:re?void 0:"button",$isActive:re,onClick:re?void 0:()=>te(Z.id),...re?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[re&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:Z.image_url?e.jsx("img",{src:Z.image_url,alt:Z.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(Z.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:Z.name})})]}),re?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:ge=>{ge.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async ge=>{ge.stopPropagation();try{R&&await R()}catch(ue){const ee=ue.message||"Failed to leave workspace. Please try again.";A(ee,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:14})]},Z.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),(k||S)&&e.jsxs(e.Fragment,{children:[k&&e.jsxs(Li,{children:[e.jsx(hv,{}),"Leaving organization..."]}),S&&e.jsxs(Li,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),S]})]}),e.jsx(_r,{}),z&&z.length>0&&e.jsx(e.Fragment,{children:z.filter(Z=>Z.organization.id!==(g==null?void 0:g.id)).map(Z=>{const re=Z.organization,ge=(M==null?void 0:M.filter(ee=>ee.organization.id===re.id))||[],ue=a.has(re.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:!1,onClick:()=>{Y?ce(re.id):oe(re.id)},disabled:n,children:[e.jsxs(zt,{children:[Y&&e.jsx(Ut,{size:12,style:{marginRight:"4px",transform:ue?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Ti,{children:re.image_url?e.jsx(Mi,{src:re.image_url,alt:re.name}):Q(re.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:re.name})})]}),e.jsx(zo,{className:"hover-arrow",size:14})]}),Y&&ue&&e.jsxs(e.Fragment,{children:[ge.map(ee=>{const V=(j==null?void 0:j.id)===ee.id;return e.jsxs(Io,{as:V?void 0:"button",$isActive:V,onClick:V?void 0:()=>te(ee.id),...V?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[V&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:ee.image_url?e.jsx("img",{src:ee.image_url,alt:ee.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(ee.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:ee.name})})]}),V?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:F=>{F.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async F=>{F.stopPropagation();try{R&&await R()}catch(ne){const be=ne.message||"Failed to leave workspace. Please try again.";A(be,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:16})]},ee.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(re.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:10})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),e.jsx(_r,{})]},re.id)})}),Y?g&&e.jsx(Oi,{onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})}):B&&e.jsx(Oi,{onClick:()=>{d.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create organization"})})]})})]})})}),document.body),q&&B&&e.jsx(_x,{isOpen:d.isOpen,onClose:d.close,onCreated:X}),e.jsx(u0,{isOpen:p.isOpen,onClose:p.close}),e.jsx(ld,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(ad,{isOpen:m.isOpen,onClose:()=>{m.close(),b(null)},organizationId:v})]})})};var bv=Object.defineProperty,en=Object.getOwnPropertySymbols,xd=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,Ni=(t,r,o)=>r in t?bv(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,Ps=(t,r)=>{for(var o in r||(r={}))xd.call(r,o)&&Ni(t,o,r[o]);if(en)for(var o of en(r))vd.call(r,o)&&Ni(t,o,r[o]);return t},Is=(t,r)=>{var o={};for(var n in t)xd.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&en)for(var n of en(t))r.indexOf(n)<0&&vd.call(t,n)&&(o[n]=t[n]);return o};/**
3797
3799
  * @license QR Code generator library (TypeScript)
3798
3800
  * Copyright (c) Project Nayuki.
3799
3801
  * SPDX-License-Identifier: MIT
@@ -3801,7 +3803,7 @@ cursor: pointer;
3801
3803
  * @license qrcode.react
3802
3804
  * Copyright (c) Paul O'Shannessy
3803
3805
  * SPDX-License-Identifier: ISC
3804
- */var bv={L:$r.QrCode.Ecc.LOW,M:$r.QrCode.Ecc.MEDIUM,Q:$r.QrCode.Ecc.QUARTILE,H:$r.QrCode.Ecc.HIGH},bd=128,yd="L",wd="#FFFFFF",jd="#000000",kd=!1,_d=1,yv=4,wv=0,jv=.1;function Cd(t,r=0){const o=[];return t.forEach(function(n,s){let a=null;n.forEach(function(h,f){if(!h&&a!==null){o.push(`M${a+r} ${s+r}h${f-a}v1H${a+r}z`),a=null;return}if(f===n.length-1){if(!h)return;a===null?o.push(`M${f+r},${s+r} h1v1H${f+r}z`):o.push(`M${a+r},${s+r} h${f+1-a}v1H${a+r}z`);return}h&&a===null&&(a=f)})}),o.join("")}function Sd(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,a)=>a<r.x||a>=r.x+r.w?s:!1))}function kv(t,r,o,n){if(n==null)return null;const s=t.length+o*2,a=Math.floor(r*jv),h=s/r,f=(n.width||a)*h,c=(n.height||a)*h,u=n.x==null?t.length/2-f/2:n.x*h,d=n.y==null?t.length/2-c/2:n.y*h,p=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(u),b=Math.floor(d),k=Math.ceil(f+u-v),$=Math.ceil(c+d-b);m={x:v,y:b,w:k,h:$}}const x=n.crossOrigin;return{x:u,y:d,h:c,w:f,excavation:m,opacity:p,crossOrigin:x}}function _v(t,r){return r!=null?Math.max(Math.floor(r),0):t?yv:wv}function $d({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:a,size:h,boostLevel:f}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((b,k)=>(b.push(...$r.QrSegment.makeSegments(k)),b),[]);return $r.QrCode.encodeSegments(v,bv[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:u,margin:d,numCells:p,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=_v(n,s),b=x.length+v*2,k=kv(x,h,v,a);return{cells:x,margin:v,numCells:b,calculatedImageSettings:k}},[c,h,a,n,s]);return{qrcode:c,margin:d,cells:u,numCells:p,calculatedImageSettings:m}}var Cv=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Sv=i.forwardRef(function(r,o){const n=r,{value:s,size:a=bd,level:h=yd,bgColor:f=wd,fgColor:c=jd,includeMargin:u=kd,minVersion:d=_d,boostLevel:p,marginSize:m,imageSettings:x}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:k}=b,$=Is(b,["style"]),S=x==null?void 0:x.src,C=i.useRef(null),z=i.useRef(null),w=i.useCallback(I=>{C.current=I,typeof o=="function"?o(I):o&&(o.current=I)},[o]),[y,g]=i.useState(!1),{margin:_,cells:E,numCells:j,calculatedImageSettings:T}=$d({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:m,imageSettings:x,size:a});i.useEffect(()=>{if(C.current!=null){const I=C.current,O=I.getContext("2d");if(!O)return;let N=E;const D=z.current,L=T!=null&&D!==null&&D.complete&&D.naturalHeight!==0&&D.naturalWidth!==0;L&&T.excavation!=null&&(N=Sd(E,T.excavation));const P=window.devicePixelRatio||1;I.height=I.width=a*P;const A=a/j*P;O.scale(A,A),O.fillStyle=f,O.fillRect(0,0,j,j),O.fillStyle=c,Cv?O.fill(new Path2D(Cd(N,_))):E.forEach(function(q,Y){q.forEach(function(B,H){B&&O.fillRect(H+_,Y+_,1,1)})}),T&&(O.globalAlpha=T.opacity),L&&O.drawImage(D,T.x+_,T.y+_,T.w,T.h)}}),i.useEffect(()=>{g(!1)},[S]);const R=Ps({height:a,width:a},k);let M=null;return S!=null&&(M=i.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{g(!0)},ref:z,crossOrigin:T==null?void 0:T.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",Ps({style:R,height:a,width:a,ref:w,role:"img"},$)),M)});Sv.displayName="QRCodeCanvas";var Zs=i.forwardRef(function(r,o){const n=r,{value:s,size:a=bd,level:h=yd,bgColor:f=wd,fgColor:c=jd,includeMargin:u=kd,minVersion:d=_d,boostLevel:p,title:m,marginSize:x,imageSettings:v}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:k,cells:$,numCells:S,calculatedImageSettings:C}=$d({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:x,imageSettings:v,size:a});let z=$,w=null;v!=null&&C!=null&&(C.excavation!=null&&(z=Sd($,C.excavation)),w=i.createElement("image",{href:v.src,height:C.h,width:C.w,x:C.x+k,y:C.y+k,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const y=Cd(z,k);return i.createElement("svg",Ps({height:a,width:a,viewBox:`0 0 ${S} ${S}`,ref:o,role:"img"},b),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:f,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:y,shapeRendering:"crispEdges"}),w)});Zs.displayName="QRCodeSVG";const zd=i.createContext(void 0),Yt=()=>{const t=i.useContext(zd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},$v=l.div`
3806
+ */var yv={L:$r.QrCode.Ecc.LOW,M:$r.QrCode.Ecc.MEDIUM,Q:$r.QrCode.Ecc.QUARTILE,H:$r.QrCode.Ecc.HIGH},bd=128,yd="L",wd="#FFFFFF",jd="#000000",kd=!1,_d=1,wv=4,jv=0,kv=.1;function Cd(t,r=0){const o=[];return t.forEach(function(n,s){let a=null;n.forEach(function(h,f){if(!h&&a!==null){o.push(`M${a+r} ${s+r}h${f-a}v1H${a+r}z`),a=null;return}if(f===n.length-1){if(!h)return;a===null?o.push(`M${f+r},${s+r} h1v1H${f+r}z`):o.push(`M${a+r},${s+r} h${f+1-a}v1H${a+r}z`);return}h&&a===null&&(a=f)})}),o.join("")}function Sd(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,a)=>a<r.x||a>=r.x+r.w?s:!1))}function _v(t,r,o,n){if(n==null)return null;const s=t.length+o*2,a=Math.floor(r*kv),h=s/r,f=(n.width||a)*h,c=(n.height||a)*h,u=n.x==null?t.length/2-f/2:n.x*h,d=n.y==null?t.length/2-c/2:n.y*h,p=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(u),b=Math.floor(d),k=Math.ceil(f+u-v),$=Math.ceil(c+d-b);m={x:v,y:b,w:k,h:$}}const x=n.crossOrigin;return{x:u,y:d,h:c,w:f,excavation:m,opacity:p,crossOrigin:x}}function Cv(t,r){return r!=null?Math.max(Math.floor(r),0):t?wv:jv}function $d({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:a,size:h,boostLevel:f}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((b,k)=>(b.push(...$r.QrSegment.makeSegments(k)),b),[]);return $r.QrCode.encodeSegments(v,yv[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:u,margin:d,numCells:p,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=Cv(n,s),b=x.length+v*2,k=_v(x,h,v,a);return{cells:x,margin:v,numCells:b,calculatedImageSettings:k}},[c,h,a,n,s]);return{qrcode:c,margin:d,cells:u,numCells:p,calculatedImageSettings:m}}var Sv=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),$v=i.forwardRef(function(r,o){const n=r,{value:s,size:a=bd,level:h=yd,bgColor:f=wd,fgColor:c=jd,includeMargin:u=kd,minVersion:d=_d,boostLevel:p,marginSize:m,imageSettings:x}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:k}=b,$=Is(b,["style"]),S=x==null?void 0:x.src,C=i.useRef(null),z=i.useRef(null),w=i.useCallback(I=>{C.current=I,typeof o=="function"?o(I):o&&(o.current=I)},[o]),[y,g]=i.useState(!1),{margin:_,cells:E,numCells:j,calculatedImageSettings:T}=$d({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:m,imageSettings:x,size:a});i.useEffect(()=>{if(C.current!=null){const I=C.current,O=I.getContext("2d");if(!O)return;let N=E;const D=z.current,L=T!=null&&D!==null&&D.complete&&D.naturalHeight!==0&&D.naturalWidth!==0;L&&T.excavation!=null&&(N=Sd(E,T.excavation));const P=window.devicePixelRatio||1;I.height=I.width=a*P;const A=a/j*P;O.scale(A,A),O.fillStyle=f,O.fillRect(0,0,j,j),O.fillStyle=c,Sv?O.fill(new Path2D(Cd(N,_))):E.forEach(function(q,Y){q.forEach(function(B,H){B&&O.fillRect(H+_,Y+_,1,1)})}),T&&(O.globalAlpha=T.opacity),L&&O.drawImage(D,T.x+_,T.y+_,T.w,T.h)}}),i.useEffect(()=>{g(!1)},[S]);const R=Ps({height:a,width:a},k);let M=null;return S!=null&&(M=i.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{g(!0)},ref:z,crossOrigin:T==null?void 0:T.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",Ps({style:R,height:a,width:a,ref:w,role:"img"},$)),M)});$v.displayName="QRCodeCanvas";var Zs=i.forwardRef(function(r,o){const n=r,{value:s,size:a=bd,level:h=yd,bgColor:f=wd,fgColor:c=jd,includeMargin:u=kd,minVersion:d=_d,boostLevel:p,title:m,marginSize:x,imageSettings:v}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:k,cells:$,numCells:S,calculatedImageSettings:C}=$d({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:x,imageSettings:v,size:a});let z=$,w=null;v!=null&&C!=null&&(C.excavation!=null&&(z=Sd($,C.excavation)),w=i.createElement("image",{href:v.src,height:C.h,width:C.w,x:C.x+k,y:C.y+k,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const y=Cd(z,k);return i.createElement("svg",Ps({height:a,width:a,viewBox:`0 0 ${S} ${S}`,ref:o,role:"img"},b),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:f,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:y,shapeRendering:"crispEdges"}),w)});Zs.displayName="QRCodeSVG";const zd=i.createContext(void 0),Yt=()=>{const t=i.useContext(zd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},zv=l.div`
3805
3807
  position: fixed;
3806
3808
  background: var(--color-background);
3807
3809
  border-radius: var(--radius-md);
@@ -3825,11 +3827,11 @@ cursor: pointer;
3825
3827
  font-weight: 400;
3826
3828
  color: var(--color-foreground);
3827
3829
  margin-bottom: 12px;
3828
- `,zv=l.div`
3830
+ `,Ev=l.div`
3829
3831
  display: flex;
3830
3832
  align-items: center;
3831
3833
  gap: 8px;
3832
- `,Ev=l.div`
3834
+ `,Pv=l.div`
3833
3835
  width: 40px;
3834
3836
  height: 38px;
3835
3837
  border-radius: var(--radius-sm);
@@ -3840,7 +3842,7 @@ cursor: pointer;
3840
3842
  justify-content: center;
3841
3843
  color: var(--color-muted);
3842
3844
  flex-shrink: 0;
3843
- `,Ui=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:a})=>{const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const y=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const E=a.current;if(E){const j=E.getBoundingClientRect(),T=380,R=300,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),d({top:I,left:O})}},10),g=E=>{h.current&&!h.current.contains(E.target)&&t()},_=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",_),()=>{clearTimeout(y),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",_)}},[t,a]);const[m,x]=i.useState(s?"otp":"email"),[v,b]=i.useState(s||""),[k,$]=i.useState(""),[S,C]=i.useState(!1),z=async()=>{if(!(!v||S)){C(!0);try{await r(v),x("otp")}catch(y){const g=y.message||"Failed to add email address. Please try again.";p(g,"error")}finally{C(!1)}}},w=async()=>{C(!0);try{await o(k),t()}catch(y){const g=y.message||"Failed to verify email. Please check the code and try again.";p(g,"error")}finally{C(!1)}};return f?e.jsx($v,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(Bi,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(zv,{children:[e.jsx(Ev,{children:e.jsx(hn,{size:16})}),e.jsx(se,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:y=>b(y.target.value),style:{flex:1}})]})}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:!v||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bi,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(qt,{onComplete:async y=>$(y),onResend:n,isSubmitting:S}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(J,{onClick:w,disabled:k.length<6||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Verifying...":"Verify"})]})]})}):null},Pv=l.div`
3845
+ `,Ui=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:a})=>{const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const y=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const E=a.current;if(E){const j=E.getBoundingClientRect(),T=380,R=300,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),d({top:I,left:O})}},10),g=E=>{h.current&&!h.current.contains(E.target)&&t()},_=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",_),()=>{clearTimeout(y),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",_)}},[t,a]);const[m,x]=i.useState(s?"otp":"email"),[v,b]=i.useState(s||""),[k,$]=i.useState(""),[S,C]=i.useState(!1),z=async()=>{if(!(!v||S)){C(!0);try{await r(v),x("otp")}catch(y){const g=y.message||"Failed to add email address. Please try again.";p(g,"error")}finally{C(!1)}}},w=async()=>{C(!0);try{await o(k),t()}catch(y){const g=y.message||"Failed to verify email. Please check the code and try again.";p(g,"error")}finally{C(!1)}};return f?e.jsx(zv,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(Bi,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(Ev,{children:[e.jsx(Pv,{children:e.jsx(hn,{size:16})}),e.jsx(se,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:y=>b(y.target.value),style:{flex:1}})]})}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:!v||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bi,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(qt,{onComplete:async y=>$(y),onResend:n,isSubmitting:S}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(J,{onClick:w,disabled:k.length<6||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Verifying...":"Verify"})]})]})}):null},Iv=l.div`
3844
3846
  position: fixed;
3845
3847
  background: var(--color-background);
3846
3848
  border-radius: var(--radius-md);
@@ -3864,7 +3866,7 @@ cursor: pointer;
3864
3866
  font-weight: 400;
3865
3867
  color: var(--color-foreground);
3866
3868
  margin-bottom: 12px;
3867
- `,Gi=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:a})=>{var _;const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const E=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const R=a.current;if(R){const M=R.getBoundingClientRect(),I=380,O=300,N=8;let D=0,L=0;const P=window.innerHeight-M.bottom,A=M.top;P>=O+N?(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):A>=O+N?(D=M.top-O-N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left)),d({top:D,left:L})}},10),j=R=>{h.current&&!h.current.contains(R.target)&&t()},T=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(E),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,a]);const[m,x]=i.useState(n?"otp":"phone"),[v,b]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[k,$]=i.useState((_=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:_.pop()),[S,C]=i.useState(""),[z,w]=i.useState(!1),y=async()=>{if(!(!v||z)){w(!0);try{await r(v,k||""),x("otp")}catch(E){const j=E.message||"Failed to add phone number. Please try again.";p(j,"error")}finally{w(!1)}}},g=async()=>{w(!0);try{await o(S),t()}catch(E){const j=E.message||"Failed to verify phone. Please check the code and try again.";p(j,"error")}finally{w(!1)}};return f?e.jsx(Pv,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(oo,{value:v,onChange:E=>b(E.target.value),error:"",countryCode:k,setCountryCode:$})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:y,disabled:!v||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(qt,{onComplete:E=>C(E),onResend:async()=>s()})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:g,disabled:S.length!==6||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},Iv=l.div`
3869
+ `,Gi=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:a})=>{var _;const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const E=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const R=a.current;if(R){const M=R.getBoundingClientRect(),I=380,O=300,N=8;let D=0,L=0;const P=window.innerHeight-M.bottom,A=M.top;P>=O+N?(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):A>=O+N?(D=M.top-O-N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left)),d({top:D,left:L})}},10),j=R=>{h.current&&!h.current.contains(R.target)&&t()},T=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(E),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,a]);const[m,x]=i.useState(n?"otp":"phone"),[v,b]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[k,$]=i.useState((_=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:_.pop()),[S,C]=i.useState(""),[z,w]=i.useState(!1),y=async()=>{if(!(!v||z)){w(!0);try{await r(v,k||""),x("otp")}catch(E){const j=E.message||"Failed to add phone number. Please try again.";p(j,"error")}finally{w(!1)}}},g=async()=>{w(!0);try{await o(S),t()}catch(E){const j=E.message||"Failed to verify phone. Please check the code and try again.";p(j,"error")}finally{w(!1)}};return f?e.jsx(Iv,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(oo,{value:v,onChange:E=>b(E.target.value),error:"",countryCode:k,setCountryCode:$})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:y,disabled:!v||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(qt,{onComplete:E=>C(E),onResend:async()=>s()})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:g,disabled:S.length!==6||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},Rv=l.div`
3868
3870
  position: fixed;
3869
3871
  background: var(--color-background);
3870
3872
  border-radius: var(--radius-md);
@@ -3907,7 +3909,7 @@ cursor: pointer;
3907
3909
  font-weight: 400;
3908
3910
  color: var(--color-foreground);
3909
3911
  margin-bottom: 8px;
3910
- `,Rv=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const s=i.useRef(null),[a,h]=i.useState("qr"),[f,c]=i.useState(""),[u,d]=i.useState(""),[p,m]=i.useState(["",""]),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState({top:0,left:0}),{toast:C}=Yt();i.useEffect(()=>{k(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const _=n.current;if(_){const E=_.getBoundingClientRect(),j=380,T=400,R=8;let M=0,I=0;const O=window.innerHeight-E.bottom,N=E.top;O>=T+R?(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):N>=T+R?(M=E.top-T-R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left)),S({top:M,left:I})}},10),y=_=>{s.current&&!s.current.contains(_.target)&&t()},g=_=>{_.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,n]),i.useEffect(()=>{(async()=>{v(!0);try{const y=await r();c(y.otp_url||""),d(y.totp_secret||"")}catch(y){const g=y.message||"Failed to setup two-factor authentication. Please try again.";C(g,"error")}finally{v(!1)}})()},[]);const z=async()=>{if(!p.some(w=>w.length!==6)){v(!0);try{await o(p),t()}catch(w){const y=w.message||"Failed to verify codes. Please check your authenticator app and try again.";C(y,"error")}finally{v(!1)}}};return b?e.jsx(Iv,{ref:s,style:{top:`${$.top}px`,left:`${$.left}px`,visibility:$.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:a==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(qi,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:x?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):f?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Zs,{value:f,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),u&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:u})]}),e.jsx(Hi,{children:e.jsx(rs,{$primary:!0,onClick:()=>h("verify"),disabled:x||!f,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(qi,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(se,{id:"totp-code-1",type:"text",placeholder:"000000",value:p[0],onChange:w=>{const y=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([y,p[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(se,{id:"totp-code-2",type:"text",placeholder:"000000",value:p[1],onChange:w=>{const y=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([p[0],y])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(Hi,{children:[e.jsx(rs,{onClick:()=>h("qr"),children:"Back"}),e.jsx(rs,{$primary:!0,onClick:z,disabled:x||p.some(w=>w.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},Tv=l.div`
3912
+ `,Tv=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const s=i.useRef(null),[a,h]=i.useState("qr"),[f,c]=i.useState(""),[u,d]=i.useState(""),[p,m]=i.useState(["",""]),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState({top:0,left:0}),{toast:C}=Yt();i.useEffect(()=>{k(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const _=n.current;if(_){const E=_.getBoundingClientRect(),j=380,T=400,R=8;let M=0,I=0;const O=window.innerHeight-E.bottom,N=E.top;O>=T+R?(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):N>=T+R?(M=E.top-T-R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left)),S({top:M,left:I})}},10),y=_=>{s.current&&!s.current.contains(_.target)&&t()},g=_=>{_.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,n]),i.useEffect(()=>{(async()=>{v(!0);try{const y=await r();c(y.otp_url||""),d(y.totp_secret||"")}catch(y){const g=y.message||"Failed to setup two-factor authentication. Please try again.";C(g,"error")}finally{v(!1)}})()},[]);const z=async()=>{if(!p.some(w=>w.length!==6)){v(!0);try{await o(p),t()}catch(w){const y=w.message||"Failed to verify codes. Please check your authenticator app and try again.";C(y,"error")}finally{v(!1)}}};return b?e.jsx(Rv,{ref:s,style:{top:`${$.top}px`,left:`${$.left}px`,visibility:$.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:a==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(qi,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:x?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):f?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Zs,{value:f,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),u&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:u})]}),e.jsx(Hi,{children:e.jsx(rs,{$primary:!0,onClick:()=>h("verify"),disabled:x||!f,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(qi,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(se,{id:"totp-code-1",type:"text",placeholder:"000000",value:p[0],onChange:w=>{const y=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([y,p[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(se,{id:"totp-code-2",type:"text",placeholder:"000000",value:p[1],onChange:w=>{const y=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([p[0],y])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(Hi,{children:[e.jsx(rs,{onClick:()=>h("qr"),children:"Back"}),e.jsx(rs,{$primary:!0,onClick:z,disabled:x||p.some(w=>w.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},Mv=l.div`
3911
3913
  position: fixed;
3912
3914
  background: var(--color-background);
3913
3915
  border-radius: var(--radius-md);
@@ -3940,12 +3942,12 @@ cursor: pointer;
3940
3942
  opacity: 0.5;
3941
3943
  cursor: not-allowed;
3942
3944
  }
3943
- `,Mv=l.div`
3945
+ `,Ov=l.div`
3944
3946
  display: flex;
3945
3947
  gap: 8px;
3946
3948
  justify-content: flex-end;
3947
3949
  margin-top: 16px;
3948
- `,Ov=l.div`
3950
+ `,Av=l.div`
3949
3951
  font-size: 14px;
3950
3952
  font-weight: 400;
3951
3953
  color: var(--color-foreground);
@@ -3977,7 +3979,7 @@ cursor: pointer;
3977
3979
  color: var(--color-error);
3978
3980
  font-size: 12px;
3979
3981
  margin-top: 4px;
3980
- `,Zi=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const s=i.useRef(null),[a,h]=i.useState(!1),[f,c]=i.useState({top:0,left:0}),[u,d]=i.useState(""),[p,m]=i.useState(""),[x,v]=i.useState(""),[b,k]=i.useState(!1),[$,S]=i.useState(!1),[C,z]=i.useState(!1),[w,y]=i.useState(!1),[g,_]=i.useState({});i.useEffect(()=>{h(!0);const j=setTimeout(()=>{if(!s.current||!(o!=null&&o.current))return;const M=o.current;if(M){const I=M.getBoundingClientRect(),O=380,N=350,D=8;let L=0,P=0;const A=window.innerHeight-I.bottom,q=I.top;A>=N+D?(L=I.bottom+D,P=I.right-O,P<D&&(P=I.left,P+O>window.innerWidth-D&&(P=(window.innerWidth-O)/2))):q>=N+D?(L=I.top-N-D,P=I.right-O,P<D&&(P=I.left,P+O>window.innerWidth-D&&(P=(window.innerWidth-O)/2))):(L=I.bottom+D,P=I.right-O,P<D&&(P=I.left)),c({top:L,left:P})}},10),T=M=>{s.current&&!s.current.contains(M.target)&&t()},R=M=>{M.key==="Escape"&&t()};return document.addEventListener("mousedown",T),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",T),document.removeEventListener("keydown",R)}},[t,o]);const E=async()=>{if(w)return;const j={};if(!n&&!u&&(j.currentPassword="Current password is required"),p?p.length<8&&(j.newPassword="Password must be at least 8 characters"):j.newPassword="New password is required",p!==x&&(j.confirmPassword="Passwords do not match"),Object.keys(j).length>0){_(j);return}y(!0);try{await r(n?"":u,p),t()}catch(T){_({form:T.message||"Failed to update password"})}finally{y(!1)}};return a?e.jsxs(Tv,{ref:s,style:{top:`${f.top}px`,left:`${f.left}px`,visibility:f.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:[e.jsx(Ov,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(os,{children:[e.jsx(ie,{children:"Current Password"}),e.jsxs(ns,{children:[e.jsx(se,{type:b?"text":"password",placeholder:"Enter your current password",value:u,onChange:j=>d(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!b),"aria-label":b?"Hide current password":"Show current password",children:b?e.jsx(Mn,{size:16}):e.jsx(On,{size:16})})]}),g.currentPassword&&e.jsx(Ao,{children:g.currentPassword})]}),e.jsxs(os,{children:[e.jsx(ie,{children:n?"Password":"New Password"}),e.jsxs(ns,{children:[e.jsx(se,{type:$?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:p,onChange:j=>m(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>S(!$),"aria-label":$?"Hide new password":"Show new password",children:$?e.jsx(Mn,{size:16}):e.jsx(On,{size:16})})]}),g.newPassword&&e.jsx(Ao,{children:g.newPassword})]}),e.jsxs(os,{children:[e.jsx(ie,{children:"Confirm New Password"}),e.jsxs(ns,{children:[e.jsx(se,{type:C?"text":"password",placeholder:"Confirm your new password",value:x,onChange:j=>v(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>z(!C),"aria-label":C?"Hide confirm password":"Show confirm password",children:C?e.jsx(Mn,{size:16}):e.jsx(On,{size:16})})]}),g.confirmPassword&&e.jsx(Ao,{children:g.confirmPassword})]}),g.form&&e.jsx(Ao,{children:g.form}),e.jsxs(Mv,{children:[e.jsx(Yi,{onClick:t,children:"Cancel"}),e.jsx(Yi,{$primary:!0,onClick:E,disabled:w,children:w?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},Av=l.div`
3982
+ `,Zi=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const s=i.useRef(null),[a,h]=i.useState(!1),[f,c]=i.useState({top:0,left:0}),[u,d]=i.useState(""),[p,m]=i.useState(""),[x,v]=i.useState(""),[b,k]=i.useState(!1),[$,S]=i.useState(!1),[C,z]=i.useState(!1),[w,y]=i.useState(!1),[g,_]=i.useState({});i.useEffect(()=>{h(!0);const j=setTimeout(()=>{if(!s.current||!(o!=null&&o.current))return;const M=o.current;if(M){const I=M.getBoundingClientRect(),O=380,N=350,D=8;let L=0,P=0;const A=window.innerHeight-I.bottom,q=I.top;A>=N+D?(L=I.bottom+D,P=I.right-O,P<D&&(P=I.left,P+O>window.innerWidth-D&&(P=(window.innerWidth-O)/2))):q>=N+D?(L=I.top-N-D,P=I.right-O,P<D&&(P=I.left,P+O>window.innerWidth-D&&(P=(window.innerWidth-O)/2))):(L=I.bottom+D,P=I.right-O,P<D&&(P=I.left)),c({top:L,left:P})}},10),T=M=>{s.current&&!s.current.contains(M.target)&&t()},R=M=>{M.key==="Escape"&&t()};return document.addEventListener("mousedown",T),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",T),document.removeEventListener("keydown",R)}},[t,o]);const E=async()=>{if(w)return;const j={};if(!n&&!u&&(j.currentPassword="Current password is required"),p?p.length<8&&(j.newPassword="Password must be at least 8 characters"):j.newPassword="New password is required",p!==x&&(j.confirmPassword="Passwords do not match"),Object.keys(j).length>0){_(j);return}y(!0);try{await r(n?"":u,p),t()}catch(T){_({form:T.message||"Failed to update password"})}finally{y(!1)}};return a?e.jsxs(Mv,{ref:s,style:{top:`${f.top}px`,left:`${f.left}px`,visibility:f.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:[e.jsx(Av,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(os,{children:[e.jsx(ie,{children:"Current Password"}),e.jsxs(ns,{children:[e.jsx(se,{type:b?"text":"password",placeholder:"Enter your current password",value:u,onChange:j=>d(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!b),"aria-label":b?"Hide current password":"Show current password",children:b?e.jsx(Mn,{size:16}):e.jsx(On,{size:16})})]}),g.currentPassword&&e.jsx(Ao,{children:g.currentPassword})]}),e.jsxs(os,{children:[e.jsx(ie,{children:n?"Password":"New Password"}),e.jsxs(ns,{children:[e.jsx(se,{type:$?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:p,onChange:j=>m(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>S(!$),"aria-label":$?"Hide new password":"Show new password",children:$?e.jsx(Mn,{size:16}):e.jsx(On,{size:16})})]}),g.newPassword&&e.jsx(Ao,{children:g.newPassword})]}),e.jsxs(os,{children:[e.jsx(ie,{children:"Confirm New Password"}),e.jsxs(ns,{children:[e.jsx(se,{type:C?"text":"password",placeholder:"Confirm your new password",value:x,onChange:j=>v(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>z(!C),"aria-label":C?"Hide confirm password":"Show confirm password",children:C?e.jsx(Mn,{size:16}):e.jsx(On,{size:16})})]}),g.confirmPassword&&e.jsx(Ao,{children:g.confirmPassword})]}),g.form&&e.jsx(Ao,{children:g.form}),e.jsxs(Ov,{children:[e.jsx(Yi,{onClick:t,children:"Cancel"}),e.jsx(Yi,{$primary:!0,onClick:E,disabled:w,children:w?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},Lv=l.div`
3981
3983
  position: fixed;
3982
3984
  background: var(--color-background);
3983
3985
  border-radius: var(--radius-md);
@@ -3991,12 +3993,12 @@ cursor: pointer;
3991
3993
  @media (max-width: 600px) {
3992
3994
  width: calc(100vw - 48px);
3993
3995
  }
3994
- `,Lv=l.div`
3996
+ `,Dv=l.div`
3995
3997
  display: flex;
3996
3998
  gap: 8px;
3997
3999
  justify-content: flex-end;
3998
4000
  margin-top: 16px;
3999
- `,Dv=l.div`
4001
+ `,Nv=l.div`
4000
4002
  font-size: 16px;
4001
4003
  font-weight: 400;
4002
4004
  color: var(--color-foreground);
@@ -4004,18 +4006,18 @@ cursor: pointer;
4004
4006
  display: flex;
4005
4007
  align-items: center;
4006
4008
  gap: 8px;
4007
- `,Nv=l.div`
4009
+ `,Fv=l.div`
4008
4010
  background: var(--color-warning-bg, rgba(251, 191, 36, 0.1));
4009
4011
  border: 1px solid var(--color-warning-border, rgba(251, 191, 36, 0.3));
4010
4012
  border-radius: var(--radius-sm);
4011
4013
  padding: 12px;
4012
4014
  margin-bottom: 16px;
4013
- `,Fv=l.p`
4015
+ `,Bv=l.p`
4014
4016
  font-size: 13px;
4015
4017
  color: var(--color-warning-text, var(--color-foreground));
4016
4018
  margin: 0;
4017
4019
  line-height: 1.5;
4018
- `,Bv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[h,f]=i.useState({top:0,left:0}),[c,u]=i.useState(""),[d,p]=i.useState(!1),{toast:m}=Yt();i.useEffect(()=>{a(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const $=o.current;if($){const S=$.getBoundingClientRect(),C=400,z=300,w=8;let y=0,g=0;const _=window.innerHeight-S.bottom,E=S.top;_>=z+w?(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):E>=z+w?(y=S.top-z-w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left)),f({top:y,left:g})}},10),b=$=>{n.current&&!n.current.contains($.target)&&t()},k=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",k),()=>{clearTimeout(v),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",k)}},[t,o]);const x=async()=>{if(!(!c||d)){p(!0);try{await r(c),t()}catch(v){const b=v.message||"Failed to remove password. Please try again.";m(b,"error")}finally{p(!1)}}};return s?e.jsxs(Av,{ref:n,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(Dv,{children:[e.jsx(jt,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(Nv,{children:e.jsx(Fv,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(se,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>u(v.target.value),autoFocus:!0})]}),e.jsxs(Lv,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:x,disabled:!c||d,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:d?"Removing...":"Remove Password"})]})]}):null},Uv=l.div`
4020
+ `,Uv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[h,f]=i.useState({top:0,left:0}),[c,u]=i.useState(""),[d,p]=i.useState(!1),{toast:m}=Yt();i.useEffect(()=>{a(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const $=o.current;if($){const S=$.getBoundingClientRect(),C=400,z=300,w=8;let y=0,g=0;const _=window.innerHeight-S.bottom,E=S.top;_>=z+w?(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):E>=z+w?(y=S.top-z-w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left)),f({top:y,left:g})}},10),b=$=>{n.current&&!n.current.contains($.target)&&t()},k=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",k),()=>{clearTimeout(v),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",k)}},[t,o]);const x=async()=>{if(!(!c||d)){p(!0);try{await r(c),t()}catch(v){const b=v.message||"Failed to remove password. Please try again.";m(b,"error")}finally{p(!1)}}};return s?e.jsxs(Lv,{ref:n,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(Nv,{children:[e.jsx(jt,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(Fv,{children:e.jsx(Bv,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(se,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>u(v.target.value),autoFocus:!0})]}),e.jsxs(Dv,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:x,disabled:!c||d,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:d?"Removing...":"Remove Password"})]})]}):null},Wv=l.div`
4019
4021
  position: fixed;
4020
4022
  background: var(--color-background);
4021
4023
  border-radius: var(--radius-md);
@@ -4048,24 +4050,24 @@ cursor: pointer;
4048
4050
  opacity: 0.5;
4049
4051
  cursor: not-allowed;
4050
4052
  }
4051
- `,Wv=l.div`
4053
+ `,Vv=l.div`
4052
4054
  display: flex;
4053
4055
  justify-content: space-between;
4054
4056
  align-items: center;
4055
4057
  margin-bottom: 8px;
4056
- `,Vv=l.div`
4058
+ `,Gv=l.div`
4057
4059
  font-size: 14px;
4058
4060
  font-weight: 400;
4059
4061
  color: var(--color-foreground);
4060
- `,Gv=l.div`
4062
+ `,Hv=l.div`
4061
4063
  display: flex;
4062
4064
  gap: 8px;
4063
- `,Hv=l.div`
4065
+ `,qv=l.div`
4064
4066
  display: grid;
4065
4067
  grid-template-columns: repeat(2, 1fr);
4066
4068
  gap: 6px;
4067
4069
  margin: 12px 0;
4068
- `,qv=l.div`
4070
+ `,Yv=l.div`
4069
4071
  background: var(--color-input-background);
4070
4072
  border: 1px solid var(--color-border);
4071
4073
  border-radius: var(--radius-sm);
@@ -4081,7 +4083,7 @@ cursor: pointer;
4081
4083
  background: var(--color-input-background-hover);
4082
4084
  border-color: var(--color-primary);
4083
4085
  }
4084
- `,Yv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:s})=>{const a=i.useRef(null),[h,f]=i.useState(!1),[c,u]=i.useState({top:0,left:0});return i.useEffect(()=>{f(!0);const d=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const x=s.current;if(x){const v=x.getBoundingClientRect(),b=380,k=300,$=8;let S=0,C=0;const z=window.innerHeight-v.bottom,w=v.top;z>=k+$?(S=v.bottom+$,C=v.right-b,C<$&&(C=v.left,C+b>window.innerWidth-$&&(C=(window.innerWidth-b)/2))):w>=k+$?(S=v.top-k-$,C=v.right-b,C<$&&(C=v.left,C+b>window.innerWidth-$&&(C=(window.innerWidth-b)/2))):(S=v.bottom+$,C=v.right-b,C<$&&(C=v.left)),u({top:S,left:C})}},10),p=x=>{a.current&&!a.current.contains(x.target)&&r()},m=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{clearTimeout(d),document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[r,s]),h?e.jsxs(Uv,{ref:a,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:d=>d.stopPropagation(),children:[e.jsxs(Wv,{children:[e.jsx(Vv,{children:"Backup Codes"}),e.jsxs(Gv,{children:[e.jsxs(Ki,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(pr,{size:14}),"Copy"]}),e.jsxs(Ki,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(pn,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(Hv,{children:t.map((d,p)=>e.jsx(qv,{onClick:()=>{navigator.clipboard.writeText(d)},title:"Click to copy",children:d},p))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},Zv=l.div`
4086
+ `,Zv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:s})=>{const a=i.useRef(null),[h,f]=i.useState(!1),[c,u]=i.useState({top:0,left:0});return i.useEffect(()=>{f(!0);const d=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const x=s.current;if(x){const v=x.getBoundingClientRect(),b=380,k=300,$=8;let S=0,C=0;const z=window.innerHeight-v.bottom,w=v.top;z>=k+$?(S=v.bottom+$,C=v.right-b,C<$&&(C=v.left,C+b>window.innerWidth-$&&(C=(window.innerWidth-b)/2))):w>=k+$?(S=v.top-k-$,C=v.right-b,C<$&&(C=v.left,C+b>window.innerWidth-$&&(C=(window.innerWidth-b)/2))):(S=v.bottom+$,C=v.right-b,C<$&&(C=v.left)),u({top:S,left:C})}},10),p=x=>{a.current&&!a.current.contains(x.target)&&r()},m=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{clearTimeout(d),document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[r,s]),h?e.jsxs(Wv,{ref:a,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:d=>d.stopPropagation(),children:[e.jsxs(Vv,{children:[e.jsx(Gv,{children:"Backup Codes"}),e.jsxs(Hv,{children:[e.jsxs(Ki,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(pr,{size:14}),"Copy"]}),e.jsxs(Ki,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(pn,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(qv,{children:t.map((d,p)=>e.jsx(Yv,{onClick:()=>{navigator.clipboard.writeText(d)},title:"Click to copy",children:d},p))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},Kv=l.div`
4085
4087
  position: fixed;
4086
4088
  background: var(--color-background);
4087
4089
  border-radius: var(--radius-md);
@@ -4114,29 +4116,29 @@ cursor: pointer;
4114
4116
  opacity: 0.5;
4115
4117
  cursor: not-allowed;
4116
4118
  }
4117
- `,Kv=l.div`
4119
+ `,Qv=l.div`
4118
4120
  display: flex;
4119
4121
  gap: 8px;
4120
4122
  justify-content: flex-end;
4121
4123
  margin-top: 16px;
4122
- `,Qv=l.div`
4124
+ `,Xv=l.div`
4123
4125
  font-size: 14px;
4124
4126
  font-weight: 400;
4125
4127
  color: var(--color-foreground);
4126
4128
  margin-bottom: 8px;
4127
- `,Xv=l.div`
4129
+ `,Jv=l.div`
4128
4130
  display: flex;
4129
4131
  flex-direction: column;
4130
4132
  gap: 4px;
4131
4133
  margin-bottom: 12px;
4132
- `,Jv=l.div`
4134
+ `,e1=l.div`
4133
4135
  color: var(--color-error);
4134
4136
  font-size: 12px;
4135
4137
  margin-top: 4px;
4136
- `,e1=({onClose:t,onAddPasskey:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[h,f]=i.useState({top:0,left:0}),[c,u]=i.useState(""),[d,p]=i.useState(!1),[m,x]=i.useState("");i.useEffect(()=>{a(!0);const b=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const S=o.current;if(S){const C=S.getBoundingClientRect(),z=320,w=180,y=8;let g=0,_=0;const E=window.innerHeight-C.bottom,j=C.top;E>=w+y?(g=C.bottom+y,_=C.right-z,_<y&&(_=C.left,_+z>window.innerWidth-y&&(_=(window.innerWidth-z)/2))):j>=w+y?(g=C.top-w-y,_=C.right-z,_<y&&(_=C.left,_+z>window.innerWidth-y&&(_=(window.innerWidth-z)/2))):(g=C.bottom+y,_=C.right-z,_<y&&(_=C.left)),f({top:g,left:_})}},10),k=S=>{n.current&&!n.current.contains(S.target)&&t()},$=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",k),document.addEventListener("keydown",$),()=>{clearTimeout(b),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",$)}},[t,o]);const v=async()=>{if(!d){p(!0),x("");try{await r(c.trim()),t()}catch(b){x(b.message||"Failed to register passkey"),p(!1)}}};return s?e.jsxs(Zv,{ref:n,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:[e.jsx(Qv,{children:"Add Passkey"}),e.jsx(Xv,{children:e.jsx(se,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:c,onChange:b=>u(b.target.value),autoFocus:!0})}),m&&e.jsx(Jv,{children:m}),e.jsxs(Kv,{children:[e.jsx(Qi,{onClick:t,children:"Cancel"}),e.jsx(Qi,{$primary:!0,onClick:v,disabled:d,children:d?"Registering...":"Continue"})]})]}):null},t1=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),r1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),o1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),n1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),s1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),a1=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),i1=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),c1=Ht`
4138
+ `,t1=({onClose:t,onAddPasskey:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[h,f]=i.useState({top:0,left:0}),[c,u]=i.useState(""),[d,p]=i.useState(!1),[m,x]=i.useState("");i.useEffect(()=>{a(!0);const b=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const S=o.current;if(S){const C=S.getBoundingClientRect(),z=320,w=180,y=8;let g=0,_=0;const E=window.innerHeight-C.bottom,j=C.top;E>=w+y?(g=C.bottom+y,_=C.right-z,_<y&&(_=C.left,_+z>window.innerWidth-y&&(_=(window.innerWidth-z)/2))):j>=w+y?(g=C.top-w-y,_=C.right-z,_<y&&(_=C.left,_+z>window.innerWidth-y&&(_=(window.innerWidth-z)/2))):(g=C.bottom+y,_=C.right-z,_<y&&(_=C.left)),f({top:g,left:_})}},10),k=S=>{n.current&&!n.current.contains(S.target)&&t()},$=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",k),document.addEventListener("keydown",$),()=>{clearTimeout(b),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",$)}},[t,o]);const v=async()=>{if(!d){p(!0),x("");try{await r(c.trim()),t()}catch(b){x(b.message||"Failed to register passkey"),p(!1)}}};return s?e.jsxs(Kv,{ref:n,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:[e.jsx(Xv,{children:"Add Passkey"}),e.jsx(Jv,{children:e.jsx(se,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:c,onChange:b=>u(b.target.value),autoFocus:!0})}),m&&e.jsx(e1,{children:m}),e.jsxs(Qv,{children:[e.jsx(Qi,{onClick:t,children:"Cancel"}),e.jsx(Qi,{$primary:!0,onClick:v,disabled:d,children:d?"Registering...":"Continue"})]})]}):null},r1=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),o1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),n1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),s1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),a1=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),i1=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),c1=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),l1=Ht`
4137
4139
  0% { transform: rotate(0deg); }
4138
4140
  100% { transform: rotate(360deg); }
4139
- `,l1=l.div`
4141
+ `,d1=l.div`
4140
4142
  * {
4141
4143
  box-sizing: border-box;
4142
4144
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -4188,14 +4190,14 @@ cursor: pointer;
4188
4190
  pointer-events: none;
4189
4191
  z-index: 1;
4190
4192
  }
4191
- `,d1=l.div`
4193
+ `,u1=l.div`
4192
4194
  padding: 0 24px;
4193
4195
  border-bottom: 1px solid var(--color-border);
4194
4196
 
4195
4197
  @media (max-width: 768px) {
4196
4198
  padding: 0 20px;
4197
4199
  }
4198
- `,u1=l.div`
4200
+ `,p1=l.div`
4199
4201
  display: flex;
4200
4202
  align-items: center;
4201
4203
  gap: 20px;
@@ -4237,7 +4239,7 @@ cursor: pointer;
4237
4239
  display: inline-flex;
4238
4240
  align-items: center;
4239
4241
  gap: 6px;
4240
- `,p1=l.div`
4242
+ `,h1=l.div`
4241
4243
  flex: 1;
4242
4244
  padding: 24px 24px 0 24px;
4243
4245
  overflow-y: auto;
@@ -4268,7 +4270,7 @@ cursor: pointer;
4268
4270
  flex-wrap: wrap;
4269
4271
  gap: 12px;
4270
4272
  margin-bottom: 0;
4271
- `,h1=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),f1=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(r1,{...o}):r.includes("firefox")?e.jsx(o1,{...o}):r.includes("safari")?e.jsx(n1,{...o}):r.includes("edge")?e.jsx(s1,{...o}):r.includes("opera")?e.jsx(a1,{...o}):r.includes("brave")?e.jsx(i1,{...o}):e.jsx(h1,{})},g1=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:s,loading:a}=Vc(),{refetch:h}=Qe(),{toast:f}=Yt(),c=o,u=async p=>{try{await n(p),await Promise.all([s(),h()]),r(null),f("Session ended successfully","info")}catch(m){f(m.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const m=new Date(p);if(isNaN(m.getTime()))return"Unknown";const v=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return v<1?"Just now":v<60?`${v}m ago`:v<1440?`${Math.floor(v/60)}h ago`:m.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Browser & Device"}),e.jsx(Ee,{children:"Location"}),e.jsx(Ee,{children:"Last Active"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:c.map(p=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ed,{children:e.jsx(f1,{browser:p.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.device})]})]})}),e.jsx(Ue,{children:e.jsxs("div",{children:[e.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.ip_address})]})}),e.jsx(Ue,{children:d(p.last_active_at)}),e.jsx($t,{children:e.jsxs(ft,{open:t===p.id,openChange:m=>r(m?p.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{children:"•••"})}),e.jsx(gt,{children:e.jsx(Be,{onClick:()=>u(p.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ft,{size:14}),"End Session"]})})})]})})]},p.id))})]}):e.jsx(xt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},m1=()=>{var y,g,_,E;const{deployment:t}=we(),{toast:r}=Yt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[h,f]=i.useState(!1),[c,u]=i.useState(null),[d,p]=i.useState(""),m=i.useRef(null),x=i.useRef({}),{user:v,createEmailAddress:b,deleteEmailAddress:k,prepareEmailVerification:$,attemptEmailVerification:S,makeEmailPrimary:C}=Gt();if(!((g=(y=t==null?void 0:t.auth_settings)==null?void 0:y.email_address)!=null&&g.enabled))return null;const z=async j=>{try{if(j===(v==null?void 0:v.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await k(j),v.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},w=i.useMemo(()=>v!=null&&v.user_email_addresses?d.trim()?v.user_email_addresses.filter(j=>j.email.toLowerCase().includes(d.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,d]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:d,onChange:p,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:m,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),h&&e.jsx(Ui,{triggerRef:m,onClose:()=>f(!1),onAddEmail:async j=>{const T=await b(j);a(T.data.id),await $(T.data.id),v.refetch()},onPrepareVerification:async()=>{await $(s),v.refetch()},onAttemptVerification:async j=>{await S(s,j),v.refetch(),f(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email Address"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(j=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:j.email}),e.jsx(Ue,{children:j.id===(v==null?void 0:v.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx($t,{children:j.id!==(v==null?void 0:v.primary_email_address_id)||!j.verified?e.jsxs(ft,{open:o===j.id,openChange:T=>n(T?j.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:T=>{T&&(x.current[j.id]=T)},children:"•••"})}),e.jsxs(gt,{children:[j.id!==(v==null?void 0:v.primary_email_address_id)&&j.verified&&e.jsx(Be,{onClick:async()=>{try{await C(j.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Be,{onClick:async()=>{n(null),await $(j.id),u(j.id)},children:"Verify email"}),j.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Be,{$destructive:!0,onClick:()=>{z(j.id),n(null)},children:"Remove"})]})]}):null})]},j.id))})]}):e.jsx(xt,{title:d?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(Ui,{existingEmail:(E=(_=v==null?void 0:v.user_email_addresses)==null?void 0:_.find(j=>j.id===c))==null?void 0:E.email,triggerRef:{current:x.current[c]},onClose:()=>u(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await $(c),v.refetch()},onAttemptVerification:async j=>{await S(c,j),v.refetch(),u(null),r("Email verified successfully!","info")}})]})},x1=()=>{var w,y,g,_;const{deployment:t}=we(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState(""),p=i.useRef(null),m=i.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:b,preparePhoneVerification:k,attemptPhoneVerification:$,makePhonePrimary:S}=Gt();if(!((y=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&y.enabled))return null;const C=E=>{const j=Vo.find(T=>T.dialCode===E);return(j==null?void 0:j.flag)||"🌍"},z=i.useMemo(()=>x!=null&&x.user_phone_numbers?u.trim()?x.user_phone_numbers.filter(E=>E.phone_number.toLowerCase().includes(u.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,u]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:u,onChange:d,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:p,onClick:()=>h(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),a&&e.jsx(Gi,{triggerRef:p,onClose:()=>h(!1),onAddPhone:async(E,j)=>{const T=await v(E,j);s(T.data.id),await k(T.data.id)},onPrepareVerification:async()=>{await k(n),x.refetch()},onAttemptVerification:async E=>{await $(n,E),x.refetch(),h(!1)}}),f&&e.jsx(Gi,{existingPhone:(_=(g=x==null?void 0:x.user_phone_numbers)==null?void 0:g.find(E=>E.id===f))==null?void 0:_.phone_number,triggerRef:{current:m.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await k(f),x.refetch()},onAttemptVerification:async E=>{await $(f,E),x.refetch(),c(null)}})]})]}),z!=null&&z.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Phone Number"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(E=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:C(E.country_code)}),e.jsx("span",{children:E.country_code}),e.jsx("span",{children:E.phone_number})]})}),e.jsx(Ue,{children:E.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx($t,{children:e.jsxs(ft,{open:r===E.id,openChange:j=>o(j?E.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:j=>{j&&(m.current[E.id]=j)},children:"•••"})}),e.jsxs(gt,{children:[E.id!==(x==null?void 0:x.primary_phone_number_id)&&E.verified&&e.jsx(Be,{onClick:async()=>{await S(E.id),o(null),x.refetch()},children:"Make primary"}),!E.verified&&e.jsx(Be,{onClick:async()=>{await k(E.id),c(E.id),o(null)},children:"Verify phone"}),e.jsx(Be,{$destructive:!0,onClick:async()=>{await b(E.id),o(null),x.refetch()},children:"Remove"})]})]})})]},E.id))})]}):e.jsx(xt,{title:u?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Ed=l.div`
4273
+ `,f1=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),g1=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(o1,{...o}):r.includes("firefox")?e.jsx(n1,{...o}):r.includes("safari")?e.jsx(s1,{...o}):r.includes("edge")?e.jsx(a1,{...o}):r.includes("opera")?e.jsx(i1,{...o}):r.includes("brave")?e.jsx(c1,{...o}):e.jsx(f1,{})},m1=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:s,loading:a}=Vc(),{refetch:h}=Qe(),{toast:f}=Yt(),c=o,u=async p=>{try{await n(p),await Promise.all([s(),h()]),r(null),f("Session ended successfully","info")}catch(m){f(m.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const m=new Date(p);if(isNaN(m.getTime()))return"Unknown";const v=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return v<1?"Just now":v<60?`${v}m ago`:v<1440?`${Math.floor(v/60)}h ago`:m.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Browser & Device"}),e.jsx(Ee,{children:"Location"}),e.jsx(Ee,{children:"Last Active"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:c.map(p=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ed,{children:e.jsx(g1,{browser:p.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.device})]})]})}),e.jsx(Ue,{children:e.jsxs("div",{children:[e.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.ip_address})]})}),e.jsx(Ue,{children:d(p.last_active_at)}),e.jsx($t,{children:e.jsxs(ft,{open:t===p.id,openChange:m=>r(m?p.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{children:"•••"})}),e.jsx(gt,{children:e.jsx(Be,{onClick:()=>u(p.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ft,{size:14}),"End Session"]})})})]})})]},p.id))})]}):e.jsx(xt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},x1=()=>{var y,g,_,E;const{deployment:t}=we(),{toast:r}=Yt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[h,f]=i.useState(!1),[c,u]=i.useState(null),[d,p]=i.useState(""),m=i.useRef(null),x=i.useRef({}),{user:v,createEmailAddress:b,deleteEmailAddress:k,prepareEmailVerification:$,attemptEmailVerification:S,makeEmailPrimary:C}=Gt();if(!((g=(y=t==null?void 0:t.auth_settings)==null?void 0:y.email_address)!=null&&g.enabled))return null;const z=async j=>{try{if(j===(v==null?void 0:v.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await k(j),v.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},w=i.useMemo(()=>v!=null&&v.user_email_addresses?d.trim()?v.user_email_addresses.filter(j=>j.email.toLowerCase().includes(d.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,d]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:d,onChange:p,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:m,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),h&&e.jsx(Ui,{triggerRef:m,onClose:()=>f(!1),onAddEmail:async j=>{const T=await b(j);a(T.data.id),await $(T.data.id),v.refetch()},onPrepareVerification:async()=>{await $(s),v.refetch()},onAttemptVerification:async j=>{await S(s,j),v.refetch(),f(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email Address"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(j=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:j.email}),e.jsx(Ue,{children:j.id===(v==null?void 0:v.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx($t,{children:j.id!==(v==null?void 0:v.primary_email_address_id)||!j.verified?e.jsxs(ft,{open:o===j.id,openChange:T=>n(T?j.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:T=>{T&&(x.current[j.id]=T)},children:"•••"})}),e.jsxs(gt,{children:[j.id!==(v==null?void 0:v.primary_email_address_id)&&j.verified&&e.jsx(Be,{onClick:async()=>{try{await C(j.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Be,{onClick:async()=>{n(null),await $(j.id),u(j.id)},children:"Verify email"}),j.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Be,{$destructive:!0,onClick:()=>{z(j.id),n(null)},children:"Remove"})]})]}):null})]},j.id))})]}):e.jsx(xt,{title:d?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(Ui,{existingEmail:(E=(_=v==null?void 0:v.user_email_addresses)==null?void 0:_.find(j=>j.id===c))==null?void 0:E.email,triggerRef:{current:x.current[c]},onClose:()=>u(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await $(c),v.refetch()},onAttemptVerification:async j=>{await S(c,j),v.refetch(),u(null),r("Email verified successfully!","info")}})]})},v1=()=>{var w,y,g,_;const{deployment:t}=we(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState(""),p=i.useRef(null),m=i.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:b,preparePhoneVerification:k,attemptPhoneVerification:$,makePhonePrimary:S}=Gt();if(!((y=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&y.enabled))return null;const C=E=>{const j=Vo.find(T=>T.dialCode===E);return(j==null?void 0:j.flag)||"🌍"},z=i.useMemo(()=>x!=null&&x.user_phone_numbers?u.trim()?x.user_phone_numbers.filter(E=>E.phone_number.toLowerCase().includes(u.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,u]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:u,onChange:d,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:p,onClick:()=>h(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),a&&e.jsx(Gi,{triggerRef:p,onClose:()=>h(!1),onAddPhone:async(E,j)=>{const T=await v(E,j);s(T.data.id),await k(T.data.id)},onPrepareVerification:async()=>{await k(n),x.refetch()},onAttemptVerification:async E=>{await $(n,E),x.refetch(),h(!1)}}),f&&e.jsx(Gi,{existingPhone:(_=(g=x==null?void 0:x.user_phone_numbers)==null?void 0:g.find(E=>E.id===f))==null?void 0:_.phone_number,triggerRef:{current:m.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await k(f),x.refetch()},onAttemptVerification:async E=>{await $(f,E),x.refetch(),c(null)}})]})]}),z!=null&&z.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Phone Number"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(E=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:C(E.country_code)}),e.jsx("span",{children:E.country_code}),e.jsx("span",{children:E.phone_number})]})}),e.jsx(Ue,{children:E.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx($t,{children:e.jsxs(ft,{open:r===E.id,openChange:j=>o(j?E.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:j=>{j&&(m.current[E.id]=j)},children:"•••"})}),e.jsxs(gt,{children:[E.id!==(x==null?void 0:x.primary_phone_number_id)&&E.verified&&e.jsx(Be,{onClick:async()=>{await S(E.id),o(null),x.refetch()},children:"Make primary"}),!E.verified&&e.jsx(Be,{onClick:async()=>{await k(E.id),c(E.id),o(null)},children:"Verify phone"}),e.jsx(Be,{$destructive:!0,onClick:async()=>{await b(E.id),o(null),x.refetch()},children:"Remove"})]})]})})]},E.id))})]}):e.jsx(xt,{title:u?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Ed=l.div`
4272
4274
  width: 20px;
4273
4275
  height: 20px;
4274
4276
  flex-shrink: 0;
@@ -4283,11 +4285,11 @@ cursor: pointer;
4283
4285
  flex-shrink: 0;
4284
4286
  display: block;
4285
4287
  }
4286
- `,v1=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=Gt(),{deployment:n}=we(),s={google_oauth:{icon:e.jsx(zl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(t1,{}),label:"Microsoft"},github_oauth:{icon:e.jsx($l,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Il,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Pl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Rl,{}),label:"Discord"},x_oauth:{icon:e.jsx(El,{}),label:"X"}},a=(n==null?void 0:n.social_connections.filter(h=>h.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:a.map((h,f)=>{var d;const c=((d=t==null?void 0:t.social_connections)==null?void 0:d.filter(p=>p.provider===h.provider))||[],u=s[h.provider];return u?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Ed,{children:u.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:u.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(p=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:p.email_address}),e.jsx(vn,{onClick:async()=>{await r(p.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(lt,{size:14})})]},p.id)),c.length>0?e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},h.provider):null})})]})},Pd=()=>{var v,b,k,$,S,C,z;const{loading:t}=Gt(),{deployment:r}=we(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((w,y="info")=>{a(w),f(y),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(fe,{children:e.jsx(Xi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const u=r==null?void 0:r.auth_settings,d=(v=u==null?void 0:u.email_address)==null?void 0:v.enabled,p=(b=u==null?void 0:u.phone_number)==null?void 0:b.enabled,m=((k=r==null?void 0:r.social_connections)==null?void 0:k.some(w=>w.enabled))||!1,x=(($=u==null?void 0:u.password)==null?void 0:$.enabled)||((S=u==null?void 0:u.auth_factors_enabled)==null?void 0:S.authenticator)||((C=u==null?void 0:u.auth_factors_enabled)==null?void 0:C.phone_otp)||((z=u==null?void 0:u.auth_factors_enabled)==null?void 0:z.backup_code);return e.jsx(fe,{children:e.jsx(l1,{children:e.jsx(zd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Xi,{children:[e.jsx(d1,{children:e.jsxs(u1,{children:[e.jsx(Cr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(Sr,{children:[e.jsx(Ko,{size:16}),"Profile"]})}),d&&e.jsx(Cr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(Sr,{children:[e.jsx(hn,{size:16}),"Email"]})}),p&&e.jsx(Cr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(Sr,{children:[e.jsx(Yh,{size:16}),"Phone"]})}),m&&e.jsx(Cr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(Sr,{children:[e.jsx(Dh,{size:16}),"Connections"]})}),x&&e.jsx(Cr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(Sr,{children:[e.jsx(pt,{size:16}),"Security"]})}),e.jsx(Cr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(Sr,{children:[e.jsx(uh,{size:16}),"Sessions"]})})]})}),e.jsxs(p1,{children:[o==="profile"&&e.jsx(y1,{}),o==="email"&&d&&e.jsx(m1,{}),o==="phone"&&p&&e.jsx(x1,{}),o==="social"&&m&&e.jsx(v1,{}),o==="security"&&x&&e.jsx(b1,{}),o==="sessions"&&e.jsx(g1,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},b1=()=>{var Qs,Xs,Js,ea,ta,ra,oa;const{deployment:t}=we(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:h,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:u,getPasskeys:d,registerPasskey:p,deletePasskey:m}=Gt(),{toast:x}=Yt(),[v,b]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[k,$]=i.useState(!1),S=async ae=>{try{await u({second_factor_policy:ae}),b(ae),x("2FA requirement updated successfully","info")}catch(De){x(De.message||"Failed to update 2FA requirement","error")}},[C,z]=i.useState(!1),[w,y]=i.useState(!1),[g,_]=i.useState(!1),[E,j]=i.useState(!1),T=i.useRef(null),R=i.useRef(null),M=i.useRef(null),I=i.useRef(null),[O,N]=i.useState([]),[D,L]=i.useState(!1),[P,A]=i.useState(!1),[q,Y]=i.useState(!1),[B,H]=i.useState(!1),[G,X]=i.useState(null),oe=i.useRef(null),[te,ce]=i.useState("table"),[Q,me]=i.useState(""),[xe,de]=i.useState(""),[U,le]=i.useState(""),[K,Z]=i.useState(["",""]),[re,ge]=i.useState([]),[ue,ee]=i.useState(!1),[V,F]=i.useState(!1),[ne]=i.useState(!1),[be,Me]=i.useState(!1),Ce=(Qs=t==null?void 0:t.auth_settings)==null?void 0:Qs.auth_factors_enabled,Se=(Js=(Xs=t==null?void 0:t.auth_settings)==null?void 0:Xs.password)==null?void 0:Js.enabled;if(!(Ce!=null&&Ce.authenticator)&&!(Ce!=null&&Ce.backup_code)&&!Se)return null;const Ve=async(ae,De)=>{await o(ae,De),await r.refetch(),x("Password updated successfully","info")},Le=async ae=>{await n(ae),await r.refetch(),x("Password removed successfully","info")},Ae=()=>{var na,sa,aa,ia,ca,la;if(!r)return!1;const ae=(na=r.user_email_addresses)==null?void 0:na.some(Dr=>Dr.verified),De=(sa=r.user_phone_numbers)==null?void 0:sa.some(Dr=>Dr.verified),Ne=r.social_connections&&r.social_connections.length>0,et=t==null?void 0:t.auth_settings;return(et==null?void 0:et.first_factor)==="email_otp"&&ae||((aa=et==null?void 0:et.magic_link)==null?void 0:aa.enabled)&&ae||((ia=et==null?void 0:et.passkey)==null?void 0:ia.enabled)||((ca=et==null?void 0:et.auth_factors_enabled)==null?void 0:ca.phone_otp)&&De||Ne&&((la=t==null?void 0:t.social_connections)==null?void 0:la.some(Dr=>Dr.enabled))},ve=async()=>{if(K.some(ae=>ae.length!==6)){x("Please enter both 6-digit verification codes","error");return}try{if(F(!0),await a(U,K),await r.refetch(),Ce!=null&&Ce.backup_code){const ae=await f();ge(ae),await r.refetch(),ce("backup")}else ce("success")}catch(ae){x(ae.message||"Invalid verification codes","error")}finally{F(!1)}},pe=()=>{ce("table"),me(""),de(""),le(""),Z(["",""]),ge([]),x("Two-factor authentication setup completed successfully!","info")},ye=async()=>{var ae;if((ae=r==null?void 0:r.user_authenticator)!=null&&ae.id)try{Me(!0),await h(r.user_authenticator.id),await r.refetch(),$(!1),x("Two-factor authentication removed successfully","info")}catch(De){x(De.message||"Failed to remove authenticator","error")}finally{Me(!1)}},$e=async()=>{if(!ue)try{ee(!0);const ae=await c();ge(ae),await r.refetch(),j(!0),x("New backup codes generated","info")}catch(ae){x(ae.message||"Failed to generate backup codes","error")}finally{ee(!1)}},Ie=()=>{const ae=re.join(`
4288
+ `,b1=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=Gt(),{deployment:n}=we(),s={google_oauth:{icon:e.jsx(zl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(r1,{}),label:"Microsoft"},github_oauth:{icon:e.jsx($l,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Il,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Pl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Rl,{}),label:"Discord"},x_oauth:{icon:e.jsx(El,{}),label:"X"}},a=(n==null?void 0:n.social_connections.filter(h=>h.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:a.map((h,f)=>{var d;const c=((d=t==null?void 0:t.social_connections)==null?void 0:d.filter(p=>p.provider===h.provider))||[],u=s[h.provider];return u?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Ed,{children:u.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:u.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(p=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:p.email_address}),e.jsx(vn,{onClick:async()=>{await r(p.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(lt,{size:14})})]},p.id)),c.length>0?e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},h.provider):null})})]})},Pd=()=>{var v,b,k,$,S,C,z;const{loading:t}=Gt(),{deployment:r}=we(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((w,y="info")=>{a(w),f(y),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(fe,{children:e.jsx(Xi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const u=r==null?void 0:r.auth_settings,d=(v=u==null?void 0:u.email_address)==null?void 0:v.enabled,p=(b=u==null?void 0:u.phone_number)==null?void 0:b.enabled,m=((k=r==null?void 0:r.social_connections)==null?void 0:k.some(w=>w.enabled))||!1,x=(($=u==null?void 0:u.password)==null?void 0:$.enabled)||((S=u==null?void 0:u.auth_factors_enabled)==null?void 0:S.authenticator)||((C=u==null?void 0:u.auth_factors_enabled)==null?void 0:C.phone_otp)||((z=u==null?void 0:u.auth_factors_enabled)==null?void 0:z.backup_code);return e.jsx(fe,{children:e.jsx(d1,{children:e.jsx(zd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Xi,{children:[e.jsx(u1,{children:e.jsxs(p1,{children:[e.jsx(Cr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(Sr,{children:[e.jsx(Ko,{size:16}),"Profile"]})}),d&&e.jsx(Cr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(Sr,{children:[e.jsx(hn,{size:16}),"Email"]})}),p&&e.jsx(Cr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(Sr,{children:[e.jsx(Yh,{size:16}),"Phone"]})}),m&&e.jsx(Cr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(Sr,{children:[e.jsx(Dh,{size:16}),"Connections"]})}),x&&e.jsx(Cr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(Sr,{children:[e.jsx(pt,{size:16}),"Security"]})}),e.jsx(Cr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(Sr,{children:[e.jsx(uh,{size:16}),"Sessions"]})})]})}),e.jsxs(h1,{children:[o==="profile"&&e.jsx(w1,{}),o==="email"&&d&&e.jsx(x1,{}),o==="phone"&&p&&e.jsx(v1,{}),o==="social"&&m&&e.jsx(b1,{}),o==="security"&&x&&e.jsx(y1,{}),o==="sessions"&&e.jsx(m1,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},y1=()=>{var Qs,Xs,Js,ea,ta,ra,oa;const{deployment:t}=we(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:h,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:u,getPasskeys:d,registerPasskey:p,deletePasskey:m}=Gt(),{toast:x}=Yt(),[v,b]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[k,$]=i.useState(!1),S=async ae=>{try{await u({second_factor_policy:ae}),b(ae),x("2FA requirement updated successfully","info")}catch(De){x(De.message||"Failed to update 2FA requirement","error")}},[C,z]=i.useState(!1),[w,y]=i.useState(!1),[g,_]=i.useState(!1),[E,j]=i.useState(!1),T=i.useRef(null),R=i.useRef(null),M=i.useRef(null),I=i.useRef(null),[O,N]=i.useState([]),[D,L]=i.useState(!1),[P,A]=i.useState(!1),[q,Y]=i.useState(!1),[B,H]=i.useState(!1),[G,X]=i.useState(null),oe=i.useRef(null),[te,ce]=i.useState("table"),[Q,me]=i.useState(""),[xe,de]=i.useState(""),[U,le]=i.useState(""),[K,Z]=i.useState(["",""]),[re,ge]=i.useState([]),[ue,ee]=i.useState(!1),[V,F]=i.useState(!1),[ne]=i.useState(!1),[be,Me]=i.useState(!1),Ce=(Qs=t==null?void 0:t.auth_settings)==null?void 0:Qs.auth_factors_enabled,Se=(Js=(Xs=t==null?void 0:t.auth_settings)==null?void 0:Xs.password)==null?void 0:Js.enabled;if(!(Ce!=null&&Ce.authenticator)&&!(Ce!=null&&Ce.backup_code)&&!Se)return null;const Ve=async(ae,De)=>{await o(ae,De),await r.refetch(),x("Password updated successfully","info")},Le=async ae=>{await n(ae),await r.refetch(),x("Password removed successfully","info")},Ae=()=>{var na,sa,aa,ia,ca,la;if(!r)return!1;const ae=(na=r.user_email_addresses)==null?void 0:na.some(Dr=>Dr.verified),De=(sa=r.user_phone_numbers)==null?void 0:sa.some(Dr=>Dr.verified),Ne=r.social_connections&&r.social_connections.length>0,et=t==null?void 0:t.auth_settings;return(et==null?void 0:et.first_factor)==="email_otp"&&ae||((aa=et==null?void 0:et.magic_link)==null?void 0:aa.enabled)&&ae||((ia=et==null?void 0:et.passkey)==null?void 0:ia.enabled)||((ca=et==null?void 0:et.auth_factors_enabled)==null?void 0:ca.phone_otp)&&De||Ne&&((la=t==null?void 0:t.social_connections)==null?void 0:la.some(Dr=>Dr.enabled))},ve=async()=>{if(K.some(ae=>ae.length!==6)){x("Please enter both 6-digit verification codes","error");return}try{if(F(!0),await a(U,K),await r.refetch(),Ce!=null&&Ce.backup_code){const ae=await f();ge(ae),await r.refetch(),ce("backup")}else ce("success")}catch(ae){x(ae.message||"Invalid verification codes","error")}finally{F(!1)}},pe=()=>{ce("table"),me(""),de(""),le(""),Z(["",""]),ge([]),x("Two-factor authentication setup completed successfully!","info")},ye=async()=>{var ae;if((ae=r==null?void 0:r.user_authenticator)!=null&&ae.id)try{Me(!0),await h(r.user_authenticator.id),await r.refetch(),$(!1),x("Two-factor authentication removed successfully","info")}catch(De){x(De.message||"Failed to remove authenticator","error")}finally{Me(!1)}},$e=async()=>{if(!ue)try{ee(!0);const ae=await c();ge(ae),await r.refetch(),j(!0),x("New backup codes generated","info")}catch(ae){x(ae.message||"Failed to generate backup codes","error")}finally{ee(!1)}},Ie=()=>{const ae=re.join(`
4287
4289
  `);navigator.clipboard.writeText(ae).then(()=>{x("Backup codes copied to clipboard","info")}).catch(()=>{x("Failed to copy backup codes","error")})},Ge=()=>{const ae=re.join(`
4288
- `),De=new Blob([ae],{type:"text/plain"}),Ne=URL.createObjectURL(De),et=document.createElement("a");et.href=Ne,et.download="wacht-backup-codes.txt",et.click(),URL.revokeObjectURL(Ne),x("Backup codes downloaded","info")},no=async()=>{var ae,De;if((De=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.passkey)!=null&&De.enabled)try{L(!0);const Ne=await d();N(Ne.data||[])}catch(Ne){console.error("Failed to load passkeys:",Ne)}finally{L(!1)}},Bd=async ae=>{try{A(!0),await p(ae||void 0),await no(),x("Passkey registered successfully!","info")}catch(De){throw x(De.message||"Failed to register passkey","error"),De}finally{A(!1)}},Ud=async ae=>{try{await m(ae),await no(),x("Passkey removed","info")}catch(De){x(De.message||"Failed to remove passkey","error")}};i.useEffect(()=>{no()},[(ta=(ea=t==null?void 0:t.auth_settings)==null?void 0:ea.passkey)==null?void 0:ta.enabled]);const Lt=[];return Se&&Lt.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),(oa=(ra=t==null?void 0:t.auth_settings)==null?void 0:ra.passkey)!=null&&oa.enabled&&Lt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:O.length>0?`${O.length} registered`:"",actions:O.length>0?["manage","add"]:["add"]}),Ce!=null&&Ce.authenticator&&Lt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&Lt.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),r!=null&&r.user_authenticator&&Lt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),te!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(tn,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[te==="qr"&&"Setup Two-Factor Authentication",te==="verify"&&"Verify Your Authenticator",te==="backup"&&"Save Your Backup Codes",te==="success"&&"Setup Complete!"]})]}),e.jsx(J,{onClick:()=>ce("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[te==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:ne?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${c1} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):Q?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Zs,{value:Q,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:xe||"Loading..."})]}),e.jsx(J,{onClick:()=>ce("verify"),disabled:!Q||!xe,style:{padding:"10px 20px",background:!Q||!xe?"var(--color-border)":"var(--color-primary)",color:!Q||!xe?"var(--color-secondary-text)":"white",border:`1px solid ${!Q||!xe?"var(--color-border)":"var(--color-primary)"}`,cursor:!Q||!xe?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),te==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(se,{type:"text",placeholder:"000000",value:K[0],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([De,K[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(se,{type:"text",placeholder:"000000",value:K[1],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([K[0],De])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(J,{onClick:()=>ce("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(J,{onClick:ve,disabled:V||K.some(ae=>ae.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:V?"Verifying...":"Verify & Continue"})]})]}),te==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(jt,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:re.map((ae,De)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(ae),children:ae},De))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(J,{onClick:Ie,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(J,{onClick:Ge,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(pn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(J,{onClick:pe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),te==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(tt,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(J,{onClick:pe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),Lt.length?e.jsx("div",{children:Lt.map((ae,De)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:ae.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:ae.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[ae.status&&ae.id!=="passkey"&&e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:ae.status}),e.jsxs("div",{style:{position:"relative"},children:[ae.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:R,onClick:()=>y(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve})]}),Ae()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:M,onClick:()=>_(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),g&&e.jsx(Bv,{triggerRef:M,onClose:()=>_(!1),onRemovePassword:Le})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:R,onClick:()=>y(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve,isSetup:!0})]})}),ae.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:T,onClick:()=>z(!0),disabled:ne,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:ne?"Setting up...":"Setup"}),C&&e.jsx(Rv,{triggerRef:T,onClose:()=>z(!1),onSetupTOTP:async()=>{const Ne=await s();return le(Ne.id),Ne},onVerifyTOTP:async Ne=>{await a(U,Ne),await r.refetch(),x("Two-factor authentication enabled successfully!","info")}})]})}),ae.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>$(!0),disabled:be,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:be?"not-allowed":"pointer",opacity:be?.6:1},children:be?"Removing...":"Remove"}),k&&e.jsx(Mr,{title:"Remove MFA and reset policy to default?",onConfirm:ye,onCancel:()=>$(!1)})]}),ae.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:I,onClick:$e,disabled:ue,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:ue?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),E&&e.jsx(Yv,{triggerRef:I,codes:re,onClose:()=>j(!1),onCopy:Ie,onDownload:Ge})]})}),ae.id==="second_factor_policy"&&e.jsx(mr,{checked:v==="enforced",onChange:Ne=>{S(Ne?"enforced":"none")}}),ae.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(J,{onClick:()=>Y(!q),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"auto",height:"auto"},children:[q?"Hide":"Manage"," (",O.length,")",e.jsx(Ut,{size:14,style:{transform:q?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:oe,onClick:()=>H(!0),disabled:P,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:P?"not-allowed":"pointer",opacity:P?.7:1,whiteSpace:"nowrap",width:"auto",height:"auto"},children:P?"Registering...":"Add"}),B&&e.jsx(e1,{triggerRef:oe,onClose:()=>H(!1),onAddPasskey:Bd})]})]})]})]})]}),ae.id==="passkey"&&q&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:D?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Re,{})}):O.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:O.map(Ne=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:Ne.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Ne.device_type==="platform"?"This device":"Security key",Ne.last_used_at&&` • Last used ${new Date(Ne.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>X(Ne.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),G===Ne.id&&e.jsx(Mr,{title:`Remove "${Ne.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Ud(Ne.id),X(null)},onCancel:()=>X(null)})]})]},Ne.id))})}),De<Lt.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},ae.id))}):e.jsx(xt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},y1=()=>{var D,L;const{deployment:t}=we(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=Gt(),{toast:a}=Yt(),[h,f]=i.useState(""),[c,u]=i.useState(""),[d,p]=i.useState(""),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(!1),[S,C]=i.useState(""),[z,w]=i.useState((r==null?void 0:r.profile_picture_url)||null),y=i.useRef(null);i.useEffect(()=>{r&&!m&&(f(r.first_name||""),u(r.last_name||""),p(r.username||""),w(r.profile_picture_url||null),x(!0))},[r,m]);const g=i.useCallback(async()=>{if(r)try{const P={};h!==r.first_name&&(P.first_name=h),c!==r.last_name&&(P.last_name=c),d!==r.username&&(P.username=d),Object.keys(P).length>0&&await o(P)}catch(P){a(P.message||"Failed to save profile changes","error")}},[r,o,h,c,d,a]),_=P=>{f(P.target.value)},E=P=>{u(P.target.value)},j=P=>{p(P.target.value)},T=()=>{g()},R=()=>{g()},M=()=>{g()},I=P=>{var A;if((A=P.target.files)!=null&&A[0]){const q=P.target.files[0];w(URL.createObjectURL(q)),setTimeout(async()=>{try{await n(q),r.refetch(),a("Profile picture updated successfully","info")}catch(Y){a(Y.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{y.current&&y.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const N=async()=>{if(!(!r||S!==r.username)){$(!0);try{await s(""),a("Account deleted successfully","info")}catch(P){a(P.message||"Failed to delete account","error")}finally{$(!1),C(""),b(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:z?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,onMouseEnter:P=>{P.currentTarget.style.borderColor="var(--color-primary)",P.currentTarget.style.transform="scale(1.02)"},onMouseLeave:P=>{P.currentTarget.style.borderColor="var(--color-border)",P.currentTarget.style.transform="scale(1)"},children:[z?e.jsx("img",{src:z,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ko,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:I})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var P;return(P=y.current)==null?void 0:P.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(pn,{size:14}),z?"Change":"Upload"]}),e.jsxs(J,{onClick:async()=>{w(null),y.current&&(y.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),a("Profile picture removed successfully","info")}catch(P){a(P.message||"Failed to remove profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(jt,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"firstName",children:"First Name"}),e.jsx(se,{id:"firstName",type:"text",value:h,onChange:_,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"lastName",children:"Last Name"}),e.jsx(se,{id:"lastName",type:"text",value:c,onChange:E,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((L=(D=t==null?void 0:t.auth_settings)==null?void 0:D.username)==null?void 0:L.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{id:"username",type:"text",value:d,onChange:j,onBlur:M,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:v?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(J,{onClick:()=>{v?(b(!1),C("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(se,{id:"confirm_username",type:"text",value:S,onChange:P=>C(P.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(J,{onClick:N,disabled:S!==(r==null?void 0:r.username)||k,style:{background:S===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:S===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:S===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:S===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:k?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Id=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(Pd,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),w1=l.div`
4290
+ `),De=new Blob([ae],{type:"text/plain"}),Ne=URL.createObjectURL(De),et=document.createElement("a");et.href=Ne,et.download="wacht-backup-codes.txt",et.click(),URL.revokeObjectURL(Ne),x("Backup codes downloaded","info")},no=async()=>{var ae,De;if((De=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.passkey)!=null&&De.enabled)try{L(!0);const Ne=await d();N(Ne.data||[])}catch(Ne){console.error("Failed to load passkeys:",Ne)}finally{L(!1)}},Bd=async ae=>{try{A(!0),await p(ae||void 0),await no(),x("Passkey registered successfully!","info")}catch(De){throw x(De.message||"Failed to register passkey","error"),De}finally{A(!1)}},Ud=async ae=>{try{await m(ae),await no(),x("Passkey removed","info")}catch(De){x(De.message||"Failed to remove passkey","error")}};i.useEffect(()=>{no()},[(ta=(ea=t==null?void 0:t.auth_settings)==null?void 0:ea.passkey)==null?void 0:ta.enabled]);const Lt=[];return Se&&Lt.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),(oa=(ra=t==null?void 0:t.auth_settings)==null?void 0:ra.passkey)!=null&&oa.enabled&&Lt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:O.length>0?`${O.length} registered`:"",actions:O.length>0?["manage","add"]:["add"]}),Ce!=null&&Ce.authenticator&&Lt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&Lt.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),r!=null&&r.user_authenticator&&Lt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),te!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(tn,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[te==="qr"&&"Setup Two-Factor Authentication",te==="verify"&&"Verify Your Authenticator",te==="backup"&&"Save Your Backup Codes",te==="success"&&"Setup Complete!"]})]}),e.jsx(J,{onClick:()=>ce("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[te==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:ne?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${l1} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):Q?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Zs,{value:Q,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:xe||"Loading..."})]}),e.jsx(J,{onClick:()=>ce("verify"),disabled:!Q||!xe,style:{padding:"10px 20px",background:!Q||!xe?"var(--color-border)":"var(--color-primary)",color:!Q||!xe?"var(--color-secondary-text)":"white",border:`1px solid ${!Q||!xe?"var(--color-border)":"var(--color-primary)"}`,cursor:!Q||!xe?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),te==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(se,{type:"text",placeholder:"000000",value:K[0],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([De,K[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(se,{type:"text",placeholder:"000000",value:K[1],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([K[0],De])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(J,{onClick:()=>ce("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(J,{onClick:ve,disabled:V||K.some(ae=>ae.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:V?"Verifying...":"Verify & Continue"})]})]}),te==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(jt,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:re.map((ae,De)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(ae),children:ae},De))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(J,{onClick:Ie,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(J,{onClick:Ge,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(pn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(J,{onClick:pe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),te==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(tt,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(J,{onClick:pe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),Lt.length?e.jsx("div",{children:Lt.map((ae,De)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:ae.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:ae.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[ae.status&&ae.id!=="passkey"&&e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:ae.status}),e.jsxs("div",{style:{position:"relative"},children:[ae.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:R,onClick:()=>y(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve})]}),Ae()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:M,onClick:()=>_(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),g&&e.jsx(Uv,{triggerRef:M,onClose:()=>_(!1),onRemovePassword:Le})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:R,onClick:()=>y(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve,isSetup:!0})]})}),ae.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:T,onClick:()=>z(!0),disabled:ne,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:ne?"Setting up...":"Setup"}),C&&e.jsx(Tv,{triggerRef:T,onClose:()=>z(!1),onSetupTOTP:async()=>{const Ne=await s();return le(Ne.id),Ne},onVerifyTOTP:async Ne=>{await a(U,Ne),await r.refetch(),x("Two-factor authentication enabled successfully!","info")}})]})}),ae.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>$(!0),disabled:be,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:be?"not-allowed":"pointer",opacity:be?.6:1},children:be?"Removing...":"Remove"}),k&&e.jsx(Mr,{title:"Remove MFA and reset policy to default?",onConfirm:ye,onCancel:()=>$(!1)})]}),ae.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:I,onClick:$e,disabled:ue,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:ue?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),E&&e.jsx(Zv,{triggerRef:I,codes:re,onClose:()=>j(!1),onCopy:Ie,onDownload:Ge})]})}),ae.id==="second_factor_policy"&&e.jsx(mr,{checked:v==="enforced",onChange:Ne=>{S(Ne?"enforced":"none")}}),ae.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(J,{onClick:()=>Y(!q),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"auto",height:"auto"},children:[q?"Hide":"Manage"," (",O.length,")",e.jsx(Ut,{size:14,style:{transform:q?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:oe,onClick:()=>H(!0),disabled:P,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:P?"not-allowed":"pointer",opacity:P?.7:1,whiteSpace:"nowrap",width:"auto",height:"auto"},children:P?"Registering...":"Add"}),B&&e.jsx(t1,{triggerRef:oe,onClose:()=>H(!1),onAddPasskey:Bd})]})]})]})]})]}),ae.id==="passkey"&&q&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:D?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Re,{})}):O.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:O.map(Ne=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:Ne.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Ne.device_type==="platform"?"This device":"Security key",Ne.last_used_at&&` • Last used ${new Date(Ne.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>X(Ne.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),G===Ne.id&&e.jsx(Mr,{title:`Remove "${Ne.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Ud(Ne.id),X(null)},onCancel:()=>X(null)})]})]},Ne.id))})}),De<Lt.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},ae.id))}):e.jsx(xt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},w1=()=>{var D,L;const{deployment:t}=we(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=Gt(),{toast:a}=Yt(),[h,f]=i.useState(""),[c,u]=i.useState(""),[d,p]=i.useState(""),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(!1),[S,C]=i.useState(""),[z,w]=i.useState((r==null?void 0:r.profile_picture_url)||null),y=i.useRef(null);i.useEffect(()=>{r&&!m&&(f(r.first_name||""),u(r.last_name||""),p(r.username||""),w(r.profile_picture_url||null),x(!0))},[r,m]);const g=i.useCallback(async()=>{if(r)try{const P={};h!==r.first_name&&(P.first_name=h),c!==r.last_name&&(P.last_name=c),d!==r.username&&(P.username=d),Object.keys(P).length>0&&await o(P)}catch(P){a(P.message||"Failed to save profile changes","error")}},[r,o,h,c,d,a]),_=P=>{f(P.target.value)},E=P=>{u(P.target.value)},j=P=>{p(P.target.value)},T=()=>{g()},R=()=>{g()},M=()=>{g()},I=P=>{var A;if((A=P.target.files)!=null&&A[0]){const q=P.target.files[0];w(URL.createObjectURL(q)),setTimeout(async()=>{try{await n(q),r.refetch(),a("Profile picture updated successfully","info")}catch(Y){a(Y.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{y.current&&y.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const N=async()=>{if(!(!r||S!==r.username)){$(!0);try{await s(""),a("Account deleted successfully","info")}catch(P){a(P.message||"Failed to delete account","error")}finally{$(!1),C(""),b(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:z?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,onMouseEnter:P=>{P.currentTarget.style.borderColor="var(--color-primary)",P.currentTarget.style.transform="scale(1.02)"},onMouseLeave:P=>{P.currentTarget.style.borderColor="var(--color-border)",P.currentTarget.style.transform="scale(1)"},children:[z?e.jsx("img",{src:z,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ko,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:I})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var P;return(P=y.current)==null?void 0:P.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(pn,{size:14}),z?"Change":"Upload"]}),e.jsxs(J,{onClick:async()=>{w(null),y.current&&(y.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),a("Profile picture removed successfully","info")}catch(P){a(P.message||"Failed to remove profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(jt,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"firstName",children:"First Name"}),e.jsx(se,{id:"firstName",type:"text",value:h,onChange:_,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"lastName",children:"Last Name"}),e.jsx(se,{id:"lastName",type:"text",value:c,onChange:E,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((L=(D=t==null?void 0:t.auth_settings)==null?void 0:D.username)==null?void 0:L.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{id:"username",type:"text",value:d,onChange:j,onBlur:M,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:v?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(J,{onClick:()=>{v?(b(!1),C("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(se,{id:"confirm_username",type:"text",value:S,onChange:P=>C(P.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(J,{onClick:N,disabled:S!==(r==null?void 0:r.username)||k,style:{background:S===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:S===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:S===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:S===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:k?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Id=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(Pd,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),j1=l.div`
4289
4291
  position: relative;
4290
- `,j1=l.button`
4292
+ `,k1=l.button`
4291
4293
  display: flex;
4292
4294
  align-items: center;
4293
4295
  gap: 12px;
@@ -4317,7 +4319,7 @@ cursor: pointer;
4317
4319
  height: 100%;
4318
4320
  object-fit: cover;
4319
4321
  }
4320
- `,k1=l.div`
4322
+ `,_1=l.div`
4321
4323
  font-size: 14px;
4322
4324
  font-weight: 400;
4323
4325
  color: var(--color-foreground);
@@ -4328,7 +4330,7 @@ cursor: pointer;
4328
4330
  `,ec=l.span`
4329
4331
  font-size: 12px;
4330
4332
  color: var(--color-secondary-text);
4331
- `,_1=l.div`
4333
+ `,C1=l.div`
4332
4334
  position: fixed;
4333
4335
  ${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
4334
4336
  ${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
@@ -4424,7 +4426,7 @@ cursor: pointer;
4424
4426
  width: 14px;
4425
4427
  height: 14px;
4426
4428
  }
4427
- `,Ks=({showName:t=!0})=>{var y,g,_,E;const[r,o]=i.useState(!1),n=i.useRef(null),s=i.useRef(null),a=dd({triggerRef:n,isOpen:r,minWidth:380}),h=Zr(!1),{session:f,signOut:c,switchSignIn:u,refetch:d}=Qe(),{navigateToSignIn:p}=rt(),{deployment:m}=we(),x=(y=f==null?void 0:f.active_signin)==null?void 0:y.user,v=((_=(g=m==null?void 0:m.auth_settings)==null?void 0:g.multi_session_support)==null?void 0:_.enabled)??!1,b=(((E=f==null?void 0:f.signins)==null?void 0:E.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=R=>{var I,O;const M=R.target;(I=n.current)!=null&&I.contains(M)||(O=s.current)!=null&&O.contains(M)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const k=()=>{o(!r)},$=j=>j.split(" ").map(T=>T[0]).join("").toUpperCase(),S=async j=>{try{await c(j),await d(),o(!1)}catch{}},C=async()=>{try{await c(),await d(),o(!1)}catch{}},z=async j=>{try{await u(j),await d(),o(!1)}catch{}},w=()=>{h.open(),o(!1)};return e.jsx(fe,{children:e.jsxs(w1,{children:[e.jsxs(j1,{ref:n,onClick:k,children:[e.jsx(ss,{children:e.jsx(Rd,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(k1,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&eo.createPortal(e.jsx(fe,{children:e.jsx(_1,{ref:s,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const j=[...(f==null?void 0:f.signins)||[]].sort((T,R)=>{const M=T.user.id===(x==null?void 0:x.id),I=R.user.id===(x==null?void 0:x.id);return M&&!I?-1:!M&&I?1:0});return j.map(({user:T,id:R},M)=>{const I=T.id===(x==null?void 0:x.id),O=!I;return e.jsxs(i.Fragment,{children:[e.jsxs(tc,{$isClickable:O,onClick:O?()=>z(R):void 0,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):$(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(ec,{children:T.primary_email_address.email})]})]}),I&&e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>S(R),children:[e.jsx(Ft,{}),"Sign out"]})]})]}),M===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():x&&e.jsxs(tc,{$isClickable:!1,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(ec,{children:x.primary_email_address.email})]})]}),e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>{var j;return S(((j=f==null?void 0:f.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Ft,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(ic,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(cc,{onClick:()=>p(),children:[e.jsx(it,{}),"Add new account"]})}),b&&e.jsx(ic,{children:e.jsxs(cc,{onClick:C,children:[e.jsx(Ft,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Id,{isOpen:h.isOpen,onClose:h.close})]})})},C1=l.div`
4429
+ `,Ks=({showName:t=!0})=>{var y,g,_,E;const[r,o]=i.useState(!1),n=i.useRef(null),s=i.useRef(null),a=dd({triggerRef:n,isOpen:r,minWidth:380}),h=Zr(!1),{session:f,signOut:c,switchSignIn:u,refetch:d}=Qe(),{navigateToSignIn:p}=rt(),{deployment:m}=we(),x=(y=f==null?void 0:f.active_signin)==null?void 0:y.user,v=((_=(g=m==null?void 0:m.auth_settings)==null?void 0:g.multi_session_support)==null?void 0:_.enabled)??!1,b=(((E=f==null?void 0:f.signins)==null?void 0:E.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=R=>{var I,O;const M=R.target;(I=n.current)!=null&&I.contains(M)||(O=s.current)!=null&&O.contains(M)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const k=()=>{o(!r)},$=j=>j.split(" ").map(T=>T[0]).join("").toUpperCase(),S=async j=>{try{await c(j),await d(),o(!1)}catch{}},C=async()=>{try{await c(),await d(),o(!1)}catch{}},z=async j=>{try{await u(j),await d(),o(!1)}catch{}},w=()=>{h.open(),o(!1)};return e.jsx(fe,{children:e.jsxs(j1,{children:[e.jsxs(k1,{ref:n,onClick:k,children:[e.jsx(ss,{children:e.jsx(Rd,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(_1,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&eo.createPortal(e.jsx(fe,{children:e.jsx(C1,{ref:s,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const j=[...(f==null?void 0:f.signins)||[]].sort((T,R)=>{const M=T.user.id===(x==null?void 0:x.id),I=R.user.id===(x==null?void 0:x.id);return M&&!I?-1:!M&&I?1:0});return j.map(({user:T,id:R},M)=>{const I=T.id===(x==null?void 0:x.id),O=!I;return e.jsxs(i.Fragment,{children:[e.jsxs(tc,{$isClickable:O,onClick:O?()=>z(R):void 0,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):$(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(ec,{children:T.primary_email_address.email})]})]}),I&&e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>S(R),children:[e.jsx(Ft,{}),"Sign out"]})]})]}),M===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():x&&e.jsxs(tc,{$isClickable:!1,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(ec,{children:x.primary_email_address.email})]})]}),e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>{var j;return S(((j=f==null?void 0:f.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Ft,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(ic,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(cc,{onClick:()=>p(),children:[e.jsx(it,{}),"Add new account"]})}),b&&e.jsx(ic,{children:e.jsxs(cc,{onClick:C,children:[e.jsx(Ft,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Id,{isOpen:h.isOpen,onClose:h.close})]})})},S1=l.div`
4428
4430
  padding: var(--space-md) var(--space-lg);
4429
4431
  background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
4430
4432
  transition: all 0.2s ease;
@@ -4439,49 +4441,49 @@ cursor: pointer;
4439
4441
  &:not(:last-child) {
4440
4442
  border-bottom: 1px solid var(--color-border);
4441
4443
  }
4442
- `,S1=l.div`
4444
+ `,$1=l.div`
4443
4445
  display: flex;
4444
4446
  align-items: flex-start;
4445
4447
  justify-content: space-between;
4446
4448
  gap: var(--space-sm);
4447
4449
  margin-bottom: var(--space-xs);
4448
- `,$1=l.div`
4450
+ `,z1=l.div`
4449
4451
  display: flex;
4450
4452
  align-items: center;
4451
4453
  flex: 1;
4452
4454
  gap: var(--space-xs);
4453
- `,z1=l.h4`
4455
+ `,E1=l.h4`
4454
4456
  font-size: var(--font-xs);
4455
4457
  font-weight: 400;
4456
4458
  color: var(--color-foreground);
4457
4459
  margin: 0;
4458
4460
  flex: 1;
4459
4461
  line-height: 1.4;
4460
- `,E1=l.span`
4462
+ `,P1=l.span`
4461
4463
  display: inline-block;
4462
4464
  width: 8px;
4463
4465
  height: 8px;
4464
4466
  border-radius: var(--radius-full);
4465
4467
  background: ${t=>{switch(t.$severity){case"success":return"var(--color-success)";case"warning":return"var(--color-warning)";case"error":return"var(--color-error)";default:return"var(--color-primary)"}}};
4466
4468
  flex-shrink: 0;
4467
- `,P1=l.p`
4469
+ `,I1=l.p`
4468
4470
  font-size: var(--font-2xs);
4469
4471
  color: var(--color-secondary-text);
4470
4472
  margin: 0 0 var(--space-sm) 0;
4471
4473
  line-height: 1.5;
4472
- `,I1=l.div`
4474
+ `,R1=l.div`
4473
4475
  display: flex;
4474
4476
  align-items: center;
4475
4477
  justify-content: space-between;
4476
4478
  gap: var(--space-sm);
4477
- `,R1=l.span`
4479
+ `,T1=l.span`
4478
4480
  font-size: var(--font-2xs);
4479
4481
  color: var(--color-muted);
4480
- `,T1=l.div`
4482
+ `,M1=l.div`
4481
4483
  display: flex;
4482
4484
  align-items: center;
4483
4485
  gap: var(--space-xs);
4484
- `,M1=l.button`
4486
+ `,O1=l.button`
4485
4487
  background: transparent;
4486
4488
  border: none;
4487
4489
  padding: var(--space-2xs);
@@ -4507,7 +4509,7 @@ cursor: pointer;
4507
4509
  width: 14px;
4508
4510
  height: 14px;
4509
4511
  }
4510
- `,O1=l.a`
4512
+ `,A1=l.a`
4511
4513
  display: inline-flex;
4512
4514
  align-items: center;
4513
4515
  gap: var(--space-2xs);
@@ -4533,7 +4535,7 @@ cursor: pointer;
4533
4535
  width: 12px;
4534
4536
  height: 12px;
4535
4537
  }
4536
- `;function Td({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=a=>{const h=new Date(a),c=new Date().getTime()-h.getTime(),u=Math.floor(c/1e3),d=Math.floor(u/60),p=Math.floor(d/60),m=Math.floor(p/24);return m>7?h.toLocaleDateString():m>0?`${m}d ago`:p>0?`${p}h ago`:d>0?`${d}m ago`:"Just now"};return e.jsxs(C1,{$unread:!t.is_read,onClick:n,children:[e.jsxs(S1,{children:[e.jsxs($1,{children:[e.jsx(E1,{$severity:t.severity}),e.jsx(z1,{children:t.title})]}),e.jsx(M1,{onClick:a=>{a.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(lt,{})})]}),e.jsx(P1,{children:t.body}),e.jsxs(I1,{children:[e.jsx(R1,{children:s(t.created_at)}),t.action_url&&e.jsx(T1,{children:e.jsxs(O1,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),children:[t.action_label||"View",e.jsx(Ns,{})]})})]})]})}const A1=l.div`
4538
+ `;function Td({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=a=>{const h=new Date(a),c=new Date().getTime()-h.getTime(),u=Math.floor(c/1e3),d=Math.floor(u/60),p=Math.floor(d/60),m=Math.floor(p/24);return m>7?h.toLocaleDateString():m>0?`${m}d ago`:p>0?`${p}h ago`:d>0?`${d}m ago`:"Just now"};return e.jsxs(S1,{$unread:!t.is_read,onClick:n,children:[e.jsxs($1,{children:[e.jsxs(z1,{children:[e.jsx(P1,{$severity:t.severity}),e.jsx(E1,{children:t.title})]}),e.jsx(O1,{onClick:a=>{a.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(lt,{})})]}),e.jsx(I1,{children:t.body}),e.jsxs(R1,{children:[e.jsx(T1,{children:s(t.created_at)}),t.action_url&&e.jsx(M1,{children:e.jsxs(A1,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),children:[t.action_label||"View",e.jsx(Ns,{})]})})]})]})}const L1=l.div`
4537
4539
  position: fixed;
4538
4540
  ${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
4539
4541
  ${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
@@ -4554,19 +4556,19 @@ cursor: pointer;
4554
4556
  width: 320px;
4555
4557
  max-height: 500px;
4556
4558
  }
4557
- `,L1=l.div`
4559
+ `,D1=l.div`
4558
4560
  padding: 10px 16px;
4559
4561
  border-bottom: 1px solid var(--color-border);
4560
4562
  display: flex;
4561
4563
  align-items: center;
4562
4564
  justify-content: space-between;
4563
4565
  background: var(--color-background);
4564
- `,D1=l.h3`
4566
+ `,N1=l.h3`
4565
4567
  font-size: 14px;
4566
4568
  font-weight: 400;
4567
4569
  color: var(--color-foreground);
4568
4570
  margin: 0;
4569
- `,N1=l.button`
4571
+ `,F1=l.button`
4570
4572
  background: transparent;
4571
4573
  border: none;
4572
4574
  color: var(--color-primary);
@@ -4586,23 +4588,23 @@ cursor: pointer;
4586
4588
  outline: none;
4587
4589
  box-shadow: 0 0 0 2px var(--color-primary);
4588
4590
  }
4589
- `,F1=l.div`
4591
+ `,B1=l.div`
4590
4592
  flex: 1;
4591
4593
  overflow-y: auto;
4592
4594
  max-height: 450px;
4593
- `,B1=l.div`
4595
+ `,U1=l.div`
4594
4596
  display: flex;
4595
4597
  align-items: center;
4596
4598
  justify-content: center;
4597
4599
  padding: 32px;
4598
- `,U1=l.div`
4600
+ `,W1=l.div`
4599
4601
  padding: 40px 16px;
4600
4602
  display: flex;
4601
4603
  flex-direction: column;
4602
4604
  align-items: center;
4603
4605
  justify-content: center;
4604
4606
  text-align: center;
4605
- `,W1=l.div`
4607
+ `,V1=l.div`
4606
4608
  width: 40px;
4607
4609
  height: 40px;
4608
4610
  border-radius: 50%;
@@ -4618,22 +4620,22 @@ cursor: pointer;
4618
4620
  color: var(--color-secondary-text);
4619
4621
  opacity: 0.6;
4620
4622
  }
4621
- `,V1=l.h3`
4623
+ `,G1=l.h3`
4622
4624
  font-size: 14px;
4623
4625
  font-weight: 400;
4624
4626
  color: var(--color-foreground);
4625
4627
  margin: 0 0 4px 0;
4626
- `,G1=l.p`
4628
+ `,H1=l.p`
4627
4629
  font-size: var(--font-xs);
4628
4630
  color: var(--color-secondary-text);
4629
4631
  margin: 0;
4630
4632
  line-height: 1.4;
4631
- `,H1=l.div`
4633
+ `,q1=l.div`
4632
4634
  padding: 8px 16px;
4633
4635
  border-top: 1px solid var(--color-border);
4634
4636
  background: var(--color-background);
4635
4637
  text-align: center;
4636
- `,q1=l.a`
4638
+ `,Y1=l.a`
4637
4639
  color: var(--color-primary);
4638
4640
  font-size: var(--font-xs);
4639
4641
  font-weight: 400;
@@ -4644,9 +4646,9 @@ cursor: pointer;
4644
4646
  color: var(--color-primary-hover);
4645
4647
  text-decoration: underline;
4646
4648
  }
4647
- `,Md=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:a},h)=>{const f=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(A1,{ref:h,$position:t,children:[e.jsxs(L1,{children:[e.jsx(D1,{children:"Notifications"}),f&&e.jsx(N1,{onClick:s,children:"Mark all as read"})]}),e.jsx(F1,{children:o?e.jsx(B1,{children:e.jsx(Re,{})}):r.length===0?e.jsxs(U1,{children:[e.jsx(W1,{children:e.jsx(hh,{})}),e.jsx(V1,{children:"No notifications"}),e.jsx(G1,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(Td,{notification:c,onMarkAsRead:n,onDelete:a},c.id))}),!o&&r.length>0&&e.jsx(H1,{children:e.jsx(q1,{href:"/notifications",children:"View all notifications"})})]})}),Y1=l.div`
4649
+ `,Md=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:a},h)=>{const f=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(L1,{ref:h,$position:t,children:[e.jsxs(D1,{children:[e.jsx(N1,{children:"Notifications"}),f&&e.jsx(F1,{onClick:s,children:"Mark all as read"})]}),e.jsx(B1,{children:o?e.jsx(U1,{children:e.jsx(Re,{})}):r.length===0?e.jsxs(W1,{children:[e.jsx(V1,{children:e.jsx(hh,{})}),e.jsx(G1,{children:"No notifications"}),e.jsx(H1,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(Td,{notification:c,onMarkAsRead:n,onDelete:a},c.id))}),!o&&r.length>0&&e.jsx(q1,{children:e.jsx(Y1,{href:"/notifications",children:"View all notifications"})})]})}),Z1=l.div`
4648
4650
  position: relative;
4649
- `,Z1=l.div`
4651
+ `,K1=l.div`
4650
4652
  width: 40px;
4651
4653
  height: 40px;
4652
4654
  border-radius: 50%;
@@ -4661,7 +4663,7 @@ cursor: pointer;
4661
4663
  background: var(--color-background-hover);
4662
4664
  border-color: var(--color-primary);
4663
4665
  }
4664
- `,K1=l.button`
4666
+ `,Q1=l.button`
4665
4667
  position: relative;
4666
4668
  display: flex;
4667
4669
  align-items: center;
@@ -4690,7 +4692,7 @@ cursor: pointer;
4690
4692
  &:hover svg {
4691
4693
  color: var(--color-primary);
4692
4694
  }
4693
- `,Q1=l.span`
4695
+ `,X1=l.span`
4694
4696
  position: absolute;
4695
4697
  top: -2px;
4696
4698
  right: -2px;
@@ -4707,18 +4709,18 @@ cursor: pointer;
4707
4709
  justify-content: center;
4708
4710
  border: 2px solid var(--color-background);
4709
4711
  box-shadow: 0 1px 3px var(--color-shadow);
4710
- `;function Od({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[a,h]=i.useState(!1),[f,c]=i.useState(),u=i.useRef(null),d=i.useRef(null),p={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:m,notifications:x,loading:v,markAsRead:b,markAllAsRead:k,deleteNotification:$}=Qc(p);return i.useEffect(()=>{if(!a)return;const S=setTimeout(()=>{const C=z=>{var y,g;const w=z.target;(y=u.current)!=null&&y.contains(w)||(g=d.current)!=null&&g.contains(w)||h(!1)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},50);return()=>{clearTimeout(S)}},[a]),i.useEffect(()=>{if(a&&u.current){const S=u.current.getBoundingClientRect(),C=400,z=600,w=window.innerWidth,y=window.innerHeight,g=w-S.left,_=y-S.bottom,E=S.top;let j,T;g>=C?j=S.left:T=w-S.right;let R,M;_>=z+8?R=S.bottom+8:E>=z+8?M=y-S.top+8:R=S.bottom+8,c({top:R,bottom:M,left:j,right:T})}else c(void 0)},[a]),e.jsx(fe,{children:e.jsxs(Y1,{ref:u,className:t,children:[e.jsx(Z1,{children:e.jsxs(K1,{onClick:()=>h(!a),children:[e.jsx(gh,{size:16}),r&&m>0&&e.jsx(Q1,{children:m>9?"9+":m})]})}),typeof window<"u"&&a&&eo.createPortal(e.jsx(fe,{children:e.jsx(Md,{ref:d,position:f,notifications:x,loading:v,onMarkAsRead:b,onMarkAllAsRead:k,onDelete:$})}),document.body)]})})}const X1=l.div`
4712
+ `;function Od({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[a,h]=i.useState(!1),[f,c]=i.useState(),u=i.useRef(null),d=i.useRef(null),p={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:m,notifications:x,loading:v,markAsRead:b,markAllAsRead:k,deleteNotification:$}=Qc(p);return i.useEffect(()=>{if(!a)return;const S=setTimeout(()=>{const C=z=>{var y,g;const w=z.target;(y=u.current)!=null&&y.contains(w)||(g=d.current)!=null&&g.contains(w)||h(!1)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},50);return()=>{clearTimeout(S)}},[a]),i.useEffect(()=>{if(a&&u.current){const S=u.current.getBoundingClientRect(),C=400,z=600,w=window.innerWidth,y=window.innerHeight,g=w-S.left,_=y-S.bottom,E=S.top;let j,T;g>=C?j=S.left:T=w-S.right;let R,M;_>=z+8?R=S.bottom+8:E>=z+8?M=y-S.top+8:R=S.bottom+8,c({top:R,bottom:M,left:j,right:T})}else c(void 0)},[a]),e.jsx(fe,{children:e.jsxs(Z1,{ref:u,className:t,children:[e.jsx(K1,{children:e.jsxs(Q1,{onClick:()=>h(!a),children:[e.jsx(gh,{size:16}),r&&m>0&&e.jsx(X1,{children:m>9?"9+":m})]})}),typeof window<"u"&&a&&eo.createPortal(e.jsx(fe,{children:e.jsx(Md,{ref:d,position:f,notifications:x,loading:v,onMarkAsRead:b,onMarkAllAsRead:k,onDelete:$})}),document.body)]})})}const J1=l.div`
4711
4713
  display: flex;
4712
4714
  align-items: center;
4713
4715
  gap: 8px;
4714
- `,J1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(X1,{children:[r&&e.jsx(Od,{}),e.jsx(Ks,{showName:t})]}),eb=({children:t})=>{var a;const{session:r,loading:o}=Qe(),{deployment:n}=we(),{navigateToAccountSelection:s}=rt();return i.useEffect(()=>{var h;o||(h=r==null?void 0:r.signins)!=null&&h.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((a=r.signins)!=null&&a.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},tb=({children:t})=>{var n;const{loading:r,session:o}=Qe();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},Ad=Ht`
4716
+ `,eb=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(J1,{children:[r&&e.jsx(Od,{}),e.jsx(Ks,{showName:t})]}),tb=({children:t})=>{var a;const{session:r,loading:o}=Qe(),{deployment:n}=we(),{navigateToAccountSelection:s}=rt();return i.useEffect(()=>{var h;o||(h=r==null?void 0:r.signins)!=null&&h.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((a=r.signins)!=null&&a.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},rb=({children:t})=>{var n;const{loading:r,session:o}=Qe();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},Ad=Ht`
4715
4717
  0% {
4716
4718
  background-position: -1000px 0;
4717
4719
  }
4718
4720
  100% {
4719
4721
  background-position: 1000px 0;
4720
4722
  }
4721
- `,rb=Ht`
4723
+ `,ob=Ht`
4722
4724
  from {
4723
4725
  transform: rotate(0deg);
4724
4726
  }
@@ -4749,7 +4751,7 @@ cursor: pointer;
4749
4751
  `,hc=l.p`
4750
4752
  color: var(--color-secondary-text);
4751
4753
  font-size: var(--font-xs);
4752
- `,ob=l.div`
4754
+ `,nb=l.div`
4753
4755
  display: flex;
4754
4756
  align-items: center;
4755
4757
  gap: var(--space-md);
@@ -4802,7 +4804,7 @@ cursor: pointer;
4802
4804
  50% { opacity: 0.5; }
4803
4805
  }
4804
4806
  `}
4805
- `,nb=l.div`
4807
+ `,sb=l.div`
4806
4808
  width: 40px;
4807
4809
  height: 40px;
4808
4810
  border-radius: 50%;
@@ -4821,10 +4823,10 @@ cursor: pointer;
4821
4823
  height: 100%;
4822
4824
  object-fit: cover;
4823
4825
  }
4824
- `,sb=l.div`
4826
+ `,ab=l.div`
4825
4827
  flex: 1;
4826
4828
  min-width: 0;
4827
- `,ab=l.div`
4829
+ `,ib=l.div`
4828
4830
  font-size: var(--font-sm);
4829
4831
  font-weight: 400;
4830
4832
  color: var(--color-foreground);
@@ -4832,13 +4834,13 @@ cursor: pointer;
4832
4834
  white-space: nowrap;
4833
4835
  overflow: hidden;
4834
4836
  text-overflow: ellipsis;
4835
- `,ib=l.div`
4837
+ `,cb=l.div`
4836
4838
  font-size: var(--font-xs);
4837
4839
  color: var(--color-secondary-text);
4838
4840
  white-space: nowrap;
4839
4841
  overflow: hidden;
4840
4842
  text-overflow: ellipsis;
4841
- `,cb=l.button`
4843
+ `,lb=l.button`
4842
4844
  display: flex;
4843
4845
  align-items: center;
4844
4846
  gap: var(--space-xs);
@@ -4858,10 +4860,10 @@ cursor: pointer;
4858
4860
  }
4859
4861
 
4860
4862
  svg {
4861
- animation: ${t=>t.$isLoading?rb:"none"} 1s linear
4863
+ animation: ${t=>t.$isLoading?ob:"none"} 1s linear
4862
4864
  infinite;
4863
4865
  }
4864
- `,lb=l.button`
4866
+ `,db=l.button`
4865
4867
  display: flex;
4866
4868
  align-items: center;
4867
4869
  justify-content: center;
@@ -4886,7 +4888,7 @@ cursor: pointer;
4886
4888
  width: 16px;
4887
4889
  height: 16px;
4888
4890
  }
4889
- `,db=l.div`
4891
+ `,ub=l.div`
4890
4892
  display: flex;
4891
4893
  align-items: center;
4892
4894
  gap: var(--space-md);
@@ -4896,7 +4898,7 @@ cursor: pointer;
4896
4898
  &:last-child {
4897
4899
  border-bottom: none;
4898
4900
  }
4899
- `,ub=l.div`
4901
+ `,pb=l.div`
4900
4902
  width: 40px;
4901
4903
  height: 40px;
4902
4904
  border-radius: 50%;
@@ -4908,7 +4910,7 @@ cursor: pointer;
4908
4910
  );
4909
4911
  background-size: 1000px 100%;
4910
4912
  animation: ${Ad} 2s infinite linear;
4911
- `,pb=l.div`
4913
+ `,hb=l.div`
4912
4914
  flex: 1;
4913
4915
  display: flex;
4914
4916
  flex-direction: column;
@@ -4925,12 +4927,12 @@ cursor: pointer;
4925
4927
  );
4926
4928
  background-size: 1000px 100%;
4927
4929
  animation: ${Ad} 2s infinite linear;
4928
- `,hb=l.p`
4930
+ `,fb=l.p`
4929
4931
  margin-top: var(--space-lg);
4930
4932
  text-align: center;
4931
4933
  font-size: var(--font-xs);
4932
4934
  color: var(--color-secondary-text);
4933
- `,fb=l.span`
4935
+ `,gb=l.span`
4934
4936
  color: var(--color-primary);
4935
4937
  text-decoration: none;
4936
4938
  font-weight: 400;
@@ -4940,7 +4942,7 @@ cursor: pointer;
4940
4942
  &:hover {
4941
4943
  color: var(--color-primary-hover);
4942
4944
  }
4943
- `,gb=({onAccountSelect:t,showAddAccount:r=!0})=>{var z,w,y,g,_;const{session:o,loading:n,switchSignIn:s,signOut:a}=Qe(),{deployment:h}=we(),{navigateToSignIn:f,navigate:c}=rt(),[u,d]=i.useState(null),[p,m]=i.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[],b=((w=(z=h==null?void 0:h.auth_settings)==null?void 0:z.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||v.length||f()},[n,v,f]);const k=E=>E.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),$=async E=>{var j;if(!(E===(x==null?void 0:x.id)||p)){m(E);try{if(await s(E),t)t(E),m(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),T){let R;try{R=new URL(T)}catch{R=new URL(T,window.location.origin)}(h==null?void 0:h.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else m(null)}}catch(T){console.error("Failed to switch account:",T),m(null)}}},S=async(E,j)=>{E.stopPropagation(),d(j);try{await a(j)}catch(T){console.error("Failed to sign out:",T)}finally{d(null)}},C=()=>{var j;let E=new URLSearchParams(window.location.search).get("redirect_uri");E||(E=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),f(E)};return n?e.jsx(fe,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",((y=h==null?void 0:h.ui_settings)==null?void 0:y.app_name)||"App"]})]}),e.jsx(dc,{children:[1,2].map(E=>e.jsxs(db,{children:[e.jsx(ub,{}),e.jsxs(pb,{children:[e.jsx(fc,{}),e.jsx(fc,{$width:"small"})]})]},E))})]})}):v.length?e.jsx(fe,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",(g=h==null?void 0:h.ui_settings)==null?void 0:g.app_name]})]}),e.jsxs(dc,{children:[v.map(({user:E,id:j})=>{var I,O,N,D,L;if(!E)return null;const T=j===(x==null?void 0:x.id),R=p===j,M=`${E.first_name||""} ${E.last_name||""}`.trim();return e.jsxs(ob,{$isActive:T,$isSwitching:R,onClick:()=>$(j),children:[e.jsx(nb,{children:E.has_profile_picture?e.jsx("img",{src:E.profile_picture_url,alt:M}):k(M||((I=E.primary_email_address)==null?void 0:I.email)||((O=E.primary_phone_number)==null?void 0:O.phone_number)||E.username||"U")}),e.jsxs(sb,{children:[e.jsx(ab,{children:M||((N=E.primary_email_address)==null?void 0:N.email)||((D=E.primary_phone_number)==null?void 0:D.phone_number)||E.username||"User"}),e.jsx(ib,{children:((L=E.primary_email_address)==null?void 0:L.email)||E.username})]}),!R&&e.jsxs(cb,{onClick:P=>S(P,j),$isLoading:u===j,disabled:u===j,children:[u===j?e.jsx(yt,{size:12}):e.jsx(Ft,{size:12}),u===j?"Signing out...":"Sign out"]})]},j)}),r&&b&&e.jsxs(lb,{onClick:C,children:[e.jsx(it,{}),"Add another account"]})]}),e.jsxs(hb,{children:["Don't have an account?"," ",e.jsx(fb,{children:e.jsx(ht,{to:`${(_=h.ui_settings)==null?void 0:_.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},mb=()=>{const{navigateToSignIn:t}=rt();return i.useEffect(()=>{t()},[t]),null},xb=()=>{const{navigateToSignUp:t}=rt();return i.useEffect(()=>{t()},[t]),null},vb=l.div`
4945
+ `,mb=({onAccountSelect:t,showAddAccount:r=!0})=>{var z,w,y,g,_;const{session:o,loading:n,switchSignIn:s,signOut:a}=Qe(),{deployment:h}=we(),{navigateToSignIn:f,navigate:c}=rt(),[u,d]=i.useState(null),[p,m]=i.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[],b=((w=(z=h==null?void 0:h.auth_settings)==null?void 0:z.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||v.length||f()},[n,v,f]);const k=E=>E.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),$=async E=>{var j;if(!(E===(x==null?void 0:x.id)||p)){m(E);try{if(await s(E),t)t(E),m(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),T){let R;try{R=new URL(T)}catch{R=new URL(T,window.location.origin)}(h==null?void 0:h.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else m(null)}}catch(T){console.error("Failed to switch account:",T),m(null)}}},S=async(E,j)=>{E.stopPropagation(),d(j);try{await a(j)}catch(T){console.error("Failed to sign out:",T)}finally{d(null)}},C=()=>{var j;let E=new URLSearchParams(window.location.search).get("redirect_uri");E||(E=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),f(E)};return n?e.jsx(fe,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",((y=h==null?void 0:h.ui_settings)==null?void 0:y.app_name)||"App"]})]}),e.jsx(dc,{children:[1,2].map(E=>e.jsxs(ub,{children:[e.jsx(pb,{}),e.jsxs(hb,{children:[e.jsx(fc,{}),e.jsx(fc,{$width:"small"})]})]},E))})]})}):v.length?e.jsx(fe,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",(g=h==null?void 0:h.ui_settings)==null?void 0:g.app_name]})]}),e.jsxs(dc,{children:[v.map(({user:E,id:j})=>{var I,O,N,D,L;if(!E)return null;const T=j===(x==null?void 0:x.id),R=p===j,M=`${E.first_name||""} ${E.last_name||""}`.trim();return e.jsxs(nb,{$isActive:T,$isSwitching:R,onClick:()=>$(j),children:[e.jsx(sb,{children:E.has_profile_picture?e.jsx("img",{src:E.profile_picture_url,alt:M}):k(M||((I=E.primary_email_address)==null?void 0:I.email)||((O=E.primary_phone_number)==null?void 0:O.phone_number)||E.username||"U")}),e.jsxs(ab,{children:[e.jsx(ib,{children:M||((N=E.primary_email_address)==null?void 0:N.email)||((D=E.primary_phone_number)==null?void 0:D.phone_number)||E.username||"User"}),e.jsx(cb,{children:((L=E.primary_email_address)==null?void 0:L.email)||E.username})]}),!R&&e.jsxs(lb,{onClick:P=>S(P,j),$isLoading:u===j,disabled:u===j,children:[u===j?e.jsx(wt,{size:12}):e.jsx(Ft,{size:12}),u===j?"Signing out...":"Sign out"]})]},j)}),r&&b&&e.jsxs(db,{onClick:C,children:[e.jsx(it,{}),"Add another account"]})]}),e.jsxs(fb,{children:["Don't have an account?"," ",e.jsx(gb,{children:e.jsx(ht,{to:`${(_=h.ui_settings)==null?void 0:_.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},xb=()=>{const{navigateToSignIn:t}=rt();return i.useEffect(()=>{t()},[t]),null},vb=()=>{const{navigateToSignUp:t}=rt();return i.useEffect(()=>{t()},[t]),null},bb=l.div`
4944
4946
  width: 100%;
4945
4947
  height: 500px;
4946
4948
  background: var(--color-background);
@@ -4948,35 +4950,35 @@ cursor: pointer;
4948
4950
  grid-template-columns: 280px 1fr;
4949
4951
  border-radius: var(--radius-lg);
4950
4952
  overflow: hidden;
4951
- `,bb=l.div`
4953
+ `,yb=l.div`
4952
4954
  background: var(--color-background-hover);
4953
4955
  padding: 32px 24px;
4954
4956
  display: flex;
4955
4957
  flex-direction: column;
4956
4958
  justify-content: space-between;
4957
4959
  border-right: 1px solid var(--color-border);
4958
- `,yb=l.div`
4960
+ `,wb=l.div`
4959
4961
  padding: 32px 24px;
4960
4962
  display: flex;
4961
4963
  flex-direction: column;
4962
4964
  overflow: hidden;
4963
- `,wb=l.div`
4965
+ `,jb=l.div`
4964
4966
  flex: 1;
4965
4967
  display: flex;
4966
4968
  flex-direction: column;
4967
4969
  overflow: hidden;
4968
4970
  margin-bottom: 24px;
4969
- `,jb=l.div`
4971
+ `,kb=l.div`
4970
4972
  display: flex;
4971
4973
  align-items: center;
4972
4974
  justify-content: space-between;
4973
4975
  margin-bottom: 8px;
4974
- `,kb=l.h2`
4976
+ `,_b=l.h2`
4975
4977
  font-size: 14px;
4976
4978
  font-weight: 400;
4977
4979
  color: var(--color-secondary-text);
4978
4980
  margin: 0;
4979
- `,_b=l.button`
4981
+ `,Cb=l.button`
4980
4982
  display: flex;
4981
4983
  align-items: center;
4982
4984
  gap: 4px;
@@ -4997,24 +4999,24 @@ cursor: pointer;
4997
4999
  width: 14px;
4998
5000
  height: 14px;
4999
5001
  }
5000
- `,Cb=l.div`
5002
+ `,Sb=l.div`
5001
5003
  display: flex;
5002
5004
  flex-direction: column;
5003
5005
  align-items: flex-start;
5004
5006
  gap: 4px;
5005
5007
  flex: 1;
5006
- `,Sb=l.h1`
5008
+ `,$b=l.h1`
5007
5009
  font-size: 16px;
5008
5010
  font-weight: 400;
5009
5011
  color: var(--color-foreground);
5010
5012
  margin: 0;
5011
5013
  line-height: 1.2;
5012
- `,$b=l.p`
5014
+ `,zb=l.p`
5013
5015
  color: var(--color-secondary-text);
5014
5016
  font-size: var(--font-sm);
5015
5017
  margin: 0;
5016
5018
  font-weight: 400;
5017
- `,zb=l.div`
5019
+ `,Eb=l.div`
5018
5020
  flex: 1;
5019
5021
  overflow-y: auto;
5020
5022
  display: flex;
@@ -5148,15 +5150,15 @@ cursor: pointer;
5148
5150
  margin: 0 auto;
5149
5151
  padding: 6px 16px;
5150
5152
  font-size: 13px;
5151
- `,Eb=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=Ot(),{workspaces:n}=Wt(),{switchOrganization:s,switchWorkspace:a}=Qe(),{deployment:h}=we(),[f,c]=i.useState(null),[u,d]=i.useState("orgList"),[p,m]=i.useState(null),x=(h==null?void 0:h.b2b_settings.workspaces_enabled)??!1,v=(h==null?void 0:h.b2b_settings.allow_users_to_create_orgs)??!1,b=i.useRef(!1);i.useEffect(()=>{if(!(b.current||!t)){if(b.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",u,x);const k=M=>M.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),$=async M=>{if(x){m(M.id),d("workspaceList");return}c(M.id);try{await s(M.id)}finally{c(null)}},S=async M=>{c(M.id);try{await a(M.id)}finally{c(null)}},C=async M=>{await r(),x&&M&&(m(M.id),d("createWorkspace"))},z=()=>{},w=async()=>{m(null),d("orgList")},y=(T=t==null?void 0:t.find(M=>M.organization.id===p))==null?void 0:T.organization,g=p?n==null?void 0:n.filter(M=>M.organization.id===p):[];if(o)return null;if(u==="createOrg")return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(xn,{onSuccess:C,onCancel:()=>d("orgList")})});if(u==="createWorkspace"&&p)return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(Gs,{organizationId:p,onSuccess:z,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const _=u==="workspaceList",E=_?"Select a workspace":"Select an organization",j=_?`Choose a workspace in ${(y==null?void 0:y.name)||""}`:`to continue to ${((R=h==null?void 0:h.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(vb,{children:[e.jsxs(bb,{children:[e.jsxs("div",{children:[e.jsx(Oe,{}),e.jsxs(Cb,{children:[e.jsx(Sb,{children:E}),e.jsx($b,{children:j})]})]}),e.jsx(Ks,{showName:!0})]}),e.jsxs(yb,{children:[e.jsxs(wb,{children:[e.jsxs(jb,{children:[e.jsx(kb,{children:_?"Workspaces":"Your organizations"}),_&&e.jsxs(_b,{onClick:w,children:[e.jsx(ro,{}),"Go back"]})]}),e.jsx(zb,{children:_?e.jsx(e.Fragment,{children:g&&g.length>0?g.map(M=>{var O,N,D;const I=((O=M.eligibility_restriction)==null?void 0:O.type)!=="none"&&((N=M.eligibility_restriction)==null?void 0:N.type)!==void 0;return e.jsxs(gc,{onClick:()=>!I&&S(M),disabled:f===M.id||I,style:{opacity:I?.7:1},children:[e.jsx(mc,{children:M.image_url?e.jsx(xc,{src:M.image_url,alt:M.name}):k(M.name).charAt(0)}),e.jsxs(vc,{children:[e.jsx(bc,{children:M.name}),e.jsxs(yc,{children:[e.jsx(Qo,{}),"Workspace"]})]}),e.jsx(wc,{children:e.jsx($s,{})}),I&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(D=M.eligibility_restriction)==null?void 0:D.message]})]},M.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No workspaces yet"}),e.jsxs(Cc,{children:["Create your first workspace for"," ",(y==null?void 0:y.name)||"this organization"]}),e.jsxs(Sc,{onClick:()=>d("createWorkspace"),children:[e.jsx(it,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(M=>{var Y,B,H;const I=M.organization,O=n==null?void 0:n.filter(G=>G.organization.id===I.id),N=(O==null?void 0:O.length)||0,D=I.member_count,L=M.roles[0].name,P=M.roles.length-1,A=P>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${P}`:L.charAt(0).toUpperCase()+L.slice(1),q=((Y=M.eligibility_restriction)==null?void 0:Y.type)!=="none"&&((B=M.eligibility_restriction)==null?void 0:B.type)!==void 0;return e.jsxs(gc,{onClick:()=>!q&&$(I),disabled:f===I.id||q,style:{opacity:q?.7:1},children:[e.jsx(mc,{children:I.image_url?e.jsx(xc,{src:I.image_url,alt:I.name}):k(I.name)}),e.jsxs(vc,{children:[e.jsx(bc,{children:I.name}),e.jsx(yc,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Qo,{}),N," workspace",N!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(vh,{}),A," • ",D," member",D!==1?"s":""]})})]}),e.jsx(wc,{children:e.jsx($s,{})}),q&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(H=M.eligibility_restriction)==null?void 0:H.message]})]},I.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No organizations yet"}),e.jsx(Cc,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Sc,{onClick:()=>d("createOrg"),children:[e.jsx(it,{}),"Create organization"]})]})})]}),_&&g&&g.length>0&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new workspace"]}),!_&&t&&t.length>0&&v&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new organization"]})]})]})},Pb=l(ze.Content)`
5153
+ `,Pb=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=Ot(),{workspaces:n}=Wt(),{switchOrganization:s,switchWorkspace:a}=Qe(),{deployment:h}=we(),[f,c]=i.useState(null),[u,d]=i.useState("orgList"),[p,m]=i.useState(null),x=(h==null?void 0:h.b2b_settings.workspaces_enabled)??!1,v=(h==null?void 0:h.b2b_settings.allow_users_to_create_orgs)??!1,b=i.useRef(!1);i.useEffect(()=>{if(!(b.current||!t)){if(b.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",u,x);const k=M=>M.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),$=async M=>{if(x){m(M.id),d("workspaceList");return}c(M.id);try{await s(M.id)}finally{c(null)}},S=async M=>{c(M.id);try{await a(M.id)}finally{c(null)}},C=async M=>{await r(),x&&M&&(m(M.id),d("createWorkspace"))},z=()=>{},w=async()=>{m(null),d("orgList")},y=(T=t==null?void 0:t.find(M=>M.organization.id===p))==null?void 0:T.organization,g=p?n==null?void 0:n.filter(M=>M.organization.id===p):[];if(o)return null;if(u==="createOrg")return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(xn,{onSuccess:C,onCancel:()=>d("orgList")})});if(u==="createWorkspace"&&p)return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(Gs,{organizationId:p,onSuccess:z,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const _=u==="workspaceList",E=_?"Select a workspace":"Select an organization",j=_?`Choose a workspace in ${(y==null?void 0:y.name)||""}`:`to continue to ${((R=h==null?void 0:h.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(bb,{children:[e.jsxs(yb,{children:[e.jsxs("div",{children:[e.jsx(Oe,{}),e.jsxs(Sb,{children:[e.jsx($b,{children:E}),e.jsx(zb,{children:j})]})]}),e.jsx(Ks,{showName:!0})]}),e.jsxs(wb,{children:[e.jsxs(jb,{children:[e.jsxs(kb,{children:[e.jsx(_b,{children:_?"Workspaces":"Your organizations"}),_&&e.jsxs(Cb,{onClick:w,children:[e.jsx(ro,{}),"Go back"]})]}),e.jsx(Eb,{children:_?e.jsx(e.Fragment,{children:g&&g.length>0?g.map(M=>{var O,N,D;const I=((O=M.eligibility_restriction)==null?void 0:O.type)!=="none"&&((N=M.eligibility_restriction)==null?void 0:N.type)!==void 0;return e.jsxs(gc,{onClick:()=>!I&&S(M),disabled:f===M.id||I,style:{opacity:I?.7:1},children:[e.jsx(mc,{children:M.image_url?e.jsx(xc,{src:M.image_url,alt:M.name}):k(M.name).charAt(0)}),e.jsxs(vc,{children:[e.jsx(bc,{children:M.name}),e.jsxs(yc,{children:[e.jsx(Qo,{}),"Workspace"]})]}),e.jsx(wc,{children:e.jsx($s,{})}),I&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(D=M.eligibility_restriction)==null?void 0:D.message]})]},M.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No workspaces yet"}),e.jsxs(Cc,{children:["Create your first workspace for"," ",(y==null?void 0:y.name)||"this organization"]}),e.jsxs(Sc,{onClick:()=>d("createWorkspace"),children:[e.jsx(it,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(M=>{var Y,B,H;const I=M.organization,O=n==null?void 0:n.filter(G=>G.organization.id===I.id),N=(O==null?void 0:O.length)||0,D=I.member_count,L=M.roles[0].name,P=M.roles.length-1,A=P>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${P}`:L.charAt(0).toUpperCase()+L.slice(1),q=((Y=M.eligibility_restriction)==null?void 0:Y.type)!=="none"&&((B=M.eligibility_restriction)==null?void 0:B.type)!==void 0;return e.jsxs(gc,{onClick:()=>!q&&$(I),disabled:f===I.id||q,style:{opacity:q?.7:1},children:[e.jsx(mc,{children:I.image_url?e.jsx(xc,{src:I.image_url,alt:I.name}):k(I.name)}),e.jsxs(vc,{children:[e.jsx(bc,{children:I.name}),e.jsx(yc,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Qo,{}),N," workspace",N!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(vh,{}),A," • ",D," member",D!==1?"s":""]})})]}),e.jsx(wc,{children:e.jsx($s,{})}),q&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(H=M.eligibility_restriction)==null?void 0:H.message]})]},I.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No organizations yet"}),e.jsx(Cc,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Sc,{onClick:()=>d("createOrg"),children:[e.jsx(it,{}),"Create organization"]})]})})]}),_&&g&&g.length>0&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new workspace"]}),!_&&t&&t.length>0&&v&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new organization"]})]})]})},Ib=l(ze.Content)`
5152
5154
  padding: 0;
5153
5155
  max-width: 90vw;
5154
- `,Ib=({children:t})=>{var b,k,$,S;const{loading:r,session:o}=Qe(),{activeOrganization:n}=st(),{activeWorkspace:s,loading:a}=Vt(),{workspaces:h}=Wt(),{deployment:f}=we(),{organizationMemberships:c}=Ot(),u=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,d=c==null?void 0:c.find(C=>C.organization.id===(n==null?void 0:n.id)),p=h==null?void 0:h.find(C=>{var z;return C.id===((z=o==null?void 0:o.active_signin)==null?void 0:z.active_workspace_membership_id)}),m=((b=d==null?void 0:d.eligibility_restriction)==null?void 0:b.type)!=="none"&&((k=d==null?void 0:d.eligibility_restriction)==null?void 0:k.type)!==void 0,x=(($=p==null?void 0:p.eligibility_restriction)==null?void 0:$.type)!=="none"&&((S=p==null?void 0:p.eligibility_restriction)==null?void 0:S.type)!==void 0;return r||u&&a?null:(m||x||!n?!1:u?s?h==null?void 0:h.some(z=>z.id===s.id&&z.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(fe,{children:e.jsx(ze,{isOpen:!0,children:e.jsx(ze.Overlay,{children:e.jsx(Pb,{style:{width:"850px"},children:e.jsx(Eb,{})})})})})},Rb=l.div`
5156
+ `,Rb=({children:t})=>{var b,k,$,S;const{loading:r,session:o}=Qe(),{activeOrganization:n}=st(),{activeWorkspace:s,loading:a}=Vt(),{workspaces:h}=Wt(),{deployment:f}=we(),{organizationMemberships:c}=Ot(),u=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,d=c==null?void 0:c.find(C=>C.organization.id===(n==null?void 0:n.id)),p=h==null?void 0:h.find(C=>{var z;return C.id===((z=o==null?void 0:o.active_signin)==null?void 0:z.active_workspace_membership_id)}),m=((b=d==null?void 0:d.eligibility_restriction)==null?void 0:b.type)!=="none"&&((k=d==null?void 0:d.eligibility_restriction)==null?void 0:k.type)!==void 0,x=(($=p==null?void 0:p.eligibility_restriction)==null?void 0:$.type)!=="none"&&((S=p==null?void 0:p.eligibility_restriction)==null?void 0:S.type)!==void 0;return r||u&&a?null:(m||x||!n?!1:u?s?h==null?void 0:h.some(z=>z.id===s.id&&z.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(fe,{children:e.jsx(ze,{isOpen:!0,children:e.jsx(ze.Overlay,{children:e.jsx(Ib,{style:{width:"850px"},children:e.jsx(Pb,{})})})})})},Tb=l.div`
5155
5157
  display: flex;
5156
5158
  gap: 8px;
5157
5159
  flex-wrap: wrap;
5158
5160
  margin-bottom: 12px;
5159
- `,Tb=l.button`
5161
+ `,Mb=l.button`
5160
5162
  padding: 4px 8px;
5161
5163
  border-radius: 12px;
5162
5164
  border: 1px solid var(--color-border);
@@ -5172,21 +5174,21 @@ cursor: pointer;
5172
5174
  &:hover {
5173
5175
  background: ${t=>t.$active?"var(--color-primary)":"var(--color-background-hover)"};
5174
5176
  }
5175
- `,Mb=l.span`
5177
+ `,Ob=l.span`
5176
5178
  background: var(--color-background);
5177
5179
  color: var(--color-text);
5178
5180
  padding: 1px 4px;
5179
5181
  border-radius: 8px;
5180
5182
  font-size: 10px;
5181
5183
  font-weight: 400;
5182
- `,Ob={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function Ab({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=s=>{if(t.includes(s)){const h=t.filter(f=>f!==s);h.length===0?o(["user"]):o(h)}else o([...t,s])};return e.jsx(Rb,{children:Object.entries(Ob).map(([s,a])=>{const h=(r==null?void 0:r[s])||0,f=t.includes(s);return e.jsxs(Tb,{$active:f,onClick:()=>n(s),children:[a,h>0&&e.jsx(Mb,{children:h})]},s)})})}const $c=l.div`
5184
+ `,Ab={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function Lb({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=s=>{if(t.includes(s)){const h=t.filter(f=>f!==s);h.length===0?o(["user"]):o(h)}else o([...t,s])};return e.jsx(Tb,{children:Object.entries(Ab).map(([s,a])=>{const h=(r==null?void 0:r[s])||0,f=t.includes(s);return e.jsxs(Mb,{$active:f,onClick:()=>n(s),children:[a,h>0&&e.jsx(Ob,{children:h})]},s)})})}const $c=l.div`
5183
5185
  display: flex;
5184
5186
  flex-direction: column;
5185
5187
  width: 100%;
5186
5188
  height: 100%;
5187
5189
  background: var(--color-background);
5188
5190
  overflow: hidden;
5189
- `,Lb=l.div`
5191
+ `,Db=l.div`
5190
5192
  display: flex;
5191
5193
  align-items: center;
5192
5194
  justify-content: space-between;
@@ -5194,11 +5196,11 @@ cursor: pointer;
5194
5196
  background: var(--color-background);
5195
5197
  border-bottom: 1px solid var(--color-border-subtle);
5196
5198
  flex-shrink: 0;
5197
- `,Db=l.div`
5199
+ `,Nb=l.div`
5198
5200
  display: flex;
5199
5201
  align-items: center;
5200
5202
  gap: 12px;
5201
- `,Nb=l.button`
5203
+ `,Fb=l.button`
5202
5204
  display: flex;
5203
5205
  align-items: center;
5204
5206
  justify-content: center;
@@ -5214,11 +5216,11 @@ cursor: pointer;
5214
5216
  &:hover {
5215
5217
  background: var(--color-background-hover);
5216
5218
  }
5217
- `,Fb=l.div`
5219
+ `,Bb=l.div`
5218
5220
  display: flex;
5219
5221
  align-items: center;
5220
5222
  gap: 10px;
5221
- `,Bb=l.div`
5223
+ `,Ub=l.div`
5222
5224
  width: 36px;
5223
5225
  height: 36px;
5224
5226
  border-radius: 50%;
@@ -5227,10 +5229,10 @@ cursor: pointer;
5227
5229
  align-items: center;
5228
5230
  justify-content: center;
5229
5231
  color: white;
5230
- `,Ub=l.div`
5232
+ `,Wb=l.div`
5231
5233
  display: flex;
5232
5234
  flex-direction: column;
5233
- `,Wb=l.div`
5235
+ `,Vb=l.div`
5234
5236
  width: 6px;
5235
5237
  height: 6px;
5236
5238
  border-radius: 50%;
@@ -5244,18 +5246,18 @@ cursor: pointer;
5244
5246
  50% { opacity: 0.5; }
5245
5247
  }
5246
5248
  `}
5247
- `,Vb=l.h3`
5249
+ `,Gb=l.h3`
5248
5250
  margin: 0;
5249
5251
  font-size: 14px;
5250
5252
  font-weight: 400;
5251
5253
  color: var(--color-foreground);
5252
5254
  letter-spacing: -0.01em;
5253
- `,Gb=l.p`
5255
+ `,Hb=l.p`
5254
5256
  margin: 0;
5255
5257
  font-size: 11px;
5256
5258
  color: ${t=>t.$status==="Connecting..."?"var(--color-warning)":t.$status==="Connection error"||t.$status==="Disconnected"?"var(--color-error)":t.$status==="Waiting for your input..."?"var(--color-info)":t.$status==="Working..."?"var(--color-primary)":t.$status==="Ready"?"var(--color-success)":"var(--color-secondary-text)"};
5257
5259
  font-weight: 400;
5258
- `,Hb=l.div`
5260
+ `,qb=l.div`
5259
5261
  font-size: 10px;
5260
5262
  padding: 2px 6px;
5261
5263
  border-radius: 9999px;
@@ -5274,7 +5276,7 @@ cursor: pointer;
5274
5276
  background-color: var(--color-error-background);
5275
5277
  color: var(--color-error-text);
5276
5278
  `;default:return"display: none;"}}}
5277
- `,qb=l.div`
5279
+ `,Yb=l.div`
5278
5280
  flex: 1;
5279
5281
  overflow-y: auto;
5280
5282
  overflow-x: hidden;
@@ -5325,7 +5327,7 @@ cursor: pointer;
5325
5327
  margin-right: auto;
5326
5328
  font-weight: 400;
5327
5329
  `}
5328
- `,Yb=l.span`
5330
+ `,Zb=l.span`
5329
5331
  display: inline-flex;
5330
5332
  gap: 2px;
5331
5333
  margin-left: 8px;
@@ -5349,7 +5351,7 @@ cursor: pointer;
5349
5351
  opacity: 1;
5350
5352
  }
5351
5353
  }
5352
- `,Zb=l(Ld)`
5354
+ `,Kb=l(Ld)`
5353
5355
  opacity: 0.7;
5354
5356
  position: relative;
5355
5357
  display: inline-block;
@@ -5374,7 +5376,7 @@ cursor: pointer;
5374
5376
  transform: rotate(360deg);
5375
5377
  }
5376
5378
  }
5377
- `,Kb=l.div`
5379
+ `,Qb=l.div`
5378
5380
  display: flex;
5379
5381
  justify-content: flex-start;
5380
5382
  align-items: center;
@@ -5432,7 +5434,7 @@ cursor: pointer;
5432
5434
  margin: 0;
5433
5435
  font-size: 13px;
5434
5436
  }
5435
- `,Qb=l.div`
5437
+ `,Xb=l.div`
5436
5438
  background: var(--color-primary-background);
5437
5439
  border: 1px solid var(--color-primary-border);
5438
5440
  border-radius: 8px;
@@ -5530,12 +5532,12 @@ cursor: pointer;
5530
5532
  flex-direction: row;
5531
5533
  gap: 20px;
5532
5534
  }
5533
- `,Xb=l.form`
5535
+ `,Jb=l.form`
5534
5536
  padding: 20px;
5535
5537
  background: var(--color-background);
5536
5538
  border-top: 1px solid var(--color-border);
5537
5539
  flex-shrink: 0;
5538
- `,Jb=l.div`
5540
+ `,ey=l.div`
5539
5541
  position: relative;
5540
5542
  display: flex;
5541
5543
  align-items: flex-end;
@@ -5544,13 +5546,13 @@ cursor: pointer;
5544
5546
  border-radius: 12px;
5545
5547
  padding: 8px 8px 8px 20px;
5546
5548
  min-height: 56px;
5547
- `,ey=l.div`
5549
+ `,ty=l.div`
5548
5550
  flex: 1;
5549
5551
  display: flex;
5550
5552
  flex-direction: column;
5551
5553
  gap: 8px;
5552
5554
  padding-right: 12px;
5553
- `,ty=l.textarea`
5555
+ `,ry=l.textarea`
5554
5556
  width: 100%;
5555
5557
  padding: 0;
5556
5558
  border: none;
@@ -5572,11 +5574,11 @@ cursor: pointer;
5572
5574
  color: var(--color-text-disabled);
5573
5575
  cursor: not-allowed;
5574
5576
  }
5575
- `,ry=l.div`
5577
+ `,oy=l.div`
5576
5578
  display: flex;
5577
5579
  gap: 8px;
5578
5580
  margin-top: 4px;
5579
- `,oy=l.div`
5581
+ `,ny=l.div`
5580
5582
  display: flex;
5581
5583
  gap: 8px;
5582
5584
  padding: 8px 20px;
@@ -5584,7 +5586,7 @@ cursor: pointer;
5584
5586
  background: var(--color-background);
5585
5587
  overflow-x: auto;
5586
5588
  max-height: 120px;
5587
- `,ny=l.div`
5589
+ `,sy=l.div`
5588
5590
  position: relative;
5589
5591
  width: 80px;
5590
5592
  height: 80px;
@@ -5598,7 +5600,7 @@ cursor: pointer;
5598
5600
  height: 100%;
5599
5601
  object-fit: cover;
5600
5602
  }
5601
- `,sy=l.button`
5603
+ `,ay=l.button`
5602
5604
  position: absolute;
5603
5605
  top: 4px;
5604
5606
  right: 4px;
@@ -5616,9 +5618,9 @@ cursor: pointer;
5616
5618
  &:hover {
5617
5619
  background: rgba(0, 0, 0, 0.9);
5618
5620
  }
5619
- `,ay=l.input`
5621
+ `,iy=l.input`
5620
5622
  display: none;
5621
- `,iy=l.button`
5623
+ `,cy=l.button`
5622
5624
  padding: 4px 10px;
5623
5625
  border: 1px solid var(--color-border);
5624
5626
  border-radius: 8px;
@@ -5643,7 +5645,7 @@ cursor: pointer;
5643
5645
  border-color: var(--color-border);
5644
5646
  cursor: not-allowed;
5645
5647
  }
5646
- `,cy=l.button`
5648
+ `,ly=l.button`
5647
5649
  align-self: flex-end;
5648
5650
  padding: 6px;
5649
5651
  border: none;
@@ -5668,7 +5670,7 @@ cursor: pointer;
5668
5670
  color: var(--color-text-disabled);
5669
5671
  cursor: not-allowed;
5670
5672
  }
5671
- `,ly=l.div`
5673
+ `,dy=l.div`
5672
5674
  display: ${t=>t.$isOpen?"flex":"none"};
5673
5675
  position: fixed;
5674
5676
  top: 0;
@@ -5693,7 +5695,7 @@ cursor: pointer;
5693
5695
  backdrop-filter: blur(10px);
5694
5696
  }
5695
5697
  }
5696
- `,dy=l.div`
5698
+ `,uy=l.div`
5697
5699
  position: relative;
5698
5700
  width: 100%;
5699
5701
  height: 100%;
@@ -5749,7 +5751,7 @@ cursor: pointer;
5749
5751
  `,Do=l(Dd)`
5750
5752
  width: 32px;
5751
5753
  padding: 0;
5752
- `,uy=l.img`
5754
+ `,py=l.img`
5753
5755
  max-width: calc(100% - 20px);
5754
5756
  max-height: calc(100% - 20px);
5755
5757
  width: auto;
@@ -5760,7 +5762,7 @@ cursor: pointer;
5760
5762
  transition: ${t=>t.$isDragging?"none":"transform 0.2s ease"};
5761
5763
  user-select: none;
5762
5764
  -webkit-user-drag: none;
5763
- `,py=l.div`
5765
+ `,hy=l.div`
5764
5766
  position: absolute;
5765
5767
  bottom: 20px;
5766
5768
  left: 50%;
@@ -5768,7 +5770,7 @@ cursor: pointer;
5768
5770
  display: flex;
5769
5771
  gap: 8px;
5770
5772
  align-items: center;
5771
- `,hy=l.div`
5773
+ `,fy=l.div`
5772
5774
  display: flex;
5773
5775
  gap: 4px;
5774
5776
  align-items: center;
@@ -5778,14 +5780,14 @@ cursor: pointer;
5778
5780
  border-radius: 12px;
5779
5781
  padding: 4px;
5780
5782
  box-shadow: 0 10px 25px -5px var(--color-shadow);
5781
- `,fy=l.span`
5783
+ `,gy=l.span`
5782
5784
  min-width: 60px;
5783
5785
  text-align: center;
5784
5786
  font-size: 12px;
5785
5787
  font-weight: 400;
5786
5788
  color: var(--color-foreground);
5787
5789
  padding: 0 8px;
5788
- `,gy=l.div`
5790
+ `,my=l.div`
5789
5791
  height: 125px;
5790
5792
  width: auto;
5791
5793
  min-width: 125px;
@@ -5833,18 +5835,18 @@ cursor: pointer;
5833
5835
  &:hover .expand-icon {
5834
5836
  opacity: 1;
5835
5837
  }
5836
- `,my=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:h,onZoom:f,onReset:c,onWheel:u,onMouseDown:d,onMouseMove:p,onMouseUp:m})=>{const[x,v]=i.useState(!1),b=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const k=document.body.style.overflow;document.body.style.overflow="hidden";const $=z=>{(z.ctrlKey||z.metaKey)&&z.preventDefault()},S=z=>{z.preventDefault()},C=z=>{z.preventDefault()};return document.addEventListener("wheel",$,{passive:!1}),document.addEventListener("gesturestart",S,{passive:!1}),document.addEventListener("gesturechange",C,{passive:!1}),()=>{document.body.style.overflow=k,document.removeEventListener("wheel",$),document.removeEventListener("gesturestart",S),document.removeEventListener("gesturechange",C)}}},[t]),!x||!t||!r?null:eo.createPortal(e.jsx(fe,{children:e.jsx(ly,{ref:b,$isOpen:!0,onClick:k=>{k.target===k.currentTarget&&a()},children:e.jsxs(dy,{onClick:k=>k.stopPropagation(),onWheel:k=>{k.preventDefault(),k.stopPropagation(),u(k)},onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:[e.jsx(uy,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:d,draggable:!1}),e.jsx(Do,{$variant:"ghost",onClick:a,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(lt,{size:14})}),e.jsxs(py,{children:[e.jsxs(hy,{children:[e.jsx(Do,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(uf,{size:14})}),e.jsxs(fy,{children:[Math.round(o*100),"%"]}),e.jsx(Do,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(lf,{size:14})}),e.jsx(Do,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Wh,{size:14})})]}),e.jsxs(Dd,{$variant:"primary",onClick:h,title:"Download image",children:[e.jsx(pn,{size:14}),"Download"]})]})]})})}),document.body)};function Nd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:a,selectSession:h}=rn(),f=a==null?void 0:a.id;if(!f)return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx($c,{children:e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,u=!0,d="Start a conversation by typing a message below",[p,m]=i.useState(""),[x,v]=i.useState(!1),[b,k]=i.useState(null),[$,S]=i.useState([]),[C,z]=i.useState([]),[w,y]=i.useState(null),[g,_]=i.useState(1),[E,j]=i.useState(!1),[T,R]=i.useState({x:0,y:0}),[M,I]=i.useState({x:0,y:0}),O=i.useRef(null),N=i.useRef(null),{messages:D,pendingMessage:L,pendingImages:P,connectionState:A,isConnected:q,isExecuting:Y,executionStatus:B,isWaitingForInput:H,sendMessage:G,submitUserInput:X,cancelExecution:oe}=Xc({contextId:f,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var V;(V=O.current)==null||V.scrollIntoView({behavior:"smooth"})},[D]),i.useEffect(()=>{var V;if(H){const F=D.slice().reverse().find(ne=>{var be;return((be=ne.metadata)==null?void 0:be.type)==="user_input_request"});(V=F==null?void 0:F.metadata)!=null&&V.userInputRequest&&k(F.metadata.userInputRequest)}else k(null),S([])},[H,D]);const te=V=>{if(V.preventDefault(),!!q)if(H&&b){let F=p.trim();b.input_type==="multiselect"&&(F=$.join(",")),F&&(X(F),m(""),S([]))}else!Y&&p.trim()&&(G(p,C.length>0?C:void 0),m(""),z([]))},ce=V=>{const F=V.target.files;F&&(Array.from(F).forEach(ne=>{if(ne.type.startsWith("image/")){const be=new FileReader;be.onload=Me=>{var Ce;if((Ce=Me.target)!=null&&Ce.result){const Ve=Me.target.result.split(",")[1];z(Le=>[...Le,{mime_type:ne.type,data:Ve}])}},be.readAsDataURL(ne)}}),N.current&&(N.current.value=""))},Q=V=>{z(F=>F.filter((ne,be)=>be!==V))},me=V=>{y(V),_(1),R({x:0,y:0})},xe=()=>{y(null),_(1),R({x:0,y:0}),j(!1)},de=V=>{const F=document.createElement("a");F.href=V,F.download=`image-${Date.now()}.png`,document.body.appendChild(F),F.click(),document.body.removeChild(F)},U=V=>{_(F=>{const ne=F+V;return Math.min(Math.max(ne,.5),3)})},le=V=>{V.preventDefault(),V.stopPropagation();const F=V.deltaY>0?-.1:.1;U(F)},K=V=>{g>1&&(j(!0),I({x:V.clientX-T.x,y:V.clientY-T.y}))},Z=V=>{E&&g>1&&R({x:V.clientX-M.x,y:V.clientY-M.y})},re=()=>{j(!1)},ge=()=>A.status===Rt.CONNECTING?"Connecting...":A.status===Rt.ERROR?"Connection error":A.status===Rt.DISCONNECTED||!q?"Disconnected":H?"Waiting for your input...":Y?"Working...":"Ready",ue=()=>{if(!H||!b)return"Ask anything";switch(b.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},ee=()=>!H||!b?!1:["select","multiselect","boolean","date"].includes(b.input_type||"");return e.jsxs(fe,{style:{height:"100%",width:"100%"},children:[e.jsxs($c,{children:[e.jsxs(Lb,{children:[e.jsxs(Db,{children:[t&&e.jsx(Nb,{onClick:()=>{r?r():h(null)},children:e.jsx(ro,{size:20})}),e.jsxs(Fb,{children:[e.jsx(Bb,{children:e.jsx(Tn,{size:20})}),e.jsxs(Ub,{children:[e.jsx(Vb,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Wb,{$status:ge()}),e.jsx(Gb,{$status:ge(),children:ge()})]})]})]})]}),B!==He.IDLE&&e.jsx(Hb,{$status:B,children:B.replace("_"," ")})]}),e.jsx(qb,{children:D.length===0&&u?e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:d})]}):e.jsxs(e.Fragment,{children:[D.map((V,F)=>{var ne,be,Me,Ce;if(((ne=V.metadata)==null?void 0:ne.type)==="user_input_request"&&V.metadata.userInputRequest){const Se=V.metadata.userInputRequest,Ve=!Se.input_type||Se.input_type==="text"||Se.input_type==="number",Le=H&&(b==null?void 0:b.input_type)===Se.input_type;return e.jsx(as,{$isUser:!1,children:e.jsxs(Qb,{children:[e.jsx("div",{className:"question",children:Se.question}),Se.context&&Se.context.trim()&&e.jsx("div",{className:"context",children:Se.context}),!Ve&&e.jsxs("div",{className:"controls",children:[Se.input_type==="select"&&Se.options&&e.jsxs("select",{value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le,children:[e.jsx("option",{value:"",children:"Choose an option..."}),Se.options.map(Ae=>e.jsx("option",{value:Ae,children:Ae},Ae))]}),Se.input_type==="multiselect"&&Se.options&&e.jsx("div",{className:"checkbox-group",children:Se.options.map(Ae=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Le&&$.includes(Ae),onChange:ve=>{ve.target.checked?S([...$,Ae]):S($.filter(pe=>pe!==Ae))},disabled:!Le}),e.jsx("span",{children:Ae})]},Ae))}),Se.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Le&&p==="true",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Le&&p==="false",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"No"})]})]}),Se.input_type==="date"&&e.jsx("input",{type:"date",value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le})]}),e.jsx("div",{className:"instruction",children:Le?Ve?"Type your response below":Se.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},V.id)}if(((be=V.metadata)==null?void 0:be.type)==="log"){const Se=D[F-1],Ve=D[F+1],Le=((Me=Se==null?void 0:Se.metadata)==null?void 0:Me.type)==="log",Ae=((Ce=Ve==null?void 0:Ve.metadata)==null?void 0:Ce.type)==="log",ve=Le||Ae,pe=!Le&&Ae,ye=Le&&!Ae;return e.jsx(Kb,{$isGrouped:ve,$isFirstInGroup:pe,$isLastInGroup:ye,children:e.jsx("div",{className:"log-content",children:V.content})},V.id)}return!V.content&&(!V.images||V.images.length===0)?null:e.jsx(as,{$isUser:V.role==="user",children:e.jsxs(Ld,{$isUser:V.role==="user",children:[e.jsx("div",{children:V.content}),V.images&&V.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:V.images.map((Se,Ve)=>{const Le=Se.url||`data:${Se.mime_type};base64,${Se.data}`;return e.jsxs(gy,{onClick:()=>me(Le),title:"Click to preview",children:[e.jsx("img",{src:Le,alt:`Image ${Ve+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(Ph,{size:14})})]},Ve)})}),V.isStreaming&&e.jsx(Yb,{})]})},V.id)}),L&&e.jsx(as,{$isUser:!0,children:e.jsxs(Zb,{$isUser:!0,children:[e.jsx("div",{children:L}),P&&P.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:P.map((V,F)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Image ${F+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},F))})]})}),e.jsx("div",{ref:O})]})}),C.length>0&&e.jsx(oy,{children:C.map((V,F)=>e.jsxs(ny,{children:[e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Upload ${F+1}`}),e.jsx(sy,{type:"button",onClick:()=>Q(F),children:e.jsx(lt,{size:12})})]},F))}),e.jsx(Xb,{onSubmit:te,children:e.jsxs(Jb,{children:[e.jsxs(ey,{children:[e.jsx(ty,{value:p,onChange:V=>m(V.target.value),onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),te(V))},placeholder:ue(),disabled:!q||Y&&!H||ee(),rows:1}),e.jsx(ry,{children:e.jsxs(iy,{type:"button",disabled:!q||Y,onClick:()=>{var V;return(V=N.current)==null?void 0:V.click()},children:[e.jsx(Hh,{size:16}),"Attach"]})}),e.jsx(ay,{ref:N,type:"file",accept:"image/*",multiple:!0,onChange:ce})]}),e.jsx(cy,{type:Y?"button":"submit",disabled:!q||!H&&!Y&&!p.trim(),onClick:Y?oe:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:Y&&x?"var(--color-error)":void 0},children:Y?x?e.jsx(lt,{size:14}):e.jsx(yt,{size:14,className:"animate-spin"}):e.jsx(Fs,{size:14})})]})})]}),e.jsx(my,{isOpen:!!w,imageUrl:w,zoomLevel:g,dragPosition:T,isDragging:E,onClose:xe,onDownload:()=>w&&de(w),onZoom:U,onReset:()=>{_(1),R({x:0,y:0})},onWheel:le,onMouseDown:K,onMouseMove:Z,onMouseUp:re})]})}const xy=l.div`
5838
+ `,xy=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:h,onZoom:f,onReset:c,onWheel:u,onMouseDown:d,onMouseMove:p,onMouseUp:m})=>{const[x,v]=i.useState(!1),b=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const k=document.body.style.overflow;document.body.style.overflow="hidden";const $=z=>{(z.ctrlKey||z.metaKey)&&z.preventDefault()},S=z=>{z.preventDefault()},C=z=>{z.preventDefault()};return document.addEventListener("wheel",$,{passive:!1}),document.addEventListener("gesturestart",S,{passive:!1}),document.addEventListener("gesturechange",C,{passive:!1}),()=>{document.body.style.overflow=k,document.removeEventListener("wheel",$),document.removeEventListener("gesturestart",S),document.removeEventListener("gesturechange",C)}}},[t]),!x||!t||!r?null:eo.createPortal(e.jsx(fe,{children:e.jsx(dy,{ref:b,$isOpen:!0,onClick:k=>{k.target===k.currentTarget&&a()},children:e.jsxs(uy,{onClick:k=>k.stopPropagation(),onWheel:k=>{k.preventDefault(),k.stopPropagation(),u(k)},onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:[e.jsx(py,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:d,draggable:!1}),e.jsx(Do,{$variant:"ghost",onClick:a,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(lt,{size:14})}),e.jsxs(hy,{children:[e.jsxs(fy,{children:[e.jsx(Do,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(uf,{size:14})}),e.jsxs(gy,{children:[Math.round(o*100),"%"]}),e.jsx(Do,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(lf,{size:14})}),e.jsx(Do,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Wh,{size:14})})]}),e.jsxs(Dd,{$variant:"primary",onClick:h,title:"Download image",children:[e.jsx(pn,{size:14}),"Download"]})]})]})})}),document.body)};function Nd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:a,selectSession:h}=rn(),f=a==null?void 0:a.id;if(!f)return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx($c,{children:e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,u=!0,d="Start a conversation by typing a message below",[p,m]=i.useState(""),[x,v]=i.useState(!1),[b,k]=i.useState(null),[$,S]=i.useState([]),[C,z]=i.useState([]),[w,y]=i.useState(null),[g,_]=i.useState(1),[E,j]=i.useState(!1),[T,R]=i.useState({x:0,y:0}),[M,I]=i.useState({x:0,y:0}),O=i.useRef(null),N=i.useRef(null),{messages:D,pendingMessage:L,pendingImages:P,connectionState:A,isConnected:q,isExecuting:Y,executionStatus:B,isWaitingForInput:H,sendMessage:G,submitUserInput:X,cancelExecution:oe}=Xc({contextId:f,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var V;(V=O.current)==null||V.scrollIntoView({behavior:"smooth"})},[D]),i.useEffect(()=>{var V;if(H){const F=D.slice().reverse().find(ne=>{var be;return((be=ne.metadata)==null?void 0:be.type)==="user_input_request"});(V=F==null?void 0:F.metadata)!=null&&V.userInputRequest&&k(F.metadata.userInputRequest)}else k(null),S([])},[H,D]);const te=V=>{if(V.preventDefault(),!!q)if(H&&b){let F=p.trim();b.input_type==="multiselect"&&(F=$.join(",")),F&&(X(F),m(""),S([]))}else!Y&&p.trim()&&(G(p,C.length>0?C:void 0),m(""),z([]))},ce=V=>{const F=V.target.files;F&&(Array.from(F).forEach(ne=>{if(ne.type.startsWith("image/")){const be=new FileReader;be.onload=Me=>{var Ce;if((Ce=Me.target)!=null&&Ce.result){const Ve=Me.target.result.split(",")[1];z(Le=>[...Le,{mime_type:ne.type,data:Ve}])}},be.readAsDataURL(ne)}}),N.current&&(N.current.value=""))},Q=V=>{z(F=>F.filter((ne,be)=>be!==V))},me=V=>{y(V),_(1),R({x:0,y:0})},xe=()=>{y(null),_(1),R({x:0,y:0}),j(!1)},de=V=>{const F=document.createElement("a");F.href=V,F.download=`image-${Date.now()}.png`,document.body.appendChild(F),F.click(),document.body.removeChild(F)},U=V=>{_(F=>{const ne=F+V;return Math.min(Math.max(ne,.5),3)})},le=V=>{V.preventDefault(),V.stopPropagation();const F=V.deltaY>0?-.1:.1;U(F)},K=V=>{g>1&&(j(!0),I({x:V.clientX-T.x,y:V.clientY-T.y}))},Z=V=>{E&&g>1&&R({x:V.clientX-M.x,y:V.clientY-M.y})},re=()=>{j(!1)},ge=()=>A.status===Rt.CONNECTING?"Connecting...":A.status===Rt.ERROR?"Connection error":A.status===Rt.DISCONNECTED||!q?"Disconnected":H?"Waiting for your input...":Y?"Working...":"Ready",ue=()=>{if(!H||!b)return"Ask anything";switch(b.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},ee=()=>!H||!b?!1:["select","multiselect","boolean","date"].includes(b.input_type||"");return e.jsxs(fe,{style:{height:"100%",width:"100%"},children:[e.jsxs($c,{children:[e.jsxs(Db,{children:[e.jsxs(Nb,{children:[t&&e.jsx(Fb,{onClick:()=>{r?r():h(null)},children:e.jsx(ro,{size:20})}),e.jsxs(Bb,{children:[e.jsx(Ub,{children:e.jsx(Tn,{size:20})}),e.jsxs(Wb,{children:[e.jsx(Gb,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Vb,{$status:ge()}),e.jsx(Hb,{$status:ge(),children:ge()})]})]})]})]}),B!==He.IDLE&&e.jsx(qb,{$status:B,children:B.replace("_"," ")})]}),e.jsx(Yb,{children:D.length===0&&u?e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:d})]}):e.jsxs(e.Fragment,{children:[D.map((V,F)=>{var ne,be,Me,Ce;if(((ne=V.metadata)==null?void 0:ne.type)==="user_input_request"&&V.metadata.userInputRequest){const Se=V.metadata.userInputRequest,Ve=!Se.input_type||Se.input_type==="text"||Se.input_type==="number",Le=H&&(b==null?void 0:b.input_type)===Se.input_type;return e.jsx(as,{$isUser:!1,children:e.jsxs(Xb,{children:[e.jsx("div",{className:"question",children:Se.question}),Se.context&&Se.context.trim()&&e.jsx("div",{className:"context",children:Se.context}),!Ve&&e.jsxs("div",{className:"controls",children:[Se.input_type==="select"&&Se.options&&e.jsxs("select",{value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le,children:[e.jsx("option",{value:"",children:"Choose an option..."}),Se.options.map(Ae=>e.jsx("option",{value:Ae,children:Ae},Ae))]}),Se.input_type==="multiselect"&&Se.options&&e.jsx("div",{className:"checkbox-group",children:Se.options.map(Ae=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Le&&$.includes(Ae),onChange:ve=>{ve.target.checked?S([...$,Ae]):S($.filter(pe=>pe!==Ae))},disabled:!Le}),e.jsx("span",{children:Ae})]},Ae))}),Se.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Le&&p==="true",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Le&&p==="false",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"No"})]})]}),Se.input_type==="date"&&e.jsx("input",{type:"date",value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le})]}),e.jsx("div",{className:"instruction",children:Le?Ve?"Type your response below":Se.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},V.id)}if(((be=V.metadata)==null?void 0:be.type)==="log"){const Se=D[F-1],Ve=D[F+1],Le=((Me=Se==null?void 0:Se.metadata)==null?void 0:Me.type)==="log",Ae=((Ce=Ve==null?void 0:Ve.metadata)==null?void 0:Ce.type)==="log",ve=Le||Ae,pe=!Le&&Ae,ye=Le&&!Ae;return e.jsx(Qb,{$isGrouped:ve,$isFirstInGroup:pe,$isLastInGroup:ye,children:e.jsx("div",{className:"log-content",children:V.content})},V.id)}return!V.content&&(!V.images||V.images.length===0)?null:e.jsx(as,{$isUser:V.role==="user",children:e.jsxs(Ld,{$isUser:V.role==="user",children:[e.jsx("div",{children:V.content}),V.images&&V.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:V.images.map((Se,Ve)=>{const Le=Se.url||`data:${Se.mime_type};base64,${Se.data}`;return e.jsxs(my,{onClick:()=>me(Le),title:"Click to preview",children:[e.jsx("img",{src:Le,alt:`Image ${Ve+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(Ph,{size:14})})]},Ve)})}),V.isStreaming&&e.jsx(Zb,{})]})},V.id)}),L&&e.jsx(as,{$isUser:!0,children:e.jsxs(Kb,{$isUser:!0,children:[e.jsx("div",{children:L}),P&&P.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:P.map((V,F)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Image ${F+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},F))})]})}),e.jsx("div",{ref:O})]})}),C.length>0&&e.jsx(ny,{children:C.map((V,F)=>e.jsxs(sy,{children:[e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Upload ${F+1}`}),e.jsx(ay,{type:"button",onClick:()=>Q(F),children:e.jsx(lt,{size:12})})]},F))}),e.jsx(Jb,{onSubmit:te,children:e.jsxs(ey,{children:[e.jsxs(ty,{children:[e.jsx(ry,{value:p,onChange:V=>m(V.target.value),onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),te(V))},placeholder:ue(),disabled:!q||Y&&!H||ee(),rows:1}),e.jsx(oy,{children:e.jsxs(cy,{type:"button",disabled:!q||Y,onClick:()=>{var V;return(V=N.current)==null?void 0:V.click()},children:[e.jsx(Hh,{size:16}),"Attach"]})}),e.jsx(iy,{ref:N,type:"file",accept:"image/*",multiple:!0,onChange:ce})]}),e.jsx(ly,{type:Y?"button":"submit",disabled:!q||!H&&!Y&&!p.trim(),onClick:Y?oe:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:Y&&x?"var(--color-error)":void 0},children:Y?x?e.jsx(lt,{size:14}):e.jsx(wt,{size:14,className:"animate-spin"}):e.jsx(Fs,{size:14})})]})})]}),e.jsx(xy,{isOpen:!!w,imageUrl:w,zoomLevel:g,dragPosition:T,isDragging:E,onClose:xe,onDownload:()=>w&&de(w),onZoom:U,onReset:()=>{_(1),R({x:0,y:0})},onWheel:le,onMouseDown:K,onMouseMove:Z,onMouseUp:re})]})}const vy=l.div`
5837
5839
  height: 100%;
5838
5840
  display: flex;
5839
5841
  flex-direction: column;
5840
5842
  background: var(--color-background);
5841
- `,vy=l.div`
5843
+ `,by=l.div`
5842
5844
  display: flex;
5843
5845
  align-items: center;
5844
5846
  gap: var(--space-md);
5845
5847
  padding: var(--space-lg);
5846
5848
  border-bottom: 1px solid var(--color-border);
5847
- `,by=l.button`
5849
+ `,yy=l.button`
5848
5850
  display: flex;
5849
5851
  align-items: center;
5850
5852
  justify-content: center;
@@ -5860,16 +5862,16 @@ cursor: pointer;
5860
5862
  &:hover {
5861
5863
  background: var(--color-background-hover);
5862
5864
  }
5863
- `,yy=l.h1`
5865
+ `,wy=l.h1`
5864
5866
  flex: 1;
5865
5867
  margin: 0;
5866
5868
  font-size: var(--font-lg);
5867
5869
  font-weight: 400;
5868
5870
  color: var(--color-foreground);
5869
- `,wy=l.div`
5871
+ `,jy=l.div`
5870
5872
  padding: var(--space-lg);
5871
5873
  border-bottom: 1px solid var(--color-border);
5872
- `,jy=l.input`
5874
+ `,ky=l.input`
5873
5875
  width: 100%;
5874
5876
  padding: var(--space-sm) var(--space-md);
5875
5877
  background: var(--color-background-subtle);
@@ -5888,20 +5890,20 @@ cursor: pointer;
5888
5890
  border-color: var(--color-primary);
5889
5891
  background: var(--color-background);
5890
5892
  }
5891
- `,ky=l.div`
5893
+ `,_y=l.div`
5892
5894
  flex: 1;
5893
5895
  overflow-y: auto;
5894
5896
  padding: var(--space-lg);
5895
- `,_y=l.div`
5897
+ `,Cy=l.div`
5896
5898
  margin-bottom: var(--space-xl);
5897
- `,Cy=l.h3`
5899
+ `,Sy=l.h3`
5898
5900
  font-size: var(--font-xs);
5899
5901
  font-weight: 400;
5900
5902
  color: var(--color-muted);
5901
5903
  margin: 0 0 var(--space-sm) 0;
5902
5904
  text-transform: uppercase;
5903
5905
  letter-spacing: 0.05em;
5904
- `,Sy=l.div`
5906
+ `,$y=l.div`
5905
5907
  display: flex;
5906
5908
  align-items: center;
5907
5909
  gap: var(--space-md);
@@ -5917,7 +5919,7 @@ cursor: pointer;
5917
5919
  background: var(--color-surface-hover, var(--color-background-hover));
5918
5920
  border-color: var(--color-border-hover, var(--color-border));
5919
5921
  }
5920
- `,$y=l.div`
5922
+ `,zy=l.div`
5921
5923
  width: 36px;
5922
5924
  height: 36px;
5923
5925
  display: flex;
@@ -5926,10 +5928,10 @@ cursor: pointer;
5926
5928
  background: var(--color-background-subtle);
5927
5929
  border-radius: var(--radius-md);
5928
5930
  color: var(--color-secondary-text);
5929
- `,zy=l.div`
5931
+ `,Ey=l.div`
5930
5932
  flex: 1;
5931
5933
  min-width: 0;
5932
- `,Ey=l.div`
5934
+ `,Py=l.div`
5933
5935
  font-size: var(--font-sm);
5934
5936
  font-weight: 400;
5935
5937
  color: var(--color-foreground);
@@ -5937,13 +5939,13 @@ cursor: pointer;
5937
5939
  white-space: nowrap;
5938
5940
  overflow: hidden;
5939
5941
  text-overflow: ellipsis;
5940
- `,Py=l.div`
5942
+ `,Iy=l.div`
5941
5943
  font-size: var(--font-2xs);
5942
5944
  color: var(--color-secondary-text);
5943
5945
  display: flex;
5944
5946
  align-items: center;
5945
5947
  gap: var(--space-xs);
5946
- `,Iy=l.span`
5948
+ `,Ry=l.span`
5947
5949
  display: inline-block;
5948
5950
  padding: 2px 6px;
5949
5951
  border-radius: var(--radius-sm);
@@ -5951,7 +5953,7 @@ cursor: pointer;
5951
5953
  font-weight: 400;
5952
5954
  background: ${t=>{switch(t.$status){case"running":return"var(--color-success-bg)";case"waiting_for_input":return"var(--color-warning-bg)";case"failed":return"var(--color-error-bg)";default:return"var(--color-background-subtle)"}}};
5953
5955
  color: ${t=>{switch(t.$status){case"running":return"var(--color-success)";case"waiting_for_input":return"var(--color-warning)";case"failed":return"var(--color-error)";default:return"var(--color-secondary-text)"}}};
5954
- `,Ry=l.button`
5956
+ `,Ty=l.button`
5955
5957
  display: flex;
5956
5958
  align-items: center;
5957
5959
  justify-content: center;
@@ -5968,7 +5970,7 @@ cursor: pointer;
5968
5970
  background: var(--color-error-bg);
5969
5971
  color: var(--color-error);
5970
5972
  }
5971
- `,Ty=l.div`
5973
+ `,My=l.div`
5972
5974
  display: flex;
5973
5975
  flex-direction: column;
5974
5976
  align-items: center;
@@ -5984,11 +5986,11 @@ cursor: pointer;
5984
5986
  margin-bottom: var(--space-md);
5985
5987
  opacity: 0.5;
5986
5988
  }
5987
- `,My=l.div`
5989
+ `,Oy=l.div`
5988
5990
  display: flex;
5989
5991
  flex-direction: column;
5990
5992
  gap: var(--space-sm);
5991
- `,Oy=l.div`
5993
+ `,Ay=l.div`
5992
5994
  display: flex;
5993
5995
  align-items: center;
5994
5996
  gap: var(--space-md);
@@ -6007,33 +6009,33 @@ cursor: pointer;
6007
6009
  opacity: 0.5;
6008
6010
  }
6009
6011
  }
6010
- `,Ay=l.div`
6012
+ `,Ly=l.div`
6011
6013
  width: 36px;
6012
6014
  height: 36px;
6013
6015
  background: var(--color-border);
6014
6016
  border-radius: var(--radius-md);
6015
- `,Ly=l.div`
6017
+ `,Dy=l.div`
6016
6018
  flex: 1;
6017
6019
  display: flex;
6018
6020
  flex-direction: column;
6019
6021
  gap: var(--space-xs);
6020
- `,Dy=l.div`
6022
+ `,Ny=l.div`
6021
6023
  height: 14px;
6022
6024
  width: 60%;
6023
6025
  background: var(--color-border);
6024
6026
  border-radius: var(--radius-sm);
6025
- `,Ny=l.div`
6027
+ `,Fy=l.div`
6026
6028
  height: 12px;
6027
6029
  width: 30%;
6028
6030
  background: var(--color-border);
6029
6031
  border-radius: var(--radius-sm);
6030
6032
  opacity: 0.6;
6031
- `;function Fd({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:s,selectSession:a,deleteSession:h,setShowHistory:f}=rn(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),u=x=>{const v={},b=new Date,k=new Date(b.getFullYear(),b.getMonth(),b.getDate()),$=new Date(k);$.setDate($.getDate()-1);const S=new Date(k);return S.setDate(S.getDate()-7),x.forEach(C=>{const z=new Date(C.last_activity_at);let w;z>=k?w="Today":z>=$?w="Yesterday":z>=S?w="This Week":w="Older",v[w]||(v[w]=[]),v[w].push(C)}),v},d=async(x,v)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await h(v)}catch(b){console.error("Failed to delete session:",b)}},p=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=u(c);return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsxs(xy,{children:[e.jsxs(vy,{children:[t&&e.jsx(by,{onClick:()=>f(!1),children:e.jsx(ro,{size:20})}),e.jsx(yy,{children:"Conversation History"})]}),e.jsx(wy,{children:e.jsx(jy,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(ky,{children:s?e.jsx(My,{children:[1,2,3,4,5].map(x=>e.jsxs(Oy,{children:[e.jsx(Ay,{}),e.jsxs(Ly,{children:[e.jsx(Dy,{}),e.jsx(Ny,{})]})]},x))}):c.length===0?e.jsxs(Ty,{children:[e.jsx(Da,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(m).map(([x,v])=>e.jsxs(_y,{children:[e.jsx(Cy,{children:x}),v.map(b=>e.jsxs(Sy,{onClick:()=>a(b),children:[e.jsx($y,{children:e.jsx(Da,{size:18})}),e.jsxs(zy,{children:[e.jsx(Ey,{children:b.title}),e.jsxs(Py,{children:[e.jsx("span",{children:p(b.last_activity_at)}),b.status!=="idle"&&e.jsx(Iy,{$status:b.status,children:b.status.replace("_"," ")})]})]}),e.jsx(Ry,{onClick:k=>d(k,b.id),children:e.jsx(fn,{size:16})})]},b.id))]},x))})]})})}const Fy=l.div`
6033
+ `;function Fd({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:s,selectSession:a,deleteSession:h,setShowHistory:f}=rn(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),u=x=>{const v={},b=new Date,k=new Date(b.getFullYear(),b.getMonth(),b.getDate()),$=new Date(k);$.setDate($.getDate()-1);const S=new Date(k);return S.setDate(S.getDate()-7),x.forEach(C=>{const z=new Date(C.last_activity_at);let w;z>=k?w="Today":z>=$?w="Yesterday":z>=S?w="This Week":w="Older",v[w]||(v[w]=[]),v[w].push(C)}),v},d=async(x,v)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await h(v)}catch(b){console.error("Failed to delete session:",b)}},p=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=u(c);return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsxs(vy,{children:[e.jsxs(by,{children:[t&&e.jsx(yy,{onClick:()=>f(!1),children:e.jsx(ro,{size:20})}),e.jsx(wy,{children:"Conversation History"})]}),e.jsx(jy,{children:e.jsx(ky,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(_y,{children:s?e.jsx(Oy,{children:[1,2,3,4,5].map(x=>e.jsxs(Ay,{children:[e.jsx(Ly,{}),e.jsxs(Dy,{children:[e.jsx(Ny,{}),e.jsx(Fy,{})]})]},x))}):c.length===0?e.jsxs(My,{children:[e.jsx(Da,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(m).map(([x,v])=>e.jsxs(Cy,{children:[e.jsx(Sy,{children:x}),v.map(b=>e.jsxs($y,{onClick:()=>a(b),children:[e.jsx(zy,{children:e.jsx(Da,{size:18})}),e.jsxs(Ey,{children:[e.jsx(Py,{children:b.title}),e.jsxs(Iy,{children:[e.jsx("span",{children:p(b.last_activity_at)}),b.status!=="idle"&&e.jsx(Ry,{$status:b.status,children:b.status.replace("_"," ")})]})]}),e.jsx(Ty,{onClick:k=>d(k,b.id),children:e.jsx(fn,{size:16})})]},b.id))]},x))})]})})}const By=l.div`
6032
6034
  height: 100%;
6033
6035
  display: flex;
6034
6036
  flex-direction: column;
6035
6037
  background: var(--color-background);
6036
- `,By=l.div`
6038
+ `,Uy=l.div`
6037
6039
  height: 100%;
6038
6040
  display: flex;
6039
6041
  flex-direction: column;
@@ -6041,7 +6043,7 @@ cursor: pointer;
6041
6043
  justify-content: center;
6042
6044
  padding: var(--space-2xl);
6043
6045
  overflow: auto;
6044
- `,Uy=l.div`
6046
+ `,Wy=l.div`
6045
6047
  width: 56px;
6046
6048
  height: 56px;
6047
6049
  margin-bottom: var(--space-lg);
@@ -6052,18 +6054,18 @@ cursor: pointer;
6052
6054
  color: var(--color-secondary-text);
6053
6055
  opacity: 0.6;
6054
6056
  }
6055
- `,Wy=l.h2`
6057
+ `,Vy=l.h2`
6056
6058
  font-size: var(--font-lg);
6057
6059
  font-weight: 400;
6058
6060
  color: var(--color-foreground);
6059
6061
  margin: 0 0 var(--space-sm) 0;
6060
6062
  text-align: center;
6061
- `,Vy=l.p`
6063
+ `,Gy=l.p`
6062
6064
  font-size: var(--font-sm);
6063
6065
  color: var(--color-secondary-text);
6064
6066
  margin: 0 0 var(--space-xl) 0;
6065
6067
  text-align: center;
6066
- `,Gy=l.button`
6068
+ `,Hy=l.button`
6067
6069
  background: var(--color-primary);
6068
6070
  color: white;
6069
6071
  border: none;
@@ -6101,7 +6103,7 @@ cursor: pointer;
6101
6103
  opacity: 0.6;
6102
6104
  }
6103
6105
  }
6104
- `,Hy=l.span`
6106
+ `,qy=l.span`
6105
6107
  &::after {
6106
6108
  content: ".";
6107
6109
  animation: dots 1.5s steps(3, end) infinite;
@@ -6120,7 +6122,7 @@ cursor: pointer;
6120
6122
  content: "...";
6121
6123
  }
6122
6124
  }
6123
- `,qy=l.div`
6125
+ `,Yy=l.div`
6124
6126
  width: 100%;
6125
6127
  padding: var(--space-md);
6126
6128
  background: var(--color-surface, var(--color-background));
@@ -6135,7 +6137,7 @@ cursor: pointer;
6135
6137
  background: var(--color-surface-hover, var(--color-background-hover));
6136
6138
  border-color: var(--color-border-hover, var(--color-border));
6137
6139
  }
6138
- `,Yy=l.div`
6140
+ `,Zy=l.div`
6139
6141
  font-size: var(--font-sm);
6140
6142
  font-weight: 400;
6141
6143
  color: var(--color-foreground);
@@ -6143,34 +6145,34 @@ cursor: pointer;
6143
6145
  white-space: nowrap;
6144
6146
  overflow: hidden;
6145
6147
  text-overflow: ellipsis;
6146
- `,Zy=l.div`
6148
+ `,Ky=l.div`
6147
6149
  font-size: var(--font-2xs);
6148
6150
  color: var(--color-secondary-text);
6149
6151
  display: flex;
6150
6152
  align-items: center;
6151
6153
  gap: var(--space-xs);
6152
- `,Ky=l.div`
6154
+ `,Qy=l.div`
6153
6155
  flex: 1;
6154
6156
  min-width: 0;
6155
- `,Qy=l.div`
6157
+ `,Xy=l.div`
6156
6158
  width: 100%;
6157
6159
  max-width: 320px;
6158
6160
  margin-top: var(--space-2xl);
6159
6161
  padding-top: var(--space-2xl);
6160
6162
  border-top: 1px solid var(--color-border);
6161
- `,Xy=l.div`
6163
+ `,Jy=l.div`
6162
6164
  display: flex;
6163
6165
  justify-content: space-between;
6164
6166
  align-items: center;
6165
6167
  margin-bottom: var(--space-md);
6166
- `,Jy=l.h3`
6168
+ `,e2=l.h3`
6167
6169
  font-size: var(--font-xs);
6168
6170
  font-weight: 400;
6169
6171
  color: var(--color-muted);
6170
6172
  margin: 0;
6171
6173
  text-transform: uppercase;
6172
6174
  letter-spacing: 0.05em;
6173
- `,e2=l.button`
6175
+ `,t2=l.button`
6174
6176
  background: transparent;
6175
6177
  border: none;
6176
6178
  color: var(--color-primary);
@@ -6182,9 +6184,9 @@ cursor: pointer;
6182
6184
  &:hover {
6183
6185
  opacity: 0.8;
6184
6186
  }
6185
- `,t2=l.div`
6187
+ `,r2=l.div`
6186
6188
  display: flex;
6187
6189
  flex-direction: column;
6188
6190
  gap: var(--space-xs);
6189
- `;function r2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:h,setShowHistory:f}=rn(),c=async()=>{try{r(!0),await h()}finally{r(!1)}},u=d=>{try{const p=new Date(d),x=new Date().getTime()-p.getTime(),v=Math.floor(x/6e4),b=Math.floor(v/60),k=Math.floor(b/24);return k>0?`${k}d ago`:b>0?`${b}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return s?e.jsx(Fd,{showBackButton:!0}):n?e.jsx(Nd,{showBackButton:!0}):e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx(Fy,{children:e.jsxs(By,{children:[e.jsx(Uy,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(Wy,{children:"Hi there! 👋"}),e.jsx(Vy,{children:"How can I help you today?"}),e.jsx(Gy,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(Hy,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(Qy,{children:[e.jsxs(Xy,{children:[e.jsx(Jy,{children:"Recent Chats"}),e.jsx(e2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(t2,{children:o.slice(0,2).map(d=>e.jsx(qy,{onClick:()=>a(d),children:e.jsxs(Ky,{children:[e.jsx(Yy,{children:d.title}),e.jsxs(Zy,{children:[e.jsx("span",{children:u(d.last_activity_at)}),d.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},d.id))})]})]})})})}const o2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},n2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=ox;exports.AgentConversation=Nd;exports.AgentConversationHistory=Fd;exports.AgentConversationHub=r2;exports.AgentConversationProvider=_u;exports.AuthFormImage=Oe;exports.ChannelSelector=Ab;exports.CreateOrganizationForm=xn;exports.CreateWorkspaceDialog=ad;exports.CreateWorkspaceForm=Gs;exports.DeploymentInitialized=ep;exports.DeploymentInitializing=tp;exports.DeploymentProvider=Gd;exports.Dialog=ze;exports.DialogTrigger=ag;exports.Dropdown=ft;exports.DropdownDivider=mn;exports.DropdownItem=Be;exports.DropdownItems=gt;exports.DropdownTrigger=mt;exports.Form=wt;exports.FormGroup=he;exports.Input=se;exports.Label=ie;exports.MagicLinkVerification=Km;exports.ManageAccount=Pd;exports.ManageAccountDialog=Id;exports.ManageOrganization=od;exports.ManageWorkspace=cd;exports.ManageWorkspaceDialog=ld;exports.NavigateToSignIn=mb;exports.NavigateToSignUp=xb;exports.NavigationLink=ht;exports.NotificationBell=Od;exports.NotificationItem=Td;exports.NotificationPopover=Md;exports.OAuthProvider=Bc;exports.ORG_ADMIN_PERMISSIONS=ud;exports.ORG_MANAGEMENT_PERMISSIONS=pd;exports.OTPInput=qt;exports.OrganizationSwitcher=md;exports.PhoneNumberInput=oo;exports.PhoneVerification=Yl;exports.ProfileCompletion=Kl;exports.RequireActiveTenancy=Ib;exports.SSOCallback=Bm;exports.SignInForm=wm;exports.SignUpForm=Gf;exports.SignedIn=eb;exports.SignedInAccounts=gb;exports.SignedOut=tb;exports.SimpleDialog=sg;exports.Spinner=Re;exports.Switch=mr;exports.TwoFactorMethodSelector=ql;exports.TwoFactorVerification=Zl;exports.UserButton=Ks;exports.UserControls=J1;exports.WORKSPACE_ADMIN_PERMISSIONS=hd;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=fd;exports.WaitlistForm=Am;exports.canManageOrganization=gd;exports.canManageWorkspace=Es;exports.clearTokenCache=Mt;exports.fetchChannelCounts=Yu;exports.hasIncompleteProfile=Qm;exports.hasOrgPermission=qs;exports.hasWorkspacePermission=Ys;exports.isExternalUrl=o2;exports.isOrgAdmin=ov;exports.isSafeUrl=n2;exports.isWorkspaceAdmin=nv;exports.redirectToProfileCompletion=Xm;exports.useActiveOrganization=st;exports.useActiveTenancy=Hu;exports.useActiveWorkspace=Vt;exports.useAgentConversation=Xc;exports.useAgentConversationContext=rn;exports.useChannelCounts=Ju;exports.useClient=Ke;exports.useConversationSessions=Nc;exports.useDeployment=we;exports.useForgotPassword=Zc;exports.useInvitation=Jc;exports.useMagicLinkParams=Yc;exports.useMagicLinkVerification=qc;exports.useNavigation=rt;exports.useNotificationStream=Kc;exports.useNotifications=Qc;exports.useOrganizationList=on;exports.useOrganizationMemberships=Ot;exports.useSSOCallback=Hc;exports.useSession=Qe;exports.useSignIn=Uc;exports.useSignInWithStrategy=zr;exports.useSignUp=Wc;exports.useUser=Gt;exports.useUserSignins=Vc;exports.useWaitlist=Gc;exports.useWorkspaceList=Wt;exports.useWorkspaceMemberships=nn;Object.keys(da).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>da[t]})});
6191
+ `;function o2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:h,setShowHistory:f}=rn(),c=async()=>{try{r(!0),await h()}finally{r(!1)}},u=d=>{try{const p=new Date(d),x=new Date().getTime()-p.getTime(),v=Math.floor(x/6e4),b=Math.floor(v/60),k=Math.floor(b/24);return k>0?`${k}d ago`:b>0?`${b}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return s?e.jsx(Fd,{showBackButton:!0}):n?e.jsx(Nd,{showBackButton:!0}):e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx(By,{children:e.jsxs(Uy,{children:[e.jsx(Wy,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(Vy,{children:"Hi there! 👋"}),e.jsx(Gy,{children:"How can I help you today?"}),e.jsx(Hy,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(qy,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(Xy,{children:[e.jsxs(Jy,{children:[e.jsx(e2,{children:"Recent Chats"}),e.jsx(t2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(r2,{children:o.slice(0,2).map(d=>e.jsx(Yy,{onClick:()=>a(d),children:e.jsxs(Qy,{children:[e.jsx(Zy,{children:d.title}),e.jsxs(Ky,{children:[e.jsx("span",{children:u(d.last_activity_at)}),d.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},d.id))})]})]})})})}const n2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},s2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=nx;exports.AgentConversation=Nd;exports.AgentConversationHistory=Fd;exports.AgentConversationHub=o2;exports.AgentConversationProvider=_u;exports.AuthFormImage=Oe;exports.ChannelSelector=Lb;exports.CreateOrganizationForm=xn;exports.CreateWorkspaceDialog=ad;exports.CreateWorkspaceForm=Gs;exports.DeploymentInitialized=ep;exports.DeploymentInitializing=tp;exports.DeploymentProvider=Gd;exports.Dialog=ze;exports.DialogTrigger=ag;exports.Dropdown=ft;exports.DropdownDivider=mn;exports.DropdownItem=Be;exports.DropdownItems=gt;exports.DropdownTrigger=mt;exports.Form=yt;exports.FormGroup=he;exports.Input=se;exports.Label=ie;exports.MagicLinkVerification=Qm;exports.ManageAccount=Pd;exports.ManageAccountDialog=Id;exports.ManageOrganization=od;exports.ManageWorkspace=cd;exports.ManageWorkspaceDialog=ld;exports.NavigateToSignIn=xb;exports.NavigateToSignUp=vb;exports.NavigationLink=ht;exports.NotificationBell=Od;exports.NotificationItem=Td;exports.NotificationPopover=Md;exports.OAuthProvider=Bc;exports.ORG_ADMIN_PERMISSIONS=ud;exports.ORG_MANAGEMENT_PERMISSIONS=pd;exports.OTPInput=qt;exports.OrganizationSwitcher=md;exports.PhoneNumberInput=oo;exports.PhoneVerification=Yl;exports.ProfileCompletion=Kl;exports.RequireActiveTenancy=Rb;exports.SSOCallback=Um;exports.SignInForm=jm;exports.SignUpForm=Gf;exports.SignedIn=tb;exports.SignedInAccounts=mb;exports.SignedOut=rb;exports.SimpleDialog=sg;exports.Spinner=Re;exports.Switch=mr;exports.TwoFactorMethodSelector=ql;exports.TwoFactorVerification=Zl;exports.UserButton=Ks;exports.UserControls=eb;exports.WORKSPACE_ADMIN_PERMISSIONS=hd;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=fd;exports.WaitlistForm=Lm;exports.canManageOrganization=gd;exports.canManageWorkspace=Es;exports.clearTokenCache=Mt;exports.fetchChannelCounts=Yu;exports.hasIncompleteProfile=Xm;exports.hasOrgPermission=qs;exports.hasWorkspacePermission=Ys;exports.isExternalUrl=n2;exports.isOrgAdmin=nv;exports.isSafeUrl=s2;exports.isWorkspaceAdmin=sv;exports.redirectToProfileCompletion=Jm;exports.useActiveOrganization=st;exports.useActiveTenancy=Hu;exports.useActiveWorkspace=Vt;exports.useAgentConversation=Xc;exports.useAgentConversationContext=rn;exports.useChannelCounts=Ju;exports.useClient=Ke;exports.useConversationSessions=Nc;exports.useDeployment=we;exports.useForgotPassword=Zc;exports.useInvitation=Jc;exports.useMagicLinkParams=Yc;exports.useMagicLinkVerification=qc;exports.useNavigation=rt;exports.useNotificationStream=Kc;exports.useNotifications=Qc;exports.useOrganizationList=on;exports.useOrganizationMemberships=Ot;exports.useSSOCallback=Hc;exports.useSession=Qe;exports.useSignIn=Uc;exports.useSignInWithStrategy=zr;exports.useSignUp=Wc;exports.useUser=Gt;exports.useUserSignins=Vc;exports.useWaitlist=Gc;exports.useWorkspaceList=Wt;exports.useWorkspaceMemberships=nn;Object.keys(da).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>da[t]})});
6190
6192
  //# sourceMappingURL=index.cjs.js.map