@wacht/jsx 1.0.0-beta.64 → 1.0.0-beta.65

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
@@ -83,7 +83,7 @@ If you need access to the theme in an uncertain composition scenario, \`React.us
83
83
  You may see this warning because you've called styled inside another component.
84
84
  To resolve this only create new StyledComponents outside of any render method and function component.
85
85
  See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
86
- `,r=console.error;try{let i=!0;console.error=(l,...m)=>{vi.test(l)?(i=!1,$s.delete(s)):r(l,...m)},typeof o.useState=="function"&&o.useState(null),i&&!$s.has(s)&&(console.warn(s),$s.add(s))}catch(i){vi.test(i.message)&&$s.delete(s)}finally{console.error=r}}},kr=Object.freeze([]),Qa=Object.freeze({});function nc(e,a,s=Qa){return e.theme!==s.theme&&e.theme||a||s.theme}const _8=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,k8=/(^-|-$)/g;function rc(e){return e.replace(_8,"-").replace(k8,"")}const C8=/(a)(d)/gi,bi=e=>String.fromCharCode(e+(e>25?39:97));function ic(e){let a,s="";for(a=Math.abs(e);a>52;a=a/52|0)s=bi(a%52)+s;return(bi(a%52)+s).replace(C8,"$1-$2")}const or=5381,La=(e,a)=>{let s=a.length;for(;s;)e=33*e^a.charCodeAt(--s);return e},oc=e=>La(or,e);function lc(e){return ic(oc(e)>>>0)}function Cr(e){return process.env.NODE_ENV!=="production"&&typeof e=="string"&&e||e.displayName||e.name||"Component"}function Gs(e){return typeof e=="string"&&(process.env.NODE_ENV==="production"||e.charAt(0)===e.charAt(0).toLowerCase())}function N8(e){return Gs(e)?`styled.${e}`:`Styled(${Cr(e)})`}const cc=Symbol.for("react.memo"),S8=Symbol.for("react.forward_ref"),E8={contextType:!0,defaultProps:!0,displayName:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,propTypes:!0,type:!0},A8={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},dc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},M8={[S8]:{$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},[cc]:dc};function yi(e){return("type"in(a=e)&&a.type.$$typeof)===cc?dc:"$$typeof"in e?M8[e.$$typeof]:E8;var a}const R8=Object.defineProperty,L8=Object.getOwnPropertyNames,P8=Object.getOwnPropertySymbols,$8=Object.getOwnPropertyDescriptor,O8=Object.getPrototypeOf,Z8=Object.prototype;function uc(e,a,s){if(typeof a!="string"){const r=O8(a);r&&r!==Z8&&uc(e,r,s);const i=L8(a).concat(P8(a)),l=yi(e),m=yi(a);for(let c=0;c<i.length;++c){const d=i[c];if(!(d in A8||s&&s[d]||m&&d in m||l&&d in l)){const p=$8(a,d);try{R8(e,d,p)}catch{}}}}return e}function bs(e){return typeof e=="function"}function Nr(e){return typeof e=="object"&&"styledComponentId"in e}function ls(e,a){return e&&a?e+" "+a:e||a||""}function lr(e,a){return e.join("")}function Za(e){return e!==null&&typeof e=="object"&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function cr(e,a,s=!1){if(!s&&!Za(e)&&!Array.isArray(e))return a;if(Array.isArray(a))for(let r=0;r<a.length;r++)e[r]=cr(e[r],a[r]);else if(Za(a))for(const r in a)e[r]=cr(e[r],a[r]);return e}function mc(e,a){Object.defineProperty(e,"toString",{value:a})}const H8=class{constructor(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e,this._cGroup=0,this._cIndex=0}indexOfGroup(e){if(e===this._cGroup)return this._cIndex;let a=this._cIndex;if(e>this._cGroup)for(let s=this._cGroup;s<e;s++)a+=this.groupSizes[s];else for(let s=this._cGroup-1;s>=e;s--)a-=this.groupSizes[s];return this._cGroup=e,this._cIndex=a,a}insertRules(e,a){if(e>=this.groupSizes.length){const i=this.groupSizes,l=i.length;let m=l;for(;e>=m;)if(m<<=1,m<0)throw vs(16,`${e}`);this.groupSizes=new Uint32Array(m),this.groupSizes.set(i),this.length=m;for(let c=l;c<m;c++)this.groupSizes[c]=0}let s=this.indexOfGroup(e+1),r=0;for(let i=0,l=a.length;i<l;i++)this.tag.insertRule(s,a[i])&&(this.groupSizes[e]++,s++,r++);r>0&&this._cGroup>e&&(this._cIndex+=r)}clearGroup(e){if(e<this.length){const a=this.groupSizes[e],s=this.indexOfGroup(e),r=s+a;this.groupSizes[e]=0;for(let i=s;i<r;i++)this.tag.deleteRule(s);a>0&&this._cGroup>e&&(this._cIndex-=a)}}getGroup(e){let a="";if(e>=this.length||this.groupSizes[e]===0)return a;const s=this.groupSizes[e],r=this.indexOfGroup(e),i=r+s;for(let l=r;l<i;l++)a+=this.tag.getRule(l)+_r;return a}},F8=`style[${Oa}][${ac}="${un}"]`,T8=new RegExp(`^${Oa}\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)`),ji=e=>typeof ShadowRoot<"u"&&e instanceof ShadowRoot||"host"in e&&e.nodeType===11,dr=e=>{if(!e)return document;if(ji(e))return e;if("getRootNode"in e){const a=e.getRootNode();if(ji(a))return a}return document},I8=(e,a,s)=>{const r=s.split(",");let i;for(let l=0,m=r.length;l<m;l++)(i=r[l])&&e.registerName(a,i)},V8=(e,a)=>{var s;const r=((s=a.textContent)!==null&&s!==void 0?s:"").split(_r),i=[];for(let l=0,m=r.length;l<m;l++){const c=r[l].trim();if(!c)continue;const d=c.match(T8);if(d){const p=0|parseInt(d[1],10),u=d[2];p!==0&&(j8(u,p),I8(e,u,d[3]),e.getTag().insertRules(p,i)),i.length=0}else i.push(c)}},Ln=e=>{const a=dr(e.options.target).querySelectorAll(F8);for(let s=0,r=a.length;s<r;s++){const i=a[s];i&&i.getAttribute(Oa)!==tc&&(V8(e,i),i.parentNode&&i.parentNode.removeChild(i))}};let ns=!1;function z8(){if(ns!==!1)return ns;if(typeof document<"u"){const e=document.head.querySelector('meta[property="csp-nonce"]');if(e)return ns=e.nonce||e.getAttribute("content")||void 0;const a=document.head.querySelector('meta[name="sc-nonce"]');if(a)return ns=a.getAttribute("content")||void 0}return ns=typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0}const pc=(e,a)=>{const s=document.head,r=e||s,i=document.createElement("style"),l=(d=>{const p=Array.from(d.querySelectorAll(`style[${Oa}]`));return p[p.length-1]})(r),m=l!==void 0?l.nextSibling:null;i.setAttribute(Oa,tc),i.setAttribute(ac,un);const c=a||z8();return c&&i.setAttribute("nonce",c),r.insertBefore(i,m),i},D8=class{constructor(e,a){this.element=pc(e,a),this.element.appendChild(document.createTextNode("")),this.sheet=(s=>{var r;if(s.sheet)return s.sheet;const i=(r=s.getRootNode().styleSheets)!==null&&r!==void 0?r:document.styleSheets;for(let l=0,m=i.length;l<m;l++){const c=i[l];if(c.ownerNode===s)return c}throw vs(17)})(this.element),this.length=0}insertRule(e,a){try{return this.sheet.insertRule(a,e),this.length++,!0}catch{return!1}}deleteRule(e){this.sheet.deleteRule(e),this.length--}getRule(e){const a=this.sheet.cssRules[e];return a&&a.cssText?a.cssText:""}},U8=class{constructor(e,a){this.element=pc(e,a),this.nodes=this.element.childNodes,this.length=0}insertRule(e,a){if(e<=this.length&&e>=0){const s=document.createTextNode(a);return this.element.insertBefore(s,this.nodes[e]||null),this.length++,!0}return!1}deleteRule(e){this.element.removeChild(this.nodes[e]),this.length--}getRule(e){return e<this.length?this.nodes[e].textContent:""}};let _i=ms;const W8={isServer:!ms,useCSSOMInjection:!w8};class ys{static registerId(a){return Ps(a)}constructor(a=Qa,s={},r){this.options=Object.assign(Object.assign({},W8),a),this.gs=s,this.keyframeIds=new Set,this.names=new Map(r),this.server=!!a.isServer,!this.server&&ms&&_i&&(_i=!1,Ln(this)),mc(this,()=>(i=>{const l=i.getTag(),{length:m}=l;let c="";for(let d=0;d<m;d++){const p=y8(d);if(p===void 0)continue;const u=i.names.get(p);if(u===void 0||!u.size)continue;const f=l.getGroup(d);if(f.length===0)continue;const h=Oa+".g"+d+'[id="'+p+'"]';let g="";for(const x of u)x.length>0&&(g+=x+",");c+=f+h+'{content:"'+g+'"}'+_r}return c})(this))}rehydrate(){!this.server&&ms&&Ln(this)}reconstructWithOptions(a,s=!0){const r=new ys(Object.assign(Object.assign({},this.options),a),this.gs,s&&this.names||void 0);return r.keyframeIds=new Set(this.keyframeIds),!this.server&&ms&&a.target!==this.options.target&&dr(this.options.target)!==dr(a.target)&&Ln(r),r}allocateGSInstance(a){return this.gs[a]=(this.gs[a]||0)+1}getTag(){return this.tag||(this.tag=(a=(({useCSSOMInjection:s,target:r,nonce:i})=>s?new D8(r,i):new U8(r,i))(this.options),new H8(a)));var a}hasNameForId(a,s){var r,i;return(i=(r=this.names.get(a))===null||r===void 0?void 0:r.has(s))!==null&&i!==void 0&&i}registerName(a,s){Ps(a),a.startsWith(g8)&&this.keyframeIds.add(a);const r=this.names.get(a);r?r.add(s):this.names.set(a,new Set([s]))}insertRules(a,s,r){this.registerName(a,s),this.getTag().insertRules(Ps(a),r)}clearNames(a){this.names.has(a)&&this.names.get(a).clear()}clearRules(a){this.getTag().clearGroup(Ps(a)),this.clearNames(a)}clearTag(){this.tag=void 0}}const hc=new WeakSet,B8={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexShrink:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function G8(e,a){return a==null||typeof a=="boolean"||a===""?"":typeof a!="number"||a===0||e in B8||e.startsWith("--")?String(a).trim():a+"px"}const Sa=47;function ki(e){if(e.charCodeAt(0)===45&&e.charCodeAt(1)===45)return e;let a="";for(let s=0;s<e.length;s++){const r=e.charCodeAt(s);a+=r>=65&&r<=90?"-"+String.fromCharCode(r+32):e[s]}return a.startsWith("ms-")?"-"+a:a}const q8=Symbol.for("sc-keyframes");function ur(e){return typeof e=="object"&&e!==null&&q8 in e}function fc(e){return bs(e)&&!(e.prototype&&e.prototype.isReactComponent)}const wc=e=>e==null||e===!1||e==="",K8=Symbol.for("react.client.reference");function Ci(e){return e.$$typeof===K8}function Ni(e){const a=e.$$id,s=(a&&a.includes("#")?a.split("#").pop():a)||e.name||"unknown";console.warn(`Interpolating a client component (${s}) as a selector is not supported in server components. The component selector pattern requires access to the component's internal class name, which is not available across the server/client boundary. Use a plain CSS class selector instead.`)}function gc(e,a){for(const s in e){const r=e[s];e.hasOwnProperty(s)&&!wc(r)&&(Array.isArray(r)&&hc.has(r)||bs(r)?a.push(ki(s)+":",r,";"):Za(r)?(a.push(s+" {"),gc(r,a),a.push("}")):a.push(ki(s)+": "+G8(s,r)+";"))}}function pa(e,a,s,r,i=[]){if(wc(e))return i;const l=typeof e;if(l==="string")return i.push(e),i;if(l==="function"){if(Ci(e))return process.env.NODE_ENV!=="production"&&Ni(e),i;if(fc(e)&&a){const m=e(a);return process.env.NODE_ENV==="production"||typeof m!="object"||Array.isArray(m)||ur(m)||Za(m)||m===null||console.error(`${Cr(e)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),pa(m,a,s,r,i)}return i.push(e),i}if(Array.isArray(e)){for(let m=0;m<e.length;m++)pa(e[m],a,s,r,i);return i}return Nr(e)?(i.push(`.${e.styledComponentId}`),i):ur(e)?(s?(e.inject(s,r),i.push(e.getName(r))):i.push(e),i):Ci(e)?(process.env.NODE_ENV!=="production"&&Ni(e),i):Za(e)?(gc(e,i),i):(i.push(e.toString()),i)}const Y8=oc(un);class Q8{constructor(a,s,r){this.rules=a,this.componentId=s,this.baseHash=La(Y8,s),this.baseStyle=r,ys.registerId(s)}generateAndInjectStyles(a,s,r){let i=this.baseStyle?this.baseStyle.generateAndInjectStyles(a,s,r):"";{let l="";for(let m=0;m<this.rules.length;m++){const c=this.rules[m];if(typeof c=="string")l+=c;else if(c)if(fc(c)){const d=c(a);typeof d=="string"?l+=d:d!=null&&d!==!1&&(process.env.NODE_ENV==="production"||typeof d!="object"||Array.isArray(d)||ur(d)||Za(d)||console.error(`${Cr(c)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),l+=lr(pa(d,a,s,r)))}else l+=lr(pa(c,a,s,r))}if(l){this.dynamicNameCache||(this.dynamicNameCache=new Map);const m=r.hash?r.hash+l:l;let c=this.dynamicNameCache.get(m);if(!c){if(c=ic(La(La(this.baseHash,r.hash),l)>>>0),this.dynamicNameCache.size>=200){const d=this.dynamicNameCache.keys().next().value;d!==void 0&&this.dynamicNameCache.delete(d)}this.dynamicNameCache.set(m,c)}if(!s.hasNameForId(this.componentId,c)){const d=r(l,"."+c,void 0,this.componentId);s.insertRules(this.componentId,c,d)}i=ls(i,c)}}return i}}const J8=/&/g;function xc(e,a){let s=0;for(;--a>=0&&e.charCodeAt(a)===92;)s++;return!(1&~s)}function Pn(e){const a=e.length;let s="",r=0,i=0,l=0,m=!1,c=!1;for(let d=0;d<a;d++){const p=e.charCodeAt(d);if(l!==0||m||p!==Sa||e.charCodeAt(d+1)!==42)if(m)p===42&&e.charCodeAt(d+1)===Sa&&(m=!1,d++);else if(p!==34&&p!==39||xc(e,d)){if(l===0)if(p===123)i++;else if(p===125){if(i--,i<0){c=!0;let u=d+1;for(;u<a;){const f=e.charCodeAt(u);if(f===59||f===10)break;u++}u<a&&e.charCodeAt(u)===59&&u++,i=0,d=u-1,r=u;continue}i===0&&(s+=e.substring(r,d+1),r=d+1)}else p===59&&i===0&&(s+=e.substring(r,d+1),r=d+1)}else l===0?l=p:l===p&&(l=0);else m=!0,d++}return c||i!==0||l!==0?(r<a&&i===0&&l===0&&(s+=e.substring(r)),s):e}function vc(e,a){const s=a+" ",r=","+s;for(let i=0;i<e.length;i++){const l=e[i];if(l.type==="rule"){l.value=(s+l.value).replaceAll(",",r);const m=l.props,c=[];for(let d=0;d<m.length;d++)c[d]=s+m[d];l.props=c}Array.isArray(l.children)&&l.type!=="@keyframes"&&vc(l.children,a)}return e}function X8({options:e=Qa,plugins:a=kr}=Qa){let s,r,i;const l=(h,g,x)=>x.startsWith(r)&&x.endsWith(r)&&x.replaceAll(r,"").length>0?`.${s}`:h,m=a.slice();m.push(h=>{h.type===on&&h.value.includes("&")&&(i||(i=new RegExp(`\\${r}\\b`,"g")),h.props[0]=h.props[0].replace(J8,r).replace(i,l))}),e.prefix&&m.push(f8),m.push(m8);let c=[];const d=p8(m.concat(h8(h=>c.push(h)))),p=(h,g="",x="",w="&")=>{s=w,r=g,i=void 0;const b=(function(v){const k=v.indexOf("//")!==-1,N=v.indexOf("}")!==-1;if(!k&&!N)return v;if(!k)return Pn(v);const _=v.length;let C="",y=0,E=0,M=0,F=0,A=0,T=!1;for(;E<_;){const P=v.charCodeAt(E);if(P!==34&&P!==39||xc(v,E))if(M===0)if(P===Sa&&E+1<_&&v.charCodeAt(E+1)===42){for(E+=2;E+1<_&&(v.charCodeAt(E)!==42||v.charCodeAt(E+1)!==Sa);)E++;E+=2}else if(P!==40)if(P!==41)if(F>0)E++;else if(P===42&&E+1<_&&v.charCodeAt(E+1)===Sa)C+=v.substring(y,E),E+=2,y=E,T=!0;else if(P===Sa&&E+1<_&&v.charCodeAt(E+1)===Sa){for(C+=v.substring(y,E);E<_&&v.charCodeAt(E)!==10;)E++;y=E,T=!0}else P===123?A++:P===125&&A--,E++;else F>0&&F--,E++;else F++,E++;else E++;else M===0?M=P:M===P&&(M=0),E++}return T?(y<_&&(C+=v.substring(y)),A===0?C:Pn(C)):A===0?v:Pn(v)})(h);let j=d8(x||g?x+" "+g+" { "+b+" }":b);return e.namespace&&(j=vc(j,e.namespace)),c=[],Ys(j,d),c},u=e;let f=or;for(let h=0;h<a.length;h++)a[h].name||vs(15),f=La(f,a[h].name);return u!=null&&u.namespace&&(f=La(f,u.namespace)),u!=null&&u.prefix&&(f=La(f,"p")),p.hash=f!==or?f.toString():"",p}const e4=new ys,t4=X8(),bc=o.createContext({shouldForwardProp:void 0,styleSheet:e4,stylis:t4,stylisPlugins:void 0});bc.Consumer;function yc(){return o.useContext(bc)}const Sr=o.createContext(void 0);Sr.Consumer;const Si=Object.prototype.hasOwnProperty,$n={};function a4(e,a){const s=typeof e!="string"?"sc":rc(e);$n[s]=($n[s]||0)+1;const r=s+"-"+lc(un+s+$n[s]);return a?a+"-"+r:r}let On;function s4(e,a,s){const r=Nr(e),i=e,l=!Gs(e),{attrs:m=kr,componentId:c=a4(a.displayName,a.parentComponentId),displayName:d=N8(e)}=a,p=a.displayName&&a.componentId?rc(a.displayName)+"-"+a.componentId:a.componentId||c,u=r&&i.attrs?i.attrs.concat(m).filter(Boolean):m;let{shouldForwardProp:f}=a;if(r&&i.shouldForwardProp){const w=i.shouldForwardProp;if(a.shouldForwardProp){const b=a.shouldForwardProp;f=(j,v)=>w(j,v)&&b(j,v)}else f=w}const h=new Q8(s,p,r?i.componentStyle:void 0);function g(w,b){return(function(j,v,k){const{attrs:N,componentStyle:_,defaultProps:C,foldedComponentIds:y,styledComponentId:E,target:M}=j,F=o.useContext(Sr),A=yc(),T=j.shouldForwardProp||A.shouldForwardProp;process.env.NODE_ENV!=="production"&&o.useDebugValue&&o.useDebugValue(E);const P=nc(v,F,C)||Qa;let S,$;{const Z=o.useRef(null),L=Z.current;if(L!==null&&L[1]===P&&L[2]===A.styleSheet&&L[3]===A.stylis&&L[7]===_&&(function(U,D,Y){const B=U,Q=D;let ue=0;for(const we in Q)if(Si.call(Q,we)&&(ue++,B[we]!==Q[we]))return!1;return ue===Y})(L[0],v,L[4]))S=L[5],$=L[6];else{S=(function(D,Y,B){const Q=Object.assign(Object.assign({},Y),{className:void 0,theme:B}),ue=D.length>1;for(let we=0;we<D.length;we++){const ne=D[we],ae=bs(ne)?ne(ue?Object.assign({},Q):Q):ne;for(const re in ae)re==="className"?Q.className=ls(Q.className,ae[re]):re==="style"?Q.style=Object.assign(Object.assign({},Q.style),ae[re]):re in Y&&Y[re]===void 0||(Q[re]=ae[re])}return"className"in Y&&typeof Y.className=="string"&&(Q.className=ls(Q.className,Y.className)),Q})(N,v,P),$=(function(D,Y,B,Q){const ue=D.generateAndInjectStyles(Y,B,Q);return process.env.NODE_ENV!=="production"&&o.useDebugValue&&o.useDebugValue(ue),ue})(_,S,A.styleSheet,A.stylis);let U=0;for(const D in v)Si.call(v,D)&&U++;Z.current=[v,P,A.styleSheet,A.stylis,U,S,$,_]}}process.env.NODE_ENV!=="production"&&j.warnTooManyClasses&&j.warnTooManyClasses($);const H=S.as||M,R=(function(Z,L,U,D){const Y={};for(const B in Z)Z[B]===void 0||B[0]==="$"||B==="as"||B==="theme"&&Z.theme===U||(B==="forwardedAs"?Y.as=Z.forwardedAs:D&&!D(B,L)||(Y[B]=Z[B],D||process.env.NODE_ENV!=="development"||Yu(B)||(On||(On=new Set)).has(B)||!Gs(L)||L.includes("-")||(On.add(B),console.warn(`styled-components: it looks like an unknown prop "${B}" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via \`<StyleSheetManager shouldForwardProp={...}>\` (connect an API like \`@emotion/is-prop-valid\`) or consider using transient props (\`$\` prefix for automatic filtering.)`))));return Y})(S,H,P,T);let O=ls(y,E);return $&&(O+=" "+$),S.className&&(O+=" "+S.className),R[Gs(H)&&H.includes("-")?"class":"className"]=O,k&&(R.ref=k),o.createElement(H,R)})(x,w,b)}g.displayName=d;let x=o.forwardRef(g);return x.attrs=u,x.componentStyle=h,x.displayName=d,x.shouldForwardProp=f,x.foldedComponentIds=r?ls(i.foldedComponentIds,i.styledComponentId):"",x.styledComponentId=p,x.target=r?i.target:e,Object.defineProperty(x,"defaultProps",{get(){return this._foldedDefaultProps},set(w){this._foldedDefaultProps=r?(function(b,...j){for(const v of j)cr(b,v,!0);return b})({},i.defaultProps,w):w}}),process.env.NODE_ENV!=="production"&&(sc(d,p),x.warnTooManyClasses=((w,b)=>{let j={},v=!1;return k=>{!v&&(j[k]=!0,Object.keys(j).length>=200)&&(console.warn(`Over 200 classes were generated for component ${w}${b?` with the id of "${b}"`:""}.
86
+ `,r=console.error;try{let i=!0;console.error=(l,...m)=>{vi.test(l)?(i=!1,$s.delete(s)):r(l,...m)},typeof o.useState=="function"&&o.useState(null),i&&!$s.has(s)&&(console.warn(s),$s.add(s))}catch(i){vi.test(i.message)&&$s.delete(s)}finally{console.error=r}}},kr=Object.freeze([]),Qa=Object.freeze({});function nc(e,a,s=Qa){return e.theme!==s.theme&&e.theme||a||s.theme}const _8=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,k8=/(^-|-$)/g;function rc(e){return e.replace(_8,"-").replace(k8,"")}const C8=/(a)(d)/gi,bi=e=>String.fromCharCode(e+(e>25?39:97));function ic(e){let a,s="";for(a=Math.abs(e);a>52;a=a/52|0)s=bi(a%52)+s;return(bi(a%52)+s).replace(C8,"$1-$2")}const or=5381,La=(e,a)=>{let s=a.length;for(;s;)e=33*e^a.charCodeAt(--s);return e},oc=e=>La(or,e);function lc(e){return ic(oc(e)>>>0)}function Cr(e){return process.env.NODE_ENV!=="production"&&typeof e=="string"&&e||e.displayName||e.name||"Component"}function Gs(e){return typeof e=="string"&&(process.env.NODE_ENV==="production"||e.charAt(0)===e.charAt(0).toLowerCase())}function N8(e){return Gs(e)?`styled.${e}`:`Styled(${Cr(e)})`}const cc=Symbol.for("react.memo"),S8=Symbol.for("react.forward_ref"),E8={contextType:!0,defaultProps:!0,displayName:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,propTypes:!0,type:!0},A8={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},dc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},M8={[S8]:{$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},[cc]:dc};function yi(e){return("type"in(a=e)&&a.type.$$typeof)===cc?dc:"$$typeof"in e?M8[e.$$typeof]:E8;var a}const R8=Object.defineProperty,L8=Object.getOwnPropertyNames,P8=Object.getOwnPropertySymbols,$8=Object.getOwnPropertyDescriptor,O8=Object.getPrototypeOf,Z8=Object.prototype;function uc(e,a,s){if(typeof a!="string"){const r=O8(a);r&&r!==Z8&&uc(e,r,s);const i=L8(a).concat(P8(a)),l=yi(e),m=yi(a);for(let c=0;c<i.length;++c){const d=i[c];if(!(d in A8||s&&s[d]||m&&d in m||l&&d in l)){const p=$8(a,d);try{R8(e,d,p)}catch{}}}}return e}function bs(e){return typeof e=="function"}function Nr(e){return typeof e=="object"&&"styledComponentId"in e}function ls(e,a){return e&&a?e+" "+a:e||a||""}function lr(e,a){return e.join("")}function Za(e){return e!==null&&typeof e=="object"&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function cr(e,a,s=!1){if(!s&&!Za(e)&&!Array.isArray(e))return a;if(Array.isArray(a))for(let r=0;r<a.length;r++)e[r]=cr(e[r],a[r]);else if(Za(a))for(const r in a)e[r]=cr(e[r],a[r]);return e}function mc(e,a){Object.defineProperty(e,"toString",{value:a})}const H8=class{constructor(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e,this._cGroup=0,this._cIndex=0}indexOfGroup(e){if(e===this._cGroup)return this._cIndex;let a=this._cIndex;if(e>this._cGroup)for(let s=this._cGroup;s<e;s++)a+=this.groupSizes[s];else for(let s=this._cGroup-1;s>=e;s--)a-=this.groupSizes[s];return this._cGroup=e,this._cIndex=a,a}insertRules(e,a){if(e>=this.groupSizes.length){const i=this.groupSizes,l=i.length;let m=l;for(;e>=m;)if(m<<=1,m<0)throw vs(16,`${e}`);this.groupSizes=new Uint32Array(m),this.groupSizes.set(i),this.length=m;for(let c=l;c<m;c++)this.groupSizes[c]=0}let s=this.indexOfGroup(e+1),r=0;for(let i=0,l=a.length;i<l;i++)this.tag.insertRule(s,a[i])&&(this.groupSizes[e]++,s++,r++);r>0&&this._cGroup>e&&(this._cIndex+=r)}clearGroup(e){if(e<this.length){const a=this.groupSizes[e],s=this.indexOfGroup(e),r=s+a;this.groupSizes[e]=0;for(let i=s;i<r;i++)this.tag.deleteRule(s);a>0&&this._cGroup>e&&(this._cIndex-=a)}}getGroup(e){let a="";if(e>=this.length||this.groupSizes[e]===0)return a;const s=this.groupSizes[e],r=this.indexOfGroup(e),i=r+s;for(let l=r;l<i;l++)a+=this.tag.getRule(l)+_r;return a}},F8=`style[${Oa}][${ac}="${un}"]`,T8=new RegExp(`^${Oa}\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)`),ji=e=>typeof ShadowRoot<"u"&&e instanceof ShadowRoot||"host"in e&&e.nodeType===11,dr=e=>{if(!e)return document;if(ji(e))return e;if("getRootNode"in e){const a=e.getRootNode();if(ji(a))return a}return document},I8=(e,a,s)=>{const r=s.split(",");let i;for(let l=0,m=r.length;l<m;l++)(i=r[l])&&e.registerName(a,i)},V8=(e,a)=>{var s;const r=((s=a.textContent)!==null&&s!==void 0?s:"").split(_r),i=[];for(let l=0,m=r.length;l<m;l++){const c=r[l].trim();if(!c)continue;const d=c.match(T8);if(d){const p=0|parseInt(d[1],10),u=d[2];p!==0&&(j8(u,p),I8(e,u,d[3]),e.getTag().insertRules(p,i)),i.length=0}else i.push(c)}},Ln=e=>{const a=dr(e.options.target).querySelectorAll(F8);for(let s=0,r=a.length;s<r;s++){const i=a[s];i&&i.getAttribute(Oa)!==tc&&(V8(e,i),i.parentNode&&i.parentNode.removeChild(i))}};let ns=!1;function z8(){if(ns!==!1)return ns;if(typeof document<"u"){const e=document.head.querySelector('meta[property="csp-nonce"]');if(e)return ns=e.nonce||e.getAttribute("content")||void 0;const a=document.head.querySelector('meta[name="sc-nonce"]');if(a)return ns=a.getAttribute("content")||void 0}return ns=typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0}const pc=(e,a)=>{const s=document.head,r=e||s,i=document.createElement("style"),l=(d=>{const p=Array.from(d.querySelectorAll(`style[${Oa}]`));return p[p.length-1]})(r),m=l!==void 0?l.nextSibling:null;i.setAttribute(Oa,tc),i.setAttribute(ac,un);const c=a||z8();return c&&i.setAttribute("nonce",c),r.insertBefore(i,m),i},D8=class{constructor(e,a){this.element=pc(e,a),this.element.appendChild(document.createTextNode("")),this.sheet=(s=>{var r;if(s.sheet)return s.sheet;const i=(r=s.getRootNode().styleSheets)!==null&&r!==void 0?r:document.styleSheets;for(let l=0,m=i.length;l<m;l++){const c=i[l];if(c.ownerNode===s)return c}throw vs(17)})(this.element),this.length=0}insertRule(e,a){try{return this.sheet.insertRule(a,e),this.length++,!0}catch{return!1}}deleteRule(e){this.sheet.deleteRule(e),this.length--}getRule(e){const a=this.sheet.cssRules[e];return a&&a.cssText?a.cssText:""}},U8=class{constructor(e,a){this.element=pc(e,a),this.nodes=this.element.childNodes,this.length=0}insertRule(e,a){if(e<=this.length&&e>=0){const s=document.createTextNode(a);return this.element.insertBefore(s,this.nodes[e]||null),this.length++,!0}return!1}deleteRule(e){this.element.removeChild(this.nodes[e]),this.length--}getRule(e){return e<this.length?this.nodes[e].textContent:""}};let _i=ms;const W8={isServer:!ms,useCSSOMInjection:!w8};class ys{static registerId(a){return Ps(a)}constructor(a=Qa,s={},r){this.options=Object.assign(Object.assign({},W8),a),this.gs=s,this.keyframeIds=new Set,this.names=new Map(r),this.server=!!a.isServer,!this.server&&ms&&_i&&(_i=!1,Ln(this)),mc(this,()=>(i=>{const l=i.getTag(),{length:m}=l;let c="";for(let d=0;d<m;d++){const p=y8(d);if(p===void 0)continue;const u=i.names.get(p);if(u===void 0||!u.size)continue;const f=l.getGroup(d);if(f.length===0)continue;const h=Oa+".g"+d+'[id="'+p+'"]';let g="";for(const x of u)x.length>0&&(g+=x+",");c+=f+h+'{content:"'+g+'"}'+_r}return c})(this))}rehydrate(){!this.server&&ms&&Ln(this)}reconstructWithOptions(a,s=!0){const r=new ys(Object.assign(Object.assign({},this.options),a),this.gs,s&&this.names||void 0);return r.keyframeIds=new Set(this.keyframeIds),!this.server&&ms&&a.target!==this.options.target&&dr(this.options.target)!==dr(a.target)&&Ln(r),r}allocateGSInstance(a){return this.gs[a]=(this.gs[a]||0)+1}getTag(){return this.tag||(this.tag=(a=(({useCSSOMInjection:s,target:r,nonce:i})=>s?new D8(r,i):new U8(r,i))(this.options),new H8(a)));var a}hasNameForId(a,s){var r,i;return(i=(r=this.names.get(a))===null||r===void 0?void 0:r.has(s))!==null&&i!==void 0&&i}registerName(a,s){Ps(a),a.startsWith(g8)&&this.keyframeIds.add(a);const r=this.names.get(a);r?r.add(s):this.names.set(a,new Set([s]))}insertRules(a,s,r){this.registerName(a,s),this.getTag().insertRules(Ps(a),r)}clearNames(a){this.names.has(a)&&this.names.get(a).clear()}clearRules(a){this.getTag().clearGroup(Ps(a)),this.clearNames(a)}clearTag(){this.tag=void 0}}const hc=new WeakSet,B8={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexShrink:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function G8(e,a){return a==null||typeof a=="boolean"||a===""?"":typeof a!="number"||a===0||e in B8||e.startsWith("--")?String(a).trim():a+"px"}const Sa=47;function ki(e){if(e.charCodeAt(0)===45&&e.charCodeAt(1)===45)return e;let a="";for(let s=0;s<e.length;s++){const r=e.charCodeAt(s);a+=r>=65&&r<=90?"-"+String.fromCharCode(r+32):e[s]}return a.startsWith("ms-")?"-"+a:a}const q8=Symbol.for("sc-keyframes");function ur(e){return typeof e=="object"&&e!==null&&q8 in e}function fc(e){return bs(e)&&!(e.prototype&&e.prototype.isReactComponent)}const wc=e=>e==null||e===!1||e==="",K8=Symbol.for("react.client.reference");function Ci(e){return e.$$typeof===K8}function Ni(e){const a=e.$$id,s=(a&&a.includes("#")?a.split("#").pop():a)||e.name||"unknown";console.warn(`Interpolating a client component (${s}) as a selector is not supported in server components. The component selector pattern requires access to the component's internal class name, which is not available across the server/client boundary. Use a plain CSS class selector instead.`)}function gc(e,a){for(const s in e){const r=e[s];e.hasOwnProperty(s)&&!wc(r)&&(Array.isArray(r)&&hc.has(r)||bs(r)?a.push(ki(s)+":",r,";"):Za(r)?(a.push(s+" {"),gc(r,a),a.push("}")):a.push(ki(s)+": "+G8(s,r)+";"))}}function pa(e,a,s,r,i=[]){if(wc(e))return i;const l=typeof e;if(l==="string")return i.push(e),i;if(l==="function"){if(Ci(e))return process.env.NODE_ENV!=="production"&&Ni(e),i;if(fc(e)&&a){const m=e(a);return process.env.NODE_ENV==="production"||typeof m!="object"||Array.isArray(m)||ur(m)||Za(m)||m===null||console.error(`${Cr(e)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),pa(m,a,s,r,i)}return i.push(e),i}if(Array.isArray(e)){for(let m=0;m<e.length;m++)pa(e[m],a,s,r,i);return i}return Nr(e)?(i.push(`.${e.styledComponentId}`),i):ur(e)?(s?(e.inject(s,r),i.push(e.getName(r))):i.push(e),i):Ci(e)?(process.env.NODE_ENV!=="production"&&Ni(e),i):Za(e)?(gc(e,i),i):(i.push(e.toString()),i)}const Y8=oc(un);class Q8{constructor(a,s,r){this.rules=a,this.componentId=s,this.baseHash=La(Y8,s),this.baseStyle=r,ys.registerId(s)}generateAndInjectStyles(a,s,r){let i=this.baseStyle?this.baseStyle.generateAndInjectStyles(a,s,r):"";{let l="";for(let m=0;m<this.rules.length;m++){const c=this.rules[m];if(typeof c=="string")l+=c;else if(c)if(fc(c)){const d=c(a);typeof d=="string"?l+=d:d!=null&&d!==!1&&(process.env.NODE_ENV==="production"||typeof d!="object"||Array.isArray(d)||ur(d)||Za(d)||console.error(`${Cr(c)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),l+=lr(pa(d,a,s,r)))}else l+=lr(pa(c,a,s,r))}if(l){this.dynamicNameCache||(this.dynamicNameCache=new Map);const m=r.hash?r.hash+l:l;let c=this.dynamicNameCache.get(m);if(!c){if(c=ic(La(La(this.baseHash,r.hash),l)>>>0),this.dynamicNameCache.size>=200){const d=this.dynamicNameCache.keys().next().value;d!==void 0&&this.dynamicNameCache.delete(d)}this.dynamicNameCache.set(m,c)}if(!s.hasNameForId(this.componentId,c)){const d=r(l,"."+c,void 0,this.componentId);s.insertRules(this.componentId,c,d)}i=ls(i,c)}}return i}}const J8=/&/g;function xc(e,a){let s=0;for(;--a>=0&&e.charCodeAt(a)===92;)s++;return!(1&~s)}function Pn(e){const a=e.length;let s="",r=0,i=0,l=0,m=!1,c=!1;for(let d=0;d<a;d++){const p=e.charCodeAt(d);if(l!==0||m||p!==Sa||e.charCodeAt(d+1)!==42)if(m)p===42&&e.charCodeAt(d+1)===Sa&&(m=!1,d++);else if(p!==34&&p!==39||xc(e,d)){if(l===0)if(p===123)i++;else if(p===125){if(i--,i<0){c=!0;let u=d+1;for(;u<a;){const f=e.charCodeAt(u);if(f===59||f===10)break;u++}u<a&&e.charCodeAt(u)===59&&u++,i=0,d=u-1,r=u;continue}i===0&&(s+=e.substring(r,d+1),r=d+1)}else p===59&&i===0&&(s+=e.substring(r,d+1),r=d+1)}else l===0?l=p:l===p&&(l=0);else m=!0,d++}return c||i!==0||l!==0?(r<a&&i===0&&l===0&&(s+=e.substring(r)),s):e}function vc(e,a){const s=a+" ",r=","+s;for(let i=0;i<e.length;i++){const l=e[i];if(l.type==="rule"){l.value=(s+l.value).replaceAll(",",r);const m=l.props,c=[];for(let d=0;d<m.length;d++)c[d]=s+m[d];l.props=c}Array.isArray(l.children)&&l.type!=="@keyframes"&&vc(l.children,a)}return e}function X8({options:e=Qa,plugins:a=kr}=Qa){let s,r,i;const l=(h,g,x)=>x.startsWith(r)&&x.endsWith(r)&&x.replaceAll(r,"").length>0?`.${s}`:h,m=a.slice();m.push(h=>{h.type===on&&h.value.includes("&")&&(i||(i=new RegExp(`\\${r}\\b`,"g")),h.props[0]=h.props[0].replace(J8,r).replace(i,l))}),e.prefix&&m.push(f8),m.push(m8);let c=[];const d=p8(m.concat(h8(h=>c.push(h)))),p=(h,g="",x="",w="&")=>{s=w,r=g,i=void 0;const b=(function(v){const k=v.indexOf("//")!==-1,N=v.indexOf("}")!==-1;if(!k&&!N)return v;if(!k)return Pn(v);const _=v.length;let C="",y=0,E=0,M=0,F=0,A=0,T=!1;for(;E<_;){const P=v.charCodeAt(E);if(P!==34&&P!==39||xc(v,E))if(M===0)if(P===Sa&&E+1<_&&v.charCodeAt(E+1)===42){for(E+=2;E+1<_&&(v.charCodeAt(E)!==42||v.charCodeAt(E+1)!==Sa);)E++;E+=2}else if(P!==40)if(P!==41)if(F>0)E++;else if(P===42&&E+1<_&&v.charCodeAt(E+1)===Sa)C+=v.substring(y,E),E+=2,y=E,T=!0;else if(P===Sa&&E+1<_&&v.charCodeAt(E+1)===Sa){for(C+=v.substring(y,E);E<_&&v.charCodeAt(E)!==10;)E++;y=E,T=!0}else P===123?A++:P===125&&A--,E++;else F>0&&F--,E++;else F++,E++;else E++;else M===0?M=P:M===P&&(M=0),E++}return T?(y<_&&(C+=v.substring(y)),A===0?C:Pn(C)):A===0?v:Pn(v)})(h);let j=d8(x||g?x+" "+g+" { "+b+" }":b);return e.namespace&&(j=vc(j,e.namespace)),c=[],Ys(j,d),c},u=e;let f=or;for(let h=0;h<a.length;h++)a[h].name||vs(15),f=La(f,a[h].name);return u!=null&&u.namespace&&(f=La(f,u.namespace)),u!=null&&u.prefix&&(f=La(f,"p")),p.hash=f!==or?f.toString():"",p}const em=new ys,tm=X8(),bc=o.createContext({shouldForwardProp:void 0,styleSheet:em,stylis:tm,stylisPlugins:void 0});bc.Consumer;function yc(){return o.useContext(bc)}const Sr=o.createContext(void 0);Sr.Consumer;const Si=Object.prototype.hasOwnProperty,$n={};function am(e,a){const s=typeof e!="string"?"sc":rc(e);$n[s]=($n[s]||0)+1;const r=s+"-"+lc(un+s+$n[s]);return a?a+"-"+r:r}let On;function sm(e,a,s){const r=Nr(e),i=e,l=!Gs(e),{attrs:m=kr,componentId:c=am(a.displayName,a.parentComponentId),displayName:d=N8(e)}=a,p=a.displayName&&a.componentId?rc(a.displayName)+"-"+a.componentId:a.componentId||c,u=r&&i.attrs?i.attrs.concat(m).filter(Boolean):m;let{shouldForwardProp:f}=a;if(r&&i.shouldForwardProp){const w=i.shouldForwardProp;if(a.shouldForwardProp){const b=a.shouldForwardProp;f=(j,v)=>w(j,v)&&b(j,v)}else f=w}const h=new Q8(s,p,r?i.componentStyle:void 0);function g(w,b){return(function(j,v,k){const{attrs:N,componentStyle:_,defaultProps:C,foldedComponentIds:y,styledComponentId:E,target:M}=j,F=o.useContext(Sr),A=yc(),T=j.shouldForwardProp||A.shouldForwardProp;process.env.NODE_ENV!=="production"&&o.useDebugValue&&o.useDebugValue(E);const P=nc(v,F,C)||Qa;let S,$;{const Z=o.useRef(null),L=Z.current;if(L!==null&&L[1]===P&&L[2]===A.styleSheet&&L[3]===A.stylis&&L[7]===_&&(function(U,D,Y){const B=U,Q=D;let ue=0;for(const we in Q)if(Si.call(Q,we)&&(ue++,B[we]!==Q[we]))return!1;return ue===Y})(L[0],v,L[4]))S=L[5],$=L[6];else{S=(function(D,Y,B){const Q=Object.assign(Object.assign({},Y),{className:void 0,theme:B}),ue=D.length>1;for(let we=0;we<D.length;we++){const ne=D[we],ae=bs(ne)?ne(ue?Object.assign({},Q):Q):ne;for(const re in ae)re==="className"?Q.className=ls(Q.className,ae[re]):re==="style"?Q.style=Object.assign(Object.assign({},Q.style),ae[re]):re in Y&&Y[re]===void 0||(Q[re]=ae[re])}return"className"in Y&&typeof Y.className=="string"&&(Q.className=ls(Q.className,Y.className)),Q})(N,v,P),$=(function(D,Y,B,Q){const ue=D.generateAndInjectStyles(Y,B,Q);return process.env.NODE_ENV!=="production"&&o.useDebugValue&&o.useDebugValue(ue),ue})(_,S,A.styleSheet,A.stylis);let U=0;for(const D in v)Si.call(v,D)&&U++;Z.current=[v,P,A.styleSheet,A.stylis,U,S,$,_]}}process.env.NODE_ENV!=="production"&&j.warnTooManyClasses&&j.warnTooManyClasses($);const H=S.as||M,R=(function(Z,L,U,D){const Y={};for(const B in Z)Z[B]===void 0||B[0]==="$"||B==="as"||B==="theme"&&Z.theme===U||(B==="forwardedAs"?Y.as=Z.forwardedAs:D&&!D(B,L)||(Y[B]=Z[B],D||process.env.NODE_ENV!=="development"||Yu(B)||(On||(On=new Set)).has(B)||!Gs(L)||L.includes("-")||(On.add(B),console.warn(`styled-components: it looks like an unknown prop "${B}" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via \`<StyleSheetManager shouldForwardProp={...}>\` (connect an API like \`@emotion/is-prop-valid\`) or consider using transient props (\`$\` prefix for automatic filtering.)`))));return Y})(S,H,P,T);let O=ls(y,E);return $&&(O+=" "+$),S.className&&(O+=" "+S.className),R[Gs(H)&&H.includes("-")?"class":"className"]=O,k&&(R.ref=k),o.createElement(H,R)})(x,w,b)}g.displayName=d;let x=o.forwardRef(g);return x.attrs=u,x.componentStyle=h,x.displayName=d,x.shouldForwardProp=f,x.foldedComponentIds=r?ls(i.foldedComponentIds,i.styledComponentId):"",x.styledComponentId=p,x.target=r?i.target:e,Object.defineProperty(x,"defaultProps",{get(){return this._foldedDefaultProps},set(w){this._foldedDefaultProps=r?(function(b,...j){for(const v of j)cr(b,v,!0);return b})({},i.defaultProps,w):w}}),process.env.NODE_ENV!=="production"&&(sc(d,p),x.warnTooManyClasses=((w,b)=>{let j={},v=!1;return k=>{!v&&(j[k]=!0,Object.keys(j).length>=200)&&(console.warn(`Over 200 classes were generated for component ${w}${b?` with the id of "${b}"`:""}.
87
87
  Consider using the attrs method, together with a style object for frequently changed styles.
88
88
  Example:
89
89
  const Component = styled.div.attrs(props => ({
@@ -92,20 +92,20 @@ Example:
92
92
  },
93
93
  }))\`width: 100%;\`
94
94
 
95
- <Component />`),v=!0,j={})}})(d,p)),mc(x,()=>`.${x.styledComponentId}`),l&&uc(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}var n4=new Set(["a","abbr","address","area","article","aside","audio","b","bdi","bdo","blockquote","body","button","br","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","slot","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","tspan","use"]);function Ei(e,a){const s=[e[0]];for(let r=0,i=a.length;r<i;r+=1)s.push(a[r],e[r+1]);return s}const Ai=e=>(hc.add(e),e);function jc(e,...a){if(bs(e)||Za(e))return Ai(pa(Ei(kr,[e,...a])));const s=e;return a.length===0&&s.length===1&&typeof s[0]=="string"?pa(s):Ai(pa(Ei(s,a)))}function mr(e,a,s=Qa){if(!a)throw vs(1,a);const r=(i,...l)=>e(a,s,jc(i,...l));return r.attrs=i=>mr(e,a,Object.assign(Object.assign({},s),{attrs:Array.prototype.concat(s.attrs,i).filter(Boolean)})),r.withConfig=i=>mr(e,a,Object.assign(Object.assign({},s),i)),r}const _c=e=>mr(s4,e),r4=_c;n4.forEach(e=>{r4[e]=_c(e)});class i4{constructor(a,s){this.instanceRules=new Map,this.rules=a,this.componentId=s,this.isStatic=(function(r){for(let i=0;i<r.length;i+=1){const l=r[i];if(bs(l)&&!Nr(l))return!1}return!0})(a),ys.registerId(this.componentId)}removeStyles(a,s){this.instanceRules.delete(a),this.rebuildGroup(s)}renderStyles(a,s,r,i){const l=this.componentId;if(this.isStatic){if(r.hasNameForId(l,l+a))this.instanceRules.has(a)||this.computeRules(a,s,r,i);else{const c=this.computeRules(a,s,r,i);r.insertRules(l,c.name,c.rules)}return}const m=this.instanceRules.get(a);if(this.computeRules(a,s,r,i),!r.server&&m){const c=m.rules,d=this.instanceRules.get(a).rules;if(c.length===d.length){let p=!0;for(let u=0;u<c.length;u++)if(c[u]!==d[u]){p=!1;break}if(p)return}}this.rebuildGroup(r)}computeRules(a,s,r,i){const l=lr(pa(this.rules,s,r,i)),m={name:this.componentId+a,rules:i(l,"")};return this.instanceRules.set(a,m),m}rebuildGroup(a){const s=this.componentId;a.clearRules(s);for(const r of this.instanceRules.values())a.insertRules(s,r.name,r.rules)}}function o4(e,...a){const s=jc(e,...a),r=`sc-global-${lc(JSON.stringify(s))}`,i=new i4(s,r);process.env.NODE_ENV!=="production"&&sc(r);const l=c=>{const d=yc(),p=o.useContext(Sr);let u;{const f=o.useRef(null);f.current===null&&(f.current=d.styleSheet.allocateGSInstance(r)),u=f.current}process.env.NODE_ENV!=="production"&&o.Children.count(c.children)&&console.warn(`The global style component ${r} was given child JSX. createGlobalStyle does not render children.`),process.env.NODE_ENV!=="production"&&s.some(f=>typeof f=="string"&&f.indexOf("@import")!==-1)&&console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app."),d.styleSheet.server&&m(u,c,d.styleSheet,p,d.stylis);{const f=i.isStatic?[u,d.styleSheet,i]:[u,c,d.styleSheet,p,d.stylis,i],h=o.useRef(i);o.useLayoutEffect(()=>{d.styleSheet.server||(h.current!==i&&(d.styleSheet.clearRules(r),h.current=i),m(u,c,d.styleSheet,p,d.stylis))},f),o.useLayoutEffect(()=>()=>{d.styleSheet.server||i.removeStyles(u,d.styleSheet)},[u,d.styleSheet,i])}return d.styleSheet.server&&i.instanceRules.delete(u),null};function m(c,d,p,u,f){if(i.isStatic)i.renderStyles(c,x8,p,f);else{const h=Object.assign(Object.assign({},d),{theme:nc(d,u,l.defaultProps)});i.renderStyles(c,h,p,f)}}return o.memo(l)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
95
+ <Component />`),v=!0,j={})}})(d,p)),mc(x,()=>`.${x.styledComponentId}`),l&&uc(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}var nm=new Set(["a","abbr","address","area","article","aside","audio","b","bdi","bdo","blockquote","body","button","br","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","slot","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","tspan","use"]);function Ei(e,a){const s=[e[0]];for(let r=0,i=a.length;r<i;r+=1)s.push(a[r],e[r+1]);return s}const Ai=e=>(hc.add(e),e);function jc(e,...a){if(bs(e)||Za(e))return Ai(pa(Ei(kr,[e,...a])));const s=e;return a.length===0&&s.length===1&&typeof s[0]=="string"?pa(s):Ai(pa(Ei(s,a)))}function mr(e,a,s=Qa){if(!a)throw vs(1,a);const r=(i,...l)=>e(a,s,jc(i,...l));return r.attrs=i=>mr(e,a,Object.assign(Object.assign({},s),{attrs:Array.prototype.concat(s.attrs,i).filter(Boolean)})),r.withConfig=i=>mr(e,a,Object.assign(Object.assign({},s),i)),r}const _c=e=>mr(sm,e),rm=_c;nm.forEach(e=>{rm[e]=_c(e)});class im{constructor(a,s){this.instanceRules=new Map,this.rules=a,this.componentId=s,this.isStatic=(function(r){for(let i=0;i<r.length;i+=1){const l=r[i];if(bs(l)&&!Nr(l))return!1}return!0})(a),ys.registerId(this.componentId)}removeStyles(a,s){this.instanceRules.delete(a),this.rebuildGroup(s)}renderStyles(a,s,r,i){const l=this.componentId;if(this.isStatic){if(r.hasNameForId(l,l+a))this.instanceRules.has(a)||this.computeRules(a,s,r,i);else{const c=this.computeRules(a,s,r,i);r.insertRules(l,c.name,c.rules)}return}const m=this.instanceRules.get(a);if(this.computeRules(a,s,r,i),!r.server&&m){const c=m.rules,d=this.instanceRules.get(a).rules;if(c.length===d.length){let p=!0;for(let u=0;u<c.length;u++)if(c[u]!==d[u]){p=!1;break}if(p)return}}this.rebuildGroup(r)}computeRules(a,s,r,i){const l=lr(pa(this.rules,s,r,i)),m={name:this.componentId+a,rules:i(l,"")};return this.instanceRules.set(a,m),m}rebuildGroup(a){const s=this.componentId;a.clearRules(s);for(const r of this.instanceRules.values())a.insertRules(s,r.name,r.rules)}}function om(e,...a){const s=jc(e,...a),r=`sc-global-${lc(JSON.stringify(s))}`,i=new im(s,r);process.env.NODE_ENV!=="production"&&sc(r);const l=c=>{const d=yc(),p=o.useContext(Sr);let u;{const f=o.useRef(null);f.current===null&&(f.current=d.styleSheet.allocateGSInstance(r)),u=f.current}process.env.NODE_ENV!=="production"&&o.Children.count(c.children)&&console.warn(`The global style component ${r} was given child JSX. createGlobalStyle does not render children.`),process.env.NODE_ENV!=="production"&&s.some(f=>typeof f=="string"&&f.indexOf("@import")!==-1)&&console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app."),d.styleSheet.server&&m(u,c,d.styleSheet,p,d.stylis);{const f=i.isStatic?[u,d.styleSheet,i]:[u,c,d.styleSheet,p,d.stylis,i],h=o.useRef(i);o.useLayoutEffect(()=>{d.styleSheet.server||(h.current!==i&&(d.styleSheet.clearRules(r),h.current=i),m(u,c,d.styleSheet,p,d.stylis))},f),o.useLayoutEffect(()=>()=>{d.styleSheet.server||i.removeStyles(u,d.styleSheet)},[u,d.styleSheet,i])}return d.styleSheet.server&&i.instanceRules.delete(u),null};function m(c,d,p,u,f){if(i.isStatic)i.renderStyles(c,x8,p,f);else{const h=Object.assign(Object.assign({},d),{theme:nc(d,u,l.defaultProps)});i.renderStyles(c,h,p,f)}}return o.memo(l)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
96
96
  Perhaps you're looking to import 'styled-components/native'?
97
97
  Read more about this at https://styled-components.com/docs/basics#react-native`);const Os=`__sc-${Oa}__`;process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[Os]||(window[Os]=0),window[Os]===1&&console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
98
98
 
99
- See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page for more info.`),window[Os]+=1);const l4='.wacht-root{--wa-surface: var(--wa-ov-light-surface, #ffffff);--wa-surface-subtle: var(--wa-ov-light-surface_subtle, #fafaf8);--wa-background: var(--wa-ov-light-background, #f5f5f2);--wa-canvas: var(--wa-ov-light-canvas, #ebebe7);--wa-text: var(--wa-ov-light-text, #161618);--wa-text-secondary: var(--wa-ov-light-text_secondary, #3b3b3f);--wa-text-muted: var(--wa-ov-light-text_muted, #76767c);--wa-text-faint: var(--wa-ov-light-text_faint, #a8a8ad);--wa-border: var(--wa-ov-light-border, rgba(20, 20, 22, .08));--wa-border-strong: var(--wa-ov-light-border_strong, rgba(20, 20, 22, .14));--wa-primary: var(--wa-ov-light-primary, #6b3df5);--wa-primary-soft: var(--wa-ov-light-primary_soft, rgba(107, 61, 245, .1));--wa-primary-foreground: var(--wa-ov-light-primary_foreground, #ffffff);--wa-success: var(--wa-ov-light-success, #0f8a4a);--wa-success-soft: var(--wa-ov-light-success_soft, rgba(15, 138, 74, .12));--wa-info: var(--wa-ov-light-info, #2f6fdb);--wa-info-soft: var(--wa-ov-light-info_soft, rgba(47, 111, 219, .1));--wa-warning: var(--wa-ov-light-warning, #a8650a);--wa-warning-soft: var(--wa-ov-light-warning_soft, rgba(168, 101, 10, .12));--wa-error: var(--wa-ov-light-error, #c4271f);--wa-error-soft: var(--wa-ov-light-error_soft, rgba(196, 39, 31, .1));--wa-radius: var(--wa-ov-light-radius, 6px);--wa-radius-lg: var(--wa-ov-light-radius_lg, 10px);--wa-font-sans: var(--wa-ov-light-font_sans, "Geist", "Inter"), system-ui, -apple-system, sans-serif;--wa-font-mono: var(--wa-ov-light-font_mono, "Geist Mono"), ui-monospace, SFMono-Regular, Menlo, monospace;font-family:var(--wa-font-sans)}.dark .wacht-root,.wacht-root.dark{--wa-surface: var(--wa-ov-dark-surface, #131318);--wa-surface-subtle: var(--wa-ov-dark-surface_subtle, #101015);--wa-background: var(--wa-ov-dark-background, #0d0d10);--wa-canvas: var(--wa-ov-dark-canvas, #050507);--wa-text: var(--wa-ov-dark-text, #ececef);--wa-text-secondary: var(--wa-ov-dark-text_secondary, #c5c5cb);--wa-text-muted: var(--wa-ov-dark-text_muted, #8a8a92);--wa-text-faint: var(--wa-ov-dark-text_faint, #57575e);--wa-border: var(--wa-ov-dark-border, rgba(255, 255, 255, .07));--wa-border-strong: var(--wa-ov-dark-border_strong, rgba(255, 255, 255, .14));--wa-primary: var(--wa-ov-dark-primary, #9277ff);--wa-primary-soft: var(--wa-ov-dark-primary_soft, rgba(146, 119, 255, .16));--wa-primary-foreground: var(--wa-ov-dark-primary_foreground, #ffffff);--wa-success: var(--wa-ov-dark-success, #0f8a4a);--wa-success-soft: var(--wa-ov-dark-success_soft, rgba(15, 138, 74, .18));--wa-info: var(--wa-ov-dark-info, #2f6fdb);--wa-info-soft: var(--wa-ov-dark-info_soft, rgba(47, 111, 219, .18));--wa-warning: var(--wa-ov-dark-warning, #a8650a);--wa-warning-soft: var(--wa-ov-dark-warning_soft, rgba(168, 101, 10, .18));--wa-error: var(--wa-ov-dark-error, #c4271f);--wa-error-soft: var(--wa-ov-dark-error_soft, rgba(196, 39, 31, .18));--wa-radius: var(--wa-ov-dark-radius, 6px);--wa-radius-lg: var(--wa-ov-dark-radius_lg, 10px);--wa-font-sans: var(--wa-ov-dark-font_sans, "Geist", "Inter"), system-ui, -apple-system, sans-serif;--wa-font-mono: var(--wa-ov-dark-font_mono, "Geist Mono"), ui-monospace, SFMono-Regular, Menlo, monospace}.wacht-root *{box-sizing:border-box}',c4='.w-flex-col{display:flex;flex-direction:column}.w-inline{display:inline-flex;align-items:center}.w-wrap{flex-wrap:wrap}.w-grow{flex:1 1 auto;min-width:0}.w-none{flex:none}.w-full{width:100%}.w-gap-1{gap:4px}.w-gap-2{gap:8px}.w-gap-3{gap:12px}.w-gap-4{gap:16px}.w-gap-5{gap:20px}.w-gap-6{gap:24px}.w-truncate{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-contents{display:contents}.w-h-full{height:100%}.w-minh-full{min-height:100%}.w-mono-sm{font:400 12px/1.4 var(--wa-font-mono);color:var(--wa-text-muted)}.w-text-primary{color:var(--wa-primary)}.w-text-secondary{color:var(--wa-text-secondary)}.w-text-muted{color:var(--wa-text-muted)}.w-text-faint{color:var(--wa-text-faint)}.w-text-error{color:var(--wa-error)}.w-text-success{color:var(--wa-success)}.w-text-warning{color:var(--wa-warning)}.w-mb-4{margin-bottom:16px}.w-mt-6{margin-top:24px}.w-maxw-sm{max-width:340px}.w-rolepick-btn{min-width:120px}.w-combo-menu--pop{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:60}.w-relative{position:relative}.w-card{background:var(--wa-surface);border:0;border-radius:var(--wa-radius-lg);box-shadow:0 0 0 .5px var(--wa-border),0 1px 1px #1414160a,0 4px 8px -4px #14141614,0 24px 48px -16px #14141629;overflow:hidden}.w-eyebrow{font:400 10px/1 var(--wa-font-mono);letter-spacing:.12em;text-transform:uppercase;color:var(--wa-text-faint)}.w-title{font:400 17px/1.25 var(--wa-font-sans);letter-spacing:-.02em;color:var(--wa-text);margin:0}.w-title-lg{font:400 19px/1.2 var(--wa-font-sans);letter-spacing:-.022em;color:var(--wa-text);margin:0}.w-sub{font:400 13px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);margin:0}.w-sec{font:400 13px/1.3 var(--wa-font-sans);color:var(--wa-text);margin:0}.w-secsub{font:400 12px/1.45 var(--wa-font-sans);color:var(--wa-text-muted);margin:0}.w-btn{height:32px;padding:0 13px;border-radius:var(--wa-radius);border:.5px solid transparent;font:400 12.5px/1 var(--wa-font-sans);display:inline-flex;align-items:center;justify-content:center;gap:7px;cursor:pointer;white-space:nowrap;-webkit-user-select:none;user-select:none;transition:background .14s ease,border-color .14s ease,filter .14s ease,box-shadow .14s ease;background:transparent;color:var(--wa-text)}.w-btn:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-btn:disabled{opacity:.6;cursor:not-allowed}.w-btn svg{width:14px;height:14px;flex:none}.w-btn.w-notif-bell{width:32px;height:32px}.w-btn.w-notif-bell svg{width:18px;height:18px}.w-btn--primary{background:var(--wa-primary);color:var(--wa-primary-foreground);box-shadow:inset 0 1px #ffffff2e,0 1px 2px #1414161f,0 2px 8px -2px color-mix(in srgb,var(--wa-primary) 50%,transparent);background-image:linear-gradient(180deg,#ffffff1a,#fff0 42%)}.w-btn--primary:active:not(:disabled){filter:brightness(.97);box-shadow:inset 0 1px 2px #14141633}.w-btn--block{width:100%;height:38px;font-size:13px}.w-btn--secondary{background:var(--wa-surface);border-color:var(--wa-border-strong);color:var(--wa-text);box-shadow:inset 0 1px #ffffff80,0 1px 1.5px #1414160a}.w-btn--ghost{background:transparent;color:var(--wa-text-secondary)}.w-btn--danger{background:transparent;color:var(--wa-error);border-color:color-mix(in srgb,var(--wa-error) 26%,transparent)}.w-btn--danger-solid{background:var(--wa-error);color:#fff}.w-btn--sm{height:26px;padding:0 9px;font-size:11.5px}.w-btn--lg{height:42px;padding:0 18px;font-size:13.5px}.w-btn--icon{height:28px;width:28px;padding:0;color:var(--wa-text-muted)}.w-btn--icon:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-social{height:40px;width:100%;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);color:var(--wa-text);font:400 13px/1 var(--wa-font-sans);display:flex;align-items:center;justify-content:center;gap:10px;padding:0 14px;cursor:pointer;position:relative;box-shadow:inset 0 1px #ffffff80,0 1px 1.5px #1414160a;transition:background .14s ease,border-color .14s ease,box-shadow .14s ease,transform .1s ease}.w-social:active{transform:translateY(.5px)}.w-social:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-social svg,.w-social img{width:17px;height:17px;flex:none}.w-social .w-social-label{flex:none}.w-social .w-lastused{position:absolute;top:-9px;right:12px;white-space:nowrap;font:400 9.5px/1 var(--wa-font-mono);letter-spacing:.04em;color:var(--wa-text-muted);background:var(--wa-surface);border:.5px solid var(--wa-border);padding:3px 6px;border-radius:5px}.w-field{display:flex;flex-direction:column;gap:7px}.w-label{font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);display:flex;align-items:center;gap:4px;letter-spacing:-.005em;white-space:nowrap}.w-req{color:var(--wa-error);font-size:12px}.w-input{height:34px;padding:0 12px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);color:var(--wa-text);font:400 13px/1 var(--wa-font-sans);width:100%;box-shadow:inset 0 1px 2px #1414160d;transition:border-color .14s ease,box-shadow .14s ease}.w-input::placeholder{color:var(--wa-text-faint)}.w-input:focus{outline:none;border-color:var(--wa-primary);box-shadow:inset 0 1px 2px #1414160a,0 0 0 3px var(--wa-primary-soft)}.w-input-row{display:flex;align-items:center;gap:6px}.w-input-trail{margin-left:-34px;z-index:1}.w-input-wrap{position:relative}.w-input--valid:focus{border-color:var(--wa-success);box-shadow:0 0 0 3px var(--wa-success-soft)}.w-input--invalid,.w-input[aria-invalid=true]{border-color:color-mix(in srgb,var(--wa-error) 55%,var(--wa-border-strong))}.w-input--invalid:focus,.w-input[aria-invalid=true]:focus{border-color:var(--wa-error);box-shadow:0 0 0 3px var(--wa-error-soft)}.w-input:disabled,.w-input[data-disabled]{opacity:.55;cursor:not-allowed}.w-input-err{font:400 11.5px/1.3 var(--wa-font-sans);color:var(--wa-error)}.w-input-ok{font:400 11.5px/1.3 var(--wa-font-sans);color:var(--wa-success)}.w-input-eye{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:28px;height:28px;display:grid;place-items:center;border:0;background:none;cursor:pointer;color:var(--wa-text-faint);border-radius:6px}.w-input-eye:hover{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-input-eye svg{width:15px;height:15px}.w-avatar{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;font:400 var(--av-fs, 13px)/1 var(--wa-font-sans);color:#fff;flex:none;background:var( --av-bg, linear-gradient( 135deg, var(--wa-primary), var( --wa-primary-tint, color-mix(in srgb, var(--wa-primary), #fff 25%) ) ) );box-shadow:inset 0 0 0 .5px #ffffff29;letter-spacing:.01em;overflow:hidden}.w-avatar img{width:100%;height:100%;object-fit:cover}.w-avatar--square{border-radius:var(--wa-radius)}.w-avatar--sm{width:20px;height:20px;font-size:10px}.w-avatar--md{width:28px;height:28px;font-size:11px}.w-avatar--lg{width:44px;height:44px;font-size:15px}.w-avatar--xl{width:80px;height:80px;font-size:24px}.w-avatar-edit{position:relative;cursor:pointer;border:0;padding:0}.w-avatar-edit .w-avatar-veil{position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;display:grid;place-items:center;color:#fff;background:color-mix(in srgb,#000 45%,transparent);opacity:0;transition:opacity .15s ease;font:400 11px/1.2 var(--wa-font-sans);text-align:center;padding:0 6px}.w-avatar-edit:hover .w-avatar-veil,.w-avatar-edit[data-busy] .w-avatar-veil{opacity:1}.w-avatar-veil svg{width:18px;height:18px}.w-pill{display:inline-flex;align-items:center;gap:6px;height:21px;padding:0 8px;border-radius:4px;font:400 10.5px/1 var(--wa-font-mono);text-transform:lowercase;letter-spacing:.01em;background:var(--wa-surface-subtle);color:var(--wa-text-muted);border:.5px solid var(--wa-border);white-space:nowrap;flex:none}.w-pill .w-dot{width:5px;height:5px;border-radius:999px;background:var(--wa-text-faint)}.w-pill--success{background:var(--wa-success-soft);color:var(--wa-success);border-color:color-mix(in srgb,var(--wa-success) 26%,transparent)}.w-pill--success .w-dot{background:var(--wa-success)}.w-pill--warning{background:var(--wa-warning-soft);color:var(--wa-warning);border-color:color-mix(in srgb,var(--wa-warning) 26%,transparent)}.w-pill--warning .w-dot{background:var(--wa-warning)}.w-pill--info{background:var(--wa-info-soft);color:var(--wa-info);border-color:color-mix(in srgb,var(--wa-info) 26%,transparent)}.w-pill--info .w-dot{background:var(--wa-info)}.w-pill--current{background:var(--wa-primary-soft);color:var(--wa-primary);border-color:color-mix(in srgb,var(--wa-primary) 26%,transparent)}.w-pill--error{background:var(--wa-error-soft);color:var(--wa-error);border-color:color-mix(in srgb,var(--wa-error) 26%,transparent)}.w-pill--error .w-dot{background:var(--wa-error)}.w-pill--pending{background:transparent;color:var(--wa-warning);border:.5px dashed color-mix(in srgb,var(--wa-warning) 55%,transparent)}.w-pill--pending .w-dot{background:var(--wa-warning)}.w-chip{display:inline-flex;align-items:center;gap:7px;height:24px;padding:0 5px 0 9px;border-radius:var(--wa-radius);background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);font:400 12px/1 var(--wa-font-mono);color:var(--wa-text-secondary)}.w-chip-x{display:grid;place-items:center;width:16px;height:16px;border-radius:3px;color:var(--wa-text-faint);cursor:pointer}.w-chip-x:hover{background:var(--wa-border);color:var(--wa-text)}.w-chip-x svg{width:11px;height:11px}.w-or{display:flex;align-items:center;gap:14px;margin:18px 0}.w-or:before,.w-or:after{content:"";height:.5px;background:var(--wa-border);flex:1}.w-or span{font:400 10px/1 var(--wa-font-mono);letter-spacing:.14em;color:var(--wa-text-faint)}.w-hr{height:.5px;background:var(--wa-border);border:0;margin:0;width:100%}.w-list{display:flex;flex-direction:column}.w-listhead{display:grid;align-items:center;padding:0 2px 8px;font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);border-bottom:.5px solid var(--wa-border)}.w-row{display:grid;align-items:center;padding:13px 2px;border-bottom:.5px solid var(--wa-border)}.w-row:last-child{border-bottom:0}.w-row--hover{border-radius:var(--wa-radius);margin:0 -8px;padding:11px 10px;border-bottom:0;transition:background .12s ease}.w-row--hover:hover{background:var(--wa-surface-subtle)}.w-acct{display:flex;align-items:center;gap:13px;width:100%;text-align:left;padding:11px 12px;border:.5px solid transparent;border-radius:var(--wa-radius-lg);background:none;cursor:pointer;transition:background .13s ease,border-color .13s ease}.w-acct:hover{background:var(--wa-surface-subtle)}.w-acct[data-active]{background:var(--wa-surface-subtle);border-color:var(--wa-border)}.w-acct .w-acct-go{color:var(--wa-text-faint);flex:none;opacity:0;transform:translate(-4px);transition:opacity .13s ease,transform .13s ease}.w-acct:hover .w-acct-go{opacity:1;transform:none;color:var(--wa-text-muted)}.w-acct[data-busy]{opacity:.55;pointer-events:none}.w-acct-list{border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);overflow:hidden;margin-bottom:18px}.w-acct-list-head{padding:11px 14px;border-bottom:.5px solid var(--wa-border)}.w-acct-list-body{padding:6px}.w-acct-text{flex:1;min-width:0;text-align:left}.w-acct-name{display:block;font:400 13px/1.3 var(--wa-font-sans);color:var(--wa-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-acct-text .w-secsub{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-acct .w-avatar{width:34px;height:34px;flex:none}.w-acct[data-active] .w-avatar{width:40px;height:40px}.w-acct-add-ic{width:36px;height:36px;border-radius:50%;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);display:grid;place-items:center;color:var(--wa-text-muted);flex:none;transition:color .13s ease,border-color .13s ease}.w-acct--add:hover .w-acct-add-ic{color:var(--wa-text);border-color:var(--wa-text-muted)}.w-acct-out{color:var(--wa-text-faint);flex:none;margin-right:-6px}.w-acct-out:hover{color:var(--wa-error);background:var(--wa-error-soft)}.w-acct--add:hover{background:var(--wa-surface-subtle)}.w-acct-foot{margin-top:8px;padding-top:10px}.w-acct-add{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;height:36px;border:0;background:none;cursor:pointer;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-muted);transition:background .13s ease,color .13s ease}.w-acct-add svg{width:15px;height:15px}.w-acct-add:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-tabs{display:flex;gap:2px}.w-tab{display:inline-flex;align-items:center;gap:7px;height:30px;flex:none;white-space:nowrap;padding:0 12px;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-muted);background:none;border:0;cursor:pointer;transition:color .14s ease,background .14s ease}.w-tab svg{width:14px;height:14px}.w-tab:hover,.w-tab--active{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-tab--active svg{color:var(--wa-primary)}.w-menu{width:264px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;padding:4px;overflow:hidden}.w-menu-head{display:flex;align-items:center;gap:11px;padding:11px 9px}.w-menu-item{display:flex;align-items:center;justify-content:flex-start;gap:10px;height:32px;padding:0 8px;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);cursor:pointer;transition:background .12s ease;width:100%;border:0;background:none;text-align:left;white-space:nowrap}.w-menu-item:hover{background:var(--wa-surface-subtle)}.w-menu-item svg{width:15px;height:15px;color:var(--wa-text-muted);flex:none}.w-menu-item .w-avatar svg{color:inherit}.w-menu-item--danger{color:var(--wa-error)}.w-menu-item--danger svg{color:var(--wa-error)}.w-menu-item--danger:hover{background:var(--wa-error-soft)}.w-menu-trail{margin-left:auto;font:400 10.5px/1 var(--wa-font-mono);color:var(--wa-text-faint)}.w-menu-label{font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);padding:10px 9px 5px}.w-orgtrigger{display:flex;align-items:center;gap:9px;width:100%;height:40px;padding:0 9px;border:0;border-radius:var(--wa-radius);background:transparent;color:var(--wa-text);cursor:pointer;font:400 13px/1 var(--wa-font-sans);text-align:left;transition:background .12s ease}.w-orgtrigger:hover,.w-orgtrigger[data-open]{background:var(--wa-surface-subtle)}.w-orgtrigger:disabled{opacity:.6;cursor:default}.w-orgtrigger>svg{color:var(--wa-text-faint);flex:none}.w-switch-body{overflow-y:auto;padding:4px 0}.w-switch-banner{margin:8px 8px 0}.w-switch-nest{display:flex;flex-direction:column;margin:2px 0 6px 24px;padding-left:8px;border-left:.5px solid var(--wa-border)}.w-menu-item--muted{color:var(--wa-text-muted)}.w-menu-item--muted svg{color:var(--wa-text-muted)}.w-rowact{display:inline-grid;place-items:center;width:22px;height:22px;border-radius:5px;color:var(--wa-text-muted);cursor:pointer}.w-rowact:hover{color:var(--wa-text);background:var(--wa-border)}.w-rowact svg{width:13px;height:13px}.w-danger{border:.5px solid color-mix(in srgb,var(--wa-error) 30%,transparent);background:var(--wa-error-soft);border-radius:var(--wa-radius);padding:14px 16px;display:flex;align-items:center;justify-content:space-between;gap:20px}.w-link{color:var(--wa-text);font-weight:400;cursor:pointer;text-decoration:none}.w-link--sm{font-size:12px}.w-link:hover{text-decoration:underline}.w-link--muted{color:var(--wa-text-muted)}.w-mono-faint{font:400 12px/1.4 var(--wa-font-mono);color:var(--wa-text-faint)}@keyframes w-spin{to{transform:rotate(360deg)}}.w-spin{display:inline-block;border-radius:50%;border:2px solid var(--wa-border-strong);border-top-color:var(--wa-primary);animation:w-spin .7s linear infinite}.w-spin--on-accent{border-color:#ffffff59;border-top-color:#fff}.w-loading{display:grid;place-items:center;gap:14px;padding:40px;text-align:center}.w-otp{display:flex;gap:8px}.w-otp .w-otp-cell{width:42px;height:48px;text-align:center;font:400 20px/1 var(--wa-font-mono);color:var(--wa-text);border:.5px solid var(--wa-border-strong);border-radius:var(--wa-radius);background:var(--wa-surface);display:grid;place-items:center}.w-otp .w-otp-cell[data-active],.w-otp .w-otp-cell:focus{outline:none;border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-otp .w-otp-cell[data-filled]{border-color:var(--wa-text-muted)}.w-otp[data-error] .w-otp-cell{border-color:color-mix(in srgb,var(--wa-error) 50%,var(--wa-border-strong))}.w-otp-caret{width:1.5px;height:22px;background:var(--wa-primary);animation:w-blink 1s steps(1) infinite}@keyframes w-blink{50%{opacity:0}}.w-addr-badge{display:inline-flex;align-items:center;gap:8px;height:30px;padding:0 6px 0 12px;border-radius:999px;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-secondary)}.w-addr-badge button{border:0;background:none;cursor:pointer;color:var(--wa-primary);font:400 12px/1 var(--wa-font-sans);padding:4px 8px;border-radius:6px}.w-addr-badge button:hover{background:var(--wa-primary-soft)}.w-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px;padding:48px 24px}.w-empty .w-empty-ic{display:grid;place-items:center;width:44px;height:44px;border-radius:var(--wa-radius-lg);background:var(--wa-primary-soft);color:var(--wa-primary)}.w-empty .w-empty-ic svg{width:20px;height:20px;color:var(--wa-primary)}.w-empty-text{display:flex;flex-direction:column;gap:4px}.w-empty h4{margin:0;font:500 14px/1.4 var(--wa-font-sans);color:var(--wa-text)}.w-empty p{margin:0;font:400 12px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);max-width:384px;text-wrap:pretty}.w-empty-action{margin-top:4px}.w-empty--fill{height:100%}.w-empty-ic--accent{width:44px;height:44px}.w-toast{display:inline-flex;align-items:center;gap:11px;padding:11px 13px 11px 14px;border-radius:var(--wa-radius-lg);background:var(--wa-surface);border:.5px solid var(--wa-border);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;min-width:280px;max-width:380px}.w-toast .w-toast-ic{width:20px;height:20px;border-radius:50%;display:grid;place-items:center;flex:none}.w-toast .w-toast-ic svg{width:12px;height:12px}.w-toast--success .w-toast-ic{background:var(--wa-success-soft);color:var(--wa-success)}.w-toast--error .w-toast-ic{background:var(--wa-error-soft);color:var(--wa-error)}.w-toast-msg{flex:1;font:400 13px/1.35 var(--wa-font-sans);color:var(--wa-text)}.w-toast-x{border:0;background:none;cursor:pointer;color:var(--wa-text-faint);width:22px;height:22px;border-radius:6px;display:grid;place-items:center;flex:none}.w-toast-x:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-toast-x svg{width:12px;height:12px}.w-pop{width:320px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;overflow:hidden}.w-pop-body{padding:15px 15px 13px;display:flex;flex-direction:column;gap:11px}.w-pop-title{margin:0;font:400 13.5px/1.3 var(--wa-font-sans);letter-spacing:-.01em;color:var(--wa-text)}.w-pop-sub{margin:0;font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);text-wrap:pretty}.w-pop-title+.w-pop-sub{margin-top:-7px}.w-pop-foot{display:flex;gap:8px;justify-content:flex-end;padding:10px 14px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-pop-foot .w-btn{width:auto}.w-pop-icon{width:38px;height:38px;border-radius:var(--wa-radius);display:grid;place-items:center;flex:none}.w-pop-icon--danger{background:var(--wa-error-soft);color:var(--wa-error)}.w-pop-icon--warn{background:var(--wa-warning-soft);color:var(--wa-warning)}.w-pop-icon svg{width:18px;height:18px}.w-locked{display:flex;align-items:center;gap:10px;height:38px;padding:0 8px 0 13px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-locked .w-locked-ic{color:var(--wa-text-faint);flex:none}.w-locked .w-locked-ic svg{width:15px;height:15px;display:block}.w-locked .w-locked-val{flex:1;font:400 13.5px/1 var(--wa-font-sans);color:var(--wa-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-restricted{opacity:.55;cursor:not-allowed}.w-restricted *{pointer-events:none}.w-warn-ic{color:var(--wa-warning);display:inline-grid;place-items:center}.w-warn-ic svg{width:15px;height:15px}.w-codes{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:14px;border-radius:var(--wa-radius);background:var(--wa-surface-subtle);border:.5px solid var(--wa-border)}.w-codes span{font:400 13px/1.6 var(--wa-font-mono);color:var(--wa-text);text-align:center;letter-spacing:.04em}.w-qr{width:148px;height:148px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface);display:grid;place-items:center;color:var(--wa-text)}.w-banner{display:flex;gap:11px;padding:12px 14px;border-radius:var(--wa-radius);align-items:flex-start}.w-banner svg{width:16px;height:16px;flex:none;margin-top:1px}.w-banner-txt{font:400 12.5px/1.5 var(--wa-font-sans);text-wrap:pretty;color:var(--wa-text-secondary)}.w-banner--error{background:var(--wa-error-soft)}.w-banner--warn{background:var(--wa-warning-soft)}.w-banner--info{background:var(--wa-info-soft)}.w-banner--error svg{color:var(--wa-error)}.w-banner--warn svg{color:var(--wa-warning)}.w-banner--info svg{color:var(--wa-info)}.w-seg{display:inline-flex;padding:3px;gap:2px;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);border-radius:var(--wa-radius)}.w-seg button{height:28px;padding:0 12px;border:0;background:none;cursor:pointer;border-radius:4px;font:400 12px/1 var(--wa-font-sans);color:var(--wa-text-muted);white-space:nowrap}.w-seg button[data-on]{background:var(--wa-surface);color:var(--wa-text);box-shadow:0 0 0 .5px var(--wa-border)}.w-steps{display:flex;gap:6px;justify-content:center}.w-steps i{width:5px;height:5px;border-radius:999px;background:var(--wa-border-strong);transition:background .2s ease,width .2s ease}.w-steps i[data-on]{background:var(--wa-primary);width:16px}.w-ibadge{display:grid;place-items:center;width:48px;height:48px;flex:none;border-radius:var(--wa-radius-lg);background:var(--wa-primary-soft);color:var(--wa-primary);overflow:hidden}.w-ibadge svg{width:24px;height:24px}.w-ibadge img{width:100%;height:100%;object-fit:cover}.w-ibadge--done{width:52px;height:52px;border-radius:999px;background:var(--wa-success-soft);color:var(--wa-success)}.w-ibadge--done svg{width:26px;height:26px}.w-ibadge-wrap{position:relative}.w-ibadge-x{position:absolute;top:-6px;right:-6px;width:20px;height:20px;display:grid;place-items:center;border-radius:999px;border:.5px solid var(--wa-border);background:var(--wa-surface);color:var(--wa-text-muted);cursor:pointer;box-shadow:0 1px 2px #1414161f}.w-ibadge-x svg{width:11px;height:11px}.w-create-foot{padding:13px 32px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle);text-align:center}.w-create-summary{display:flex;align-items:center;justify-content:center;gap:12px;width:100%;padding:12px 16px;border:.5px solid var(--wa-border);border-radius:var(--wa-radius)}.w-auth-card{width:min(440px,100%)}.w-auth-head{display:flex;flex-direction:column;align-items:center;gap:14px;margin-bottom:24px}.w-auth-head-text{display:flex;flex-direction:column;gap:6px;text-align:center}.w-auth-title{margin:0;font:400 21px/1.2 var(--wa-font-sans);letter-spacing:-.025em;color:var(--wa-text)}.w-auth-sub{margin:0;font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);text-wrap:pretty}.w-auth-status{display:flex;flex-direction:column;align-items:center;gap:16px;padding-top:4px;text-align:center}.w-auth-foot{font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted)}.w-fineprint{margin:2px 2px 0;font:400 11px/1.5 var(--wa-font-sans);color:var(--wa-text-faint);text-align:center;text-wrap:pretty}.w-switch{display:inline-flex;align-items:center;gap:10px;cursor:pointer;-webkit-user-select:none;user-select:none}.w-switch .w-switch-track{width:36px;height:20px;border-radius:999px;background:var(--wa-border-strong);border:.5px solid transparent;position:relative;transition:background .16s ease;flex:none}.w-switch .w-switch-knob{position:absolute;top:1.5px;left:1.5px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform .16s ease}.w-switch[data-on] .w-switch-track{background:var(--wa-primary)}.w-switch[data-on] .w-switch-knob{transform:translate(16px)}.w-switch-label{font:400 13px/1 var(--wa-font-sans);color:var(--wa-text)}.w-search{display:flex;align-items:center;gap:8px;height:32px;width:240px;max-width:100%;padding:0 11px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface)}.w-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:14px}.w-search svg{width:15px;height:15px;color:var(--wa-text-faint);flex:none}.w-search input{border:0;background:none;outline:none;flex:1;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);min-width:0}.w-search input::placeholder{color:var(--wa-text-faint)}.w-combo{display:flex;align-items:center;gap:8px;height:34px;padding:0 10px 0 12px;width:100%;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);cursor:pointer;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);transition:border-color .14s ease}.w-combo:hover{border-color:var(--wa-text-muted)}.w-combo[data-open]{border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-combo .w-combo-val{flex:1;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-combo .w-combo-val[data-ph]{color:var(--wa-text-faint)}.w-combo svg{width:15px;height:15px;color:var(--wa-text-muted);flex:none}.w-combo-menu{width:100%;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;padding:4px;overflow:hidden}.w-combo-opt{display:flex;align-items:center;justify-content:flex-start;gap:9px;height:30px;padding:0 8px;border-radius:5px;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);cursor:pointer;width:100%;border:0;background:none;text-align:left;white-space:nowrap}.w-combo-opt>svg{width:15px;height:15px;flex:none;color:var(--wa-text-muted)}.w-combo-opt:hover{background:var(--wa-surface-subtle)}.w-combo-opt .w-combo-check{margin-left:auto;color:var(--wa-primary);display:grid;place-items:center}.w-combo-opt .w-combo-check svg{width:14px;height:14px}.w-combo-opt[data-disabled]{opacity:.5;cursor:not-allowed}.w-combo-grp{font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);padding:9px 9px 5px}.w-phone{display:flex;align-items:stretch;gap:0;width:100%}.w-phone .w-phone-cc{display:flex;align-items:center;gap:7px;height:34px;padding:0 10px;border:.5px solid var(--wa-border-strong);border-right:0;border-radius:var(--wa-radius) 0 0 var(--wa-radius);background:var(--wa-surface-subtle);cursor:pointer;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);white-space:nowrap}.w-phone .w-phone-cc svg{width:13px;height:13px;color:var(--wa-text-muted)}.w-phone input{flex:1;height:34px;padding:0 12px;border:.5px solid var(--wa-border-strong);border-radius:0 var(--wa-radius) var(--wa-radius) 0;background:var(--wa-surface);font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);outline:none;min-width:0}.w-phone input:focus{border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft);position:relative}.w-flag{width:18px;height:13px;border-radius:2px;display:inline-block;flex:none;box-shadow:inset 0 0 0 .5px #00000026}.w-country-pop{position:absolute;top:calc(100% + 6px);left:0;z-index:50;width:260px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;overflow:hidden}.w-country-search{display:flex;align-items:center;gap:8px;padding:9px 11px;border-bottom:.5px solid var(--wa-border)}.w-country-search svg{width:14px;height:14px;color:var(--wa-text-faint);flex:none}.w-country-search input{border:0;background:none;outline:none;flex:1;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);min-width:0}.w-country-search input::placeholder{color:var(--wa-text-faint)}.w-country-list{max-height:220px;overflow-y:auto;padding:5px}.w-country-opt{display:flex;align-items:center;gap:9px;height:32px;padding:0 9px;border-radius:5px;cursor:pointer;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);width:100%;border:0;background:none;text-align:left}.w-country-opt:hover{background:var(--wa-surface-subtle)}.w-country-opt .dial{margin-left:auto;color:var(--wa-text-muted);font:400 12px/1 var(--wa-font-mono);flex:none}.w-method-stack{display:flex;flex-direction:column;gap:10px}.w-method{display:flex;align-items:center;gap:13px;width:100%;padding:13px 14px;border:.5px solid var(--wa-border-strong);border-radius:var(--wa-radius);background:var(--wa-surface);cursor:pointer;text-align:left;transition:background .14s ease,border-color .14s ease}.w-method .w-method-ic{width:34px;height:34px;border-radius:var(--wa-radius);display:grid;place-items:center;background:var(--wa-surface-subtle);color:var(--wa-text-secondary);flex:none}.w-method .w-method-ic svg{width:17px;height:17px}.w-method .w-method-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.w-method .w-method-title{font:400 13.5px/1 var(--wa-font-sans);color:var(--wa-text)}.w-method .w-method-desc{font:400 12px/1.4 var(--wa-font-sans);color:var(--wa-text-muted)}.w-method .w-method-go{color:var(--wa-text-faint);flex:none}.w-method .w-method-go svg{width:16px;height:16px}.w-method[data-disabled]{opacity:.5;cursor:not-allowed}.w-overlay{position:relative;width:100%;height:100%;background:color-mix(in srgb,#000 38%,transparent);display:grid;place-items:center;border-radius:inherit}.w-dialog{background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;width:100%;max-width:480px;overflow:hidden;display:flex;flex-direction:column}.w-dialog--panel{display:block;width:880px;max-width:100%;height:min(560px,calc(100dvh - 40px));overflow-y:auto}.w-dialog--panel .w-card{background:transparent;border-radius:0;box-shadow:none}@media(max-width:640px){.w-dialog--panel{height:calc(100dvh - 16px)}}.w-dialog--create{background:transparent;border:0;box-shadow:none;width:440px;max-width:100%;align-items:center;scrollbar-gutter:stable both-edges}.w-create-card{width:440px;max-width:100%}.w-create-body{padding:34px 32px 28px}.w-create-head{margin-bottom:24px}.w-create-steps{margin-bottom:22px}.w-text-center{text-align:center}.w-linkbtn{background:none;border:0;padding:0;cursor:pointer}.w-modal{position:fixed;top:0;right:0;bottom:0;left:0;background:#08080c80;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);display:flex;justify-content:center;align-items:center;padding:20px;z-index:99999}@media(max-width:640px){.w-modal{padding:8px}}.w-dialog-head{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:.5px solid var(--wa-border)}.w-dialog-title{margin:0;font:400 15px/1.2 var(--wa-font-sans);letter-spacing:-.01em;color:var(--wa-text)}.w-dialog-body{padding:20px;display:flex;flex-direction:column;gap:14px}.w-dialog-foot{display:flex;gap:8px;justify-content:flex-end;padding:14px 20px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-vtabs{display:flex;flex-direction:column;gap:2px}.w-vtab{display:flex;align-items:center;gap:10px;height:34px;padding:0 11px;border-radius:var(--wa-radius);font:400 13px/1 var(--wa-font-sans);color:var(--wa-text-muted);background:none;border:0;cursor:pointer;text-align:left;width:100%}.w-vtab svg{width:15px;height:15px}.w-vtab:hover,.w-vtab[data-on]{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-vtab[data-on] svg{color:var(--wa-primary)}@keyframes w-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.w-skel{border-radius:6px;background:linear-gradient(90deg,var(--wa-surface-subtle) 25%,var(--wa-border) 37%,var(--wa-surface-subtle) 63%);background-size:200% 100%;animation:w-shimmer 1.4s ease infinite}.w-auth-skel{display:flex;flex-direction:column;gap:22px}.w-auth-skel-head{display:flex;flex-direction:column;align-items:center;gap:12px;margin-bottom:2px}.w-auth-skel-fields{display:flex;flex-direction:column;gap:15px}.w-auth-skel-field{display:flex;flex-direction:column;gap:7px}.w-skel-avatar{width:44px;height:44px;border-radius:50%}.w-skel-line{height:10px}.w-skel-title{height:16px;width:56%}.w-skel-sub{height:11px;width:78%}.w-skel-label{height:9px;width:34%}.w-skel-input{height:38px;border-radius:var(--wa-radius)}.w-skel-btn{height:38px;border-radius:var(--wa-radius);margin-top:3px}.w-table{width:100%;border-collapse:separate;border-spacing:0;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);overflow:hidden}.w-table thead{background:var(--wa-surface-subtle)}.w-table th{text-align:left;padding:9px 16px;font:400 11px/1 var(--wa-font-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--wa-text-faint);white-space:nowrap;border-bottom:.5px solid var(--wa-border)}.w-table th:last-child{text-align:right}.w-table td{padding:11px 16px;font:400 13px/1.35 var(--wa-font-sans);color:var(--wa-text-secondary);vertical-align:middle;white-space:nowrap}.w-table tbody tr{transition:background .12s ease}.w-table tbody tr:not(:last-child) td{border-bottom:.5px solid var(--wa-border)}.w-table tbody tr:hover td{background:var(--wa-surface-subtle)}.w-table tbody tr:last-child td:last-child{overflow:visible}.w-td--flex>div{display:flex;align-items:center;gap:10px}.w-td--actions{text-align:right;width:auto;white-space:nowrap;position:relative;overflow:visible}.w-td--actions>*{width:fit-content;margin-left:auto}.w-td--actions>[data-dropdown-trigger]{display:inline-flex;width:fit-content;margin-left:auto}.w-actions{display:flex;gap:6px;justify-content:flex-end;align-items:center}.w-kebab{width:28px;height:28px;border-radius:6px;border:0;background:none;cursor:pointer;color:var(--wa-text-muted);display:grid;place-items:center}.w-kebab:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-kebab svg{width:16px;height:16px}.w-token{display:flex;align-items:center;gap:8px;height:36px;padding:0 6px 0 12px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-token code{flex:1;font:400 12px/1 var(--wa-font-mono);color:var(--wa-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-page-head{display:flex;align-items:center;flex-wrap:wrap;gap:12px;padding:18px 22px}.w-tabsbar{flex:none;padding:0 22px;border-bottom:.5px solid var(--wa-border);overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.w-tabsbar::-webkit-scrollbar{display:none}.w-tabbody{flex:1;min-height:0;padding:20px 22px;overflow-y:auto;overflow-x:auto}.w-tabpane{min-width:300px}.w-card-head{display:flex;align-items:flex-start;justify-content:space-between;flex-wrap:wrap;gap:16px;padding:16px 20px}.w-card-body{padding:16px 20px}.w-card-foot{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:12px;padding:14px 20px;border-top:.5px solid var(--wa-border)}.w-sechead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px}.w-iconbox{width:22px;height:22px;flex:none;display:inline-flex;align-items:center;justify-content:center;overflow:hidden}.w-iconbox svg,.w-iconbox img{width:22px;height:22px;display:block}.w-vrow{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 0}.w-vrow:not(:last-child){border-bottom:.5px solid var(--wa-border)}.w-row-act-top{align-self:flex-start;margin-top:20px}.w-rowitem{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 20px}.w-rowitem:not(:last-child){border-bottom:.5px solid var(--wa-border)}.w-aside-copy{max-width:220px;text-align:center}.w-split{display:flex;min-height:400px;border-radius:var(--wa-radius-lg);overflow:hidden;border:.5px solid var(--wa-border);background:var(--wa-surface)}.w-split-aside{width:35%;min-width:200px;flex:none;background:var(--wa-surface-subtle);border-right:.5px solid var(--wa-border);padding:28px;display:flex;flex-direction:column;gap:14px}.w-split-main{flex:1;min-width:0;padding:28px;display:flex;flex-direction:column;gap:16px}@media(max-width:600px){.w-split{flex-direction:column}.w-split-aside{width:100%;border-right:0;border-bottom:.5px solid var(--wa-border)}}.w-listrow{display:flex;align-items:center;gap:12px;width:100%;padding:12px 0;text-align:left;border:0;border-bottom:.5px solid var(--wa-border);background:transparent;cursor:pointer;transition:background .12s ease}.w-listrow:last-child{border-bottom:0}.w-listrow:hover{background:var(--wa-surface-subtle)}.w-listrow:disabled{opacity:.6;cursor:not-allowed}.w-tile{border:.5px solid var(--wa-border);border-radius:var(--wa-radius);padding:12px;background:var(--wa-surface-subtle)}.w-input--area{min-height:80px;padding-top:9px;padding-bottom:9px;resize:vertical;line-height:1.5}.w-input--mono{font-family:var(--wa-font-mono)}.w-pop--wide{width:372px;max-width:calc(100vw - 24px);overflow:visible}.w-pop .w-input:not(.w-input--area),.w-pop .w-combo{height:32px}.w-feature-badge{width:52px;height:52px;border-radius:999px;display:grid;place-items:center;color:var(--wa-primary-foreground);background:linear-gradient(135deg,var(--wa-primary),var(--wa-primary-tint, #9277ff));box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-primary) 55%,transparent);margin-bottom:18px}.w-narrow{max-width:420px;margin:0 auto}.w-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:14px}.w-grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.w-grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}@media(max-width:600px){.w-grid-2,.w-grid-3,.w-grid-4{grid-template-columns:1fr}}.w-toast--fixed{position:fixed;bottom:20px;right:20px;z-index:1000}.w-toast--contained{position:absolute;bottom:16px;left:50%;transform:translate(-50%);z-index:20;width:max-content;max-width:calc(100% - 32px)}.w-notif-badge{position:absolute;top:4px;right:4px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--wa-error);color:#fff;font:500 9px/1 var(--wa-font-sans);display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--wa-surface)}.w-notif-badge[data-dot]{top:6px;right:6px;min-width:8px;height:8px;padding:0}.w-notif-row{cursor:pointer;padding:12px 18px;border-bottom:.5px solid var(--wa-border);transition:background .12s ease}.w-notif-row:hover,.w-notif-row[data-unread]{background:var(--wa-surface-subtle)}.w-notif-row:hover .w-notif-actions button{color:var(--wa-text-secondary)}.w-notif-row .w-notif-actions button{color:var(--wa-text-faint);transition:color .12s ease}.w-notif-row .w-notif-actions button:hover{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-notif-row .w-notif-actions button[data-on]{color:var(--wa-warning)}.w-notif-dot{width:8px;height:8px;border-radius:50%;background:var(--wa-primary);flex:none}.w-notif-pop{position:fixed;width:450px;max-width:calc(100vw - 24px);z-index:99999}.w-notif-panel{width:450px;max-width:100%;height:100%;background:var(--wa-surface);overflow:hidden}.w-notif-panel--fill{width:100%}.w-notif-head{position:relative;padding:14px 18px;border-bottom:.5px solid var(--wa-border)}.w-notif-body{overflow-x:hidden;overflow-y:auto;background:var(--wa-surface)}.w-notif-menu{position:absolute;top:calc(100% + 4px);right:12px;width:200px;z-index:100000}.w-notif-menu .w-menu-check{margin-left:auto;color:var(--wa-primary)}.w-notif-filter-dot{position:absolute;top:5px;right:5px;width:6px;height:6px;border-radius:50%;background:var(--wa-primary)}.w-banner--success{background:var(--wa-success-soft)}.w-banner--success svg{color:var(--wa-success)}@keyframes w-pop{0%{transform:scale(.5);opacity:0}60%{transform:scale(1.06)}to{transform:scale(1);opacity:1}}@keyframes w-ring{0%{transform:scale(.85);opacity:.45}to{transform:scale(1.9);opacity:0}}@keyframes w-draw{to{stroke-dashoffset:0}}@keyframes w-indeterminate{0%{transform:translate(-100%)}to{transform:translate(330%)}}.w-success{position:relative;display:grid;place-items:center;width:56px;height:56px}.w-success .ring{position:absolute;top:2px;right:2px;bottom:2px;left:2px;border-radius:999px;border:1.5px solid var(--wa-success);opacity:0}.w-success .disc{width:52px;height:52px;border-radius:999px;background:var(--wa-success);color:#fff;display:grid;place-items:center;box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-success) 55%,transparent)}.w-success .disc svg{width:26px;height:26px}.w-success--error .ring{border-color:var(--wa-error)}.w-success--error .disc{background:var(--wa-error);box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-error) 55%,transparent)}.w-success--info .ring{border-color:var(--wa-info)}.w-success--info .disc{background:var(--wa-info);box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-info) 55%,transparent)}.w-progress{position:relative;width:70%;height:3px;border-radius:999px;background:var(--wa-border);overflow:hidden}.w-progress:after{content:"";position:absolute;top:0;left:0;width:30%;height:100%;border-radius:999px;background:var(--wa-primary)}@media(prefers-reduced-motion:no-preference){.w-success .ring{animation:w-ring 1.7s ease-out infinite}.w-success .disc{animation:w-pop .42s cubic-bezier(.2,.9,.3,1.2)}.w-success .disc svg path{stroke-dasharray:26;stroke-dashoffset:26;animation:w-draw .4s .22s ease forwards}.w-progress:after{animation:w-indeterminate 1.15s ease-in-out infinite}}.w-sso-conn{padding-bottom:24px}.w-sso-conn:not(:last-child){margin-bottom:24px;border-bottom:.5px solid var(--wa-border)}.w-sso-detail{display:grid;grid-template-columns:auto 1fr;gap:4px 32px}.w-sso-scim{padding-top:16px;border-top:.5px solid var(--wa-border)}.w-sso-template{padding:12px;background:var(--wa-primary-soft);border-radius:var(--wa-radius);border:.5px solid var(--wa-primary)}.w-sso-check{padding:8px 12px;background:var(--wa-surface);border-radius:var(--wa-radius);border:.5px solid var(--wa-border)}.w-sso-check-mark{min-width:12px}.w-sso-tile{display:flex;flex-direction:column;align-items:center;gap:8px;padding:14px 10px;border:.5px solid var(--wa-border);border-radius:var(--wa-radius);background:var(--wa-surface);cursor:pointer;transition:border-color .14s ease,background .14s ease}.w-sso-tile:hover{border-color:var(--wa-border-strong);background:var(--wa-surface-subtle)}.w-sso-logo{object-fit:contain;background:var(--wa-surface);padding:4px}.w-sso-logo--ph{background:var(--wa-surface)}.w-token-chip{background:var(--wa-surface-subtle);padding:2px 6px;border-radius:4px;color:var(--wa-text)}.w-disclosure{cursor:pointer;font:400 12.5px/1 var(--wa-font-sans)}.w-disclosure-caret{font-size:9px}.w-break-all{word-break:break-all}.w-col-full{grid-column:1 / -1}.dark .w-card{box-shadow:0 0 0 .5px var(--wa-border),0 2px 4px #0006,0 28px 60px -20px #000000b3}.dark .w-menu,.dark .w-pop,.dark .w-toast,.dark .w-dialog,.dark .w-combo-menu,.dark .w-country-pop{box-shadow:0 1px 2px #00000080,0 18px 44px -14px #000000b3}.dark .w-btn--secondary,.dark .w-social{box-shadow:inset 0 1px #ffffff0d,0 1px 1.5px #1414160a}.w-flex{display:flex}.w-inline{display:inline-flex}.w-items-center{align-items:center}.w-items-start{align-items:flex-start}.w-items-end{align-items:flex-end}.w-justify-start{justify-content:flex-start}.w-justify-center{justify-content:center}.w-justify-end{justify-content:flex-end}.w-justify-between{justify-content:space-between}',d4=o4`
100
- ${l4}
101
- ${c4}
102
- `,u4={display:"contents"};function m4(e){const a={};if(!e)return a;const s=(r,i)=>{if(i)for(const l in i){const m=i[l];typeof m=="string"&&m.trim()!==""&&(a[`--wa-ov-${r}-${l}`]=m)}};return s("light",e.light),s("dark",e.dark),a}function as(){var s,r;const e=o.useContext(gr),a=(r=(s=e==null?void 0:e.deployment)==null?void 0:s.ui_settings)==null?void 0:r.theme_tokens;return o.useMemo(()=>m4(a),[a])}const Mi=o.createContext(!1),p4=o.memo(function(){return t.jsx(d4,{})});function Re({children:e,className:a,style:s,...r}){const i=o.useContext(Mi),l=as(),[m,c]=o.useState(!1);if(o.useEffect(()=>c(!0),[]),!m)return null;const d=t.jsx("div",{...r,className:a?`wacht-root ${a}`:"wacht-root",style:{...u4,...l,...s},children:e});return i?d:t.jsxs(Mi.Provider,{value:!0,children:[t.jsx(p4,{}),d]})}function ba({length:e=6,onComplete:a,onResend:s,error:r,isSubmitting:i=!1}){const[l,m]=o.useState(new Array(e).fill("")),[c,d]=o.useState(60),[p,u]=o.useState(!1),f=o.useRef([]),h=o.useCallback(()=>{const j=setInterval(()=>{d(v=>v<=1?(u(!0),clearInterval(j),0):v-1)},1e3);return j},[]);o.useEffect(()=>{const j=h();return()=>clearInterval(j)},[h]);const g=async()=>{var j;!p||i||!s||(await s(),u(!1),d(60),m(new Array(e).fill("")),(j=f.current[0])==null||j.focus(),h())},x=(j,v)=>{var C;if(i)return;const k=j.value,N=[...l];N[v]=k.replace(/[^0-9]/g,""),m(N);const _=N.join("");_.length===e&&a(_),k&&v<e-1&&((C=f.current[v+1])==null||C.focus())},w=(j,v)=>{var k;i||j.key==="Backspace"&&!l[v]&&v>0&&((k=f.current[v-1])==null||k.focus())},b=(j,v)=>{var C,y;if(i)return;j.preventDefault();const k=j.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!k.length)return;const N=[...l];for(let E=0;E<k.length&&v+E<e;E++)N[v+E]=k[E];if(v===0&&k.length===e)for(let E=0;E<e;E++)N[E]=k[E];m(N);const _=N.join("");if(_.length===e)a(_),(C=f.current[e-1])==null||C.focus();else{const E=N.findIndex((M,F)=>F>=v&&!M);E!==-1&&((y=f.current[E])==null||y.focus())}};return t.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{className:"w-otp","data-error":r?"":void 0,children:l.map((j,v)=>t.jsx("input",{className:"w-otp-cell",type:"text",inputMode:"numeric",maxLength:1,value:j,"data-filled":j?"":void 0,onChange:k=>x(k.target,v),onKeyDown:k=>w(k,v),onPaste:k=>b(k,v),ref:k=>{f.current[v]=k},disabled:i,autoFocus:v===0},v))}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[r&&t.jsx("span",{className:"w-input-err",children:r}),s&&(p?t.jsx("button",{type:"button",className:"w-link",style:{background:"none",border:0,cursor:"pointer",fontSize:12.5},onClick:g,disabled:i,children:"Didn't receive a code? Resend"}):t.jsxs("span",{className:"w-secsub",children:["Resend code in ",c,"s"]}))]})]})}const kc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...e,children:[t.jsx("title",{id:"githubIconTitle",children:"GitHub"}),t.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),Cc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),t.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),t.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),t.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),Nc=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...e,children:t.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),h4=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Sc=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:t.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),Ec=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),f4=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Ac=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),t.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),w4={google_oauth:{label:"Continue with Google",icon:t.jsx(Cc,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(kc,{})},x_oauth:{label:"Continue with X",icon:t.jsx(Nc,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(h4,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(Sc,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(Ec,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(f4,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(Ac,{})}},Er=({connections:e,callback:a})=>{const s=e.map(r=>({connection:r,config:w4[r.provider]})).filter(r=>r.config);if(!s.length)return null;if(s.length>3){const r=Math.min(s.length,4);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gap:8},children:s.map(({connection:i,config:l})=>t.jsx("button",{type:"button",className:"w-social",style:{justifyContent:"center",padding:0},onClick:()=>a(i),title:l.label,"aria-label":l.label,children:l.icon},i.provider))})}return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:s.map(({connection:r,config:i})=>t.jsxs("button",{type:"button",className:"w-social",onClick:()=>a(r),children:[i.icon,t.jsx("span",{className:"w-social-label",children:i.label})]},r.provider))})},Et=({to:e,replace:a,children:s,...r})=>{const{navigate:i}=kt(),l=o.useCallback(m=>{m.preventDefault(),i(e,{replace:a})},[e,a,i]);return t.jsx("a",{href:e||void 0,onClick:l,...r,children:s})},Kt=o.forwardRef(({onFocus:e,readOnly:a,...s},r)=>{const[i,l]=o.useState(!1);return t.jsx("input",{ref:r,...s,readOnly:a||!i,onFocus:m=>{i||l(!0),e==null||e(m)}})});Kt.displayName="NoPrefillInput";const qs=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],js=({value:e,onChange:a,error:s,countryCode:r,setCountryCode:i})=>{const[l,m]=o.useState(!1),[c,d]=o.useState(qs.find(x=>x.code===r)||qs[0]),p=o.useRef(null),[u,f]=o.useState(""),h=o.useRef(null);o.useEffect(()=>{function x(w){p.current&&!p.current.contains(w.target)&&m(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const g=qs.filter(x=>x.name.toLowerCase().includes(u.toLowerCase())||x.dialCode.includes(u));return o.useEffect(()=>{i(c.dialCode)},[c,i]),t.jsxs("div",{className:"w-phone",children:[t.jsxs("div",{style:{position:"relative"},ref:p,children:[t.jsxs("button",{type:"button",className:"w-phone-cc",style:{height:"100%"},onClick:()=>m(x=>!x),children:[t.jsx("span",{children:c.flag}),t.jsx("span",{children:c.dialCode}),t.jsx(Wt,{weight:"bold"})]}),l&&t.jsxs("div",{className:"w-country-pop",children:[t.jsxs("div",{className:"w-country-search",children:[t.jsx(Al,{}),t.jsx("input",{type:"text",placeholder:"Search country…",value:u,onChange:x=>f(x.target.value),onClick:x=>x.stopPropagation()})]}),t.jsx("div",{className:"w-country-list",children:g.map(x=>t.jsxs("button",{type:"button",className:"w-country-opt",onClick:w=>{var b;w.stopPropagation(),w.preventDefault(),d(x),m(!1),(b=h.current)==null||b.focus()},children:[t.jsx("span",{children:x.flag}),t.jsx("span",{children:x.name}),t.jsx("span",{className:"dial",children:x.dialCode})]},x.code))})]})]}),t.jsx("input",{type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:h,value:e,onChange:a,placeholder:"Phone number","aria-invalid":!!s,pattern:"^\\d{7,15}$"})]})};function Ar({placement:e="center"}){var m;const{deployment:a}=je(),[s,r]=o.useState(!1),i=(m=a==null?void 0:a.ui_settings)==null?void 0:m.logo_image_url;if(!i||s)return null;const l=e==="left"?"flex-start":e==="right"?"flex-end":"center";return t.jsx("div",{style:{display:"flex",justifyContent:l,width:"100%"},children:t.jsx("img",{src:i,alt:"Logo",onError:()=>r(!0),style:{maxWidth:40,maxHeight:40,width:"auto",height:"auto",objectFit:"contain"}})})}function et({children:e,footer:a}){return t.jsxs("div",{className:"w-card w-auth-card",children:[t.jsx("div",{className:"w-create-body",children:e}),a&&t.jsx("div",{className:"w-create-foot",children:a})]})}function nt({title:e,sub:a,children:s}){return t.jsxs("div",{className:"w-auth-head",children:[t.jsx(Ar,{}),t.jsxs("div",{className:"w-auth-head-text",children:[t.jsx("h1",{className:"w-auth-title",children:e}),a&&t.jsx("p",{className:"w-auth-sub",children:a})]}),s]})}function vt({size:e=16,onAccent:a}){return t.jsx("span",{className:a?"w-spin w-spin--on-accent":"w-spin",style:{width:e,height:e}})}function _s(){return t.jsx(Re,{children:t.jsx("div",{className:"w-card w-auth-card",children:t.jsx("div",{className:"w-create-body",children:t.jsxs("div",{className:"w-auth-skel","aria-hidden":"true",children:[t.jsxs("div",{className:"w-auth-skel-head",children:[t.jsx("span",{className:"w-skel w-skel-avatar"}),t.jsx("span",{className:"w-skel w-skel-title"}),t.jsx("span",{className:"w-skel w-skel-sub"})]}),t.jsxs("div",{className:"w-auth-skel-fields",children:[t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsx("span",{className:"w-skel w-skel-btn"})]})]})})})})}function g4(e){const a=e.indexOf(":");return a>=0?e.slice(0,a):e}function x4(e){const a=e.trim();if(!a)return null;try{return new URL(a.includes("://")?a:`https://${a}`).hostname.toLowerCase()||null}catch{return null}}function v4(e){try{return new URL(e)}catch{if(typeof window>"u")return null;try{return new URL(e,window.location.origin)}catch{return null}}}function b4(e,a){return!e||!a?!1:e===a?!0:e.endsWith(`.${a}`)}function y4(e,a){if(!a)return!1;const s=v4(a);if(!s||s.protocol!=="https:"&&s.protocol!=="http:")return!1;if((e==null?void 0:e.mode)==="staging")return!0;if(s.protocol!=="https:"||!(e!=null&&e.frontend_host))return!1;const r=x4(g4(e.frontend_host));return r?b4(s.hostname.toLowerCase(),r):!1}function gt(e,a){return a&&y4(e,a)?a:null}function j4(){var B,Q,ue,we,ne,ae,re,Me,q,tt,Ie,De,Ee,ce,W,G;const{loading:e,signUp:a,signupAttempt:s,discardSignupAttempt:r}=go(),{signIn:i}=cs("oauth"),{deployment:l}=je(),{navigate:m}=kt(),{session:c,refetch:d,loading:p}=it(),[u,f]=o.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[h,g]=o.useState({}),[x,w]=o.useState(!1),[b,j]=o.useState(void 0),[v,k]=o.useState(null),[N,_]=o.useState(null),[C,y]=o.useState(!1),E=((B=l==null?void 0:l.restrictions)==null?void 0:B.sign_up_mode)==="restricted",M=((Q=l==null?void 0:l.restrictions)==null?void 0:Q.sign_up_mode)==="waitlist",F=((we=(ue=l==null?void 0:l.auth_settings)==null?void 0:ue.multi_session_support)==null?void 0:we.enabled)??!1;o.useEffect(()=>{var K;if(!p&&(c!=null&&c.active_signin)&&!F&&!C){y(!0);let V=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));V||(V=((K=l==null?void 0:l.ui_settings)==null?void 0:K.after_signin_redirect_url)||null),!V&&(l!=null&&l.frontend_host)&&(V=`https://${l.frontend_host}`),V&&m(V)}},[c,p,F,l,m,C]),o.useEffect(()=>{var de;if(!l)return;const V=new URLSearchParams(window.location.search).get("invite_token");if(M&&!V){y(!0);const z=((de=l.ui_settings)==null?void 0:de.waitlist_page_url)||`https://${l.frontend_host}/waitlist`;m(z);return}V&&!v&&a&&(_(V),a.validateDeploymentInvitation(V).then(z=>{k(z),z.valid&&f(le=>({...le,first_name:z.first_name||le.first_name,last_name:z.last_name||le.last_name,email:z.email||le.email}))}).catch(()=>{g(z=>({...z,submit:"Failed to validate invitation."}))}))},[l,M,m,v,a]);const[A,T]=o.useState(!1),[P,S]=o.useState(""),$=K=>{let{name:V,value:de}=K.target;V==="phone_number"?de=de.replace(/[^0-9-]/g,""):V==="email"&&(de=de.toLowerCase()),f(z=>({...z,[V]:de})),g(z=>({...z,[V]:""}))},H=()=>{f({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),g({}),T(!1),S(""),r()},R=async K=>{if(K.preventDefault(),e||x)return;const V={},de=/^[a-zA-Z]{3,30}$/,z=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,le=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Je=/^\d{7,15}$/,ot=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(L!=null&&L.first_name.enabled&&(L!=null&&L.first_name.required&&!u.first_name?V.first_name="First name is required":u.first_name&&!de.test(u.first_name)&&(V.first_name="Invalid name")),L!=null&&L.last_name.enabled&&(L!=null&&L.last_name.required&&!u.last_name?V.last_name="Last name is required":u.last_name&&!de.test(u.last_name)&&(V.last_name="Invalid last name")),L!=null&&L.username.enabled&&(L!=null&&L.username.required&&!u.username?V.username="Username is required":u.username&&!z.test(u.username)&&(V.username="Username must be 3-20 characters")),L!=null&&L.email_address.enabled&&(L!=null&&L.email_address.required&&!u.email?V.email="Email address is required":u.email&&!le.test(u.email)&&(V.email="Invalid email address")),L!=null&&L.phone_number.enabled&&(L!=null&&L.phone_number.required&&!u.phone_number?V.phone_number="Phone number is required":u.phone_number&&!Je.test(u.phone_number)&&(V.phone_number="Phone number must contain 7-15 digits")),L!=null&&L.password.enabled&&(u.password?ot.test(u.password)||(V.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):V.password="Password is required"),g(V),!(Object.keys(V).length>0)){w(!0);try{const ge={...u};u.phone_number&&b&&(ge.phone_country_code=b),N&&(ge.invite_token=N),await a.create(ge)}catch(ge){g({submit:ge.message})}finally{w(!1)}}},O=async K=>{if(!(e||x)){w(!0);try{const V=new URLSearchParams(window.location.search),de=gt(l,V.get("redirect_uri"))||void 0,{data:z}=await i.create({provider:K.provider,redirectUri:de});z&&typeof z=="object"&&"oauth_url"in z&&(window.location.href=z.oauth_url)}catch(V){g({submit:V.message})}finally{w(!1)}}},Z=(l==null?void 0:l.social_connections.filter(K=>K.enabled))||[],L=l==null?void 0:l.auth_settings,U=!!((ne=L==null?void 0:L.first_name)!=null&&ne.enabled&&((ae=L==null?void 0:L.last_name)!=null&&ae.enabled)),D=async K=>{var de;if(K.preventDefault(),e||x)return;w(!0);const V={};if(!P){V.otp="OTP code is required",g(V),w(!1);return}g(V);try{const z=await a.completeVerification(P);"data"in z&&((de=z.data)!=null&&de.active_signin)&&await d()}catch{g(z=>({...z,submit:"Verification failed. Please try again."}))}finally{w(!1)}};if(o.useEffect(()=>{var K;if(s){if(s.completed){let V=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(V||(V=((K=l==null?void 0:l.ui_settings)==null?void 0:K.after_signup_redirect_url)||null),!V&&(l!=null&&l.frontend_host)&&(V=`https://${l.frontend_host}`),V){let de;try{de=new URL(V)}catch{de=new URL(V,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&de.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(de.toString())}return}if(!A){switch(s.current_step){case"verify_email":a.prepareVerification({strategy:"email_otp"});break;case"verify_phone":a.prepareVerification({strategy:"phone_otp"});break}T(!0)}}},[s,a,A,l,c,m]),p||C)return t.jsx(_s,{});const Y=((re=l==null?void 0:l.ui_settings)==null?void 0:re.app_name)||"App";if(E)return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx(Et,{className:"w-link",to:(Me=l==null?void 0:l.ui_settings)!=null&&Me.sign_in_page_url?`${l.ui_settings.sign_in_page_url}?help=true`:"#",children:"Get help"})]}),children:[t.jsx(nt,{title:"Sign-up restricted",sub:"This app isn't open for public sign-up right now."}),t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"New account registration is currently restricted. Please check back later or contact your administrator for an invitation."})})]})});if(A){const K=(s==null?void 0:s.current_step)==="verify_phone";return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((q=l==null?void 0:l.ui_settings)==null?void 0:q.support_page_url)||"#",children:"Get help"})]}),children:[t.jsx(nt,{title:K?"Check your phone":"Enter the code",sub:K?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",children:t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:H,children:[t.jsx(Pl,{weight:"bold"}),K?`+${u.phone_number}`:u.email]})}),t.jsxs("form",{onSubmit:D,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ba,{onComplete:async V=>{S(V)},onResend:async()=>{const V=K?"phone_otp":"email_otp";await a.prepareVerification({strategy:V})},error:h.otp,isSubmitting:x}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!P,children:x&&P?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${Y}`})]})]})})}return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Already have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((tt=l==null?void 0:l.ui_settings)==null?void 0:tt.sign_in_page_url)??""}${window.location.search}`,children:"Sign in"})]}),children:[t.jsx(nt,{title:"Create your account",sub:v!=null&&v.valid?"You've been invited — complete your registration below.":"Get started in a few seconds."}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Er,{connections:Z,callback:O}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})})]}),t.jsxs("form",{onSubmit:R,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[(((Ie=L==null?void 0:L.first_name)==null?void 0:Ie.enabled)||((De=L==null?void 0:L.last_name)==null?void 0:De.enabled))&&t.jsxs("div",{className:U?"w-grid-2":"",children:[((Ee=L==null?void 0:L.first_name)==null?void 0:Ee.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["First name",((ce=L==null?void 0:L.first_name)==null?void 0:ce.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"text",id:"first_name",name:"first_name",autoComplete:"given-name",required:!0,minLength:3,maxLength:30,value:u.first_name,onChange:$,placeholder:"Jane","aria-invalid":!!h.first_name,pattern:"^[a-zA-Z]{3,30}$"}),h.first_name&&t.jsx("span",{className:"w-input-err",children:h.first_name})]}),((W=L==null?void 0:L.last_name)==null?void 0:W.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Last name",((G=L==null?void 0:L.last_name)==null?void 0:G.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"text",id:"last_name",name:"last_name",autoComplete:"family-name",required:!0,minLength:3,maxLength:30,value:u.last_name,onChange:$,placeholder:"Doe","aria-invalid":!!h.last_name,pattern:"^[a-zA-Z]{3,30}$"}),h.last_name&&t.jsx("span",{className:"w-input-err",children:h.last_name})]})]}),(L==null?void 0:L.username.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Username",L.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"text",id:"username",name:"username",autoComplete:"username",minLength:3,maxLength:20,value:u.username,onChange:$,placeholder:"yourname","aria-invalid":!!h.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),h.username&&t.jsx("span",{className:"w-input-err",children:h.username})]}),(L==null?void 0:L.email_address.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Email address",L.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",maxLength:320,value:u.email,onChange:$,placeholder:"you@company.com","aria-invalid":!!h.email,required:!0,readOnly:(v==null?void 0:v.valid)&&!!(v!=null&&v.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),h.email&&t.jsx("span",{className:"w-input-err",children:h.email})]}),(L==null?void 0:L.phone_number.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Phone number",L.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(js,{value:u.phone_number,onChange:$,error:h.phone_number,countryCode:b,setCountryCode:j}),h.phone_number&&t.jsx("span",{className:"w-input-err",children:h.phone_number})]}),(L==null?void 0:L.password.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Password",L.password.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"new-password",value:u.password,onChange:$,placeholder:"Create a password","aria-invalid":!!h.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"}),h.password&&t.jsx("span",{className:"w-input-err",children:h.password})]}),h.submit&&t.jsx("span",{className:"w-input-err",children:h.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e,children:x?t.jsx(vt,{size:15,onAccent:!0}):"Continue"}),(()=>{var de,z;const K=(de=l==null?void 0:l.ui_settings)==null?void 0:de.tos_page_url,V=(z=l==null?void 0:l.ui_settings)==null?void 0:z.privacy_policy_url;return!K&&!V?null:t.jsxs("p",{className:"w-fineprint",children:["By continuing you agree to our"," ",K&&t.jsx(Et,{className:"w-link w-link--muted",to:K,children:"Terms of Service"}),K&&V&&" and ",V&&t.jsx(Et,{className:"w-link w-link--muted",to:V,children:"Privacy Policy"}),"."]})})()]})]})})}function Mc({icon:e,label:a,description:s,onClick:r,disabled:i,type:l="button"}){return t.jsxs("button",{type:l,className:"w-method",onClick:r,disabled:i,"data-disabled":i?"":void 0,children:[t.jsx("span",{className:"w-method-ic",children:e}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:a}),s&&t.jsx("span",{className:"w-method-desc",children:s})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Jt,{})})]})}const Rc=o.createContext(void 0);function Lc(){const e=o.useContext(Rc);if(!e)throw new Error("useSignIn must be used within a SignInProvider");return e}function _4({children:e}){var j;const{deployment:a}=je(),[s,r]=o.useState((a==null?void 0:a.auth_settings.first_factor)||"email_password"),i=o.useRef(!!(a!=null&&a.auth_settings.first_factor)),[l,m]=o.useState(""),[c,d]=o.useState(!1),[p,u]=o.useState(!1),[f,h]=o.useState(!1),[g,x]=o.useState("identifier"),w=(a==null?void 0:a.social_connections.filter(v=>v.enabled))||[],b=a==null?void 0:a.auth_settings;return o.useEffect(()=>{var k;const v=(k=a==null?void 0:a.auth_settings)==null?void 0:k.first_factor;!i.current&&v&&(r(v),i.current=!0)},[(j=a==null?void 0:a.auth_settings)==null?void 0:j.first_factor]),t.jsx(Rc.Provider,{value:{email:l,showOtherOptions:c,showForgotPassword:p,otpSent:f,setFirstFactor:r,setEmail:m,setShowOtherOptions:d,setShowForgotPassword:u,setOtpSent:h,enabledSocialsProviders:w,authSettings:b,firstFactor:s,signInStep:g,setSignInStep:x},children:e})}const k4=[{key:"email_magic_link",icon:t.jsx(Vu,{}),label:"Magic link",description:"We'll email you a one-click sign-in link"},{key:"email_password",icon:t.jsx(Iu,{}),label:"Email and password",description:"Sign in with your email and password"},{key:"email_otp",icon:t.jsx(jl,{}),label:"Email one-time code",description:"We'll send a verification code to your email"},{key:"phone_otp",icon:t.jsx(Ou,{}),label:"Phone number",description:"We'll send a verification code via SMS"},{key:"username_password",icon:t.jsx(fs,{}),label:"Username and password",description:"Sign in with your username and password"}];function Pc(){const{deployment:e}=je(),{signIn:a}=cs("oauth"),{setFirstFactor:s,firstFactor:r,setShowOtherOptions:i,setSignInStep:l}=Lc(),[m,c]=o.useState(!1),d=e==null?void 0:e.auth_settings,p=(e==null?void 0:e.social_connections.filter(x=>x.enabled))||[],u=async x=>{if(!m){c(!0);try{const{data:w}=await a.create({provider:x.provider});w&&typeof w=="object"&&"oauth_url"in w&&(window.location.href=w.oauth_url)}catch{}finally{c(!1)}}},f=k4.filter(x=>{if(x.key===r)return!1;const w=d==null?void 0:d.auth_factors_enabled;return w?w[x.key]:!1}),h=p.length>0,g=f.length>0;return t.jsxs(t.Fragment,{children:[h&&t.jsx(Er,{connections:p,callback:u}),h&&g&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"or"})}),g&&t.jsx("div",{className:"w-method-stack",children:f.map(x=>t.jsx(Mc,{icon:x.icon,label:x.label,description:x.description,onClick:()=>{s(x.key),l("identifier"),i(!1)}},x.key))})]})}function C4({onBack:e}){var F;const{deployment:a}=je(),{navigate:s}=kt(),[r,i]=o.useState("start"),[l,m]=o.useState(""),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(""),[g,x]=o.useState(""),{forgotPassword:w,verifyOtp:b,resetPassword:j}=Lo(),[v,k]=o.useState(!1),[N,_]=o.useState(null),C=async A=>{if(A.preventDefault(),!!l){k(!0),_(null);try{await w(l),i("otp")}catch(T){_(T)}finally{k(!1)}}},y=async A=>{if(A.preventDefault(),c.length===6){k(!0),_(null);try{const T=await b(l,c);T.data&&(u(T.data.token),i("reset"))}catch(T){_(T)}finally{k(!1)}}},E=async A=>{var T,P;if(A.preventDefault(),f===g&&!(f.length<8)){k(!0),_(null);try{const S=await j(p,f);if(S.data){const $=S.data,H=$.signin_attempts&&$.signin_attempts.length>0?$.signin_attempts[$.signin_attempts.length-1]:null;if(H&&!H.completed){const R=(T=a==null?void 0:a.ui_settings)==null?void 0:T.sign_in_page_url;if(R){const O=new URL(R,window.location.origin);O.searchParams.set("signin_attempt_id",H.id),s(O.toString())}else e()}else{const R=((P=a==null?void 0:a.ui_settings)==null?void 0:P.after_signin_redirect_url)||"/";s(R)}}}catch(S){_(S)}finally{k(!1)}}},M=t.jsx("span",{className:"w-auth-foot",children:t.jsx("span",{className:"w-link",style:{cursor:"pointer"},onClick:e,children:"Back to sign in"})});return t.jsxs(Re,{children:[r==="start"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Forgot your password?",sub:"Reset it, or sign in another way."}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>i("email"),disabled:v,children:"Reset your password"}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsx(Pc,{}),t.jsxs("p",{className:"w-secsub",style:{textAlign:"center",marginTop:16},children:["Unable to reset password?"," ",t.jsx("a",{className:"w-link",href:((F=a==null?void 0:a.ui_settings)==null?void 0:F.support_page_url)||"#",children:"Get help"})]})]}),r==="email"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Forgot password",sub:"Enter your email and we'll send you a code to reset your password."}),t.jsxs("form",{onSubmit:C,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx("input",{className:"w-input",type:"email",id:"email",value:l,onChange:A=>m(A.target.value),placeholder:"you@company.com",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Send code"})]})]}),r==="otp"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Enter verification code",sub:`We sent a 6-digit code to ${l}.`}),t.jsxs("form",{onSubmit:y,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ba,{onComplete:A=>d(A),isSubmitting:v,error:N==null?void 0:N.message,onResend:async()=>{await w(l)}}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v||c.length!==6,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Verify"})]})]}),r==="reset"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Reset password",sub:"Create a new password for your account."}),t.jsxs("form",{onSubmit:E,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"New password"}),t.jsx("input",{className:"w-input",type:"password",id:"password",value:f,onChange:A=>h(A.target.value),placeholder:"Enter new password",required:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Confirm new password"}),t.jsx("input",{className:"w-input",type:"password",id:"confirmPassword",value:g,onChange:A=>x(A.target.value),placeholder:"Confirm new password",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Reset password"})]})]})]})}function N4({onBack:e}){var r;const{deployment:a}=je(),s=(r=a==null?void 0:a.ui_settings)==null?void 0:r.app_name;return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to sign in"})}),children:[t.jsx(nt,{title:"All sign-in methods",sub:`Choose another way to sign in to ${s||"your account"}`}),t.jsx(Pc,{})]})})}function $c({methods:e,onSelectMethod:a,onBack:s}){return t.jsx(Re,{children:t.jsxs(et,{footer:s?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:s,children:"Back to login"})}):void 0,children:[t.jsx(nt,{title:"Two-factor authentication",sub:"Choose how you'd like to verify your identity"}),t.jsx("div",{className:"w-method-stack",children:e.map(r=>t.jsx(Mc,{icon:r.icon,label:r.name,description:r.phoneNumber?`${r.description} ${r.phoneNumber}`:r.description,onClick:()=>a(r.id),disabled:!r.available},r.id))})]})})}function Oc({onVerify:e,onBack:a,loading:s}){const[r,i]=o.useState(""),[l,m]=o.useState(""),c=p=>{if(p.preventDefault(),r.length!==4){m("Please enter the last 4 digits of your phone number");return}e(r)},d=p=>{const u=p.target.value.replace(/\D/g,"").slice(0,4);i(u),m("")};return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Choose a different method"})}),children:[t.jsx(nt,{title:"Verify phone",sub:"Enter the last 4 digits of your phone number."}),t.jsxs("form",{onSubmit:c,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"lastDigits",children:"Last 4 digits"}),t.jsx("input",{className:`w-input${l?" w-input--invalid":""}`,type:"text",id:"lastDigits",name:"lastDigits",value:r,onChange:d,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!l,autoFocus:!0}),l&&t.jsx("span",{className:"w-input-err",children:l})]}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:s||r.length!==4,children:s?t.jsx(vt,{onAccent:!0}):"Send code"})]})]})})}const S4=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),E4=()=>t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),t.jsx("path",{d:"M12 18h.01"})]}),A4=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})});function Zc({onBack:e,attempt:a,completeVerification:s,prepareVerification:r}){const{deployment:i}=je(),[l,m]=o.useState(""),[c,d]=o.useState({}),[p,u]=o.useState(!1),[f,h]=o.useState(null),[g,x]=o.useState(!0),[w,b]=o.useState(!1),[j,v]=o.useState(""),[k,N]=o.useState(!1),{navigate:_}=kt(),C=(a==null?void 0:a.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(S4,{}),available:C.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(E4,{}),available:C.includes("phone_otp"),phoneNumber:j},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(A4,{}),available:C.includes("backup_code")}].filter(P=>P.available),E=async P=>{h(P),x(!1),P==="phone_otp"&&b(!0)},M=async P=>{var S,$;if(a){u(!0);try{const H=await r({strategy:"phone_otp",lastDigits:P});H&&"data"in H&&((S=H.data)!=null&&S.otp_sent)?(($=H.data)!=null&&$.masked_phone&&v(H.data.masked_phone),b(!1)):d({phone:"Phone number verification failed"})}catch(H){d({phone:H.message})}finally{u(!1)}}},F=async(P,S)=>{if(P.preventDefault(),p)return;const $=S||l,H={};if($?f==="authenticator"&&$.length!==6?H.code="Authentication code must be 6 digits":f==="phone_otp"&&$.length!==6&&(H.code="SMS code must be 6 digits"):H.code="Verification code is required",d(H),!(Object.keys(H).length>0)){u(!0);try{await s($)}catch(R){d({submit:R.message})}finally{u(!1)}}},A=P=>{let S=P.target.value;f!=="backup_code"&&(S=S.replace(/\D/g,"").slice(0,6)),m(S),d($=>({...$,code:""}))};if(o.useEffect(()=>{var P;if(a.completed){N(!0);let S=gt(i,new URLSearchParams(window.location.search).get("redirect_uri"));if(S||(S=((P=i==null?void 0:i.ui_settings)==null?void 0:P.after_signin_redirect_url)||null),!S&&(i!=null&&i.frontend_host)&&(S=`https://${i.frontend_host}`),S){let $;try{$=new URL(S)}catch{$=new URL(S,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&$.searchParams.set("__dev_session__",xt(i.backend_host)||""),_($.toString())}return}},[a,i]),k)return t.jsx(_s,{});if(g)return y.length===0?t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(nt,{title:"Set up two-factor authentication",sub:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."}),e&&t.jsx("div",{style:{textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to login"})})]})}):t.jsx($c,{methods:y,onSelectMethod:E,onBack:e});if(w&&f==="phone_otp")return t.jsx(Oc,{onVerify:M,onBack:()=>{b(!1),x(!0),h(null)},loading:p});const T=f==="authenticator"?"Enter the 6-digit code from your authenticator app":f==="phone_otp"?`Enter the 6-digit code sent to your phone ${j}`:"Enter one of your backup codes";return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(nt,{title:"Two-factor authentication",sub:T}),t.jsxs("form",{onSubmit:F,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[f==="backup_code"?t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"code",children:"Backup code"}),t.jsx("input",{className:`w-input${c.code?" w-input--invalid":""}`,type:"text",id:"code",name:"code",value:l,onChange:A,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!c.code,autoFocus:!0}),c.code&&t.jsx("span",{className:"w-input-err",children:c.code})]}):t.jsx(ba,{onComplete:async P=>{if(m(P),f!=="backup_code"){const S=new Event("submit",{bubbles:!0,cancelable:!0});await F(S,P)}},onResend:f==="phone_otp"?async()=>{try{await r({strategy:"phone_otp",lastDigits:j.slice(-4)})}catch(P){d({submit:P.message})}}:void 0,error:c.code,isSubmitting:p}),c.submit&&t.jsx("span",{className:"w-input-err",children:c.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:p||!l,children:p?t.jsx(vt,{onAccent:!0}):"Verify"})]}),t.jsxs("div",{style:{marginTop:18,textAlign:"center",display:"flex",flexDirection:"column",gap:8},children:[t.jsx("button",{type:"button",className:"w-link",onClick:()=>{x(!0),h(null),m(""),d({})},children:"Try another method"}),e&&t.jsx("button",{type:"button",className:"w-link w-link--muted",onClick:e,children:"Back to login"})]})]})})}function Hc({attempt:e,onBack:a,completeProfile:s,completeVerification:r,prepareVerification:i}){var Z,L,U,D,Y,B,Q,ue,we;const{deployment:l}=je(),{navigate:m}=kt(),[c,d]=o.useState({}),[p,u]=o.useState({}),[f,h]=o.useState("US"),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(null),[k,N]=o.useState(!1),_=j,C=w,y=()=>{var ae;N(!0);let ne=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(ne||(ne=((ae=l==null?void 0:l.ui_settings)==null?void 0:ae.after_signin_redirect_url)||null),!ne&&(l!=null&&l.frontend_host)&&(ne=`https://${l.frontend_host}`),ne){let re;try{re=new URL(ne)}catch{re=new URL(ne,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&re.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(re.toString())}},E=async ne=>{b(!0),v(null);try{await s(ne)&&y()}catch(ae){const re=ae;throw v(re),re}finally{b(!1)}},M=async ne=>{b(!0),v(null);try{return await r(ne)&&y(),!0}catch(ae){return v(ae),!1}finally{b(!1)}};if(k||!e)return t.jsx(_s,{});const F=e.missing_fields||[],A=l==null?void 0:l.auth_settings,T=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||g,P=ne=>{const{name:ae,value:re}=ne.target;d(Me=>({...Me,[ae]:re})),p[ae]&&u(Me=>({...Me,[ae]:""}))},S=()=>{const ne={};return F.forEach(ae=>{var q,tt,Ie,De,Ee;const re=c[ae];let Me=!1;switch(ae){case"first_name":Me=((q=A==null?void 0:A.first_name)==null?void 0:q.enabled)||!1;break;case"last_name":Me=((tt=A==null?void 0:A.last_name)==null?void 0:tt.enabled)||!1;break;case"username":Me=((Ie=A==null?void 0:A.username)==null?void 0:Ie.enabled)||!1;break;case"phone_number":Me=((De=A==null?void 0:A.phone_number)==null?void 0:De.enabled)||!1;break;case"email_address":Me=((Ee=A==null?void 0:A.email_address)==null?void 0:Ee.enabled)||!1;break;default:Me=!0}if(Me&&(!re||re.trim()==="")){const ce=ae.replace("_"," ").replace(/\b\w/g,W=>W.toUpperCase());ne[ae]=`${ce} is required`}}),c.username&&F.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(c.username)||(ne.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),c.phone_number&&F.includes("phone_number")&&(/^\d{7,15}$/.test(c.phone_number)||(ne.phone_number="Phone number must contain 7-15 digits")),c.email&&F.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(c.email)||(ne.email_address="Please enter a valid email address")),u(ne),Object.keys(ne).length===0},$=async ne=>{if(ne.preventDefault(),!S())return;const ae={...c};c.phone_number&&f&&(ae.phone_country_code=f),await E(ae)},H=ne=>{const ae=ne.target.value;d(re=>({...re,phone_number:ae})),p.phone_number&&u(re=>({...re,phone_number:""}))},R=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(l==null?void 0:l.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]});if(T){const ne=e.current_step==="verify_phone_otp"?"Verify your phone number":"Verify your email",ae=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",re=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx(Re,{children:t.jsxs(et,{footer:R,children:[t.jsx(nt,{title:ne,sub:ae}),t.jsxs("form",{onSubmit:Me=>Me.preventDefault(),noValidate:!0,style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsx(ba,{onComplete:M,onResend:async()=>{await i({strategy:re})},error:_==null?void 0:_.message,isSubmitting:C}),_&&t.jsx("span",{className:"w-input-err",children:_.message})]}),t.jsx("div",{style:{marginTop:16,textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:()=>x(!1),children:"Back to profile completion"})})]})})}const O=!!((Z=A==null?void 0:A.first_name)!=null&&Z.enabled&&((L=A==null?void 0:A.last_name)!=null&&L.enabled)&&F.includes("first_name")&&F.includes("last_name"));return t.jsx(Re,{children:t.jsxs(et,{footer:a?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Back to login"})}):R,children:[t.jsx(nt,{title:"Complete your profile",sub:"Please provide the following information to continue"}),t.jsxs("form",{onSubmit:$,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(F.includes("first_name")||F.includes("last_name"))&&(((U=A==null?void 0:A.first_name)==null?void 0:U.enabled)||((D=A==null?void 0:A.last_name)==null?void 0:D.enabled))&&t.jsxs("div",{className:O?"w-grid-2":"",children:[F.includes("first_name")&&((Y=A==null?void 0:A.first_name)==null?void 0:Y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",A.first_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.first_name?" w-input--invalid":""}`,type:"text",id:"first_name",name:"first_name",value:c.first_name||"",onChange:P,placeholder:"Enter your first name",disabled:C,autoComplete:"given-name"}),p.first_name&&t.jsx("span",{className:"w-input-err",children:p.first_name})]}),F.includes("last_name")&&((B=A==null?void 0:A.last_name)==null?void 0:B.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",A.last_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.last_name?" w-input--invalid":""}`,type:"text",id:"last_name",name:"last_name",value:c.last_name||"",onChange:P,placeholder:"Enter your last name",disabled:C,autoComplete:"family-name"}),p.last_name&&t.jsx("span",{className:"w-input-err",children:p.last_name})]})]}),F.includes("username")&&((Q=A==null?void 0:A.username)==null?void 0:Q.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"username",children:["Username",A.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.username?" w-input--invalid":""}`,type:"text",id:"username",name:"username",value:c.username||"",onChange:P,placeholder:"Choose a username",disabled:C,autoComplete:"username"}),p.username&&t.jsx("span",{className:"w-input-err",children:p.username})]}),F.includes("phone_number")&&((ue=A==null?void 0:A.phone_number)==null?void 0:ue.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(js,{value:c.phone_number||"",onChange:H,error:p.phone_number,countryCode:f,setCountryCode:h}),p.phone_number&&t.jsx("span",{className:"w-input-err",children:p.phone_number})]}),F.includes("email_address")&&((we=A==null?void 0:A.email_address)==null?void 0:we.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",A.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.email_address?" w-input--invalid":""}`,type:"email",id:"email",name:"email",value:c.email||"",onChange:P,placeholder:"Enter your email address",disabled:C,autoComplete:"email"}),p.email_address&&t.jsx("span",{className:"w-input-err",children:p.email_address})]}),_&&t.jsx("span",{className:"w-input-err",children:_.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:C,children:C?t.jsx(vt,{onAccent:!0}):"Continue"})]})]})})}function Fc({onComplete:e,onSkip:a}){var u;const[s,r]=o.useState(!1),[i,l]=o.useState(null),{registerPasskey:m}=va(),{deployment:c}=je(),d=async()=>{r(!0),l(null);try{await m(),e==null||e()}catch(f){l(f instanceof Error?f.message:"Failed to register passkey")}finally{r(!1)}},p=((u=c==null?void 0:c.ui_settings)==null?void 0:u.app_name)||"this app";return t.jsxs("div",{className:"w-flex w-flex-col w-items-center w-text-center",children:[t.jsx("div",{className:"w-feature-badge",children:t.jsx(nr,{size:26})}),t.jsx("h1",{className:"w-title-lg",children:"Add a passkey"}),t.jsxs("p",{className:"w-sub",style:{marginTop:6,maxWidth:320},children:["Sign in faster and more securely with a passkey. Use your fingerprint, face, or screen lock to access ",p,"."]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,width:"100%",marginTop:24},children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:d,disabled:s,children:s?t.jsxs(t.Fragment,{children:[t.jsx(vt,{size:15,onAccent:!0}),"Registering…"]}):t.jsxs(t.Fragment,{children:[t.jsx(nr,{}),"Add passkey"]})}),t.jsx("button",{type:"button",className:"w-social",onClick:a,children:"Maybe later"})]}),i&&t.jsx("p",{className:"w-input-err",style:{marginTop:14},children:i})]})}function M4(){return t.jsx(_4,{children:t.jsx(R4,{})})}function R4(){var Bt,ya,ja,yt,sa,na,ra,ia,oe,xe,Ne,J,ve,Ye,Ve,jt,_t,Be,wt,Gt,oa,la,ca;const{deployment:e}=je(),{navigate:a}=kt(),{session:s,loading:r,refetch:i,exchangeTicket:l,switchSignIn:m}=it(),c=((ya=(Bt=e==null?void 0:e.auth_settings)==null?void 0:Bt.multi_session_support)==null?void 0:ya.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:u,showForgotPassword:f,setShowForgotPassword:h,showOtherOptions:g,setShowOtherOptions:x,enabledSocialsProviders:w,firstFactor:b,setFirstFactor:j,signInStep:v,setSignInStep:k}=Lc(),{loading:N,signIn:_,signinAttempt:C,discardSignInAttempt:y,setSignInAttempt:E}=cs("generic"),{signIn:M}=cs("oauth"),{signIn:F}=cs("passkey"),[A,T]=o.useState({email:"",username:"",password:"",phone:""}),[P,S]=o.useState({}),[$,H]=o.useState(!1),[R,O]=o.useState(""),[Z,L]=o.useState("US"),[U,D]=o.useState(!1),[Y,B]=o.useState(null),[Q,ue]=o.useState(!1),[we,ne]=o.useState(!1),[ae,re]=o.useState(!1),[Me,q]=o.useState(60),[tt,Ie]=o.useState(!1),[De,Ee]=o.useState(null),ce=[...(s==null?void 0:s.signins)||[]].sort((X,te)=>{var pe,Pe;return X.id===((pe=s==null?void 0:s.active_signin)==null?void 0:pe.id)?-1:te.id===((Pe=s==null?void 0:s.active_signin)==null?void 0:Pe.id)?1:0});o.useEffect(()=>{const X=new URLSearchParams(window.location.search),te=X.get("error"),pe=X.get("error_description");if(te==="access_denied"&&pe){B(pe),X.delete("error"),X.delete("error_description");const Pe=X.toString()?`${window.location.pathname}?${X.toString()}`:window.location.pathname;window.history.replaceState({},"",Pe)}},[]),o.useEffect(()=>{if(b!=="email_magic_link"||!p)return;q(60),Ie(!1);const X=setInterval(()=>{q(te=>te<=1?(Ie(!0),clearInterval(X),0):te-1)},1e3);return()=>clearInterval(X)},[b,p]),o.useEffect(()=>{var X,te,pe,Pe;if(!r&&(s!=null&&s.active_signin)&&!c&&!U&&!Q){let Ae=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));Ae||(Ae=((X=e==null?void 0:e.ui_settings)==null?void 0:X.after_signin_redirect_url)||null),!Ae&&(e!=null&&e.frontend_host)&&(Ae=`https://${e.frontend_host}`);const ut=(te=e==null?void 0:e.auth_settings)==null?void 0:te.passkey;(ut==null?void 0:ut.enabled)&&(ut==null?void 0:ut.prompt_registration_on_auth)&&!((Pe=(pe=s.active_signin)==null?void 0:pe.user)!=null&&Pe.has_passkeys)?(Ee(Ae),ue(!0)):Ae&&(D(!0),a(Ae))}},[s,r,c,e,a,U]);const W=X=>{let{name:te,value:pe}=X.target;te==="phone"?pe=pe.replace(/[^0-9]/g,""):te==="email"&&(d(pe),pe=pe.toLowerCase()),T(Pe=>({...Pe,[te]:pe})),S(Pe=>({...Pe,[te]:""}))},G=()=>{T({email:"",username:"",password:"",phone:""}),S({}),L("US"),k("identifier")},K=async X=>{if(!X){S({email:"Email address is required"});return}H(!0),S({});try{const te=await _.identify(X);if(te.strategy==="sso"&&te.connection_id){const pe=new URLSearchParams(window.location.search),Pe=gt(e,pe.get("redirect_uri"))||void 0,Ae=await _.initEnterpriseSso(te.connection_id,Pe);if(Ae&&Ae.sso_url){D(!0),window.location.href=Ae.sso_url;return}}else if(te.strategy==="social"&&te.provider){const pe=w.find(Pe=>Pe.provider===te.provider);if(pe){const Pe=new URLSearchParams(window.location.search),Ae=gt(e,Pe.get("redirect_uri"))||void 0,{data:ut}=await M.create({provider:pe.provider,redirectUri:Ae});if(ut&&typeof ut=="object"&&"oauth_url"in ut){D(!0),window.location.href=ut.oauth_url;return}}else k("password")}else k("password")}catch(te){S({submit:te.message})}finally{U||H(!1)}},V=async X=>{if(X.preventDefault(),N||$)return;y();const te={};if(v==="identifier"&&b==="email_password"){if(!A.email){S({email:"Email address is required"});return}await K(A.email);return}if(v==="identifier"&&b==="username_password"){if(!A.username){S({username:"Username is required"});return}S({}),k("password");return}if(b==="email_password"?(A.email||(te.email="Email address is required"),A.password||(te.password="Password is required")):b==="username_password"?(A.username||(te.username="Username is required"),A.password||(te.password="Password is required")):b==="email_otp"||b==="email_magic_link"?A.email||(te.email="Email address is required"):b==="phone_otp"&&(A.phone?/^\d{7,15}$/.test(A.phone)||(te.phone="Phone number must contain 7-15 digits"):te.phone="Phone number is required"),S(te),Object.keys(te).length>0)return;let pe="";switch(b){case"email_password":pe="plain_email";break;case"username_password":pe="plain_username";break;case"email_otp":pe="email_otp";break;case"email_magic_link":pe="magic_link";break;case"phone_otp":pe="phone_otp";break}const Pe=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";H(!0);try{const Ae={...A,strategy:pe};b==="phone_otp"&&Z&&(Ae.phone_country_code=Z),await _.create(Ae),Pe||H(!1)}catch(Ae){S({submit:Ae.message}),H(!1)}},de=async X=>{if(X.preventDefault(),N||$)return;const te={};if(!R){te.otp="OTP code is required",S(te);return}H(!0),S({});try{await _.completeVerification(R),u(!1),O("")}catch(pe){S({otp:pe.message||"Verification failed"})}finally{H(!1)}},z=async X=>{if(!(N||$)){H(!0);try{const te=new URLSearchParams(window.location.search),pe=gt(e,te.get("redirect_uri"))||void 0,{data:Pe}=await M.create({provider:X.provider,redirectUri:pe});Pe&&typeof Pe=="object"&&"oauth_url"in Pe&&(window.location.href=Pe.oauth_url)}catch(te){S({submit:te.message})}finally{H(!1)}}},le=async()=>{var X;if(!(N||$)){H(!0),S({});try{const te=await F.create();if("data"in te&&te.data){await i();let pe=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));pe||(pe=((X=e==null?void 0:e.ui_settings)==null?void 0:X.after_signin_redirect_url)||null),!pe&&(e!=null&&e.frontend_host)&&(pe=`https://${e.frontend_host}`),D(!0),pe&&a(pe)}}catch(te){S({submit:te.message||"Passkey sign-in failed"})}finally{H(!1)}}},Je=()=>{var pe;let X=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(X||(X=((pe=e==null?void 0:e.ui_settings)==null?void 0:pe.after_signin_redirect_url)||null),!X&&(e!=null&&e.frontend_host)&&(X=`https://${e.frontend_host}`),!X)return null;let te;try{te=new URL(X)}catch{te=new URL(X,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&te.searchParams.set("__dev_session__",xt(e.backend_host)||""),te.toString()},ot=async X=>{if(!(N||$)){S({}),H(!0);try{await m(X);const te=Je();te&&(D(!0),a(te))}catch(te){S({submit:te.message||"Failed to continue with selected account"})}finally{H(!1)}}},ge=(X,te)=>`${X||""} ${te||""}`.trim().split(" ").filter(Boolean).map(pe=>pe[0]).join("").toUpperCase().slice(0,2)||"?",lt=o.useRef(!1);if(o.useEffect(()=>{if(r)return;const X=new URLSearchParams(window.location.search),te=X.get("ticket");if(te&&!lt.current&&!N){lt.current=!0,X.delete("ticket");const Pe=X.toString()?`${window.location.pathname}?${X.toString()}`:window.location.pathname;window.history.replaceState({},"",Pe),(async()=>{var ut;try{H(!0),await l(te),D(!0);let Vt=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(Vt||(Vt=((ut=e==null?void 0:e.ui_settings)==null?void 0:ut.after_signin_redirect_url)||null),!Vt&&(e!=null&&e.frontend_host)&&(Vt=`https://${e.frontend_host}`),Vt){let Ss;try{Ss=new URL(Vt)}catch{Ss=new URL(Vt,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Ss.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(Ss.toString())}return}catch(Vt){S({submit:Vt.message||"Failed to exchange ticket"}),lt.current=!1}finally{H(!1)}})();return}const pe=X.get("signin_attempt_id");if(pe&&(s!=null&&s.signin_attempts)&&!C){const Pe=s.signin_attempts.find(Ae=>Ae.id===pe);if(Pe){E(Pe),X.delete("signin_attempt_id");const Ae=X.toString()?`${window.location.pathname}?${X.toString()}`:window.location.pathname;window.history.replaceState({},"",Ae)}}},[s,r,C,E,N]),o.useEffect(()=>{var Pe;if(!C)return;if(C.completed){D(!0);let Ae=new URLSearchParams(window.location.search).get("redirect_uri");if(Ae||(Ae=((Pe=e==null?void 0:e.ui_settings)==null?void 0:Pe.after_signin_redirect_url)||null),!Ae&&(e!=null&&e.frontend_host)&&(Ae=`https://${e.frontend_host}`),Ae){let ut;try{ut=new URL(Ae)}catch{ut=new URL(Ae,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&ut.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(ut.toString())}return}if(!_||p)return;const te={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(!te)return;(async()=>{try{await _.prepareVerification({strategy:te}),H(!1),u(!0)}catch{S({submit:"Failed to send verification. Please try again."}),H(!1)}})()},[C,_,p,u,a,e]),g)return t.jsx(N4,{onBack:()=>x(!1)});if(f)return t.jsx(C4,{onBack:()=>h(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return t.jsx(Zc,{attempt:C,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return t.jsx(Hc,{attempt:C,completeProfile:_.completeProfile,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if(Q){const X=()=>{ue(!1),De&&(D(!0),a(De))},te=()=>{ue(!1),De&&(D(!0),a(De))};return t.jsx(Re,{children:t.jsx(et,{children:t.jsx(Fc,{onComplete:X,onSkip:te})})})}if(r||U)return t.jsx(_s,{});const Ke=((ja=e==null?void 0:e.ui_settings)==null?void 0:ja.app_name)||"App",ie=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&p,me=b==="email_magic_link",Ze=c&&!ie&&ce.length>0&&!ae,He=()=>{u(!1),y(),G()};let qe;if(ie){const X=b==="phone_otp"?"Check your phone":me?"Check your inbox":"Enter the code",te=me?"We sent a magic link to your email — click it to sign in instantly.":b==="phone_otp"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",pe=(b==="email_otp"||me)&&A.email?A.email:b==="phone_otp"&&A.phone?`+${A.phone}`:null;qe=t.jsx(nt,{title:X,sub:te,children:pe&&t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:He,children:[t.jsx(Pl,{weight:"bold"}),pe]})})}else qe=t.jsx(nt,{title:"Sign in to your account",sub:`Please enter your details to continue to ${Ke}.`});let ct;ie?ct=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((yt=e==null?void 0:e.ui_settings)==null?void 0:yt.support_page_url)||"#",children:"Get help"})]}):ct=t.jsxs("span",{className:"w-auth-foot",children:["Don't have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((sa=e==null?void 0:e.ui_settings)==null?void 0:sa.sign_up_page_url)??""}${window.location.search}`,children:"Sign up"})]});let Rt;if(ie&&me)Rt=t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,padding:"12px 0 4px"},children:tt?t.jsx("button",{type:"button",className:"w-link w-linkbtn",onClick:async()=>{Ie(!1),q(60);try{await _.prepareVerification({strategy:"magic_link"})}catch{}},children:"Resend magic link"}):t.jsxs("span",{className:"w-secsub",children:["Resend in ",Me,"s"]})});else if(ie)Rt=t.jsxs("form",{onSubmit:de,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ba,{onComplete:async X=>{if(O(X),X&&X.length===6){H(!0),S({});try{await _.completeVerification(X),u(!1)}catch(te){S({otp:te.message||"Verification failed"})}finally{H(!1)}}},onResend:async()=>{const X=b==="email_otp"?"email_otp":"phone_otp";await _.prepareVerification({strategy:X})},error:P.otp,isSubmitting:$}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N||!R,children:$&&R?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${Ke}`})]});else{const X=(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((ra=(na=e==null?void 0:e.auth_settings)==null?void 0:na.email_address)==null?void 0:ra.enabled),te=b==="username_password"&&((oe=(ia=e==null?void 0:e.auth_settings)==null?void 0:ia.username)==null?void 0:oe.enabled),pe=b==="phone_otp"&&((Ne=(xe=e==null?void 0:e.auth_settings)==null?void 0:xe.phone_number)==null?void 0:Ne.enabled),Pe=v==="password"&&(b==="email_password"||b==="username_password")&&((ve=(J=e==null?void 0:e.auth_settings)==null?void 0:J.password)==null?void 0:ve.enabled);Rt=t.jsxs(t.Fragment,{children:[w.length>0&&t.jsx(Er,{connections:w,callback:z}),((Ve=(Ye=e==null?void 0:e.auth_settings)==null?void 0:Ye.passkey)==null?void 0:Ve.enabled)&&t.jsxs("button",{type:"button",className:"w-social",style:{marginTop:w.length>0?10:0},onClick:le,disabled:$,children:[t.jsx(nr,{}),t.jsx("span",{children:"Sign in with a passkey"})]}),(w.length>0||((_t=(jt=e==null?void 0:e.auth_settings)==null?void 0:jt.passkey)==null?void 0:_t.enabled))&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsxs("form",{onSubmit:V,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[X&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Email address"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&b==="email_password"&&A.email?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:A.email}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>k("identifier"),children:"Edit"})]}):t.jsx(Kt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",value:A.email,onChange:W,placeholder:"you@company.com","aria-invalid":!!P.email}),P.email&&t.jsx("span",{className:"w-input-err",children:P.email})]}),te&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Username"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&A.username?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:A.username}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>{k("identifier"),T(Ae=>({...Ae,password:""}))},children:"Edit"})]}):t.jsx(Kt,{className:"w-input",type:"text",id:"username",name:"username",value:A.username,onChange:W,placeholder:"yourname","aria-invalid":!!P.username,autoComplete:"username"}),P.username&&t.jsx("span",{className:"w-input-err",children:P.username})]}),pe&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(js,{value:A.phone,onChange:W,error:P.phone,countryCode:Z,setCountryCode:L}),P.phone&&t.jsx("span",{className:"w-input-err",children:P.phone})]}),Pe&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{className:"w-label",children:"Password"}),t.jsx("span",{className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer"},onClick:()=>h(!0),children:"Forgot?"})]}),t.jsx(Kt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"current-password",value:A.password,onChange:W,placeholder:"••••••••","aria-invalid":!!P.password}),P.password&&t.jsx("span",{className:"w-input-err",children:P.password})]}),P.submit&&t.jsx("span",{className:"w-input-err",children:P.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N,children:$?t.jsx(vt,{size:15,onAccent:!0}):t.jsxs(t.Fragment,{children:[v==="identifier"?"Continue":"Sign in",t.jsx(Jt,{weight:"bold"})]})}),v==="password"&&((wt=(Be=e==null?void 0:e.auth_settings)==null?void 0:Be.auth_factors_enabled)==null?void 0:wt.email_otp)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-or",style:{margin:"5px 0"},children:t.jsx("span",{children:"OR"})}),t.jsxs("button",{type:"button",className:"w-method",disabled:$,onClick:async()=>{H(!0),S({});try{await _.create({email:A.email,strategy:"email_otp"}),j("email_otp")}catch(Ae){S({submit:Ae.message}),H(!1)}},children:[t.jsx("span",{className:"w-method-ic",children:t.jsx(jl,{})}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:"Sign in with a code"}),t.jsx("span",{className:"w-method-desc",children:"We'll send a 6-digit code to your email"})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Jt,{})})]})]})]})]})}return t.jsx(Re,{children:t.jsxs(et,{footer:ct,children:[qe,Y&&t.jsxs("div",{className:"w-banner w-banner--error",style:{marginBottom:18},children:[t.jsx(Ta,{weight:"fill"}),t.jsxs("span",{className:"w-banner-txt",children:[t.jsx("strong",{children:"Access denied."})," ",Y," ",t.jsx("span",{className:"w-link",onClick:()=>B(null),children:"Try again"})]})]}),Ze&&(we?t.jsxs("div",{className:"w-acct-list",children:[t.jsx("div",{className:"w-secsub w-acct-list-head",children:"Choose an account"}),t.jsxs("div",{className:"w-acct-list-body",children:[ce.map(X=>{var te,pe,Pe,Ae;return t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>ot(X.id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:X.user.has_profile_picture?t.jsx("img",{src:X.user.profile_picture_url,alt:((te=X.user.primary_email_address)==null?void 0:te.email)||"account"}):ge(X.user.first_name,X.user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsx("span",{className:"w-acct-name",children:X.user.first_name&&X.user.last_name?`${X.user.first_name} ${X.user.last_name}`:X.user.first_name||((Pe=(pe=X.user.primary_email_address)==null?void 0:pe.email)==null?void 0:Pe.split("@")[0])||"Account"}),t.jsx("span",{className:"w-secsub",children:(Ae=X.user.primary_email_address)==null?void 0:Ae.email})]}),t.jsx(Jt,{className:"w-acct-go"})]},X.id)}),t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>{ne(!1),re(!0),G()},children:[t.jsx("span",{className:"w-avatar",style:{background:"var(--wa-surface-subtle)",color:"var(--wa-text-muted)"},children:t.jsx(Gu,{size:16})}),t.jsx("span",{className:"w-acct-text w-acct-name",children:"Use a different account"}),t.jsx(Jt,{className:"w-acct-go"})]})]})]}):t.jsxs("button",{type:"button",className:"w-acct","data-active":!0,style:{marginBottom:18},onClick:()=>ot(ce[0].id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:ce[0].user.has_profile_picture?t.jsx("img",{src:ce[0].user.profile_picture_url,alt:((Gt=ce[0].user.primary_email_address)==null?void 0:Gt.email)||"account"}):ge(ce[0].user.first_name,ce[0].user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsxs("span",{className:"w-acct-name",children:["Welcome back,"," ",ce[0].user.first_name||((la=(oa=ce[0].user.primary_email_address)==null?void 0:oa.email)==null?void 0:la.split("@")[0])||"back"]}),t.jsx("span",{className:"w-secsub",children:(ca=ce[0].user.primary_email_address)==null?void 0:ca.email})]}),t.jsx("span",{className:"w-link w-link--muted w-link--sm",style:{flex:"none"},onClick:X=>{X.stopPropagation(),ce.length>1?ne(!0):(re(!0),G())},children:"Not you?"})]})),Rt]})})}function L4(){var b,j,v,k,N,_,C,y,E,M,F,A;const{deployment:e}=je(),{loading:a,joinWaitlist:s}=Ao(),[r,i]=o.useState({first_name:"",last_name:"",email:""}),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(null),f=()=>{if(p)return p.message},h=e==null?void 0:e.auth_settings,g=!!((b=h==null?void 0:h.first_name)!=null&&b.enabled&&((j=h==null?void 0:h.last_name)!=null&&j.enabled)),x=T=>{const{name:P,value:S}=T.target;i($=>({...$,[P]:S}))},w=async T=>{if(T.preventDefault(),!!h){d(!0),u(null);try{(await s(r)).data&&m(!0)}catch(P){u(P)}finally{d(!1)}}};return l?t.jsx(Re,{children:t.jsx(et,{children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,textAlign:"center"},children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{weight:"bold"})})]}),t.jsx("h1",{className:"w-auth-title",children:"You're on the waitlist"}),t.jsxs("p",{className:"w-auth-sub",children:["Thanks for your interest! We'll notify you at"," ",r.email," when we're ready for you to join."]})]})})}):t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx("a",{href:"/contact",className:"w-link",children:"Get help"})]}),children:[t.jsx(nt,{title:"Join the waitlist",sub:"Be the first to know when we launch!"}),t.jsxs("form",{onSubmit:w,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(((v=h==null?void 0:h.first_name)==null?void 0:v.enabled)||((k=h==null?void 0:h.last_name)==null?void 0:k.enabled))&&t.jsxs("div",{className:g?"w-grid-2":"",children:[((N=h==null?void 0:h.first_name)==null?void 0:N.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",((_=h==null?void 0:h.first_name)==null?void 0:_.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"first_name",name:"first_name",required:(C=h==null?void 0:h.first_name)==null?void 0:C.required,minLength:2,maxLength:50,value:r.first_name,onChange:x,placeholder:"First name"})]}),((y=h==null?void 0:h.last_name)==null?void 0:y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",((E=h==null?void 0:h.last_name)==null?void 0:E.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"last_name",name:"last_name",required:(M=h==null?void 0:h.last_name)==null?void 0:M.required,minLength:2,maxLength:50,value:r.last_name,onChange:x,placeholder:"Last name"})]})]}),t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",((F=h==null?void 0:h.email_address)==null?void 0:F.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"email",id:"email",name:"email",required:(A=h==null?void 0:h.email_address)==null?void 0:A.required,value:r.email,onChange:x,placeholder:"Enter your email address"})]}),f()&&t.jsx("span",{className:"w-input-err",children:f()}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:c||a,children:c||a?t.jsx(vt,{onAccent:!0}):"Join waitlist"})]})]})})}function Zn({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx(Re,{children:t.jsxs(et,{footer:l,children:[t.jsx(nt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function P4(){const{deployment:e}=je(),{navigate:a}=kt(),{error:s,session:r,processed:i,signinAttempt:l,redirectUri:m,loading:c}=Mo(),[d,p]=o.useState(!1),[u,f]=o.useState(null),h=()=>{window.location.reload()},g=()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||"/sign-in";a(b)},x=()=>{p(!1),u&&a(u)},w=()=>{p(!1),u&&a(u)};if(o.useEffect(()=>{var b,j,v,k,N;if(!(!i||c||d)){if(l&&!l.completed){const _=(b=e==null?void 0:e.ui_settings)==null?void 0:b.sign_in_page_url;if(_){const C=new URL(_,window.location.origin);C.searchParams.set("signin_attempt_id",l.id),m&&C.searchParams.set("redirect_uri",m),a(C.toString())}return}if(l!=null&&l.completed){const C=gt(e,m)||((j=e==null?void 0:e.ui_settings)==null?void 0:j.after_signin_redirect_url)||(e==null?void 0:e.frontend_host)||"/";let y;try{y=new URL(C)}catch{y=new URL(C,window.location.origin)}if(y){(e==null?void 0:e.mode)==="staging"&&y.searchParams.set("__dev_session__",xt(e.backend_host)||"");const E=(v=e==null?void 0:e.auth_settings)==null?void 0:v.passkey;(E==null?void 0:E.enabled)&&(E==null?void 0:E.prompt_registration_on_auth)&&!((N=(k=r==null?void 0:r.active_signin)==null?void 0:k.user)!=null&&N.has_passkeys)?(f(y.toString()),p(!0)):a(y.toString())}}}},[r,i,c,m,e,l,a]),o.useEffect(()=>{s&&s.message.includes("No OAuth callback data found")&&setTimeout(()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||(e==null?void 0:e.frontend_host);b&&a(b)},2e3)},[s,e,a]),d)return t.jsx(Re,{children:t.jsx(et,{children:t.jsx(Fc,{onComplete:x,onSkip:w})})});if(r&&i&&!s)return t.jsx(Zn,{title:"Success",sub:"Authentication completed successfully",icon:t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{weight:"bold"})})]}),message:"You'll be redirected to your destination shortly."});if(s){const b=s.message.includes("No OAuth callback data found");return t.jsx(Zn,{title:"Something went wrong",sub:"We couldn't complete your sign in",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Pa,{weight:"bold"})})]}),message:s.message||"An unexpected error occurred during authentication.",action:b?void 0:t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:h,children:"Try again"}),footer:b?void 0:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:g,children:"Return to sign in"})]})})}return t.jsx(Zn,{title:"Completing sign in",sub:"Please wait while we authenticate you",icon:t.jsx(vt,{size:32}),message:"Verifying your credentials… this will only take a moment."})}function $4({onSuccess:e,onError:a}={}){const[s,r]=o.useState("loading"),[i,l]=o.useState(""),{token:m,attempt:c,redirectUri:d}=X1(),{verifyMagicLink:p}=Ro(),{navigate:u}=kt(),{deployment:f}=je(),h=o.useRef(!1);o.useEffect(()=>{(async()=>{if(!h.current){if(!m||!c){r("error"),l("The magic link appears to be malformed. Please try signing in again."),a==null||a("Invalid magic link parameters");return}h.current=!0,r("loading"),l("Please wait while we verify your magic link.");try{await p({token:m,attempt:c,redirectUri:d}),r("success"),l("You will be redirected to your account shortly."),e==null||e(),setTimeout(()=>{var b;let w=gt(f,d);if(w||(w=(b=f==null?void 0:f.ui_settings)==null?void 0:b.after_signin_redirect_url),!w&&(f!=null&&f.frontend_host)&&(w=`https://${f.frontend_host}`),w){const j=new URL(w);(f==null?void 0:f.mode)==="staging"&&j.searchParams.set("__dev_session__",xt(f.backend_host)||""),u(j.toString())}},2e3)}catch(w){r("error"),l("The magic link may have expired or already been used. Please try signing in again."),a==null||a(w.message)}}})()},[m,c]);const g=()=>{var x;(x=f==null?void 0:f.ui_settings)!=null&&x.sign_in_page_url&&u(f.ui_settings.sign_in_page_url)};return t.jsx(Re,{children:t.jsxs(et,{children:[t.jsx(nt,{title:"Magic link",sub:"Verifying your magic link"}),t.jsxs("div",{className:"w-auth-status",children:[s==="loading"&&t.jsx(vt,{size:32}),s==="success"&&t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{weight:"bold"})})]}),s==="error"&&t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Pa,{weight:"bold"})})]}),t.jsx("p",{className:"w-auth-sub",children:i}),s==="error"&&t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:g,children:"Try again"})]})]})})}function O4(e){var r,i;return e?((r=e.signin_attempts)==null?void 0:r.find(l=>l.requires_completion&&!l.completed))?!0:!!((i=e.signup_attempts)==null?void 0:i.find(l=>{var m,c;return((m=l.missing_fields)==null?void 0:m.length)>0||((c=l.remaining_steps)==null?void 0:c.length)>0&&!l.completed})):!1}function Z4(e){const a=e?`/profile-completion?redirect_uri=${encodeURIComponent(e)}`:"/profile-completion";window.location.href=a}function rs({kind:e}){const a=e==="success"?"w-success":e==="error"?"w-success w-success--error":"w-success w-success--info",s=e==="success"?Ge:e==="error"?Pa:Tu;return t.jsxs("div",{className:a,children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(s,{weight:"bold"})})]})}function ka({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx(Re,{children:t.jsxs(et,{footer:l,children:[t.jsx(nt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function H4({token:e,onSuccess:a,onError:s}){var b;const{acceptInvitation:r,invitationData:i,loading:l,error:m}=Io(),{navigate:c}=kt(),{deployment:d}=je(),p=o.useRef(!1),u=()=>{var v;const j=new URLSearchParams(window.location.search);return{token:e||j.get("invite_token")||j.get("token"),redirectUri:gt(d,j.get("redirect_uri"))||((v=d==null?void 0:d.ui_settings)==null?void 0:v.after_signin_redirect_url)||"/"}};o.useEffect(()=>{if(p.current)return;const{token:j}=u();j&&(p.current=!0,r(j))},[r]),o.useEffect(()=>{var j;i&&(i.organization&&!i.requires_signin&&a&&a(i.organization.id,(j=i.workspace)==null?void 0:j.id),i.error_code&&s&&s(i.message||"Failed to accept invitation"))},[i,a,s]);const f=()=>{const{redirectUri:j}=u();c(j)},h=()=>{var E,M;const{token:j}=u(),v=((E=d==null?void 0:d.ui_settings)==null?void 0:E.sign_in_page_url)||"/sign-in",k=((M=d==null?void 0:d.ui_settings)==null?void 0:M.sign_up_page_url)||"/sign-up",N=new URLSearchParams;j&&N.set("invite_token",j),i!=null&&i.invited_email&&N.set("invited_email",i.invited_email);const C=`${window.location.pathname}?token=${j}`;N.set("redirect_uri",C),i!=null&&i.message&&N.set("message",i.message);const y=(i==null?void 0:i.error_code)==="INVITATION_REQUIRES_SIGNUP";c(`${y?k:v}?${N.toString()}`)},g=()=>{const{token:j}=u();j&&(p.current=!1,r(j))},x=(j,v)=>t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:v,children:j}),{token:w}=u();if(!w&&!l)return t.jsx(ka,{title:"Invalid invitation",sub:"No invitation token found",icon:t.jsx(rs,{kind:"error"}),message:"The invitation link appears to be invalid or incomplete.",action:x("Go to home",()=>c("/"))});if(l)return t.jsx(ka,{title:"Processing invitation",sub:"Please wait while we verify your invitation",icon:t.jsx(vt,{size:32}),message:"Verifying invitation… this will only take a moment."});if(i!=null&&i.organization&&!i.requires_signin)return t.jsx(ka,{title:"Invitation accepted",sub:"You've successfully joined the organization",icon:t.jsx(rs,{kind:"success"}),message:t.jsxs(t.Fragment,{children:["Welcome to"," ",t.jsx("strong",{children:i.organization.name}),i.workspace?`. You've been added to the ${i.workspace.name} workspace.`:"."]}),action:x("Continue to application",f)});if(i!=null&&i.already_member)return t.jsx(ka,{title:"Already a member",sub:"You're already part of this organization",icon:t.jsx(rs,{kind:"info"}),message:`You're already a member of ${((b=i.organization)==null?void 0:b.name)||"this organization"}. No action needed.`,action:x("Continue to application",f)});if(i!=null&&i.requires_signin){const j=i.error_code==="INVITATION_REQUIRES_SIGNUP";return t.jsx(ka,{title:j?"Sign up required":"Sign in required",sub:"To accept this invitation",icon:t.jsx(rs,{kind:"info"}),message:t.jsxs(t.Fragment,{children:["This invitation is for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email}),"."," ",j?"Create an account with this email address to accept it.":i.error_code==="INVITATION_EMAIL_MISMATCH"?"You're signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."]}),action:x(j?"Sign up to accept":"Sign in to accept",h)})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?t.jsx(ka,{title:"Invitation expired",sub:"This invitation is no longer valid",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx($u,{weight:"bold"})})]}),message:t.jsxs(t.Fragment,{children:["Invitation for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email})," ","has expired. Invitations are valid for 10 days — please request a new one from your organization administrator."]})}):m||i!=null&&i.error_code?t.jsx(ka,{title:"Invitation error",sub:"Unable to process invitation",icon:t.jsx(rs,{kind:"error"}),message:(i==null?void 0:i.message)||m||"Failed to accept invitation",action:x("Try again",g),footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:h,children:"Sign in manually"})]})}):null}const Tc=o.createContext(void 0),Ic=()=>{const e=o.useContext(Tc);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},F4=({isOpen:e,onClose:a,children:s})=>{const[r,i]=o.useState(!1),l=as();return o.useEffect(()=>{i(!0);const m=c=>{c.key==="Escape"&&e&&(a==null||a())};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[e,a]),!e||!r?null:tn.createPortal(t.jsx("div",{className:"wacht-root",style:l,children:t.jsx(Tc.Provider,{value:{isOpen:e,onClose:a},children:s})}),document.body)},T4=({children:e})=>{const{onClose:a}=Ic(),s=o.useRef(null),r=i=>{s.current&&!s.current.contains(i.target)&&(a==null||a())};return t.jsx("div",{className:"w-modal",onClick:r,children:t.jsx("div",{ref:s,style:{maxWidth:"100%",minWidth:0},children:e})})},I4=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog${s?` ${s}`:""}`,style:{maxHeight:"90vh",overflowY:"auto",...a},children:e}),V4=({children:e,showCloseButton:a=!0})=>{const{onClose:s}=Ic();return t.jsxs("div",{className:"w-dialog-head",children:[typeof e=="string"?t.jsx("h2",{className:"w-dialog-title",children:e}):e,a&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:s,children:t.jsx(Pa,{size:18})})]})},z4=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog-body${s?` ${s}`:""}`,style:a,children:e}),D4=({children:e})=>t.jsx("div",{className:"w-dialog-foot",children:e}),ze=Object.assign(F4,{Overlay:T4,Content:I4,Header:V4,Body:z4,Footer:D4}),U4=({isOpen:e,onClose:a,title:s,children:r,showCloseButton:i=!0})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{children:[s&&t.jsx(ze.Header,{showCloseButton:i,children:s}),t.jsx(ze.Body,{children:r})]})})}),W4=({trigger:e,renderDialog:a})=>{const[s,r]=o.useState(!1),i=()=>r(!0),l=()=>r(!1);return t.jsxs(t.Fragment,{children:[e({onClick:i}),a({isOpen:s,onClose:l})]})},Vc=o.createContext(void 0),zc=()=>{const e=o.useContext(Vc);if(!e)throw new Error("useDropdownContext must be used within a DropdownProvider");return e},ks=({children:e,open:a,openChange:s,style:r})=>{const i=o.useRef(null),[l,m]=o.useState(!1);return o.useEffect(()=>{const c=d=>{i.current&&!i.current.contains(d.target)&&m(!1)};return l&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[l,s]),o.useEffect(()=>{s==null||s(l)},[l]),o.useEffect(()=>{m(!!a)},[a]),t.jsx(Vc.Provider,{value:{open:l,openChange:c=>m(c)},children:t.jsx("div",{style:{width:"fit-content",...r},ref:i,children:e})})},Cs=({children:e,style:a,className:s})=>{const{open:r}=zc(),[i,l]=o.useState({top:0,left:0}),[m,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{r&&d.current?(c(!1),requestAnimationFrame(()=>{var f,h;const p=(f=d.current)==null?void 0:f.parentElement;if(!p)return;const u=p.querySelector("[data-dropdown-trigger]")||p.firstElementChild;if(u&&u!==d.current){const g=u.getBoundingClientRect(),x=(h=d.current)==null?void 0:h.getBoundingClientRect(),w=window.innerWidth,b=window.innerHeight;let j=g.bottom+4,v=g.right-((x==null?void 0:x.width)||200);v<8&&(v=g.left),v+((x==null?void 0:x.width)||200)>w-8&&(v=w-((x==null?void 0:x.width)||200)-8),x&&j+x.height>b-8&&(j=g.top-(x.height+4)),l({top:j,left:v}),c(!0)}})):c(!1)},[r]),r?t.jsx("div",{className:s?`w-menu ${s}`:"w-menu",ref:d,style:{position:"fixed",zIndex:1e3,width:"max-content",minWidth:140,maxWidth:240,...a,top:`${i.top}px`,left:`${i.left}px`,visibility:m?"visible":"hidden",opacity:m?1:0,transition:m?"opacity 0.15s ease-in-out":"none"},children:e}):null},Ns=({children:e})=>{const{openChange:a,open:s}=zc(),r=o.useCallback(()=>{a(!s)},[s,a]);return t.jsx("div",{style:{position:"relative",display:"inline-flex"},onClick:r,"data-dropdown-trigger":!0,children:e})},ta=o.forwardRef(({$destructive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:`w-menu-item${e?" w-menu-item--danger":""}${a?` ${a}`:""}`,...s}));ta.displayName="DropdownItem";const Dc=()=>t.jsx("div",{style:{height:"0.5px",background:"var(--wa-border)",width:"100%",margin:"4px 0"}}),Uc=o.forwardRef(({className:e,style:a,...s},r)=>t.jsx("form",{ref:r,className:e,style:{display:"flex",flexDirection:"column",gap:16,...a},...s}));Uc.displayName="Form";const We=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:`w-field${e?` ${e}`:""}`,...a}));We.displayName="FormGroup";const Te=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:`w-label${e?` ${e}`:""}`,...a}));Te.displayName="Label";const be=o.forwardRef(({as:e="input",className:a,...s},r)=>{const i=`w-input${a?` ${a}`:""}`;return e==="textarea"?t.jsx("textarea",{className:i,...s}):t.jsx("input",{ref:r,className:i,...s})});be.displayName="Input";const _e=({size:e,className:a})=>t.jsx("div",{className:a,style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:e?`${e}px`:"100%"},children:t.jsx("span",{className:"w-spin",style:{width:e??40,height:e??40}})}),Ha=({checked:e,onChange:a})=>t.jsxs("label",{className:"w-switch","data-on":e?"":void 0,children:[t.jsx("input",{type:"checkbox",checked:e,onChange:s=>a(s.target.checked),style:{position:"absolute",opacity:0,width:0,height:0}}),t.jsx("span",{className:"w-switch-track",children:t.jsx("span",{className:"w-switch-knob"})})]}),Yt=(e=!1)=>{const[a,s]=o.useState(e),r=o.useCallback(()=>{s(!0)},[]),i=o.useCallback(()=>{s(!1)},[]),l=o.useCallback(()=>{s(m=>!m)},[]);return{isOpen:a,open:r,close:i,toggle:l}},Wc=({onChange:e,placeholder:a,value:s})=>t.jsxs("div",{className:"w-search",children:[t.jsx(Al,{}),t.jsx("input",{type:"text",placeholder:a,value:s,onChange:r=>e(r.target.value)})]}),se=o.forwardRef(({$primary:e,$outline:a,$destructive:s,$fullWidth:r,$size:i,className:l,style:m,...c},d)=>{const f=`w-btn ${s?"w-btn--danger-solid":a?"w-btn--secondary":"w-btn--primary"}${i==="sm"?" w-btn--sm":i==="lg"?" w-btn--lg":""}${l?` ${l}`:""}`;return t.jsx("button",{ref:d,className:f,style:r?{width:"100%",...m}:m,...c})});se.displayName="Button";const Bc=e=>({position:"absolute",top:"calc(100% + 6px)",left:0,width:"100%",maxHeight:260,overflowY:"auto",zIndex:1e3,opacity:e?1:0,transform:e?"scale(1)":"scale(0.97)",transformOrigin:"top",pointerEvents:e?"auto":"none",transition:"opacity 0.15s ease, transform 0.15s ease"}),Gc={width:"100%",height:32,padding:"0 9px",border:"none",borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,fontFamily:"var(--wa-font-sans)",fontSize:13,outline:"none",background:"transparent",color:"var(--wa-text)",marginBottom:4},Js=({children:e})=>t.jsx("div",{style:{padding:"10px 9px",color:"var(--wa-text-faint)",fontFamily:"var(--wa-font-sans)",fontSize:12.5,textAlign:"center"},children:e}),mn=({options:e,value:a,onChange:s,placeholder:r="Select an option",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).find(y=>y.value===a),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(s(y),h(!1),x(""))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k?void 0:"",children:k?k.label:r}),f?t.jsx(tl,{size:16}):t.jsx(Wt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:Bc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Gc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Js,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>_(M.value,M.disabled),role:"option","aria-selected":M.value===a,children:[M.label,M.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Js,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":y.value===a,children:[y.label,y.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a||""})]})},qc=({options:e,value:a,onChange:s,placeholder:r="Select options",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).filter(y=>a.includes(y.value)),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(a.includes(y)?s(a.filter(M=>M!==y)):s([...a,y]))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k.length>0?void 0:"",children:k.length>0?k.map(y=>y.label).join(", "):r}),f?t.jsx(tl,{size:16}):t.jsx(Wt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:Bc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Gc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Js,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>_(M.value,M.disabled),role:"option","aria-selected":a.includes(M.value),children:[M.label,a.includes(M.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Js,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":a.includes(y.value),children:[y.label,a.includes(y.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a.join(",")})]})},Zs=e=>e.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)||"?",Ri=e=>e.trim().replace(/[<>"'&]/g,""),B4=e=>e.length>=2&&e.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(e),G4=e=>/.+@.+\..+/.test(e),Li=(e,a)=>e.length?e.find(s=>s.name===a)||e[0]:null,q4=({roles:e,value:a,onChange:s,fullWidth:r})=>{const[i,l]=o.useState(!1),m=o.useRef(null);return o.useEffect(()=>{if(!i)return;const c=d=>{m.current&&!m.current.contains(d.target)&&l(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]),t.jsxs("div",{ref:m,className:`w-relative${r?" w-full":" w-none"}`,children:[t.jsxs("button",{type:"button",className:`w-combo${r?" w-full":" w-rolepick-btn"}`,"data-open":i?"":void 0,onClick:()=>l(c=>!c),disabled:!e.length,children:[t.jsx("span",{className:"w-combo-val",children:(a==null?void 0:a.name)||"Role"}),t.jsx(Wt,{size:14})]}),i&&t.jsx("div",{className:"w-combo-menu w-combo-menu--pop",children:e.map(c=>t.jsxs("button",{type:"button",className:"w-combo-opt",onClick:()=>{s(c),l(!1)},children:[c.name,c.id===(a==null?void 0:a.id)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:13})})]},c.id))})]})},Kc=({mode:e,organizationId:a,onSuccess:s,onCancel:r,onCreateOrganization:i})=>{var ce;const l=e==="org",m=l?"organization":"workspace",c=l?"Organization":"Workspace",{createOrganization:d,getOrganizationRoles:p,inviteOrganizationMember:u}=Dt(),{createWorkspace:f,getWorkspaceRoles:h,createWorkspaceInvitation:g}=xa(),{organizationMemberships:x}=ga(),{refetch:w}=it(),[b,j]=o.useState(0),[v,k]=o.useState(""),[N,_]=o.useState(""),[C,y]=o.useState(),[E,M]=o.useState(null),[F,A]=o.useState(!1),[T,P]=o.useState(null),[S,$]=o.useState(a),[H,R]=o.useState(!1),O=o.useRef(null),Z=o.useRef(null),[L,U]=o.useState(null),[D,Y]=o.useState([]),[B,Q]=o.useState([]),[ue,we]=o.useState(""),[ne,ae]=o.useState(null),re=(ce=x==null?void 0:x.find(W=>W.organization.id===S))==null?void 0:ce.organization;o.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]),o.useEffect(()=>{if(!H)return;const W=G=>{O.current&&!O.current.contains(G.target)&&R(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[H]);const Me=W=>{var K;const G=(K=W.target.files)==null?void 0:K[0];if(G){if(G.size>2*1024*1024){P("Image must be under 2 MB.");return}if(!G.type.startsWith("image/")){P("Please choose a valid image file.");return}E&&URL.revokeObjectURL(E),P(null),y(G),M(URL.createObjectURL(G))}},q=async()=>{var K;const W=Ri(v),G=Ri(N);if(!B4(W)){P(`Enter a valid ${m} name (2–100 characters).`);return}if(!l&&!S){P("Select an organization first.");return}A(!0),P(null);try{if(l){const V=await d({name:W,description:G,image:C}),de=((K=V==null?void 0:V.data)==null?void 0:K.organization)??(V==null?void 0:V.organization)??V;U(de);const z=await p(de).catch(()=>[]);Y(z),ae(Li(z,"Member"))}else{const V=await f(S,W,C,G),de=(V==null?void 0:V.workspace)??V,z={...de,organization:{id:S}};U(z);const le=await h(de).catch(()=>[]);Y(le),ae(Li(le,"Editor"))}await w(),j(1)}catch(V){P((V==null?void 0:V.message)||`Failed to create ${m}.`)}finally{A(!1)}},tt=()=>{const W=ue.trim();!G4(W)||B.some(G=>G.email===W)||ne&&(Q(G=>[...G,{email:W,roleId:ne.id,roleName:ne.name}]),we(""))},Ie=W=>{(W.key==="Enter"||W.key===",")&&(W.preventDefault(),tt())},De=async()=>{if(!B.length){j(2);return}A(!0),P(null);try{for(const W of B)l?await u(L,{email:W.email,organizationRole:{id:W.roleId}}):await g(L,W.email,W.roleId);j(2)}catch(W){P((W==null?void 0:W.message)||"Some invitations could not be sent.")}finally{A(!1)}},Ee=()=>{j(0),k(""),_(""),y(void 0),E&&URL.revokeObjectURL(E),M(null),U(null),Y([]),Q([]),we(""),P(null)};return t.jsxs("div",{className:"w-card w-create-card",children:[t.jsxs("div",{className:"w-create-body",children:[t.jsxs("div",{className:"w-flex-col w-items-center w-gap-3 w-create-head",children:[b===0?t.jsxs("span",{className:"w-ibadge-wrap",children:[t.jsxs("button",{type:"button",className:"w-ibadge w-avatar-edit","data-busy":F?"":void 0,onClick:()=>{var W;return(W=Z.current)==null?void 0:W.click()},title:`Upload ${m} logo`,"aria-label":`Upload ${m} logo`,children:[E?t.jsx("img",{src:E,alt:`${c} logo`}):l?t.jsx(hs,{}):t.jsx(pi,{}),t.jsx("span",{className:"w-avatar-veil",children:t.jsx(nn,{})})]}),t.jsx("input",{ref:Z,type:"file",className:"w-none",hidden:!0,accept:"image/png, image/jpeg, image/gif, image/svg+xml",onChange:Me,disabled:F}),E&&t.jsx("button",{type:"button",className:"w-ibadge-x",title:"Remove logo","aria-label":"Remove logo",onClick:()=>{E&&URL.revokeObjectURL(E),M(null),y(void 0)},children:t.jsx(Pa,{})})]}):t.jsx("span",{className:`w-ibadge${b===2?" w-ibadge--done":""}`,children:b===2?t.jsx(Ge,{}):l?t.jsx(hs,{}):t.jsx(pi,{})}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-text-center",children:[t.jsx("h1",{className:"w-title-lg",children:b===0?`Create ${l?"an":"a"} ${m}`:b===1?"Invite your team":`${c} created`}),t.jsx("p",{className:"w-sub",children:b===0?`Set up a new ${m}${l?" to collaborate with your team.":" inside your organization."}`:b===1?"Add people now, or skip and do it later.":`${v} is ready to go.`})]})]}),b<2&&t.jsxs("div",{className:"w-steps w-create-steps",children:[t.jsx("i",{"data-on":""}),t.jsx("i",{"data-on":b>=1?"":void 0})]}),T&&t.jsx("div",{className:"w-banner w-banner--error w-mb-4",children:T}),b===0&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[!l&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Organization"}),t.jsxs("div",{className:"w-relative",ref:O,children:[t.jsxs("button",{type:"button",className:"w-combo w-full","data-open":H?"":void 0,onClick:()=>R(W=>!W),disabled:F,children:[t.jsxs("span",{className:"w-combo-val w-inline w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:re!=null&&re.image_url?t.jsx("img",{src:re.image_url,alt:re.name}):Zs((re==null?void 0:re.name)||"O").charAt(0)}),t.jsx("span",{children:(re==null?void 0:re.name)||"Select organization"})]}),t.jsx(Wt,{size:14})]}),H&&t.jsxs("div",{className:"w-combo-menu w-combo-menu--pop",children:[x==null?void 0:x.map(W=>{var K;const G=!!((K=W.eligibility_restriction)!=null&&K.type)&&W.eligibility_restriction.type!=="none";return t.jsxs("button",{type:"button",className:"w-combo-opt",disabled:G,"data-disabled":G?"":void 0,onClick:()=>{G||($(W.organization.id),R(!1))},children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:W.organization.image_url?t.jsx("img",{src:W.organization.image_url,alt:W.organization.name}):Zs(W.organization.name).charAt(0)}),t.jsx("span",{children:W.organization.name})]},W.organization.id)}),i&&t.jsxs("button",{type:"button",className:"w-combo-opt w-text-primary",onClick:()=>{R(!1),i()},children:[t.jsx(St,{size:13}),"Create new organization"]})]})]})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:[c," name"]}),t.jsx(be,{autoFocus:!0,value:v,onChange:W=>k(W.target.value),placeholder:l?"Acme Inc":"Product",disabled:F})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Description"," ",t.jsx("span",{className:"w-secsub",children:"· optional"})]}),t.jsx(be,{as:"textarea",className:"w-input--area",value:N,onChange:W=>_(W.target.value),placeholder:l?"What does your team do?":"What's this workspace for?",disabled:F})]}),t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:q,disabled:F||!v.trim(),children:F?t.jsx(_e,{size:15}):t.jsxs(t.Fragment,{children:["Continue",t.jsx(Jt,{size:15})]})}),r&&t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-btn--block",onClick:r,disabled:F,children:"Cancel"})]})]}),b===1&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Invite by email"}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(be,{autoFocus:!0,className:"w-grow",value:ue,onChange:W=>we(W.target.value),onKeyDown:Ie,placeholder:"teammate@acme.com"}),t.jsx(q4,{roles:D,value:ne,onChange:ae})]}),t.jsx("span",{className:"w-secsub",children:"Press Enter to add each person."})]}),B.length>0&&t.jsx("div",{className:"w-list",children:B.map(W=>t.jsxs("div",{className:"w-row",style:{gridTemplateColumns:"1fr auto",padding:"10px 0"},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:Zs(W.email)}),t.jsx("span",{className:"w-truncate w-text-secondary",children:W.email})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-pill",children:W.roleName}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",title:"Remove",onClick:()=>Q(G=>G.filter(K=>K.email!==W.email)),children:t.jsx(Pa,{size:13})})]})]},W.email))}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-none",onClick:()=>j(2),disabled:F,children:"Skip"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-grow",onClick:De,disabled:F,children:F?t.jsx(_e,{size:15}):B.length?`Invite ${B.length} & finish`:"Finish"})]})]}),b===2&&t.jsxs("div",{className:"w-flex-col w-items-center w-gap-4",children:[t.jsxs("div",{className:"w-create-summary",children:[t.jsx("span",{className:"w-avatar w-avatar--md",children:E?t.jsx("img",{src:E,alt:v}):Zs(v)}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:v}),t.jsx("span",{className:"w-secsub",children:B.length?`${B.length} invite${B.length>1?"s":""} sent`:"No invites yet"})]})]}),t.jsxs("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>s==null?void 0:s(L),children:["Go to ",m,t.jsx(Jt,{size:15})]}),t.jsxs("button",{type:"button",className:"w-link w-link--muted w-linkbtn w-inline w-gap-1",onClick:Ee,children:[t.jsx(Uo,{size:12})," Create another"]})]})]}),b===0&&t.jsx("div",{className:"w-create-foot",children:t.jsx("span",{className:"w-secsub",children:l?"Organizations group your team, billing and settings.":"Workspaces live inside an organization."})})]})},pn=({onSuccess:e,onCancel:a})=>t.jsx(Re,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Kc,{mode:"org",onSuccess:e,onCancel:a})})}),Yc=({isOpen:e,onClose:a,onCreated:s})=>{const r=()=>{s==null||s(),a==null||a()};return t.jsx(Re,{children:t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsx(ze.Content,{className:"w-dialog--create",children:t.jsx(pn,{onSuccess:r,onCancel:a})})})})})},Mr=o.createContext({screen:null,setScreen:()=>{},toast:(e,a)=>{}}),Ct=()=>{const e=o.useContext(Mr);if(!e)throw new Error("useScreenContext must be used within a ScreenContextProvider");return e},Ja=({title:e,description:a,onConfirm:s,onCancel:r,style:i})=>{const l=o.useRef(null);return o.useEffect(()=>{const m=c=>{l.current&&!l.current.contains(c.target)&&r()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[r]),t.jsxs("div",{ref:l,className:"w-pop",style:{position:"fixed",zIndex:1e3,right:44,...i},children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("h3",{className:"w-pop-title",children:e}),a&&t.jsx("p",{className:"w-pop-sub",children:a})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:r,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:s,children:"Confirm"})]})]})},Pi=[{id:"okta",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"saml",description:"SAML",docUrl:"https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_saml.htm",placeholders:{entityId:"http://www.okta.com/{yourOktaDomain}",ssoUrl:"https://{yourOktaDomain}.okta.com/app/{appId}/sso/saml"},attributeMapping:{first_name:"firstName",last_name:"lastName",email:"email"}},{id:"okta-oidc",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"oidc",description:"OIDC",docUrl:"https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/",placeholders:{issuerUrl:"https://{yourOktaDomain}.okta.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"azure",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso",placeholders:{entityId:"https://sts.windows.net/{tenantId}/",ssoUrl:"https://login.microsoftonline.com/{tenantId}/saml2"},attributeMapping:{first_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",last_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",email:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"}},{id:"azure-oidc",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"oidc",description:"OIDC",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc",placeholders:{issuerUrl:"https://login.microsoftonline.com/{tenantId}/v2.0",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"google",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"saml",description:"SAML",docUrl:"https://support.google.com/a/answer/6087519",placeholders:{entityId:"https://accounts.google.com/o/saml2?idpid={idpId}",ssoUrl:"https://accounts.google.com/o/saml2/idp?idpid={idpId}"},attributeMapping:{first_name:"FirstName",last_name:"LastName",email:"email"}},{id:"google-oidc",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"oidc",description:"OIDC",docUrl:"https://developers.google.com/identity/openid-connect/openid-connect",placeholders:{issuerUrl:"https://accounts.google.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"auth0",name:"Auth0",logo:"https://cdn.auth0.com/styleguide/latest/lib/logos/img/badge.png",protocol:"oidc",description:"OIDC",docUrl:"https://auth0.com/docs/authenticate/protocols/openid-connect-protocol",placeholders:{issuerUrl:"https://{yourDomain}.auth0.com/",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"onelogin",name:"OneLogin",logo:"",protocol:"saml",description:"SAML",docUrl:"https://onelogin.service-now.com/support?id=kb_article&sys_id=912bb23adbdc1cd0ca1c400e0b96197d",placeholders:{entityId:"https://app.onelogin.com/saml/metadata/{appId}",ssoUrl:"https://{subdomain}.onelogin.com/trust/saml2/http-post/sso/{appId}"}},{id:"ping",name:"PingOne",logo:"",protocol:"saml",description:"SAML",docUrl:"https://docs.pingidentity.com/pingone/latest/connector/configure-saml.html",placeholders:{entityId:"https://auth.pingone.com/{envId}",ssoUrl:"https://auth.pingone.com/{envId}/saml20/idp/sso"}},{id:"jumpcloud",name:"JumpCloud",logo:"",protocol:"saml",description:"SAML",docUrl:"https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-saml",placeholders:{entityId:"https://sso.jumpcloud.com/saml2/{appId}",ssoUrl:"https://sso.jumpcloud.com/saml2/{appId}"}},{id:"duo",name:"Duo",logo:"",protocol:"saml",description:"SAML",docUrl:"https://duo.com/docs/sso",placeholders:{entityId:"https://sso.duosecurity.com/saml2/sp/{appId}",ssoUrl:"https://sso.duosecurity.com/saml2/idp/{appId}/sso"}},{id:"keycloak",name:"Keycloak",logo:"https://www.keycloak.org/resources/images/icon.svg",protocol:"oidc",description:"OIDC",docUrl:"https://www.keycloak.org/docs/latest/securing_apps/",placeholders:{issuerUrl:"https://{host}/realms/{realm}",scopes:"openid profile email"}},{id:"adfs",name:"ADFS",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Microsoft_logo.svg/100px-Microsoft_logo.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-relying-party-trust",placeholders:{entityId:"http://{adfsServer}/adfs/services/trust",ssoUrl:"https://{adfsServer}/adfs/ls/"}},{id:"custom-saml",name:"Custom",logo:"",protocol:"saml",description:"SAML",docUrl:"",placeholders:{}},{id:"custom-oidc",name:"Custom",logo:"",protocol:"oidc",description:"OIDC",docUrl:"",placeholders:{}}],K4=({template:e})=>{const[a,s]=o.useState(!1);return!e.logo||a?t.jsx("span",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo--ph",children:t.jsx(ea,{size:18,className:"w-text-muted"})}):t.jsx("img",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo",src:e.logo,alt:e.name,onError:()=>s(!0)})},Y4=({organization:e})=>{const{getEnterpriseConnections:a,createEnterpriseConnection:s,deleteEnterpriseConnection:r,testEnterpriseConnection:i,generateSCIMToken:l,getSCIMToken:m,revokeSCIMToken:c}=Dt(),{toast:d}=Ct(),[p,u]=o.useState(!1),[f,h]=o.useState(null),{data:g=[],isLoading:x,mutate:w}=Ce(e!=null&&e.id?`wacht-org-sso:${e.id}`:null,async()=>await(a==null?void 0:a(e))||[],{refreshInterval:3e4,revalidateOnFocus:!1}),b=async j=>{try{await(r==null?void 0:r(e,j)),w(),d("SSO connection deleted","info")}catch(v){d(v.message||"Failed to delete connection","error")}h(null)};return x?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):p?t.jsx(J4,{organization:e,onClose:()=>u(!1),onCreate:async j=>{try{await(s==null?void 0:s(e,j)),w(),u(!1),d("SSO connection created","info")}catch(v){d(v.message||"Failed to create connection","error")}}}):t.jsx(t.Fragment,{children:g.length===0?t.jsxs("div",{className:"w-empty w-empty--fill",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(ea,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"Enterprise SSO"}),t.jsx("p",{children:"Let members sign in with your identity provider."})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{onClick:()=>u(!0),children:[t.jsx(St,{size:16})," Configure SSO"]})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-sechead",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-title",children:"Enterprise SSO"}),t.jsx("p",{className:"w-sub",children:"Configure SAML or OIDC SSO for your organization"})]})}),g.map(j=>t.jsx(Q4,{connection:j,onDelete:v=>h(v),connectionToDelete:f,onConfirmDelete:b,onCancelDelete:()=>h(null),testConnection:v=>i(e,v),generateSCIMToken:v=>l(e,v),getSCIMToken:v=>m(e,v),revokeSCIMToken:v=>c(e,v),toast:d},j.id))]})})},Q4=({connection:e,onDelete:a,connectionToDelete:s,onConfirmDelete:r,onCancelDelete:i,testConnection:l,generateSCIMToken:m,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var F,A,T,P,S;const[u,f]=o.useState(null),[h,g]=o.useState(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),[v,k]=o.useState(!1),[N,_]=o.useState(null);o.useEffect(()=>{c&&e.id&&c(e.id).then(f).catch(()=>{})},[e.id,c]);const C=async()=>{if(l){k(!0),_(null);try{const $=await l(e.id);_($)}catch($){_({success:!1,checks:{},errors:{general:$.message||"Test failed"}})}finally{k(!1)}}},y=async()=>{if(m){g(!0);try{const $=await m(e.id);w($.token),f({exists:!0,token:$}),p("SCIM token generated. Copy it now - it won't be shown again!","info")}catch($){p($.message||"Failed to generate token","error")}finally{g(!1)}}},E=async()=>{if(d){g(!0);try{await d(e.id),f({exists:!1,scim_base_url:u==null?void 0:u.scim_base_url}),w(null),p("SCIM token revoked","info")}catch($){p($.message||"Failed to revoke token","error")}finally{g(!1)}}},M=($,H)=>{navigator.clipboard.writeText($),j(H),setTimeout(()=>j(null),2e3)};return t.jsxs("div",{className:"w-flex-col w-gap-4 w-sso-conn",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-start",children:[t.jsxs("h3",{className:"w-sec w-inline w-gap-2",children:[t.jsx(ea,{size:16}),e.protocol==="oidc"?"OIDC SSO":"SAML SSO",t.jsx("span",{className:"w-pill w-pill--current",children:e.protocol.toUpperCase()})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(se,{$size:"sm",onClick:C,disabled:v,children:v?t.jsx(_e,{size:14}):"Test"}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>a(e.id),className:"w-text-error",children:"Remove"}),s===e.id&&t.jsx(Ja,{title:"Delete this SSO connection?",onConfirm:()=>r(e.id),onCancel:i})]})]})]}),N&&t.jsx("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"}`,children:t.jsxs("span",{className:`w-banner-txt w-flex-col w-gap-1 ${N.success?"w-text-success":"w-text-error"}`,children:[t.jsx("span",{children:N.success?"✓ Connection is valid":"✗ Connection failed"}),N.errors&&Object.entries(N.errors).map(([$,H])=>t.jsxs("div",{children:[$.replace(/_/g," "),": ",H]},$))]})}),t.jsxs("div",{className:"w-sso-detail",children:[e.protocol==="saml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Entity ID"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_entity_id}),t.jsx("span",{className:"w-secsub",children:"SSO URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_sso_url})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Issuer URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.oidc_issuer_url}),t.jsx("span",{className:"w-secsub",children:"Client ID"}),t.jsx("span",{className:"w-sec",children:e.oidc_client_id}),t.jsx("span",{className:"w-secsub",children:"Scopes"}),t.jsx("span",{className:"w-sec",children:e.oidc_scopes||"openid profile email"})]}),t.jsx("span",{className:"w-secsub",children:"Created"}),t.jsx("span",{className:"w-sec",children:new Date(e.created_at).toLocaleDateString()})]}),t.jsxs("div",{className:"w-flex-col w-gap-3 w-sso-scim",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center",children:[t.jsxs("div",{className:"w-sec w-inline w-gap-2",children:[t.jsx(ea,{size:14}),"SCIM Provisioning"]}),t.jsx("div",{className:"w-flex w-wrap w-gap-2",children:!(u!=null&&u.exists)||!((F=u==null?void 0:u.token)!=null&&F.enabled)?t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Rotate"}),t.jsx(se,{$size:"sm",$outline:!0,onClick:E,disabled:h,className:"w-text-error",children:"Revoke"})]})})]}),(((A=u==null?void 0:u.token)==null?void 0:A.scim_base_url)||x)&&t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Base URL:"}),t.jsx("code",{children:((T=u==null?void 0:u.token)==null?void 0:T.scim_base_url)||"Loading..."}),((P=u==null?void 0:u.token)==null?void 0:P.scim_base_url)&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>M(u.token.scim_base_url,"scim-url"),children:b==="scim-url"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]}),x&&t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Token:"}),t.jsx("code",{children:x}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>M(x,"scim-token"),children:b==="scim-token"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]}),t.jsx("div",{className:"w-mono-faint w-text-warning",children:"⚠️ Copy this token now. It won't be shown again."})]}),(u==null?void 0:u.exists)&&((S=u==null?void 0:u.token)==null?void 0:S.enabled)&&!x&&t.jsxs("div",{className:"w-secsub",children:["Token:"," ",t.jsxs("code",{className:"w-mono-sm w-token-chip",children:[u.token.token_prefix,"..."]}),u.token.last_used_at&&t.jsxs("span",{children:[" ","· Last used:"," ",new Date(u.token.last_used_at).toLocaleDateString()]})]})]})]})},J4=({onCreate:e,organization:a})=>{const{getOrganizationDomains:s,testEnterpriseConnectionConfig:r}=Dt(),{deployment:i}=je(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(null),[u,f]=o.useState("saml"),[h,g]=o.useState(null),[x,w]=o.useState(!1),[b,j]=o.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:""}),[v,k]=o.useState(!1),[N,_]=o.useState(null),{data:C=[],isLoading:y}=Ce("wacht-org-verified-domains-for-sso-screen",async()=>(await(s==null?void 0:s(a))||[]).filter(R=>R.verified),{revalidateOnFocus:!1}),E=H=>{p(H),f(H.protocol),H.protocol==="saml"?j(R=>{var O,Z,L;return{...R,idp_entity_id:H.placeholders.entityId||"",idp_sso_url:H.placeholders.ssoUrl||"",attr_first_name:((O=H.attributeMapping)==null?void 0:O.first_name)||"",attr_last_name:((Z=H.attributeMapping)==null?void 0:Z.last_name)||"",attr_email:((L=H.attributeMapping)==null?void 0:L.email)||""}}):j(R=>{var O,Z,L;return{...R,oidc_issuer_url:H.placeholders.issuerUrl||"",oidc_scopes:H.placeholders.scopes||"openid profile email",attr_first_name:((O=H.attributeMapping)==null?void 0:O.first_name)||"",attr_last_name:((Z=H.attributeMapping)==null?void 0:Z.last_name)||"",attr_email:((L=H.attributeMapping)==null?void 0:L.email)||""}})},M=i!=null&&i.backend_host?`${i.backend_host.startsWith("https://")?"":"https://"}${i.backend_host}/auth/sso/oidc/callback`:"",F=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/metadata`:"",A=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/callback`:"",T=(H,R)=>{navigator.clipboard.writeText(H),g(R),setTimeout(()=>g(null),2e3)},P=async H=>{H.preventDefault();const R=O=>O.includes("{")||O.includes("}");if(u==="saml"){if(!b.idp_entity_id||R(b.idp_entity_id)){l("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||R(b.idp_sso_url)){l("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){l("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||R(b.oidc_issuer_url)){l("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||R(b.oidc_client_id)){l("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){l("Please enter the Client Secret","error");return}}c(!0);try{const O={};b.attr_first_name&&(O.first_name=b.attr_first_name),b.attr_last_name&&(O.last_name=b.attr_last_name),b.attr_email&&(O.email=b.attr_email);const Z=Object.keys(O).length>0;u==="saml"?await e({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,...Z&&{attribute_mapping:O}}):await e({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,...Z&&{attribute_mapping:O}})}finally{c(!1)}},S=async()=>{k(!0),_(null);const H=Z=>Z.includes("{")||Z.includes("}"),R={},O={};if(u==="saml"?(b.idp_entity_id?H(b.idp_entity_id)?(O.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):O.entity_id_valid=!0:(O.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?H(b.idp_sso_url)?(O.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):O.sso_url_valid=!0:(O.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?O.certificate_provided=!0:(O.certificate_provided=!1,R.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?H(b.oidc_issuer_url)?(O.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):O.issuer_url_valid=!0:(O.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?H(b.oidc_client_id)?(O.client_id_valid=!1,R.client_id_valid="Client ID contains placeholder values - please replace with actual values"):O.client_id_valid=!0:(O.client_id_valid=!1,R.client_id_valid="Client ID is required")),Object.keys(R).length>0){_({success:!1,checks:O,errors:R}),k(!1);return}try{const Z=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(r==null?void 0:r(a,Z));L&&_(L)}catch(Z){_({success:!1,checks:{},errors:{general:"Test failed: "+Z.message}})}finally{k(!1)}},$=H=>t.jsx(K4,{template:H});return t.jsxs("form",{onSubmit:P,autoComplete:"off",className:"w-flex-col w-gap-4",children:[d?t.jsxs("div",{className:"w-flex w-items-center w-gap-4 w-sso-template",children:[$(d),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:d.name}),t.jsx("div",{className:"w-eyebrow",children:d.protocol})]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:()=>p(null),children:"Change"})]}):t.jsxs("div",{className:"w-flex-col w-gap-5",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"SAML Providers"}),t.jsx("div",{className:"w-grid-4",children:Pi.filter(H=>H.protocol==="saml").map(H=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(H),children:[$(H),t.jsx("span",{className:"w-secsub",children:H.name})]},H.id))})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"OIDC Providers"}),t.jsx("div",{className:"w-grid-4",children:Pi.filter(H=>H.protocol==="oidc").map(H=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(H),children:[$(H),t.jsx("span",{className:"w-secsub",children:H.name})]},H.id))})]})]}),d&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-sec",children:"Service Provider Details"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"ACS URL:"}),t.jsx("code",{children:A}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(A,"acs"),children:h==="acs"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]}),t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Metadata:"}),t.jsx("code",{children:F}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(F,"metadata"),children:h==="metadata"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]})]}):t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Callback:"}),t.jsx("code",{children:M}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(M,"callback"),children:h==="callback"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]})})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:d?`${d.name} Configuration`:"Configuration"}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[d&&d.docUrl&&t.jsxs("a",{href:d.docUrl,target:"_blank",rel:"noopener noreferrer",className:"w-link w-link--sm w-text-primary w-inline w-gap-1",children:[t.jsx(Eu,{size:12})," Docs"]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:S,disabled:v||!d,children:v?t.jsx(_e,{size:16}):"Test Connection"}),t.jsx(se,{$size:"sm",type:"submit",disabled:m||C.length===0||!d,children:m?t.jsx(_e,{size:16}):"Create Connection"})]})]}),N&&(()=>{const H={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 t.jsxs("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"} w-flex-col w-gap-3`,children:[t.jsx("div",{className:`w-sec ${N.success?"w-text-success":"w-text-error"}`,children:N.success?"✓ All checks passed":"✗ Some checks failed"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:Object.entries(N.checks).map(([R,O])=>{var Z;return t.jsxs("div",{className:"w-flex w-items-start w-gap-2 w-sso-check",children:[t.jsx("span",{className:`w-sso-check-mark ${O?"w-text-success":"w-text-error"}`,children:O?"✓":"✗"}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:H[R]||R.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((Z=N.errors)==null?void 0:Z[R])&&t.jsx("div",{className:"w-secsub w-text-error",children:N.errors[R]})]})]},R)})})]})})(),t.jsxs("div",{className:"w-grid-2",children:[!d&&t.jsxs(We,{children:[t.jsx(Te,{children:"Protocol *"}),t.jsxs("select",{className:"w-input",value:u,onChange:H=>f(H.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(We,{className:"w-col-full",children:[t.jsx(Te,{children:"Domain *"}),y?t.jsx("div",{className:"w-secsub",children:"Loading domains..."}):C.length===0?t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"No verified domains found. Please add and verify a domain first."})}):t.jsxs("select",{className:"w-input",value:b.domain_id,onChange:H=>j({...b,domain_id:H.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),C.map(H=>t.jsx("option",{value:H.id,children:H.fqdn},H.id))]})]}),u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(We,{children:[t.jsx(Te,{children:"IdP Entity ID *"}),t.jsx(be,{type:"text",value:b.idp_entity_id,onChange:H=>j({...b,idp_entity_id:H.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"IdP SSO URL *"}),t.jsx(be,{type:"url",value:b.idp_sso_url,onChange:H=>j({...b,idp_sso_url:H.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(We,{className:"w-col-full",children:[t.jsx(Te,{children:"X.509 Certificate *"}),t.jsx(be,{as:"textarea",value:b.idp_certificate,onChange:H=>j({...b,idp_certificate:H.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0,className:"w-input--area w-input--mono"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(We,{children:[t.jsx(Te,{children:"Issuer URL *"}),t.jsx(be,{type:"url",value:b.oidc_issuer_url,onChange:H=>j({...b,oidc_issuer_url:H.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Client ID *"}),t.jsx(be,{type:"text",value:b.oidc_client_id,onChange:H=>j({...b,oidc_client_id:H.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Client Secret *"}),t.jsx(be,{type:"password",value:b.oidc_client_secret,onChange:H=>j({...b,oidc_client_secret:H.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Scopes"}),t.jsx(be,{type:"text",value:b.oidc_scopes,onChange:H=>j({...b,oidc_scopes:H.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(We,{className:"w-col-full",children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:"Enable JIT Provisioning"}),t.jsx("div",{className:"w-secsub",children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),t.jsx(Ha,{checked:b.jit_enabled,onChange:()=>j({...b,jit_enabled:!b.jit_enabled})})]})}),t.jsxs("div",{className:"w-col-full w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-inline w-gap-2 w-text-primary w-disclosure",onClick:()=>w(!x),children:[t.jsx("span",{className:"w-disclosure-caret",children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-secsub",children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),t.jsxs("div",{className:"w-grid-3",children:[t.jsxs(We,{children:[t.jsx(Te,{children:"First Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_first_name,onChange:H=>j({...b,attr_first_name:H.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Last Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_last_name,onChange:H=>j({...b,attr_last_name:H.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Email Attribute"}),t.jsx(be,{type:"text",value:b.attr_email,onChange:H=>j({...b,attr_email:H.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ht=(...e)=>e.filter(Boolean).join(" "),$i=({className:e,...a})=>t.jsx("div",{className:ht("w-contents",e),...a}),Hn=({className:e,...a})=>t.jsx("div",{className:ht("w-card","w-flex-col","w-full","w-minh-full",e),...a}),X4=({className:e,...a})=>t.jsx("div",{className:ht("w-tabsbar",e),...a}),em=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),Da=({className:e,$isActive:a,...s})=>t.jsx("button",{className:ht("w-tab",a&&"w-tab--active",e),...s}),Ua=({className:e,...a})=>t.jsx("span",{className:ht("w-inline","w-gap-2",e),...a}),tm=({className:e,children:a,...s})=>t.jsx("div",{className:ht("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Rr=({className:e,...a})=>t.jsx("div",{className:ht("w-sechead",e),...a}),Oi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Zi=({className:e,...a})=>t.jsx("div",{className:ht("w-grow",e),...a}),Hi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-3","w-none",e),...a}),hn=({className:e,...a})=>t.jsx("div",{className:ht("w-full",e),...a}),am=({className:e,...a})=>t.jsx("div",{className:ht("w-page-head",e),...a}),sm=({className:e,...a})=>t.jsx("div",{className:ht("w-grow","w-flex-col","w-gap-1",e),...a}),nm=({className:e,...a})=>t.jsx("div",{className:ht("w-sec","w-truncate",e),...a}),rm=({className:e,...a})=>t.jsx("div",{className:ht("w-secsub","w-truncate",e),...a}),im={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},ha=({className:e,$variant:a="neutral",children:s,...r})=>t.jsxs("span",{className:ht("w-pill",im[a],e),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),Fi=({className:e,$first:a,...s})=>t.jsx("div",{className:ht("w-sec",e),...s}),om=({organization:e})=>{var A,T,P,S,$,H;const{switchOrganization:a,refetch:s}=it(),{workspaces:r}=xa(),{deployment:i}=je(),{deleteOrganization:l,updateOrganization:m}=Dt(),{toast:c}=Ct(),[d,p]=o.useState((e==null?void 0:e.name)||""),[u,f]=o.useState((e==null?void 0:e.description)||""),[h,g]=o.useState(!1),[x,w]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,j]=o.useState(""),[v,k]=o.useState(!1),[N,_]=o.useState(!1),C=o.useRef({name:d,description:u,security:x,isSaving:h});o.useEffect(()=>{C.current={name:d,description:u,security:x,isSaving:h}},[d,u,x,h]);const y=o.useCallback(async()=>{if(!e)return;const R=C.current;try{g(!0),await m(e,{name:R.name,description:R.description,whitelisted_ips:R.security.allowed_ips.split(`
99
+ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page for more info.`),window[Os]+=1);const lm='.wacht-root{--wa-surface: var(--wa-ov-light-surface, #ffffff);--wa-surface-subtle: var(--wa-ov-light-surface_subtle, #fafaf8);--wa-background: var(--wa-ov-light-background, #f5f5f2);--wa-canvas: var(--wa-ov-light-canvas, #ebebe7);--wa-text: var(--wa-ov-light-text, #161618);--wa-text-secondary: var(--wa-ov-light-text_secondary, #3b3b3f);--wa-text-muted: var(--wa-ov-light-text_muted, #76767c);--wa-text-faint: var(--wa-ov-light-text_faint, #a8a8ad);--wa-border: var(--wa-ov-light-border, rgba(20, 20, 22, .08));--wa-border-strong: var(--wa-ov-light-border_strong, rgba(20, 20, 22, .14));--wa-primary: var(--wa-ov-light-primary, #6b3df5);--wa-primary-soft: var(--wa-ov-light-primary_soft, rgba(107, 61, 245, .1));--wa-primary-foreground: var(--wa-ov-light-primary_foreground, #ffffff);--wa-success: var(--wa-ov-light-success, #0f8a4a);--wa-success-soft: var(--wa-ov-light-success_soft, rgba(15, 138, 74, .12));--wa-info: var(--wa-ov-light-info, #2f6fdb);--wa-info-soft: var(--wa-ov-light-info_soft, rgba(47, 111, 219, .1));--wa-warning: var(--wa-ov-light-warning, #a8650a);--wa-warning-soft: var(--wa-ov-light-warning_soft, rgba(168, 101, 10, .12));--wa-error: var(--wa-ov-light-error, #c4271f);--wa-error-soft: var(--wa-ov-light-error_soft, rgba(196, 39, 31, .1));--wa-radius: var(--wa-ov-light-radius, 6px);--wa-radius-lg: var(--wa-ov-light-radius_lg, 10px);--wa-font-sans: var(--wa-ov-light-font_sans, "Geist", "Inter"), system-ui, -apple-system, sans-serif;--wa-font-mono: var(--wa-ov-light-font_mono, "Geist Mono"), ui-monospace, SFMono-Regular, Menlo, monospace;font-family:var(--wa-font-sans)}.dark .wacht-root,.wacht-root.dark{--wa-surface: var(--wa-ov-dark-surface, #131318);--wa-surface-subtle: var(--wa-ov-dark-surface_subtle, #101015);--wa-background: var(--wa-ov-dark-background, #0d0d10);--wa-canvas: var(--wa-ov-dark-canvas, #050507);--wa-text: var(--wa-ov-dark-text, #ececef);--wa-text-secondary: var(--wa-ov-dark-text_secondary, #c5c5cb);--wa-text-muted: var(--wa-ov-dark-text_muted, #8a8a92);--wa-text-faint: var(--wa-ov-dark-text_faint, #57575e);--wa-border: var(--wa-ov-dark-border, rgba(255, 255, 255, .07));--wa-border-strong: var(--wa-ov-dark-border_strong, rgba(255, 255, 255, .14));--wa-primary: var(--wa-ov-dark-primary, #9277ff);--wa-primary-soft: var(--wa-ov-dark-primary_soft, rgba(146, 119, 255, .16));--wa-primary-foreground: var(--wa-ov-dark-primary_foreground, #ffffff);--wa-success: var(--wa-ov-dark-success, #0f8a4a);--wa-success-soft: var(--wa-ov-dark-success_soft, rgba(15, 138, 74, .18));--wa-info: var(--wa-ov-dark-info, #2f6fdb);--wa-info-soft: var(--wa-ov-dark-info_soft, rgba(47, 111, 219, .18));--wa-warning: var(--wa-ov-dark-warning, #a8650a);--wa-warning-soft: var(--wa-ov-dark-warning_soft, rgba(168, 101, 10, .18));--wa-error: var(--wa-ov-dark-error, #c4271f);--wa-error-soft: var(--wa-ov-dark-error_soft, rgba(196, 39, 31, .18));--wa-radius: var(--wa-ov-dark-radius, 6px);--wa-radius-lg: var(--wa-ov-dark-radius_lg, 10px);--wa-font-sans: var(--wa-ov-dark-font_sans, "Geist", "Inter"), system-ui, -apple-system, sans-serif;--wa-font-mono: var(--wa-ov-dark-font_mono, "Geist Mono"), ui-monospace, SFMono-Regular, Menlo, monospace}.wacht-root *{box-sizing:border-box}',cm='.w-flex-col{display:flex;flex-direction:column}.w-inline{display:inline-flex;align-items:center}.w-wrap{flex-wrap:wrap}.w-grow{flex:1 1 auto;min-width:0}.w-none{flex:none}.w-full{width:100%}.w-gap-1{gap:4px}.w-gap-2{gap:8px}.w-gap-3{gap:12px}.w-gap-4{gap:16px}.w-gap-5{gap:20px}.w-gap-6{gap:24px}.w-truncate{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-contents{display:contents}.w-h-full{height:100%}.w-minh-full{min-height:100%}.w-mono-sm{font:400 12px/1.4 var(--wa-font-mono);color:var(--wa-text-muted)}.w-text-primary{color:var(--wa-primary)}.w-text-secondary{color:var(--wa-text-secondary)}.w-text-muted{color:var(--wa-text-muted)}.w-text-faint{color:var(--wa-text-faint)}.w-text-error{color:var(--wa-error)}.w-text-success{color:var(--wa-success)}.w-text-warning{color:var(--wa-warning)}.w-mb-4{margin-bottom:16px}.w-mt-6{margin-top:24px}.w-maxw-sm{max-width:340px}.w-rolepick-btn{min-width:120px}.w-combo-menu--pop{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:60}.w-relative{position:relative}.w-card{background:var(--wa-surface);border:0;border-radius:var(--wa-radius-lg);box-shadow:0 0 0 .5px var(--wa-border),0 1px 1px #1414160a,0 4px 8px -4px #14141614,0 24px 48px -16px #14141629;overflow:hidden}.w-eyebrow{font:400 10px/1 var(--wa-font-mono);letter-spacing:.12em;text-transform:uppercase;color:var(--wa-text-faint)}.w-title{font:400 17px/1.25 var(--wa-font-sans);letter-spacing:-.02em;color:var(--wa-text);margin:0}.w-title-lg{font:400 19px/1.2 var(--wa-font-sans);letter-spacing:-.022em;color:var(--wa-text);margin:0}.w-sub{font:400 13px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);margin:0}.w-sec{font:400 13px/1.3 var(--wa-font-sans);color:var(--wa-text);margin:0}.w-secsub{font:400 12px/1.45 var(--wa-font-sans);color:var(--wa-text-muted);margin:0}.w-btn{height:32px;padding:0 13px;border-radius:var(--wa-radius);border:.5px solid transparent;font:400 12.5px/1 var(--wa-font-sans);display:inline-flex;align-items:center;justify-content:center;gap:7px;cursor:pointer;white-space:nowrap;-webkit-user-select:none;user-select:none;transition:background .14s ease,border-color .14s ease,filter .14s ease,box-shadow .14s ease;background:transparent;color:var(--wa-text)}.w-btn:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-btn:disabled{opacity:.6;cursor:not-allowed}.w-btn svg{width:14px;height:14px;flex:none}.w-btn.w-notif-bell{width:32px;height:32px}.w-btn.w-notif-bell svg{width:18px;height:18px}.w-btn--primary{background:var(--wa-primary);color:var(--wa-primary-foreground);box-shadow:inset 0 1px #ffffff2e,0 1px 2px #1414161f,0 2px 8px -2px color-mix(in srgb,var(--wa-primary) 50%,transparent);background-image:linear-gradient(180deg,#ffffff1a,#fff0 42%)}.w-btn--primary:active:not(:disabled){filter:brightness(.97);box-shadow:inset 0 1px 2px #14141633}.w-btn--block{width:100%;height:38px;font-size:13px}.w-btn--secondary{background:var(--wa-surface);border-color:var(--wa-border-strong);color:var(--wa-text);box-shadow:inset 0 1px #ffffff80,0 1px 1.5px #1414160a}.w-btn--ghost{background:transparent;color:var(--wa-text-secondary)}.w-btn--danger{background:transparent;color:var(--wa-error);border-color:color-mix(in srgb,var(--wa-error) 26%,transparent)}.w-btn--danger-solid{background:var(--wa-error);color:#fff}.w-btn--sm{height:26px;padding:0 9px;font-size:11.5px}.w-btn--lg{height:42px;padding:0 18px;font-size:13.5px}.w-btn--icon{height:28px;width:28px;padding:0;color:var(--wa-text-muted)}.w-btn--icon:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-social{height:40px;width:100%;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);color:var(--wa-text);font:400 13px/1 var(--wa-font-sans);display:flex;align-items:center;justify-content:center;gap:10px;padding:0 14px;cursor:pointer;position:relative;box-shadow:inset 0 1px #ffffff80,0 1px 1.5px #1414160a;transition:background .14s ease,border-color .14s ease,box-shadow .14s ease,transform .1s ease}.w-social:active{transform:translateY(.5px)}.w-social:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-social svg,.w-social img{width:17px;height:17px;flex:none}.w-social .w-social-label{flex:none}.w-social .w-lastused{position:absolute;top:-9px;right:12px;white-space:nowrap;font:400 9.5px/1 var(--wa-font-mono);letter-spacing:.04em;color:var(--wa-text-muted);background:var(--wa-surface);border:.5px solid var(--wa-border);padding:3px 6px;border-radius:5px}.w-field{display:flex;flex-direction:column;gap:7px}.w-label{font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);display:flex;align-items:center;gap:4px;letter-spacing:-.005em;white-space:nowrap}.w-req{color:var(--wa-error);font-size:12px}.w-input{height:34px;padding:0 12px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);color:var(--wa-text);font:400 13px/1 var(--wa-font-sans);width:100%;box-shadow:inset 0 1px 2px #1414160d;transition:border-color .14s ease,box-shadow .14s ease}.w-input::placeholder{color:var(--wa-text-faint)}.w-input:focus{outline:none;border-color:var(--wa-primary);box-shadow:inset 0 1px 2px #1414160a,0 0 0 3px var(--wa-primary-soft)}.w-input-row{display:flex;align-items:center;gap:6px}.w-input-trail{margin-left:-34px;z-index:1}.w-input-wrap{position:relative}.w-input--valid:focus{border-color:var(--wa-success);box-shadow:0 0 0 3px var(--wa-success-soft)}.w-input--invalid,.w-input[aria-invalid=true]{border-color:color-mix(in srgb,var(--wa-error) 55%,var(--wa-border-strong))}.w-input--invalid:focus,.w-input[aria-invalid=true]:focus{border-color:var(--wa-error);box-shadow:0 0 0 3px var(--wa-error-soft)}.w-input:disabled,.w-input[data-disabled]{opacity:.55;cursor:not-allowed}.w-input-err{font:400 11.5px/1.3 var(--wa-font-sans);color:var(--wa-error)}.w-input-ok{font:400 11.5px/1.3 var(--wa-font-sans);color:var(--wa-success)}.w-input-eye{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:28px;height:28px;display:grid;place-items:center;border:0;background:none;cursor:pointer;color:var(--wa-text-faint);border-radius:6px}.w-input-eye:hover{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-input-eye svg{width:15px;height:15px}.w-avatar{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;font:400 var(--av-fs, 13px)/1 var(--wa-font-sans);color:var(--wa-primary-foreground);flex:none;background:var( --av-bg, linear-gradient( 135deg, var(--wa-primary), var( --wa-primary-tint, color-mix(in srgb, var(--wa-primary), #fff 25%) ) ) );box-shadow:inset 0 0 0 .5px #ffffff29;letter-spacing:.01em;overflow:hidden}.w-avatar img{width:100%;height:100%;object-fit:cover}.w-avatar--square{border-radius:var(--wa-radius)}.w-avatar--sm{width:20px;height:20px;font-size:10px}.w-avatar--md{width:28px;height:28px;font-size:11px}.w-avatar--lg{width:44px;height:44px;font-size:15px}.w-avatar--xl{width:80px;height:80px;font-size:24px}.w-avatar-edit{position:relative;cursor:pointer;border:0;padding:0}.w-avatar-edit .w-avatar-veil{position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;display:grid;place-items:center;color:#fff;background:color-mix(in srgb,#000 45%,transparent);opacity:0;transition:opacity .15s ease;font:400 11px/1.2 var(--wa-font-sans);text-align:center;padding:0 6px}.w-avatar-edit:hover .w-avatar-veil,.w-avatar-edit[data-busy] .w-avatar-veil{opacity:1}.w-avatar-veil svg{width:18px;height:18px}.w-pill{display:inline-flex;align-items:center;gap:6px;height:21px;padding:0 8px;border-radius:4px;font:400 10.5px/1 var(--wa-font-mono);text-transform:lowercase;letter-spacing:.01em;background:var(--wa-surface-subtle);color:var(--wa-text-muted);border:.5px solid var(--wa-border);white-space:nowrap;flex:none}.w-pill .w-dot{width:5px;height:5px;border-radius:999px;background:var(--wa-text-faint)}.w-pill--success{background:var(--wa-success-soft);color:var(--wa-success);border-color:color-mix(in srgb,var(--wa-success) 26%,transparent)}.w-pill--success .w-dot{background:var(--wa-success)}.w-pill--warning{background:var(--wa-warning-soft);color:var(--wa-warning);border-color:color-mix(in srgb,var(--wa-warning) 26%,transparent)}.w-pill--warning .w-dot{background:var(--wa-warning)}.w-pill--info{background:var(--wa-info-soft);color:var(--wa-info);border-color:color-mix(in srgb,var(--wa-info) 26%,transparent)}.w-pill--info .w-dot{background:var(--wa-info)}.w-pill--current{background:var(--wa-primary-soft);color:var(--wa-primary);border-color:color-mix(in srgb,var(--wa-primary) 26%,transparent)}.w-pill--error{background:var(--wa-error-soft);color:var(--wa-error);border-color:color-mix(in srgb,var(--wa-error) 26%,transparent)}.w-pill--error .w-dot{background:var(--wa-error)}.w-pill--pending{background:transparent;color:var(--wa-warning);border:.5px dashed color-mix(in srgb,var(--wa-warning) 55%,transparent)}.w-pill--pending .w-dot{background:var(--wa-warning)}.w-chip{display:inline-flex;align-items:center;gap:7px;height:24px;padding:0 5px 0 9px;border-radius:var(--wa-radius);background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);font:400 12px/1 var(--wa-font-mono);color:var(--wa-text-secondary)}.w-chip-x{display:grid;place-items:center;width:16px;height:16px;border-radius:3px;color:var(--wa-text-faint);cursor:pointer}.w-chip-x:hover{background:var(--wa-border);color:var(--wa-text)}.w-chip-x svg{width:11px;height:11px}.w-or{display:flex;align-items:center;gap:14px;margin:18px 0}.w-or:before,.w-or:after{content:"";height:.5px;background:var(--wa-border);flex:1}.w-or span{font:400 10px/1 var(--wa-font-mono);letter-spacing:.14em;color:var(--wa-text-faint)}.w-hr{height:.5px;background:var(--wa-border);border:0;margin:0;width:100%}.w-list{display:flex;flex-direction:column}.w-listhead{display:grid;align-items:center;padding:0 2px 8px;font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);border-bottom:.5px solid var(--wa-border)}.w-row{display:grid;align-items:center;padding:13px 2px;border-bottom:.5px solid var(--wa-border)}.w-row:last-child{border-bottom:0}.w-row--hover{border-radius:var(--wa-radius);margin:0 -8px;padding:11px 10px;border-bottom:0;transition:background .12s ease}.w-row--hover:hover{background:var(--wa-surface-subtle)}.w-acct{display:flex;align-items:center;gap:13px;width:100%;text-align:left;padding:11px 12px;border:.5px solid transparent;border-radius:var(--wa-radius-lg);background:none;cursor:pointer;transition:background .13s ease,border-color .13s ease}.w-acct:hover{background:var(--wa-surface-subtle)}.w-acct[data-active]{background:var(--wa-surface-subtle);border-color:var(--wa-border)}.w-acct .w-acct-go{color:var(--wa-text-faint);flex:none;opacity:0;transform:translate(-4px);transition:opacity .13s ease,transform .13s ease}.w-acct:hover .w-acct-go{opacity:1;transform:none;color:var(--wa-text-muted)}.w-acct[data-busy]{opacity:.55;pointer-events:none}.w-acct-list{border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);overflow:hidden;margin-bottom:18px}.w-acct-list-head{padding:11px 14px;border-bottom:.5px solid var(--wa-border)}.w-acct-list-body{padding:6px}.w-acct-text{flex:1;min-width:0;text-align:left}.w-acct-name{display:block;font:400 13px/1.3 var(--wa-font-sans);color:var(--wa-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-acct-text .w-secsub{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-acct .w-avatar{width:34px;height:34px;flex:none}.w-acct[data-active] .w-avatar{width:40px;height:40px}.w-acct-add-ic{width:36px;height:36px;border-radius:50%;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);display:grid;place-items:center;color:var(--wa-text-muted);flex:none;transition:color .13s ease,border-color .13s ease}.w-acct--add:hover .w-acct-add-ic{color:var(--wa-text);border-color:var(--wa-text-muted)}.w-acct-out{color:var(--wa-text-faint);flex:none;margin-right:-6px}.w-acct-out:hover{color:var(--wa-error);background:var(--wa-error-soft)}.w-acct--add:hover{background:var(--wa-surface-subtle)}.w-acct-foot{margin-top:8px;padding-top:10px}.w-acct-add{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;height:36px;border:0;background:none;cursor:pointer;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-muted);transition:background .13s ease,color .13s ease}.w-acct-add svg{width:15px;height:15px}.w-acct-add:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-tabs{display:flex;gap:2px}.w-tab{display:inline-flex;align-items:center;gap:7px;height:30px;flex:none;white-space:nowrap;padding:0 12px;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-muted);background:none;border:0;cursor:pointer;transition:color .14s ease,background .14s ease}.w-tab svg{width:14px;height:14px}.w-tab:hover,.w-tab--active{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-tab--active svg{color:var(--wa-primary)}.w-menu{width:264px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;padding:4px;overflow:hidden}.w-menu-head{display:flex;align-items:center;gap:11px;padding:11px 9px}.w-menu-item{display:flex;align-items:center;justify-content:flex-start;gap:10px;height:32px;padding:0 8px;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);cursor:pointer;transition:background .12s ease;width:100%;border:0;background:none;text-align:left;white-space:nowrap}.w-menu-item:hover{background:var(--wa-surface-subtle)}.w-menu-item svg{width:15px;height:15px;color:var(--wa-text-muted);flex:none}.w-menu-item .w-avatar svg{color:inherit}.w-menu-item--danger{color:var(--wa-error)}.w-menu-item--danger svg{color:var(--wa-error)}.w-menu-item--danger:hover{background:var(--wa-error-soft)}.w-menu-trail{margin-left:auto;font:400 10.5px/1 var(--wa-font-mono);color:var(--wa-text-faint)}.w-menu-label{font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);padding:10px 9px 5px}.w-orgtrigger{display:flex;align-items:center;gap:9px;width:100%;height:40px;padding:0 9px;border:0;border-radius:var(--wa-radius);background:transparent;color:var(--wa-text);cursor:pointer;font:400 13px/1 var(--wa-font-sans);text-align:left;transition:background .12s ease}.w-orgtrigger:hover,.w-orgtrigger[data-open]{background:var(--wa-surface-subtle)}.w-orgtrigger:disabled{opacity:.6;cursor:default}.w-orgtrigger>svg{color:var(--wa-text-faint);flex:none}.w-switch-body{overflow-y:auto;padding:4px 0}.w-switch-banner{margin:8px 8px 0}.w-switch-nest{display:flex;flex-direction:column;margin:2px 0 6px 24px;padding-left:8px;border-left:.5px solid var(--wa-border)}.w-menu-item--muted{color:var(--wa-text-muted)}.w-menu-item--muted svg{color:var(--wa-text-muted)}.w-rowact{display:inline-grid;place-items:center;width:22px;height:22px;border-radius:5px;color:var(--wa-text-muted);cursor:pointer}.w-rowact:hover{color:var(--wa-text);background:var(--wa-border)}.w-rowact svg{width:13px;height:13px}.w-danger{border:.5px solid color-mix(in srgb,var(--wa-error) 30%,transparent);background:var(--wa-error-soft);border-radius:var(--wa-radius);padding:14px 16px;display:flex;align-items:center;justify-content:space-between;gap:20px}.w-link{color:var(--wa-text);font-weight:400;cursor:pointer;text-decoration:none}.w-link--sm{font-size:12px}.w-link:hover{text-decoration:underline}.w-link--muted{color:var(--wa-text-muted)}.w-mono-faint{font:400 12px/1.4 var(--wa-font-mono);color:var(--wa-text-faint)}@keyframes w-spin{to{transform:rotate(360deg)}}.w-spin{display:inline-block;border-radius:50%;border:2px solid var(--wa-border-strong);border-top-color:var(--wa-primary);animation:w-spin .7s linear infinite}.w-spin--on-accent{border-color:#ffffff59;border-top-color:#fff}.w-loading{display:grid;place-items:center;gap:14px;padding:40px;text-align:center}.w-otp{display:flex;gap:8px}.w-otp .w-otp-cell{width:42px;height:48px;text-align:center;font:400 20px/1 var(--wa-font-mono);color:var(--wa-text);border:.5px solid var(--wa-border-strong);border-radius:var(--wa-radius);background:var(--wa-surface);display:grid;place-items:center}.w-otp .w-otp-cell[data-active],.w-otp .w-otp-cell:focus{outline:none;border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-otp .w-otp-cell[data-filled]{border-color:var(--wa-text-muted)}.w-otp[data-error] .w-otp-cell{border-color:color-mix(in srgb,var(--wa-error) 50%,var(--wa-border-strong))}.w-otp-caret{width:1.5px;height:22px;background:var(--wa-primary);animation:w-blink 1s steps(1) infinite}@keyframes w-blink{50%{opacity:0}}.w-addr-badge{display:inline-flex;align-items:center;gap:8px;height:30px;padding:0 6px 0 12px;border-radius:999px;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-secondary)}.w-addr-badge button{border:0;background:none;cursor:pointer;color:var(--wa-primary);font:400 12px/1 var(--wa-font-sans);padding:4px 8px;border-radius:6px}.w-addr-badge button:hover{background:var(--wa-primary-soft)}.w-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px;padding:48px 24px}.w-empty .w-empty-ic{display:grid;place-items:center;width:44px;height:44px;border-radius:var(--wa-radius-lg);background:var(--wa-primary-soft);color:var(--wa-primary)}.w-empty .w-empty-ic svg{width:20px;height:20px;color:var(--wa-primary)}.w-empty-text{display:flex;flex-direction:column;gap:4px}.w-empty h4{margin:0;font:500 14px/1.4 var(--wa-font-sans);color:var(--wa-text)}.w-empty p{margin:0;font:400 12px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);max-width:384px;text-wrap:pretty}.w-empty-action{margin-top:4px}.w-empty--fill{height:100%}.w-empty-ic--accent{width:44px;height:44px}.w-toast{display:inline-flex;align-items:center;gap:11px;padding:11px 13px 11px 14px;border-radius:var(--wa-radius-lg);background:var(--wa-surface);border:.5px solid var(--wa-border);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;min-width:280px;max-width:380px}.w-toast .w-toast-ic{width:20px;height:20px;border-radius:50%;display:grid;place-items:center;flex:none}.w-toast .w-toast-ic svg{width:12px;height:12px}.w-toast--success .w-toast-ic{background:var(--wa-success-soft);color:var(--wa-success)}.w-toast--error .w-toast-ic{background:var(--wa-error-soft);color:var(--wa-error)}.w-toast-msg{flex:1;font:400 13px/1.35 var(--wa-font-sans);color:var(--wa-text)}.w-toast-x{border:0;background:none;cursor:pointer;color:var(--wa-text-faint);width:22px;height:22px;border-radius:6px;display:grid;place-items:center;flex:none}.w-toast-x:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-toast-x svg{width:12px;height:12px}.w-pop{width:320px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;overflow:hidden}.w-pop-body{padding:15px 15px 13px;display:flex;flex-direction:column;gap:11px}.w-pop-title{margin:0;font:400 13.5px/1.3 var(--wa-font-sans);letter-spacing:-.01em;color:var(--wa-text)}.w-pop-sub{margin:0;font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);text-wrap:pretty}.w-pop-title+.w-pop-sub{margin-top:-7px}.w-pop-foot{display:flex;gap:8px;justify-content:flex-end;padding:10px 14px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-pop-foot .w-btn{width:auto}.w-pop-icon{width:38px;height:38px;border-radius:var(--wa-radius);display:grid;place-items:center;flex:none}.w-pop-icon--danger{background:var(--wa-error-soft);color:var(--wa-error)}.w-pop-icon--warn{background:var(--wa-warning-soft);color:var(--wa-warning)}.w-pop-icon svg{width:18px;height:18px}.w-locked{display:flex;align-items:center;gap:10px;height:38px;padding:0 8px 0 13px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-locked .w-locked-ic{color:var(--wa-text-faint);flex:none}.w-locked .w-locked-ic svg{width:15px;height:15px;display:block}.w-locked .w-locked-val{flex:1;font:400 13.5px/1 var(--wa-font-sans);color:var(--wa-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-restricted{opacity:.55;cursor:not-allowed}.w-restricted *{pointer-events:none}.w-warn-ic{color:var(--wa-warning);display:inline-grid;place-items:center}.w-warn-ic svg{width:15px;height:15px}.w-codes{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:14px;border-radius:var(--wa-radius);background:var(--wa-surface-subtle);border:.5px solid var(--wa-border)}.w-codes span{font:400 13px/1.6 var(--wa-font-mono);color:var(--wa-text);text-align:center;letter-spacing:.04em}.w-qr{width:148px;height:148px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface);display:grid;place-items:center;color:var(--wa-text)}.w-banner{display:flex;gap:11px;padding:12px 14px;border-radius:var(--wa-radius);align-items:flex-start}.w-banner svg{width:16px;height:16px;flex:none;margin-top:1px}.w-banner-txt{font:400 12.5px/1.5 var(--wa-font-sans);text-wrap:pretty;color:var(--wa-text-secondary)}.w-banner--error{background:var(--wa-error-soft)}.w-banner--warn{background:var(--wa-warning-soft)}.w-banner--info{background:var(--wa-info-soft)}.w-banner--error svg{color:var(--wa-error)}.w-banner--warn svg{color:var(--wa-warning)}.w-banner--info svg{color:var(--wa-info)}.w-seg{display:inline-flex;padding:3px;gap:2px;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);border-radius:var(--wa-radius)}.w-seg button{height:28px;padding:0 12px;border:0;background:none;cursor:pointer;border-radius:4px;font:400 12px/1 var(--wa-font-sans);color:var(--wa-text-muted);white-space:nowrap}.w-seg button[data-on]{background:var(--wa-surface);color:var(--wa-text);box-shadow:0 0 0 .5px var(--wa-border)}.w-steps{display:flex;gap:6px;justify-content:center}.w-steps i{width:5px;height:5px;border-radius:999px;background:var(--wa-border-strong);transition:background .2s ease,width .2s ease}.w-steps i[data-on]{background:var(--wa-primary);width:16px}.w-ibadge{display:grid;place-items:center;width:48px;height:48px;flex:none;border-radius:var(--wa-radius-lg);background:var(--wa-primary-soft);color:var(--wa-primary);overflow:hidden}.w-ibadge svg{width:24px;height:24px}.w-ibadge img{width:100%;height:100%;object-fit:cover}.w-ibadge--done{width:52px;height:52px;border-radius:999px;background:var(--wa-success-soft);color:var(--wa-success)}.w-ibadge--done svg{width:26px;height:26px}.w-ibadge-wrap{position:relative}.w-ibadge-x{position:absolute;top:-6px;right:-6px;width:20px;height:20px;display:grid;place-items:center;border-radius:999px;border:.5px solid var(--wa-border);background:var(--wa-surface);color:var(--wa-text-muted);cursor:pointer;box-shadow:0 1px 2px #1414161f}.w-ibadge-x svg{width:11px;height:11px}.w-create-foot{padding:13px 32px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle);text-align:center}.w-create-summary{display:flex;align-items:center;justify-content:center;gap:12px;width:100%;padding:12px 16px;border:.5px solid var(--wa-border);border-radius:var(--wa-radius)}.w-auth-card{width:min(440px,100%)}.w-auth-head{display:flex;flex-direction:column;align-items:center;gap:14px;margin-bottom:24px}.w-auth-head-text{display:flex;flex-direction:column;gap:6px;text-align:center}.w-auth-title{margin:0;font:400 21px/1.2 var(--wa-font-sans);letter-spacing:-.025em;color:var(--wa-text)}.w-auth-sub{margin:0;font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);text-wrap:pretty}.w-auth-status{display:flex;flex-direction:column;align-items:center;gap:16px;padding-top:4px;text-align:center}.w-auth-foot{font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted)}.w-fineprint{margin:2px 2px 0;font:400 11px/1.5 var(--wa-font-sans);color:var(--wa-text-faint);text-align:center;text-wrap:pretty}.w-switch{display:inline-flex;align-items:center;gap:10px;cursor:pointer;-webkit-user-select:none;user-select:none}.w-switch .w-switch-track{width:36px;height:20px;border-radius:999px;background:var(--wa-border-strong);border:.5px solid transparent;position:relative;transition:background .16s ease;flex:none}.w-switch .w-switch-knob{position:absolute;top:1.5px;left:1.5px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform .16s ease}.w-switch[data-on] .w-switch-track{background:var(--wa-primary)}.w-switch[data-on] .w-switch-knob{transform:translate(16px)}.w-switch-label{font:400 13px/1 var(--wa-font-sans);color:var(--wa-text)}.w-search{display:flex;align-items:center;gap:8px;height:32px;width:240px;max-width:100%;padding:0 11px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface)}.w-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:14px}.w-search svg{width:15px;height:15px;color:var(--wa-text-faint);flex:none}.w-search input{border:0;background:none;outline:none;flex:1;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);min-width:0}.w-search input::placeholder{color:var(--wa-text-faint)}.w-combo{display:flex;align-items:center;gap:8px;height:34px;padding:0 10px 0 12px;width:100%;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);cursor:pointer;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);transition:border-color .14s ease}.w-combo:hover{border-color:var(--wa-text-muted)}.w-combo[data-open]{border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-combo .w-combo-val{flex:1;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-combo .w-combo-val[data-ph]{color:var(--wa-text-faint)}.w-combo svg{width:15px;height:15px;color:var(--wa-text-muted);flex:none}.w-combo-menu{width:100%;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;padding:4px;overflow:hidden}.w-combo-opt{display:flex;align-items:center;justify-content:flex-start;gap:9px;height:30px;padding:0 8px;border-radius:5px;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);cursor:pointer;width:100%;border:0;background:none;text-align:left;white-space:nowrap}.w-combo-opt>svg{width:15px;height:15px;flex:none;color:var(--wa-text-muted)}.w-combo-opt:hover{background:var(--wa-surface-subtle)}.w-combo-opt .w-combo-check{margin-left:auto;color:var(--wa-primary);display:grid;place-items:center}.w-combo-opt .w-combo-check svg{width:14px;height:14px}.w-combo-opt[data-disabled]{opacity:.5;cursor:not-allowed}.w-combo-grp{font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);padding:9px 9px 5px}.w-phone{display:flex;align-items:stretch;gap:0;width:100%}.w-phone .w-phone-cc{display:flex;align-items:center;gap:7px;height:34px;padding:0 10px;border:.5px solid var(--wa-border-strong);border-right:0;border-radius:var(--wa-radius) 0 0 var(--wa-radius);background:var(--wa-surface-subtle);cursor:pointer;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);white-space:nowrap}.w-phone .w-phone-cc svg{width:13px;height:13px;color:var(--wa-text-muted)}.w-phone input{flex:1;height:34px;padding:0 12px;border:.5px solid var(--wa-border-strong);border-radius:0 var(--wa-radius) var(--wa-radius) 0;background:var(--wa-surface);font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);outline:none;min-width:0}.w-phone input:focus{border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft);position:relative}.w-flag{width:18px;height:13px;border-radius:2px;display:inline-block;flex:none;box-shadow:inset 0 0 0 .5px #00000026}.w-country-pop{position:absolute;top:calc(100% + 6px);left:0;z-index:50;width:260px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;overflow:hidden}.w-country-search{display:flex;align-items:center;gap:8px;padding:9px 11px;border-bottom:.5px solid var(--wa-border)}.w-country-search svg{width:14px;height:14px;color:var(--wa-text-faint);flex:none}.w-country-search input{border:0;background:none;outline:none;flex:1;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);min-width:0}.w-country-search input::placeholder{color:var(--wa-text-faint)}.w-country-list{max-height:220px;overflow-y:auto;padding:5px}.w-country-opt{display:flex;align-items:center;gap:9px;height:32px;padding:0 9px;border-radius:5px;cursor:pointer;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);width:100%;border:0;background:none;text-align:left}.w-country-opt:hover{background:var(--wa-surface-subtle)}.w-country-opt .dial{margin-left:auto;color:var(--wa-text-muted);font:400 12px/1 var(--wa-font-mono);flex:none}.w-method-stack{display:flex;flex-direction:column;gap:10px}.w-method{display:flex;align-items:center;gap:13px;width:100%;padding:13px 14px;border:.5px solid var(--wa-border-strong);border-radius:var(--wa-radius);background:var(--wa-surface);cursor:pointer;text-align:left;transition:background .14s ease,border-color .14s ease}.w-method .w-method-ic{width:34px;height:34px;border-radius:var(--wa-radius);display:grid;place-items:center;background:var(--wa-surface-subtle);color:var(--wa-text-secondary);flex:none}.w-method .w-method-ic svg{width:17px;height:17px}.w-method .w-method-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.w-method .w-method-title{font:400 13.5px/1 var(--wa-font-sans);color:var(--wa-text)}.w-method .w-method-desc{font:400 12px/1.4 var(--wa-font-sans);color:var(--wa-text-muted)}.w-method .w-method-go{color:var(--wa-text-faint);flex:none}.w-method .w-method-go svg{width:16px;height:16px}.w-method[data-disabled]{opacity:.5;cursor:not-allowed}.w-overlay{position:relative;width:100%;height:100%;background:color-mix(in srgb,#000 38%,transparent);display:grid;place-items:center;border-radius:inherit}.w-dialog{background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;width:100%;max-width:480px;overflow:hidden;display:flex;flex-direction:column}.w-dialog--panel{display:block;width:880px;max-width:100%;height:min(560px,calc(100dvh - 40px));overflow-y:auto}.w-dialog--panel .w-card{background:transparent;border-radius:0;box-shadow:none}@media(max-width:640px){.w-dialog--panel{height:calc(100dvh - 16px)}}.w-dialog--create{background:transparent;border:0;box-shadow:none;width:440px;max-width:100%;align-items:center;scrollbar-gutter:stable both-edges}.w-create-card{width:440px;max-width:100%}.w-create-body{padding:34px 32px 28px}.w-create-head{margin-bottom:24px}.w-create-steps{margin-bottom:22px}.w-text-center{text-align:center}.w-linkbtn{background:none;border:0;padding:0;cursor:pointer}.w-modal{position:fixed;top:0;right:0;bottom:0;left:0;background:#08080c80;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);display:flex;justify-content:center;align-items:center;padding:20px;z-index:99999}@media(max-width:640px){.w-modal{padding:8px}}.w-dialog-head{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:.5px solid var(--wa-border)}.w-dialog-title{margin:0;font:400 15px/1.2 var(--wa-font-sans);letter-spacing:-.01em;color:var(--wa-text)}.w-dialog-body{padding:20px;display:flex;flex-direction:column;gap:14px}.w-dialog-foot{display:flex;gap:8px;justify-content:flex-end;padding:14px 20px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-vtabs{display:flex;flex-direction:column;gap:2px}.w-vtab{display:flex;align-items:center;gap:10px;height:34px;padding:0 11px;border-radius:var(--wa-radius);font:400 13px/1 var(--wa-font-sans);color:var(--wa-text-muted);background:none;border:0;cursor:pointer;text-align:left;width:100%}.w-vtab svg{width:15px;height:15px}.w-vtab:hover,.w-vtab[data-on]{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-vtab[data-on] svg{color:var(--wa-primary)}@keyframes w-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.w-skel{border-radius:6px;background:linear-gradient(90deg,var(--wa-surface-subtle) 25%,var(--wa-border) 37%,var(--wa-surface-subtle) 63%);background-size:200% 100%;animation:w-shimmer 1.4s ease infinite}.w-auth-skel{display:flex;flex-direction:column;gap:22px}.w-auth-skel-head{display:flex;flex-direction:column;align-items:center;gap:12px;margin-bottom:2px}.w-auth-skel-fields{display:flex;flex-direction:column;gap:15px}.w-auth-skel-field{display:flex;flex-direction:column;gap:7px}.w-skel-avatar{width:44px;height:44px;border-radius:50%}.w-skel-line{height:10px}.w-skel-title{height:16px;width:56%}.w-skel-sub{height:11px;width:78%}.w-skel-label{height:9px;width:34%}.w-skel-input{height:38px;border-radius:var(--wa-radius)}.w-skel-btn{height:38px;border-radius:var(--wa-radius);margin-top:3px}.w-table{width:100%;border-collapse:separate;border-spacing:0;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);overflow:hidden}.w-table thead{background:var(--wa-surface-subtle)}.w-table th{text-align:left;padding:9px 16px;font:400 11px/1 var(--wa-font-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--wa-text-faint);white-space:nowrap;border-bottom:.5px solid var(--wa-border)}.w-table th:last-child{text-align:right}.w-table td{padding:11px 16px;font:400 13px/1.35 var(--wa-font-sans);color:var(--wa-text-secondary);vertical-align:middle;white-space:nowrap}.w-table tbody tr{transition:background .12s ease}.w-table tbody tr:not(:last-child) td{border-bottom:.5px solid var(--wa-border)}.w-table tbody tr:hover td{background:var(--wa-surface-subtle)}.w-table tbody tr:last-child td:last-child{overflow:visible}.w-td--flex>div{display:flex;align-items:center;gap:10px}.w-td--actions{text-align:right;width:auto;white-space:nowrap;position:relative;overflow:visible}.w-td--actions>*{width:fit-content;margin-left:auto}.w-td--actions>[data-dropdown-trigger]{display:inline-flex;width:fit-content;margin-left:auto}.w-actions{display:flex;gap:6px;justify-content:flex-end;align-items:center}.w-kebab{width:28px;height:28px;border-radius:6px;border:0;background:none;cursor:pointer;color:var(--wa-text-muted);display:grid;place-items:center}.w-kebab:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-kebab svg{width:16px;height:16px}.w-token{display:flex;align-items:center;gap:8px;height:36px;padding:0 6px 0 12px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-token code{flex:1;font:400 12px/1 var(--wa-font-mono);color:var(--wa-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-page-head{display:flex;align-items:center;flex-wrap:wrap;gap:12px;padding:18px 22px}.w-tabsbar{flex:none;padding:0 22px;border-bottom:.5px solid var(--wa-border);overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.w-tabsbar::-webkit-scrollbar{display:none}.w-tabbody{flex:1;min-height:0;padding:20px 22px;overflow-y:auto;overflow-x:auto}.w-tabpane{min-width:300px}.w-card-head{display:flex;align-items:flex-start;justify-content:space-between;flex-wrap:wrap;gap:16px;padding:16px 20px}.w-card-body{padding:16px 20px}.w-card-foot{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:12px;padding:14px 20px;border-top:.5px solid var(--wa-border)}.w-sechead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px}.w-iconbox{width:22px;height:22px;flex:none;display:inline-flex;align-items:center;justify-content:center;overflow:hidden}.w-iconbox svg,.w-iconbox img{width:22px;height:22px;display:block}.w-vrow{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 0}.w-vrow:not(:last-child){border-bottom:.5px solid var(--wa-border)}.w-row-act-top{align-self:flex-start;margin-top:20px}.w-rowitem{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 20px}.w-rowitem:not(:last-child){border-bottom:.5px solid var(--wa-border)}.w-aside-copy{max-width:220px;text-align:center}.w-split{display:flex;min-height:400px;border-radius:var(--wa-radius-lg);overflow:hidden;border:.5px solid var(--wa-border);background:var(--wa-surface)}.w-split-aside{width:35%;min-width:200px;flex:none;background:var(--wa-surface-subtle);border-right:.5px solid var(--wa-border);padding:28px;display:flex;flex-direction:column;gap:14px}.w-split-main{flex:1;min-width:0;padding:28px;display:flex;flex-direction:column;gap:16px}@media(max-width:600px){.w-split{flex-direction:column}.w-split-aside{width:100%;border-right:0;border-bottom:.5px solid var(--wa-border)}}.w-listrow{display:flex;align-items:center;gap:12px;width:100%;padding:12px 0;text-align:left;border:0;border-bottom:.5px solid var(--wa-border);background:transparent;cursor:pointer;transition:background .12s ease}.w-listrow:last-child{border-bottom:0}.w-listrow:hover{background:var(--wa-surface-subtle)}.w-listrow:disabled{opacity:.6;cursor:not-allowed}.w-tile{border:.5px solid var(--wa-border);border-radius:var(--wa-radius);padding:12px;background:var(--wa-surface-subtle)}.w-input--area{min-height:80px;padding-top:9px;padding-bottom:9px;resize:vertical;line-height:1.5}.w-input--mono{font-family:var(--wa-font-mono)}.w-pop--wide{width:372px;max-width:calc(100vw - 24px);overflow:visible}.w-pop .w-input:not(.w-input--area),.w-pop .w-combo{height:32px}.w-feature-badge{width:52px;height:52px;border-radius:999px;display:grid;place-items:center;color:var(--wa-primary-foreground);background:linear-gradient(135deg,var(--wa-primary),var(--wa-primary-tint, #9277ff));box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-primary) 55%,transparent);margin-bottom:18px}.w-narrow{max-width:420px;margin:0 auto}.w-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:14px}.w-grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.w-grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}@media(max-width:600px){.w-grid-2,.w-grid-3,.w-grid-4{grid-template-columns:1fr}}.w-toast--fixed{position:fixed;bottom:20px;right:20px;z-index:1000}.w-toast--contained{position:absolute;bottom:16px;left:50%;transform:translate(-50%);z-index:20;width:max-content;max-width:calc(100% - 32px)}.w-notif-badge{position:absolute;top:4px;right:4px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--wa-error);color:#fff;font:500 9px/1 var(--wa-font-sans);display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--wa-surface)}.w-notif-badge[data-dot]{top:6px;right:6px;min-width:8px;height:8px;padding:0}.w-notif-row{cursor:pointer;padding:12px 18px;border-bottom:.5px solid var(--wa-border);transition:background .12s ease}.w-notif-row:hover,.w-notif-row[data-unread]{background:var(--wa-surface-subtle)}.w-notif-row:hover .w-notif-actions button{color:var(--wa-text-secondary)}.w-notif-row .w-notif-actions button{color:var(--wa-text-faint);transition:color .12s ease}.w-notif-row .w-notif-actions button:hover{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-notif-row .w-notif-actions button[data-on]{color:var(--wa-warning)}.w-notif-dot{width:8px;height:8px;border-radius:50%;background:var(--wa-primary);flex:none}.w-notif-pop{position:fixed;width:450px;max-width:calc(100vw - 24px);z-index:99999}.w-notif-panel{width:450px;max-width:100%;height:100%;background:var(--wa-surface);overflow:hidden}.w-notif-panel--fill{width:100%}.w-notif-head{position:relative;padding:14px 18px;border-bottom:.5px solid var(--wa-border)}.w-notif-body{overflow-x:hidden;overflow-y:auto;background:var(--wa-surface)}.w-notif-menu{position:absolute;top:calc(100% + 4px);right:12px;width:200px;z-index:100000}.w-notif-menu .w-menu-check{margin-left:auto;color:var(--wa-primary)}.w-notif-filter-dot{position:absolute;top:5px;right:5px;width:6px;height:6px;border-radius:50%;background:var(--wa-primary)}.w-banner--success{background:var(--wa-success-soft)}.w-banner--success svg{color:var(--wa-success)}@keyframes w-pop{0%{transform:scale(.5);opacity:0}60%{transform:scale(1.06)}to{transform:scale(1);opacity:1}}@keyframes w-ring{0%{transform:scale(.85);opacity:.45}to{transform:scale(1.9);opacity:0}}@keyframes w-draw{to{stroke-dashoffset:0}}@keyframes w-indeterminate{0%{transform:translate(-100%)}to{transform:translate(330%)}}.w-success{position:relative;display:grid;place-items:center;width:56px;height:56px}.w-success .ring{position:absolute;top:2px;right:2px;bottom:2px;left:2px;border-radius:999px;border:1.5px solid var(--wa-success);opacity:0}.w-success .disc{width:52px;height:52px;border-radius:999px;background:var(--wa-success);color:#fff;display:grid;place-items:center;box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-success) 55%,transparent)}.w-success .disc svg{width:26px;height:26px}.w-success--error .ring{border-color:var(--wa-error)}.w-success--error .disc{background:var(--wa-error);box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-error) 55%,transparent)}.w-success--info .ring{border-color:var(--wa-info)}.w-success--info .disc{background:var(--wa-info);box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-info) 55%,transparent)}.w-progress{position:relative;width:70%;height:3px;border-radius:999px;background:var(--wa-border);overflow:hidden}.w-progress:after{content:"";position:absolute;top:0;left:0;width:30%;height:100%;border-radius:999px;background:var(--wa-primary)}@media(prefers-reduced-motion:no-preference){.w-success .ring{animation:w-ring 1.7s ease-out infinite}.w-success .disc{animation:w-pop .42s cubic-bezier(.2,.9,.3,1.2)}.w-success .disc svg path{stroke-dasharray:26;stroke-dashoffset:26;animation:w-draw .4s .22s ease forwards}.w-progress:after{animation:w-indeterminate 1.15s ease-in-out infinite}}.w-sso-conn{padding-bottom:24px}.w-sso-conn:not(:last-child){margin-bottom:24px;border-bottom:.5px solid var(--wa-border)}.w-sso-detail{display:grid;grid-template-columns:auto 1fr;gap:4px 32px}.w-sso-scim{padding-top:16px;border-top:.5px solid var(--wa-border)}.w-sso-template{padding:12px;background:var(--wa-primary-soft);border-radius:var(--wa-radius);border:.5px solid var(--wa-primary)}.w-sso-check{padding:8px 12px;background:var(--wa-surface);border-radius:var(--wa-radius);border:.5px solid var(--wa-border)}.w-sso-check-mark{min-width:12px}.w-sso-tile{display:flex;flex-direction:column;align-items:center;gap:8px;padding:14px 10px;border:.5px solid var(--wa-border);border-radius:var(--wa-radius);background:var(--wa-surface);cursor:pointer;transition:border-color .14s ease,background .14s ease}.w-sso-tile:hover{border-color:var(--wa-border-strong);background:var(--wa-surface-subtle)}.w-sso-logo{object-fit:contain;background:var(--wa-surface);padding:4px}.w-sso-logo--ph{background:var(--wa-surface)}.w-token-chip{background:var(--wa-surface-subtle);padding:2px 6px;border-radius:4px;color:var(--wa-text)}.w-disclosure{cursor:pointer;font:400 12.5px/1 var(--wa-font-sans)}.w-disclosure-caret{font-size:9px}.w-break-all{word-break:break-all}.w-col-full{grid-column:1 / -1}.dark .w-card{box-shadow:0 0 0 .5px var(--wa-border),0 2px 4px #0006,0 28px 60px -20px #000000b3}.dark .w-menu,.dark .w-pop,.dark .w-toast,.dark .w-dialog,.dark .w-combo-menu,.dark .w-country-pop{box-shadow:0 1px 2px #00000080,0 18px 44px -14px #000000b3}.dark .w-btn--secondary,.dark .w-social{box-shadow:inset 0 1px #ffffff0d,0 1px 1.5px #1414160a}.w-flex{display:flex}.w-inline{display:inline-flex}.w-items-center{align-items:center}.w-items-start{align-items:flex-start}.w-items-end{align-items:flex-end}.w-justify-start{justify-content:flex-start}.w-justify-center{justify-content:center}.w-justify-end{justify-content:flex-end}.w-justify-between{justify-content:space-between}',dm=om`
100
+ ${lm}
101
+ ${cm}
102
+ `,um={display:"contents"};function mm(e){const a={};if(!e)return a;const s=(r,i)=>{if(i)for(const l in i){const m=i[l];typeof m=="string"&&m.trim()!==""&&(a[`--wa-ov-${r}-${l}`]=m)}};return s("light",e.light),s("dark",e.dark),a}function as(){var s,r;const e=o.useContext(gr),a=(r=(s=e==null?void 0:e.deployment)==null?void 0:s.ui_settings)==null?void 0:r.theme_tokens;return o.useMemo(()=>mm(a),[a])}const Mi=o.createContext(!1),pm=o.memo(function(){return t.jsx(dm,{})});function Re({children:e,className:a,style:s,...r}){const i=o.useContext(Mi),l=as(),[m,c]=o.useState(!1);if(o.useEffect(()=>c(!0),[]),!m)return null;const d=t.jsx("div",{...r,className:a?`wacht-root ${a}`:"wacht-root",style:{...um,...l,...s},children:e});return i?d:t.jsxs(Mi.Provider,{value:!0,children:[t.jsx(pm,{}),d]})}function ba({length:e=6,onComplete:a,onResend:s,error:r,isSubmitting:i=!1}){const[l,m]=o.useState(new Array(e).fill("")),[c,d]=o.useState(60),[p,u]=o.useState(!1),f=o.useRef([]),h=o.useCallback(()=>{const j=setInterval(()=>{d(v=>v<=1?(u(!0),clearInterval(j),0):v-1)},1e3);return j},[]);o.useEffect(()=>{const j=h();return()=>clearInterval(j)},[h]);const g=async()=>{var j;!p||i||!s||(await s(),u(!1),d(60),m(new Array(e).fill("")),(j=f.current[0])==null||j.focus(),h())},x=(j,v)=>{var C;if(i)return;const k=j.value,N=[...l];N[v]=k.replace(/[^0-9]/g,""),m(N);const _=N.join("");_.length===e&&a(_),k&&v<e-1&&((C=f.current[v+1])==null||C.focus())},w=(j,v)=>{var k;i||j.key==="Backspace"&&!l[v]&&v>0&&((k=f.current[v-1])==null||k.focus())},b=(j,v)=>{var C,y;if(i)return;j.preventDefault();const k=j.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!k.length)return;const N=[...l];for(let E=0;E<k.length&&v+E<e;E++)N[v+E]=k[E];if(v===0&&k.length===e)for(let E=0;E<e;E++)N[E]=k[E];m(N);const _=N.join("");if(_.length===e)a(_),(C=f.current[e-1])==null||C.focus();else{const E=N.findIndex((M,F)=>F>=v&&!M);E!==-1&&((y=f.current[E])==null||y.focus())}};return t.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{className:"w-otp","data-error":r?"":void 0,children:l.map((j,v)=>t.jsx("input",{className:"w-otp-cell",type:"text",inputMode:"numeric",maxLength:1,value:j,"data-filled":j?"":void 0,onChange:k=>x(k.target,v),onKeyDown:k=>w(k,v),onPaste:k=>b(k,v),ref:k=>{f.current[v]=k},disabled:i,autoFocus:v===0},v))}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[r&&t.jsx("span",{className:"w-input-err",children:r}),s&&(p?t.jsx("button",{type:"button",className:"w-link",style:{background:"none",border:0,cursor:"pointer",fontSize:12.5},onClick:g,disabled:i,children:"Didn't receive a code? Resend"}):t.jsxs("span",{className:"w-secsub",children:["Resend code in ",c,"s"]}))]})]})}const kc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...e,children:[t.jsx("title",{id:"githubIconTitle",children:"GitHub"}),t.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),Cc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),t.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),t.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),t.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),Nc=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...e,children:t.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),hm=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Sc=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:t.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),Ec=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),fm=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Ac=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),t.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),wm={google_oauth:{label:"Continue with Google",icon:t.jsx(Cc,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(kc,{})},x_oauth:{label:"Continue with X",icon:t.jsx(Nc,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(hm,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(Sc,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(Ec,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(fm,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(Ac,{})}},Er=({connections:e,callback:a})=>{const s=e.map(r=>({connection:r,config:wm[r.provider]})).filter(r=>r.config);if(!s.length)return null;if(s.length>3){const r=Math.min(s.length,4);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gap:8},children:s.map(({connection:i,config:l})=>t.jsx("button",{type:"button",className:"w-social",style:{justifyContent:"center",padding:0},onClick:()=>a(i),title:l.label,"aria-label":l.label,children:l.icon},i.provider))})}return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:s.map(({connection:r,config:i})=>t.jsxs("button",{type:"button",className:"w-social",onClick:()=>a(r),children:[i.icon,t.jsx("span",{className:"w-social-label",children:i.label})]},r.provider))})},Et=({to:e,replace:a,children:s,...r})=>{const{navigate:i}=kt(),l=o.useCallback(m=>{m.preventDefault(),i(e,{replace:a})},[e,a,i]);return t.jsx("a",{href:e||void 0,onClick:l,...r,children:s})},Kt=o.forwardRef(({onFocus:e,readOnly:a,...s},r)=>{const[i,l]=o.useState(!1);return t.jsx("input",{ref:r,...s,readOnly:a||!i,onFocus:m=>{i||l(!0),e==null||e(m)}})});Kt.displayName="NoPrefillInput";const qs=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],js=({value:e,onChange:a,error:s,countryCode:r,setCountryCode:i})=>{const[l,m]=o.useState(!1),[c,d]=o.useState(qs.find(x=>x.code===r)||qs[0]),p=o.useRef(null),[u,f]=o.useState(""),h=o.useRef(null);o.useEffect(()=>{function x(w){p.current&&!p.current.contains(w.target)&&m(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const g=qs.filter(x=>x.name.toLowerCase().includes(u.toLowerCase())||x.dialCode.includes(u));return o.useEffect(()=>{i(c.dialCode)},[c,i]),t.jsxs("div",{className:"w-phone",children:[t.jsxs("div",{style:{position:"relative"},ref:p,children:[t.jsxs("button",{type:"button",className:"w-phone-cc",style:{height:"100%"},onClick:()=>m(x=>!x),children:[t.jsx("span",{children:c.flag}),t.jsx("span",{children:c.dialCode}),t.jsx(Wt,{weight:"bold"})]}),l&&t.jsxs("div",{className:"w-country-pop",children:[t.jsxs("div",{className:"w-country-search",children:[t.jsx(Al,{}),t.jsx("input",{type:"text",placeholder:"Search country…",value:u,onChange:x=>f(x.target.value),onClick:x=>x.stopPropagation()})]}),t.jsx("div",{className:"w-country-list",children:g.map(x=>t.jsxs("button",{type:"button",className:"w-country-opt",onClick:w=>{var b;w.stopPropagation(),w.preventDefault(),d(x),m(!1),(b=h.current)==null||b.focus()},children:[t.jsx("span",{children:x.flag}),t.jsx("span",{children:x.name}),t.jsx("span",{className:"dial",children:x.dialCode})]},x.code))})]})]}),t.jsx("input",{type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:h,value:e,onChange:a,placeholder:"Phone number","aria-invalid":!!s,pattern:"^\\d{7,15}$"})]})};function Ar({placement:e="center"}){var m;const{deployment:a}=je(),[s,r]=o.useState(!1),i=(m=a==null?void 0:a.ui_settings)==null?void 0:m.logo_image_url;if(!i||s)return null;const l=e==="left"?"flex-start":e==="right"?"flex-end":"center";return t.jsx("div",{style:{display:"flex",justifyContent:l,width:"100%"},children:t.jsx("img",{src:i,alt:"Logo",onError:()=>r(!0),style:{maxWidth:40,maxHeight:40,width:"auto",height:"auto",objectFit:"contain"}})})}function et({children:e,footer:a}){return t.jsxs("div",{className:"w-card w-auth-card",children:[t.jsx("div",{className:"w-create-body",children:e}),a&&t.jsx("div",{className:"w-create-foot",children:a})]})}function nt({title:e,sub:a,children:s}){return t.jsxs("div",{className:"w-auth-head",children:[t.jsx(Ar,{}),t.jsxs("div",{className:"w-auth-head-text",children:[t.jsx("h1",{className:"w-auth-title",children:e}),a&&t.jsx("p",{className:"w-auth-sub",children:a})]}),s]})}function vt({size:e=16,onAccent:a}){return t.jsx("span",{className:a?"w-spin w-spin--on-accent":"w-spin",style:{width:e,height:e}})}function _s(){return t.jsx(Re,{children:t.jsx("div",{className:"w-card w-auth-card",children:t.jsx("div",{className:"w-create-body",children:t.jsxs("div",{className:"w-auth-skel","aria-hidden":"true",children:[t.jsxs("div",{className:"w-auth-skel-head",children:[t.jsx("span",{className:"w-skel w-skel-avatar"}),t.jsx("span",{className:"w-skel w-skel-title"}),t.jsx("span",{className:"w-skel w-skel-sub"})]}),t.jsxs("div",{className:"w-auth-skel-fields",children:[t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsx("span",{className:"w-skel w-skel-btn"})]})]})})})})}function gm(e){const a=e.indexOf(":");return a>=0?e.slice(0,a):e}function xm(e){const a=e.trim();if(!a)return null;try{return new URL(a.includes("://")?a:`https://${a}`).hostname.toLowerCase()||null}catch{return null}}function vm(e){try{return new URL(e)}catch{if(typeof window>"u")return null;try{return new URL(e,window.location.origin)}catch{return null}}}function bm(e,a){return!e||!a?!1:e===a?!0:e.endsWith(`.${a}`)}function ym(e,a){if(!a)return!1;const s=vm(a);if(!s||s.protocol!=="https:"&&s.protocol!=="http:")return!1;if((e==null?void 0:e.mode)==="staging")return!0;if(s.protocol!=="https:"||!(e!=null&&e.frontend_host))return!1;const r=xm(gm(e.frontend_host));return r?bm(s.hostname.toLowerCase(),r):!1}function gt(e,a){return a&&ym(e,a)?a:null}function jm(){var B,Q,ue,we,ne,ae,re,Me,q,tt,Ie,De,Ee,ce,W,G;const{loading:e,signUp:a,signupAttempt:s,discardSignupAttempt:r}=go(),{signIn:i}=cs("oauth"),{deployment:l}=je(),{navigate:m}=kt(),{session:c,refetch:d,loading:p}=it(),[u,f]=o.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[h,g]=o.useState({}),[x,w]=o.useState(!1),[b,j]=o.useState(void 0),[v,k]=o.useState(null),[N,_]=o.useState(null),[C,y]=o.useState(!1),E=((B=l==null?void 0:l.restrictions)==null?void 0:B.sign_up_mode)==="restricted",M=((Q=l==null?void 0:l.restrictions)==null?void 0:Q.sign_up_mode)==="waitlist",F=((we=(ue=l==null?void 0:l.auth_settings)==null?void 0:ue.multi_session_support)==null?void 0:we.enabled)??!1;o.useEffect(()=>{var K;if(!p&&(c!=null&&c.active_signin)&&!F&&!C){y(!0);let V=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));V||(V=((K=l==null?void 0:l.ui_settings)==null?void 0:K.after_signin_redirect_url)||null),!V&&(l!=null&&l.frontend_host)&&(V=`https://${l.frontend_host}`),V&&m(V)}},[c,p,F,l,m,C]),o.useEffect(()=>{var de;if(!l)return;const V=new URLSearchParams(window.location.search).get("invite_token");if(M&&!V){y(!0);const z=((de=l.ui_settings)==null?void 0:de.waitlist_page_url)||`https://${l.frontend_host}/waitlist`;m(z);return}V&&!v&&a&&(_(V),a.validateDeploymentInvitation(V).then(z=>{k(z),z.valid&&f(le=>({...le,first_name:z.first_name||le.first_name,last_name:z.last_name||le.last_name,email:z.email||le.email}))}).catch(()=>{g(z=>({...z,submit:"Failed to validate invitation."}))}))},[l,M,m,v,a]);const[A,T]=o.useState(!1),[P,S]=o.useState(""),$=K=>{let{name:V,value:de}=K.target;V==="phone_number"?de=de.replace(/[^0-9-]/g,""):V==="email"&&(de=de.toLowerCase()),f(z=>({...z,[V]:de})),g(z=>({...z,[V]:""}))},H=()=>{f({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),g({}),T(!1),S(""),r()},R=async K=>{if(K.preventDefault(),e||x)return;const V={},de=/^[a-zA-Z]{3,30}$/,z=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,le=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Je=/^\d{7,15}$/,ot=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(L!=null&&L.first_name.enabled&&(L!=null&&L.first_name.required&&!u.first_name?V.first_name="First name is required":u.first_name&&!de.test(u.first_name)&&(V.first_name="Invalid name")),L!=null&&L.last_name.enabled&&(L!=null&&L.last_name.required&&!u.last_name?V.last_name="Last name is required":u.last_name&&!de.test(u.last_name)&&(V.last_name="Invalid last name")),L!=null&&L.username.enabled&&(L!=null&&L.username.required&&!u.username?V.username="Username is required":u.username&&!z.test(u.username)&&(V.username="Username must be 3-20 characters")),L!=null&&L.email_address.enabled&&(L!=null&&L.email_address.required&&!u.email?V.email="Email address is required":u.email&&!le.test(u.email)&&(V.email="Invalid email address")),L!=null&&L.phone_number.enabled&&(L!=null&&L.phone_number.required&&!u.phone_number?V.phone_number="Phone number is required":u.phone_number&&!Je.test(u.phone_number)&&(V.phone_number="Phone number must contain 7-15 digits")),L!=null&&L.password.enabled&&(u.password?ot.test(u.password)||(V.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):V.password="Password is required"),g(V),!(Object.keys(V).length>0)){w(!0);try{const ge={...u};u.phone_number&&b&&(ge.phone_country_code=b),N&&(ge.invite_token=N),await a.create(ge)}catch(ge){g({submit:ge.message})}finally{w(!1)}}},O=async K=>{if(!(e||x)){w(!0);try{const V=new URLSearchParams(window.location.search),de=gt(l,V.get("redirect_uri"))||void 0,{data:z}=await i.create({provider:K.provider,redirectUri:de});z&&typeof z=="object"&&"oauth_url"in z&&(window.location.href=z.oauth_url)}catch(V){g({submit:V.message})}finally{w(!1)}}},Z=(l==null?void 0:l.social_connections.filter(K=>K.enabled))||[],L=l==null?void 0:l.auth_settings,U=!!((ne=L==null?void 0:L.first_name)!=null&&ne.enabled&&((ae=L==null?void 0:L.last_name)!=null&&ae.enabled)),D=async K=>{var de;if(K.preventDefault(),e||x)return;w(!0);const V={};if(!P){V.otp="OTP code is required",g(V),w(!1);return}g(V);try{const z=await a.completeVerification(P);"data"in z&&((de=z.data)!=null&&de.active_signin)&&await d()}catch{g(z=>({...z,submit:"Verification failed. Please try again."}))}finally{w(!1)}};if(o.useEffect(()=>{var K;if(s){if(s.completed){let V=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(V||(V=((K=l==null?void 0:l.ui_settings)==null?void 0:K.after_signup_redirect_url)||null),!V&&(l!=null&&l.frontend_host)&&(V=`https://${l.frontend_host}`),V){let de;try{de=new URL(V)}catch{de=new URL(V,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&de.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(de.toString())}return}if(!A){switch(s.current_step){case"verify_email":a.prepareVerification({strategy:"email_otp"});break;case"verify_phone":a.prepareVerification({strategy:"phone_otp"});break}T(!0)}}},[s,a,A,l,c,m]),p||C)return t.jsx(_s,{});const Y=((re=l==null?void 0:l.ui_settings)==null?void 0:re.app_name)||"App";if(E)return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx(Et,{className:"w-link",to:(Me=l==null?void 0:l.ui_settings)!=null&&Me.sign_in_page_url?`${l.ui_settings.sign_in_page_url}?help=true`:"#",children:"Get help"})]}),children:[t.jsx(nt,{title:"Sign-up restricted",sub:"This app isn't open for public sign-up right now."}),t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"New account registration is currently restricted. Please check back later or contact your administrator for an invitation."})})]})});if(A){const K=(s==null?void 0:s.current_step)==="verify_phone";return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((q=l==null?void 0:l.ui_settings)==null?void 0:q.support_page_url)||"#",children:"Get help"})]}),children:[t.jsx(nt,{title:K?"Check your phone":"Enter the code",sub:K?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",children:t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:H,children:[t.jsx(Pl,{weight:"bold"}),K?`+${u.phone_number}`:u.email]})}),t.jsxs("form",{onSubmit:D,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ba,{onComplete:async V=>{S(V)},onResend:async()=>{const V=K?"phone_otp":"email_otp";await a.prepareVerification({strategy:V})},error:h.otp,isSubmitting:x}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!P,children:x&&P?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${Y}`})]})]})})}return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Already have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((tt=l==null?void 0:l.ui_settings)==null?void 0:tt.sign_in_page_url)??""}${window.location.search}`,children:"Sign in"})]}),children:[t.jsx(nt,{title:"Create your account",sub:v!=null&&v.valid?"You've been invited — complete your registration below.":"Get started in a few seconds."}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Er,{connections:Z,callback:O}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})})]}),t.jsxs("form",{onSubmit:R,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[(((Ie=L==null?void 0:L.first_name)==null?void 0:Ie.enabled)||((De=L==null?void 0:L.last_name)==null?void 0:De.enabled))&&t.jsxs("div",{className:U?"w-grid-2":"",children:[((Ee=L==null?void 0:L.first_name)==null?void 0:Ee.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["First name",((ce=L==null?void 0:L.first_name)==null?void 0:ce.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"text",id:"first_name",name:"first_name",autoComplete:"given-name",required:!0,minLength:3,maxLength:30,value:u.first_name,onChange:$,placeholder:"Jane","aria-invalid":!!h.first_name,pattern:"^[a-zA-Z]{3,30}$"}),h.first_name&&t.jsx("span",{className:"w-input-err",children:h.first_name})]}),((W=L==null?void 0:L.last_name)==null?void 0:W.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Last name",((G=L==null?void 0:L.last_name)==null?void 0:G.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"text",id:"last_name",name:"last_name",autoComplete:"family-name",required:!0,minLength:3,maxLength:30,value:u.last_name,onChange:$,placeholder:"Doe","aria-invalid":!!h.last_name,pattern:"^[a-zA-Z]{3,30}$"}),h.last_name&&t.jsx("span",{className:"w-input-err",children:h.last_name})]})]}),(L==null?void 0:L.username.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Username",L.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"text",id:"username",name:"username",autoComplete:"username",minLength:3,maxLength:20,value:u.username,onChange:$,placeholder:"yourname","aria-invalid":!!h.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),h.username&&t.jsx("span",{className:"w-input-err",children:h.username})]}),(L==null?void 0:L.email_address.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Email address",L.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",maxLength:320,value:u.email,onChange:$,placeholder:"you@company.com","aria-invalid":!!h.email,required:!0,readOnly:(v==null?void 0:v.valid)&&!!(v!=null&&v.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),h.email&&t.jsx("span",{className:"w-input-err",children:h.email})]}),(L==null?void 0:L.phone_number.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Phone number",L.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(js,{value:u.phone_number,onChange:$,error:h.phone_number,countryCode:b,setCountryCode:j}),h.phone_number&&t.jsx("span",{className:"w-input-err",children:h.phone_number})]}),(L==null?void 0:L.password.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Password",L.password.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(Kt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"new-password",value:u.password,onChange:$,placeholder:"Create a password","aria-invalid":!!h.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"}),h.password&&t.jsx("span",{className:"w-input-err",children:h.password})]}),h.submit&&t.jsx("span",{className:"w-input-err",children:h.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e,children:x?t.jsx(vt,{size:15,onAccent:!0}):"Continue"}),(()=>{var de,z;const K=(de=l==null?void 0:l.ui_settings)==null?void 0:de.tos_page_url,V=(z=l==null?void 0:l.ui_settings)==null?void 0:z.privacy_policy_url;return!K&&!V?null:t.jsxs("p",{className:"w-fineprint",children:["By continuing you agree to our"," ",K&&t.jsx(Et,{className:"w-link w-link--muted",to:K,children:"Terms of Service"}),K&&V&&" and ",V&&t.jsx(Et,{className:"w-link w-link--muted",to:V,children:"Privacy Policy"}),"."]})})()]})]})})}function Mc({icon:e,label:a,description:s,onClick:r,disabled:i,type:l="button"}){return t.jsxs("button",{type:l,className:"w-method",onClick:r,disabled:i,"data-disabled":i?"":void 0,children:[t.jsx("span",{className:"w-method-ic",children:e}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:a}),s&&t.jsx("span",{className:"w-method-desc",children:s})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Jt,{})})]})}const Rc=o.createContext(void 0);function Lc(){const e=o.useContext(Rc);if(!e)throw new Error("useSignIn must be used within a SignInProvider");return e}function _m({children:e}){var j;const{deployment:a}=je(),[s,r]=o.useState((a==null?void 0:a.auth_settings.first_factor)||"email_password"),i=o.useRef(!!(a!=null&&a.auth_settings.first_factor)),[l,m]=o.useState(""),[c,d]=o.useState(!1),[p,u]=o.useState(!1),[f,h]=o.useState(!1),[g,x]=o.useState("identifier"),w=(a==null?void 0:a.social_connections.filter(v=>v.enabled))||[],b=a==null?void 0:a.auth_settings;return o.useEffect(()=>{var k;const v=(k=a==null?void 0:a.auth_settings)==null?void 0:k.first_factor;!i.current&&v&&(r(v),i.current=!0)},[(j=a==null?void 0:a.auth_settings)==null?void 0:j.first_factor]),t.jsx(Rc.Provider,{value:{email:l,showOtherOptions:c,showForgotPassword:p,otpSent:f,setFirstFactor:r,setEmail:m,setShowOtherOptions:d,setShowForgotPassword:u,setOtpSent:h,enabledSocialsProviders:w,authSettings:b,firstFactor:s,signInStep:g,setSignInStep:x},children:e})}const km=[{key:"email_magic_link",icon:t.jsx(Vu,{}),label:"Magic link",description:"We'll email you a one-click sign-in link"},{key:"email_password",icon:t.jsx(Iu,{}),label:"Email and password",description:"Sign in with your email and password"},{key:"email_otp",icon:t.jsx(jl,{}),label:"Email one-time code",description:"We'll send a verification code to your email"},{key:"phone_otp",icon:t.jsx(Ou,{}),label:"Phone number",description:"We'll send a verification code via SMS"},{key:"username_password",icon:t.jsx(fs,{}),label:"Username and password",description:"Sign in with your username and password"}];function Pc(){const{deployment:e}=je(),{signIn:a}=cs("oauth"),{setFirstFactor:s,firstFactor:r,setShowOtherOptions:i,setSignInStep:l}=Lc(),[m,c]=o.useState(!1),d=e==null?void 0:e.auth_settings,p=(e==null?void 0:e.social_connections.filter(x=>x.enabled))||[],u=async x=>{if(!m){c(!0);try{const{data:w}=await a.create({provider:x.provider});w&&typeof w=="object"&&"oauth_url"in w&&(window.location.href=w.oauth_url)}catch{}finally{c(!1)}}},f=km.filter(x=>{if(x.key===r)return!1;const w=d==null?void 0:d.auth_factors_enabled;return w?w[x.key]:!1}),h=p.length>0,g=f.length>0;return t.jsxs(t.Fragment,{children:[h&&t.jsx(Er,{connections:p,callback:u}),h&&g&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"or"})}),g&&t.jsx("div",{className:"w-method-stack",children:f.map(x=>t.jsx(Mc,{icon:x.icon,label:x.label,description:x.description,onClick:()=>{s(x.key),l("identifier"),i(!1)}},x.key))})]})}function Cm({onBack:e}){var F;const{deployment:a}=je(),{navigate:s}=kt(),[r,i]=o.useState("start"),[l,m]=o.useState(""),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(""),[g,x]=o.useState(""),{forgotPassword:w,verifyOtp:b,resetPassword:j}=Lo(),[v,k]=o.useState(!1),[N,_]=o.useState(null),C=async A=>{if(A.preventDefault(),!!l){k(!0),_(null);try{await w(l),i("otp")}catch(T){_(T)}finally{k(!1)}}},y=async A=>{if(A.preventDefault(),c.length===6){k(!0),_(null);try{const T=await b(l,c);T.data&&(u(T.data.token),i("reset"))}catch(T){_(T)}finally{k(!1)}}},E=async A=>{var T,P;if(A.preventDefault(),f===g&&!(f.length<8)){k(!0),_(null);try{const S=await j(p,f);if(S.data){const $=S.data,H=$.signin_attempts&&$.signin_attempts.length>0?$.signin_attempts[$.signin_attempts.length-1]:null;if(H&&!H.completed){const R=(T=a==null?void 0:a.ui_settings)==null?void 0:T.sign_in_page_url;if(R){const O=new URL(R,window.location.origin);O.searchParams.set("signin_attempt_id",H.id),s(O.toString())}else e()}else{const R=((P=a==null?void 0:a.ui_settings)==null?void 0:P.after_signin_redirect_url)||"/";s(R)}}}catch(S){_(S)}finally{k(!1)}}},M=t.jsx("span",{className:"w-auth-foot",children:t.jsx("span",{className:"w-link",style:{cursor:"pointer"},onClick:e,children:"Back to sign in"})});return t.jsxs(Re,{children:[r==="start"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Forgot your password?",sub:"Reset it, or sign in another way."}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>i("email"),disabled:v,children:"Reset your password"}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsx(Pc,{}),t.jsxs("p",{className:"w-secsub",style:{textAlign:"center",marginTop:16},children:["Unable to reset password?"," ",t.jsx("a",{className:"w-link",href:((F=a==null?void 0:a.ui_settings)==null?void 0:F.support_page_url)||"#",children:"Get help"})]})]}),r==="email"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Forgot password",sub:"Enter your email and we'll send you a code to reset your password."}),t.jsxs("form",{onSubmit:C,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx("input",{className:"w-input",type:"email",id:"email",value:l,onChange:A=>m(A.target.value),placeholder:"you@company.com",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Send code"})]})]}),r==="otp"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Enter verification code",sub:`We sent a 6-digit code to ${l}.`}),t.jsxs("form",{onSubmit:y,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ba,{onComplete:A=>d(A),isSubmitting:v,error:N==null?void 0:N.message,onResend:async()=>{await w(l)}}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v||c.length!==6,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Verify"})]})]}),r==="reset"&&t.jsxs(et,{footer:M,children:[t.jsx(nt,{title:"Reset password",sub:"Create a new password for your account."}),t.jsxs("form",{onSubmit:E,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"New password"}),t.jsx("input",{className:"w-input",type:"password",id:"password",value:f,onChange:A=>h(A.target.value),placeholder:"Enter new password",required:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Confirm new password"}),t.jsx("input",{className:"w-input",type:"password",id:"confirmPassword",value:g,onChange:A=>x(A.target.value),placeholder:"Confirm new password",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Reset password"})]})]})]})}function Nm({onBack:e}){var r;const{deployment:a}=je(),s=(r=a==null?void 0:a.ui_settings)==null?void 0:r.app_name;return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to sign in"})}),children:[t.jsx(nt,{title:"All sign-in methods",sub:`Choose another way to sign in to ${s||"your account"}`}),t.jsx(Pc,{})]})})}function $c({methods:e,onSelectMethod:a,onBack:s}){return t.jsx(Re,{children:t.jsxs(et,{footer:s?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:s,children:"Back to login"})}):void 0,children:[t.jsx(nt,{title:"Two-factor authentication",sub:"Choose how you'd like to verify your identity"}),t.jsx("div",{className:"w-method-stack",children:e.map(r=>t.jsx(Mc,{icon:r.icon,label:r.name,description:r.phoneNumber?`${r.description} ${r.phoneNumber}`:r.description,onClick:()=>a(r.id),disabled:!r.available},r.id))})]})})}function Oc({onVerify:e,onBack:a,loading:s}){const[r,i]=o.useState(""),[l,m]=o.useState(""),c=p=>{if(p.preventDefault(),r.length!==4){m("Please enter the last 4 digits of your phone number");return}e(r)},d=p=>{const u=p.target.value.replace(/\D/g,"").slice(0,4);i(u),m("")};return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Choose a different method"})}),children:[t.jsx(nt,{title:"Verify phone",sub:"Enter the last 4 digits of your phone number."}),t.jsxs("form",{onSubmit:c,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"lastDigits",children:"Last 4 digits"}),t.jsx("input",{className:`w-input${l?" w-input--invalid":""}`,type:"text",id:"lastDigits",name:"lastDigits",value:r,onChange:d,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!l,autoFocus:!0}),l&&t.jsx("span",{className:"w-input-err",children:l})]}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:s||r.length!==4,children:s?t.jsx(vt,{onAccent:!0}):"Send code"})]})]})})}const Sm=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Em=()=>t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),t.jsx("path",{d:"M12 18h.01"})]}),Am=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})});function Zc({onBack:e,attempt:a,completeVerification:s,prepareVerification:r}){const{deployment:i}=je(),[l,m]=o.useState(""),[c,d]=o.useState({}),[p,u]=o.useState(!1),[f,h]=o.useState(null),[g,x]=o.useState(!0),[w,b]=o.useState(!1),[j,v]=o.useState(""),[k,N]=o.useState(!1),{navigate:_}=kt(),C=(a==null?void 0:a.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(Sm,{}),available:C.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(Em,{}),available:C.includes("phone_otp"),phoneNumber:j},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(Am,{}),available:C.includes("backup_code")}].filter(P=>P.available),E=async P=>{h(P),x(!1),P==="phone_otp"&&b(!0)},M=async P=>{var S,$;if(a){u(!0);try{const H=await r({strategy:"phone_otp",lastDigits:P});H&&"data"in H&&((S=H.data)!=null&&S.otp_sent)?(($=H.data)!=null&&$.masked_phone&&v(H.data.masked_phone),b(!1)):d({phone:"Phone number verification failed"})}catch(H){d({phone:H.message})}finally{u(!1)}}},F=async(P,S)=>{if(P.preventDefault(),p)return;const $=S||l,H={};if($?f==="authenticator"&&$.length!==6?H.code="Authentication code must be 6 digits":f==="phone_otp"&&$.length!==6&&(H.code="SMS code must be 6 digits"):H.code="Verification code is required",d(H),!(Object.keys(H).length>0)){u(!0);try{await s($)}catch(R){d({submit:R.message})}finally{u(!1)}}},A=P=>{let S=P.target.value;f!=="backup_code"&&(S=S.replace(/\D/g,"").slice(0,6)),m(S),d($=>({...$,code:""}))};if(o.useEffect(()=>{var P;if(a.completed){N(!0);let S=gt(i,new URLSearchParams(window.location.search).get("redirect_uri"));if(S||(S=((P=i==null?void 0:i.ui_settings)==null?void 0:P.after_signin_redirect_url)||null),!S&&(i!=null&&i.frontend_host)&&(S=`https://${i.frontend_host}`),S){let $;try{$=new URL(S)}catch{$=new URL(S,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&$.searchParams.set("__dev_session__",xt(i.backend_host)||""),_($.toString())}return}},[a,i]),k)return t.jsx(_s,{});if(g)return y.length===0?t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(nt,{title:"Set up two-factor authentication",sub:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."}),e&&t.jsx("div",{style:{textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to login"})})]})}):t.jsx($c,{methods:y,onSelectMethod:E,onBack:e});if(w&&f==="phone_otp")return t.jsx(Oc,{onVerify:M,onBack:()=>{b(!1),x(!0),h(null)},loading:p});const T=f==="authenticator"?"Enter the 6-digit code from your authenticator app":f==="phone_otp"?`Enter the 6-digit code sent to your phone ${j}`:"Enter one of your backup codes";return t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(nt,{title:"Two-factor authentication",sub:T}),t.jsxs("form",{onSubmit:F,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[f==="backup_code"?t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"code",children:"Backup code"}),t.jsx("input",{className:`w-input${c.code?" w-input--invalid":""}`,type:"text",id:"code",name:"code",value:l,onChange:A,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!c.code,autoFocus:!0}),c.code&&t.jsx("span",{className:"w-input-err",children:c.code})]}):t.jsx(ba,{onComplete:async P=>{if(m(P),f!=="backup_code"){const S=new Event("submit",{bubbles:!0,cancelable:!0});await F(S,P)}},onResend:f==="phone_otp"?async()=>{try{await r({strategy:"phone_otp",lastDigits:j.slice(-4)})}catch(P){d({submit:P.message})}}:void 0,error:c.code,isSubmitting:p}),c.submit&&t.jsx("span",{className:"w-input-err",children:c.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:p||!l,children:p?t.jsx(vt,{onAccent:!0}):"Verify"})]}),t.jsxs("div",{style:{marginTop:18,textAlign:"center",display:"flex",flexDirection:"column",gap:8},children:[t.jsx("button",{type:"button",className:"w-link",onClick:()=>{x(!0),h(null),m(""),d({})},children:"Try another method"}),e&&t.jsx("button",{type:"button",className:"w-link w-link--muted",onClick:e,children:"Back to login"})]})]})})}function Hc({attempt:e,onBack:a,completeProfile:s,completeVerification:r,prepareVerification:i}){var Z,L,U,D,Y,B,Q,ue,we;const{deployment:l}=je(),{navigate:m}=kt(),[c,d]=o.useState({}),[p,u]=o.useState({}),[f,h]=o.useState("US"),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(null),[k,N]=o.useState(!1),_=j,C=w,y=()=>{var ae;N(!0);let ne=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(ne||(ne=((ae=l==null?void 0:l.ui_settings)==null?void 0:ae.after_signin_redirect_url)||null),!ne&&(l!=null&&l.frontend_host)&&(ne=`https://${l.frontend_host}`),ne){let re;try{re=new URL(ne)}catch{re=new URL(ne,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&re.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(re.toString())}},E=async ne=>{b(!0),v(null);try{await s(ne)&&y()}catch(ae){const re=ae;throw v(re),re}finally{b(!1)}},M=async ne=>{b(!0),v(null);try{return await r(ne)&&y(),!0}catch(ae){return v(ae),!1}finally{b(!1)}};if(k||!e)return t.jsx(_s,{});const F=e.missing_fields||[],A=l==null?void 0:l.auth_settings,T=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||g,P=ne=>{const{name:ae,value:re}=ne.target;d(Me=>({...Me,[ae]:re})),p[ae]&&u(Me=>({...Me,[ae]:""}))},S=()=>{const ne={};return F.forEach(ae=>{var q,tt,Ie,De,Ee;const re=c[ae];let Me=!1;switch(ae){case"first_name":Me=((q=A==null?void 0:A.first_name)==null?void 0:q.enabled)||!1;break;case"last_name":Me=((tt=A==null?void 0:A.last_name)==null?void 0:tt.enabled)||!1;break;case"username":Me=((Ie=A==null?void 0:A.username)==null?void 0:Ie.enabled)||!1;break;case"phone_number":Me=((De=A==null?void 0:A.phone_number)==null?void 0:De.enabled)||!1;break;case"email_address":Me=((Ee=A==null?void 0:A.email_address)==null?void 0:Ee.enabled)||!1;break;default:Me=!0}if(Me&&(!re||re.trim()==="")){const ce=ae.replace("_"," ").replace(/\b\w/g,W=>W.toUpperCase());ne[ae]=`${ce} is required`}}),c.username&&F.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(c.username)||(ne.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),c.phone_number&&F.includes("phone_number")&&(/^\d{7,15}$/.test(c.phone_number)||(ne.phone_number="Phone number must contain 7-15 digits")),c.email&&F.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(c.email)||(ne.email_address="Please enter a valid email address")),u(ne),Object.keys(ne).length===0},$=async ne=>{if(ne.preventDefault(),!S())return;const ae={...c};c.phone_number&&f&&(ae.phone_country_code=f),await E(ae)},H=ne=>{const ae=ne.target.value;d(re=>({...re,phone_number:ae})),p.phone_number&&u(re=>({...re,phone_number:""}))},R=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(l==null?void 0:l.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]});if(T){const ne=e.current_step==="verify_phone_otp"?"Verify your phone number":"Verify your email",ae=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",re=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx(Re,{children:t.jsxs(et,{footer:R,children:[t.jsx(nt,{title:ne,sub:ae}),t.jsxs("form",{onSubmit:Me=>Me.preventDefault(),noValidate:!0,style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsx(ba,{onComplete:M,onResend:async()=>{await i({strategy:re})},error:_==null?void 0:_.message,isSubmitting:C}),_&&t.jsx("span",{className:"w-input-err",children:_.message})]}),t.jsx("div",{style:{marginTop:16,textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:()=>x(!1),children:"Back to profile completion"})})]})})}const O=!!((Z=A==null?void 0:A.first_name)!=null&&Z.enabled&&((L=A==null?void 0:A.last_name)!=null&&L.enabled)&&F.includes("first_name")&&F.includes("last_name"));return t.jsx(Re,{children:t.jsxs(et,{footer:a?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Back to login"})}):R,children:[t.jsx(nt,{title:"Complete your profile",sub:"Please provide the following information to continue"}),t.jsxs("form",{onSubmit:$,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(F.includes("first_name")||F.includes("last_name"))&&(((U=A==null?void 0:A.first_name)==null?void 0:U.enabled)||((D=A==null?void 0:A.last_name)==null?void 0:D.enabled))&&t.jsxs("div",{className:O?"w-grid-2":"",children:[F.includes("first_name")&&((Y=A==null?void 0:A.first_name)==null?void 0:Y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",A.first_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.first_name?" w-input--invalid":""}`,type:"text",id:"first_name",name:"first_name",value:c.first_name||"",onChange:P,placeholder:"Enter your first name",disabled:C,autoComplete:"given-name"}),p.first_name&&t.jsx("span",{className:"w-input-err",children:p.first_name})]}),F.includes("last_name")&&((B=A==null?void 0:A.last_name)==null?void 0:B.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",A.last_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.last_name?" w-input--invalid":""}`,type:"text",id:"last_name",name:"last_name",value:c.last_name||"",onChange:P,placeholder:"Enter your last name",disabled:C,autoComplete:"family-name"}),p.last_name&&t.jsx("span",{className:"w-input-err",children:p.last_name})]})]}),F.includes("username")&&((Q=A==null?void 0:A.username)==null?void 0:Q.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"username",children:["Username",A.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.username?" w-input--invalid":""}`,type:"text",id:"username",name:"username",value:c.username||"",onChange:P,placeholder:"Choose a username",disabled:C,autoComplete:"username"}),p.username&&t.jsx("span",{className:"w-input-err",children:p.username})]}),F.includes("phone_number")&&((ue=A==null?void 0:A.phone_number)==null?void 0:ue.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(js,{value:c.phone_number||"",onChange:H,error:p.phone_number,countryCode:f,setCountryCode:h}),p.phone_number&&t.jsx("span",{className:"w-input-err",children:p.phone_number})]}),F.includes("email_address")&&((we=A==null?void 0:A.email_address)==null?void 0:we.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",A.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.email_address?" w-input--invalid":""}`,type:"email",id:"email",name:"email",value:c.email||"",onChange:P,placeholder:"Enter your email address",disabled:C,autoComplete:"email"}),p.email_address&&t.jsx("span",{className:"w-input-err",children:p.email_address})]}),_&&t.jsx("span",{className:"w-input-err",children:_.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:C,children:C?t.jsx(vt,{onAccent:!0}):"Continue"})]})]})})}function Fc({onComplete:e,onSkip:a}){var u;const[s,r]=o.useState(!1),[i,l]=o.useState(null),{registerPasskey:m}=va(),{deployment:c}=je(),d=async()=>{r(!0),l(null);try{await m(),e==null||e()}catch(f){l(f instanceof Error?f.message:"Failed to register passkey")}finally{r(!1)}},p=((u=c==null?void 0:c.ui_settings)==null?void 0:u.app_name)||"this app";return t.jsxs("div",{className:"w-flex w-flex-col w-items-center w-text-center",children:[t.jsx("div",{className:"w-feature-badge",children:t.jsx(nr,{size:26})}),t.jsx("h1",{className:"w-title-lg",children:"Add a passkey"}),t.jsxs("p",{className:"w-sub",style:{marginTop:6,maxWidth:320},children:["Sign in faster and more securely with a passkey. Use your fingerprint, face, or screen lock to access ",p,"."]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,width:"100%",marginTop:24},children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:d,disabled:s,children:s?t.jsxs(t.Fragment,{children:[t.jsx(vt,{size:15,onAccent:!0}),"Registering…"]}):t.jsxs(t.Fragment,{children:[t.jsx(nr,{}),"Add passkey"]})}),t.jsx("button",{type:"button",className:"w-social",onClick:a,children:"Maybe later"})]}),i&&t.jsx("p",{className:"w-input-err",style:{marginTop:14},children:i})]})}function Mm(){return t.jsx(_m,{children:t.jsx(Rm,{})})}function Rm(){var Bt,ya,ja,yt,sa,na,ra,ia,oe,xe,Ne,J,ve,Ye,Ve,jt,_t,Be,wt,Gt,oa,la,ca;const{deployment:e}=je(),{navigate:a}=kt(),{session:s,loading:r,refetch:i,exchangeTicket:l,switchSignIn:m}=it(),c=((ya=(Bt=e==null?void 0:e.auth_settings)==null?void 0:Bt.multi_session_support)==null?void 0:ya.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:u,showForgotPassword:f,setShowForgotPassword:h,showOtherOptions:g,setShowOtherOptions:x,enabledSocialsProviders:w,firstFactor:b,setFirstFactor:j,signInStep:v,setSignInStep:k}=Lc(),{loading:N,signIn:_,signinAttempt:C,discardSignInAttempt:y,setSignInAttempt:E}=cs("generic"),{signIn:M}=cs("oauth"),{signIn:F}=cs("passkey"),[A,T]=o.useState({email:"",username:"",password:"",phone:""}),[P,S]=o.useState({}),[$,H]=o.useState(!1),[R,O]=o.useState(""),[Z,L]=o.useState("US"),[U,D]=o.useState(!1),[Y,B]=o.useState(null),[Q,ue]=o.useState(!1),[we,ne]=o.useState(!1),[ae,re]=o.useState(!1),[Me,q]=o.useState(60),[tt,Ie]=o.useState(!1),[De,Ee]=o.useState(null),ce=[...(s==null?void 0:s.signins)||[]].sort((X,te)=>{var pe,Pe;return X.id===((pe=s==null?void 0:s.active_signin)==null?void 0:pe.id)?-1:te.id===((Pe=s==null?void 0:s.active_signin)==null?void 0:Pe.id)?1:0});o.useEffect(()=>{const X=new URLSearchParams(window.location.search),te=X.get("error"),pe=X.get("error_description");if(te==="access_denied"&&pe){B(pe),X.delete("error"),X.delete("error_description");const Pe=X.toString()?`${window.location.pathname}?${X.toString()}`:window.location.pathname;window.history.replaceState({},"",Pe)}},[]),o.useEffect(()=>{if(b!=="email_magic_link"||!p)return;q(60),Ie(!1);const X=setInterval(()=>{q(te=>te<=1?(Ie(!0),clearInterval(X),0):te-1)},1e3);return()=>clearInterval(X)},[b,p]),o.useEffect(()=>{var X,te,pe,Pe;if(!r&&(s!=null&&s.active_signin)&&!c&&!U&&!Q){let Ae=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));Ae||(Ae=((X=e==null?void 0:e.ui_settings)==null?void 0:X.after_signin_redirect_url)||null),!Ae&&(e!=null&&e.frontend_host)&&(Ae=`https://${e.frontend_host}`);const ut=(te=e==null?void 0:e.auth_settings)==null?void 0:te.passkey;(ut==null?void 0:ut.enabled)&&(ut==null?void 0:ut.prompt_registration_on_auth)&&!((Pe=(pe=s.active_signin)==null?void 0:pe.user)!=null&&Pe.has_passkeys)?(Ee(Ae),ue(!0)):Ae&&(D(!0),a(Ae))}},[s,r,c,e,a,U]);const W=X=>{let{name:te,value:pe}=X.target;te==="phone"?pe=pe.replace(/[^0-9]/g,""):te==="email"&&(d(pe),pe=pe.toLowerCase()),T(Pe=>({...Pe,[te]:pe})),S(Pe=>({...Pe,[te]:""}))},G=()=>{T({email:"",username:"",password:"",phone:""}),S({}),L("US"),k("identifier")},K=async X=>{if(!X){S({email:"Email address is required"});return}H(!0),S({});try{const te=await _.identify(X);if(te.strategy==="sso"&&te.connection_id){const pe=new URLSearchParams(window.location.search),Pe=gt(e,pe.get("redirect_uri"))||void 0,Ae=await _.initEnterpriseSso(te.connection_id,Pe);if(Ae&&Ae.sso_url){D(!0),window.location.href=Ae.sso_url;return}}else if(te.strategy==="social"&&te.provider){const pe=w.find(Pe=>Pe.provider===te.provider);if(pe){const Pe=new URLSearchParams(window.location.search),Ae=gt(e,Pe.get("redirect_uri"))||void 0,{data:ut}=await M.create({provider:pe.provider,redirectUri:Ae});if(ut&&typeof ut=="object"&&"oauth_url"in ut){D(!0),window.location.href=ut.oauth_url;return}}else k("password")}else k("password")}catch(te){S({submit:te.message})}finally{U||H(!1)}},V=async X=>{if(X.preventDefault(),N||$)return;y();const te={};if(v==="identifier"&&b==="email_password"){if(!A.email){S({email:"Email address is required"});return}await K(A.email);return}if(v==="identifier"&&b==="username_password"){if(!A.username){S({username:"Username is required"});return}S({}),k("password");return}if(b==="email_password"?(A.email||(te.email="Email address is required"),A.password||(te.password="Password is required")):b==="username_password"?(A.username||(te.username="Username is required"),A.password||(te.password="Password is required")):b==="email_otp"||b==="email_magic_link"?A.email||(te.email="Email address is required"):b==="phone_otp"&&(A.phone?/^\d{7,15}$/.test(A.phone)||(te.phone="Phone number must contain 7-15 digits"):te.phone="Phone number is required"),S(te),Object.keys(te).length>0)return;let pe="";switch(b){case"email_password":pe="plain_email";break;case"username_password":pe="plain_username";break;case"email_otp":pe="email_otp";break;case"email_magic_link":pe="magic_link";break;case"phone_otp":pe="phone_otp";break}const Pe=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";H(!0);try{const Ae={...A,strategy:pe};b==="phone_otp"&&Z&&(Ae.phone_country_code=Z),await _.create(Ae),Pe||H(!1)}catch(Ae){S({submit:Ae.message}),H(!1)}},de=async X=>{if(X.preventDefault(),N||$)return;const te={};if(!R){te.otp="OTP code is required",S(te);return}H(!0),S({});try{await _.completeVerification(R),u(!1),O("")}catch(pe){S({otp:pe.message||"Verification failed"})}finally{H(!1)}},z=async X=>{if(!(N||$)){H(!0);try{const te=new URLSearchParams(window.location.search),pe=gt(e,te.get("redirect_uri"))||void 0,{data:Pe}=await M.create({provider:X.provider,redirectUri:pe});Pe&&typeof Pe=="object"&&"oauth_url"in Pe&&(window.location.href=Pe.oauth_url)}catch(te){S({submit:te.message})}finally{H(!1)}}},le=async()=>{var X;if(!(N||$)){H(!0),S({});try{const te=await F.create();if("data"in te&&te.data){await i();let pe=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));pe||(pe=((X=e==null?void 0:e.ui_settings)==null?void 0:X.after_signin_redirect_url)||null),!pe&&(e!=null&&e.frontend_host)&&(pe=`https://${e.frontend_host}`),D(!0),pe&&a(pe)}}catch(te){S({submit:te.message||"Passkey sign-in failed"})}finally{H(!1)}}},Je=()=>{var pe;let X=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(X||(X=((pe=e==null?void 0:e.ui_settings)==null?void 0:pe.after_signin_redirect_url)||null),!X&&(e!=null&&e.frontend_host)&&(X=`https://${e.frontend_host}`),!X)return null;let te;try{te=new URL(X)}catch{te=new URL(X,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&te.searchParams.set("__dev_session__",xt(e.backend_host)||""),te.toString()},ot=async X=>{if(!(N||$)){S({}),H(!0);try{await m(X);const te=Je();te&&(D(!0),a(te))}catch(te){S({submit:te.message||"Failed to continue with selected account"})}finally{H(!1)}}},ge=(X,te)=>`${X||""} ${te||""}`.trim().split(" ").filter(Boolean).map(pe=>pe[0]).join("").toUpperCase().slice(0,2)||"?",lt=o.useRef(!1);if(o.useEffect(()=>{if(r)return;const X=new URLSearchParams(window.location.search),te=X.get("ticket");if(te&&!lt.current&&!N){lt.current=!0,X.delete("ticket");const Pe=X.toString()?`${window.location.pathname}?${X.toString()}`:window.location.pathname;window.history.replaceState({},"",Pe),(async()=>{var ut;try{H(!0),await l(te),D(!0);let Vt=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(Vt||(Vt=((ut=e==null?void 0:e.ui_settings)==null?void 0:ut.after_signin_redirect_url)||null),!Vt&&(e!=null&&e.frontend_host)&&(Vt=`https://${e.frontend_host}`),Vt){let Ss;try{Ss=new URL(Vt)}catch{Ss=new URL(Vt,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Ss.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(Ss.toString())}return}catch(Vt){S({submit:Vt.message||"Failed to exchange ticket"}),lt.current=!1}finally{H(!1)}})();return}const pe=X.get("signin_attempt_id");if(pe&&(s!=null&&s.signin_attempts)&&!C){const Pe=s.signin_attempts.find(Ae=>Ae.id===pe);if(Pe){E(Pe),X.delete("signin_attempt_id");const Ae=X.toString()?`${window.location.pathname}?${X.toString()}`:window.location.pathname;window.history.replaceState({},"",Ae)}}},[s,r,C,E,N]),o.useEffect(()=>{var Pe;if(!C)return;if(C.completed){D(!0);let Ae=new URLSearchParams(window.location.search).get("redirect_uri");if(Ae||(Ae=((Pe=e==null?void 0:e.ui_settings)==null?void 0:Pe.after_signin_redirect_url)||null),!Ae&&(e!=null&&e.frontend_host)&&(Ae=`https://${e.frontend_host}`),Ae){let ut;try{ut=new URL(Ae)}catch{ut=new URL(Ae,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&ut.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(ut.toString())}return}if(!_||p)return;const te={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(!te)return;(async()=>{try{await _.prepareVerification({strategy:te}),H(!1),u(!0)}catch{S({submit:"Failed to send verification. Please try again."}),H(!1)}})()},[C,_,p,u,a,e]),g)return t.jsx(Nm,{onBack:()=>x(!1)});if(f)return t.jsx(Cm,{onBack:()=>h(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return t.jsx(Zc,{attempt:C,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return t.jsx(Hc,{attempt:C,completeProfile:_.completeProfile,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if(Q){const X=()=>{ue(!1),De&&(D(!0),a(De))},te=()=>{ue(!1),De&&(D(!0),a(De))};return t.jsx(Re,{children:t.jsx(et,{children:t.jsx(Fc,{onComplete:X,onSkip:te})})})}if(r||U)return t.jsx(_s,{});const Ke=((ja=e==null?void 0:e.ui_settings)==null?void 0:ja.app_name)||"App",ie=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&p,me=b==="email_magic_link",Ze=c&&!ie&&ce.length>0&&!ae,He=()=>{u(!1),y(),G()};let qe;if(ie){const X=b==="phone_otp"?"Check your phone":me?"Check your inbox":"Enter the code",te=me?"We sent a magic link to your email — click it to sign in instantly.":b==="phone_otp"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",pe=(b==="email_otp"||me)&&A.email?A.email:b==="phone_otp"&&A.phone?`+${A.phone}`:null;qe=t.jsx(nt,{title:X,sub:te,children:pe&&t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:He,children:[t.jsx(Pl,{weight:"bold"}),pe]})})}else qe=t.jsx(nt,{title:"Sign in to your account",sub:`Please enter your details to continue to ${Ke}.`});let ct;ie?ct=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((yt=e==null?void 0:e.ui_settings)==null?void 0:yt.support_page_url)||"#",children:"Get help"})]}):ct=t.jsxs("span",{className:"w-auth-foot",children:["Don't have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((sa=e==null?void 0:e.ui_settings)==null?void 0:sa.sign_up_page_url)??""}${window.location.search}`,children:"Sign up"})]});let Rt;if(ie&&me)Rt=t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,padding:"12px 0 4px"},children:tt?t.jsx("button",{type:"button",className:"w-link w-linkbtn",onClick:async()=>{Ie(!1),q(60);try{await _.prepareVerification({strategy:"magic_link"})}catch{}},children:"Resend magic link"}):t.jsxs("span",{className:"w-secsub",children:["Resend in ",Me,"s"]})});else if(ie)Rt=t.jsxs("form",{onSubmit:de,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ba,{onComplete:async X=>{if(O(X),X&&X.length===6){H(!0),S({});try{await _.completeVerification(X),u(!1)}catch(te){S({otp:te.message||"Verification failed"})}finally{H(!1)}}},onResend:async()=>{const X=b==="email_otp"?"email_otp":"phone_otp";await _.prepareVerification({strategy:X})},error:P.otp,isSubmitting:$}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N||!R,children:$&&R?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${Ke}`})]});else{const X=(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((ra=(na=e==null?void 0:e.auth_settings)==null?void 0:na.email_address)==null?void 0:ra.enabled),te=b==="username_password"&&((oe=(ia=e==null?void 0:e.auth_settings)==null?void 0:ia.username)==null?void 0:oe.enabled),pe=b==="phone_otp"&&((Ne=(xe=e==null?void 0:e.auth_settings)==null?void 0:xe.phone_number)==null?void 0:Ne.enabled),Pe=v==="password"&&(b==="email_password"||b==="username_password")&&((ve=(J=e==null?void 0:e.auth_settings)==null?void 0:J.password)==null?void 0:ve.enabled);Rt=t.jsxs(t.Fragment,{children:[w.length>0&&t.jsx(Er,{connections:w,callback:z}),((Ve=(Ye=e==null?void 0:e.auth_settings)==null?void 0:Ye.passkey)==null?void 0:Ve.enabled)&&t.jsxs("button",{type:"button",className:"w-social",style:{marginTop:w.length>0?10:0},onClick:le,disabled:$,children:[t.jsx(nr,{}),t.jsx("span",{children:"Sign in with a passkey"})]}),(w.length>0||((_t=(jt=e==null?void 0:e.auth_settings)==null?void 0:jt.passkey)==null?void 0:_t.enabled))&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsxs("form",{onSubmit:V,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[X&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Email address"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&b==="email_password"&&A.email?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:A.email}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>k("identifier"),children:"Edit"})]}):t.jsx(Kt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",value:A.email,onChange:W,placeholder:"you@company.com","aria-invalid":!!P.email}),P.email&&t.jsx("span",{className:"w-input-err",children:P.email})]}),te&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Username"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&A.username?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:A.username}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>{k("identifier"),T(Ae=>({...Ae,password:""}))},children:"Edit"})]}):t.jsx(Kt,{className:"w-input",type:"text",id:"username",name:"username",value:A.username,onChange:W,placeholder:"yourname","aria-invalid":!!P.username,autoComplete:"username"}),P.username&&t.jsx("span",{className:"w-input-err",children:P.username})]}),pe&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(js,{value:A.phone,onChange:W,error:P.phone,countryCode:Z,setCountryCode:L}),P.phone&&t.jsx("span",{className:"w-input-err",children:P.phone})]}),Pe&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{className:"w-label",children:"Password"}),t.jsx("span",{className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer"},onClick:()=>h(!0),children:"Forgot?"})]}),t.jsx(Kt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"current-password",value:A.password,onChange:W,placeholder:"••••••••","aria-invalid":!!P.password}),P.password&&t.jsx("span",{className:"w-input-err",children:P.password})]}),P.submit&&t.jsx("span",{className:"w-input-err",children:P.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N,children:$?t.jsx(vt,{size:15,onAccent:!0}):t.jsxs(t.Fragment,{children:[v==="identifier"?"Continue":"Sign in",t.jsx(Jt,{weight:"bold"})]})}),v==="password"&&((wt=(Be=e==null?void 0:e.auth_settings)==null?void 0:Be.auth_factors_enabled)==null?void 0:wt.email_otp)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-or",style:{margin:"5px 0"},children:t.jsx("span",{children:"OR"})}),t.jsxs("button",{type:"button",className:"w-method",disabled:$,onClick:async()=>{H(!0),S({});try{await _.create({email:A.email,strategy:"email_otp"}),j("email_otp")}catch(Ae){S({submit:Ae.message}),H(!1)}},children:[t.jsx("span",{className:"w-method-ic",children:t.jsx(jl,{})}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:"Sign in with a code"}),t.jsx("span",{className:"w-method-desc",children:"We'll send a 6-digit code to your email"})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Jt,{})})]})]})]})]})}return t.jsx(Re,{children:t.jsxs(et,{footer:ct,children:[qe,Y&&t.jsxs("div",{className:"w-banner w-banner--error",style:{marginBottom:18},children:[t.jsx(Ta,{weight:"fill"}),t.jsxs("span",{className:"w-banner-txt",children:[t.jsx("strong",{children:"Access denied."})," ",Y," ",t.jsx("span",{className:"w-link",onClick:()=>B(null),children:"Try again"})]})]}),Ze&&(we?t.jsxs("div",{className:"w-acct-list",children:[t.jsx("div",{className:"w-secsub w-acct-list-head",children:"Choose an account"}),t.jsxs("div",{className:"w-acct-list-body",children:[ce.map(X=>{var te,pe,Pe,Ae;return t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>ot(X.id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:X.user.has_profile_picture?t.jsx("img",{src:X.user.profile_picture_url,alt:((te=X.user.primary_email_address)==null?void 0:te.email)||"account"}):ge(X.user.first_name,X.user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsx("span",{className:"w-acct-name",children:X.user.first_name&&X.user.last_name?`${X.user.first_name} ${X.user.last_name}`:X.user.first_name||((Pe=(pe=X.user.primary_email_address)==null?void 0:pe.email)==null?void 0:Pe.split("@")[0])||"Account"}),t.jsx("span",{className:"w-secsub",children:(Ae=X.user.primary_email_address)==null?void 0:Ae.email})]}),t.jsx(Jt,{className:"w-acct-go"})]},X.id)}),t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>{ne(!1),re(!0),G()},children:[t.jsx("span",{className:"w-avatar",style:{background:"var(--wa-surface-subtle)",color:"var(--wa-text-muted)"},children:t.jsx(Gu,{size:16})}),t.jsx("span",{className:"w-acct-text w-acct-name",children:"Use a different account"}),t.jsx(Jt,{className:"w-acct-go"})]})]})]}):t.jsxs("button",{type:"button",className:"w-acct","data-active":!0,style:{marginBottom:18},onClick:()=>ot(ce[0].id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:ce[0].user.has_profile_picture?t.jsx("img",{src:ce[0].user.profile_picture_url,alt:((Gt=ce[0].user.primary_email_address)==null?void 0:Gt.email)||"account"}):ge(ce[0].user.first_name,ce[0].user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsxs("span",{className:"w-acct-name",children:["Welcome back,"," ",ce[0].user.first_name||((la=(oa=ce[0].user.primary_email_address)==null?void 0:oa.email)==null?void 0:la.split("@")[0])||"back"]}),t.jsx("span",{className:"w-secsub",children:(ca=ce[0].user.primary_email_address)==null?void 0:ca.email})]}),t.jsx("span",{className:"w-link w-link--muted w-link--sm",style:{flex:"none"},onClick:X=>{X.stopPropagation(),ce.length>1?ne(!0):(re(!0),G())},children:"Not you?"})]})),Rt]})})}function Lm(){var b,j,v,k,N,_,C,y,E,M,F,A;const{deployment:e}=je(),{loading:a,joinWaitlist:s}=Ao(),[r,i]=o.useState({first_name:"",last_name:"",email:""}),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(null),f=()=>{if(p)return p.message},h=e==null?void 0:e.auth_settings,g=!!((b=h==null?void 0:h.first_name)!=null&&b.enabled&&((j=h==null?void 0:h.last_name)!=null&&j.enabled)),x=T=>{const{name:P,value:S}=T.target;i($=>({...$,[P]:S}))},w=async T=>{if(T.preventDefault(),!!h){d(!0),u(null);try{(await s(r)).data&&m(!0)}catch(P){u(P)}finally{d(!1)}}};return l?t.jsx(Re,{children:t.jsx(et,{children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,textAlign:"center"},children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{weight:"bold"})})]}),t.jsx("h1",{className:"w-auth-title",children:"You're on the waitlist"}),t.jsxs("p",{className:"w-auth-sub",children:["Thanks for your interest! We'll notify you at"," ",r.email," when we're ready for you to join."]})]})})}):t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx("a",{href:"/contact",className:"w-link",children:"Get help"})]}),children:[t.jsx(nt,{title:"Join the waitlist",sub:"Be the first to know when we launch!"}),t.jsxs("form",{onSubmit:w,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(((v=h==null?void 0:h.first_name)==null?void 0:v.enabled)||((k=h==null?void 0:h.last_name)==null?void 0:k.enabled))&&t.jsxs("div",{className:g?"w-grid-2":"",children:[((N=h==null?void 0:h.first_name)==null?void 0:N.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",((_=h==null?void 0:h.first_name)==null?void 0:_.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"first_name",name:"first_name",required:(C=h==null?void 0:h.first_name)==null?void 0:C.required,minLength:2,maxLength:50,value:r.first_name,onChange:x,placeholder:"First name"})]}),((y=h==null?void 0:h.last_name)==null?void 0:y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",((E=h==null?void 0:h.last_name)==null?void 0:E.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"last_name",name:"last_name",required:(M=h==null?void 0:h.last_name)==null?void 0:M.required,minLength:2,maxLength:50,value:r.last_name,onChange:x,placeholder:"Last name"})]})]}),t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",((F=h==null?void 0:h.email_address)==null?void 0:F.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"email",id:"email",name:"email",required:(A=h==null?void 0:h.email_address)==null?void 0:A.required,value:r.email,onChange:x,placeholder:"Enter your email address"})]}),f()&&t.jsx("span",{className:"w-input-err",children:f()}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:c||a,children:c||a?t.jsx(vt,{onAccent:!0}):"Join waitlist"})]})]})})}function Zn({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx(Re,{children:t.jsxs(et,{footer:l,children:[t.jsx(nt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function Pm(){const{deployment:e}=je(),{navigate:a}=kt(),{error:s,session:r,processed:i,signinAttempt:l,redirectUri:m,loading:c}=Mo(),[d,p]=o.useState(!1),[u,f]=o.useState(null),h=()=>{window.location.reload()},g=()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||"/sign-in";a(b)},x=()=>{p(!1),u&&a(u)},w=()=>{p(!1),u&&a(u)};if(o.useEffect(()=>{var b,j,v,k,N;if(!(!i||c||d)){if(l&&!l.completed){const _=(b=e==null?void 0:e.ui_settings)==null?void 0:b.sign_in_page_url;if(_){const C=new URL(_,window.location.origin);C.searchParams.set("signin_attempt_id",l.id),m&&C.searchParams.set("redirect_uri",m),a(C.toString())}return}if(l!=null&&l.completed){const C=gt(e,m)||((j=e==null?void 0:e.ui_settings)==null?void 0:j.after_signin_redirect_url)||(e==null?void 0:e.frontend_host)||"/";let y;try{y=new URL(C)}catch{y=new URL(C,window.location.origin)}if(y){(e==null?void 0:e.mode)==="staging"&&y.searchParams.set("__dev_session__",xt(e.backend_host)||"");const E=(v=e==null?void 0:e.auth_settings)==null?void 0:v.passkey;(E==null?void 0:E.enabled)&&(E==null?void 0:E.prompt_registration_on_auth)&&!((N=(k=r==null?void 0:r.active_signin)==null?void 0:k.user)!=null&&N.has_passkeys)?(f(y.toString()),p(!0)):a(y.toString())}}}},[r,i,c,m,e,l,a]),o.useEffect(()=>{s&&s.message.includes("No OAuth callback data found")&&setTimeout(()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||(e==null?void 0:e.frontend_host);b&&a(b)},2e3)},[s,e,a]),d)return t.jsx(Re,{children:t.jsx(et,{children:t.jsx(Fc,{onComplete:x,onSkip:w})})});if(r&&i&&!s)return t.jsx(Zn,{title:"Success",sub:"Authentication completed successfully",icon:t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{weight:"bold"})})]}),message:"You'll be redirected to your destination shortly."});if(s){const b=s.message.includes("No OAuth callback data found");return t.jsx(Zn,{title:"Something went wrong",sub:"We couldn't complete your sign in",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Pa,{weight:"bold"})})]}),message:s.message||"An unexpected error occurred during authentication.",action:b?void 0:t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:h,children:"Try again"}),footer:b?void 0:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:g,children:"Return to sign in"})]})})}return t.jsx(Zn,{title:"Completing sign in",sub:"Please wait while we authenticate you",icon:t.jsx(vt,{size:32}),message:"Verifying your credentials… this will only take a moment."})}function $m({onSuccess:e,onError:a}={}){const[s,r]=o.useState("loading"),[i,l]=o.useState(""),{token:m,attempt:c,redirectUri:d}=X1(),{verifyMagicLink:p}=Ro(),{navigate:u}=kt(),{deployment:f}=je(),h=o.useRef(!1);o.useEffect(()=>{(async()=>{if(!h.current){if(!m||!c){r("error"),l("The magic link appears to be malformed. Please try signing in again."),a==null||a("Invalid magic link parameters");return}h.current=!0,r("loading"),l("Please wait while we verify your magic link.");try{await p({token:m,attempt:c,redirectUri:d}),r("success"),l("You will be redirected to your account shortly."),e==null||e(),setTimeout(()=>{var b;let w=gt(f,d);if(w||(w=(b=f==null?void 0:f.ui_settings)==null?void 0:b.after_signin_redirect_url),!w&&(f!=null&&f.frontend_host)&&(w=`https://${f.frontend_host}`),w){const j=new URL(w);(f==null?void 0:f.mode)==="staging"&&j.searchParams.set("__dev_session__",xt(f.backend_host)||""),u(j.toString())}},2e3)}catch(w){r("error"),l("The magic link may have expired or already been used. Please try signing in again."),a==null||a(w.message)}}})()},[m,c]);const g=()=>{var x;(x=f==null?void 0:f.ui_settings)!=null&&x.sign_in_page_url&&u(f.ui_settings.sign_in_page_url)};return t.jsx(Re,{children:t.jsxs(et,{children:[t.jsx(nt,{title:"Magic link",sub:"Verifying your magic link"}),t.jsxs("div",{className:"w-auth-status",children:[s==="loading"&&t.jsx(vt,{size:32}),s==="success"&&t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{weight:"bold"})})]}),s==="error"&&t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Pa,{weight:"bold"})})]}),t.jsx("p",{className:"w-auth-sub",children:i}),s==="error"&&t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:g,children:"Try again"})]})]})})}function Om(e){var r,i;return e?((r=e.signin_attempts)==null?void 0:r.find(l=>l.requires_completion&&!l.completed))?!0:!!((i=e.signup_attempts)==null?void 0:i.find(l=>{var m,c;return((m=l.missing_fields)==null?void 0:m.length)>0||((c=l.remaining_steps)==null?void 0:c.length)>0&&!l.completed})):!1}function Zm(e){const a=e?`/profile-completion?redirect_uri=${encodeURIComponent(e)}`:"/profile-completion";window.location.href=a}function rs({kind:e}){const a=e==="success"?"w-success":e==="error"?"w-success w-success--error":"w-success w-success--info",s=e==="success"?Ge:e==="error"?Pa:Tu;return t.jsxs("div",{className:a,children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(s,{weight:"bold"})})]})}function ka({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx(Re,{children:t.jsxs(et,{footer:l,children:[t.jsx(nt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function Hm({token:e,onSuccess:a,onError:s}){var b;const{acceptInvitation:r,invitationData:i,loading:l,error:m}=Io(),{navigate:c}=kt(),{deployment:d}=je(),p=o.useRef(!1),u=()=>{var v;const j=new URLSearchParams(window.location.search);return{token:e||j.get("invite_token")||j.get("token"),redirectUri:gt(d,j.get("redirect_uri"))||((v=d==null?void 0:d.ui_settings)==null?void 0:v.after_signin_redirect_url)||"/"}};o.useEffect(()=>{if(p.current)return;const{token:j}=u();j&&(p.current=!0,r(j))},[r]),o.useEffect(()=>{var j;i&&(i.organization&&!i.requires_signin&&a&&a(i.organization.id,(j=i.workspace)==null?void 0:j.id),i.error_code&&s&&s(i.message||"Failed to accept invitation"))},[i,a,s]);const f=()=>{const{redirectUri:j}=u();c(j)},h=()=>{var E,M;const{token:j}=u(),v=((E=d==null?void 0:d.ui_settings)==null?void 0:E.sign_in_page_url)||"/sign-in",k=((M=d==null?void 0:d.ui_settings)==null?void 0:M.sign_up_page_url)||"/sign-up",N=new URLSearchParams;j&&N.set("invite_token",j),i!=null&&i.invited_email&&N.set("invited_email",i.invited_email);const C=`${window.location.pathname}?token=${j}`;N.set("redirect_uri",C),i!=null&&i.message&&N.set("message",i.message);const y=(i==null?void 0:i.error_code)==="INVITATION_REQUIRES_SIGNUP";c(`${y?k:v}?${N.toString()}`)},g=()=>{const{token:j}=u();j&&(p.current=!1,r(j))},x=(j,v)=>t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:v,children:j}),{token:w}=u();if(!w&&!l)return t.jsx(ka,{title:"Invalid invitation",sub:"No invitation token found",icon:t.jsx(rs,{kind:"error"}),message:"The invitation link appears to be invalid or incomplete.",action:x("Go to home",()=>c("/"))});if(l)return t.jsx(ka,{title:"Processing invitation",sub:"Please wait while we verify your invitation",icon:t.jsx(vt,{size:32}),message:"Verifying invitation… this will only take a moment."});if(i!=null&&i.organization&&!i.requires_signin)return t.jsx(ka,{title:"Invitation accepted",sub:"You've successfully joined the organization",icon:t.jsx(rs,{kind:"success"}),message:t.jsxs(t.Fragment,{children:["Welcome to"," ",t.jsx("strong",{children:i.organization.name}),i.workspace?`. You've been added to the ${i.workspace.name} workspace.`:"."]}),action:x("Continue to application",f)});if(i!=null&&i.already_member)return t.jsx(ka,{title:"Already a member",sub:"You're already part of this organization",icon:t.jsx(rs,{kind:"info"}),message:`You're already a member of ${((b=i.organization)==null?void 0:b.name)||"this organization"}. No action needed.`,action:x("Continue to application",f)});if(i!=null&&i.requires_signin){const j=i.error_code==="INVITATION_REQUIRES_SIGNUP";return t.jsx(ka,{title:j?"Sign up required":"Sign in required",sub:"To accept this invitation",icon:t.jsx(rs,{kind:"info"}),message:t.jsxs(t.Fragment,{children:["This invitation is for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email}),"."," ",j?"Create an account with this email address to accept it.":i.error_code==="INVITATION_EMAIL_MISMATCH"?"You're signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."]}),action:x(j?"Sign up to accept":"Sign in to accept",h)})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?t.jsx(ka,{title:"Invitation expired",sub:"This invitation is no longer valid",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx($u,{weight:"bold"})})]}),message:t.jsxs(t.Fragment,{children:["Invitation for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email})," ","has expired. Invitations are valid for 10 days — please request a new one from your organization administrator."]})}):m||i!=null&&i.error_code?t.jsx(ka,{title:"Invitation error",sub:"Unable to process invitation",icon:t.jsx(rs,{kind:"error"}),message:(i==null?void 0:i.message)||m||"Failed to accept invitation",action:x("Try again",g),footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:h,children:"Sign in manually"})]})}):null}const Tc=o.createContext(void 0),Ic=()=>{const e=o.useContext(Tc);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},Fm=({isOpen:e,onClose:a,children:s})=>{const[r,i]=o.useState(!1),l=as();return o.useEffect(()=>{i(!0);const m=c=>{c.key==="Escape"&&e&&(a==null||a())};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[e,a]),!e||!r?null:tn.createPortal(t.jsx("div",{className:"wacht-root",style:l,children:t.jsx(Tc.Provider,{value:{isOpen:e,onClose:a},children:s})}),document.body)},Tm=({children:e})=>{const{onClose:a}=Ic(),s=o.useRef(null),r=i=>{s.current&&!s.current.contains(i.target)&&(a==null||a())};return t.jsx("div",{className:"w-modal",onClick:r,children:t.jsx("div",{ref:s,style:{maxWidth:"100%",minWidth:0},children:e})})},Im=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog${s?` ${s}`:""}`,style:{maxHeight:"90vh",overflowY:"auto",...a},children:e}),Vm=({children:e,showCloseButton:a=!0})=>{const{onClose:s}=Ic();return t.jsxs("div",{className:"w-dialog-head",children:[typeof e=="string"?t.jsx("h2",{className:"w-dialog-title",children:e}):e,a&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:s,children:t.jsx(Pa,{size:18})})]})},zm=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog-body${s?` ${s}`:""}`,style:a,children:e}),Dm=({children:e})=>t.jsx("div",{className:"w-dialog-foot",children:e}),ze=Object.assign(Fm,{Overlay:Tm,Content:Im,Header:Vm,Body:zm,Footer:Dm}),Um=({isOpen:e,onClose:a,title:s,children:r,showCloseButton:i=!0})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{children:[s&&t.jsx(ze.Header,{showCloseButton:i,children:s}),t.jsx(ze.Body,{children:r})]})})}),Wm=({trigger:e,renderDialog:a})=>{const[s,r]=o.useState(!1),i=()=>r(!0),l=()=>r(!1);return t.jsxs(t.Fragment,{children:[e({onClick:i}),a({isOpen:s,onClose:l})]})},Vc=o.createContext(void 0),zc=()=>{const e=o.useContext(Vc);if(!e)throw new Error("useDropdownContext must be used within a DropdownProvider");return e},ks=({children:e,open:a,openChange:s,style:r})=>{const i=o.useRef(null),[l,m]=o.useState(!1);return o.useEffect(()=>{const c=d=>{i.current&&!i.current.contains(d.target)&&m(!1)};return l&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[l,s]),o.useEffect(()=>{s==null||s(l)},[l]),o.useEffect(()=>{m(!!a)},[a]),t.jsx(Vc.Provider,{value:{open:l,openChange:c=>m(c)},children:t.jsx("div",{style:{width:"fit-content",...r},ref:i,children:e})})},Cs=({children:e,style:a,className:s})=>{const{open:r}=zc(),[i,l]=o.useState({top:0,left:0}),[m,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{r&&d.current?(c(!1),requestAnimationFrame(()=>{var f,h;const p=(f=d.current)==null?void 0:f.parentElement;if(!p)return;const u=p.querySelector("[data-dropdown-trigger]")||p.firstElementChild;if(u&&u!==d.current){const g=u.getBoundingClientRect(),x=(h=d.current)==null?void 0:h.getBoundingClientRect(),w=window.innerWidth,b=window.innerHeight;let j=g.bottom+4,v=g.right-((x==null?void 0:x.width)||200);v<8&&(v=g.left),v+((x==null?void 0:x.width)||200)>w-8&&(v=w-((x==null?void 0:x.width)||200)-8),x&&j+x.height>b-8&&(j=g.top-(x.height+4)),l({top:j,left:v}),c(!0)}})):c(!1)},[r]),r?t.jsx("div",{className:s?`w-menu ${s}`:"w-menu",ref:d,style:{position:"fixed",zIndex:1e3,width:"max-content",minWidth:140,maxWidth:240,...a,top:`${i.top}px`,left:`${i.left}px`,visibility:m?"visible":"hidden",opacity:m?1:0,transition:m?"opacity 0.15s ease-in-out":"none"},children:e}):null},Ns=({children:e})=>{const{openChange:a,open:s}=zc(),r=o.useCallback(()=>{a(!s)},[s,a]);return t.jsx("div",{style:{position:"relative",display:"inline-flex"},onClick:r,"data-dropdown-trigger":!0,children:e})},ta=o.forwardRef(({$destructive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:`w-menu-item${e?" w-menu-item--danger":""}${a?` ${a}`:""}`,...s}));ta.displayName="DropdownItem";const Dc=()=>t.jsx("div",{style:{height:"0.5px",background:"var(--wa-border)",width:"100%",margin:"4px 0"}}),Uc=o.forwardRef(({className:e,style:a,...s},r)=>t.jsx("form",{ref:r,className:e,style:{display:"flex",flexDirection:"column",gap:16,...a},...s}));Uc.displayName="Form";const We=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:`w-field${e?` ${e}`:""}`,...a}));We.displayName="FormGroup";const Te=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:`w-label${e?` ${e}`:""}`,...a}));Te.displayName="Label";const be=o.forwardRef(({as:e="input",className:a,...s},r)=>{const i=`w-input${a?` ${a}`:""}`;return e==="textarea"?t.jsx("textarea",{className:i,...s}):t.jsx("input",{ref:r,className:i,...s})});be.displayName="Input";const _e=({size:e,className:a})=>t.jsx("div",{className:a,style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:e?`${e}px`:"100%"},children:t.jsx("span",{className:"w-spin",style:{width:e??40,height:e??40}})}),Ha=({checked:e,onChange:a})=>t.jsxs("label",{className:"w-switch","data-on":e?"":void 0,children:[t.jsx("input",{type:"checkbox",checked:e,onChange:s=>a(s.target.checked),style:{position:"absolute",opacity:0,width:0,height:0}}),t.jsx("span",{className:"w-switch-track",children:t.jsx("span",{className:"w-switch-knob"})})]}),Yt=(e=!1)=>{const[a,s]=o.useState(e),r=o.useCallback(()=>{s(!0)},[]),i=o.useCallback(()=>{s(!1)},[]),l=o.useCallback(()=>{s(m=>!m)},[]);return{isOpen:a,open:r,close:i,toggle:l}},Wc=({onChange:e,placeholder:a,value:s})=>t.jsxs("div",{className:"w-search",children:[t.jsx(Al,{}),t.jsx("input",{type:"text",placeholder:a,value:s,onChange:r=>e(r.target.value)})]}),se=o.forwardRef(({$primary:e,$outline:a,$destructive:s,$fullWidth:r,$size:i,className:l,style:m,...c},d)=>{const f=`w-btn ${s?"w-btn--danger-solid":a?"w-btn--secondary":"w-btn--primary"}${i==="sm"?" w-btn--sm":i==="lg"?" w-btn--lg":""}${l?` ${l}`:""}`;return t.jsx("button",{ref:d,className:f,style:r?{width:"100%",...m}:m,...c})});se.displayName="Button";const Bc=e=>({position:"absolute",top:"calc(100% + 6px)",left:0,width:"100%",maxHeight:260,overflowY:"auto",zIndex:1e3,opacity:e?1:0,transform:e?"scale(1)":"scale(0.97)",transformOrigin:"top",pointerEvents:e?"auto":"none",transition:"opacity 0.15s ease, transform 0.15s ease"}),Gc={width:"100%",height:32,padding:"0 9px",border:"none",borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,fontFamily:"var(--wa-font-sans)",fontSize:13,outline:"none",background:"transparent",color:"var(--wa-text)",marginBottom:4},Js=({children:e})=>t.jsx("div",{style:{padding:"10px 9px",color:"var(--wa-text-faint)",fontFamily:"var(--wa-font-sans)",fontSize:12.5,textAlign:"center"},children:e}),mn=({options:e,value:a,onChange:s,placeholder:r="Select an option",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).find(y=>y.value===a),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(s(y),h(!1),x(""))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k?void 0:"",children:k?k.label:r}),f?t.jsx(tl,{size:16}):t.jsx(Wt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:Bc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Gc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Js,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>_(M.value,M.disabled),role:"option","aria-selected":M.value===a,children:[M.label,M.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Js,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":y.value===a,children:[y.label,y.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a||""})]})},qc=({options:e,value:a,onChange:s,placeholder:r="Select options",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).filter(y=>a.includes(y.value)),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(a.includes(y)?s(a.filter(M=>M!==y)):s([...a,y]))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k.length>0?void 0:"",children:k.length>0?k.map(y=>y.label).join(", "):r}),f?t.jsx(tl,{size:16}):t.jsx(Wt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:Bc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Gc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Js,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>_(M.value,M.disabled),role:"option","aria-selected":a.includes(M.value),children:[M.label,a.includes(M.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Js,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":a.includes(y.value),children:[y.label,a.includes(y.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a.join(",")})]})},Zs=e=>e.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)||"?",Ri=e=>e.trim().replace(/[<>"'&]/g,""),Bm=e=>e.length>=2&&e.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(e),Gm=e=>/.+@.+\..+/.test(e),Li=(e,a)=>e.length?e.find(s=>s.name===a)||e[0]:null,qm=({roles:e,value:a,onChange:s,fullWidth:r})=>{const[i,l]=o.useState(!1),m=o.useRef(null);return o.useEffect(()=>{if(!i)return;const c=d=>{m.current&&!m.current.contains(d.target)&&l(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]),t.jsxs("div",{ref:m,className:`w-relative${r?" w-full":" w-none"}`,children:[t.jsxs("button",{type:"button",className:`w-combo${r?" w-full":" w-rolepick-btn"}`,"data-open":i?"":void 0,onClick:()=>l(c=>!c),disabled:!e.length,children:[t.jsx("span",{className:"w-combo-val",children:(a==null?void 0:a.name)||"Role"}),t.jsx(Wt,{size:14})]}),i&&t.jsx("div",{className:"w-combo-menu w-combo-menu--pop",children:e.map(c=>t.jsxs("button",{type:"button",className:"w-combo-opt",onClick:()=>{s(c),l(!1)},children:[c.name,c.id===(a==null?void 0:a.id)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ge,{size:13})})]},c.id))})]})},Kc=({mode:e,organizationId:a,onSuccess:s,onCancel:r,onCreateOrganization:i})=>{var ce;const l=e==="org",m=l?"organization":"workspace",c=l?"Organization":"Workspace",{createOrganization:d,getOrganizationRoles:p,inviteOrganizationMember:u}=Dt(),{createWorkspace:f,getWorkspaceRoles:h,createWorkspaceInvitation:g}=xa(),{organizationMemberships:x}=ga(),{refetch:w}=it(),[b,j]=o.useState(0),[v,k]=o.useState(""),[N,_]=o.useState(""),[C,y]=o.useState(),[E,M]=o.useState(null),[F,A]=o.useState(!1),[T,P]=o.useState(null),[S,$]=o.useState(a),[H,R]=o.useState(!1),O=o.useRef(null),Z=o.useRef(null),[L,U]=o.useState(null),[D,Y]=o.useState([]),[B,Q]=o.useState([]),[ue,we]=o.useState(""),[ne,ae]=o.useState(null),re=(ce=x==null?void 0:x.find(W=>W.organization.id===S))==null?void 0:ce.organization;o.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]),o.useEffect(()=>{if(!H)return;const W=G=>{O.current&&!O.current.contains(G.target)&&R(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[H]);const Me=W=>{var K;const G=(K=W.target.files)==null?void 0:K[0];if(G){if(G.size>2*1024*1024){P("Image must be under 2 MB.");return}if(!G.type.startsWith("image/")){P("Please choose a valid image file.");return}E&&URL.revokeObjectURL(E),P(null),y(G),M(URL.createObjectURL(G))}},q=async()=>{var K;const W=Ri(v),G=Ri(N);if(!Bm(W)){P(`Enter a valid ${m} name (2–100 characters).`);return}if(!l&&!S){P("Select an organization first.");return}A(!0),P(null);try{if(l){const V=await d({name:W,description:G,image:C}),de=((K=V==null?void 0:V.data)==null?void 0:K.organization)??(V==null?void 0:V.organization)??V;U(de);const z=await p(de).catch(()=>[]);Y(z),ae(Li(z,"Member"))}else{const V=await f(S,W,C,G),de=(V==null?void 0:V.workspace)??V,z={...de,organization:{id:S}};U(z);const le=await h(de).catch(()=>[]);Y(le),ae(Li(le,"Editor"))}await w(),j(1)}catch(V){P((V==null?void 0:V.message)||`Failed to create ${m}.`)}finally{A(!1)}},tt=()=>{const W=ue.trim();!Gm(W)||B.some(G=>G.email===W)||ne&&(Q(G=>[...G,{email:W,roleId:ne.id,roleName:ne.name}]),we(""))},Ie=W=>{(W.key==="Enter"||W.key===",")&&(W.preventDefault(),tt())},De=async()=>{if(!B.length){j(2);return}A(!0),P(null);try{for(const W of B)l?await u(L,{email:W.email,organizationRole:{id:W.roleId}}):await g(L,W.email,W.roleId);j(2)}catch(W){P((W==null?void 0:W.message)||"Some invitations could not be sent.")}finally{A(!1)}},Ee=()=>{j(0),k(""),_(""),y(void 0),E&&URL.revokeObjectURL(E),M(null),U(null),Y([]),Q([]),we(""),P(null)};return t.jsxs("div",{className:"w-card w-create-card",children:[t.jsxs("div",{className:"w-create-body",children:[t.jsxs("div",{className:"w-flex-col w-items-center w-gap-3 w-create-head",children:[b===0?t.jsxs("span",{className:"w-ibadge-wrap",children:[t.jsxs("button",{type:"button",className:"w-ibadge w-avatar-edit","data-busy":F?"":void 0,onClick:()=>{var W;return(W=Z.current)==null?void 0:W.click()},title:`Upload ${m} logo`,"aria-label":`Upload ${m} logo`,children:[E?t.jsx("img",{src:E,alt:`${c} logo`}):l?t.jsx(hs,{}):t.jsx(pi,{}),t.jsx("span",{className:"w-avatar-veil",children:t.jsx(nn,{})})]}),t.jsx("input",{ref:Z,type:"file",className:"w-none",hidden:!0,accept:"image/png, image/jpeg, image/gif, image/svg+xml",onChange:Me,disabled:F}),E&&t.jsx("button",{type:"button",className:"w-ibadge-x",title:"Remove logo","aria-label":"Remove logo",onClick:()=>{E&&URL.revokeObjectURL(E),M(null),y(void 0)},children:t.jsx(Pa,{})})]}):t.jsx("span",{className:`w-ibadge${b===2?" w-ibadge--done":""}`,children:b===2?t.jsx(Ge,{}):l?t.jsx(hs,{}):t.jsx(pi,{})}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-text-center",children:[t.jsx("h1",{className:"w-title-lg",children:b===0?`Create ${l?"an":"a"} ${m}`:b===1?"Invite your team":`${c} created`}),t.jsx("p",{className:"w-sub",children:b===0?`Set up a new ${m}${l?" to collaborate with your team.":" inside your organization."}`:b===1?"Add people now, or skip and do it later.":`${v} is ready to go.`})]})]}),b<2&&t.jsxs("div",{className:"w-steps w-create-steps",children:[t.jsx("i",{"data-on":""}),t.jsx("i",{"data-on":b>=1?"":void 0})]}),T&&t.jsx("div",{className:"w-banner w-banner--error w-mb-4",children:T}),b===0&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[!l&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Organization"}),t.jsxs("div",{className:"w-relative",ref:O,children:[t.jsxs("button",{type:"button",className:"w-combo w-full","data-open":H?"":void 0,onClick:()=>R(W=>!W),disabled:F,children:[t.jsxs("span",{className:"w-combo-val w-inline w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:re!=null&&re.image_url?t.jsx("img",{src:re.image_url,alt:re.name}):Zs((re==null?void 0:re.name)||"O").charAt(0)}),t.jsx("span",{children:(re==null?void 0:re.name)||"Select organization"})]}),t.jsx(Wt,{size:14})]}),H&&t.jsxs("div",{className:"w-combo-menu w-combo-menu--pop",children:[x==null?void 0:x.map(W=>{var K;const G=!!((K=W.eligibility_restriction)!=null&&K.type)&&W.eligibility_restriction.type!=="none";return t.jsxs("button",{type:"button",className:"w-combo-opt",disabled:G,"data-disabled":G?"":void 0,onClick:()=>{G||($(W.organization.id),R(!1))},children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:W.organization.image_url?t.jsx("img",{src:W.organization.image_url,alt:W.organization.name}):Zs(W.organization.name).charAt(0)}),t.jsx("span",{children:W.organization.name})]},W.organization.id)}),i&&t.jsxs("button",{type:"button",className:"w-combo-opt w-text-primary",onClick:()=>{R(!1),i()},children:[t.jsx(St,{size:13}),"Create new organization"]})]})]})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:[c," name"]}),t.jsx(be,{autoFocus:!0,value:v,onChange:W=>k(W.target.value),placeholder:l?"Acme Inc":"Product",disabled:F})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Description"," ",t.jsx("span",{className:"w-secsub",children:"· optional"})]}),t.jsx(be,{as:"textarea",className:"w-input--area",value:N,onChange:W=>_(W.target.value),placeholder:l?"What does your team do?":"What's this workspace for?",disabled:F})]}),t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:q,disabled:F||!v.trim(),children:F?t.jsx(_e,{size:15}):t.jsxs(t.Fragment,{children:["Continue",t.jsx(Jt,{size:15})]})}),r&&t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-btn--block",onClick:r,disabled:F,children:"Cancel"})]})]}),b===1&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Invite by email"}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(be,{autoFocus:!0,className:"w-grow",value:ue,onChange:W=>we(W.target.value),onKeyDown:Ie,placeholder:"teammate@acme.com"}),t.jsx(qm,{roles:D,value:ne,onChange:ae})]}),t.jsx("span",{className:"w-secsub",children:"Press Enter to add each person."})]}),B.length>0&&t.jsx("div",{className:"w-list",children:B.map(W=>t.jsxs("div",{className:"w-row",style:{gridTemplateColumns:"1fr auto",padding:"10px 0"},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:Zs(W.email)}),t.jsx("span",{className:"w-truncate w-text-secondary",children:W.email})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-pill",children:W.roleName}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",title:"Remove",onClick:()=>Q(G=>G.filter(K=>K.email!==W.email)),children:t.jsx(Pa,{size:13})})]})]},W.email))}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-none",onClick:()=>j(2),disabled:F,children:"Skip"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-grow",onClick:De,disabled:F,children:F?t.jsx(_e,{size:15}):B.length?`Invite ${B.length} & finish`:"Finish"})]})]}),b===2&&t.jsxs("div",{className:"w-flex-col w-items-center w-gap-4",children:[t.jsxs("div",{className:"w-create-summary",children:[t.jsx("span",{className:"w-avatar w-avatar--md",children:E?t.jsx("img",{src:E,alt:v}):Zs(v)}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:v}),t.jsx("span",{className:"w-secsub",children:B.length?`${B.length} invite${B.length>1?"s":""} sent`:"No invites yet"})]})]}),t.jsxs("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>s==null?void 0:s(L),children:["Go to ",m,t.jsx(Jt,{size:15})]}),t.jsxs("button",{type:"button",className:"w-link w-link--muted w-linkbtn w-inline w-gap-1",onClick:Ee,children:[t.jsx(Uo,{size:12})," Create another"]})]})]}),b===0&&t.jsx("div",{className:"w-create-foot",children:t.jsx("span",{className:"w-secsub",children:l?"Organizations group your team, billing and settings.":"Workspaces live inside an organization."})})]})},pn=({onSuccess:e,onCancel:a})=>t.jsx(Re,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Kc,{mode:"org",onSuccess:e,onCancel:a})})}),Yc=({isOpen:e,onClose:a,onCreated:s})=>{const r=()=>{s==null||s(),a==null||a()};return t.jsx(Re,{children:t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsx(ze.Content,{className:"w-dialog--create",children:t.jsx(pn,{onSuccess:r,onCancel:a})})})})})},Mr=o.createContext({screen:null,setScreen:()=>{},toast:(e,a)=>{}}),Ct=()=>{const e=o.useContext(Mr);if(!e)throw new Error("useScreenContext must be used within a ScreenContextProvider");return e},Ja=({title:e,description:a,onConfirm:s,onCancel:r,style:i})=>{const l=o.useRef(null);return o.useEffect(()=>{const m=c=>{l.current&&!l.current.contains(c.target)&&r()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[r]),t.jsxs("div",{ref:l,className:"w-pop",style:{position:"fixed",zIndex:1e3,right:44,...i},children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("h3",{className:"w-pop-title",children:e}),a&&t.jsx("p",{className:"w-pop-sub",children:a})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:r,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:s,children:"Confirm"})]})]})},Pi=[{id:"okta",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"saml",description:"SAML",docUrl:"https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_saml.htm",placeholders:{entityId:"http://www.okta.com/{yourOktaDomain}",ssoUrl:"https://{yourOktaDomain}.okta.com/app/{appId}/sso/saml"},attributeMapping:{first_name:"firstName",last_name:"lastName",email:"email"}},{id:"okta-oidc",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"oidc",description:"OIDC",docUrl:"https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/",placeholders:{issuerUrl:"https://{yourOktaDomain}.okta.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"azure",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso",placeholders:{entityId:"https://sts.windows.net/{tenantId}/",ssoUrl:"https://login.microsoftonline.com/{tenantId}/saml2"},attributeMapping:{first_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",last_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",email:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"}},{id:"azure-oidc",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"oidc",description:"OIDC",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc",placeholders:{issuerUrl:"https://login.microsoftonline.com/{tenantId}/v2.0",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"google",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"saml",description:"SAML",docUrl:"https://support.google.com/a/answer/6087519",placeholders:{entityId:"https://accounts.google.com/o/saml2?idpid={idpId}",ssoUrl:"https://accounts.google.com/o/saml2/idp?idpid={idpId}"},attributeMapping:{first_name:"FirstName",last_name:"LastName",email:"email"}},{id:"google-oidc",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"oidc",description:"OIDC",docUrl:"https://developers.google.com/identity/openid-connect/openid-connect",placeholders:{issuerUrl:"https://accounts.google.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"auth0",name:"Auth0",logo:"https://cdn.auth0.com/styleguide/latest/lib/logos/img/badge.png",protocol:"oidc",description:"OIDC",docUrl:"https://auth0.com/docs/authenticate/protocols/openid-connect-protocol",placeholders:{issuerUrl:"https://{yourDomain}.auth0.com/",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"onelogin",name:"OneLogin",logo:"",protocol:"saml",description:"SAML",docUrl:"https://onelogin.service-now.com/support?id=kb_article&sys_id=912bb23adbdc1cd0ca1c400e0b96197d",placeholders:{entityId:"https://app.onelogin.com/saml/metadata/{appId}",ssoUrl:"https://{subdomain}.onelogin.com/trust/saml2/http-post/sso/{appId}"}},{id:"ping",name:"PingOne",logo:"",protocol:"saml",description:"SAML",docUrl:"https://docs.pingidentity.com/pingone/latest/connector/configure-saml.html",placeholders:{entityId:"https://auth.pingone.com/{envId}",ssoUrl:"https://auth.pingone.com/{envId}/saml20/idp/sso"}},{id:"jumpcloud",name:"JumpCloud",logo:"",protocol:"saml",description:"SAML",docUrl:"https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-saml",placeholders:{entityId:"https://sso.jumpcloud.com/saml2/{appId}",ssoUrl:"https://sso.jumpcloud.com/saml2/{appId}"}},{id:"duo",name:"Duo",logo:"",protocol:"saml",description:"SAML",docUrl:"https://duo.com/docs/sso",placeholders:{entityId:"https://sso.duosecurity.com/saml2/sp/{appId}",ssoUrl:"https://sso.duosecurity.com/saml2/idp/{appId}/sso"}},{id:"keycloak",name:"Keycloak",logo:"https://www.keycloak.org/resources/images/icon.svg",protocol:"oidc",description:"OIDC",docUrl:"https://www.keycloak.org/docs/latest/securing_apps/",placeholders:{issuerUrl:"https://{host}/realms/{realm}",scopes:"openid profile email"}},{id:"adfs",name:"ADFS",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Microsoft_logo.svg/100px-Microsoft_logo.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-relying-party-trust",placeholders:{entityId:"http://{adfsServer}/adfs/services/trust",ssoUrl:"https://{adfsServer}/adfs/ls/"}},{id:"custom-saml",name:"Custom",logo:"",protocol:"saml",description:"SAML",docUrl:"",placeholders:{}},{id:"custom-oidc",name:"Custom",logo:"",protocol:"oidc",description:"OIDC",docUrl:"",placeholders:{}}],Km=({template:e})=>{const[a,s]=o.useState(!1);return!e.logo||a?t.jsx("span",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo--ph",children:t.jsx(ea,{size:18,className:"w-text-muted"})}):t.jsx("img",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo",src:e.logo,alt:e.name,onError:()=>s(!0)})},Ym=({organization:e})=>{const{getEnterpriseConnections:a,createEnterpriseConnection:s,deleteEnterpriseConnection:r,testEnterpriseConnection:i,generateSCIMToken:l,getSCIMToken:m,revokeSCIMToken:c}=Dt(),{toast:d}=Ct(),[p,u]=o.useState(!1),[f,h]=o.useState(null),{data:g=[],isLoading:x,mutate:w}=Ce(e!=null&&e.id?`wacht-org-sso:${e.id}`:null,async()=>await(a==null?void 0:a(e))||[],{refreshInterval:3e4,revalidateOnFocus:!1}),b=async j=>{try{await(r==null?void 0:r(e,j)),w(),d("SSO connection deleted","info")}catch(v){d(v.message||"Failed to delete connection","error")}h(null)};return x?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):p?t.jsx(Jm,{organization:e,onClose:()=>u(!1),onCreate:async j=>{try{await(s==null?void 0:s(e,j)),w(),u(!1),d("SSO connection created","info")}catch(v){d(v.message||"Failed to create connection","error")}}}):t.jsx(t.Fragment,{children:g.length===0?t.jsxs("div",{className:"w-empty w-empty--fill",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(ea,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"Enterprise SSO"}),t.jsx("p",{children:"Let members sign in with your identity provider."})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{onClick:()=>u(!0),children:[t.jsx(St,{size:16})," Configure SSO"]})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-sechead",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-title",children:"Enterprise SSO"}),t.jsx("p",{className:"w-sub",children:"Configure SAML or OIDC SSO for your organization"})]})}),g.map(j=>t.jsx(Qm,{connection:j,onDelete:v=>h(v),connectionToDelete:f,onConfirmDelete:b,onCancelDelete:()=>h(null),testConnection:v=>i(e,v),generateSCIMToken:v=>l(e,v),getSCIMToken:v=>m(e,v),revokeSCIMToken:v=>c(e,v),toast:d},j.id))]})})},Qm=({connection:e,onDelete:a,connectionToDelete:s,onConfirmDelete:r,onCancelDelete:i,testConnection:l,generateSCIMToken:m,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var F,A,T,P,S;const[u,f]=o.useState(null),[h,g]=o.useState(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),[v,k]=o.useState(!1),[N,_]=o.useState(null);o.useEffect(()=>{c&&e.id&&c(e.id).then(f).catch(()=>{})},[e.id,c]);const C=async()=>{if(l){k(!0),_(null);try{const $=await l(e.id);_($)}catch($){_({success:!1,checks:{},errors:{general:$.message||"Test failed"}})}finally{k(!1)}}},y=async()=>{if(m){g(!0);try{const $=await m(e.id);w($.token),f({exists:!0,token:$}),p("SCIM token generated. Copy it now - it won't be shown again!","info")}catch($){p($.message||"Failed to generate token","error")}finally{g(!1)}}},E=async()=>{if(d){g(!0);try{await d(e.id),f({exists:!1,scim_base_url:u==null?void 0:u.scim_base_url}),w(null),p("SCIM token revoked","info")}catch($){p($.message||"Failed to revoke token","error")}finally{g(!1)}}},M=($,H)=>{navigator.clipboard.writeText($),j(H),setTimeout(()=>j(null),2e3)};return t.jsxs("div",{className:"w-flex-col w-gap-4 w-sso-conn",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-start",children:[t.jsxs("h3",{className:"w-sec w-inline w-gap-2",children:[t.jsx(ea,{size:16}),e.protocol==="oidc"?"OIDC SSO":"SAML SSO",t.jsx("span",{className:"w-pill w-pill--current",children:e.protocol.toUpperCase()})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(se,{$size:"sm",onClick:C,disabled:v,children:v?t.jsx(_e,{size:14}):"Test"}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>a(e.id),className:"w-text-error",children:"Remove"}),s===e.id&&t.jsx(Ja,{title:"Delete this SSO connection?",onConfirm:()=>r(e.id),onCancel:i})]})]})]}),N&&t.jsx("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"}`,children:t.jsxs("span",{className:`w-banner-txt w-flex-col w-gap-1 ${N.success?"w-text-success":"w-text-error"}`,children:[t.jsx("span",{children:N.success?"✓ Connection is valid":"✗ Connection failed"}),N.errors&&Object.entries(N.errors).map(([$,H])=>t.jsxs("div",{children:[$.replace(/_/g," "),": ",H]},$))]})}),t.jsxs("div",{className:"w-sso-detail",children:[e.protocol==="saml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Entity ID"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_entity_id}),t.jsx("span",{className:"w-secsub",children:"SSO URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_sso_url})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Issuer URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.oidc_issuer_url}),t.jsx("span",{className:"w-secsub",children:"Client ID"}),t.jsx("span",{className:"w-sec",children:e.oidc_client_id}),t.jsx("span",{className:"w-secsub",children:"Scopes"}),t.jsx("span",{className:"w-sec",children:e.oidc_scopes||"openid profile email"})]}),t.jsx("span",{className:"w-secsub",children:"Created"}),t.jsx("span",{className:"w-sec",children:new Date(e.created_at).toLocaleDateString()})]}),t.jsxs("div",{className:"w-flex-col w-gap-3 w-sso-scim",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center",children:[t.jsxs("div",{className:"w-sec w-inline w-gap-2",children:[t.jsx(ea,{size:14}),"SCIM Provisioning"]}),t.jsx("div",{className:"w-flex w-wrap w-gap-2",children:!(u!=null&&u.exists)||!((F=u==null?void 0:u.token)!=null&&F.enabled)?t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Rotate"}),t.jsx(se,{$size:"sm",$outline:!0,onClick:E,disabled:h,className:"w-text-error",children:"Revoke"})]})})]}),(((A=u==null?void 0:u.token)==null?void 0:A.scim_base_url)||x)&&t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Base URL:"}),t.jsx("code",{children:((T=u==null?void 0:u.token)==null?void 0:T.scim_base_url)||"Loading..."}),((P=u==null?void 0:u.token)==null?void 0:P.scim_base_url)&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>M(u.token.scim_base_url,"scim-url"),children:b==="scim-url"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]}),x&&t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Token:"}),t.jsx("code",{children:x}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>M(x,"scim-token"),children:b==="scim-token"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]}),t.jsx("div",{className:"w-mono-faint w-text-warning",children:"⚠️ Copy this token now. It won't be shown again."})]}),(u==null?void 0:u.exists)&&((S=u==null?void 0:u.token)==null?void 0:S.enabled)&&!x&&t.jsxs("div",{className:"w-secsub",children:["Token:"," ",t.jsxs("code",{className:"w-mono-sm w-token-chip",children:[u.token.token_prefix,"..."]}),u.token.last_used_at&&t.jsxs("span",{children:[" ","· Last used:"," ",new Date(u.token.last_used_at).toLocaleDateString()]})]})]})]})},Jm=({onCreate:e,organization:a})=>{const{getOrganizationDomains:s,testEnterpriseConnectionConfig:r}=Dt(),{deployment:i}=je(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(null),[u,f]=o.useState("saml"),[h,g]=o.useState(null),[x,w]=o.useState(!1),[b,j]=o.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:""}),[v,k]=o.useState(!1),[N,_]=o.useState(null),{data:C=[],isLoading:y}=Ce("wacht-org-verified-domains-for-sso-screen",async()=>(await(s==null?void 0:s(a))||[]).filter(R=>R.verified),{revalidateOnFocus:!1}),E=H=>{p(H),f(H.protocol),H.protocol==="saml"?j(R=>{var O,Z,L;return{...R,idp_entity_id:H.placeholders.entityId||"",idp_sso_url:H.placeholders.ssoUrl||"",attr_first_name:((O=H.attributeMapping)==null?void 0:O.first_name)||"",attr_last_name:((Z=H.attributeMapping)==null?void 0:Z.last_name)||"",attr_email:((L=H.attributeMapping)==null?void 0:L.email)||""}}):j(R=>{var O,Z,L;return{...R,oidc_issuer_url:H.placeholders.issuerUrl||"",oidc_scopes:H.placeholders.scopes||"openid profile email",attr_first_name:((O=H.attributeMapping)==null?void 0:O.first_name)||"",attr_last_name:((Z=H.attributeMapping)==null?void 0:Z.last_name)||"",attr_email:((L=H.attributeMapping)==null?void 0:L.email)||""}})},M=i!=null&&i.backend_host?`${i.backend_host.startsWith("https://")?"":"https://"}${i.backend_host}/auth/sso/oidc/callback`:"",F=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/metadata`:"",A=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/callback`:"",T=(H,R)=>{navigator.clipboard.writeText(H),g(R),setTimeout(()=>g(null),2e3)},P=async H=>{H.preventDefault();const R=O=>O.includes("{")||O.includes("}");if(u==="saml"){if(!b.idp_entity_id||R(b.idp_entity_id)){l("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||R(b.idp_sso_url)){l("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){l("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||R(b.oidc_issuer_url)){l("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||R(b.oidc_client_id)){l("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){l("Please enter the Client Secret","error");return}}c(!0);try{const O={};b.attr_first_name&&(O.first_name=b.attr_first_name),b.attr_last_name&&(O.last_name=b.attr_last_name),b.attr_email&&(O.email=b.attr_email);const Z=Object.keys(O).length>0;u==="saml"?await e({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,...Z&&{attribute_mapping:O}}):await e({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,...Z&&{attribute_mapping:O}})}finally{c(!1)}},S=async()=>{k(!0),_(null);const H=Z=>Z.includes("{")||Z.includes("}"),R={},O={};if(u==="saml"?(b.idp_entity_id?H(b.idp_entity_id)?(O.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):O.entity_id_valid=!0:(O.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?H(b.idp_sso_url)?(O.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):O.sso_url_valid=!0:(O.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?O.certificate_provided=!0:(O.certificate_provided=!1,R.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?H(b.oidc_issuer_url)?(O.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):O.issuer_url_valid=!0:(O.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?H(b.oidc_client_id)?(O.client_id_valid=!1,R.client_id_valid="Client ID contains placeholder values - please replace with actual values"):O.client_id_valid=!0:(O.client_id_valid=!1,R.client_id_valid="Client ID is required")),Object.keys(R).length>0){_({success:!1,checks:O,errors:R}),k(!1);return}try{const Z=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(r==null?void 0:r(a,Z));L&&_(L)}catch(Z){_({success:!1,checks:{},errors:{general:"Test failed: "+Z.message}})}finally{k(!1)}},$=H=>t.jsx(Km,{template:H});return t.jsxs("form",{onSubmit:P,autoComplete:"off",className:"w-flex-col w-gap-4",children:[d?t.jsxs("div",{className:"w-flex w-items-center w-gap-4 w-sso-template",children:[$(d),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:d.name}),t.jsx("div",{className:"w-eyebrow",children:d.protocol})]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:()=>p(null),children:"Change"})]}):t.jsxs("div",{className:"w-flex-col w-gap-5",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"SAML Providers"}),t.jsx("div",{className:"w-grid-4",children:Pi.filter(H=>H.protocol==="saml").map(H=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(H),children:[$(H),t.jsx("span",{className:"w-secsub",children:H.name})]},H.id))})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"OIDC Providers"}),t.jsx("div",{className:"w-grid-4",children:Pi.filter(H=>H.protocol==="oidc").map(H=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(H),children:[$(H),t.jsx("span",{className:"w-secsub",children:H.name})]},H.id))})]})]}),d&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-sec",children:"Service Provider Details"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"ACS URL:"}),t.jsx("code",{children:A}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(A,"acs"),children:h==="acs"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]}),t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Metadata:"}),t.jsx("code",{children:F}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(F,"metadata"),children:h==="metadata"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]})]}):t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Callback:"}),t.jsx("code",{children:M}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(M,"callback"),children:h==="callback"?t.jsx(Ge,{size:12}):t.jsx(qa,{size:12})})]})})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:d?`${d.name} Configuration`:"Configuration"}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[d&&d.docUrl&&t.jsxs("a",{href:d.docUrl,target:"_blank",rel:"noopener noreferrer",className:"w-link w-link--sm w-text-primary w-inline w-gap-1",children:[t.jsx(Eu,{size:12})," Docs"]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:S,disabled:v||!d,children:v?t.jsx(_e,{size:16}):"Test Connection"}),t.jsx(se,{$size:"sm",type:"submit",disabled:m||C.length===0||!d,children:m?t.jsx(_e,{size:16}):"Create Connection"})]})]}),N&&(()=>{const H={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 t.jsxs("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"} w-flex-col w-gap-3`,children:[t.jsx("div",{className:`w-sec ${N.success?"w-text-success":"w-text-error"}`,children:N.success?"✓ All checks passed":"✗ Some checks failed"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:Object.entries(N.checks).map(([R,O])=>{var Z;return t.jsxs("div",{className:"w-flex w-items-start w-gap-2 w-sso-check",children:[t.jsx("span",{className:`w-sso-check-mark ${O?"w-text-success":"w-text-error"}`,children:O?"✓":"✗"}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:H[R]||R.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((Z=N.errors)==null?void 0:Z[R])&&t.jsx("div",{className:"w-secsub w-text-error",children:N.errors[R]})]})]},R)})})]})})(),t.jsxs("div",{className:"w-grid-2",children:[!d&&t.jsxs(We,{children:[t.jsx(Te,{children:"Protocol *"}),t.jsxs("select",{className:"w-input",value:u,onChange:H=>f(H.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(We,{className:"w-col-full",children:[t.jsx(Te,{children:"Domain *"}),y?t.jsx("div",{className:"w-secsub",children:"Loading domains..."}):C.length===0?t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"No verified domains found. Please add and verify a domain first."})}):t.jsxs("select",{className:"w-input",value:b.domain_id,onChange:H=>j({...b,domain_id:H.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),C.map(H=>t.jsx("option",{value:H.id,children:H.fqdn},H.id))]})]}),u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(We,{children:[t.jsx(Te,{children:"IdP Entity ID *"}),t.jsx(be,{type:"text",value:b.idp_entity_id,onChange:H=>j({...b,idp_entity_id:H.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"IdP SSO URL *"}),t.jsx(be,{type:"url",value:b.idp_sso_url,onChange:H=>j({...b,idp_sso_url:H.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(We,{className:"w-col-full",children:[t.jsx(Te,{children:"X.509 Certificate *"}),t.jsx(be,{as:"textarea",value:b.idp_certificate,onChange:H=>j({...b,idp_certificate:H.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0,className:"w-input--area w-input--mono"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(We,{children:[t.jsx(Te,{children:"Issuer URL *"}),t.jsx(be,{type:"url",value:b.oidc_issuer_url,onChange:H=>j({...b,oidc_issuer_url:H.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Client ID *"}),t.jsx(be,{type:"text",value:b.oidc_client_id,onChange:H=>j({...b,oidc_client_id:H.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Client Secret *"}),t.jsx(be,{type:"password",value:b.oidc_client_secret,onChange:H=>j({...b,oidc_client_secret:H.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Scopes"}),t.jsx(be,{type:"text",value:b.oidc_scopes,onChange:H=>j({...b,oidc_scopes:H.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(We,{className:"w-col-full",children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:"Enable JIT Provisioning"}),t.jsx("div",{className:"w-secsub",children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),t.jsx(Ha,{checked:b.jit_enabled,onChange:()=>j({...b,jit_enabled:!b.jit_enabled})})]})}),t.jsxs("div",{className:"w-col-full w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-inline w-gap-2 w-text-primary w-disclosure",onClick:()=>w(!x),children:[t.jsx("span",{className:"w-disclosure-caret",children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-secsub",children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),t.jsxs("div",{className:"w-grid-3",children:[t.jsxs(We,{children:[t.jsx(Te,{children:"First Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_first_name,onChange:H=>j({...b,attr_first_name:H.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Last Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_last_name,onChange:H=>j({...b,attr_last_name:H.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Email Attribute"}),t.jsx(be,{type:"text",value:b.attr_email,onChange:H=>j({...b,attr_email:H.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ht=(...e)=>e.filter(Boolean).join(" "),$i=({className:e,...a})=>t.jsx("div",{className:ht("w-contents",e),...a}),Hn=({className:e,...a})=>t.jsx("div",{className:ht("w-card","w-flex-col","w-full","w-minh-full",e),...a}),Xm=({className:e,...a})=>t.jsx("div",{className:ht("w-tabsbar",e),...a}),e4=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),Da=({className:e,$isActive:a,...s})=>t.jsx("button",{className:ht("w-tab",a&&"w-tab--active",e),...s}),Ua=({className:e,...a})=>t.jsx("span",{className:ht("w-inline","w-gap-2",e),...a}),t4=({className:e,children:a,...s})=>t.jsx("div",{className:ht("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Rr=({className:e,...a})=>t.jsx("div",{className:ht("w-sechead",e),...a}),Oi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Zi=({className:e,...a})=>t.jsx("div",{className:ht("w-grow",e),...a}),Hi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-3","w-none",e),...a}),hn=({className:e,...a})=>t.jsx("div",{className:ht("w-full",e),...a}),a4=({className:e,...a})=>t.jsx("div",{className:ht("w-page-head",e),...a}),s4=({className:e,...a})=>t.jsx("div",{className:ht("w-grow","w-flex-col","w-gap-1",e),...a}),n4=({className:e,...a})=>t.jsx("div",{className:ht("w-sec","w-truncate",e),...a}),r4=({className:e,...a})=>t.jsx("div",{className:ht("w-secsub","w-truncate",e),...a}),i4={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},ha=({className:e,$variant:a="neutral",children:s,...r})=>t.jsxs("span",{className:ht("w-pill",i4[a],e),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),Fi=({className:e,$first:a,...s})=>t.jsx("div",{className:ht("w-sec",e),...s}),o4=({organization:e})=>{var A,T,P,S,$,H;const{switchOrganization:a,refetch:s}=it(),{workspaces:r}=xa(),{deployment:i}=je(),{deleteOrganization:l,updateOrganization:m}=Dt(),{toast:c}=Ct(),[d,p]=o.useState((e==null?void 0:e.name)||""),[u,f]=o.useState((e==null?void 0:e.description)||""),[h,g]=o.useState(!1),[x,w]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,j]=o.useState(""),[v,k]=o.useState(!1),[N,_]=o.useState(!1),C=o.useRef({name:d,description:u,security:x,isSaving:h});o.useEffect(()=>{C.current={name:d,description:u,security:x,isSaving:h}},[d,u,x,h]);const y=o.useCallback(async()=>{if(!e)return;const R=C.current;try{g(!0),await m(e,{name:R.name,description:R.description,whitelisted_ips:R.security.allowed_ips.split(`
103
103
  `).filter(O=>O.trim()),enable_ip_restriction:R.security.ip_restrictions,enforce_mfa:R.security.mfa_required,auto_assigned_workspace_id:R.security.default_workspace_id||"0"}),c("Changes saved","info")}catch(O){c(O.message||"Failed to save changes","error")}finally{g(!1)}},[e,m,c]),E=o.useCallback(()=>{C.current.isSaving||y()},[y]);o.useEffect(()=>{var R;e&&(p(e.name||""),f(e.description||""),w({allowed_ips:((R=e.whitelisted_ips)==null?void 0:R.join(`
104
104
  `))||"",ip_restrictions:e.enable_ip_restriction||!1,mfa_required:e.enforce_mfa||!1,default_workspace_id:e.auto_assigned_workspace_id||""}))},[e]);const M=o.useMemo(()=>r.filter(R=>R.organization.id===(e==null?void 0:e.id)),[r,e==null?void 0:e.id]),F=async()=>{if(!(!e||b!==e.name))try{k(!0),await a(""),await l(e),await s(),c("Organization deleted","info")}catch{c("Failed to delete organization","error")}finally{k(!1),j("")}};return e?t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"name",children:"Organization name"}),t.jsx(be,{id:"name",value:d,onChange:R=>p(R.target.value),onBlur:E,placeholder:"Organization name",required:!0})]}),t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"description",children:"Description"}),t.jsx(be,{id:"description",as:"textarea",value:u,onChange:R=>f(R.target.value),onBlur:E,placeholder:"Optional description",className:"w-input--area"})]}),((A=i==null?void 0:i.b2b_settings)==null?void 0:A.workspaces_enabled)&&M.length>0&&t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"default_workspace",children:"Default workspace"}),t.jsx(mn,{options:M.map(R=>({value:R.id,label:R.name})),value:x.default_workspace_id,onChange:R=>{w(O=>({...O,default_workspace_id:R})),setTimeout(E,0)},placeholder:"Select default workspace"})]})]}),(((T=i==null?void 0:i.b2b_settings)==null?void 0:T.enforce_mfa_per_org_enabled)||((P=i==null?void 0:i.b2b_settings)==null?void 0:P.ip_allowlist_per_org_enabled))&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Fi,{children:"Security"}),((S=i==null?void 0:i.b2b_settings)==null?void 0:S.enforce_mfa_per_org_enabled)&&t.jsxs(Oi,{children:[t.jsxs(Zi,{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Multi-factor authentication"}),t.jsx("p",{className:"w-secsub",children:"Require all members to set up MFA for added security."})]}),t.jsx(Hi,{children:t.jsx(Ha,{checked:x.mfa_required,onChange:()=>{const R=!x.mfa_required;w(O=>({...O,mfa_required:R})),setTimeout(E,0)}})})]}),(($=i==null?void 0:i.b2b_settings)==null?void 0:$.ip_allowlist_per_org_enabled)&&t.jsxs(t.Fragment,{children:[t.jsxs(Oi,{children:[t.jsxs(Zi,{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"IP restrictions"}),t.jsx("p",{className:"w-secsub",children:"Only allow access from specific IP addresses."})]}),t.jsx(Hi,{children:t.jsx(Ha,{checked:x.ip_restrictions,onChange:()=>{const R=!x.ip_restrictions;w(O=>({...O,ip_restrictions:R})),setTimeout(E,0)}})})]}),x.ip_restrictions&&t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(be,{id:"allowed_ips",as:"textarea",value:x.allowed_ips,onChange:R=>w(O=>({...O,allowed_ips:R.target.value})),onBlur:E,placeholder:`192.168.1.1
105
- 10.0.0.0/24`,className:"w-input--area w-input--mono"})]})]})]}),((H=i==null?void 0:i.b2b_settings)==null?void 0:H.allow_org_deletion)&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Fi,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start w-gap-3",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-full",children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete organization"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this organization, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{_(!N),j("")},children:N?"Cancel":"Delete organization"})]}),N&&t.jsxs("div",{className:"w-flex-col w-gap-3 w-full",children:[t.jsxs(We,{children:[t.jsxs(Te,{htmlFor:"confirm_org_name",children:["Type"," ",t.jsx("strong",{children:e.name})," ","to confirm"]}),t.jsx(be,{id:"confirm_org_name",type:"text",value:b,onChange:R=>j(R.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:F,disabled:b!==e.name||v,children:v?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})]}):t.jsx(_e,{})},Lr=(e,a)=>a?`${e} ${a}`:e,Ht=o.forwardRef(({className:e,...a},s)=>t.jsx("table",{ref:s,className:Lr("w-table",e),...a}));Ht.displayName="Table";const Ft=o.forwardRef((e,a)=>t.jsx("thead",{ref:a,...e}));Ft.displayName="TableHead";const Tt=o.forwardRef((e,a)=>t.jsx("tbody",{ref:a,...e}));Tt.displayName="TableBody";const rt=o.forwardRef((e,a)=>t.jsx("tr",{ref:a,...e}));rt.displayName="TableRow";const Oe=o.forwardRef((e,a)=>t.jsx("th",{ref:a,...e}));Oe.displayName="TableHeader";const Qe=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:e,...a}));Qe.displayName="TableCell";const lm=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Lr("w-td--flex",e),...a}));lm.displayName="TableCellFlex";const It=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Lr("w-td--actions",e),...a}));It.displayName="ActionsCell";const Nt=({title:e,description:a,icon:s,action:r})=>t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:s??t.jsx(Bu,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:e}),t.jsx("p",{children:a})]}),r&&t.jsx("div",{className:"w-empty-action",children:r})]}),bt=({triggerRef:e,isOpen:a,minWidth:s=300,defaultMaxHeight:r=400,offset:i=8,contentRef:l})=>{const[m,c]=o.useState();return o.useEffect(()=>{if(!a||!e.current){c(void 0);return}const d=()=>{var N;if(!e.current)return;const u=e.current.getBoundingClientRect(),f=window.innerWidth,h=window.innerHeight,g=((N=l==null?void 0:l.current)==null?void 0:N.offsetWidth)||s,x=h-u.bottom,w=u.top,b={};x>=w?(b.top=u.bottom+i,b.maxHeight=Math.min(r,x-i*2)):(b.bottom=h-u.top+i,b.maxHeight=Math.min(r,w-i*2));const j=f-u.left,v=u.right,k=j>=v?u.left:u.right-g;b.left=Math.max(i,Math.min(f-g-i,k)),c(b)},p=requestAnimationFrame(d);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{cancelAnimationFrame(p),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[a,s,r,i,l]),m},Ti=({onClose:e,domain:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,f]=o.useState(!1),{addDomain:h,verifyDomain:g}=wa(),{toast:x}=Ct(),w=bt({contentRef:r,triggerRef:s??{current:null},isOpen:u,minWidth:360,defaultMaxHeight:420}),b=_=>/^[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(_),j=_=>_.trim().toLowerCase().replace(/^https?:\/\//,""),v=async()=>{const _=j(m);if(!_){x("Please enter a domain name","error");return}if(!b(_)){x("Please enter a valid domain (e.g., example.com)","error");return}if(_.length>253){x("Domain name is too long","error");return}p(!0);try{const C=await h({fqdn:_});x("Domain added","info"),l(C.data)}catch(C){x(C.message||"Failed to add domain. Please try again.","error")}finally{p(!1)}},k=async()=>{if(!(!i||d)){p(!0);try{await g(i),e==null||e(),x("Domain verified","info")}catch(_){x(_.message||"Failed to verify domain. Check DNS records and try again.","error")}finally{p(!1)}}};if(o.useEffect(()=>{f(!0);const _=y=>{r.current&&!r.current.contains(y.target)&&(e==null||e())},C=y=>{y.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]),o.useEffect(()=>{a&&l(a)},[a]),!u)return null;const N={position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"};return i?t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"verify-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"verify-domain-title",children:"Verify domain"}),t.jsx("p",{className:"w-pop-sub",children:"Add this DNS record, then verify."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Type"}),t.jsx(be,{value:i==null?void 0:i.verification_dns_record_type,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(be,{value:i==null?void 0:i.verification_dns_record_name,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Value"}),t.jsx(be,{value:i==null?void 0:i.verification_dns_record_data,disabled:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:d,children:d?t.jsx(_e,{size:12}):"Verify"})]})]}):t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"add-domain-title",children:"Add domain"}),t.jsx("p",{className:"w-pop-sub",children:"Verified members auto-join this org."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Domain"}),t.jsx(be,{type:"text",placeholder:"example.com",value:m,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&m&&v()},autoFocus:!0,"aria-label":"Domain name"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!m||d,children:d?t.jsx(_e,{size:12}):"Continue"})]})]})},cm=({organization:e})=>{const{getOrganizationDomains:a,removeOrganizationDomain:s}=Dt(),[r,i]=o.useState(null),[l,m]=o.useState(!1),[c,d]=o.useState(null),[p,u]=o.useState(new Set),f=o.useRef(null),h=o.useRef({}),{data:g=[],isLoading:x,mutate:w}=Ce(e!=null&&e.id?`wacht-org-domains:${e.id}`:null,async()=>(await(a==null?void 0:a(e))||[]).map(k=>({...k,verified:k.verified!==void 0?k.verified:!1}))),b=(v,k)=>{u(N=>{const _=new Set(N);return k?_.add(v):_.delete(v),_})},j=async v=>{b(v.id,!0);try{await s(e,v),w()}finally{b(v.id,!1),i(null)}};return x?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Rr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Domains"}),t.jsx("div",{className:"w-secsub",children:"Users with verified domain emails auto-join this organization."})]}),t.jsx(se,{ref:f,onClick:()=>m(!0),$size:"sm",children:"Add domain"}),l&&t.jsx(Ti,{onClose:()=>{m(!1),w()},triggerRef:f})]}),g!=null&&g.length?t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Domain"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{children:"Added"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:g.map(v=>{const k=p.has(v.id);return t.jsxs(rt,{children:[t.jsx(Qe,{children:v.fqdn}),t.jsx(Qe,{children:v.verified?t.jsx(ha,{$variant:"success",children:"Verified"}):t.jsx(ha,{$variant:"warning",children:"Pending"})}),t.jsx(Qe,{children:new Date(v.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:N=>{N&&(h.current[v.id]=N)},$size:"sm",$outline:!0,disabled:k,onClick:()=>d(v.id),children:v.verified?"View DNS":"Verify"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:k,onClick:()=>i(v.id),children:k?t.jsx(_e,{size:12}):"Remove"})]})})]},v.id)})})]})}):t.jsx(Nt,{title:"No domains added",description:"Users with verified domain emails automatically join this organization."}),r&&t.jsx(Ja,{title:"Remove domain?",description:"Active users aren't affected, but new users with this domain won't auto-join.",onConfirm:()=>{const v=g.find(k=>k.id===r);v&&j(v)},onCancel:()=>i(null)}),c&&t.jsx(Ti,{domain:g.find(v=>v.id===c),onClose:()=>d(null),triggerRef:{current:h.current[c]}})]})},Qc=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{inviteMember:g}=wa(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:360}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}u(!0);try{await g({email:k,organizationRole:c}),a==null||a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{u(!1)}}};return o.useEffect(()=>{h(!0);const k=_=>{i.current&&!i.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email"}),t.jsx(be,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&l&&c&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Role"}),t.jsx(mn,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},dm=({organization:e})=>{const{getOrganizationMembers:a,getOrganizationRoles:s,addRoleToOrganizationMember:r,removeRoleFromOrganizationMember:i,removeOrganizationMember:l}=Dt(),{session:m}=it(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(!1),[w,b]=o.useState(new Set),j=o.useRef(null),[v,k]=o.useState(d);o.useEffect(()=>{const S=setTimeout(()=>{k(d),f(1)},500);return()=>clearTimeout(S)},[d]);const{data:N,mutate:_}=Ce(e?`wacht-api-organizations:${e.id}:members:${u}:${h}:${v}`:null,()=>a==null?void 0:a(e,{page:u,limit:h,search:v}),{keepPreviousData:!0}),C=(N==null?void 0:N.data)||[],y=(N==null?void 0:N.meta)||{total:0,limit:10},E=Math.ceil(y.total/(y.limit||10)),{data:M=[]}=Ce(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),F=M,A=(S,$)=>{b(H=>{const R=new Set(H);return $?R.add(S):R.delete(S),R})},T=async(S,$,H)=>{A(S.id,!0);try{H?(await i(e,S,$),c("Role removed","info")):(await r(e,S,$),c("Role added","info")),_()}catch(R){c(R.message||"Failed to update role","error")}finally{A(S.id,!1)}},P=async S=>{A(S.id,!0);try{await l(e,S),_(),c("Member removed","info")}catch($){c($.message||"Failed to remove member","error")}finally{A(S.id,!1)}};return N?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Wc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[y.total>0&&t.jsxs("div",{className:"w-secsub",children:[y.total," member",y.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>x(!0),$size:"sm",children:"Invite"})]})]}),g&&t.jsx(Qc,{onClose:()=>x(!1),onSuccess:()=>{_(),x(!1)},roles:F,triggerRef:j}),C.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Invite someone or connect a corporate domain to auto-join."}):t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Roles"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:C.map(S=>{var R,O;const $=((R=S.user)==null?void 0:R.id)===((O=m==null?void 0:m.active_signin)==null?void 0:O.user_id),H=w.has(S.id);return t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsx(um,{member:S,isCurrentUser:$})}),t.jsx(Qe,{children:new Date(S.created_at).toLocaleDateString()}),t.jsx(Qe,{children:t.jsx(mm,{member:S,roles:F,onToggle:T,disabled:H})}),t.jsx(It,{children:t.jsx("div",{className:"w-actions",children:t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:H||$,onClick:()=>P(S),title:$?"You cannot remove yourself":"Remove member",children:H?t.jsx(_e,{size:12}):"Remove"})})})]},S.id)})})]})}),E>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4 w-mt-6",children:[t.jsx(se,{onClick:()=>f(S=>Math.max(1,S-1)),disabled:u===1,$size:"sm",$outline:!0,children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",E]}),t.jsx(se,{onClick:()=>f(S=>Math.min(E,S+1)),disabled:u===E,$size:"sm",$outline:!0,children:"Next"})]})]}):t.jsx(_e,{})},um=({member:e,isCurrentUser:a})=>{var l,m;const s=e.user,r=(c="",d="")=>`${c[0]||""}${d[0]||""}`.toUpperCase()||"?",i=s?`${s.first_name||""} ${s.last_name||""}`.trim()||((l=s.primary_email_address)==null?void 0:l.email):"Unknown";return t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx("div",{className:"w-avatar w-avatar--md",children:s!=null&&s.profile_picture_url?t.jsx("img",{src:s.profile_picture_url,alt:i}):r(s==null?void 0:s.first_name,s==null?void 0:s.last_name)}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:i}),a&&t.jsx(ha,{$variant:"neutral",children:"You"})]}),t.jsx("span",{className:"w-secsub",children:(m=s==null?void 0:s.primary_email_address)==null?void 0:m.email})]})]})},mm=({member:e,roles:a,onToggle:s,disabled:r})=>{var c;const i=e.roles||[],l=d=>i.some(p=>p.id===d),m=i.length===0?"No role":i.length===1?(c=i[0])==null?void 0:c.name:`${i.length} roles`;return t.jsxs(ks,{children:[t.jsx(Ns,{children:t.jsxs(se,{$size:"sm",$outline:!0,disabled:r,className:"w-justify-between w-rolepick-btn",children:[m,t.jsx(Wt,{size:12})]})}),t.jsx(Cs,{children:a.length===0?t.jsx("div",{className:"w-secsub w-menu-head",children:"No roles configured"}):a.map(d=>{const p=l(d.id);return t.jsx(ta,{onClick:()=>s(e,d,p),children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-3 w-full",children:[t.jsx("span",{children:d.name}),p&&t.jsx(Ge,{size:13,className:"w-text-primary"})]})},d.id)})})]})},pm=e=>{const a=e.expires_at;return a?new Date(a).getTime()<Date.now():!1},hm=({organization:e})=>{const{getOrganizationInvitations:a,getOrganizationRoles:s,discardOrganizationInvitation:r,resendOrganizationInvitation:i}=Dt(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(new Set),u=o.useRef(null),{data:f=[],isLoading:h,mutate:g}=Ce(e?`wacht-api-organizations:${e.id}:invitations`:null,()=>(a==null?void 0:a(e))||[]),{data:x=[],isLoading:w}=Ce(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),b=x,j=(N,_)=>{p(C=>{const y=new Set(C);return _?y.add(N):y.delete(N),y})},v=async N=>{j(N.id,!0);try{await r(e,N),g(),l("Invitation cancelled","info")}catch(_){l(_.message||"Failed to cancel invitation","error")}finally{j(N.id,!1)}},k=async N=>{j(N.id,!0);try{await i(e,N),l("Invitation resent","info")}catch(_){l(_.message||"Failed to resend invitation","error")}finally{j(N.id,!1)}};return h||w?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Rr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this organization."})]}),t.jsx(se,{ref:u,onClick:()=>c(!0),$size:"sm",children:"Invite"})]}),m&&t.jsx(Qc,{onClose:()=>c(!1),onSuccess:()=>{g(),c(!1)},roles:b,triggerRef:u}),f.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to collaborate."}):t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Email"}),t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{children:"Invited"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:f.map(N=>{var y;const _=pm(N),C=d.has(N.id);return t.jsxs(rt,{children:[t.jsx(Qe,{children:N.email}),t.jsx(Qe,{children:((y=N.initial_organization_role)==null?void 0:y.name)||"No role"}),t.jsx(Qe,{children:_?t.jsx(ha,{$variant:"danger",children:"Expired"}):t.jsx(ha,{$variant:"warning",children:"Pending"})}),t.jsx(Qe,{children:new Date(N.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{$size:"sm",$outline:!0,disabled:C,onClick:()=>k(N),children:"Resend"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:C,onClick:()=>v(N),children:C?t.jsx(_e,{size:12}):"Cancel"})]})})]},N.id)})})]})})]})},Ii=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var _;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=je(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=Array.isArray((_=g==null?void 0:g.b2b_settings)==null?void 0:_.organization_permissions)?g.b2b_settings.organization_permissions.map(C=>({value:C,label:C})):[];o.useEffect(()=>{h(!0);const C=M=>{i.current&&!i.current.contains(M.target)&&(e==null||e())},y=M=>{M.key==="Escape"&&(e==null||e())},E=setTimeout(()=>{document.addEventListener("mousedown",C),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(E),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",y)}},[e]);const v=C=>C.trim().replace(/[<>"'&]/g,""),k=C=>C.length>=2&&C.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(C),N=async()=>{const C=v(l);if(!C){x("Please enter a role name","error");return}if(!k(C)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const y={id:s==null?void 0:s.id,name:C,permissions:c};a==null||a(y)}catch(y){x(y.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:C=>C.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(be,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:C=>m(C.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(qc,{options:j,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null};function Pr(e){return typeof e=="object"&&e!==null}function Jc(e,a){const s=e[a];return typeof s=="string"?s.length>0&&s!=="0":typeof s=="number"?Number.isFinite(s)&&s>0:!1}function fm(e,a){const s=e[a];return typeof s=="boolean"?s:null}function Xc(e){if(!Pr(e))return!1;const a=fm(e,"is_deployment_level");return a!==null?a:!1}function wm(e){return!Pr(e)||Xc(e)?!1:Jc(e,"organization_id")}function pr(e){return!Pr(e)||Xc(e)?!1:Jc(e,"workspace_id")}const gm=({organization:e})=>{var _;const{getOrganizationRoles:a,removeOrganizationRoles:s}=Dt(),{deployment:r}=je(),[i,l]=o.useState({isOpen:!1}),[m,c]=o.useState(null),[d,p]=o.useState(null),[u,f]=o.useState(new Set),h=o.useRef(null),g=o.useRef(new Map),{data:x=[],isLoading:w,mutate:b}=Ce(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(a==null?void 0:a(e))||[]),j=(C,y)=>{f(E=>{const M=new Set(E);return y?M.add(C):M.delete(C),M})},v=async C=>{try{await new Promise(y=>setTimeout(y,500)),c({text:`Role ${C.id?"updated":"created"} successfully`,type:"success"}),l({isOpen:!1}),b()}catch(y){const E=y instanceof Error?y.message:"Failed to save role";c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},k=async C=>{j(C.id,!0);try{await s(e,C),b()}finally{j(C.id,!1),p(null)}};if(w&&x.length===0)return t.jsx(_e,{});const N=C=>{const y=wm(C),E=u.has(C.id),M=C.permissions.length;return t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("span",{className:"w-inline w-gap-2 w-sec",children:[C.name,!y&&t.jsx(ha,{$variant:"neutral",children:"Default"})]})}),t.jsx(Qe,{children:M===0?t.jsx(ha,{$variant:"neutral",children:"No permissions"}):t.jsxs("div",{className:"w-inline w-items-center w-gap-2",children:[t.jsxs(ha,{$variant:"primary",children:[M," ",M===1?"permission":"permissions"]}),t.jsx("span",{className:"w-truncate w-text-secondary w-maxw-sm",children:C.permissions.join(", ")})]})}),t.jsx(It,{children:y?t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:F=>{F&&g.current.set(C.id,F)},$size:"sm",$outline:!0,disabled:E,onClick:()=>l({isOpen:!0,role:C,triggerElement:g.current.get(C.id)??null}),children:"Edit"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:E,onClick:()=>p(C.id),children:E?t.jsx(_e,{size:12}):"Delete"})]}):t.jsx("span",{className:"w-secsub",children:"Read-only"})})]},C.id)};return t.jsxs(t.Fragment,{children:[m&&t.jsxs("div",{className:`w-banner ${m.type==="success"?"w-banner--success":"w-banner--error"} w-mb-4`,children:[m.type==="success"?t.jsx(Ge,{size:16}):t.jsx(Ta,{size:16}),t.jsx("span",{className:"w-banner-txt",children:m.text})]}),t.jsxs(Rr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for members."})]}),((_=r==null?void 0:r.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&t.jsx(se,{ref:h,onClick:()=>l({isOpen:!0,triggerElement:h.current}),$size:"sm",children:"Add role"})]}),i.isOpen&&!i.role&&t.jsx(Ii,{onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||h.current}}),x.length===0?t.jsx(Nt,{title:"No roles yet",description:"Define custom roles to manage granular permissions."}):t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Permissions"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:x.map(N)})]})})}),d&&t.jsx(Ja,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const C=x.find(y=>y.id===d);C&&k(C)},onCancel:()=>p(null)}),i.isOpen&&i.role&&t.jsx(Ii,{role:i.role,onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||null}})]})},xm=()=>{const{activeOrganization:e,loading:a}=wa(),[s,r]=o.useState(null);return o.useEffect(()=>{e?r(e):!a&&!e&&s&&r(null)},[e,a,s]),{activeOrganization:s||e,loading:a}},e0=()=>{var w,b,j;const{loading:e,activeOrganization:a}=xm(),{updateOrganization:s}=wa(),{deployment:r}=je(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};return e&&!a?t.jsx(Re,{children:t.jsx(Hn,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})}):a?t.jsx(Re,{children:t.jsx($i,{children:t.jsx(Mr.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(Hn,{className:"w-relative",children:[t.jsxs(am,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,title:"Change logo","aria-label":"Change organization logo",children:[a.image_url?t.jsx("img",{src:a.image_url,alt:a.name}):((w=a.name)==null?void 0:w.slice(0,2).toUpperCase())||"O",t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(nn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(sm,{children:[t.jsx(nm,{children:a.name}),t.jsx(rm,{children:a.member_count!=null?`${a.member_count} members`:"Organization settings"})]})]}),t.jsx(X4,{children:t.jsxs(em,{children:[t.jsx(Da,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Ua,{children:[t.jsx(Aa,{size:16})," General"]})}),t.jsx(Da,{$isActive:i==="domains",onClick:()=>l("domains"),children:t.jsxs(Ua,{children:[t.jsx(Fu,{size:16})," Domains"]})}),t.jsx(Da,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Ua,{children:[t.jsx(ds,{size:16})," Members"]})}),t.jsx(Da,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Ua,{children:[t.jsx(pl,{size:16})," Invitations"]})}),((b=r==null?void 0:r.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&t.jsx(Da,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Ua,{children:[t.jsx(ea,{size:16})," Roles"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.enterprise_sso_enabled)&&t.jsx(Da,{$isActive:i==="sso",onClick:()=>l("sso"),children:t.jsxs(Ua,{children:[t.jsx(ea,{size:16})," SSO"]})})]})}),t.jsxs(tm,{children:[i==="general"&&t.jsx(om,{organization:a}),i==="domains"&&t.jsx(cm,{organization:a}),i==="members"&&t.jsx(dm,{organization:a}),i==="invitations"&&t.jsx(hm,{organization:a}),i==="roles"&&t.jsx(gm,{organization:a}),i==="sso"&&t.jsx(Y4,{organization:a})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Ta,{size:12}):t.jsx(Ge,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})}):t.jsx(Re,{children:t.jsx($i,{children:t.jsx(Hn,{className:"w-items-center w-justify-center",children:t.jsxs("div",{className:"w-empty",children:[t.jsx("span",{className:"w-empty-ic",children:t.jsx(hs,{size:20})}),t.jsx("h4",{children:"No Organization Selected"}),t.jsx(l0,{})]})})})})},t0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{className:"w-dialog--panel",children:[r&&t.jsx(ze.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(e0,{}),l&&t.jsx(ze.Footer,{children:l})]})})}),$r=({organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})=>t.jsx(Re,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Kc,{mode:"ws",organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})})}),Or=({isOpen:e,onClose:a,onCreated:s,organizationId:r})=>{const[i,l]=o.useState(!1),[m,c]=o.useState(r),d=()=>{s==null||s(),a==null||a()},p=()=>{l(!0)},u=f=>{var g,x,w;const h=((x=(g=f==null?void 0:f.data)==null?void 0:g.organization)==null?void 0:x.id)??((w=f==null?void 0:f.organization)==null?void 0:w.id)??(f==null?void 0:f.id);h&&c(h),l(!1)};return t.jsx(Re,{children:t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsx(ze.Content,{className:"w-dialog--create",children:i?t.jsx(pn,{onSuccess:u,onCancel:()=>l(!1)}):t.jsx($r,{organizationId:m||r,onSuccess:d,onCancel:a,onCreateOrganization:p})})})})})},ft=(...e)=>e.filter(Boolean).join(" "),vm=({className:e,...a})=>t.jsx("div",{className:ft("w-contents",e),...a}),Vi=({className:e,...a})=>t.jsx("div",{className:ft("w-card","w-flex-col","w-full","w-minh-full",e),...a}),bm=({className:e,...a})=>t.jsx("div",{className:ft("w-tabsbar",e),...a}),ym=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),Hs=({$isActive:e,className:a,...s})=>t.jsx("button",{className:ft("w-tab",e&&"w-tab--active",a),...s}),Fs=({className:e,...a})=>t.jsx("span",{className:ft("w-inline","w-gap-2",e),...a}),jm=({className:e,children:a,...s})=>t.jsx("div",{className:ft("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Xs=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:ft("w-kebab",e),...a}));Xs.displayName="IconButton";const a0=({className:e,...a})=>t.jsx("div",{className:ft("w-sechead",e),...a}),zi=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Di=({className:e,...a})=>t.jsx("div",{className:ft("w-grow",e),...a}),Ui=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-3","w-none",e),...a}),Zr=({className:e,...a})=>t.jsx("div",{className:ft("w-full",e),...a}),_m=({className:e,...a})=>t.jsx("div",{className:ft("w-page-head",e),...a}),km=({className:e,...a})=>t.jsx("div",{className:ft("w-grow","w-flex-col","w-gap-1",e),...a}),Cm=({className:e,...a})=>t.jsx("div",{className:ft("w-sec","w-truncate",e),...a}),Nm=({className:e,...a})=>t.jsx("div",{className:ft("w-secsub","w-truncate",e),...a}),Wi=({$first:e,className:a,...s})=>t.jsx("div",{className:ft("w-sec",a),...s}),Sm=()=>{var E,M;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Ut(),{deleteWorkspace:r}=xa(),{deployment:i}=je(),{toast:l}=Ct(),[m,c]=o.useState((e==null?void 0:e.name)||""),[d,p]=o.useState((e==null?void 0:e.description)||""),[u,f]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[h,g]=o.useState(!1),[x,w]=o.useState(""),[b,j]=o.useState(!1),[v,k]=o.useState(!1);o.useEffect(()=>{var F;e&&(c(e.name||""),p(e.description||""),f({mfa_required:e.enforce_2fa||!1,ip_restrictions:e.enable_ip_restriction||!1,allowed_ips:((F=e.whitelisted_ips)==null?void 0:F.join(`
105
+ 10.0.0.0/24`,className:"w-input--area w-input--mono"})]})]})]}),((H=i==null?void 0:i.b2b_settings)==null?void 0:H.allow_org_deletion)&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Fi,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start w-gap-3",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-full",children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete organization"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this organization, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{_(!N),j("")},children:N?"Cancel":"Delete organization"})]}),N&&t.jsxs("div",{className:"w-flex-col w-gap-3 w-full",children:[t.jsxs(We,{children:[t.jsxs(Te,{htmlFor:"confirm_org_name",children:["Type"," ",t.jsx("strong",{children:e.name})," ","to confirm"]}),t.jsx(be,{id:"confirm_org_name",type:"text",value:b,onChange:R=>j(R.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:F,disabled:b!==e.name||v,children:v?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})]}):t.jsx(_e,{})},Lr=(e,a)=>a?`${e} ${a}`:e,Ht=o.forwardRef(({className:e,...a},s)=>t.jsx("table",{ref:s,className:Lr("w-table",e),...a}));Ht.displayName="Table";const Ft=o.forwardRef((e,a)=>t.jsx("thead",{ref:a,...e}));Ft.displayName="TableHead";const Tt=o.forwardRef((e,a)=>t.jsx("tbody",{ref:a,...e}));Tt.displayName="TableBody";const rt=o.forwardRef((e,a)=>t.jsx("tr",{ref:a,...e}));rt.displayName="TableRow";const Oe=o.forwardRef((e,a)=>t.jsx("th",{ref:a,...e}));Oe.displayName="TableHeader";const Qe=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:e,...a}));Qe.displayName="TableCell";const l4=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Lr("w-td--flex",e),...a}));l4.displayName="TableCellFlex";const It=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Lr("w-td--actions",e),...a}));It.displayName="ActionsCell";const Nt=({title:e,description:a,icon:s,action:r})=>t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:s??t.jsx(Bu,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:e}),t.jsx("p",{children:a})]}),r&&t.jsx("div",{className:"w-empty-action",children:r})]}),bt=({triggerRef:e,isOpen:a,minWidth:s=300,defaultMaxHeight:r=400,offset:i=8,contentRef:l})=>{const[m,c]=o.useState();return o.useEffect(()=>{if(!a||!e.current){c(void 0);return}const d=()=>{var N;if(!e.current)return;const u=e.current.getBoundingClientRect(),f=window.innerWidth,h=window.innerHeight,g=((N=l==null?void 0:l.current)==null?void 0:N.offsetWidth)||s,x=h-u.bottom,w=u.top,b={};x>=w?(b.top=u.bottom+i,b.maxHeight=Math.min(r,x-i*2)):(b.bottom=h-u.top+i,b.maxHeight=Math.min(r,w-i*2));const j=f-u.left,v=u.right,k=j>=v?u.left:u.right-g;b.left=Math.max(i,Math.min(f-g-i,k)),c(b)},p=requestAnimationFrame(d);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{cancelAnimationFrame(p),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[a,s,r,i,l]),m},Ti=({onClose:e,domain:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,f]=o.useState(!1),{addDomain:h,verifyDomain:g}=wa(),{toast:x}=Ct(),w=bt({contentRef:r,triggerRef:s??{current:null},isOpen:u,minWidth:360,defaultMaxHeight:420}),b=_=>/^[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(_),j=_=>_.trim().toLowerCase().replace(/^https?:\/\//,""),v=async()=>{const _=j(m);if(!_){x("Please enter a domain name","error");return}if(!b(_)){x("Please enter a valid domain (e.g., example.com)","error");return}if(_.length>253){x("Domain name is too long","error");return}p(!0);try{const C=await h({fqdn:_});x("Domain added","info"),l(C.data)}catch(C){x(C.message||"Failed to add domain. Please try again.","error")}finally{p(!1)}},k=async()=>{if(!(!i||d)){p(!0);try{await g(i),e==null||e(),x("Domain verified","info")}catch(_){x(_.message||"Failed to verify domain. Check DNS records and try again.","error")}finally{p(!1)}}};if(o.useEffect(()=>{f(!0);const _=y=>{r.current&&!r.current.contains(y.target)&&(e==null||e())},C=y=>{y.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]),o.useEffect(()=>{a&&l(a)},[a]),!u)return null;const N={position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"};return i?t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"verify-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"verify-domain-title",children:"Verify domain"}),t.jsx("p",{className:"w-pop-sub",children:"Add this DNS record, then verify."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Type"}),t.jsx(be,{value:i==null?void 0:i.verification_dns_record_type,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(be,{value:i==null?void 0:i.verification_dns_record_name,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Value"}),t.jsx(be,{value:i==null?void 0:i.verification_dns_record_data,disabled:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:d,children:d?t.jsx(_e,{size:12}):"Verify"})]})]}):t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"add-domain-title",children:"Add domain"}),t.jsx("p",{className:"w-pop-sub",children:"Verified members auto-join this org."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Domain"}),t.jsx(be,{type:"text",placeholder:"example.com",value:m,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&m&&v()},autoFocus:!0,"aria-label":"Domain name"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!m||d,children:d?t.jsx(_e,{size:12}):"Continue"})]})]})},c4=({organization:e})=>{const{getOrganizationDomains:a,removeOrganizationDomain:s}=Dt(),[r,i]=o.useState(null),[l,m]=o.useState(!1),[c,d]=o.useState(null),[p,u]=o.useState(new Set),f=o.useRef(null),h=o.useRef({}),{data:g=[],isLoading:x,mutate:w}=Ce(e!=null&&e.id?`wacht-org-domains:${e.id}`:null,async()=>(await(a==null?void 0:a(e))||[]).map(k=>({...k,verified:k.verified!==void 0?k.verified:!1}))),b=(v,k)=>{u(N=>{const _=new Set(N);return k?_.add(v):_.delete(v),_})},j=async v=>{b(v.id,!0);try{await s(e,v),w()}finally{b(v.id,!1),i(null)}};return x?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Rr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Domains"}),t.jsx("div",{className:"w-secsub",children:"Users with verified domain emails auto-join this organization."})]}),t.jsx(se,{ref:f,onClick:()=>m(!0),$size:"sm",children:"Add domain"}),l&&t.jsx(Ti,{onClose:()=>{m(!1),w()},triggerRef:f})]}),g!=null&&g.length?t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Domain"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{children:"Added"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:g.map(v=>{const k=p.has(v.id);return t.jsxs(rt,{children:[t.jsx(Qe,{children:v.fqdn}),t.jsx(Qe,{children:v.verified?t.jsx(ha,{$variant:"success",children:"Verified"}):t.jsx(ha,{$variant:"warning",children:"Pending"})}),t.jsx(Qe,{children:new Date(v.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:N=>{N&&(h.current[v.id]=N)},$size:"sm",$outline:!0,disabled:k,onClick:()=>d(v.id),children:v.verified?"View DNS":"Verify"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:k,onClick:()=>i(v.id),children:k?t.jsx(_e,{size:12}):"Remove"})]})})]},v.id)})})]})}):t.jsx(Nt,{title:"No domains added",description:"Users with verified domain emails automatically join this organization."}),r&&t.jsx(Ja,{title:"Remove domain?",description:"Active users aren't affected, but new users with this domain won't auto-join.",onConfirm:()=>{const v=g.find(k=>k.id===r);v&&j(v)},onCancel:()=>i(null)}),c&&t.jsx(Ti,{domain:g.find(v=>v.id===c),onClose:()=>d(null),triggerRef:{current:h.current[c]}})]})},Qc=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{inviteMember:g}=wa(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:360}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}u(!0);try{await g({email:k,organizationRole:c}),a==null||a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{u(!1)}}};return o.useEffect(()=>{h(!0);const k=_=>{i.current&&!i.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email"}),t.jsx(be,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&l&&c&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Role"}),t.jsx(mn,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},d4=({organization:e})=>{const{getOrganizationMembers:a,getOrganizationRoles:s,addRoleToOrganizationMember:r,removeRoleFromOrganizationMember:i,removeOrganizationMember:l}=Dt(),{session:m}=it(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(!1),[w,b]=o.useState(new Set),j=o.useRef(null),[v,k]=o.useState(d);o.useEffect(()=>{const S=setTimeout(()=>{k(d),f(1)},500);return()=>clearTimeout(S)},[d]);const{data:N,mutate:_}=Ce(e?`wacht-api-organizations:${e.id}:members:${u}:${h}:${v}`:null,()=>a==null?void 0:a(e,{page:u,limit:h,search:v}),{keepPreviousData:!0}),C=(N==null?void 0:N.data)||[],y=(N==null?void 0:N.meta)||{total:0,limit:10},E=Math.ceil(y.total/(y.limit||10)),{data:M=[]}=Ce(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),F=M,A=(S,$)=>{b(H=>{const R=new Set(H);return $?R.add(S):R.delete(S),R})},T=async(S,$,H)=>{A(S.id,!0);try{H?(await i(e,S,$),c("Role removed","info")):(await r(e,S,$),c("Role added","info")),_()}catch(R){c(R.message||"Failed to update role","error")}finally{A(S.id,!1)}},P=async S=>{A(S.id,!0);try{await l(e,S),_(),c("Member removed","info")}catch($){c($.message||"Failed to remove member","error")}finally{A(S.id,!1)}};return N?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Wc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[y.total>0&&t.jsxs("div",{className:"w-secsub",children:[y.total," member",y.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>x(!0),$size:"sm",children:"Invite"})]})]}),g&&t.jsx(Qc,{onClose:()=>x(!1),onSuccess:()=>{_(),x(!1)},roles:F,triggerRef:j}),C.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Invite someone or connect a corporate domain to auto-join."}):t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Roles"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:C.map(S=>{var R,O;const $=((R=S.user)==null?void 0:R.id)===((O=m==null?void 0:m.active_signin)==null?void 0:O.user_id),H=w.has(S.id);return t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsx(u4,{member:S,isCurrentUser:$})}),t.jsx(Qe,{children:new Date(S.created_at).toLocaleDateString()}),t.jsx(Qe,{children:t.jsx(m4,{member:S,roles:F,onToggle:T,disabled:H})}),t.jsx(It,{children:t.jsx("div",{className:"w-actions",children:t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:H||$,onClick:()=>P(S),title:$?"You cannot remove yourself":"Remove member",children:H?t.jsx(_e,{size:12}):"Remove"})})})]},S.id)})})]})}),E>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4 w-mt-6",children:[t.jsx(se,{onClick:()=>f(S=>Math.max(1,S-1)),disabled:u===1,$size:"sm",$outline:!0,children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",E]}),t.jsx(se,{onClick:()=>f(S=>Math.min(E,S+1)),disabled:u===E,$size:"sm",$outline:!0,children:"Next"})]})]}):t.jsx(_e,{})},u4=({member:e,isCurrentUser:a})=>{var l,m;const s=e.user,r=(c="",d="")=>`${c[0]||""}${d[0]||""}`.toUpperCase()||"?",i=s?`${s.first_name||""} ${s.last_name||""}`.trim()||((l=s.primary_email_address)==null?void 0:l.email):"Unknown";return t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx("div",{className:"w-avatar w-avatar--md",children:s!=null&&s.profile_picture_url?t.jsx("img",{src:s.profile_picture_url,alt:i}):r(s==null?void 0:s.first_name,s==null?void 0:s.last_name)}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:i}),a&&t.jsx(ha,{$variant:"neutral",children:"You"})]}),t.jsx("span",{className:"w-secsub",children:(m=s==null?void 0:s.primary_email_address)==null?void 0:m.email})]})]})},m4=({member:e,roles:a,onToggle:s,disabled:r})=>{var c;const i=e.roles||[],l=d=>i.some(p=>p.id===d),m=i.length===0?"No role":i.length===1?(c=i[0])==null?void 0:c.name:`${i.length} roles`;return t.jsxs(ks,{children:[t.jsx(Ns,{children:t.jsxs(se,{$size:"sm",$outline:!0,disabled:r,className:"w-justify-between w-rolepick-btn",children:[m,t.jsx(Wt,{size:12})]})}),t.jsx(Cs,{children:a.length===0?t.jsx("div",{className:"w-secsub w-menu-head",children:"No roles configured"}):a.map(d=>{const p=l(d.id);return t.jsx(ta,{onClick:()=>s(e,d,p),children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-3 w-full",children:[t.jsx("span",{children:d.name}),p&&t.jsx(Ge,{size:13,className:"w-text-primary"})]})},d.id)})})]})},p4=e=>{const a=e.expires_at;return a?new Date(a).getTime()<Date.now():!1},h4=({organization:e})=>{const{getOrganizationInvitations:a,getOrganizationRoles:s,discardOrganizationInvitation:r,resendOrganizationInvitation:i}=Dt(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(new Set),u=o.useRef(null),{data:f=[],isLoading:h,mutate:g}=Ce(e?`wacht-api-organizations:${e.id}:invitations`:null,()=>(a==null?void 0:a(e))||[]),{data:x=[],isLoading:w}=Ce(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),b=x,j=(N,_)=>{p(C=>{const y=new Set(C);return _?y.add(N):y.delete(N),y})},v=async N=>{j(N.id,!0);try{await r(e,N),g(),l("Invitation cancelled","info")}catch(_){l(_.message||"Failed to cancel invitation","error")}finally{j(N.id,!1)}},k=async N=>{j(N.id,!0);try{await i(e,N),l("Invitation resent","info")}catch(_){l(_.message||"Failed to resend invitation","error")}finally{j(N.id,!1)}};return h||w?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Rr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this organization."})]}),t.jsx(se,{ref:u,onClick:()=>c(!0),$size:"sm",children:"Invite"})]}),m&&t.jsx(Qc,{onClose:()=>c(!1),onSuccess:()=>{g(),c(!1)},roles:b,triggerRef:u}),f.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to collaborate."}):t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Email"}),t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{children:"Invited"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:f.map(N=>{var y;const _=p4(N),C=d.has(N.id);return t.jsxs(rt,{children:[t.jsx(Qe,{children:N.email}),t.jsx(Qe,{children:((y=N.initial_organization_role)==null?void 0:y.name)||"No role"}),t.jsx(Qe,{children:_?t.jsx(ha,{$variant:"danger",children:"Expired"}):t.jsx(ha,{$variant:"warning",children:"Pending"})}),t.jsx(Qe,{children:new Date(N.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{$size:"sm",$outline:!0,disabled:C,onClick:()=>k(N),children:"Resend"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:C,onClick:()=>v(N),children:C?t.jsx(_e,{size:12}):"Cancel"})]})})]},N.id)})})]})})]})},Ii=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var _;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=je(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=Array.isArray((_=g==null?void 0:g.b2b_settings)==null?void 0:_.organization_permissions)?g.b2b_settings.organization_permissions.map(C=>({value:C,label:C})):[];o.useEffect(()=>{h(!0);const C=M=>{i.current&&!i.current.contains(M.target)&&(e==null||e())},y=M=>{M.key==="Escape"&&(e==null||e())},E=setTimeout(()=>{document.addEventListener("mousedown",C),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(E),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",y)}},[e]);const v=C=>C.trim().replace(/[<>"'&]/g,""),k=C=>C.length>=2&&C.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(C),N=async()=>{const C=v(l);if(!C){x("Please enter a role name","error");return}if(!k(C)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const y={id:s==null?void 0:s.id,name:C,permissions:c};a==null||a(y)}catch(y){x(y.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:C=>C.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(be,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:C=>m(C.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(qc,{options:j,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null};function Pr(e){return typeof e=="object"&&e!==null}function Jc(e,a){const s=e[a];return typeof s=="string"?s.length>0&&s!=="0":typeof s=="number"?Number.isFinite(s)&&s>0:!1}function f4(e,a){const s=e[a];return typeof s=="boolean"?s:null}function Xc(e){if(!Pr(e))return!1;const a=f4(e,"is_deployment_level");return a!==null?a:!1}function w4(e){return!Pr(e)||Xc(e)?!1:Jc(e,"organization_id")}function pr(e){return!Pr(e)||Xc(e)?!1:Jc(e,"workspace_id")}const g4=({organization:e})=>{var _;const{getOrganizationRoles:a,removeOrganizationRoles:s}=Dt(),{deployment:r}=je(),[i,l]=o.useState({isOpen:!1}),[m,c]=o.useState(null),[d,p]=o.useState(null),[u,f]=o.useState(new Set),h=o.useRef(null),g=o.useRef(new Map),{data:x=[],isLoading:w,mutate:b}=Ce(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(a==null?void 0:a(e))||[]),j=(C,y)=>{f(E=>{const M=new Set(E);return y?M.add(C):M.delete(C),M})},v=async C=>{try{await new Promise(y=>setTimeout(y,500)),c({text:`Role ${C.id?"updated":"created"} successfully`,type:"success"}),l({isOpen:!1}),b()}catch(y){const E=y instanceof Error?y.message:"Failed to save role";c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},k=async C=>{j(C.id,!0);try{await s(e,C),b()}finally{j(C.id,!1),p(null)}};if(w&&x.length===0)return t.jsx(_e,{});const N=C=>{const y=w4(C),E=u.has(C.id),M=C.permissions.length;return t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("span",{className:"w-inline w-gap-2 w-sec",children:[C.name,!y&&t.jsx(ha,{$variant:"neutral",children:"Default"})]})}),t.jsx(Qe,{children:M===0?t.jsx(ha,{$variant:"neutral",children:"No permissions"}):t.jsxs("div",{className:"w-inline w-items-center w-gap-2",children:[t.jsxs(ha,{$variant:"primary",children:[M," ",M===1?"permission":"permissions"]}),t.jsx("span",{className:"w-truncate w-text-secondary w-maxw-sm",children:C.permissions.join(", ")})]})}),t.jsx(It,{children:y?t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:F=>{F&&g.current.set(C.id,F)},$size:"sm",$outline:!0,disabled:E,onClick:()=>l({isOpen:!0,role:C,triggerElement:g.current.get(C.id)??null}),children:"Edit"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:E,onClick:()=>p(C.id),children:E?t.jsx(_e,{size:12}):"Delete"})]}):t.jsx("span",{className:"w-secsub",children:"Read-only"})})]},C.id)};return t.jsxs(t.Fragment,{children:[m&&t.jsxs("div",{className:`w-banner ${m.type==="success"?"w-banner--success":"w-banner--error"} w-mb-4`,children:[m.type==="success"?t.jsx(Ge,{size:16}):t.jsx(Ta,{size:16}),t.jsx("span",{className:"w-banner-txt",children:m.text})]}),t.jsxs(Rr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for members."})]}),((_=r==null?void 0:r.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&t.jsx(se,{ref:h,onClick:()=>l({isOpen:!0,triggerElement:h.current}),$size:"sm",children:"Add role"})]}),i.isOpen&&!i.role&&t.jsx(Ii,{onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||h.current}}),x.length===0?t.jsx(Nt,{title:"No roles yet",description:"Define custom roles to manage granular permissions."}):t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Permissions"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:x.map(N)})]})})}),d&&t.jsx(Ja,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const C=x.find(y=>y.id===d);C&&k(C)},onCancel:()=>p(null)}),i.isOpen&&i.role&&t.jsx(Ii,{role:i.role,onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||null}})]})},x4=()=>{const{activeOrganization:e,loading:a}=wa(),[s,r]=o.useState(null);return o.useEffect(()=>{e?r(e):!a&&!e&&s&&r(null)},[e,a,s]),{activeOrganization:s||e,loading:a}},e0=()=>{var w,b,j;const{loading:e,activeOrganization:a}=x4(),{updateOrganization:s}=wa(),{deployment:r}=je(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};return e&&!a?t.jsx(Re,{children:t.jsx(Hn,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})}):a?t.jsx(Re,{children:t.jsx($i,{children:t.jsx(Mr.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(Hn,{className:"w-relative",children:[t.jsxs(a4,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,title:"Change logo","aria-label":"Change organization logo",children:[a.image_url?t.jsx("img",{src:a.image_url,alt:a.name}):((w=a.name)==null?void 0:w.slice(0,2).toUpperCase())||"O",t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(nn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(s4,{children:[t.jsx(n4,{children:a.name}),t.jsx(r4,{children:a.member_count!=null?`${a.member_count} members`:"Organization settings"})]})]}),t.jsx(Xm,{children:t.jsxs(e4,{children:[t.jsx(Da,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Ua,{children:[t.jsx(Aa,{size:16})," General"]})}),t.jsx(Da,{$isActive:i==="domains",onClick:()=>l("domains"),children:t.jsxs(Ua,{children:[t.jsx(Fu,{size:16})," Domains"]})}),t.jsx(Da,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Ua,{children:[t.jsx(ds,{size:16})," Members"]})}),t.jsx(Da,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Ua,{children:[t.jsx(pl,{size:16})," Invitations"]})}),((b=r==null?void 0:r.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&t.jsx(Da,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Ua,{children:[t.jsx(ea,{size:16})," Roles"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.enterprise_sso_enabled)&&t.jsx(Da,{$isActive:i==="sso",onClick:()=>l("sso"),children:t.jsxs(Ua,{children:[t.jsx(ea,{size:16})," SSO"]})})]})}),t.jsxs(t4,{children:[i==="general"&&t.jsx(o4,{organization:a}),i==="domains"&&t.jsx(c4,{organization:a}),i==="members"&&t.jsx(d4,{organization:a}),i==="invitations"&&t.jsx(h4,{organization:a}),i==="roles"&&t.jsx(g4,{organization:a}),i==="sso"&&t.jsx(Ym,{organization:a})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Ta,{size:12}):t.jsx(Ge,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})}):t.jsx(Re,{children:t.jsx($i,{children:t.jsx(Hn,{className:"w-items-center w-justify-center",children:t.jsxs("div",{className:"w-empty",children:[t.jsx("span",{className:"w-empty-ic",children:t.jsx(hs,{size:20})}),t.jsx("h4",{children:"No Organization Selected"}),t.jsx(l0,{})]})})})})},t0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{className:"w-dialog--panel",children:[r&&t.jsx(ze.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(e0,{}),l&&t.jsx(ze.Footer,{children:l})]})})}),$r=({organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})=>t.jsx(Re,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Kc,{mode:"ws",organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})})}),Or=({isOpen:e,onClose:a,onCreated:s,organizationId:r})=>{const[i,l]=o.useState(!1),[m,c]=o.useState(r),d=()=>{s==null||s(),a==null||a()},p=()=>{l(!0)},u=f=>{var g,x,w;const h=((x=(g=f==null?void 0:f.data)==null?void 0:g.organization)==null?void 0:x.id)??((w=f==null?void 0:f.organization)==null?void 0:w.id)??(f==null?void 0:f.id);h&&c(h),l(!1)};return t.jsx(Re,{children:t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsx(ze.Content,{className:"w-dialog--create",children:i?t.jsx(pn,{onSuccess:u,onCancel:()=>l(!1)}):t.jsx($r,{organizationId:m||r,onSuccess:d,onCancel:a,onCreateOrganization:p})})})})})},ft=(...e)=>e.filter(Boolean).join(" "),v4=({className:e,...a})=>t.jsx("div",{className:ft("w-contents",e),...a}),Vi=({className:e,...a})=>t.jsx("div",{className:ft("w-card","w-flex-col","w-full","w-minh-full",e),...a}),b4=({className:e,...a})=>t.jsx("div",{className:ft("w-tabsbar",e),...a}),y4=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),Hs=({$isActive:e,className:a,...s})=>t.jsx("button",{className:ft("w-tab",e&&"w-tab--active",a),...s}),Fs=({className:e,...a})=>t.jsx("span",{className:ft("w-inline","w-gap-2",e),...a}),j4=({className:e,children:a,...s})=>t.jsx("div",{className:ft("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Xs=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:ft("w-kebab",e),...a}));Xs.displayName="IconButton";const a0=({className:e,...a})=>t.jsx("div",{className:ft("w-sechead",e),...a}),zi=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Di=({className:e,...a})=>t.jsx("div",{className:ft("w-grow",e),...a}),Ui=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-3","w-none",e),...a}),Zr=({className:e,...a})=>t.jsx("div",{className:ft("w-full",e),...a}),_4=({className:e,...a})=>t.jsx("div",{className:ft("w-page-head",e),...a}),k4=({className:e,...a})=>t.jsx("div",{className:ft("w-grow","w-flex-col","w-gap-1",e),...a}),C4=({className:e,...a})=>t.jsx("div",{className:ft("w-sec","w-truncate",e),...a}),N4=({className:e,...a})=>t.jsx("div",{className:ft("w-secsub","w-truncate",e),...a}),Wi=({$first:e,className:a,...s})=>t.jsx("div",{className:ft("w-sec",a),...s}),S4=()=>{var E,M;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Ut(),{deleteWorkspace:r}=xa(),{deployment:i}=je(),{toast:l}=Ct(),[m,c]=o.useState((e==null?void 0:e.name)||""),[d,p]=o.useState((e==null?void 0:e.description)||""),[u,f]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[h,g]=o.useState(!1),[x,w]=o.useState(""),[b,j]=o.useState(!1),[v,k]=o.useState(!1);o.useEffect(()=>{var F;e&&(c(e.name||""),p(e.description||""),f({mfa_required:e.enforce_2fa||!1,ip_restrictions:e.enable_ip_restriction||!1,allowed_ips:((F=e.whitelisted_ips)==null?void 0:F.join(`
106
106
  `))||""}))},[e]);const N=async()=>{if(!(!e||h))try{g(!0),await s({name:m,description:d,enforce_2fa:u.mfa_required,enable_ip_restriction:u.ip_restrictions,whitelisted_ips:u.allowed_ips.split(`
107
107
  `).filter(F=>F.trim())}),l("Changes saved","info")}catch(F){l(F.message||"Failed to save changes","error")}finally{g(!1)}},_=async()=>{if(!(!e||x!==e.name))try{j(!0),await r(e),l("Workspace deleted","info")}catch{l("Failed to delete workspace","error")}finally{j(!1),w("")}};if(a&&!e)return t.jsx(_e,{});if(!e)return null;const C=(E=i==null?void 0:i.b2b_settings)==null?void 0:E.enforce_mfa_per_workspace_enabled,y=(M=i==null?void 0:i.b2b_settings)==null?void 0:M.ip_allowlist_per_workspace_enabled;return t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"name",children:"Workspace name"}),t.jsx(be,{id:"name",value:m,onChange:F=>c(F.target.value),onBlur:N,placeholder:"Workspace name",required:!0})]}),t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"description",children:"Description"}),t.jsx(be,{id:"description",as:"textarea",value:d,onChange:F=>p(F.target.value),onBlur:N,placeholder:"Optional description",className:"w-input--area"})]})]}),(C||y)&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Wi,{children:"Security"}),C&&t.jsxs(zi,{children:[t.jsxs(Di,{children:[t.jsx("div",{className:"w-sec",children:"Multi-factor authentication"}),t.jsx("p",{className:"w-secsub",children:"Require all workspace members to set up MFA."})]}),t.jsx(Ui,{children:t.jsx(Ha,{checked:u.mfa_required,onChange:()=>{f(F=>({...F,mfa_required:!F.mfa_required})),setTimeout(N,0)}})})]}),y&&t.jsxs(t.Fragment,{children:[t.jsxs(zi,{children:[t.jsxs(Di,{children:[t.jsx("div",{className:"w-sec",children:"IP restrictions"}),t.jsx("p",{className:"w-secsub",children:"Only allow access from specific IP addresses."})]}),t.jsx(Ui,{children:t.jsx(Ha,{checked:u.ip_restrictions,onChange:()=>{f(F=>({...F,ip_restrictions:!F.ip_restrictions})),setTimeout(N,0)}})})]}),u.ip_restrictions&&t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(be,{id:"allowed_ips",as:"textarea",value:u.allowed_ips,onChange:F=>f(A=>({...A,allowed_ips:F.target.value})),onBlur:N,placeholder:`192.168.1.1
108
- 10.0.0.0/24`,className:"w-input--area w-mono-sm"})]})]})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Wi,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger",children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Delete workspace"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this workspace, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{k(!v),w("")},children:v?"Cancel":"Delete workspace"})]}),v&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(We,{children:[t.jsxs(Te,{htmlFor:"confirm_workspace_name",children:["Type ",t.jsx("strong",{children:e.name})," to confirm"]}),t.jsx(be,{id:"confirm_workspace_name",type:"text",value:x,onChange:F=>w(F.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:_,disabled:x!==e.name||b,children:b?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})},Em=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{toast:g}=Ct(),{inviteMember:x}=Ut(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name}));o.useEffect(()=>{h(!0);const k=C=>{i.current&&!i.current.contains(C.target)&&(e==null||e())},N=C=>{C.key==="Escape"&&(e==null||e())},_=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",N)},100);return()=>{clearTimeout(_),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]);const j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){g("Please enter a valid email address","error");return}if(k.length>320){g("Email address is too long","error");return}u(!0);try{await x({email:k,workspaceRoleId:c.id}),a==null||a()}catch(N){const _=N.message||"Failed to send invitation. Please try again.";g(_,"error")}finally{u(!1)}}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,maxHeight:w!=null&&w.maxHeight?`${w.maxHeight}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-workspace-member-title",children:"Invite member"}),t.jsxs(We,{children:[t.jsx(Te,{children:"Email Address"}),t.jsx(be,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Role"}),t.jsx(mn,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:14}):"Send invite"})]})]}):null},Am=()=>{const{activeWorkspace:e,getMembers:a,getRoles:s,removeMember:r,addMemberRole:i,removeMemberRole:l}=Ut(),{session:m}=it(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(""),[w,b]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>{const A=setTimeout(()=>{x(d),f(1)},500);return()=>clearTimeout(A)},[d]);const{data:v,mutate:k}=Ce(e?`wacht-api-workspaces:${e.id}:members:${u}:${h}:${g}`:null,()=>a==null?void 0:a({page:u,limit:h,search:g}),{keepPreviousData:!0}),N=(v==null?void 0:v.data)||[],_=(v==null?void 0:v.meta)||{total:0,limit:10},C=Math.ceil(_.total/(_.limit||10)),{data:y=[]}=Ce(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),E=y,M=async(A,T,P)=>{try{P?(await l(A,T),c("Role removed","info")):(await i(A,T),c("Role added","info")),k()}catch{c("Failed to update role","error")}},F=async A=>{try{await r(A),c("Member removed","info"),k()}catch{c("Failed to remove member","error")}};return v?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Wc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[_.total>0&&t.jsxs("div",{className:"w-text-muted w-secsub",children:[_.total," member",_.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>b(!0),$size:"sm",children:"Invite"})]})]}),w&&t.jsx(Em,{onClose:()=>b(!1),onSuccess:()=>{k(),b(!1)},roles:E,triggerRef:j}),N.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):t.jsx(t.Fragment,{children:t.jsx(Zr,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Role"})]})}),t.jsx(Tt,{children:N.map(A=>t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsx(Mm,{member:A,session:m})}),t.jsx(Qe,{children:new Date(A.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsx(Rm,{member:A,roles:E,onToggle:(T,P)=>M(A.id,T,P),onRemove:()=>F(A.id)})})]},A.id))})]})})}),C>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4",children:[t.jsx(se,{onClick:()=>f(A=>Math.max(1,A-1)),disabled:u===1,$size:"sm",children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",C]}),t.jsx(se,{onClick:()=>f(A=>Math.min(C,A+1)),disabled:u===C,$size:"sm",children:"Next"})]})]}):t.jsx(_e,{})},Mm=({member:e,session:a,subtitle:s})=>{var m,c,d;const r=e.public_user_data||e.user,i=(r==null?void 0:r.id)===((m=a==null?void 0:a.active_signin)==null?void 0:m.user_id),l=(p="",u="")=>`${p[0]||""}${u[0]||""} `.toUpperCase();return t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx("div",{className:"w-avatar",children:r!=null&&r.profile_picture_url?t.jsx("img",{src:r.profile_picture_url,alt:"Avatar"}):l(r==null?void 0:r.first_name,r==null?void 0:r.last_name)||"?"}),t.jsxs("div",{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:r?`${r.first_name||""} ${r.last_name||""} `.trim()||((c=r.primary_email_address)==null?void 0:c.email):"Unknown"}),i&&t.jsx("span",{className:"w-pill",children:"You"})]}),t.jsxs("div",{className:"w-flex w-wrap w-gap-2 w-secsub",children:[t.jsx("span",{children:(d=r==null?void 0:r.primary_email_address)==null?void 0:d.email}),s&&t.jsxs("span",{className:"w-text-muted",children:["• ",s]})]})]})]})},Rm=({member:e,roles:a,onToggle:s,onRemove:r})=>{var m;const i=e.roles||[],l=c=>i.some(d=>d.id===c);return t.jsxs(ks,{children:[t.jsx(Ns,{children:t.jsxs(se,{$outline:!0,$size:"sm",className:"w-justify-between w-rolepick-btn",children:[i.length>0?(m=i==null?void 0:i[0])==null?void 0:m.name:"No role"," ",t.jsx(Wt,{size:14})]})}),t.jsxs(Cs,{children:[a.map(c=>{const d=l(c.id);return t.jsx(ta,{onClick:()=>s(c.id,d),children:t.jsxs("div",{className:"w-flex w-justify-between w-full w-gap-3",children:[t.jsx("span",{children:c.name}),d&&t.jsx(Ge,{size:14,className:"w-text-success"})]})},c.id)}),t.jsx(Dc,{}),t.jsx(ta,{$destructive:!0,onClick:r,children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(br,{size:14})," Remove Member"]})})]})]})},Lm=({onClose:e,onSuccess:a,roles:s,createInvitation:r,triggerRef:i})=>{const l=o.useRef(null),[m,c]=o.useState(""),[d,p]=o.useState(s[0]||null),[u,f]=o.useState(!1),[h,g]=o.useState(!1),{toast:x}=Ct(),w=bt({contentRef:l,triggerRef:i,isOpen:h,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=m.trim().toLowerCase();if(!(!k||!d)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}f(!0);try{await r({email:k,role_id:d.id}),a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{f(!1)}}};return o.useEffect(()=>{g(!0);const k=_=>{l.current&&!l.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),h?t.jsxs("div",{ref:l,className:"w-pop w-pop--wide w-pop-body",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Email"}),t.jsx(be,{type:"email",placeholder:"colleague@company.com",value:m,onChange:k=>c(k.target.value),onKeyDown:k=>{k.key==="Enter"&&m&&d&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Role"}),t.jsx(mn,{options:b,value:d==null?void 0:d.id,onChange:k=>p(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(se,{$size:"sm",$outline:!0,$fullWidth:!0,onClick:e,children:"Cancel"}),t.jsx(se,{$size:"sm",$fullWidth:!0,onClick:v,disabled:!m||!d||u,children:u?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},Pm=()=>{const{activeWorkspace:e,loading:a,getRoles:s,getInvitations:r,inviteMember:i,discardInvitation:l,resendInvitation:m}=Ut(),{toast:c}=Ct(),[d,p]=o.useState(!0),[u,f]=o.useState(!0),[h,g]=o.useState([]),[x,w]=o.useState([]),[b,j]=o.useState(!1),v=o.useRef(null),k=async()=>{if(e){p(!0),f(!0);try{const[C,y]=await Promise.all([s(),r()]);w(C),g(y)}catch{}finally{p(!1),f(!1)}}};o.useEffect(()=>{k()},[e==null?void 0:e.id]);const N=async C=>{try{await l(C),k(),c("Invitation cancelled","info")}catch{c("Failed to cancel invitation","error")}},_=async C=>{try{await m(C),k(),c("Invitation resent","info")}catch{c("Failed to resend invitation","error")}};return a||d||u?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(a0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this workspace."})]}),t.jsx(se,{ref:v,onClick:()=>j(!0),$size:"sm",children:"Invite"})]}),b&&t.jsx(Lm,{onClose:()=>j(!1),onSuccess:()=>{k(),j(!1),c("Invitation sent","info")},roles:x,createInvitation:C=>i({email:C.email,workspaceRoleId:C.role_id}),triggerRef:v}),h.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to your workspace."}):t.jsx(t.Fragment,{children:t.jsx(Zr,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Email"}),t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Invited"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:h.map(C=>{var y,E;return t.jsxs(rt,{children:[t.jsx(Qe,{children:C.email}),t.jsx(Qe,{children:((y=C.initial_workspace_role)==null?void 0:y.name)||((E=C.initial_organization_role)==null?void 0:E.name)||"No role"}),t.jsx(Qe,{children:new Date(C.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsx($m,{onResend:()=>_(C.id),onCancel:()=>N(C.id)})})]},C.id)})})]})})})]})},$m=({onResend:e,onCancel:a})=>t.jsxs(ks,{children:[t.jsx(Ns,{children:t.jsx(Xs,{children:"•••"})}),t.jsxs(Cs,{children:[t.jsxs(ta,{onClick:e,children:[t.jsx(Rl,{size:16})," Resend"]}),t.jsxs(ta,{$destructive:!0,onClick:a,children:[t.jsx(br,{size:16})," Cancel"]})]})]}),Bi=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var C,y;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=je(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=((C=g==null?void 0:g.b2b_settings)==null?void 0:C.workspace_permissions)||((y=g==null?void 0:g.b2b_settings)==null?void 0:y.organization_permissions)||[],v=Array.isArray(j)?j.map(E=>({value:E,label:E})):[];o.useEffect(()=>{h(!0);const E=A=>{i.current&&!i.current.contains(A.target)&&(e==null||e())},M=A=>{A.key==="Escape"&&(e==null||e())},F=setTimeout(()=>{document.addEventListener("mousedown",E),document.addEventListener("keydown",M)},100);return()=>{clearTimeout(F),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",M)}},[e]);const k=E=>E.trim().replace(/[<>"'&]/g,""),N=E=>E.length>=2&&E.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(E),_=async()=>{const E=k(l);if(!E){x("Please enter a role name","error");return}if(!N(E)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const M={id:s==null?void 0:s.id,name:E,permissions:c};a==null||a(M)}catch(M){x(M.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(be,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:E=>m(E.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(qc,{options:v,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null},Om=()=>{var N;const{activeWorkspace:e,loading:a,getRoles:s,createRole:r,deleteRole:i}=Ut(),{deployment:l}=je(),{toast:m}=Ct(),[c,d]=o.useState({isOpen:!1}),[p,u]=o.useState(null),[f,h]=o.useState(null),g=o.useRef(null),x=o.useRef(new Map),{data:w=[],isLoading:b,mutate:j}=Ce(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),v=async _=>{try{await r(_.name,_.permissions||[]),m("Role saved successfully","info"),d({isOpen:!1}),j()}catch{m("Failed to save role","error")}},k=async _=>{try{await i(_),m("Role deleted","info"),u(null),j()}catch{m("Failed to delete role","error")}};return a||b?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(a0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for this workspace."})]}),((N=l==null?void 0:l.b2b_settings)==null?void 0:N.custom_workspace_role_enabled)&&t.jsx(se,{ref:g,onClick:()=>d({isOpen:!0,triggerElement:g.current}),$size:"sm",children:"Add role"})]}),c.isOpen&&!c.role&&t.jsx(Bi,{triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v}),w.length===0?t.jsx(Nt,{title:"No roles yet",description:"Create workspace-specific roles to manage access."}):t.jsx(t.Fragment,{children:t.jsx(Zr,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Permissions"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:w.map(_=>{var C;return t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2 w-wrap",children:[t.jsx("span",{className:"w-sec",children:_.name}),!pr(_)&&t.jsx("span",{className:"w-pill",children:"Default"})]})}),t.jsx(Qe,{children:t.jsxs("span",{className:"w-text-secondary",children:[(C=_.permissions)==null?void 0:C.join(", "),!pr(_)&&" • Cannot be edited or deleted"]})}),t.jsx(It,{children:t.jsx(Zm,{role:_,onEdit:y=>d({isOpen:!0,role:_,triggerElement:y}),onDelete:()=>u(_.id),open:f===_.id,onOpenChange:y=>h(y?_.id:null),dropdownButtonRefs:x})})]},_.id)})})]})})}),p&&t.jsx(Ja,{title:"Delete role?",description:"Are you sure? This will remove the role from all workspace members.",onConfirm:()=>{const _=w.find(C=>C.id===p);_&&k(_)},onCancel:()=>u(null)}),c.isOpen&&c.role&&t.jsx(Bi,{role:c.role,triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v})]})},Zm=({role:e,onEdit:a,onDelete:s,open:r,onOpenChange:i,dropdownButtonRefs:l})=>pr(e)?t.jsxs(ks,{open:r,openChange:i,children:[t.jsx(Ns,{children:t.jsx(Xs,{ref:c=>{c&&l.current.set(e.id,c)},children:"•••"})}),t.jsxs(Cs,{children:[t.jsx(ta,{onClick:()=>a(l.current.get(e.id)??null),children:"Edit Role"}),t.jsxs(ta,{$destructive:!0,onClick:s,children:[t.jsx(br,{size:16})," Remove Role"]})]})]}):t.jsx(Xs,{disabled:!0,title:"Deployment roles cannot be edited","aria-label":"Deployment roles cannot be edited",children:"•••"}),Hm=e=>(e||"").slice(0,2).toUpperCase()||"W",s0=()=>{var b,j;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Ut(),{deployment:r}=je(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(a&&!e)return t.jsx(Re,{children:t.jsx(Vi,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})});if(!e)return null;const w=(b=e.organization)==null?void 0:b.name;return t.jsx(Re,{children:t.jsx(vm,{children:t.jsx(Mr.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(Vi,{className:"w-relative",children:[t.jsxs(_m,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit",onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,"data-busy":u?"":void 0,title:"Change logo","aria-label":"Change workspace logo",children:[e.image_url?t.jsx("img",{src:e.image_url,alt:e.name}):Hm(e.name),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(nn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",className:"w-none",hidden:!0,onChange:x}),t.jsxs(km,{children:[t.jsx(Cm,{children:e.name}),t.jsx(Nm,{children:w?`${w} · Workspace settings`:"Workspace settings"})]})]}),t.jsx(bm,{children:t.jsxs(ym,{children:[t.jsx(Hs,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Fs,{children:[t.jsx(Aa,{size:14})," General"]})}),t.jsx(Hs,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Fs,{children:[t.jsx(ds,{size:14})," Members"]})}),t.jsx(Hs,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Fs,{children:[t.jsx(Rl,{size:14})," Invitations"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.custom_workspace_role_enabled)&&t.jsx(Hs,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Fs,{children:[t.jsx(ea,{size:14})," Roles"]})})]})}),t.jsxs(jm,{children:[i==="general"&&t.jsx(Sm,{}),i==="members"&&t.jsx(Am,{}),i==="invitations"&&t.jsx(Pm,{}),i==="roles"&&t.jsx(Om,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Ta,{size:14}):t.jsx(Ge,{size:14})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},Hr=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{className:"w-dialog--panel",children:[r&&t.jsx(ze.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(s0,{}),l&&t.jsx(ze.Footer,{children:l})]})})}),n0=["organization:admin"],r0=["organization:admin","organization:manage"],i0=["workspace:admin"],o0=["workspace:admin","workspace:manage"];function Fr(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Tr(e){return Fr(e,r0)}function Fm(e){return Fr(e,n0)}function Ir(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Vr(e){return Ir(e,o0)}function Tm(e){return Ir(e,i0)}const l0=({showPersonal:e=!0})=>{var Ee,ce,W;const[a,s]=o.useState(!1),[r,i]=o.useState(!1),[l,m]=o.useState(new Set),c=o.useRef(null),d=o.useRef(null),p=bt({triggerRef:c,isOpen:a,minWidth:300}),u=Yt(!1),f=Yt(!1),h=Yt(!1),g=Yt(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),v=as(),{organizationMemberships:k,loading:N,refetch:_}=ga(),{activeOrganization:C,activeMembership:y,leave:E}=wa(),{activeWorkspace:M,activeMembership:F,leave:A}=Ut(),{workspaces:T,loading:P}=xa(),{session:S,switchOrganization:$,switchWorkspace:H}=it(),{deployment:R}=je(),O=R==null?void 0:R.b2b_settings.organizations_enabled,Z=O&&(R==null?void 0:R.b2b_settings.workspaces_enabled),L=R==null?void 0:R.b2b_settings.allow_users_to_create_orgs,U=!y,D=o.useMemo(()=>{var K,V;return U?{name:"Personal account",image_url:(V=(K=S==null?void 0:S.active_signin)==null?void 0:K.user)==null?void 0:V.profile_picture_url,isPersonal:!0}:{name:Z&&M?`${C==null?void 0:C.name} / ${M.name}`:(C==null?void 0:C.name)||"",image_url:C==null?void 0:C.image_url,isPersonal:!1}},[U,C,M,S,Z]);if(o.useEffect(()=>{C&&Z&&m(G=>{if(G.has(C.id))return G;const K=new Set(G);return K.add(C.id),K})},[C,Z]),o.useEffect(()=>{if(!a)return;let G=null;const K=setTimeout(()=>{const V=de=>{var le,Je;const z=de.target;(le=c.current)!=null&&le.contains(z)||(Je=d.current)!=null&&Je.contains(z)||(s(!1),j(null))};document.addEventListener("mousedown",V),G=()=>document.removeEventListener("mousedown",V)},50);return()=>{clearTimeout(K),G==null||G()}},[a]),o.useEffect(()=>{if(!b)return;const G=setTimeout(()=>j(null),5e3);return()=>clearTimeout(G)},[b]),!O)return null;const Y=G=>G.split(" ").map(K=>K[0]).join("").toUpperCase().slice(0,2),B=G=>{i(!0),$(G).finally(()=>i(!1))},Q=G=>{i(!0),H(G).finally(()=>i(!1))},ue=G=>{m(K=>{const V=new Set(K);return V.has(G)?V.delete(G):V.add(G),V})},we=()=>{f.open(),s(!1)},ne=()=>{g.open(),s(!1)},ae=async()=>{if(E){j(null);try{await E(),await _(),s(!1)}catch(G){j(G instanceof Error?G.message:"Failed to leave organization")}}},re=async()=>{if(A){j(null);try{await A(),s(!1)}catch(G){j(G instanceof Error?G.message:"Failed to leave workspace")}}},Me=!!((Ee=y==null?void 0:y.eligibility_restriction)!=null&&Ee.type)&&y.eligibility_restriction.type!=="none",q=!!C&&!Me&&Tr(y),tt=!!Z&&!!M&&!Me&&Vr(F);return!!!S||N||Z&&P?t.jsx(Re,{children:t.jsx("div",{className:"w-full w-relative",children:t.jsxs("div",{className:"w-combo",children:[t.jsx("span",{className:"w-skel",style:{width:20,height:20}}),t.jsx("span",{className:"w-skel w-grow",style:{height:12}})]})})}):t.jsx(Re,{children:t.jsxs("div",{className:"w-full w-relative",children:[t.jsxs("button",{ref:c,className:"w-orgtrigger","data-open":a?"":void 0,onClick:()=>{s(!a),a||j(null)},disabled:r,children:[t.jsx("span",{className:`w-avatar w-avatar--sm${D.isPersonal,""}`,children:D.image_url?t.jsx("img",{src:D.image_url,alt:D.name}):D.isPersonal?t.jsx(fs,{size:11}):Y(D.name)}),t.jsx("span",{className:"w-grow w-truncate",children:D.name}),t.jsx(Ru,{size:13})]}),typeof window<"u"&&tn.createPortal(t.jsxs("div",{ref:d,className:"wacht-root w-menu w-flex-col",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 16px)",maxHeight:p!=null&&p.maxHeight?`${p.maxHeight}px`:420,padding:0,zIndex:99999,top:(p==null?void 0:p.top)!==void 0?`${p.top}px`:void 0,bottom:(p==null?void 0:p.bottom)!==void 0?`${p.bottom}px`:void 0,left:(p==null?void 0:p.left)!==void 0?`${p.left}px`:void 0,right:(p==null?void 0:p.right)!==void 0?`${p.right}px`:void 0,visibility:p&&a?"visible":"hidden",opacity:a&&p?1:0,transform:a?"translateY(0)":"translateY(-4px)",pointerEvents:a?"auto":"none",transition:`opacity 0.15s ease, transform 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,...v},children:[b&&t.jsxs("div",{className:"w-banner w-banner--error w-switch-banner",children:[t.jsx(Ra,{size:13}),t.jsx("span",{className:"w-banner-txt w-text-error",children:b})]}),t.jsx("div",{className:"w-grow w-switch-body",children:N||P?t.jsx(t.Fragment,{children:[1,2,3].map(G=>t.jsxs("div",{className:"w-flex w-items-center w-gap-3",style:{padding:"0 8px",height:34},children:[t.jsx("span",{className:"w-skel",style:{width:22,height:22}}),t.jsx("span",{className:"w-skel",style:{width:G===2?"60%":"80%",height:11}})]},G))}):t.jsxs(t.Fragment,{children:[e&&t.jsxs("button",{className:"w-menu-item",onClick:()=>{U||B()},disabled:r||U,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:(W=(ce=S==null?void 0:S.active_signin)==null?void 0:ce.user)!=null&&W.profile_picture_url?t.jsx("img",{src:S.active_signin.user.profile_picture_url,alt:"Personal"}):t.jsx(fs,{size:12})}),t.jsx("span",{className:"w-grow w-truncate",children:"Personal account"}),U&&t.jsx(Ge,{size:13,className:"w-text-primary w-none"})]}),((k==null?void 0:k.length)??0)>0&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsx("div",{className:"w-menu-label",children:"Organizations"})]}),k==null?void 0:k.map(G=>{var Je,ot;const K=G.organization,V=K.id===(C==null?void 0:C.id),de=l.has(K.id),z=Z?(T==null?void 0:T.filter(ge=>ge.organization.id===K.id))||[]:[],le=!!((Je=G.eligibility_restriction)!=null&&Je.type)&&G.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{le||(Z?ue(K.id):V||B(K.id))},disabled:r,style:le?{opacity:.55,cursor:"not-allowed"}:void 0,title:(ot=G.eligibility_restriction)==null?void 0:ot.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:K.image_url?t.jsx("img",{src:K.image_url,alt:K.name}):Y(K.name)}),t.jsx("span",{className:"w-grow w-truncate",children:K.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[le&&t.jsx(Ra,{size:12,className:"w-text-error"}),V&&q&&t.jsx("span",{className:"w-rowact",role:"button",title:"Organization settings","aria-label":"Organization settings",onClick:ge=>{ge.stopPropagation(),we()},children:t.jsx(Aa,{size:13})}),V&&!le&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave organization","aria-label":"Leave organization",onClick:ge=>{ge.stopPropagation(),ae()},children:t.jsx(Ma,{size:13})}),V&&!Z&&t.jsx(Ge,{size:13,className:"w-text-primary"}),Z&&t.jsx(Wt,{size:11,className:"w-text-muted",style:{transition:"transform 0.2s ease",transform:de?"rotate(0deg)":"rotate(-90deg)"}})]})]}),Z&&de&&!le&&t.jsxs("div",{className:"w-switch-nest",children:[z.map(ge=>{var ee,ie;const lt=V&&(M==null?void 0:M.id)===ge.id,Ke=((ee=ge.eligibility_restriction)==null?void 0:ee.type)&&ge.eligibility_restriction.type!=="none";return t.jsxs("button",{className:"w-menu-item",onClick:()=>{!lt&&!Ke&&Q(ge.id)},disabled:r,style:Ke?{opacity:.55,cursor:"not-allowed"}:void 0,title:(ie=ge.eligibility_restriction)==null?void 0:ie.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:ge.image_url?t.jsx("img",{src:ge.image_url,alt:ge.name}):Y(ge.name).charAt(0)}),t.jsx("span",{className:"w-grow w-truncate",children:ge.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[Ke&&t.jsx(Ra,{size:12,className:"w-text-error"}),lt&&tt&&t.jsx("span",{className:"w-rowact",role:"button",title:"Workspace settings","aria-label":"Workspace settings",onClick:me=>{me.stopPropagation(),ne()},children:t.jsx(Aa,{size:13})}),lt&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave workspace","aria-label":"Leave workspace",onClick:me=>{me.stopPropagation(),re()},children:t.jsx(Ma,{size:13})}),lt&&t.jsx(Ge,{size:12,className:"w-text-primary"})]})]},ge.id)}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>{w(K.id),h.open()},disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New workspace"})]})]})]},K.id)}),L&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>u.open(),disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New organization"})]})]})]})})]}),document.body),O&&L&&t.jsx(Yc,{isOpen:u.isOpen,onClose:u.close,onCreated:_}),t.jsx(t0,{isOpen:f.isOpen,onClose:f.close}),Z&&t.jsxs(t.Fragment,{children:[t.jsx(Hr,{isOpen:g.isOpen,onClose:g.close}),t.jsx(Or,{isOpen:h.isOpen,onClose:()=>{h.close(),w(null)},organizationId:x||void 0})]})]})})},c0=o.createContext(void 0),aa=()=>{const e=o.useContext(c0);if(!e)throw new Error("useScreenContext must be used within a ScreenProvider");return e},fe=(...e)=>e.filter(Boolean).join(" "),d0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-contents",e),...a}));d0.displayName="TypographyProvider";const hr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card","w-flex-col","w-full","w-minh-full",e),...a}));hr.displayName="Container";const u0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-tabsbar",e),...a}));u0.displayName="TabsContainer";const m0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}));m0.displayName="TabsList";const Ca=o.forwardRef(({$isActive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:fe("w-tab",e&&"w-tab--active",a),...s}));Ca.displayName="Tab";const Na=o.forwardRef(({className:e,...a},s)=>t.jsx("span",{ref:s,className:fe("w-inline","w-gap-1",e),...a}));Na.displayName="TabIcon";const p0=o.forwardRef(({className:e,children:a,...s},r)=>t.jsx("div",{ref:r,className:fe("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}));p0.displayName="TabContent";const Im=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:fe("w-btn","w-btn--icon",e),...a}));Im.displayName="IconButton";const h0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-justify-between","w-wrap","w-gap-3",e),...a}));h0.displayName="HeaderCTAContainer";const Vm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-start","w-gap-6",e),...a}));Vm.displayName="ProfileSectionLayout";const zm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-none",e),...a}));zm.displayName="ProfileImageContainer";const f0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-vrow",e),...a}));f0.displayName="SecurityItemRow";const w0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-grow",e),...a}));w0.displayName="SecurityItemContent";const g0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-2","w-none",e),...a}));g0.displayName="SecurityItemActions";const zr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-sechead",e),...a}));zr.displayName="ResponsiveHeaderContainer";const fn=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-full",e),...a}));fn.displayName="DesktopTableContainer";const x0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-gap-3",e),...a}));x0.displayName="FormRow";const Dm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-vrow",e),...a}));Dm.displayName="ConnectionItemRow";const Um=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-2","w-grow",e),...a}));Um.displayName="ConnectionLeft";const Wm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-justify-end","w-gap-1","w-none",e),...a}));Wm.displayName="ConnectionRight";const Dr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-iconbox",e),...a}));Dr.displayName="IconWrapper";const Bm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-wrap","w-gap-2",e),...a}));Bm.displayName="ButtonActions";const v0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-page-head",e),...a}));v0.displayName="PageHeader";const Gm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-avatar",e),...a}));Gm.displayName="PageHeaderAvatar";const b0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-1","w-grow",e),...a}));b0.displayName="PageHeaderInfo";const y0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-sec","w-truncate",e),...a}));y0.displayName="PageHeaderName";const j0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-secsub","w-truncate",e),...a}));j0.displayName="PageHeaderSub";const qm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-1","w-none",e),...a}));qm.displayName="PageHeaderActions";const Km=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-4",e),...a}));Km.displayName="PageContent";const Ym=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:fe("w-card",e),...a}));Ym.displayName="Card";const Qm=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:fe("w-card","w-danger",e),...a}));Qm.displayName="DangerCard";const Jm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card-head",e),...a}));Jm.displayName="CardHeader";const Xm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-1","w-grow",e),...a}));Xm.displayName="CardTitleBlock";const e6=o.forwardRef(({className:e,...a},s)=>t.jsx("h3",{ref:s,className:fe("w-sec",e),...a}));e6.displayName="CardTitle";const t6=o.forwardRef(({className:e,...a},s)=>t.jsx("p",{ref:s,className:fe("w-secsub",e),...a}));t6.displayName="CardSubtitle";const a6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));a6.displayName="CardActions";const s6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-hr",e),...a}));s6.displayName="CardDivider";const n6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card-body",e),...a}));n6.displayName="CardBody";const r6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card-foot",e),...a}));r6.displayName="CardFooter";const i6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-list",e),...a}));i6.displayName="RowList";const o6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-rowitem",e),...a}));o6.displayName="RowItem";const l6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-1","w-grow",e),...a}));l6.displayName="RowInfo";const c6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-sec",e),...a}));c6.displayName="RowTitle";const d6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-secsub",e),...a}));d6.displayName="RowSub";const u6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));u6.displayName="RowActions";const m6={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},Ka=({$variant:e="neutral",className:a,children:s,...r})=>t.jsxs("span",{className:fe("w-pill",m6[e],a),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),p6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-list",e),...a}));p6.displayName="Table";const h6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:fe("w-listhead","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));h6.displayName="TableHead";const f6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:e,...a}));f6.displayName="Th";const w6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:fe("w-row","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));w6.displayName="Tr";const g6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-truncate","w-text-secondary",e),...a}));g6.displayName="Td";const x6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-grid-2",e),...a}));x6.displayName="FieldGrid";const v6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-field",e),...a}));v6.displayName="Field";const b6=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:fe("w-label",e),...a}));b6.displayName="FieldLabel";const y6=()=>{var T,P;const{deployment:e}=je(),{refetch:a}=it(),{user:s,updateProfile:r,deleteAccount:i}=va(),{toast:l}=aa(),[m,c]=o.useState(""),[d,p]=o.useState(""),[u,f]=o.useState(""),[h,g]=o.useState(!1),[x,w]=o.useState(!1),[b,j]=o.useState(!1),[v,k]=o.useState("");o.useEffect(()=>{s&&!h&&(c(s.first_name||""),p(s.last_name||""),f(s.username||""),g(!0))},[s,h]);const N=o.useCallback(async()=>{if(s)try{const S={};m!==s.first_name&&(S.first_name=m),d!==s.last_name&&(S.last_name=d),u!==s.username&&(S.username=u),Object.keys(S).length>0&&await r(S)}catch(S){l(S.message||"Failed to save profile changes","error")}},[s,r,m,d,u,l]),_=S=>{c(S.target.value)},C=S=>{p(S.target.value)},y=S=>{f(S.target.value)},E=()=>{N()},M=()=>{N()},F=()=>{N()};if(!s)return t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})});const A=async()=>{if(!(!s||v!=="delete this account")){j(!0);try{await i(""),l("Account deleted successfully","info"),await a()}catch(S){l(S.message||"Failed to delete account","error")}finally{j(!1),k(""),w(!1)}}};return t.jsxs("div",{className:"w-flex-col w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx("p",{className:"w-secsub",children:"Basic information about your profile"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs(x0,{children:[t.jsxs(We,{className:"w-grow",children:[t.jsx(Te,{htmlFor:"firstName",children:"First Name"}),t.jsx(be,{id:"firstName",type:"text",value:m,onChange:_,onBlur:E,placeholder:"Enter your first name",required:!0})]}),t.jsxs(We,{className:"w-grow",children:[t.jsx(Te,{htmlFor:"lastName",children:"Last Name"}),t.jsx(be,{id:"lastName",type:"text",value:d,onChange:C,onBlur:M,placeholder:"Enter your last name",required:!0})]})]}),((P=(T=e==null?void 0:e.auth_settings)==null?void 0:T.username)==null?void 0:P.enabled)&&t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"username",children:"Username"}),t.jsx(be,{id:"username",type:"text",value:u,onChange:y,onBlur:F,placeholder:"Enter your username",required:!0})]})]})]}),t.jsx("div",{className:"w-hr"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-sec",children:"Danger Zone"}),t.jsx("p",{className:"w-secsub",children:"Irreversible and destructive actions"})]}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-full",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete Account"}),t.jsx("div",{className:"w-secsub",children:"Once you delete your account, there is no going back. Please be certain."})]}),t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>{x?(w(!1),k("")):w(!0)},children:x?"Cancel":"Delete"})]}),x&&t.jsxs("div",{className:"w-full w-flex-col w-gap-3",children:[t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),t.jsx(be,{id:"confirm_username",type:"text",value:v,onChange:S=>k(S.target.value),placeholder:"delete this account"})]}),t.jsx(se,{$destructive:!0,$fullWidth:!0,onClick:A,disabled:v!=="delete this account"||b,children:b?t.jsx(_e,{size:12}):"Delete Forever"})]})]})]})]})},Gi=({onClose:e,onAddEmail:a,onAttemptVerification:s,onPrepareVerification:r,existingEmail:i,triggerRef:l})=>{const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=aa(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const _=y=>{m.current&&!m.current.contains(y.target)&&e()},C=y=>{y.key==="Escape"&&e()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]);const[f,h]=o.useState(i?"otp":"email"),[g,x]=o.useState(i||""),[w,b]=o.useState(""),[j,v]=o.useState(!1),k=async()=>{if(!(!g||j)){v(!0);try{await a(g),h("otp")}catch(_){p(_.message||"Failed to add email. Please try again.","error")}finally{v(!1)}}},N=async()=>{v(!0);try{await s(w),e()}catch(_){p(_.message||"Failed to verify email. Check the code and try again.","error")}finally{v(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:f==="email"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add email address"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx(be,{id:"email-input",type:"email",placeholder:"you@company.com",value:g,onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&k()},autoFocus:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:!g||j,children:j?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!i&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("email"),children:[t.jsx(rn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify your email"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:g})]})]}),t.jsx(ba,{onComplete:async _=>b(_),onResend:r,isSubmitting:j})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:w.length<6||j,children:j?"Verifying…":"Verify"})]})]})}):null},j6=()=>{var M,F,A,T;const{deployment:e}=je(),{toast:a}=aa(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createEmailAddress:g,deleteEmailAddress:x,prepareEmailVerification:w,attemptEmailVerification:b,makeEmailPrimary:j}=va();if(!((F=(M=e==null?void 0:e.auth_settings)==null?void 0:M.email_address)!=null&&F.enabled))return null;const v=(P,S)=>{p($=>{const H=new Set($);return S?H.add(P):H.delete(P),H})},k=async P=>{v(P,!0);try{await j(P),await h.refetch(),a("Primary email updated","info")}catch(S){a(S.message||"Failed to update primary email","error")}finally{v(P,!1)}},N=async P=>{if(P===(h==null?void 0:h.primary_email_address_id)){a("Cannot delete primary email. Set another email as primary first.","error");return}v(P,!0);try{await x(P),await h.refetch(),a("Email removed","info")}catch(S){a(S.message||"Failed to delete email address. Please try again.","error")}finally{v(P,!1)}},_=async P=>{v(P,!0);try{await w(P),await h.refetch(),c(P)}catch(S){a(S.message||"Failed to send verification","error")}finally{v(P,!1)}},C=(h==null?void 0:h.user_email_addresses)||[],y=P=>P.id===(h==null?void 0:h.primary_email_address_id)?t.jsx(Ka,{$variant:"success",children:"Primary"}):P.verified?t.jsx(Ka,{$variant:"neutral",children:"Backup"}):t.jsx(Ka,{$variant:"warning",children:"Pending verification"}),E=P=>{const S=P.id===(h==null?void 0:h.primary_email_address_id),$=d.has(P.id);return S?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[P.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:$,onClick:()=>k(P.id),children:"Make primary"}),!P.verified&&t.jsx(se,{ref:H=>{H&&(f.current[P.id]=H)},$size:"sm",$outline:!0,disabled:$,onClick:()=>_(P.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:$,onClick:()=>N(P.id),children:$?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(zr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Email addresses"}),t.jsx("div",{className:"w-secsub",children:"Sign in and receive notifications at these addresses."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add email"}),i&&t.jsx(Gi,{triggerRef:u,onClose:()=>l(!1),onAddEmail:async P=>{const S=await g(P);r(S.data.id),await w(S.data.id),h.refetch()},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async P=>{await b(s,P),h.refetch(),l(!1),r(""),a("Email added and verified","info")}})]})]}),C.length?t.jsx(t.Fragment,{children:t.jsx(fn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Email address"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:C.map(P=>t.jsxs(rt,{children:[t.jsx(Qe,{children:P.email}),t.jsx(Qe,{children:y(P)}),t.jsx(It,{children:E(P)})]},P.id))})]})})}):t.jsx(Nt,{title:"No email addresses",description:"Add an email address to get started."}),m&&t.jsx(Gi,{existingEmail:(T=(A=h==null?void 0:h.user_email_addresses)==null?void 0:A.find(P=>P.id===m))==null?void 0:T.email,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async P=>{await b(m,P),h.refetch(),c(null),a("Email verified","info")}})]})},qi=({onClose:e,onAddPhone:a,onAttemptVerification:s,existingPhone:r,onPrepareVerification:i,triggerRef:l})=>{var y;const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=aa(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const E=F=>{m.current&&!m.current.contains(F.target)&&e()},M=F=>{F.key==="Escape"&&e()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",M)}},[e]);const[f,h]=o.useState(r?"otp":"phone"),[g,x]=o.useState((r==null?void 0:r.replace(/^\+\d+/,""))||""),[w,b]=o.useState((y=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:y.pop()),[j,v]=o.useState(""),[k,N]=o.useState(!1),_=async()=>{if(!(!g||k)){N(!0);try{await a(g,w||""),h("otp")}catch(E){p(E.message||"Failed to add phone number. Please try again.","error")}finally{N(!1)}}},C=async()=>{N(!0);try{await s(j),e()}catch(E){p(E.message||"Failed to verify phone. Check the code and try again.","error")}finally{N(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:f==="phone"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add phone number"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(js,{value:g,onChange:E=>x(E.target.value),error:"",countryCode:w,setCountryCode:b})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!g||k,children:k?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!r&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("phone"),children:[t.jsx(rn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify phone number"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:r||g})]})]}),t.jsx(ba,{onComplete:E=>v(E),onResend:async()=>i(),isSubmitting:k})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:C,disabled:j.length!==6||k,children:k?"Verifying…":"Verify"})]})]})}):null},_6=()=>{var F,A,T,P;const{deployment:e}=je(),{toast:a}=aa(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createPhoneNumber:g,deletePhoneNumber:x,preparePhoneVerification:w,attemptPhoneVerification:b,makePhonePrimary:j}=va();if(!((A=(F=e==null?void 0:e.auth_settings)==null?void 0:F.phone_number)!=null&&A.enabled))return null;const v=(S,$)=>{p(H=>{const R=new Set(H);return $?R.add(S):R.delete(S),R})},k=S=>{const $=qs.find(H=>H.dialCode===S);return($==null?void 0:$.flag)||"🌍"},N=async S=>{v(S,!0);try{await j(S),await h.refetch(),a("Primary phone updated","info")}catch($){a($.message||"Failed to update primary phone","error")}finally{v(S,!1)}},_=async S=>{if(S===(h==null?void 0:h.primary_phone_number_id)){a("Cannot delete primary phone. Set another phone as primary first.","error");return}v(S,!0);try{await x(S),await h.refetch(),a("Phone removed","info")}catch($){a($.message||"Failed to delete phone. Please try again.","error")}finally{v(S,!1)}},C=async S=>{v(S,!0);try{await w(S),await h.refetch(),c(S)}catch($){a($.message||"Failed to send verification","error")}finally{v(S,!1)}},y=(h==null?void 0:h.user_phone_numbers)||[],E=S=>S.id===(h==null?void 0:h.primary_phone_number_id)?t.jsx(Ka,{$variant:"success",children:"Primary"}):S.verified?t.jsx(Ka,{$variant:"neutral",children:"Backup"}):t.jsx(Ka,{$variant:"warning",children:"Pending verification"}),M=S=>{const $=S.id===(h==null?void 0:h.primary_phone_number_id),H=d.has(S.id);return $?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[S.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:H,onClick:()=>N(S.id),children:"Make primary"}),!S.verified&&t.jsx(se,{ref:R=>{R&&(f.current[S.id]=R)},$size:"sm",$outline:!0,disabled:H,onClick:()=>C(S.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:H,onClick:()=>_(S.id),children:H?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(zr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Phone numbers"}),t.jsx("div",{className:"w-secsub",children:"Used for sign-in and two-factor authentication."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add phone"}),i&&t.jsx(qi,{triggerRef:u,onClose:()=>l(!1),onAddPhone:async(S,$)=>{const H=await g(S,$);r(H.data.id),await w(H.data.id)},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async S=>{await b(s,S),h.refetch(),l(!1),r(""),a("Phone added and verified","info")}}),m&&t.jsx(qi,{existingPhone:(P=(T=h==null?void 0:h.user_phone_numbers)==null?void 0:T.find(S=>S.id===m))==null?void 0:P.phone_number,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async S=>{await b(m,S),h.refetch(),c(null),a("Phone verified","info")}})]})]}),y.length?t.jsx(t.Fragment,{children:t.jsx(fn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Phone number"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:y.map(S=>t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("span",{className:"w-inline w-gap-2",children:[t.jsx("span",{children:k(S.country_code)}),t.jsx("span",{className:"w-text-secondary",children:S.country_code}),t.jsx("span",{children:S.phone_number})]})}),t.jsx(Qe,{children:E(S)}),t.jsx(It,{children:M(S)})]},S.id))})]})})}):t.jsx(Nt,{title:"No phone numbers",description:"Add a phone number to get started."})]})},k6=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),t.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),t.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),t.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),C6={google_oauth:{icon:t.jsx(Cc,{}),label:"Google"},microsoft_oauth:{icon:t.jsx(k6,{}),label:"Microsoft"},github_oauth:{icon:t.jsx(kc,{}),label:"GitHub"},gitlab_oauth:{icon:t.jsx(Ec,{}),label:"GitLab"},linkedin_oauth:{icon:t.jsx(Sc,{}),label:"LinkedIn"},discord_oauth:{icon:t.jsx(Ac,{}),label:"Discord"},x_oauth:{icon:t.jsx(Nc,{}),label:"X"}},N6=()=>{const{user:e,disconnectSocialConnection:a,connectSocialAccount:s}=va(),{deployment:r}=je(),i=(r==null?void 0:r.social_connections.filter(c=>c.enabled))||[],l=c=>{s({provider:c,redirectUri:window.location.href})},m=async c=>{await a(c.toString()),e.refetch()};return i.length===0?t.jsx(Nt,{title:"No providers available",description:"Social sign-in providers have not been configured for this app."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-gap-3",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Connected accounts"}),t.jsx("div",{className:"w-secsub",children:"Sign in faster by linking third-party accounts."})]})}),t.jsx("div",{className:"w-list",children:i.map(c=>{var f;const d=C6[c.provider];if(!d)return null;const p=((f=e==null?void 0:e.social_connections)==null?void 0:f.filter(h=>h.provider===c.provider))||[],u=p.length>0;return t.jsxs("div",{className:"w-vrow",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx(Dr,{children:d.icon}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-grow",children:[t.jsx("div",{className:"w-sec",children:d.label}),u?t.jsx("div",{className:"w-flex w-wrap w-gap-1",children:p.map(h=>t.jsxs("span",{className:"w-chip",children:[t.jsx("span",{className:"w-truncate",children:h.email_address}),t.jsx("span",{className:"w-chip-x",role:"button",onClick:()=>m(h.id),title:"Remove connection","aria-label":"Remove connection",children:t.jsx(Pa,{size:10,weight:"bold"})})]},h.id))}):t.jsx("span",{className:"w-secsub",children:"Not linked"})]})]}),t.jsx("div",{className:`w-flex w-justify-end w-none${u?" w-row-act-top":""}`,children:t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>l(c.provider),children:u?"Link another":"Link"})})]},c.provider)})})]})};var S6=Object.defineProperty,en=Object.getOwnPropertySymbols,_0=Object.prototype.hasOwnProperty,k0=Object.prototype.propertyIsEnumerable,Ki=(e,a,s)=>a in e?S6(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s,fr=(e,a)=>{for(var s in a||(a={}))_0.call(a,s)&&Ki(e,s,a[s]);if(en)for(var s of en(a))k0.call(a,s)&&Ki(e,s,a[s]);return e},wr=(e,a)=>{var s={};for(var r in e)_0.call(e,r)&&a.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&en)for(var r of en(e))a.indexOf(r)<0&&k0.call(e,r)&&(s[r]=e[r]);return s};/**
108
+ 10.0.0.0/24`,className:"w-input--area w-mono-sm"})]})]})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Wi,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger",children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Delete workspace"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this workspace, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{k(!v),w("")},children:v?"Cancel":"Delete workspace"})]}),v&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(We,{children:[t.jsxs(Te,{htmlFor:"confirm_workspace_name",children:["Type ",t.jsx("strong",{children:e.name})," to confirm"]}),t.jsx(be,{id:"confirm_workspace_name",type:"text",value:x,onChange:F=>w(F.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:_,disabled:x!==e.name||b,children:b?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})},E4=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{toast:g}=Ct(),{inviteMember:x}=Ut(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name}));o.useEffect(()=>{h(!0);const k=C=>{i.current&&!i.current.contains(C.target)&&(e==null||e())},N=C=>{C.key==="Escape"&&(e==null||e())},_=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",N)},100);return()=>{clearTimeout(_),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]);const j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){g("Please enter a valid email address","error");return}if(k.length>320){g("Email address is too long","error");return}u(!0);try{await x({email:k,workspaceRoleId:c.id}),a==null||a()}catch(N){const _=N.message||"Failed to send invitation. Please try again.";g(_,"error")}finally{u(!1)}}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,maxHeight:w!=null&&w.maxHeight?`${w.maxHeight}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-workspace-member-title",children:"Invite member"}),t.jsxs(We,{children:[t.jsx(Te,{children:"Email Address"}),t.jsx(be,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),t.jsxs(We,{children:[t.jsx(Te,{children:"Role"}),t.jsx(mn,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:14}):"Send invite"})]})]}):null},A4=()=>{const{activeWorkspace:e,getMembers:a,getRoles:s,removeMember:r,addMemberRole:i,removeMemberRole:l}=Ut(),{session:m}=it(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(""),[w,b]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>{const A=setTimeout(()=>{x(d),f(1)},500);return()=>clearTimeout(A)},[d]);const{data:v,mutate:k}=Ce(e?`wacht-api-workspaces:${e.id}:members:${u}:${h}:${g}`:null,()=>a==null?void 0:a({page:u,limit:h,search:g}),{keepPreviousData:!0}),N=(v==null?void 0:v.data)||[],_=(v==null?void 0:v.meta)||{total:0,limit:10},C=Math.ceil(_.total/(_.limit||10)),{data:y=[]}=Ce(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),E=y,M=async(A,T,P)=>{try{P?(await l(A,T),c("Role removed","info")):(await i(A,T),c("Role added","info")),k()}catch{c("Failed to update role","error")}},F=async A=>{try{await r(A),c("Member removed","info"),k()}catch{c("Failed to remove member","error")}};return v?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Wc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[_.total>0&&t.jsxs("div",{className:"w-text-muted w-secsub",children:[_.total," member",_.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>b(!0),$size:"sm",children:"Invite"})]})]}),w&&t.jsx(E4,{onClose:()=>b(!1),onSuccess:()=>{k(),b(!1)},roles:E,triggerRef:j}),N.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):t.jsx(t.Fragment,{children:t.jsx(Zr,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Role"})]})}),t.jsx(Tt,{children:N.map(A=>t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsx(M4,{member:A,session:m})}),t.jsx(Qe,{children:new Date(A.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsx(R4,{member:A,roles:E,onToggle:(T,P)=>M(A.id,T,P),onRemove:()=>F(A.id)})})]},A.id))})]})})}),C>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4",children:[t.jsx(se,{onClick:()=>f(A=>Math.max(1,A-1)),disabled:u===1,$size:"sm",children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",C]}),t.jsx(se,{onClick:()=>f(A=>Math.min(C,A+1)),disabled:u===C,$size:"sm",children:"Next"})]})]}):t.jsx(_e,{})},M4=({member:e,session:a,subtitle:s})=>{var m,c,d;const r=e.public_user_data||e.user,i=(r==null?void 0:r.id)===((m=a==null?void 0:a.active_signin)==null?void 0:m.user_id),l=(p="",u="")=>`${p[0]||""}${u[0]||""} `.toUpperCase();return t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx("div",{className:"w-avatar",children:r!=null&&r.profile_picture_url?t.jsx("img",{src:r.profile_picture_url,alt:"Avatar"}):l(r==null?void 0:r.first_name,r==null?void 0:r.last_name)||"?"}),t.jsxs("div",{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:r?`${r.first_name||""} ${r.last_name||""} `.trim()||((c=r.primary_email_address)==null?void 0:c.email):"Unknown"}),i&&t.jsx("span",{className:"w-pill",children:"You"})]}),t.jsxs("div",{className:"w-flex w-wrap w-gap-2 w-secsub",children:[t.jsx("span",{children:(d=r==null?void 0:r.primary_email_address)==null?void 0:d.email}),s&&t.jsxs("span",{className:"w-text-muted",children:["• ",s]})]})]})]})},R4=({member:e,roles:a,onToggle:s,onRemove:r})=>{var m;const i=e.roles||[],l=c=>i.some(d=>d.id===c);return t.jsxs(ks,{children:[t.jsx(Ns,{children:t.jsxs(se,{$outline:!0,$size:"sm",className:"w-justify-between w-rolepick-btn",children:[i.length>0?(m=i==null?void 0:i[0])==null?void 0:m.name:"No role"," ",t.jsx(Wt,{size:14})]})}),t.jsxs(Cs,{children:[a.map(c=>{const d=l(c.id);return t.jsx(ta,{onClick:()=>s(c.id,d),children:t.jsxs("div",{className:"w-flex w-justify-between w-full w-gap-3",children:[t.jsx("span",{children:c.name}),d&&t.jsx(Ge,{size:14,className:"w-text-success"})]})},c.id)}),t.jsx(Dc,{}),t.jsx(ta,{$destructive:!0,onClick:r,children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(br,{size:14})," Remove Member"]})})]})]})},L4=({onClose:e,onSuccess:a,roles:s,createInvitation:r,triggerRef:i})=>{const l=o.useRef(null),[m,c]=o.useState(""),[d,p]=o.useState(s[0]||null),[u,f]=o.useState(!1),[h,g]=o.useState(!1),{toast:x}=Ct(),w=bt({contentRef:l,triggerRef:i,isOpen:h,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=m.trim().toLowerCase();if(!(!k||!d)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}f(!0);try{await r({email:k,role_id:d.id}),a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{f(!1)}}};return o.useEffect(()=>{g(!0);const k=_=>{l.current&&!l.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),h?t.jsxs("div",{ref:l,className:"w-pop w-pop--wide w-pop-body",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Email"}),t.jsx(be,{type:"email",placeholder:"colleague@company.com",value:m,onChange:k=>c(k.target.value),onKeyDown:k=>{k.key==="Enter"&&m&&d&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Role"}),t.jsx(mn,{options:b,value:d==null?void 0:d.id,onChange:k=>p(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(se,{$size:"sm",$outline:!0,$fullWidth:!0,onClick:e,children:"Cancel"}),t.jsx(se,{$size:"sm",$fullWidth:!0,onClick:v,disabled:!m||!d||u,children:u?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},P4=()=>{const{activeWorkspace:e,loading:a,getRoles:s,getInvitations:r,inviteMember:i,discardInvitation:l,resendInvitation:m}=Ut(),{toast:c}=Ct(),[d,p]=o.useState(!0),[u,f]=o.useState(!0),[h,g]=o.useState([]),[x,w]=o.useState([]),[b,j]=o.useState(!1),v=o.useRef(null),k=async()=>{if(e){p(!0),f(!0);try{const[C,y]=await Promise.all([s(),r()]);w(C),g(y)}catch{}finally{p(!1),f(!1)}}};o.useEffect(()=>{k()},[e==null?void 0:e.id]);const N=async C=>{try{await l(C),k(),c("Invitation cancelled","info")}catch{c("Failed to cancel invitation","error")}},_=async C=>{try{await m(C),k(),c("Invitation resent","info")}catch{c("Failed to resend invitation","error")}};return a||d||u?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(a0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this workspace."})]}),t.jsx(se,{ref:v,onClick:()=>j(!0),$size:"sm",children:"Invite"})]}),b&&t.jsx(L4,{onClose:()=>j(!1),onSuccess:()=>{k(),j(!1),c("Invitation sent","info")},roles:x,createInvitation:C=>i({email:C.email,workspaceRoleId:C.role_id}),triggerRef:v}),h.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to your workspace."}):t.jsx(t.Fragment,{children:t.jsx(Zr,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Email"}),t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Invited"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:h.map(C=>{var y,E;return t.jsxs(rt,{children:[t.jsx(Qe,{children:C.email}),t.jsx(Qe,{children:((y=C.initial_workspace_role)==null?void 0:y.name)||((E=C.initial_organization_role)==null?void 0:E.name)||"No role"}),t.jsx(Qe,{children:new Date(C.created_at).toLocaleDateString()}),t.jsx(It,{children:t.jsx($4,{onResend:()=>_(C.id),onCancel:()=>N(C.id)})})]},C.id)})})]})})})]})},$4=({onResend:e,onCancel:a})=>t.jsxs(ks,{children:[t.jsx(Ns,{children:t.jsx(Xs,{children:"•••"})}),t.jsxs(Cs,{children:[t.jsxs(ta,{onClick:e,children:[t.jsx(Rl,{size:16})," Resend"]}),t.jsxs(ta,{$destructive:!0,onClick:a,children:[t.jsx(br,{size:16})," Cancel"]})]})]}),Bi=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var C,y;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=je(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=((C=g==null?void 0:g.b2b_settings)==null?void 0:C.workspace_permissions)||((y=g==null?void 0:g.b2b_settings)==null?void 0:y.organization_permissions)||[],v=Array.isArray(j)?j.map(E=>({value:E,label:E})):[];o.useEffect(()=>{h(!0);const E=A=>{i.current&&!i.current.contains(A.target)&&(e==null||e())},M=A=>{A.key==="Escape"&&(e==null||e())},F=setTimeout(()=>{document.addEventListener("mousedown",E),document.addEventListener("keydown",M)},100);return()=>{clearTimeout(F),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",M)}},[e]);const k=E=>E.trim().replace(/[<>"'&]/g,""),N=E=>E.length>=2&&E.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(E),_=async()=>{const E=k(l);if(!E){x("Please enter a role name","error");return}if(!N(E)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const M={id:s==null?void 0:s.id,name:E,permissions:c};a==null||a(M)}catch(M){x(M.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(be,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:E=>m(E.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(qc,{options:v,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null},O4=()=>{var N;const{activeWorkspace:e,loading:a,getRoles:s,createRole:r,deleteRole:i}=Ut(),{deployment:l}=je(),{toast:m}=Ct(),[c,d]=o.useState({isOpen:!1}),[p,u]=o.useState(null),[f,h]=o.useState(null),g=o.useRef(null),x=o.useRef(new Map),{data:w=[],isLoading:b,mutate:j}=Ce(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),v=async _=>{try{await r(_.name,_.permissions||[]),m("Role saved successfully","info"),d({isOpen:!1}),j()}catch{m("Failed to save role","error")}},k=async _=>{try{await i(_),m("Role deleted","info"),u(null),j()}catch{m("Failed to delete role","error")}};return a||b?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(a0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for this workspace."})]}),((N=l==null?void 0:l.b2b_settings)==null?void 0:N.custom_workspace_role_enabled)&&t.jsx(se,{ref:g,onClick:()=>d({isOpen:!0,triggerElement:g.current}),$size:"sm",children:"Add role"})]}),c.isOpen&&!c.role&&t.jsx(Bi,{triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v}),w.length===0?t.jsx(Nt,{title:"No roles yet",description:"Create workspace-specific roles to manage access."}):t.jsx(t.Fragment,{children:t.jsx(Zr,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Permissions"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:w.map(_=>{var C;return t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2 w-wrap",children:[t.jsx("span",{className:"w-sec",children:_.name}),!pr(_)&&t.jsx("span",{className:"w-pill",children:"Default"})]})}),t.jsx(Qe,{children:t.jsxs("span",{className:"w-text-secondary",children:[(C=_.permissions)==null?void 0:C.join(", "),!pr(_)&&" • Cannot be edited or deleted"]})}),t.jsx(It,{children:t.jsx(Z4,{role:_,onEdit:y=>d({isOpen:!0,role:_,triggerElement:y}),onDelete:()=>u(_.id),open:f===_.id,onOpenChange:y=>h(y?_.id:null),dropdownButtonRefs:x})})]},_.id)})})]})})}),p&&t.jsx(Ja,{title:"Delete role?",description:"Are you sure? This will remove the role from all workspace members.",onConfirm:()=>{const _=w.find(C=>C.id===p);_&&k(_)},onCancel:()=>u(null)}),c.isOpen&&c.role&&t.jsx(Bi,{role:c.role,triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v})]})},Z4=({role:e,onEdit:a,onDelete:s,open:r,onOpenChange:i,dropdownButtonRefs:l})=>pr(e)?t.jsxs(ks,{open:r,openChange:i,children:[t.jsx(Ns,{children:t.jsx(Xs,{ref:c=>{c&&l.current.set(e.id,c)},children:"•••"})}),t.jsxs(Cs,{children:[t.jsx(ta,{onClick:()=>a(l.current.get(e.id)??null),children:"Edit Role"}),t.jsxs(ta,{$destructive:!0,onClick:s,children:[t.jsx(br,{size:16})," Remove Role"]})]})]}):t.jsx(Xs,{disabled:!0,title:"Deployment roles cannot be edited","aria-label":"Deployment roles cannot be edited",children:"•••"}),H4=e=>(e||"").slice(0,2).toUpperCase()||"W",s0=()=>{var b,j;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Ut(),{deployment:r}=je(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(a&&!e)return t.jsx(Re,{children:t.jsx(Vi,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})});if(!e)return null;const w=(b=e.organization)==null?void 0:b.name;return t.jsx(Re,{children:t.jsx(v4,{children:t.jsx(Mr.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(Vi,{className:"w-relative",children:[t.jsxs(_4,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit",onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,"data-busy":u?"":void 0,title:"Change logo","aria-label":"Change workspace logo",children:[e.image_url?t.jsx("img",{src:e.image_url,alt:e.name}):H4(e.name),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(nn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",className:"w-none",hidden:!0,onChange:x}),t.jsxs(k4,{children:[t.jsx(C4,{children:e.name}),t.jsx(N4,{children:w?`${w} · Workspace settings`:"Workspace settings"})]})]}),t.jsx(b4,{children:t.jsxs(y4,{children:[t.jsx(Hs,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Fs,{children:[t.jsx(Aa,{size:14})," General"]})}),t.jsx(Hs,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Fs,{children:[t.jsx(ds,{size:14})," Members"]})}),t.jsx(Hs,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Fs,{children:[t.jsx(Rl,{size:14})," Invitations"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.custom_workspace_role_enabled)&&t.jsx(Hs,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Fs,{children:[t.jsx(ea,{size:14})," Roles"]})})]})}),t.jsxs(j4,{children:[i==="general"&&t.jsx(S4,{}),i==="members"&&t.jsx(A4,{}),i==="invitations"&&t.jsx(P4,{}),i==="roles"&&t.jsx(O4,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Ta,{size:14}):t.jsx(Ge,{size:14})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},Hr=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{className:"w-dialog--panel",children:[r&&t.jsx(ze.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(s0,{}),l&&t.jsx(ze.Footer,{children:l})]})})}),n0=["organization:admin"],r0=["organization:admin","organization:manage"],i0=["workspace:admin"],o0=["workspace:admin","workspace:manage"];function Fr(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Tr(e){return Fr(e,r0)}function F4(e){return Fr(e,n0)}function Ir(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Vr(e){return Ir(e,o0)}function T4(e){return Ir(e,i0)}const l0=({showPersonal:e=!0})=>{var Ee,ce,W;const[a,s]=o.useState(!1),[r,i]=o.useState(!1),[l,m]=o.useState(new Set),c=o.useRef(null),d=o.useRef(null),p=bt({triggerRef:c,isOpen:a,minWidth:300}),u=Yt(!1),f=Yt(!1),h=Yt(!1),g=Yt(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),v=as(),{organizationMemberships:k,loading:N,refetch:_}=ga(),{activeOrganization:C,activeMembership:y,leave:E}=wa(),{activeWorkspace:M,activeMembership:F,leave:A}=Ut(),{workspaces:T,loading:P}=xa(),{session:S,switchOrganization:$,switchWorkspace:H}=it(),{deployment:R}=je(),O=R==null?void 0:R.b2b_settings.organizations_enabled,Z=O&&(R==null?void 0:R.b2b_settings.workspaces_enabled),L=R==null?void 0:R.b2b_settings.allow_users_to_create_orgs,U=!y,D=o.useMemo(()=>{var K,V;return U?{name:"Personal account",image_url:(V=(K=S==null?void 0:S.active_signin)==null?void 0:K.user)==null?void 0:V.profile_picture_url,isPersonal:!0}:{name:Z&&M?`${C==null?void 0:C.name} / ${M.name}`:(C==null?void 0:C.name)||"",image_url:C==null?void 0:C.image_url,isPersonal:!1}},[U,C,M,S,Z]);if(o.useEffect(()=>{C&&Z&&m(G=>{if(G.has(C.id))return G;const K=new Set(G);return K.add(C.id),K})},[C,Z]),o.useEffect(()=>{if(!a)return;let G=null;const K=setTimeout(()=>{const V=de=>{var le,Je;const z=de.target;(le=c.current)!=null&&le.contains(z)||(Je=d.current)!=null&&Je.contains(z)||(s(!1),j(null))};document.addEventListener("mousedown",V),G=()=>document.removeEventListener("mousedown",V)},50);return()=>{clearTimeout(K),G==null||G()}},[a]),o.useEffect(()=>{if(!b)return;const G=setTimeout(()=>j(null),5e3);return()=>clearTimeout(G)},[b]),!O)return null;const Y=G=>G.split(" ").map(K=>K[0]).join("").toUpperCase().slice(0,2),B=G=>{i(!0),$(G).finally(()=>i(!1))},Q=G=>{i(!0),H(G).finally(()=>i(!1))},ue=G=>{m(K=>{const V=new Set(K);return V.has(G)?V.delete(G):V.add(G),V})},we=()=>{f.open(),s(!1)},ne=()=>{g.open(),s(!1)},ae=async()=>{if(E){j(null);try{await E(),await _(),s(!1)}catch(G){j(G instanceof Error?G.message:"Failed to leave organization")}}},re=async()=>{if(A){j(null);try{await A(),s(!1)}catch(G){j(G instanceof Error?G.message:"Failed to leave workspace")}}},Me=!!((Ee=y==null?void 0:y.eligibility_restriction)!=null&&Ee.type)&&y.eligibility_restriction.type!=="none",q=!!C&&!Me&&Tr(y),tt=!!Z&&!!M&&!Me&&Vr(F);return!!!S||N||Z&&P?t.jsx(Re,{children:t.jsx("div",{className:"w-full w-relative",children:t.jsxs("div",{className:"w-combo",children:[t.jsx("span",{className:"w-skel",style:{width:20,height:20}}),t.jsx("span",{className:"w-skel w-grow",style:{height:12}})]})})}):t.jsx(Re,{children:t.jsxs("div",{className:"w-full w-relative",children:[t.jsxs("button",{ref:c,className:"w-orgtrigger","data-open":a?"":void 0,onClick:()=>{s(!a),a||j(null)},disabled:r,children:[t.jsx("span",{className:`w-avatar w-avatar--sm${D.isPersonal,""}`,children:D.image_url?t.jsx("img",{src:D.image_url,alt:D.name}):D.isPersonal?t.jsx(fs,{size:11}):Y(D.name)}),t.jsx("span",{className:"w-grow w-truncate",children:D.name}),t.jsx(Ru,{size:13})]}),typeof window<"u"&&tn.createPortal(t.jsxs("div",{ref:d,className:"wacht-root w-menu w-flex-col",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 16px)",maxHeight:p!=null&&p.maxHeight?`${p.maxHeight}px`:420,padding:0,zIndex:99999,top:(p==null?void 0:p.top)!==void 0?`${p.top}px`:void 0,bottom:(p==null?void 0:p.bottom)!==void 0?`${p.bottom}px`:void 0,left:(p==null?void 0:p.left)!==void 0?`${p.left}px`:void 0,right:(p==null?void 0:p.right)!==void 0?`${p.right}px`:void 0,visibility:p&&a?"visible":"hidden",opacity:a&&p?1:0,transform:a?"translateY(0)":"translateY(-4px)",pointerEvents:a?"auto":"none",transition:`opacity 0.15s ease, transform 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,...v},children:[b&&t.jsxs("div",{className:"w-banner w-banner--error w-switch-banner",children:[t.jsx(Ra,{size:13}),t.jsx("span",{className:"w-banner-txt w-text-error",children:b})]}),t.jsx("div",{className:"w-grow w-switch-body",children:N||P?t.jsx(t.Fragment,{children:[1,2,3].map(G=>t.jsxs("div",{className:"w-flex w-items-center w-gap-3",style:{padding:"0 8px",height:34},children:[t.jsx("span",{className:"w-skel",style:{width:22,height:22}}),t.jsx("span",{className:"w-skel",style:{width:G===2?"60%":"80%",height:11}})]},G))}):t.jsxs(t.Fragment,{children:[e&&t.jsxs("button",{className:"w-menu-item",onClick:()=>{U||B()},disabled:r||U,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:(W=(ce=S==null?void 0:S.active_signin)==null?void 0:ce.user)!=null&&W.profile_picture_url?t.jsx("img",{src:S.active_signin.user.profile_picture_url,alt:"Personal"}):t.jsx(fs,{size:12})}),t.jsx("span",{className:"w-grow w-truncate",children:"Personal account"}),U&&t.jsx(Ge,{size:13,className:"w-text-primary w-none"})]}),((k==null?void 0:k.length)??0)>0&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsx("div",{className:"w-menu-label",children:"Organizations"})]}),k==null?void 0:k.map(G=>{var Je,ot;const K=G.organization,V=K.id===(C==null?void 0:C.id),de=l.has(K.id),z=Z?(T==null?void 0:T.filter(ge=>ge.organization.id===K.id))||[]:[],le=!!((Je=G.eligibility_restriction)!=null&&Je.type)&&G.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{le||(Z?ue(K.id):V||B(K.id))},disabled:r,style:le?{opacity:.55,cursor:"not-allowed"}:void 0,title:(ot=G.eligibility_restriction)==null?void 0:ot.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:K.image_url?t.jsx("img",{src:K.image_url,alt:K.name}):Y(K.name)}),t.jsx("span",{className:"w-grow w-truncate",children:K.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[le&&t.jsx(Ra,{size:12,className:"w-text-error"}),V&&q&&t.jsx("span",{className:"w-rowact",role:"button",title:"Organization settings","aria-label":"Organization settings",onClick:ge=>{ge.stopPropagation(),we()},children:t.jsx(Aa,{size:13})}),V&&!le&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave organization","aria-label":"Leave organization",onClick:ge=>{ge.stopPropagation(),ae()},children:t.jsx(Ma,{size:13})}),V&&!Z&&t.jsx(Ge,{size:13,className:"w-text-primary"}),Z&&t.jsx(Wt,{size:11,className:"w-text-muted",style:{transition:"transform 0.2s ease",transform:de?"rotate(0deg)":"rotate(-90deg)"}})]})]}),Z&&de&&!le&&t.jsxs("div",{className:"w-switch-nest",children:[z.map(ge=>{var ee,ie;const lt=V&&(M==null?void 0:M.id)===ge.id,Ke=((ee=ge.eligibility_restriction)==null?void 0:ee.type)&&ge.eligibility_restriction.type!=="none";return t.jsxs("button",{className:"w-menu-item",onClick:()=>{!lt&&!Ke&&Q(ge.id)},disabled:r,style:Ke?{opacity:.55,cursor:"not-allowed"}:void 0,title:(ie=ge.eligibility_restriction)==null?void 0:ie.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:ge.image_url?t.jsx("img",{src:ge.image_url,alt:ge.name}):Y(ge.name).charAt(0)}),t.jsx("span",{className:"w-grow w-truncate",children:ge.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[Ke&&t.jsx(Ra,{size:12,className:"w-text-error"}),lt&&tt&&t.jsx("span",{className:"w-rowact",role:"button",title:"Workspace settings","aria-label":"Workspace settings",onClick:me=>{me.stopPropagation(),ne()},children:t.jsx(Aa,{size:13})}),lt&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave workspace","aria-label":"Leave workspace",onClick:me=>{me.stopPropagation(),re()},children:t.jsx(Ma,{size:13})}),lt&&t.jsx(Ge,{size:12,className:"w-text-primary"})]})]},ge.id)}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>{w(K.id),h.open()},disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New workspace"})]})]})]},K.id)}),L&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>u.open(),disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New organization"})]})]})]})})]}),document.body),O&&L&&t.jsx(Yc,{isOpen:u.isOpen,onClose:u.close,onCreated:_}),t.jsx(t0,{isOpen:f.isOpen,onClose:f.close}),Z&&t.jsxs(t.Fragment,{children:[t.jsx(Hr,{isOpen:g.isOpen,onClose:g.close}),t.jsx(Or,{isOpen:h.isOpen,onClose:()=>{h.close(),w(null)},organizationId:x||void 0})]})]})})},c0=o.createContext(void 0),aa=()=>{const e=o.useContext(c0);if(!e)throw new Error("useScreenContext must be used within a ScreenProvider");return e},fe=(...e)=>e.filter(Boolean).join(" "),d0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-contents",e),...a}));d0.displayName="TypographyProvider";const hr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card","w-flex-col","w-full","w-minh-full",e),...a}));hr.displayName="Container";const u0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-tabsbar",e),...a}));u0.displayName="TabsContainer";const m0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}));m0.displayName="TabsList";const Ca=o.forwardRef(({$isActive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:fe("w-tab",e&&"w-tab--active",a),...s}));Ca.displayName="Tab";const Na=o.forwardRef(({className:e,...a},s)=>t.jsx("span",{ref:s,className:fe("w-inline","w-gap-1",e),...a}));Na.displayName="TabIcon";const p0=o.forwardRef(({className:e,children:a,...s},r)=>t.jsx("div",{ref:r,className:fe("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}));p0.displayName="TabContent";const I4=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:fe("w-btn","w-btn--icon",e),...a}));I4.displayName="IconButton";const h0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-justify-between","w-wrap","w-gap-3",e),...a}));h0.displayName="HeaderCTAContainer";const V4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-start","w-gap-6",e),...a}));V4.displayName="ProfileSectionLayout";const z4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-none",e),...a}));z4.displayName="ProfileImageContainer";const f0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-vrow",e),...a}));f0.displayName="SecurityItemRow";const w0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-grow",e),...a}));w0.displayName="SecurityItemContent";const g0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-2","w-none",e),...a}));g0.displayName="SecurityItemActions";const zr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-sechead",e),...a}));zr.displayName="ResponsiveHeaderContainer";const fn=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-full",e),...a}));fn.displayName="DesktopTableContainer";const x0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-gap-3",e),...a}));x0.displayName="FormRow";const D4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-vrow",e),...a}));D4.displayName="ConnectionItemRow";const U4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-2","w-grow",e),...a}));U4.displayName="ConnectionLeft";const W4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-justify-end","w-gap-1","w-none",e),...a}));W4.displayName="ConnectionRight";const Dr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-iconbox",e),...a}));Dr.displayName="IconWrapper";const B4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-wrap","w-gap-2",e),...a}));B4.displayName="ButtonActions";const v0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-page-head",e),...a}));v0.displayName="PageHeader";const G4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-avatar",e),...a}));G4.displayName="PageHeaderAvatar";const b0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-1","w-grow",e),...a}));b0.displayName="PageHeaderInfo";const y0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-sec","w-truncate",e),...a}));y0.displayName="PageHeaderName";const j0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-secsub","w-truncate",e),...a}));j0.displayName="PageHeaderSub";const q4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-gap-1","w-none",e),...a}));q4.displayName="PageHeaderActions";const K4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-4",e),...a}));K4.displayName="PageContent";const Y4=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:fe("w-card",e),...a}));Y4.displayName="Card";const Q4=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:fe("w-card","w-danger",e),...a}));Q4.displayName="DangerCard";const J4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card-head",e),...a}));J4.displayName="CardHeader";const X4=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-1","w-grow",e),...a}));X4.displayName="CardTitleBlock";const e6=o.forwardRef(({className:e,...a},s)=>t.jsx("h3",{ref:s,className:fe("w-sec",e),...a}));e6.displayName="CardTitle";const t6=o.forwardRef(({className:e,...a},s)=>t.jsx("p",{ref:s,className:fe("w-secsub",e),...a}));t6.displayName="CardSubtitle";const a6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));a6.displayName="CardActions";const s6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-hr",e),...a}));s6.displayName="CardDivider";const n6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card-body",e),...a}));n6.displayName="CardBody";const r6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-card-foot",e),...a}));r6.displayName="CardFooter";const i6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-list",e),...a}));i6.displayName="RowList";const o6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-rowitem",e),...a}));o6.displayName="RowItem";const l6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex-col","w-gap-1","w-grow",e),...a}));l6.displayName="RowInfo";const c6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-sec",e),...a}));c6.displayName="RowTitle";const d6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-secsub",e),...a}));d6.displayName="RowSub";const u6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));u6.displayName="RowActions";const m6={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},Ka=({$variant:e="neutral",className:a,children:s,...r})=>t.jsxs("span",{className:fe("w-pill",m6[e],a),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),p6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-list",e),...a}));p6.displayName="Table";const h6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:fe("w-listhead","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));h6.displayName="TableHead";const f6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:e,...a}));f6.displayName="Th";const w6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:fe("w-row","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));w6.displayName="Tr";const g6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-truncate","w-text-secondary",e),...a}));g6.displayName="Td";const x6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-grid-2",e),...a}));x6.displayName="FieldGrid";const v6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:fe("w-field",e),...a}));v6.displayName="Field";const b6=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:fe("w-label",e),...a}));b6.displayName="FieldLabel";const y6=()=>{var T,P;const{deployment:e}=je(),{refetch:a}=it(),{user:s,updateProfile:r,deleteAccount:i}=va(),{toast:l}=aa(),[m,c]=o.useState(""),[d,p]=o.useState(""),[u,f]=o.useState(""),[h,g]=o.useState(!1),[x,w]=o.useState(!1),[b,j]=o.useState(!1),[v,k]=o.useState("");o.useEffect(()=>{s&&!h&&(c(s.first_name||""),p(s.last_name||""),f(s.username||""),g(!0))},[s,h]);const N=o.useCallback(async()=>{if(s)try{const S={};m!==s.first_name&&(S.first_name=m),d!==s.last_name&&(S.last_name=d),u!==s.username&&(S.username=u),Object.keys(S).length>0&&await r(S)}catch(S){l(S.message||"Failed to save profile changes","error")}},[s,r,m,d,u,l]),_=S=>{c(S.target.value)},C=S=>{p(S.target.value)},y=S=>{f(S.target.value)},E=()=>{N()},M=()=>{N()},F=()=>{N()};if(!s)return t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})});const A=async()=>{if(!(!s||v!=="delete this account")){j(!0);try{await i(""),l("Account deleted successfully","info"),await a()}catch(S){l(S.message||"Failed to delete account","error")}finally{j(!1),k(""),w(!1)}}};return t.jsxs("div",{className:"w-flex-col w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx("p",{className:"w-secsub",children:"Basic information about your profile"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs(x0,{children:[t.jsxs(We,{className:"w-grow",children:[t.jsx(Te,{htmlFor:"firstName",children:"First Name"}),t.jsx(be,{id:"firstName",type:"text",value:m,onChange:_,onBlur:E,placeholder:"Enter your first name",required:!0})]}),t.jsxs(We,{className:"w-grow",children:[t.jsx(Te,{htmlFor:"lastName",children:"Last Name"}),t.jsx(be,{id:"lastName",type:"text",value:d,onChange:C,onBlur:M,placeholder:"Enter your last name",required:!0})]})]}),((P=(T=e==null?void 0:e.auth_settings)==null?void 0:T.username)==null?void 0:P.enabled)&&t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"username",children:"Username"}),t.jsx(be,{id:"username",type:"text",value:u,onChange:y,onBlur:F,placeholder:"Enter your username",required:!0})]})]})]}),t.jsx("div",{className:"w-hr"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-sec",children:"Danger Zone"}),t.jsx("p",{className:"w-secsub",children:"Irreversible and destructive actions"})]}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-full",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete Account"}),t.jsx("div",{className:"w-secsub",children:"Once you delete your account, there is no going back. Please be certain."})]}),t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>{x?(w(!1),k("")):w(!0)},children:x?"Cancel":"Delete"})]}),x&&t.jsxs("div",{className:"w-full w-flex-col w-gap-3",children:[t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),t.jsx(be,{id:"confirm_username",type:"text",value:v,onChange:S=>k(S.target.value),placeholder:"delete this account"})]}),t.jsx(se,{$destructive:!0,$fullWidth:!0,onClick:A,disabled:v!=="delete this account"||b,children:b?t.jsx(_e,{size:12}):"Delete Forever"})]})]})]})]})},Gi=({onClose:e,onAddEmail:a,onAttemptVerification:s,onPrepareVerification:r,existingEmail:i,triggerRef:l})=>{const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=aa(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const _=y=>{m.current&&!m.current.contains(y.target)&&e()},C=y=>{y.key==="Escape"&&e()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]);const[f,h]=o.useState(i?"otp":"email"),[g,x]=o.useState(i||""),[w,b]=o.useState(""),[j,v]=o.useState(!1),k=async()=>{if(!(!g||j)){v(!0);try{await a(g),h("otp")}catch(_){p(_.message||"Failed to add email. Please try again.","error")}finally{v(!1)}}},N=async()=>{v(!0);try{await s(w),e()}catch(_){p(_.message||"Failed to verify email. Check the code and try again.","error")}finally{v(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:f==="email"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add email address"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx(be,{id:"email-input",type:"email",placeholder:"you@company.com",value:g,onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&k()},autoFocus:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:!g||j,children:j?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!i&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("email"),children:[t.jsx(rn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify your email"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:g})]})]}),t.jsx(ba,{onComplete:async _=>b(_),onResend:r,isSubmitting:j})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:w.length<6||j,children:j?"Verifying…":"Verify"})]})]})}):null},j6=()=>{var M,F,A,T;const{deployment:e}=je(),{toast:a}=aa(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createEmailAddress:g,deleteEmailAddress:x,prepareEmailVerification:w,attemptEmailVerification:b,makeEmailPrimary:j}=va();if(!((F=(M=e==null?void 0:e.auth_settings)==null?void 0:M.email_address)!=null&&F.enabled))return null;const v=(P,S)=>{p($=>{const H=new Set($);return S?H.add(P):H.delete(P),H})},k=async P=>{v(P,!0);try{await j(P),await h.refetch(),a("Primary email updated","info")}catch(S){a(S.message||"Failed to update primary email","error")}finally{v(P,!1)}},N=async P=>{if(P===(h==null?void 0:h.primary_email_address_id)){a("Cannot delete primary email. Set another email as primary first.","error");return}v(P,!0);try{await x(P),await h.refetch(),a("Email removed","info")}catch(S){a(S.message||"Failed to delete email address. Please try again.","error")}finally{v(P,!1)}},_=async P=>{v(P,!0);try{await w(P),await h.refetch(),c(P)}catch(S){a(S.message||"Failed to send verification","error")}finally{v(P,!1)}},C=(h==null?void 0:h.user_email_addresses)||[],y=P=>P.id===(h==null?void 0:h.primary_email_address_id)?t.jsx(Ka,{$variant:"success",children:"Primary"}):P.verified?t.jsx(Ka,{$variant:"neutral",children:"Backup"}):t.jsx(Ka,{$variant:"warning",children:"Pending verification"}),E=P=>{const S=P.id===(h==null?void 0:h.primary_email_address_id),$=d.has(P.id);return S?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[P.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:$,onClick:()=>k(P.id),children:"Make primary"}),!P.verified&&t.jsx(se,{ref:H=>{H&&(f.current[P.id]=H)},$size:"sm",$outline:!0,disabled:$,onClick:()=>_(P.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:$,onClick:()=>N(P.id),children:$?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(zr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Email addresses"}),t.jsx("div",{className:"w-secsub",children:"Sign in and receive notifications at these addresses."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add email"}),i&&t.jsx(Gi,{triggerRef:u,onClose:()=>l(!1),onAddEmail:async P=>{const S=await g(P);r(S.data.id),await w(S.data.id),h.refetch()},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async P=>{await b(s,P),h.refetch(),l(!1),r(""),a("Email added and verified","info")}})]})]}),C.length?t.jsx(t.Fragment,{children:t.jsx(fn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Email address"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:C.map(P=>t.jsxs(rt,{children:[t.jsx(Qe,{children:P.email}),t.jsx(Qe,{children:y(P)}),t.jsx(It,{children:E(P)})]},P.id))})]})})}):t.jsx(Nt,{title:"No email addresses",description:"Add an email address to get started."}),m&&t.jsx(Gi,{existingEmail:(T=(A=h==null?void 0:h.user_email_addresses)==null?void 0:A.find(P=>P.id===m))==null?void 0:T.email,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async P=>{await b(m,P),h.refetch(),c(null),a("Email verified","info")}})]})},qi=({onClose:e,onAddPhone:a,onAttemptVerification:s,existingPhone:r,onPrepareVerification:i,triggerRef:l})=>{var y;const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=aa(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const E=F=>{m.current&&!m.current.contains(F.target)&&e()},M=F=>{F.key==="Escape"&&e()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",M)}},[e]);const[f,h]=o.useState(r?"otp":"phone"),[g,x]=o.useState((r==null?void 0:r.replace(/^\+\d+/,""))||""),[w,b]=o.useState((y=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:y.pop()),[j,v]=o.useState(""),[k,N]=o.useState(!1),_=async()=>{if(!(!g||k)){N(!0);try{await a(g,w||""),h("otp")}catch(E){p(E.message||"Failed to add phone number. Please try again.","error")}finally{N(!1)}}},C=async()=>{N(!0);try{await s(j),e()}catch(E){p(E.message||"Failed to verify phone. Check the code and try again.","error")}finally{N(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:f==="phone"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add phone number"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(js,{value:g,onChange:E=>x(E.target.value),error:"",countryCode:w,setCountryCode:b})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!g||k,children:k?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!r&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("phone"),children:[t.jsx(rn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify phone number"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:r||g})]})]}),t.jsx(ba,{onComplete:E=>v(E),onResend:async()=>i(),isSubmitting:k})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:C,disabled:j.length!==6||k,children:k?"Verifying…":"Verify"})]})]})}):null},_6=()=>{var F,A,T,P;const{deployment:e}=je(),{toast:a}=aa(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createPhoneNumber:g,deletePhoneNumber:x,preparePhoneVerification:w,attemptPhoneVerification:b,makePhonePrimary:j}=va();if(!((A=(F=e==null?void 0:e.auth_settings)==null?void 0:F.phone_number)!=null&&A.enabled))return null;const v=(S,$)=>{p(H=>{const R=new Set(H);return $?R.add(S):R.delete(S),R})},k=S=>{const $=qs.find(H=>H.dialCode===S);return($==null?void 0:$.flag)||"🌍"},N=async S=>{v(S,!0);try{await j(S),await h.refetch(),a("Primary phone updated","info")}catch($){a($.message||"Failed to update primary phone","error")}finally{v(S,!1)}},_=async S=>{if(S===(h==null?void 0:h.primary_phone_number_id)){a("Cannot delete primary phone. Set another phone as primary first.","error");return}v(S,!0);try{await x(S),await h.refetch(),a("Phone removed","info")}catch($){a($.message||"Failed to delete phone. Please try again.","error")}finally{v(S,!1)}},C=async S=>{v(S,!0);try{await w(S),await h.refetch(),c(S)}catch($){a($.message||"Failed to send verification","error")}finally{v(S,!1)}},y=(h==null?void 0:h.user_phone_numbers)||[],E=S=>S.id===(h==null?void 0:h.primary_phone_number_id)?t.jsx(Ka,{$variant:"success",children:"Primary"}):S.verified?t.jsx(Ka,{$variant:"neutral",children:"Backup"}):t.jsx(Ka,{$variant:"warning",children:"Pending verification"}),M=S=>{const $=S.id===(h==null?void 0:h.primary_phone_number_id),H=d.has(S.id);return $?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[S.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:H,onClick:()=>N(S.id),children:"Make primary"}),!S.verified&&t.jsx(se,{ref:R=>{R&&(f.current[S.id]=R)},$size:"sm",$outline:!0,disabled:H,onClick:()=>C(S.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:H,onClick:()=>_(S.id),children:H?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(zr,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Phone numbers"}),t.jsx("div",{className:"w-secsub",children:"Used for sign-in and two-factor authentication."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add phone"}),i&&t.jsx(qi,{triggerRef:u,onClose:()=>l(!1),onAddPhone:async(S,$)=>{const H=await g(S,$);r(H.data.id),await w(H.data.id)},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async S=>{await b(s,S),h.refetch(),l(!1),r(""),a("Phone added and verified","info")}}),m&&t.jsx(qi,{existingPhone:(P=(T=h==null?void 0:h.user_phone_numbers)==null?void 0:T.find(S=>S.id===m))==null?void 0:P.phone_number,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async S=>{await b(m,S),h.refetch(),c(null),a("Phone verified","info")}})]})]}),y.length?t.jsx(t.Fragment,{children:t.jsx(fn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Phone number"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:y.map(S=>t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("span",{className:"w-inline w-gap-2",children:[t.jsx("span",{children:k(S.country_code)}),t.jsx("span",{className:"w-text-secondary",children:S.country_code}),t.jsx("span",{children:S.phone_number})]})}),t.jsx(Qe,{children:E(S)}),t.jsx(It,{children:M(S)})]},S.id))})]})})}):t.jsx(Nt,{title:"No phone numbers",description:"Add a phone number to get started."})]})},k6=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),t.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),t.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),t.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),C6={google_oauth:{icon:t.jsx(Cc,{}),label:"Google"},microsoft_oauth:{icon:t.jsx(k6,{}),label:"Microsoft"},github_oauth:{icon:t.jsx(kc,{}),label:"GitHub"},gitlab_oauth:{icon:t.jsx(Ec,{}),label:"GitLab"},linkedin_oauth:{icon:t.jsx(Sc,{}),label:"LinkedIn"},discord_oauth:{icon:t.jsx(Ac,{}),label:"Discord"},x_oauth:{icon:t.jsx(Nc,{}),label:"X"}},N6=()=>{const{user:e,disconnectSocialConnection:a,connectSocialAccount:s}=va(),{deployment:r}=je(),i=(r==null?void 0:r.social_connections.filter(c=>c.enabled))||[],l=c=>{s({provider:c,redirectUri:window.location.href})},m=async c=>{await a(c.toString()),e.refetch()};return i.length===0?t.jsx(Nt,{title:"No providers available",description:"Social sign-in providers have not been configured for this app."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-gap-3",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Connected accounts"}),t.jsx("div",{className:"w-secsub",children:"Sign in faster by linking third-party accounts."})]})}),t.jsx("div",{className:"w-list",children:i.map(c=>{var f;const d=C6[c.provider];if(!d)return null;const p=((f=e==null?void 0:e.social_connections)==null?void 0:f.filter(h=>h.provider===c.provider))||[],u=p.length>0;return t.jsxs("div",{className:"w-vrow",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx(Dr,{children:d.icon}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-grow",children:[t.jsx("div",{className:"w-sec",children:d.label}),u?t.jsx("div",{className:"w-flex w-wrap w-gap-1",children:p.map(h=>t.jsxs("span",{className:"w-chip",children:[t.jsx("span",{className:"w-truncate",children:h.email_address}),t.jsx("span",{className:"w-chip-x",role:"button",onClick:()=>m(h.id),title:"Remove connection","aria-label":"Remove connection",children:t.jsx(Pa,{size:10,weight:"bold"})})]},h.id))}):t.jsx("span",{className:"w-secsub",children:"Not linked"})]})]}),t.jsx("div",{className:`w-flex w-justify-end w-none${u?" w-row-act-top":""}`,children:t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>l(c.provider),children:u?"Link another":"Link"})})]},c.provider)})})]})};var S6=Object.defineProperty,en=Object.getOwnPropertySymbols,_0=Object.prototype.hasOwnProperty,k0=Object.prototype.propertyIsEnumerable,Ki=(e,a,s)=>a in e?S6(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s,fr=(e,a)=>{for(var s in a||(a={}))_0.call(a,s)&&Ki(e,s,a[s]);if(en)for(var s of en(a))k0.call(a,s)&&Ki(e,s,a[s]);return e},wr=(e,a)=>{var s={};for(var r in e)_0.call(e,r)&&a.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&en)for(var r of en(e))a.indexOf(r)<0&&k0.call(e,r)&&(s[r]=e[r]);return s};/**
109
109
  * @license QR Code generator library (TypeScript)
110
110
  * Copyright (c) Project Nayuki.
111
111
  * SPDX-License-Identifier: MIT
@@ -115,5 +115,5 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
115
115
  * SPDX-License-Identifier: ISC
116
116
  */var E6={L:Ba.QrCode.Ecc.LOW,M:Ba.QrCode.Ecc.MEDIUM,Q:Ba.QrCode.Ecc.QUARTILE,H:Ba.QrCode.Ecc.HIGH},C0=128,N0="L",S0="#FFFFFF",E0="#000000",A0=!1,M0=1,A6=4,M6=0,R6=.1;function R0(e,a=0){const s=[];return e.forEach(function(r,i){let l=null;r.forEach(function(m,c){if(!m&&l!==null){s.push(`M${l+a} ${i+a}h${c-l}v1H${l+a}z`),l=null;return}if(c===r.length-1){if(!m)return;l===null?s.push(`M${c+a},${i+a} h1v1H${c+a}z`):s.push(`M${l+a},${i+a} h${c+1-l}v1H${l+a}z`);return}m&&l===null&&(l=c)})}),s.join("")}function L0(e,a){return e.slice().map((s,r)=>r<a.y||r>=a.y+a.h?s:s.map((i,l)=>l<a.x||l>=a.x+a.w?i:!1))}function L6(e,a,s,r){if(r==null)return null;const i=e.length+s*2,l=Math.floor(a*R6),m=i/a,c=(r.width||l)*m,d=(r.height||l)*m,p=r.x==null?e.length/2-c/2:r.x*m,u=r.y==null?e.length/2-d/2:r.y*m,f=r.opacity==null?1:r.opacity;let h=null;if(r.excavate){let x=Math.floor(p),w=Math.floor(u),b=Math.ceil(c+p-x),j=Math.ceil(d+u-w);h={x,y:w,w:b,h:j}}const g=r.crossOrigin;return{x:p,y:u,h:d,w:c,excavation:h,opacity:f,crossOrigin:g}}function P6(e,a){return a!=null?Math.max(Math.floor(a),0):e?A6:M6}function P0({value:e,level:a,minVersion:s,includeMargin:r,marginSize:i,imageSettings:l,size:m,boostLevel:c}){let d=o.useMemo(()=>{const x=(Array.isArray(e)?e:[e]).reduce((w,b)=>(w.push(...Ba.QrSegment.makeSegments(b)),w),[]);return Ba.QrCode.encodeSegments(x,E6[a],s,void 0,void 0,c)},[e,a,s,c]);const{cells:p,margin:u,numCells:f,calculatedImageSettings:h}=o.useMemo(()=>{let g=d.getModules();const x=P6(r,i),w=g.length+x*2,b=L6(g,m,x,l);return{cells:g,margin:x,numCells:w,calculatedImageSettings:b}},[d,m,l,r,i]);return{qrcode:d,margin:u,cells:p,numCells:f,calculatedImageSettings:h}}var $6=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),O6=o.forwardRef(function(a,s){const r=a,{value:i,size:l=C0,level:m=N0,bgColor:c=S0,fgColor:d=E0,includeMargin:p=A0,minVersion:u=M0,boostLevel:f,marginSize:h,imageSettings:g}=r,w=wr(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=w,j=wr(w,["style"]),v=g==null?void 0:g.src,k=o.useRef(null),N=o.useRef(null),_=o.useCallback(S=>{k.current=S,typeof s=="function"?s(S):s&&(s.current=S)},[s]),[C,y]=o.useState(!1),{margin:E,cells:M,numCells:F,calculatedImageSettings:A}=P0({value:i,level:m,minVersion:u,boostLevel:f,includeMargin:p,marginSize:h,imageSettings:g,size:l});o.useEffect(()=>{if(k.current!=null){const S=k.current,$=S.getContext("2d");if(!$)return;let H=M;const R=N.current,O=A!=null&&R!==null&&R.complete&&R.naturalHeight!==0&&R.naturalWidth!==0;O&&A.excavation!=null&&(H=L0(M,A.excavation));const Z=window.devicePixelRatio||1;S.height=S.width=l*Z;const L=l/F*Z;$.scale(L,L),$.fillStyle=c,$.fillRect(0,0,F,F),$.fillStyle=d,$6?$.fill(new Path2D(R0(H,E))):M.forEach(function(U,D){U.forEach(function(Y,B){Y&&$.fillRect(B+E,D+E,1,1)})}),A&&($.globalAlpha=A.opacity),O&&$.drawImage(R,A.x+E,A.y+E,A.w,A.h)}}),o.useEffect(()=>{y(!1)},[v]);const T=fr({height:l,width:l},b);let P=null;return v!=null&&(P=o.createElement("img",{src:v,key:v,style:{display:"none"},onLoad:()=>{y(!0)},ref:N,crossOrigin:A==null?void 0:A.crossOrigin})),o.createElement(o.Fragment,null,o.createElement("canvas",fr({style:T,height:l,width:l,ref:_,role:"img"},j)),P)});O6.displayName="QRCodeCanvas";var Ur=o.forwardRef(function(a,s){const r=a,{value:i,size:l=C0,level:m=N0,bgColor:c=S0,fgColor:d=E0,includeMargin:p=A0,minVersion:u=M0,boostLevel:f,title:h,marginSize:g,imageSettings:x}=r,w=wr(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:j,numCells:v,calculatedImageSettings:k}=P0({value:i,level:m,minVersion:u,boostLevel:f,includeMargin:p,marginSize:g,imageSettings:x,size:l});let N=j,_=null;x!=null&&k!=null&&(k.excavation!=null&&(N=L0(j,k.excavation)),_=o.createElement("image",{href:x.src,height:k.h,width:k.w,x:k.x+b,y:k.y+b,preserveAspectRatio:"none",opacity:k.opacity,crossOrigin:k.crossOrigin}));const C=R0(N,b);return o.createElement("svg",fr({height:l,width:l,viewBox:`0 0 ${v} ${v}`,ref:s,role:"img"},w),!!h&&o.createElement("title",null,h),o.createElement("path",{fill:c,d:`M0,0 h${v}v${v}H0z`,shapeRendering:"crispEdges"}),o.createElement("path",{fill:d,d:C,shapeRendering:"crispEdges"}),_)});Ur.displayName="QRCodeSVG";const Yi=({onClose:e,onChangePassword:a,triggerRef:s,isSetup:r=!1})=>{const i=o.useRef(null),[l,m]=o.useState(!1),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(""),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(!1),[k,N]=o.useState(!1),[_,C]=o.useState({}),y=bt({contentRef:i,triggerRef:s??{current:null},isOpen:l,minWidth:380,defaultMaxHeight:420});o.useEffect(()=>{m(!0);const M=A=>{i.current&&!i.current.contains(A.target)&&e()},F=A=>{A.key==="Escape"&&e()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",F)}},[e]);const E=async()=>{if(k)return;const M={};if(!r&&!c&&(M.currentPassword="Current password is required"),p?p.length<8&&(M.newPassword="Password must be at least 8 characters"):M.newPassword="New password is required",p!==f&&(M.confirmPassword="Passwords do not match"),Object.keys(M).length>0){C(M);return}N(!0);try{await a(r?"":c,p),e()}catch(F){C({form:F.message||"Failed to update password"})}finally{N(!1)}};return l?t.jsxs("div",{ref:i,className:"w-pop",style:{position:"fixed",zIndex:1001,width:380,maxWidth:"calc(100vw - 24px)",top:(y==null?void 0:y.top)!==void 0?`${y.top}px`:void 0,bottom:(y==null?void 0:y.bottom)!==void 0?`${y.bottom}px`:void 0,left:(y==null?void 0:y.left)!==void 0?`${y.left}px`:void 0,right:(y==null?void 0:y.right)!==void 0?`${y.right}px`:void 0,maxHeight:y!=null&&y.maxHeight?`${y.maxHeight}px`:void 0,visibility:y?"visible":"hidden"},onClick:M=>M.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:r?"Set Password":"Change Password"}),t.jsx("p",{className:"w-pop-sub",children:r?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."})]}),!r&&t.jsxs("div",{className:"w-field",children:[t.jsx(Te,{children:"Current Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(be,{type:g?"text":"password",placeholder:"Enter your current password",value:c,onChange:M=>d(M.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>x(!g),"aria-label":g?"Hide current password":"Show current password",children:g?t.jsx(En,{size:16}):t.jsx(Sn,{size:16})})]}),_.currentPassword&&t.jsx("span",{className:"w-input-err",children:_.currentPassword})]}),t.jsxs("div",{className:"w-field",children:[t.jsx(Te,{children:r?"Password":"New Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(be,{type:w?"text":"password",placeholder:r?"Enter your password":"Enter your new password",value:p,onChange:M=>u(M.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>b(!w),"aria-label":w?"Hide new password":"Show new password",children:w?t.jsx(En,{size:16}):t.jsx(Sn,{size:16})})]}),_.newPassword&&t.jsx("span",{className:"w-input-err",children:_.newPassword})]}),t.jsxs("div",{className:"w-field",children:[t.jsx(Te,{children:"Confirm New Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(be,{type:j?"text":"password",placeholder:"Confirm your new password",value:f,onChange:M=>h(M.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>v(!j),"aria-label":j?"Hide confirm password":"Show confirm password",children:j?t.jsx(En,{size:16}):t.jsx(Sn,{size:16})})]}),_.confirmPassword&&t.jsx("span",{className:"w-input-err",children:_.confirmPassword})]}),_.form&&t.jsx("span",{className:"w-input-err",children:_.form})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:E,disabled:k,children:k?r?"Setting...":"Updating...":r?"Set Password":"Update Password"})]})]}):null},Z6=({onClose:e,onRemovePassword:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(!1),[m,c]=o.useState(""),[d,p]=o.useState(!1),{toast:u}=aa(),f=bt({contentRef:r,triggerRef:s??{current:null},isOpen:i,minWidth:400,defaultMaxHeight:360});o.useEffect(()=>{l(!0);const g=w=>{r.current&&!r.current.contains(w.target)&&e()},x=w=>{w.key==="Escape"&&e()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[e]);const h=async()=>{if(!(!m||d)){p(!0);try{await a(m),e()}catch(g){const x=g.message||"Failed to remove password. Please try again.";u(x,"error")}finally{p(!1)}}};return i?t.jsxs("div",{ref:r,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(f==null?void 0:f.top)!==void 0?`${f.top}px`:void 0,bottom:(f==null?void 0:f.bottom)!==void 0?`${f.bottom}px`:void 0,left:(f==null?void 0:f.left)!==void 0?`${f.left}px`:void 0,right:(f==null?void 0:f.right)!==void 0?`${f.right}px`:void 0,maxHeight:f!=null&&f.maxHeight?`${f.maxHeight}px`:void 0,visibility:f?"visible":"hidden"},onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Remove Password"}),t.jsxs("div",{className:"w-banner w-banner--warn",children:[t.jsx(Ta,{size:16}),t.jsx("span",{className:"w-banner-txt",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."})]}),t.jsxs(We,{children:[t.jsx(Te,{htmlFor:"current-password",children:"Confirm your current password"}),t.jsx(be,{id:"current-password",type:"password",placeholder:"Enter current password",value:m,onChange:g=>c(g.target.value),autoFocus:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:h,disabled:!m||d,children:d?"Removing...":"Remove Password"})]})]}):null},H6=({onClose:e,onSetupTOTP:a,onVerifyTOTP:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState("qr"),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(["",""]),[g,x]=o.useState(!1),[w,b]=o.useState(!1),{toast:j}=aa(),v=bt({contentRef:i,triggerRef:r??{current:null},isOpen:w,minWidth:380,defaultMaxHeight:460});o.useEffect(()=>{b(!0);const N=C=>{i.current&&!i.current.contains(C.target)&&e()},_=C=>{C.key==="Escape"&&e()};return document.addEventListener("mousedown",N),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",_)}},[e]),o.useEffect(()=>{(async()=>{x(!0);try{const _=await a();d(_.otp_url||""),u(_.totp_secret||"")}catch(_){const C=_.message||"Failed to setup two-factor authentication. Please try again.";j(C,"error")}finally{x(!1)}})()},[]);const k=async()=>{if(!f.some(N=>N.length!==6)){x(!0);try{await s(f),e()}catch(N){const _=N.message||"Failed to verify codes. Please check your authenticator app and try again.";j(_,"error")}finally{x(!1)}}};return w?t.jsx("div",{ref:i,className:"w-pop",style:{position:"fixed",zIndex:1001,width:340,maxWidth:"calc(100vw - 24px)",top:(v==null?void 0:v.top)!==void 0?`${v.top}px`:void 0,bottom:(v==null?void 0:v.bottom)!==void 0?`${v.bottom}px`:void 0,left:(v==null?void 0:v.left)!==void 0?`${v.left}px`:void 0,right:(v==null?void 0:v.right)!==void 0?`${v.right}px`:void 0,maxHeight:v!=null&&v.maxHeight?`${v.maxHeight}px`:void 0,visibility:v?"visible":"hidden"},onClick:N=>N.stopPropagation(),children:l==="qr"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Setup Two-Factor Authentication"}),t.jsx("p",{className:"w-pop-sub",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"})]}),t.jsx("div",{className:"w-flex w-justify-center",children:g?t.jsx("div",{className:"w-qr w-text-muted",children:"Loading..."}):c?t.jsx("div",{className:"w-qr",style:{background:"#fff",padding:8},children:t.jsx(Ur,{value:c,size:130,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):t.jsx("div",{className:"w-qr w-text-error",children:"QR Code Not Available"})}),p&&t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-secsub",children:"Or enter manually:"}),t.jsx("div",{className:"w-token",children:t.jsx("code",{style:{wordBreak:"break-all"},children:p})})]})]}),t.jsx("div",{className:"w-pop-foot",children:t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:()=>m("verify"),disabled:g||!c,children:"I've Scanned the Code"})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify Your Authenticator"}),t.jsx("p",{className:"w-pop-sub",children:"Enter two consecutive codes from your authenticator app"})]}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(be,{id:"totp-code-1",type:"text",placeholder:"000000",value:f[0],onChange:N=>{const _=N.target.value.replace(/[^0-9]/g,"").substring(0,6);h([_,f[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"var(--wa-font-mono)"},"aria-label":"First verification code from authenticator app"}),t.jsx(be,{id:"totp-code-2",type:"text",placeholder:"000000",value:f[1],onChange:N=>{const _=N.target.value.replace(/[^0-9]/g,"").substring(0,6);h([f[0],_])},maxLength:6,style:{textAlign:"center",fontFamily:"var(--wa-font-mono)"},"aria-label":"Second verification code from authenticator app"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:()=>m("qr"),children:"Back"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:k,disabled:g||f.some(N=>N.length!==6),children:g?"Verifying...":"Verify"})]})]})}):null},F6=({codes:e,onClose:a,onCopy:s,onDownload:r,triggerRef:i})=>{const l=o.useRef(null),[m,c]=o.useState(!1),d=bt({contentRef:l,triggerRef:i??{current:null},isOpen:m,minWidth:380,defaultMaxHeight:360});return o.useEffect(()=>{c(!0);const p=f=>{l.current&&!l.current.contains(f.target)&&a()},u=f=>{f.key==="Escape"&&a()};return document.addEventListener("mousedown",p),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",u)}},[a]),m?t.jsx("div",{ref:l,className:"w-pop",style:{position:"fixed",zIndex:1001,width:380,maxWidth:"calc(100vw - 24px)",top:(d==null?void 0:d.top)!==void 0?`${d.top}px`:void 0,bottom:(d==null?void 0:d.bottom)!==void 0?`${d.bottom}px`:void 0,left:(d==null?void 0:d.left)!==void 0?`${d.left}px`:void 0,right:(d==null?void 0:d.right)!==void 0?`${d.right}px`:void 0,maxHeight:d!=null&&d.maxHeight?`${d.maxHeight}px`:void 0,visibility:d?"visible":"hidden"},onClick:p=>p.stopPropagation(),children:t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2",children:[t.jsx("div",{className:"w-pop-title",children:"Backup Codes"}),t.jsxs("div",{className:"w-flex w-gap-2 w-none",children:[t.jsxs(se,{$outline:!0,$size:"sm",onClick:s,children:[t.jsx(qa,{size:14}),"Copy"]}),t.jsxs(se,{$outline:!0,$size:"sm",onClick:r,children:[t.jsx(ul,{size:14}),"DownloadSimple"]})]})]}),t.jsx("p",{className:"w-pop-sub",children:"Save these backup codes in a secure location. Each code can only be used once."}),t.jsx("div",{className:"w-codes",children:e.map((p,u)=>t.jsx("span",{role:"button",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(p)},title:"Click to copy",children:p},u))}),t.jsxs("div",{className:"w-banner w-banner--warn",children:[t.jsx("span",{style:{fontSize:13.5},children:"⚠️"}),t.jsx("span",{className:"w-banner-txt",children:"Keep these codes safe! They won't be shown again."})]})]})}):null},T6=({onClose:e,onAddPasskey:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(!1),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,f]=o.useState(""),h=bt({contentRef:r,triggerRef:s??{current:null},isOpen:i,minWidth:320,defaultMaxHeight:260});o.useEffect(()=>{l(!0);const x=b=>{r.current&&!r.current.contains(b.target)&&e()},w=b=>{b.key==="Escape"&&e()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",w)}},[e]);const g=async()=>{if(!d){p(!0),f("");try{await a(m.trim()),e()}catch(x){f(x.message||"Failed to register passkey"),p(!1)}}};return i?t.jsxs("div",{ref:r,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(h==null?void 0:h.top)!==void 0?`${h.top}px`:void 0,bottom:(h==null?void 0:h.bottom)!==void 0?`${h.bottom}px`:void 0,left:(h==null?void 0:h.left)!==void 0?`${h.left}px`:void 0,right:(h==null?void 0:h.right)!==void 0?`${h.right}px`:void 0,maxHeight:h!=null&&h.maxHeight?`${h.maxHeight}px`:void 0,visibility:h?"visible":"hidden"},onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add Passkey"}),t.jsx(be,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:m,onChange:x=>c(x.target.value),autoFocus:!0}),u&&t.jsx("span",{className:"w-input-err",children:u})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:g,disabled:d,children:d?"Registering...":"Continue"})]})]}):null},I6=({children:e})=>t.jsx("div",{className:"w-eyebrow",children:e}),V6=()=>{var sa,na,ra,ia,oe,xe,Ne;const{deployment:e}=je(),{user:a,updatePassword:s,removePassword:r,setupAuthenticator:i,verifyAuthenticator:l,deleteAuthenticator:m,generateBackupCodes:c,regenerateBackupCodes:d,updateProfile:p,getPasskeys:u,registerPasskey:f,deletePasskey:h}=va(),{toast:g}=aa(),[x,w]=o.useState((a==null?void 0:a.second_factor_policy)||"none"),[b,j]=o.useState(!1),v=async J=>{try{await p({second_factor_policy:J}),w(J),g("2FA requirement updated successfully","info")}catch(ve){g(ve.message||"Failed to update 2FA requirement","error")}},[k,N]=o.useState(!1),[_,C]=o.useState(!1),[y,E]=o.useState(!1),[M,F]=o.useState(!1),A=o.useRef(null),T=o.useRef(null),P=o.useRef(null),S=o.useRef(null),[$,H]=o.useState([]),[R,O]=o.useState(!1),[Z,L]=o.useState(!1),[U,D]=o.useState(!1),[Y,B]=o.useState(!1),[Q,ue]=o.useState(null),we=o.useRef(null),[ne,ae]=o.useState("table"),[re,Me]=o.useState(""),[q,tt]=o.useState(""),[Ie,De]=o.useState(""),[Ee,ce]=o.useState(["",""]),[W,G]=o.useState([]),[K,V]=o.useState(!1),[de,z]=o.useState(!1),[le]=o.useState(!1),[Je,ot]=o.useState(!1),ge=(sa=e==null?void 0:e.auth_settings)==null?void 0:sa.auth_factors_enabled,lt=(ra=(na=e==null?void 0:e.auth_settings)==null?void 0:na.password)==null?void 0:ra.enabled;if(!(ge!=null&&ge.authenticator)&&!(ge!=null&&ge.backup_code)&&!lt)return null;const Ke=async(J,ve)=>{await s(J,ve),await a.refetch(),g("Password updated successfully","info")},ee=async J=>{await r(J),await a.refetch(),g("Password removed successfully","info")},ie=()=>{var _t,Be,wt,Gt,oa,la;if(!a)return!1;const J=(_t=a.user_email_addresses)==null?void 0:_t.some(ca=>ca.verified),ve=(Be=a.user_phone_numbers)==null?void 0:Be.some(ca=>ca.verified),Ye=a.social_connections&&a.social_connections.length>0,Ve=e==null?void 0:e.auth_settings;return(Ve==null?void 0:Ve.first_factor)==="email_otp"&&J||((wt=Ve==null?void 0:Ve.magic_link)==null?void 0:wt.enabled)&&J||((Gt=Ve==null?void 0:Ve.passkey)==null?void 0:Gt.enabled)||((oa=Ve==null?void 0:Ve.auth_factors_enabled)==null?void 0:oa.phone_otp)&&ve||Ye&&((la=e==null?void 0:e.social_connections)==null?void 0:la.some(ca=>ca.enabled))},me=async()=>{if(Ee.some(J=>J.length!==6)){g("Please enter both 6-digit verification codes","error");return}try{if(z(!0),await l(Ie,Ee),await a.refetch(),ge!=null&&ge.backup_code){const J=await c();G(J),await a.refetch(),ae("backup")}else ae("success")}catch(J){g(J.message||"Invalid verification codes","error")}finally{z(!1)}},Ze=()=>{ae("table"),Me(""),tt(""),De(""),ce(["",""]),G([]),g("Two-factor authentication setup completed successfully!","info")},He=async()=>{var J;if((J=a==null?void 0:a.user_authenticator)!=null&&J.id)try{ot(!0),await m(a.user_authenticator.id),await a.refetch(),j(!1),g("Two-factor authentication removed successfully","info")}catch(ve){g(ve.message||"Failed to remove authenticator","error")}finally{ot(!1)}},qe=async()=>{if(!K)try{V(!0);const J=await d();G(J),await a.refetch(),F(!0),g("New backup codes generated","info")}catch(J){g(J.message||"Failed to generate backup codes","error")}finally{V(!1)}},ct=()=>{const J=W.join(`
117
117
  `);navigator.clipboard.writeText(J).then(()=>{g("Backup codes copied to clipboard","info")}).catch(()=>{g("Failed to copy backup codes","error")})},Rt=()=>{const J=W.join(`
118
- `),ve=new Blob([J],{type:"text/plain"}),Ye=URL.createObjectURL(ve),Ve=document.createElement("a");Ve.href=Ye,Ve.download="wacht-backup-codes.txt",Ve.click(),URL.revokeObjectURL(Ye),g("Backup codes downloaded","info")},Bt=async()=>{var J,ve;if((ve=(J=e==null?void 0:e.auth_settings)==null?void 0:J.passkey)!=null&&ve.enabled)try{O(!0);const Ye=await u();H(Ye.data||[])}catch{g("Failed to load passkeys","error")}finally{O(!1)}},ya=async J=>{try{L(!0),await f(J||void 0),await Bt(),g("Passkey registered successfully!","info")}catch(ve){throw g(ve.message||"Failed to register passkey","error"),ve}finally{L(!1)}},ja=async J=>{try{await h(J),await Bt(),g("Passkey removed","info")}catch(ve){g(ve.message||"Failed to remove passkey","error")}};o.useEffect(()=>{Bt()},[(oe=(ia=e==null?void 0:e.auth_settings)==null?void 0:ia.passkey)==null?void 0:oe.enabled]);const yt=[];return lt&&yt.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:a!=null&&a.has_password?"Enabled":"Disabled",actions:a!=null&&a.has_password?["change"]:["setup"],group:"sign-in"}),(Ne=(xe=e==null?void 0:e.auth_settings)==null?void 0:xe.passkey)!=null&&Ne.enabled&&yt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:$.length>0?`${$.length} registered`:"",actions:$.length>0?["manage","add"]:["add"],group:"sign-in"}),ge!=null&&ge.authenticator&&yt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:a!=null&&a.user_authenticator?"Enabled":"Disabled",actions:a!=null&&a.user_authenticator?["remove"]:["setup"],group:"sign-in"}),a!=null&&a.user_authenticator&&yt.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:a!=null&&a.backup_codes_generated?"Generated":"Not Generated",actions:["generate"],group:"recovery"}),a!=null&&a.user_authenticator&&yt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:x==="enforced"?"Enforced":"Optional",actions:["toggle"],group:"recovery"}),ne!=="table"?t.jsxs(t.Fragment,{children:[t.jsxs(h0,{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(ea,{size:16}),t.jsxs("span",{className:"w-sec",children:[ne==="qr"&&"Setup Two-Factor Authentication",ne==="verify"&&"Verify Your Authenticator",ne==="backup"&&"Save Your Backup Codes",ne==="success"&&"Setup Complete!"]})]}),t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("table"),children:"← Back"})]}),t.jsxs("div",{className:"w-narrow w-flex-col w-items-center w-gap-5",style:{textAlign:"center"},children:[ne==="qr"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),t.jsx("div",{className:"w-flex w-justify-center",children:le?t.jsxs("div",{className:"w-qr w-flex-col w-items-center w-gap-3",children:[t.jsx("span",{className:"w-spin"}),t.jsx("div",{className:"w-secsub",children:"Loading QR Code..."})]}):re?t.jsx("div",{className:"w-tile w-flex w-items-center w-justify-center",children:t.jsx(Ur,{value:re,size:200,level:"M",marginSize:0})}):t.jsx("div",{className:"w-qr w-text-error",children:"QR Code Not Available"})}),t.jsxs("div",{className:"w-flex-col w-gap-2 w-full",children:[t.jsx("p",{className:"w-secsub",children:"Or enter this code manually:"}),t.jsx("div",{className:"w-token",children:t.jsx("code",{children:q||"Loading..."})})]}),t.jsx(se,{$fullWidth:!0,onClick:()=>ae("verify"),disabled:!re||!q,children:"I've Scanned the Code"})]}),ne==="verify"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Enter two consecutive codes from your authenticator app to verify setup"}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(be,{type:"text",placeholder:"000000",value:Ee[0],onChange:J=>{const ve=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([ve,Ee[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}}),t.jsx(be,{type:"text",placeholder:"000000",value:Ee[1],onChange:J=>{const ve=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([Ee[0],ve])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}})]}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("qr"),children:"Back"}),t.jsx(se,{$size:"sm",onClick:me,disabled:de||Ee.some(J=>J.length!==6),children:de?"Verifying...":"Verify & Continue"})]})]}),ne==="backup"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-banner w-banner--warn",style:{textAlign:"left"},children:[t.jsx(Ta,{size:16}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Important!"}),t.jsx("div",{className:"w-banner-txt",children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),t.jsx("div",{className:"w-codes w-full",children:W.map((J,ve)=>t.jsx("span",{onClick:()=>navigator.clipboard.writeText(J),style:{cursor:"pointer"},children:J},ve))}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:ct,children:"Copy All"}),t.jsxs(se,{$outline:!0,$size:"sm",onClick:Rt,children:[t.jsx(ul,{size:16}),"DownloadSimple"]})]}),t.jsx(se,{$fullWidth:!0,onClick:Ze,children:"Complete Setup"})]}),ne==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{size:26})})]}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-items-center",children:[t.jsx("h3",{className:"w-title",children:"All Set!"}),t.jsx("p",{className:"w-secsub",children:"Your account is now protected with two-factor authentication."})]}),t.jsx(se,{$fullWidth:!0,onClick:Ze,children:"Continue to Security"})]})]})]}):t.jsx(t.Fragment,{children:yt.length?t.jsx("div",{children:yt.map((J,ve)=>{const Ye=ve>0?yt[ve-1].group:null,Ve=J.group!==Ye,jt=yt[ve+1],_t=jt&&jt.group===J.group;return t.jsxs("div",{children:[Ve&&t.jsx(I6,{$first:ve===0,children:J.group==="sign-in"?"Sign-in methods":"Recovery"}),t.jsxs(f0,{children:[t.jsxs(w0,{children:[t.jsx("div",{className:"w-flex w-items-center w-wrap w-gap-2 w-sec",children:t.jsx("span",{children:J.name})}),t.jsx("div",{className:"w-secsub",children:J.description})]}),t.jsx(g0,{children:t.jsxs("div",{className:"w-relative",children:[J.id==="password"&&t.jsx(t.Fragment,{children:a!=null&&a.has_password?t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Change"}),_&&t.jsx(Yi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Ke})]}),ie()&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",ref:P,onClick:()=>E(!0),children:"Remove"}),y&&t.jsx(Z6,{triggerRef:P,onClose:()=>E(!1),onRemovePassword:ee})]})]}):t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Setup"}),_&&t.jsx(Yi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Ke,isSetup:!0})]})}),J.id==="authenticator"&&!(a!=null&&a.user_authenticator)&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:A,onClick:()=>N(!0),disabled:le,children:le?"Setting up...":"Setup"}),k&&t.jsx(H6,{triggerRef:A,onClose:()=>N(!1),onSetupTOTP:async()=>{const Be=await i();return De(Be.id),Be},onVerifyTOTP:async Be=>{await l(Ie,Be),await a.refetch(),g("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(a==null?void 0:a.user_authenticator)&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>j(!0),disabled:Je,children:Je?"Removing...":"Remove"}),b&&t.jsx(Ja,{title:"Remove MFA and reset policy to default?",onConfirm:He,onCancel:()=>j(!1)})]}),J.id==="backup_codes"&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:S,onClick:qe,disabled:K,children:K?"Generating...":a!=null&&a.backup_codes_generated?"Regenerate":"Generate"}),M&&t.jsx(F6,{triggerRef:S,codes:W,onClose:()=>F(!1),onCopy:ct,onDownload:Rt})]})}),J.id==="second_factor_policy"&&t.jsx(Ha,{checked:x==="enforced",onChange:Be=>{v(Be?"enforced":"none")}}),J.id==="passkey"&&t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsxs(se,{$outline:!0,$size:"sm",onClick:()=>D(!U),children:[U?"Hide":"Manage"," ","(",$.length,")",t.jsx(Wt,{size:14,style:{transform:U?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:we,onClick:()=>B(!0),disabled:Z,children:Z?"Adding...":"Add"}),Y&&t.jsx(T6,{triggerRef:we,onClose:()=>B(!1),onAddPasskey:ya})]})]})]})})]}),J.id==="passkey"&&U&&t.jsx("div",{className:"w-flex-col w-gap-2",children:R?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):$.length===0?t.jsx("div",{className:"w-empty",children:t.jsx("p",{children:"No passkeys registered yet"})}):t.jsx("div",{className:"w-flex-col w-gap-2",children:$.map(Be=>t.jsxs("div",{className:"w-locked w-flex w-items-center w-justify-between",style:{height:"auto",padding:"10px 12px"},children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:Be.name||"Unnamed Passkey"}),t.jsxs("span",{className:"w-secsub",children:[Be.device_type==="platform"?"This device":"Security key",Be.last_used_at&&` • Last used ${new Date(Be.last_used_at).toLocaleDateString()}`]})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>ue(Be.id),children:"Remove"}),Q===Be.id&&t.jsx(Ja,{title:`Remove "${Be.name||"Unnamed Passkey"}"?`,onConfirm:()=>{ja(Be.id),ue(null)},onCancel:()=>ue(null)})]})]},Be.id))})}),_t&&t.jsx("div",{className:"w-hr"})]},J.id)})}):t.jsx(Nt,{title:"No security features available",description:"Contact your administrator to enable security features."})})},z6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#d93025"}),t.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),t.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#fcc934"}),t.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),t.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),t.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),t.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),t.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"}}),t.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)"}}),t.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),t.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)"}}),t.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)"}})]}),D6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[t.jsx("stop",{offset:.1,stopColor:"#ffe226"}),t.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),t.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[t.jsx("stop",{offset:.3,stopColor:"#960e18"}),t.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),t.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),t.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),t.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),t.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[t.jsx("stop",{offset:.13,stopColor:"#fff44f"}),t.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),t.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[t.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),t.jsx("stop",{offset:.67,stopColor:"#9059ff"}),t.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),t.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[t.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),t.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),t.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[t.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),t.jsx("stop",{offset:.28,stopColor:"#ff980e"}),t.jsx("stop",{offset:.47,stopColor:"#ff3750"}),t.jsx("stop",{offset:.78,stopColor:"#eb0878"}),t.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),t.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[t.jsx("stop",{offset:.11,stopColor:"#fff44f"}),t.jsx("stop",{offset:.46,stopColor:"#ff980e"}),t.jsx("stop",{offset:.72,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[t.jsx("stop",{offset:0,stopColor:"#fff44f"}),t.jsx("stop",{offset:.3,stopColor:"#ff980e"}),t.jsx("stop",{offset:.57,stopColor:"#ff3647"}),t.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[t.jsx("stop",{offset:.14,stopColor:"#fff44f"}),t.jsx("stop",{offset:.48,stopColor:"#ff980e"}),t.jsx("stop",{offset:.66,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[t.jsx("stop",{offset:.09,stopColor:"#fff44f"}),t.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),t.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[t.jsx("stop",{offset:.05,stopColor:"#fff44f"}),t.jsx("stop",{offset:.37,stopColor:"#ff980e"}),t.jsx("stop",{offset:.53,stopColor:"#ff3647"}),t.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),t.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[t.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),t.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"})]}),U6=e=>t.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",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"b",children:[t.jsx("stop",{offset:0,stopColor:"#06c2e7"}),t.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),t.jsx("stop",{offset:.5,stopColor:"#12aef1"}),t.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),t.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),t.jsxs("linearGradient",{id:"a",children:[t.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),t.jsx("stop",{offset:1,stopColor:"#fff"})]}),t.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"}),t.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:.958})}),t.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:3.564})}),t.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"})]}),t.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)"}),t.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)"}),t.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)"}),t.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"}),t.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)"}),t.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),t.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),W6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...e,children:[t.jsxs("defs",{children:[t.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:[t.jsx("stop",{offset:.7,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.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:[t.jsx("stop",{offset:.8,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#35c1f1"}),t.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),t.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),t.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),t.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#66eb6e"}),t.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#0c59a4"}),t.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#1b9de2"}),t.jsx("stop",{offset:.2,stopColor:"#1595df"}),t.jsx("stop",{offset:.7,stopColor:"#0680d7"}),t.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),t.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)"}),t.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)"}),t.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)"}),t.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)"}),t.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)"}),t.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)"})]}),B6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Opera",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),t.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),t.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),t.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)"})]}),G6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Brave",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),t.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),t.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),t.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"}),t.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)"}),t.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),q6=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"w-text-secondary",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),t.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"}),t.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),t.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),K6=({browser:e})=>{const a=(e==null?void 0:e.toLowerCase())||"",s={width:20,height:20};return a.includes("chrome")?t.jsx(z6,{...s}):a.includes("firefox")?t.jsx(D6,{...s}):a.includes("safari")?t.jsx(U6,{...s}):a.includes("edge")?t.jsx(W6,{...s}):a.includes("opera")?t.jsx(B6,{...s}):a.includes("brave")?t.jsx(G6,{...s}):t.jsx(q6,{})},Y6=()=>{const{signins:e,removeSignin:a,refetch:s,loading:r}=So(),{refetch:i}=it(),{toast:l}=aa(),m=e,c=async p=>{try{await a(p),await Promise.all([s(),i()]),l("Session ended successfully","info")}catch(u){l(u.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const u=new Date(p);if(isNaN(u.getTime()))return"Unknown";const h=Math.floor((new Date().getTime()-u.getTime())/(1e3*60));return h<1?"Just now":h<60?`${h}m ago`:h<1440?`${Math.floor(h/60)}h ago`:u.toLocaleDateString()};return r?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):t.jsx("div",{children:m&&m.length>0?t.jsx(t.Fragment,{children:t.jsx(fn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Browser & Device"}),t.jsx(Oe,{children:"Location"}),t.jsx(Oe,{children:"Last Active"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:m.map(p=>t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(Dr,{children:t.jsx(K6,{browser:p.browser||"Unknown"})}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&t.jsx("div",{className:"w-text-muted",children:p.device})]})]})}),t.jsx(Qe,{children:t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&t.jsx("div",{className:"w-text-muted",children:p.ip_address})]})}),t.jsx(Qe,{children:d(p.last_active_at)}),t.jsx(It,{children:t.jsxs(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>c(p.id),children:[t.jsx(Ma,{size:12}),"Sign out"]})})]},p.id))})]})})}):t.jsx(Nt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})},Q6=(e,a)=>`${(e==null?void 0:e[0])||""}${(a==null?void 0:a[0])||""}`.toUpperCase()||"U",$0=()=>{var N,_,C,y,E,M,F,A;const{loading:e,user:a,updateProfilePicture:s}=va(),{deployment:r}=je(),[i,l]=o.useState("profile"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((T,P="info")=>{c(T),p(P),setTimeout(()=>c(null),3e3)},[c]),x=async T=>{var S;const P=(S=T.target.files)==null?void 0:S[0];if(P){if(P.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!P.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s(P),await(a==null?void 0:a.refetch()),g("Profile picture updated","info")}catch($){g(($==null?void 0:$.message)||"Failed to update profile picture","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(e)return t.jsx(Re,{children:t.jsx(hr,{className:"w-flex w-items-center w-justify-center",children:t.jsx(_e,{})})});const w=r==null?void 0:r.auth_settings,b=(N=w==null?void 0:w.email_address)==null?void 0:N.enabled,j=(_=w==null?void 0:w.phone_number)==null?void 0:_.enabled,v=((C=r==null?void 0:r.social_connections)==null?void 0:C.some(T=>T.enabled))||!1,k=((y=w==null?void 0:w.password)==null?void 0:y.enabled)||((E=w==null?void 0:w.auth_factors_enabled)==null?void 0:E.authenticator)||((M=w==null?void 0:w.auth_factors_enabled)==null?void 0:M.phone_otp)||((F=w==null?void 0:w.auth_factors_enabled)==null?void 0:F.backup_code);return t.jsx(Re,{children:t.jsx(d0,{children:t.jsx(c0.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(hr,{className:"w-relative",children:[a&&t.jsxs(v0,{className:"mac-page-header",children:[t.jsxs("button",{type:"button",className:"w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var T;return(T=h.current)==null?void 0:T.click()},disabled:u,title:"Change profile picture","aria-label":"Change profile picture",children:[t.jsx("span",{className:"w-avatar w-avatar--lg",children:a.profile_picture_url?t.jsx("img",{src:a.profile_picture_url,alt:""}):Q6(a.first_name,a.last_name)}),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(nn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(b0,{children:[t.jsx(y0,{children:`${a.first_name||""} ${a.last_name||""}`.trim()||a.username||"Account"}),((A=a.primary_email_address)==null?void 0:A.email)&&t.jsx(j0,{children:a.primary_email_address.email})]})]}),t.jsx(u0,{children:t.jsxs(m0,{children:[t.jsx(Ca,{$isActive:i==="profile",onClick:()=>l("profile"),children:t.jsxs(Na,{children:[t.jsx(fs,{size:16}),"Profile"]})}),b&&t.jsx(Ca,{$isActive:i==="email",onClick:()=>l("email"),children:t.jsxs(Na,{children:[t.jsx(pl,{size:16}),"Email"]})}),j&&t.jsx(Ca,{$isActive:i==="phone",onClick:()=>l("phone"),children:t.jsxs(Na,{children:[t.jsx(Du,{size:16}),"Phone"]})}),v&&t.jsx(Ca,{$isActive:i==="social",onClick:()=>l("social"),children:t.jsxs(Na,{children:[t.jsx(zu,{size:16}),"Connections"]})}),k&&t.jsx(Ca,{$isActive:i==="security",onClick:()=>l("security"),children:t.jsxs(Na,{children:[t.jsx(ea,{size:16}),"Security"]})}),t.jsx(Ca,{$isActive:i==="sessions",onClick:()=>l("sessions"),children:t.jsxs(Na,{children:[t.jsx(Uu,{size:16}),"Sessions"]})})]})}),t.jsxs(p0,{children:[i==="profile"&&t.jsx(y6,{}),i==="email"&&b&&t.jsx(j6,{}),i==="phone"&&j&&t.jsx(_6,{}),i==="social"&&v&&t.jsx(N6,{}),i==="security"&&k&&t.jsx(V6,{}),i==="sessions"&&t.jsx(Y6,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,style:{minWidth:0},children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Ta,{size:12}):t.jsx(Ge,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},O0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{className:"w-dialog--panel",children:[r&&t.jsx(ze.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx($0,{}),l&&t.jsx(ze.Footer,{children:l})]})})}),Le=(...e)=>e.filter(Boolean).join(" "),J6=e=>t.jsx("div",{...e,className:Le("w-relative",e.className)}),Z0=o.forwardRef((e,a)=>t.jsx("button",{...e,ref:a,className:Le("w-acct",e.className),style:{width:"auto",margin:0,padding:4,gap:8,...e.style}}));Z0.displayName="AccountButton";const X6=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","w-avatar--md",a.className),style:{width:28,height:28,fontSize:11,...a.style},children:e}),ep=e=>t.jsx("div",{...e,className:Le("w-sec","w-text-secondary",e.className)}),H0=o.forwardRef(({$position:e,$isOpen:a,$maxHeight:s,children:r,...i},l)=>t.jsx("div",{...i,ref:l,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:s?`${s}px`:"calc(100vh - 48px)",overflowY:"auto",zIndex:99999,top:(e==null?void 0:e.top)!==void 0?`${e.top}px`:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?`${e.bottom}px`:void 0,left:(e==null?void 0:e.left)!==void 0?`${e.left}px`:void 0,right:(e==null?void 0:e.right)!==void 0?`${e.right}px`:void 0,visibility:e&&a?"visible":"hidden",opacity:a&&e?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,padding:0},children:r}));H0.displayName="DropdownContainer";const F0=o.forwardRef(({$top:e,$left:a,$isOpen:s,$maxHeight:r,children:i,...l},m)=>t.jsx("div",{...l,ref:m,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:`${r}px`,overflowY:"auto",zIndex:99999,display:"flex",flexDirection:"column",top:`${e}px`,left:`${a}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${s?"0s":"0.15s"}`,padding:0},children:i}));F0.displayName="SidePanel";const Qi=e=>t.jsx("hr",{...e,className:Le("w-hr",e.className)}),tp=e=>t.jsx("div",{...e,style:{padding:"16px 14px 8px",...e.style}}),ap=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-gap-3",e.className)}),sp=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","w-avatar--lg",a.className),children:e}),np=e=>t.jsx("div",{...e,className:Le("w-flex-col","w-grow",e.className),style:{gap:2,...e.style}}),rp=e=>t.jsx("div",{...e,className:Le("w-sec","w-truncate",e.className)}),ip=e=>t.jsx("div",{...e,className:Le("w-secsub","w-truncate",e.className)}),op=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{border:"0.5px solid var(--wa-border)",background:e?"var(--wa-surface-subtle)":void 0,...a.style}}),lp=({children:e,...a})=>t.jsx("div",{...a,className:"w-avatar w-avatar--sm",children:e}),cp=e=>t.jsx("div",{...e,className:Le("w-sec","w-grow","w-truncate",e.className)}),dp=e=>t.jsx("div",{...e,className:Le("w-secsub","w-none",e.className)}),up=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),mp=e=>t.jsx("button",{...e,className:Le("w-menu-item",e.className)}),pp=e=>t.jsx("span",{...e,className:Le("w-grow",e.className)}),hp=e=>t.jsx("span",{...e,className:Le("w-menu-trail",e.className)}),fp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),wp=e=>t.jsx("div",{...e,className:Le("w-menu-label",e.className)}),Fn=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{cursor:e?"default":"pointer",...a.style}}),Tn=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-flex","w-items-center","w-justify-center","w-none",a.className),style:{width:14,height:14,color:"var(--wa-primary)",...a.style},children:e}),gp=e=>t.jsx("div",{...e,className:"w-none",style:{width:14,...e.style}}),In=e=>t.jsx("div",{...e,className:Le("w-sec","w-grow","w-truncate",e.className)}),Ji=e=>t.jsx("div",{...e,className:Le("w-secsub","w-none",e.className)}),xp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),vp=e=>t.jsx("button",{...e,className:Le("w-menu-item","w-menu-item--danger",e.className)}),bp=e=>t.jsx("button",{...e,className:Le("w-menu-item",e.className),style:{borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,flex:"none",...e.style}}),yp=e=>t.jsx("div",{...e,style:{flex:"1 1 auto",overflowY:"auto",padding:5,...e.style}}),Xi=({$active:e,...a})=>t.jsx("button",{...a,className:Le("w-menu-item","sp-row",e&&"sp-row--active",a.className),style:{height:32,...a.style}}),eo=({$active:e,...a})=>t.jsx("button",{...a,className:Le("w-menu-item","sp-row","sp-ws-row",e&&"sp-row--active",a.className),style:{height:32,paddingLeft:30,position:"relative",...a.style},children:a.children}),to=({$personal:e,children:a,...s})=>t.jsx("div",{...s,className:Le("w-avatar","w-avatar--sm",!e&&"",s.className),children:a}),ao=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","","w-avatar--sm",a.className),children:e}),so=e=>t.jsx("span",{...e,className:Le("w-sec","w-grow","w-truncate",e.className)}),no=e=>t.jsx("span",{...e,className:Le("w-secsub","w-grow","w-truncate",e.className)}),Vn=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-none",e.className),style:{gap:4,...e.style}}),jp=({$open:e,...a})=>t.jsx(Wt,{...a,className:"w-text-muted",style:{flexShrink:0,transition:"transform 0.2s ease",transform:e?"rotate(0deg)":"rotate(-90deg)"}}),zn=e=>t.jsx(Ge,{...e,className:"w-text-primary",style:{flexShrink:0}}),_p=e=>t.jsx("div",{...e,className:Le("w-flex-col","w-gap-3","w-none",e.className),style:{padding:"12px 12px 16px",borderBottom:"0.5px solid var(--wa-border)",...e.style}}),kp=e=>t.jsx("button",{...e,className:Le("w-btn","w-btn--icon",e.className),style:{width:24,height:24,...e.style}}),ro=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-gap-3",e.className),style:{padding:"4px 4px 0",minWidth:0,...e.style}}),io=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","","w-avatar--md",a.className),children:e}),oo=e=>t.jsx("div",{...e,className:Le("w-flex-col","w-grow",e.className),style:{gap:1,minWidth:0,...e.style}}),lo=e=>t.jsx("div",{...e,className:Le("w-sec","w-truncate",e.className)}),co=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-none",e.className),style:{gap:2,...e.style}}),Ts=({$destructive:e,...a})=>t.jsx("button",{...a,className:Le("w-btn","w-btn--icon",e&&"w-btn--danger",a.className),style:{width:24,height:24,...a.style}}),uo=e=>t.jsx("div",{...e,className:"w-none",style:{borderTop:"0.5px solid var(--wa-border)",padding:5,...e.style}}),mo=e=>t.jsx("button",{...e,className:Le("w-menu-item",e.className),style:{height:32,color:"var(--wa-text-muted)",...e.style}}),po=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-justify-center","w-none",e.className),style:{width:20,height:20,...e.style}}),Wr=({showName:e=!0,onCreateOrg:a,showOrgSwitcher:s=!0,narrowBreakpoint:r=640})=>{var He,qe,ct,Rt,Bt,ya,ja,yt,sa,na,ra,ia;const i=as(),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(typeof window<"u"&&window.innerWidth<r),[f,h]=o.useState(!1),[g,x]=o.useState("org"),[w,b]=o.useState(null),[j,v]=o.useState({top:0,left:0,maxHeight:400}),[k,N]=o.useState(new Set),[_,C]=o.useState(null),y=o.useRef(null),E=o.useRef(null),M=o.useRef(null),F=bt({triggerRef:y,isOpen:l,minWidth:300}),A=Yt(!1),T=Yt(!1),P=Yt(!1),S=Yt(!1),$=Yt(!1),{session:H,signOut:R,switchSignIn:O,switchOrganization:Z,switchWorkspace:L,refetch:U}=it(),{navigateToSignIn:D}=kt(),{deployment:Y}=je(),{activeOrganization:B,activeMembership:Q,leave:ue}=wa(),{organizationMemberships:we}=ga(),{workspaces:ne}=xa(),{activeWorkspace:ae,activeMembership:re,leave:Me}=Ut(),q=(He=H==null?void 0:H.active_signin)==null?void 0:He.user,tt=((ct=(qe=Y==null?void 0:Y.auth_settings)==null?void 0:qe.multi_session_support)==null?void 0:ct.enabled)??!1,Ie=((Rt=Y==null?void 0:Y.b2b_settings)==null?void 0:Rt.allow_users_to_create_orgs)??!1,De=((Bt=Y==null?void 0:Y.b2b_settings)==null?void 0:Bt.organizations_enabled)??!1,Ee=De&&(((ya=Y==null?void 0:Y.b2b_settings)==null?void 0:ya.workspaces_enabled)??!1),ce=s&&De,W=!B,G=o.useMemo(()=>{var xe;const oe={};for(const Ne of ne||[]){const J=(xe=Ne.organization)==null?void 0:xe.id;J&&(oe[J]||(oe[J]=[]),oe[J].push(Ne))}return oe},[ne]),K=we||[],V=o.useCallback(()=>{if(!E.current)return;const oe=E.current.getBoundingClientRect(),xe=300,Ne=8,J=window.innerWidth<r;if(u(J),J){v({top:oe.top,left:oe.left,maxHeight:oe.height});return}const ve=Math.min(Math.max(oe.height,520),window.innerHeight-oe.top-16),Ye=oe.right+Ne+xe<=window.innerWidth-8;v({top:oe.top,left:Ye?oe.right+Ne:oe.left-Ne-xe,maxHeight:ve})},[r]),de=o.useCallback(()=>{V(),d(!0)},[V]),z=o.useCallback(oe=>{N(xe=>{const Ne=new Set(xe);return Ne.has(oe)?Ne.delete(oe):Ne.add(oe),Ne})},[]);o.useEffect(()=>{B&&Ee&&N(oe=>{if(oe.has(B.id))return oe;const xe=new Set(oe);return xe.add(B.id),xe})},[B,Ee]),o.useEffect(()=>{x(Ee&&ae?"ws":"org")},[Ee,ae==null?void 0:ae.id]),o.useEffect(()=>{const oe=()=>{u(window.innerWidth<r),c&&V()};return window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[r,c,V]),o.useEffect(()=>{l||(d(!1),h(!1))},[l]),o.useEffect(()=>{if(!l)return;const oe=setTimeout(()=>{const xe=Ne=>{var ve,Ye,Ve;const J=Ne.target;(ve=y.current)!=null&&ve.contains(J)||(Ye=E.current)!=null&&Ye.contains(J)||(Ve=M.current)!=null&&Ve.contains(J)||m(!1)};return document.addEventListener("mousedown",xe),()=>document.removeEventListener("mousedown",xe)},50);return()=>clearTimeout(oe)},[l]);const le=oe=>oe.split(" ").filter(Boolean).map(xe=>xe[0]).join("").toUpperCase().slice(0,2),Je=(oe,xe,Ne,J,ve)=>t.jsx(ve,{children:oe?t.jsx("img",{src:xe,alt:Ne}):le(`${Ne||""} ${J||""}`)}),ot=async oe=>{try{await R(oe),await U(),m(!1)}catch{}},ge=async oe=>{try{await O(oe),await U(),m(!1)}catch{}},lt=async oe=>{if(!f){h(!0);try{await Z(oe),await U(),d(!1)}catch{}finally{h(!1)}}},Ke=async oe=>{if(!f){h(!0);try{await L(oe),await U(),d(!1)}catch{}finally{h(!1)}}},ee=()=>{A.open(),m(!1)},ie=[...(H==null?void 0:H.signins)||[]].sort((oe,xe)=>{const Ne=oe.user.id===(q==null?void 0:q.id),J=xe.user.id===(q==null?void 0:q.id);return Ne===J?0:Ne?-1:1}),me=((ja=ie.find(oe=>oe.user.id===(q==null?void 0:q.id)))==null?void 0:ja.id)||"",Ze=((sa=(yt=Q==null?void 0:Q.roles)==null?void 0:yt[0])==null?void 0:sa.name)??null;return t.jsx(Re,{children:t.jsxs(J6,{children:[t.jsxs(Z0,{ref:y,onClick:()=>m(!l),children:[Je(q==null?void 0:q.has_profile_picture,q==null?void 0:q.profile_picture_url,q==null?void 0:q.first_name,q==null?void 0:q.last_name,X6),e&&t.jsx(ep,{children:`${(q==null?void 0:q.first_name)||""} ${(q==null?void 0:q.last_name)||""}`.trim()})]}),typeof window<"u"&&tn.createPortal(t.jsxs("div",{className:"wacht-root",style:i,children:[t.jsxs(H0,{ref:E,$position:F,$isOpen:l&&!(p&&c),$maxHeight:F==null?void 0:F.maxHeight,children:[t.jsx(tp,{children:t.jsxs(ap,{children:[Je(q==null?void 0:q.has_profile_picture,q==null?void 0:q.profile_picture_url,q==null?void 0:q.first_name,q==null?void 0:q.last_name,sp),t.jsxs(np,{children:[t.jsx(rp,{children:`${(q==null?void 0:q.first_name)||""} ${(q==null?void 0:q.last_name)||""}`.trim()}),t.jsx(ip,{children:(na=q==null?void 0:q.primary_email_address)==null?void 0:na.email})]})]})}),t.jsxs(up,{children:[ce&&t.jsxs(op,{$active:c,onClick:de,style:{marginBottom:8},children:[t.jsx(lp,{children:B?B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):(ra=B.name)==null?void 0:ra.charAt(0).toUpperCase():q!=null&&q.has_profile_picture?t.jsx("img",{src:q.profile_picture_url,alt:q.first_name}):le(`${(q==null?void 0:q.first_name)||""} ${(q==null?void 0:q.last_name)||""}`)}),t.jsx(cp,{children:(B==null?void 0:B.name)??"Personal account"}),Ze&&t.jsx(dp,{children:Ze})]}),t.jsxs(mp,{onClick:ee,children:[t.jsx(Aa,{}),t.jsx(pp,{children:"Manage account"}),t.jsx(hp,{children:"⌘,"})]})]}),t.jsx(Qi,{}),t.jsxs(fp,{children:[t.jsx(wp,{children:"Accounts"}),tt?ie.map(({user:oe,id:xe})=>{var J;const Ne=oe.id===(q==null?void 0:q.id);return t.jsxs(Fn,{$active:Ne,onClick:Ne?void 0:()=>ge(xe),children:[Ne?t.jsx(Tn,{children:t.jsx(Ge,{})}):t.jsx(gp,{}),t.jsx(In,{children:(J=oe.primary_email_address)==null?void 0:J.email}),Ne&&t.jsx(Ji,{children:"Current"})]},oe.id)}):q&&t.jsxs(Fn,{$active:!0,children:[t.jsx(Tn,{children:t.jsx(Ge,{})}),t.jsx(In,{children:(ia=q.primary_email_address)==null?void 0:ia.email}),t.jsx(Ji,{children:"Current"})]}),tt&&t.jsxs(Fn,{onClick:()=>{D(),m(!1)},children:[t.jsx(Tn,{style:{color:"var(--wa-text-muted)"},children:t.jsx(St,{})}),t.jsx(In,{style:{color:"var(--wa-text-muted)"},children:"Add account"})]})]}),t.jsx(Qi,{}),t.jsx(xp,{children:t.jsxs(vp,{onClick:()=>ot(me),children:[t.jsx(Ma,{}),"Sign out"]})})]}),t.jsxs(F0,{ref:M,$top:j.top,$left:j.left,$isOpen:l&&c,$maxHeight:j.maxHeight,children:[p&&t.jsxs(bp,{onClick:()=>d(!1),children:[t.jsx(rn,{size:13}),"Back"]}),(()=>{var _t;if(W)return null;const oe=Ee&&!!ae,xe=!!((_t=Q==null?void 0:Q.eligibility_restriction)!=null&&_t.type)&&Q.eligibility_restriction.type!=="none",Ne=!!B&&!xe&&Tr(Q),J=oe&&!xe&&Vr(re),ve=oe?g:"org",Ye=async()=>{if(ue){b("org");try{await ue(),await U(),d(!1)}catch{}finally{b(null)}}},Ve=async()=>{if(Me){b("ws");try{await Me(),d(!1)}catch{}finally{b(null)}}},jt=()=>{if(!oe)return null;const Be=ve==="org"?"ws":"org",wt=Be==="ws"?"Switch to workspace context":"Switch to organization context";return t.jsx(kp,{type:"button",onClick:()=>x(Be),title:wt,"aria-label":wt,children:t.jsx(Au,{size:12})})};return t.jsxs(_p,{children:[ve==="org"&&B&&t.jsxs(ro,{children:[jt(),t.jsx(io,{children:B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):le(B.name)}),t.jsx(oo,{children:t.jsx(lo,{children:B.name})}),t.jsxs(co,{children:[Ne&&t.jsx(Ts,{onClick:()=>{P.open(),m(!1)},title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Aa,{size:14})}),t.jsx(Ts,{$destructive:!0,onClick:Ye,disabled:w==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(Ma,{size:14})})]})]}),ve==="ws"&&oe&&t.jsxs(ro,{children:[jt(),t.jsx(io,{children:ae.image_url?t.jsx("img",{src:ae.image_url,alt:ae.name}):le(ae.name)}),t.jsx(oo,{children:t.jsx(lo,{children:ae.name})}),t.jsxs(co,{children:[J&&t.jsx(Ts,{onClick:()=>{$.open(),m(!1)},title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Aa,{size:14})}),t.jsx(Ts,{$destructive:!0,onClick:Ve,disabled:w==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(Ma,{size:14})})]})]})]})})(),t.jsxs(yp,{children:[t.jsxs(Xi,{$active:W,onClick:()=>{W||lt(void 0)},disabled:f,style:W?{cursor:"default"}:void 0,children:[t.jsx(to,{$personal:!0,children:q!=null&&q.has_profile_picture?t.jsx("img",{src:q.profile_picture_url,alt:q.first_name}):t.jsx(fs,{size:12})}),t.jsx(so,{children:"Personal account"}),W&&t.jsx(Vn,{children:t.jsx("span",{className:"sp-check",style:{display:"inline-flex"},children:t.jsx(zn,{size:13})})})]}),K.map(oe=>{var Ve,jt;const xe=oe.organization,Ne=xe.id===(B==null?void 0:B.id),J=k.has(xe.id),ve=Ee?G[xe.id]||[]:[],Ye=!!((Ve=oe.eligibility_restriction)!=null&&Ve.type)&&oe.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs(Xi,{$active:Ne,onClick:()=>{Ye||(Ee?z(xe.id):Ne||lt(xe.id))},disabled:f,style:Ye?{opacity:.55,cursor:"not-allowed"}:Ne&&!Ee?{cursor:"default"}:void 0,title:(jt=oe.eligibility_restriction)==null?void 0:jt.message,children:[t.jsx(to,{children:xe.image_url?t.jsx("img",{src:xe.image_url,alt:xe.name}):le(xe.name)}),t.jsx(so,{children:xe.name}),t.jsxs(Vn,{children:[Ye&&t.jsx(Ra,{size:12,color:"var(--wa-error)"}),Ne&&!Ee&&t.jsx(zn,{size:13}),Ee&&t.jsx(jp,{size:11,$open:J})]})]}),Ee&&J&&t.jsxs(t.Fragment,{children:[ve.map(_t=>{var oa,la;const Be=Ne&&(ae==null?void 0:ae.id)===_t.id,wt=_t,Gt=((oa=wt.eligibility_restriction)==null?void 0:oa.type)&&wt.eligibility_restriction.type!=="none";return t.jsxs(eo,{$active:Be,onClick:()=>{!Be&&!Gt&&Ke(_t.id)},disabled:f,style:Gt||Ye?{opacity:.55,cursor:"not-allowed"}:Be?{cursor:"default"}:void 0,title:(la=wt.eligibility_restriction)==null?void 0:la.message,children:[t.jsx(ao,{children:wt.image_url?t.jsx("img",{src:wt.image_url,alt:wt.name}):le(wt.name).charAt(0)}),t.jsx(no,{children:wt.name}),t.jsxs(Vn,{children:[Gt&&t.jsx(Ra,{size:12,color:"var(--wa-error)"}),Be&&t.jsx(zn,{size:12})]})]},_t.id)}),!Ye&&t.jsxs(eo,{onClick:()=>{C(xe.id),S.open()},disabled:f,children:[t.jsx(ao,{style:{background:"transparent",border:"1px dashed var(--wa-border-strong)"},children:t.jsx(St,{size:10})}),t.jsx(no,{children:"New workspace"})]})]})]},xe.id)})]}),(()=>{var Ye,Ve,jt;const oe=((we==null?void 0:we.length)??0)>0,xe=()=>Ie&&t.jsx(uo,{children:t.jsxs(mo,{onClick:()=>{a?(a(),m(!1)):T.open()},disabled:f,children:[t.jsx(po,{children:t.jsx(St,{size:12})}),"New organization"]})});if(!Ee||!oe)return xe();const Ne=!!((Ye=Q==null?void 0:Q.eligibility_restriction)!=null&&Ye.type)&&Q.eligibility_restriction.type!=="none",J=((jt=(Ve=we==null?void 0:we[0])==null?void 0:Ve.organization)==null?void 0:jt.id)??null,ve=B&&!Ne?B.id:J;return t.jsx(uo,{children:t.jsxs(mo,{onClick:()=>{C(ve),S.open()},disabled:f,children:[t.jsx(po,{children:t.jsx(St,{size:12})}),"New workspace"]})})})()]})]}),document.body),t.jsx(O0,{isOpen:A.isOpen,onClose:A.close}),ce&&t.jsxs(t.Fragment,{children:[t.jsx(Yc,{isOpen:T.isOpen,onClose:T.close}),t.jsx(t0,{isOpen:P.isOpen,onClose:P.close}),Ee&&t.jsxs(t.Fragment,{children:[t.jsx(Or,{isOpen:S.isOpen,onClose:()=>{S.close(),C(null)},organizationId:_||void 0}),t.jsx(Hr,{isOpen:$.isOpen,onClose:$.close})]})]})]})})};function T0({notification:e,onAction:a}){const[s,r]=o.useState(!1),i=c=>{c.target.closest("button")||(r(!s),e.is_read||a({type:"read",id:e.id}))},l=c=>{a({type:"custom",payload:c.payload})},m=c=>{const d=new Date(c),u=new Date().getTime()-d.getTime();if(u<6e4)return"Just now";const f=Math.floor(u/6e4);if(f<60)return`${f}m`;const h=Math.floor(f/60);if(h<24)return`${h}h`;const g=Math.floor(h/24);return g<7?`${g}d`:d.toLocaleDateString(void 0,{month:"short",day:"numeric"})};return t.jsxs("div",{className:"w-flex w-gap-3 w-notif-row",onClick:i,"data-unread":e.is_read?void 0:"",children:[t.jsxs("div",{className:"w-grow w-flex-col w-justify-center",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:2},children:[!e.is_read&&t.jsx("span",{className:"w-notif-dot"}),t.jsx("h4",{className:"w-sec w-truncate",style:{margin:0},children:e.title})]}),t.jsx("p",{className:`w-secsub${s?"":" w-truncate"}`,style:{margin:0,wordWrap:s?"break-word":void 0},children:e.body}),e.ctas&&e.ctas.length>0&&t.jsx("div",{className:"w-flex w-wrap w-gap-2",style:{marginTop:10},children:e.ctas.map((c,d)=>t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:()=>l(c),children:c.label},d))})]}),t.jsxs("div",{className:"w-flex-col w-items-end w-gap-2 w-none",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-1 w-notif-actions",children:[e.is_read&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"unread",id:e.id})},title:"Mark as unread",children:t.jsx(Pu,{size:14})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"star",id:e.id})},title:e.is_starred?"Unstar":"Star","data-on":e.is_starred?"":void 0,children:t.jsx(Wu,{size:14,fill:e.is_starred?"currentColor":"none"})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"archive",id:e.id})},title:e.is_archived?"Unarchive":"Archive",children:e.is_archived?t.jsx(Uo,{size:14}):t.jsx(zo,{size:14})})]}),t.jsx("span",{className:"w-secsub",style:{whiteSpace:"nowrap"},children:m(e.created_at)})]})]})}const I0=o.forwardRef(({scope:e="all",onAction:a,fullWidth:s,maxHeight:r,className:i},l)=>{const[m,c]=o.useState("inbox"),[d,p]=o.useState(!1),[u,f]=o.useState(!1),h=o.useRef(null),g={scope:e,limit:20,is_archived:m==="archive",is_starred:m==="starred",is_read:d?!1:void 0},{notifications:x,loading:w,error:b,hasMore:j,loadMore:v,markAsRead:k,markAsUnread:N,markAllAsRead:_,archiveAllRead:C,archiveNotification:y,starNotification:E}=$o(g);o.useEffect(()=>{if(!u)return;const T=P=>{h.current&&!h.current.contains(P.target)&&f(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[u]);const M=async T=>{switch(T.type){case"read":await k(T.id);break;case"unread":await N(T.id);break;case"archive":await y(T.id);break;case"star":await E(T.id);break;case"custom":a==null||a(T.payload);break}},F=()=>{_(),f(!1)},A=()=>{C(),f(!1)};return t.jsxs("div",{ref:l,className:`w-flex-col w-relative w-notif-panel${s?" w-notif-panel--fill":""}${i?` ${i}`:""}`,style:{maxHeight:r||"100%"},children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-none w-notif-head",children:[t.jsxs("div",{className:"w-tabs w-grow",children:[t.jsx("button",{className:`w-tab${m==="inbox"?" w-tab--active":""}`,onClick:()=>c("inbox"),children:"Inbox"}),t.jsx("button",{className:`w-tab${m==="archive"?" w-tab--active":""}`,onClick:()=>c("archive"),children:"Archive"}),t.jsx("button",{className:`w-tab${m==="starred"?" w-tab--active":""}`,onClick:()=>c("starred"),children:"Starred"})]}),t.jsxs("button",{className:"w-btn w-btn--icon w-none w-relative",onClick:()=>f(!u),title:"Options",children:[t.jsx(Zu,{size:16}),d&&t.jsx("span",{className:"w-notif-filter-dot"})]}),u&&t.jsxs("div",{ref:h,className:"w-menu w-notif-menu",children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{p(!d),f(!1)},children:[t.jsx(Hu,{})," Unread only",d&&t.jsx(Ge,{className:"w-menu-check"})]}),m==="inbox"&&t.jsxs("button",{className:"w-menu-item",onClick:F,children:[t.jsx(Lu,{})," Mark all as read"]}),t.jsxs("button",{className:"w-menu-item",onClick:A,children:[t.jsx(zo,{})," Archive all read"]})]})]}),t.jsx("div",{className:"w-grow w-notif-body",children:w?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):b?t.jsx(Nt,{icon:t.jsx(mi,{size:20,className:"w-text-error"}),title:"Failed to load notifications",description:b.message||"An unexpected error occurred."}):x.length===0?t.jsx(Nt,{icon:t.jsx(mi,{size:20}),title:"No notifications",description:"You're all caught up!"}):t.jsxs(t.Fragment,{children:[x.map(T=>t.jsx(T0,{notification:T,onAction:M},T.id)),j&&t.jsx("div",{className:"w-flex w-justify-center",style:{padding:12},children:t.jsx("button",{className:"w-btn w-btn--ghost w-btn--sm",onClick:v,children:"Load more"})})]})})]})}),V0=o.forwardRef(({position:e,scope:a,onAction:s,className:r},i)=>t.jsx("div",{ref:i,className:`w-card w-flex-col w-notif-pop${r?` ${r}`:""}`,style:{top:(e==null?void 0:e.top)!==void 0?e.top:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?e.bottom:void 0,left:(e==null?void 0:e.left)!==void 0?e.left:void 0,right:(e==null?void 0:e.right)!==void 0?e.right:void 0,maxHeight:e!=null&&e.maxHeight?e.maxHeight:"90vh"},children:t.jsx(I0,{scope:a,onAction:s,fullWidth:!0,maxHeight:e!=null&&e.maxHeight?`${e.maxHeight}px`:"100%"})}));function z0({className:e,showBadge:a=!0,scope:s="all",onAction:r}){const[i,l]=o.useState(!1),m=as(),c=o.useRef(null),d=o.useRef(null),p=o.useRef(null),{count:u,refetch:f}=Oo({scope:s}),h=async x=>{await f(),r==null||r(x.payload)},g=bt({triggerRef:p,isOpen:i,minWidth:Math.min(450,typeof window<"u"?window.innerWidth-32:300),defaultMaxHeight:550});return o.useEffect(()=>{if(!i)return;const x=setTimeout(()=>{const w=b=>{var v,k;const j=b.target;(v=c.current)!=null&&v.contains(j)||(k=d.current)!=null&&k.contains(j)||l(!1)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},50);return()=>{clearTimeout(x)}},[i]),t.jsx(Re,{children:t.jsxs("div",{ref:c,className:`w-inline w-relative${e?` ${e}`:""}`,children:[t.jsxs("button",{ref:p,className:"w-btn w-btn--icon w-notif-bell",onClick:()=>l(!i),"aria-label":u>0?`${u} unread notifications`:"Notifications",children:[t.jsx(Mu,{strokeWidth:1}),a&&u>0&&t.jsx("span",{className:"w-notif-badge","data-dot":u<=9?"":void 0,children:u>9?"9+":""})]}),typeof window<"u"&&i&&tn.createPortal(t.jsx("div",{className:"wacht-root",style:m,children:t.jsx(V0,{ref:d,position:g,scope:s,onAction:h,onClose:()=>l(!1)})}),document.body)]})})}const Cp=({showName:e=!0,showNotifications:a=!0})=>t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[a&&t.jsx(z0,{}),t.jsx(Wr,{showName:e})]}),Np=({children:e})=>{var r;const{session:a,loading:s}=it();return s||!((r=a.signins)!=null&&r.length)||!a.active_signin?null:t.jsx(t.Fragment,{children:e})},Sp=({children:e})=>{var r;const{loading:a,session:s}=it();return a||(r=s.signins)!=null&&r.length&&s.active_signin?null:t.jsx(t.Fragment,{children:e})},Ep=({onAccountSelect:e,showAddAccount:a=!0})=>{var _,C,y,E;const{session:s,loading:r,switchSignIn:i,signOut:l}=it(),{deployment:m}=je(),{navigateToSignIn:c,navigate:d}=kt(),[p,u]=o.useState(null),[f,h]=o.useState(null),g=s==null?void 0:s.active_signin,x=(s==null?void 0:s.signins)||[],w=((C=(_=m==null?void 0:m.auth_settings)==null?void 0:_.multi_session_support)==null?void 0:C.enabled)??!1,b=(y=m==null?void 0:m.ui_settings)==null?void 0:y.app_name;o.useEffect(()=>{r||x.length||c()},[r,x,c]);const j=M=>M.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2),v=async M=>{var F;h(M);try{if(await i(M),e)e(M),h(null);else{let A=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));if(A||(A=(F=m.ui_settings)==null?void 0:F.after_signin_redirect_url),A){let T;try{T=new URL(A)}catch{T=new URL(A,window.location.origin)}(m==null?void 0:m.mode)==="staging"&&T.searchParams.set("__dev_session__",xt(m.backend_host)??""),d(T.toString())}else h(null)}}catch{h(null)}},k=async(M,F)=>{M.stopPropagation(),u(F);try{await l(F)}catch{}finally{u(null)}},N=()=>{var F;let M=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));M||(M=(F=m.ui_settings)==null?void 0:F.after_signin_redirect_url),c(M)};return r?t.jsx(_s,{}):x.length?t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-sub",style:{fontSize:12.5},children:["Don't have an account?"," ",t.jsx(Et,{to:`${(E=m.ui_settings)==null?void 0:E.sign_up_page_url}${window.location.search}`,className:"w-link",children:"Sign up"})]}),children:[t.jsx(nt,{title:"Choose an account",sub:`Select an account to continue${b?` to ${b}`:""}`}),t.jsx("div",{className:"w-flex-col",children:x.map(({user:M,id:F})=>{var R,O;if(!M)return null;const A=F===(g==null?void 0:g.id),T=f===F,P=p===F,S=`${M.first_name||""} ${M.last_name||""}`.trim(),$=S||((R=M.primary_email_address)==null?void 0:R.email)||M.username||"User",H=((O=M.primary_email_address)==null?void 0:O.email)||M.username;return t.jsxs("button",{className:"w-acct","data-active":A?"":void 0,"data-busy":T?"":void 0,onClick:()=>v(F),children:[t.jsx("div",{className:"w-avatar",children:T?t.jsx(vt,{onAccent:!0}):M.has_profile_picture?t.jsx("img",{src:M.profile_picture_url,alt:S}):j($)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:$}),H&&H!==$&&t.jsx("div",{className:"w-secsub w-truncate",children:H})]}),A&&t.jsxs("span",{className:"w-pill w-pill--current",children:[t.jsx(Ge,{size:11,weight:"bold"}),"current"]}),t.jsx("span",{className:"w-kebab w-acct-out",role:"button","aria-disabled":P,title:"Sign out",onClick:Z=>k(Z,F),children:P?t.jsx(vt,{}):t.jsx(Ma,{size:15})})]},F)})}),a&&w&&t.jsx("div",{className:"w-acct-foot",children:t.jsxs("button",{className:"w-acct-add",onClick:N,children:[t.jsx(St,{size:15}),"Add another account"]})})]})}):null},Ap=()=>{const{navigateToSignIn:e}=kt();return o.useEffect(()=>{e()},[e]),null},Mp=()=>{const{navigateToSignUp:e}=kt();return o.useEffect(()=>{e()},[e]),null},Rp=()=>{var A,T;const{organizationMemberships:e,refetch:a,loading:s}=ga(),{workspaces:r}=xa(),{switchOrganization:i,switchWorkspace:l}=it(),{deployment:m}=je(),[c,d]=o.useState(null),[p,u]=o.useState("orgList"),[f,h]=o.useState(null),g=((m==null?void 0:m.b2b_settings.organizations_enabled)??!1)&&((m==null?void 0:m.b2b_settings.workspaces_enabled)??!1),x=(m==null?void 0:m.b2b_settings.allow_users_to_create_orgs)??!1,w=o.useRef(!1);o.useEffect(()=>{if(!(w.current||!e)){if(w.current=!0,e.length===0){u("createOrg");return}if(!g){u("orgList");return}if(!r||r.length===0){const P=e.find(S=>{var $,H;return!(($=S.eligibility_restriction)!=null&&$.type)||((H=S.eligibility_restriction)==null?void 0:H.type)==="none"});if(P){h(P.organization.id),u("createWorkspace");return}}u("orgList")}},[e,r,g]);const b=P=>P.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=async P=>{if(g){h(P.id),u("workspaceList");return}d(P.id);try{await i(P.id)}finally{d(null)}},v=async P=>{d(P.id);try{await l(P.id)}finally{d(null)}},k=async P=>{var $;await a();const S=(($=P==null?void 0:P.data)==null?void 0:$.organization)||(P==null?void 0:P.organization)||P;if(!g){u("orgList");return}S!=null&&S.id?(h(S.id),u("createWorkspace")):u("orgList")},N=async P=>{var $;const S=(P==null?void 0:P.id)??(($=P==null?void 0:P.workspace)==null?void 0:$.id);if(S){d(S);try{await l(S)}finally{d(null)}}},_=async()=>{h(null),u("orgList")},C=(A=e==null?void 0:e.find(P=>P.organization.id===f))==null?void 0:A.organization,y=f?r==null?void 0:r.filter(P=>P.organization.id===f):[];if(s)return null;if(p==="createOrg")return t.jsx(ze.Body,{style:{padding:0},children:t.jsx(pn,{onSuccess:k,onCancel:()=>u("orgList")})});if(p==="createWorkspace"&&f)return t.jsx(ze.Body,{style:{padding:0},children:t.jsx($r,{organizationId:f,onSuccess:N,onCancel:()=>u("workspaceList"),onCreateOrganization:()=>u("createOrg")})});const E=p==="workspaceList",M=E?"Select a workspace":"Select an organization",F=E?`Choose a workspace in ${(C==null?void 0:C.name)||""}`:`to continue to ${((T=m==null?void 0:m.ui_settings)==null?void 0:T.app_name)||"App"}`;return t.jsxs("div",{className:"w-split",children:[t.jsxs("div",{className:"w-split-aside w-flex-col w-justify-between w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx(Ar,{placement:"left"}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-title",children:M}),t.jsx("p",{className:"w-sub",children:F})]})]}),t.jsx(Wr,{showName:!0})]}),t.jsxs("div",{className:"w-split-main",children:[t.jsxs("div",{className:"w-grow w-flex-col",style:{overflow:"hidden",marginBottom:24},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:8},children:[E&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:_,"aria-label":"Go back",title:"Go back",children:t.jsx(rn,{})}),t.jsx("h2",{className:"w-sec",children:E?"Workspaces":"Your organizations"})]}),t.jsx("div",{className:"w-grow w-flex-col",style:{overflowY:"auto"},children:E?t.jsx(t.Fragment,{children:y&&y.length>0?y.map(P=>{var $,H,R;const S=(($=P.eligibility_restriction)==null?void 0:$.type)!=="none"&&((H=P.eligibility_restriction)==null?void 0:H.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!S&&v(P),disabled:c===P.id||S,title:S?(R=P.eligibility_restriction)==null?void 0:R.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:P.image_url?t.jsx("img",{src:P.image_url,alt:P.name}):b(P.name).charAt(0)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:P.name}),t.jsxs("div",{className:"w-secsub w-inline w-gap-1",children:[t.jsx(ds,{}),"Workspace"]})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[S&&t.jsx(Ra,{size:16,className:"w-text-error"}),t.jsx(Jt,{})]})]},P.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(ds,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No workspaces yet"}),t.jsxs("p",{children:["Create your first workspace for"," ",(C==null?void 0:C.name)||"this organization"]})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createWorkspace"),children:[t.jsx(St,{}),"Create workspace"]})})]})}):e&&e.length>0?e.map(P=>{var D,Y,B,Q,ue;const S=P.organization,$=r==null?void 0:r.filter(we=>we.organization.id===S.id),H=($==null?void 0:$.length)||0,R=S.member_count,O=((Y=(D=P.roles)==null?void 0:D[0])==null?void 0:Y.name)||"No role",Z=P.roles.length-1,L=Z>0?`${O.charAt(0).toUpperCase()+O.slice(1)} +${Z}`:O.charAt(0).toUpperCase()+O.slice(1),U=((B=P.eligibility_restriction)==null?void 0:B.type)!=="none"&&((Q=P.eligibility_restriction)==null?void 0:Q.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!U&&j(S),disabled:c===S.id||U,title:U?(ue=P.eligibility_restriction)==null?void 0:ue.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:S.image_url?t.jsx("img",{src:S.image_url,alt:S.name}):b(S.name)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:S.name}),t.jsx("div",{className:"w-secsub w-inline w-gap-1",children:g?t.jsxs(t.Fragment,{children:[t.jsx(ds,{}),H," ","workspace",H!==1?"s":""]}):t.jsxs(t.Fragment,{children:[t.jsx(hs,{}),L," •"," ",R," member",R!==1?"s":""]})})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[U&&t.jsx(Ra,{size:16,className:"w-text-error"}),t.jsx(Jt,{})]})]},S.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(hs,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No organizations yet"}),t.jsx("p",{children:x?"Create your first organization to get started":"You don't have access to any organizations yet"})]}),x&&t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createOrg"),children:[t.jsx(St,{}),"Create organization"]})})]})})]}),E&&f&&t.jsxs(se,{$outline:!0,onClick:()=>u("createWorkspace"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create workspace"]}),!E&&e&&e.length>0&&x&&t.jsxs(se,{$outline:!0,onClick:()=>u("createOrg"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create new organization"]})]})]})},Lp=({children:e})=>{var f,h,g,x;const{activeOrganization:a}=wa(),{activeWorkspace:s}=Ut(),{deployment:r}=je(),{loading:i,orgMembership:l,workspaceMembership:m}=Eo(),c=((r==null?void 0:r.b2b_settings.organizations_enabled)??!1)&&((r==null?void 0:r.b2b_settings.workspaces_enabled)??!1),d=((f=l==null?void 0:l.eligibility_restriction)==null?void 0:f.type)!=="none"&&((h=l==null?void 0:l.eligibility_restriction)==null?void 0:h.type)!==void 0,p=((g=m==null?void 0:m.eligibility_restriction)==null?void 0:g.type)!=="none"&&((x=m==null?void 0:m.eligibility_restriction)==null?void 0:x.type)!==void 0;return i?null:(d||p||!a?!1:c?s?(m==null?void 0:m.workspace.id)===s.id&&m.organization_id===a.id:!1:!0)?t.jsx(t.Fragment,{children:e}):t.jsx(Re,{children:t.jsx(ze,{isOpen:!0,children:t.jsx(ze.Overlay,{children:t.jsx(ze.Content,{className:"w-flex w-justify-center",style:{padding:0,width:900,maxWidth:"90vw"},children:t.jsx(Rp,{})})})})})},Pp=e=>{const a=e.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(i=>a.startsWith(i))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(i=>a.startsWith(i))},$p=e=>{const a=e.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(r=>a.startsWith(r))};exports.AcceptInvite=H4;exports.AuthFormImage=Ar;exports.CreateOrganizationForm=pn;exports.CreateWorkspaceDialog=Or;exports.CreateWorkspaceForm=$r;exports.DefaultStylesProvider=Re;exports.DeploymentInitialized=S2;exports.DeploymentInitializing=E2;exports.DeploymentProvider=K0;exports.Dialog=ze;exports.DialogTrigger=W4;exports.Dropdown=ks;exports.DropdownDivider=Dc;exports.DropdownItem=ta;exports.DropdownItems=Cs;exports.DropdownTrigger=Ns;exports.Form=Uc;exports.FormGroup=We;exports.Input=be;exports.Label=Te;exports.MagicLinkVerification=$4;exports.ManageAccount=$0;exports.ManageAccountDialog=O0;exports.ManageOrganization=e0;exports.ManageWorkspace=s0;exports.ManageWorkspaceDialog=Hr;exports.NavigateToSignIn=Ap;exports.NavigateToSignUp=Mp;exports.NavigationLink=Et;exports.NotificationBell=z0;exports.NotificationItem=T0;exports.NotificationPanel=I0;exports.NotificationPopover=V0;exports.OAuthProvider=fo;exports.ORG_ADMIN_PERMISSIONS=n0;exports.ORG_MANAGEMENT_PERMISSIONS=r0;exports.OTPInput=ba;exports.OrganizationSwitcher=l0;exports.PhoneNumberInput=js;exports.PhoneVerification=Oc;exports.ProfileCompletion=Hc;exports.RequireActiveTenancy=Lp;exports.SignInForm=M4;exports.SignUpForm=j4;exports.SignedIn=Np;exports.SignedInAccounts=Ep;exports.SignedOut=Sp;exports.SimpleDialog=U4;exports.SocialCallback=P4;exports.Spinner=_e;exports.Switch=Ha;exports.TwoFactorMethodSelector=$c;exports.TwoFactorVerification=Zc;exports.UserButton=Wr;exports.UserControls=Cp;exports.WORKSPACE_ADMIN_PERMISSIONS=i0;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=o0;exports.WaitlistForm=L4;exports.canManageOrganization=Tr;exports.canManageWorkspace=Vr;exports.clearTokenCache=$t;exports.hasIncompleteProfile=O4;exports.hasOrgPermission=Fr;exports.hasWorkspacePermission=Ir;exports.isExternalUrl=Pp;exports.isOrgAdmin=Fm;exports.isSafeUrl=$p;exports.isWorkspaceAdmin=Tm;exports.redirectToProfileCompletion=Z4;exports.useActiveOrganization=wa;exports.useActiveTenancy=Eo;exports.useActiveWorkspace=Ut;exports.useActorMcpServers=Yd;exports.useActorProjectSearch=Fd;exports.useActorProjects=Hd;exports.useActorThreadSearch=Vd;exports.useAgentSession=Rd;exports.useAgentThread=zd;exports.useAgentThreadAssignments=Ud;exports.useAgentThreadConversation=Md;exports.useAgentThreadFilesystem=Dd;exports.useAgentThreadTaskGraphs=qd;exports.useApiAuthAppSession=j2;exports.useApiAuthAuditAnalytics=C2;exports.useApiAuthAuditLogs=k2;exports.useApiAuthAuditTimeseries=N2;exports.useApiAuthKeys=_2;exports.useClient=ye;exports.useCreateWebhookEndpoint=g2;exports.useDeployment=je;exports.useExternalAgentConnections=Qd;exports.useForgotPassword=Lo;exports.useInvitation=Io;exports.useMagicLinkVerification=Ro;exports.useNavigation=kt;exports.useNotificationStream=Po;exports.useNotificationUnreadCount=Oo;exports.useNotifications=$o;exports.useOrganizationList=Dt;exports.useOrganizationMemberships=ga;exports.useProjectTaskBoardItem=Gd;exports.useProjectTaskBoardItemComments=Kd;exports.useProjectTasks=Bd;exports.useProjectThreadFeed=Id;exports.useProjectThreads=Td;exports.useSession=it;exports.useSignIn=wo;exports.useSignUp=go;exports.useSocialCallback=Mo;exports.useThemeOverrideVars=as;exports.useUser=va;exports.useUserSignins=So;exports.useWaitlist=Ao;exports.useWebhookAnalytics=b2;exports.useWebhookAppSession=h2;exports.useWebhookDeliveries=v2;exports.useWebhookEndpoints=w2;exports.useWebhookEvents=x2;exports.useWebhookStats=f2;exports.useWebhookTimeseries=y2;exports.useWorkspaceList=xa;exports.useWorkspaceMemberships=an;Object.keys(Br).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Br[e]})});
118
+ `),ve=new Blob([J],{type:"text/plain"}),Ye=URL.createObjectURL(ve),Ve=document.createElement("a");Ve.href=Ye,Ve.download="wacht-backup-codes.txt",Ve.click(),URL.revokeObjectURL(Ye),g("Backup codes downloaded","info")},Bt=async()=>{var J,ve;if((ve=(J=e==null?void 0:e.auth_settings)==null?void 0:J.passkey)!=null&&ve.enabled)try{O(!0);const Ye=await u();H(Ye.data||[])}catch{g("Failed to load passkeys","error")}finally{O(!1)}},ya=async J=>{try{L(!0),await f(J||void 0),await Bt(),g("Passkey registered successfully!","info")}catch(ve){throw g(ve.message||"Failed to register passkey","error"),ve}finally{L(!1)}},ja=async J=>{try{await h(J),await Bt(),g("Passkey removed","info")}catch(ve){g(ve.message||"Failed to remove passkey","error")}};o.useEffect(()=>{Bt()},[(oe=(ia=e==null?void 0:e.auth_settings)==null?void 0:ia.passkey)==null?void 0:oe.enabled]);const yt=[];return lt&&yt.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:a!=null&&a.has_password?"Enabled":"Disabled",actions:a!=null&&a.has_password?["change"]:["setup"],group:"sign-in"}),(Ne=(xe=e==null?void 0:e.auth_settings)==null?void 0:xe.passkey)!=null&&Ne.enabled&&yt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:$.length>0?`${$.length} registered`:"",actions:$.length>0?["manage","add"]:["add"],group:"sign-in"}),ge!=null&&ge.authenticator&&yt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:a!=null&&a.user_authenticator?"Enabled":"Disabled",actions:a!=null&&a.user_authenticator?["remove"]:["setup"],group:"sign-in"}),a!=null&&a.user_authenticator&&yt.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:a!=null&&a.backup_codes_generated?"Generated":"Not Generated",actions:["generate"],group:"recovery"}),a!=null&&a.user_authenticator&&yt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:x==="enforced"?"Enforced":"Optional",actions:["toggle"],group:"recovery"}),ne!=="table"?t.jsxs(t.Fragment,{children:[t.jsxs(h0,{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(ea,{size:16}),t.jsxs("span",{className:"w-sec",children:[ne==="qr"&&"Setup Two-Factor Authentication",ne==="verify"&&"Verify Your Authenticator",ne==="backup"&&"Save Your Backup Codes",ne==="success"&&"Setup Complete!"]})]}),t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("table"),children:"← Back"})]}),t.jsxs("div",{className:"w-narrow w-flex-col w-items-center w-gap-5",style:{textAlign:"center"},children:[ne==="qr"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),t.jsx("div",{className:"w-flex w-justify-center",children:le?t.jsxs("div",{className:"w-qr w-flex-col w-items-center w-gap-3",children:[t.jsx("span",{className:"w-spin"}),t.jsx("div",{className:"w-secsub",children:"Loading QR Code..."})]}):re?t.jsx("div",{className:"w-tile w-flex w-items-center w-justify-center",children:t.jsx(Ur,{value:re,size:200,level:"M",marginSize:0})}):t.jsx("div",{className:"w-qr w-text-error",children:"QR Code Not Available"})}),t.jsxs("div",{className:"w-flex-col w-gap-2 w-full",children:[t.jsx("p",{className:"w-secsub",children:"Or enter this code manually:"}),t.jsx("div",{className:"w-token",children:t.jsx("code",{children:q||"Loading..."})})]}),t.jsx(se,{$fullWidth:!0,onClick:()=>ae("verify"),disabled:!re||!q,children:"I've Scanned the Code"})]}),ne==="verify"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Enter two consecutive codes from your authenticator app to verify setup"}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(be,{type:"text",placeholder:"000000",value:Ee[0],onChange:J=>{const ve=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([ve,Ee[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}}),t.jsx(be,{type:"text",placeholder:"000000",value:Ee[1],onChange:J=>{const ve=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([Ee[0],ve])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}})]}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("qr"),children:"Back"}),t.jsx(se,{$size:"sm",onClick:me,disabled:de||Ee.some(J=>J.length!==6),children:de?"Verifying...":"Verify & Continue"})]})]}),ne==="backup"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-banner w-banner--warn",style:{textAlign:"left"},children:[t.jsx(Ta,{size:16}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Important!"}),t.jsx("div",{className:"w-banner-txt",children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),t.jsx("div",{className:"w-codes w-full",children:W.map((J,ve)=>t.jsx("span",{onClick:()=>navigator.clipboard.writeText(J),style:{cursor:"pointer"},children:J},ve))}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:ct,children:"Copy All"}),t.jsxs(se,{$outline:!0,$size:"sm",onClick:Rt,children:[t.jsx(ul,{size:16}),"DownloadSimple"]})]}),t.jsx(se,{$fullWidth:!0,onClick:Ze,children:"Complete Setup"})]}),ne==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ge,{size:26})})]}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-items-center",children:[t.jsx("h3",{className:"w-title",children:"All Set!"}),t.jsx("p",{className:"w-secsub",children:"Your account is now protected with two-factor authentication."})]}),t.jsx(se,{$fullWidth:!0,onClick:Ze,children:"Continue to Security"})]})]})]}):t.jsx(t.Fragment,{children:yt.length?t.jsx("div",{children:yt.map((J,ve)=>{const Ye=ve>0?yt[ve-1].group:null,Ve=J.group!==Ye,jt=yt[ve+1],_t=jt&&jt.group===J.group;return t.jsxs("div",{children:[Ve&&t.jsx(I6,{$first:ve===0,children:J.group==="sign-in"?"Sign-in methods":"Recovery"}),t.jsxs(f0,{children:[t.jsxs(w0,{children:[t.jsx("div",{className:"w-flex w-items-center w-wrap w-gap-2 w-sec",children:t.jsx("span",{children:J.name})}),t.jsx("div",{className:"w-secsub",children:J.description})]}),t.jsx(g0,{children:t.jsxs("div",{className:"w-relative",children:[J.id==="password"&&t.jsx(t.Fragment,{children:a!=null&&a.has_password?t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Change"}),_&&t.jsx(Yi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Ke})]}),ie()&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",ref:P,onClick:()=>E(!0),children:"Remove"}),y&&t.jsx(Z6,{triggerRef:P,onClose:()=>E(!1),onRemovePassword:ee})]})]}):t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Setup"}),_&&t.jsx(Yi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Ke,isSetup:!0})]})}),J.id==="authenticator"&&!(a!=null&&a.user_authenticator)&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:A,onClick:()=>N(!0),disabled:le,children:le?"Setting up...":"Setup"}),k&&t.jsx(H6,{triggerRef:A,onClose:()=>N(!1),onSetupTOTP:async()=>{const Be=await i();return De(Be.id),Be},onVerifyTOTP:async Be=>{await l(Ie,Be),await a.refetch(),g("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(a==null?void 0:a.user_authenticator)&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>j(!0),disabled:Je,children:Je?"Removing...":"Remove"}),b&&t.jsx(Ja,{title:"Remove MFA and reset policy to default?",onConfirm:He,onCancel:()=>j(!1)})]}),J.id==="backup_codes"&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:S,onClick:qe,disabled:K,children:K?"Generating...":a!=null&&a.backup_codes_generated?"Regenerate":"Generate"}),M&&t.jsx(F6,{triggerRef:S,codes:W,onClose:()=>F(!1),onCopy:ct,onDownload:Rt})]})}),J.id==="second_factor_policy"&&t.jsx(Ha,{checked:x==="enforced",onChange:Be=>{v(Be?"enforced":"none")}}),J.id==="passkey"&&t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsxs(se,{$outline:!0,$size:"sm",onClick:()=>D(!U),children:[U?"Hide":"Manage"," ","(",$.length,")",t.jsx(Wt,{size:14,style:{transform:U?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:we,onClick:()=>B(!0),disabled:Z,children:Z?"Adding...":"Add"}),Y&&t.jsx(T6,{triggerRef:we,onClose:()=>B(!1),onAddPasskey:ya})]})]})]})})]}),J.id==="passkey"&&U&&t.jsx("div",{className:"w-flex-col w-gap-2",children:R?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):$.length===0?t.jsx("div",{className:"w-empty",children:t.jsx("p",{children:"No passkeys registered yet"})}):t.jsx("div",{className:"w-flex-col w-gap-2",children:$.map(Be=>t.jsxs("div",{className:"w-locked w-flex w-items-center w-justify-between",style:{height:"auto",padding:"10px 12px"},children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:Be.name||"Unnamed Passkey"}),t.jsxs("span",{className:"w-secsub",children:[Be.device_type==="platform"?"This device":"Security key",Be.last_used_at&&` • Last used ${new Date(Be.last_used_at).toLocaleDateString()}`]})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>ue(Be.id),children:"Remove"}),Q===Be.id&&t.jsx(Ja,{title:`Remove "${Be.name||"Unnamed Passkey"}"?`,onConfirm:()=>{ja(Be.id),ue(null)},onCancel:()=>ue(null)})]})]},Be.id))})}),_t&&t.jsx("div",{className:"w-hr"})]},J.id)})}):t.jsx(Nt,{title:"No security features available",description:"Contact your administrator to enable security features."})})},z6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#d93025"}),t.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),t.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#fcc934"}),t.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),t.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),t.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),t.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),t.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"}}),t.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)"}}),t.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),t.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)"}}),t.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)"}})]}),D6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[t.jsx("stop",{offset:.1,stopColor:"#ffe226"}),t.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),t.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[t.jsx("stop",{offset:.3,stopColor:"#960e18"}),t.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),t.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),t.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),t.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),t.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[t.jsx("stop",{offset:.13,stopColor:"#fff44f"}),t.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),t.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[t.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),t.jsx("stop",{offset:.67,stopColor:"#9059ff"}),t.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),t.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[t.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),t.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),t.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[t.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),t.jsx("stop",{offset:.28,stopColor:"#ff980e"}),t.jsx("stop",{offset:.47,stopColor:"#ff3750"}),t.jsx("stop",{offset:.78,stopColor:"#eb0878"}),t.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),t.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[t.jsx("stop",{offset:.11,stopColor:"#fff44f"}),t.jsx("stop",{offset:.46,stopColor:"#ff980e"}),t.jsx("stop",{offset:.72,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[t.jsx("stop",{offset:0,stopColor:"#fff44f"}),t.jsx("stop",{offset:.3,stopColor:"#ff980e"}),t.jsx("stop",{offset:.57,stopColor:"#ff3647"}),t.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[t.jsx("stop",{offset:.14,stopColor:"#fff44f"}),t.jsx("stop",{offset:.48,stopColor:"#ff980e"}),t.jsx("stop",{offset:.66,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[t.jsx("stop",{offset:.09,stopColor:"#fff44f"}),t.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),t.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[t.jsx("stop",{offset:.05,stopColor:"#fff44f"}),t.jsx("stop",{offset:.37,stopColor:"#ff980e"}),t.jsx("stop",{offset:.53,stopColor:"#ff3647"}),t.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),t.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[t.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),t.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"})]}),U6=e=>t.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",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"b",children:[t.jsx("stop",{offset:0,stopColor:"#06c2e7"}),t.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),t.jsx("stop",{offset:.5,stopColor:"#12aef1"}),t.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),t.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),t.jsxs("linearGradient",{id:"a",children:[t.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),t.jsx("stop",{offset:1,stopColor:"#fff"})]}),t.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"}),t.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:.958})}),t.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:3.564})}),t.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"})]}),t.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)"}),t.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)"}),t.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)"}),t.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"}),t.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)"}),t.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),t.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),W6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...e,children:[t.jsxs("defs",{children:[t.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:[t.jsx("stop",{offset:.7,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.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:[t.jsx("stop",{offset:.8,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#35c1f1"}),t.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),t.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),t.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),t.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#66eb6e"}),t.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#0c59a4"}),t.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),t.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:[t.jsx("stop",{offset:0,stopColor:"#1b9de2"}),t.jsx("stop",{offset:.2,stopColor:"#1595df"}),t.jsx("stop",{offset:.7,stopColor:"#0680d7"}),t.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),t.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)"}),t.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)"}),t.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)"}),t.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)"}),t.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)"}),t.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)"})]}),B6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Opera",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),t.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),t.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),t.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)"})]}),G6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Brave",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),t.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),t.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),t.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"}),t.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)"}),t.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),q6=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"w-text-secondary",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),t.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"}),t.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),t.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),K6=({browser:e})=>{const a=(e==null?void 0:e.toLowerCase())||"",s={width:20,height:20};return a.includes("chrome")?t.jsx(z6,{...s}):a.includes("firefox")?t.jsx(D6,{...s}):a.includes("safari")?t.jsx(U6,{...s}):a.includes("edge")?t.jsx(W6,{...s}):a.includes("opera")?t.jsx(B6,{...s}):a.includes("brave")?t.jsx(G6,{...s}):t.jsx(q6,{})},Y6=()=>{const{signins:e,removeSignin:a,refetch:s,loading:r}=So(),{refetch:i}=it(),{toast:l}=aa(),m=e,c=async p=>{try{await a(p),await Promise.all([s(),i()]),l("Session ended successfully","info")}catch(u){l(u.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const u=new Date(p);if(isNaN(u.getTime()))return"Unknown";const h=Math.floor((new Date().getTime()-u.getTime())/(1e3*60));return h<1?"Just now":h<60?`${h}m ago`:h<1440?`${Math.floor(h/60)}h ago`:u.toLocaleDateString()};return r?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):t.jsx("div",{children:m&&m.length>0?t.jsx(t.Fragment,{children:t.jsx(fn,{children:t.jsxs(Ht,{children:[t.jsx(Ft,{children:t.jsxs(rt,{children:[t.jsx(Oe,{children:"Browser & Device"}),t.jsx(Oe,{children:"Location"}),t.jsx(Oe,{children:"Last Active"}),t.jsx(Oe,{})]})}),t.jsx(Tt,{children:m.map(p=>t.jsxs(rt,{children:[t.jsx(Qe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(Dr,{children:t.jsx(K6,{browser:p.browser||"Unknown"})}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&t.jsx("div",{className:"w-text-muted",children:p.device})]})]})}),t.jsx(Qe,{children:t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&t.jsx("div",{className:"w-text-muted",children:p.ip_address})]})}),t.jsx(Qe,{children:d(p.last_active_at)}),t.jsx(It,{children:t.jsxs(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>c(p.id),children:[t.jsx(Ma,{size:12}),"Sign out"]})})]},p.id))})]})})}):t.jsx(Nt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})},Q6=(e,a)=>`${(e==null?void 0:e[0])||""}${(a==null?void 0:a[0])||""}`.toUpperCase()||"U",$0=()=>{var N,_,C,y,E,M,F,A;const{loading:e,user:a,updateProfilePicture:s}=va(),{deployment:r}=je(),[i,l]=o.useState("profile"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((T,P="info")=>{c(T),p(P),setTimeout(()=>c(null),3e3)},[c]),x=async T=>{var S;const P=(S=T.target.files)==null?void 0:S[0];if(P){if(P.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!P.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s(P),await(a==null?void 0:a.refetch()),g("Profile picture updated","info")}catch($){g(($==null?void 0:$.message)||"Failed to update profile picture","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(e)return t.jsx(Re,{children:t.jsx(hr,{className:"w-flex w-items-center w-justify-center",children:t.jsx(_e,{})})});const w=r==null?void 0:r.auth_settings,b=(N=w==null?void 0:w.email_address)==null?void 0:N.enabled,j=(_=w==null?void 0:w.phone_number)==null?void 0:_.enabled,v=((C=r==null?void 0:r.social_connections)==null?void 0:C.some(T=>T.enabled))||!1,k=((y=w==null?void 0:w.password)==null?void 0:y.enabled)||((E=w==null?void 0:w.auth_factors_enabled)==null?void 0:E.authenticator)||((M=w==null?void 0:w.auth_factors_enabled)==null?void 0:M.phone_otp)||((F=w==null?void 0:w.auth_factors_enabled)==null?void 0:F.backup_code);return t.jsx(Re,{children:t.jsx(d0,{children:t.jsx(c0.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(hr,{className:"w-relative",children:[a&&t.jsxs(v0,{className:"mac-page-header",children:[t.jsxs("button",{type:"button",className:"w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var T;return(T=h.current)==null?void 0:T.click()},disabled:u,title:"Change profile picture","aria-label":"Change profile picture",children:[t.jsx("span",{className:"w-avatar w-avatar--lg",children:a.profile_picture_url?t.jsx("img",{src:a.profile_picture_url,alt:""}):Q6(a.first_name,a.last_name)}),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(nn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(b0,{children:[t.jsx(y0,{children:`${a.first_name||""} ${a.last_name||""}`.trim()||a.username||"Account"}),((A=a.primary_email_address)==null?void 0:A.email)&&t.jsx(j0,{children:a.primary_email_address.email})]})]}),t.jsx(u0,{children:t.jsxs(m0,{children:[t.jsx(Ca,{$isActive:i==="profile",onClick:()=>l("profile"),children:t.jsxs(Na,{children:[t.jsx(fs,{size:16}),"Profile"]})}),b&&t.jsx(Ca,{$isActive:i==="email",onClick:()=>l("email"),children:t.jsxs(Na,{children:[t.jsx(pl,{size:16}),"Email"]})}),j&&t.jsx(Ca,{$isActive:i==="phone",onClick:()=>l("phone"),children:t.jsxs(Na,{children:[t.jsx(Du,{size:16}),"Phone"]})}),v&&t.jsx(Ca,{$isActive:i==="social",onClick:()=>l("social"),children:t.jsxs(Na,{children:[t.jsx(zu,{size:16}),"Connections"]})}),k&&t.jsx(Ca,{$isActive:i==="security",onClick:()=>l("security"),children:t.jsxs(Na,{children:[t.jsx(ea,{size:16}),"Security"]})}),t.jsx(Ca,{$isActive:i==="sessions",onClick:()=>l("sessions"),children:t.jsxs(Na,{children:[t.jsx(Uu,{size:16}),"Sessions"]})})]})}),t.jsxs(p0,{children:[i==="profile"&&t.jsx(y6,{}),i==="email"&&b&&t.jsx(j6,{}),i==="phone"&&j&&t.jsx(_6,{}),i==="social"&&v&&t.jsx(N6,{}),i==="security"&&k&&t.jsx(V6,{}),i==="sessions"&&t.jsx(Y6,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,style:{minWidth:0},children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Ta,{size:12}):t.jsx(Ge,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},O0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(ze,{isOpen:e,onClose:a,children:t.jsx(ze.Overlay,{children:t.jsxs(ze.Content,{className:"w-dialog--panel",children:[r&&t.jsx(ze.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx($0,{}),l&&t.jsx(ze.Footer,{children:l})]})})}),Le=(...e)=>e.filter(Boolean).join(" "),J6=e=>t.jsx("div",{...e,className:Le("w-relative",e.className)}),Z0=o.forwardRef((e,a)=>t.jsx("button",{...e,ref:a,className:Le("w-acct",e.className),style:{width:"auto",margin:0,padding:4,gap:8,...e.style}}));Z0.displayName="AccountButton";const X6=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","w-avatar--md",a.className),style:{width:28,height:28,fontSize:11,...a.style},children:e}),ep=e=>t.jsx("div",{...e,className:Le("w-sec","w-text-secondary",e.className)}),H0=o.forwardRef(({$position:e,$isOpen:a,$maxHeight:s,children:r,...i},l)=>t.jsx("div",{...i,ref:l,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:s?`${s}px`:"calc(100vh - 48px)",overflowY:"auto",zIndex:99999,top:(e==null?void 0:e.top)!==void 0?`${e.top}px`:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?`${e.bottom}px`:void 0,left:(e==null?void 0:e.left)!==void 0?`${e.left}px`:void 0,right:(e==null?void 0:e.right)!==void 0?`${e.right}px`:void 0,visibility:e&&a?"visible":"hidden",opacity:a&&e?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,padding:0},children:r}));H0.displayName="DropdownContainer";const F0=o.forwardRef(({$top:e,$left:a,$isOpen:s,$maxHeight:r,children:i,...l},m)=>t.jsx("div",{...l,ref:m,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:`${r}px`,overflowY:"auto",zIndex:99999,display:"flex",flexDirection:"column",top:`${e}px`,left:`${a}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${s?"0s":"0.15s"}`,padding:0},children:i}));F0.displayName="SidePanel";const Qi=e=>t.jsx("hr",{...e,className:Le("w-hr",e.className)}),tp=e=>t.jsx("div",{...e,style:{padding:"16px 14px 8px",...e.style}}),ap=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-gap-3",e.className)}),sp=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","w-avatar--lg",a.className),children:e}),np=e=>t.jsx("div",{...e,className:Le("w-flex-col","w-grow",e.className),style:{gap:2,...e.style}}),rp=e=>t.jsx("div",{...e,className:Le("w-sec","w-truncate",e.className)}),ip=e=>t.jsx("div",{...e,className:Le("w-secsub","w-truncate",e.className)}),op=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{border:"0.5px solid var(--wa-border)",background:e?"var(--wa-surface-subtle)":void 0,...a.style}}),lp=({children:e,...a})=>t.jsx("div",{...a,className:"w-avatar w-avatar--sm",children:e}),cp=e=>t.jsx("div",{...e,className:Le("w-sec","w-grow","w-truncate",e.className)}),dp=e=>t.jsx("div",{...e,className:Le("w-secsub","w-none",e.className)}),up=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),mp=e=>t.jsx("button",{...e,className:Le("w-menu-item",e.className)}),pp=e=>t.jsx("span",{...e,className:Le("w-grow",e.className)}),hp=e=>t.jsx("span",{...e,className:Le("w-menu-trail",e.className)}),fp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),wp=e=>t.jsx("div",{...e,className:Le("w-menu-label",e.className)}),Fn=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{cursor:e?"default":"pointer",...a.style}}),Tn=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-flex","w-items-center","w-justify-center","w-none",a.className),style:{width:14,height:14,color:"var(--wa-primary)",...a.style},children:e}),gp=e=>t.jsx("div",{...e,className:"w-none",style:{width:14,...e.style}}),In=e=>t.jsx("div",{...e,className:Le("w-sec","w-grow","w-truncate",e.className)}),Ji=e=>t.jsx("div",{...e,className:Le("w-secsub","w-none",e.className)}),xp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),vp=e=>t.jsx("button",{...e,className:Le("w-menu-item","w-menu-item--danger",e.className)}),bp=e=>t.jsx("button",{...e,className:Le("w-menu-item",e.className),style:{borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,flex:"none",...e.style}}),yp=e=>t.jsx("div",{...e,style:{flex:"1 1 auto",overflowY:"auto",padding:5,...e.style}}),Xi=({$active:e,...a})=>t.jsx("button",{...a,className:Le("w-menu-item","sp-row",e&&"sp-row--active",a.className),style:{height:32,...a.style}}),eo=({$active:e,...a})=>t.jsx("button",{...a,className:Le("w-menu-item","sp-row","sp-ws-row",e&&"sp-row--active",a.className),style:{height:32,paddingLeft:30,position:"relative",...a.style},children:a.children}),to=({$personal:e,children:a,...s})=>t.jsx("div",{...s,className:Le("w-avatar","w-avatar--sm",!e&&"",s.className),children:a}),ao=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","","w-avatar--sm",a.className),children:e}),so=e=>t.jsx("span",{...e,className:Le("w-sec","w-grow","w-truncate",e.className)}),no=e=>t.jsx("span",{...e,className:Le("w-secsub","w-grow","w-truncate",e.className)}),Vn=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-none",e.className),style:{gap:4,...e.style}}),jp=({$open:e,...a})=>t.jsx(Wt,{...a,className:"w-text-muted",style:{flexShrink:0,transition:"transform 0.2s ease",transform:e?"rotate(0deg)":"rotate(-90deg)"}}),zn=e=>t.jsx(Ge,{...e,className:"w-text-primary",style:{flexShrink:0}}),_p=e=>t.jsx("div",{...e,className:Le("w-flex-col","w-gap-3","w-none",e.className),style:{padding:"12px 12px 16px",borderBottom:"0.5px solid var(--wa-border)",...e.style}}),kp=e=>t.jsx("button",{...e,className:Le("w-btn","w-btn--icon",e.className),style:{width:24,height:24,...e.style}}),ro=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-gap-3",e.className),style:{padding:"4px 4px 0",minWidth:0,...e.style}}),io=({children:e,...a})=>t.jsx("div",{...a,className:Le("w-avatar","","w-avatar--md",a.className),children:e}),oo=e=>t.jsx("div",{...e,className:Le("w-flex-col","w-grow",e.className),style:{gap:1,minWidth:0,...e.style}}),lo=e=>t.jsx("div",{...e,className:Le("w-sec","w-truncate",e.className)}),co=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-none",e.className),style:{gap:2,...e.style}}),Ts=({$destructive:e,...a})=>t.jsx("button",{...a,className:Le("w-btn","w-btn--icon",e&&"w-btn--danger",a.className),style:{width:24,height:24,...a.style}}),uo=e=>t.jsx("div",{...e,className:"w-none",style:{borderTop:"0.5px solid var(--wa-border)",padding:5,...e.style}}),mo=e=>t.jsx("button",{...e,className:Le("w-menu-item",e.className),style:{height:32,color:"var(--wa-text-muted)",...e.style}}),po=e=>t.jsx("div",{...e,className:Le("w-flex","w-items-center","w-justify-center","w-none",e.className),style:{width:20,height:20,...e.style}}),Wr=({showName:e=!0,onCreateOrg:a,showOrgSwitcher:s=!0,narrowBreakpoint:r=640})=>{var He,qe,ct,Rt,Bt,ya,ja,yt,sa,na,ra,ia;const i=as(),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(typeof window<"u"&&window.innerWidth<r),[f,h]=o.useState(!1),[g,x]=o.useState("org"),[w,b]=o.useState(null),[j,v]=o.useState({top:0,left:0,maxHeight:400}),[k,N]=o.useState(new Set),[_,C]=o.useState(null),y=o.useRef(null),E=o.useRef(null),M=o.useRef(null),F=bt({triggerRef:y,isOpen:l,minWidth:300}),A=Yt(!1),T=Yt(!1),P=Yt(!1),S=Yt(!1),$=Yt(!1),{session:H,signOut:R,switchSignIn:O,switchOrganization:Z,switchWorkspace:L,refetch:U}=it(),{navigateToSignIn:D}=kt(),{deployment:Y}=je(),{activeOrganization:B,activeMembership:Q,leave:ue}=wa(),{organizationMemberships:we}=ga(),{workspaces:ne}=xa(),{activeWorkspace:ae,activeMembership:re,leave:Me}=Ut(),q=(He=H==null?void 0:H.active_signin)==null?void 0:He.user,tt=((ct=(qe=Y==null?void 0:Y.auth_settings)==null?void 0:qe.multi_session_support)==null?void 0:ct.enabled)??!1,Ie=((Rt=Y==null?void 0:Y.b2b_settings)==null?void 0:Rt.allow_users_to_create_orgs)??!1,De=((Bt=Y==null?void 0:Y.b2b_settings)==null?void 0:Bt.organizations_enabled)??!1,Ee=De&&(((ya=Y==null?void 0:Y.b2b_settings)==null?void 0:ya.workspaces_enabled)??!1),ce=s&&De,W=!B,G=o.useMemo(()=>{var xe;const oe={};for(const Ne of ne||[]){const J=(xe=Ne.organization)==null?void 0:xe.id;J&&(oe[J]||(oe[J]=[]),oe[J].push(Ne))}return oe},[ne]),K=we||[],V=o.useCallback(()=>{if(!E.current)return;const oe=E.current.getBoundingClientRect(),xe=300,Ne=8,J=window.innerWidth<r;if(u(J),J){v({top:oe.top,left:oe.left,maxHeight:oe.height});return}const ve=Math.min(Math.max(oe.height,520),window.innerHeight-oe.top-16),Ye=oe.right+Ne+xe<=window.innerWidth-8;v({top:oe.top,left:Ye?oe.right+Ne:oe.left-Ne-xe,maxHeight:ve})},[r]),de=o.useCallback(()=>{V(),d(!0)},[V]),z=o.useCallback(oe=>{N(xe=>{const Ne=new Set(xe);return Ne.has(oe)?Ne.delete(oe):Ne.add(oe),Ne})},[]);o.useEffect(()=>{B&&Ee&&N(oe=>{if(oe.has(B.id))return oe;const xe=new Set(oe);return xe.add(B.id),xe})},[B,Ee]),o.useEffect(()=>{x(Ee&&ae?"ws":"org")},[Ee,ae==null?void 0:ae.id]),o.useEffect(()=>{const oe=()=>{u(window.innerWidth<r),c&&V()};return window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[r,c,V]),o.useEffect(()=>{l||(d(!1),h(!1))},[l]),o.useEffect(()=>{if(!l)return;const oe=setTimeout(()=>{const xe=Ne=>{var ve,Ye,Ve;const J=Ne.target;(ve=y.current)!=null&&ve.contains(J)||(Ye=E.current)!=null&&Ye.contains(J)||(Ve=M.current)!=null&&Ve.contains(J)||m(!1)};return document.addEventListener("mousedown",xe),()=>document.removeEventListener("mousedown",xe)},50);return()=>clearTimeout(oe)},[l]);const le=oe=>oe.split(" ").filter(Boolean).map(xe=>xe[0]).join("").toUpperCase().slice(0,2),Je=(oe,xe,Ne,J,ve)=>t.jsx(ve,{children:oe?t.jsx("img",{src:xe,alt:Ne}):le(`${Ne||""} ${J||""}`)}),ot=async oe=>{try{await R(oe),await U(),m(!1)}catch{}},ge=async oe=>{try{await O(oe),await U(),m(!1)}catch{}},lt=async oe=>{if(!f){h(!0);try{await Z(oe),await U(),d(!1)}catch{}finally{h(!1)}}},Ke=async oe=>{if(!f){h(!0);try{await L(oe),await U(),d(!1)}catch{}finally{h(!1)}}},ee=()=>{A.open(),m(!1)},ie=[...(H==null?void 0:H.signins)||[]].sort((oe,xe)=>{const Ne=oe.user.id===(q==null?void 0:q.id),J=xe.user.id===(q==null?void 0:q.id);return Ne===J?0:Ne?-1:1}),me=((ja=ie.find(oe=>oe.user.id===(q==null?void 0:q.id)))==null?void 0:ja.id)||"",Ze=((sa=(yt=Q==null?void 0:Q.roles)==null?void 0:yt[0])==null?void 0:sa.name)??null;return t.jsx(Re,{children:t.jsxs(J6,{children:[t.jsxs(Z0,{ref:y,onClick:()=>m(!l),children:[Je(q==null?void 0:q.has_profile_picture,q==null?void 0:q.profile_picture_url,q==null?void 0:q.first_name,q==null?void 0:q.last_name,X6),e&&t.jsx(ep,{children:`${(q==null?void 0:q.first_name)||""} ${(q==null?void 0:q.last_name)||""}`.trim()})]}),typeof window<"u"&&tn.createPortal(t.jsxs("div",{className:"wacht-root",style:i,children:[t.jsxs(H0,{ref:E,$position:F,$isOpen:l&&!(p&&c),$maxHeight:F==null?void 0:F.maxHeight,children:[t.jsx(tp,{children:t.jsxs(ap,{children:[Je(q==null?void 0:q.has_profile_picture,q==null?void 0:q.profile_picture_url,q==null?void 0:q.first_name,q==null?void 0:q.last_name,sp),t.jsxs(np,{children:[t.jsx(rp,{children:`${(q==null?void 0:q.first_name)||""} ${(q==null?void 0:q.last_name)||""}`.trim()}),t.jsx(ip,{children:(na=q==null?void 0:q.primary_email_address)==null?void 0:na.email})]})]})}),t.jsxs(up,{children:[ce&&t.jsxs(op,{$active:c,onClick:de,style:{marginBottom:8},children:[t.jsx(lp,{children:B?B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):(ra=B.name)==null?void 0:ra.charAt(0).toUpperCase():q!=null&&q.has_profile_picture?t.jsx("img",{src:q.profile_picture_url,alt:q.first_name}):le(`${(q==null?void 0:q.first_name)||""} ${(q==null?void 0:q.last_name)||""}`)}),t.jsx(cp,{children:(B==null?void 0:B.name)??"Personal account"}),Ze&&t.jsx(dp,{children:Ze})]}),t.jsxs(mp,{onClick:ee,children:[t.jsx(Aa,{}),t.jsx(pp,{children:"Manage account"}),t.jsx(hp,{children:"⌘,"})]})]}),t.jsx(Qi,{}),t.jsxs(fp,{children:[t.jsx(wp,{children:"Accounts"}),tt?ie.map(({user:oe,id:xe})=>{var J;const Ne=oe.id===(q==null?void 0:q.id);return t.jsxs(Fn,{$active:Ne,onClick:Ne?void 0:()=>ge(xe),children:[Ne?t.jsx(Tn,{children:t.jsx(Ge,{})}):t.jsx(gp,{}),t.jsx(In,{children:(J=oe.primary_email_address)==null?void 0:J.email}),Ne&&t.jsx(Ji,{children:"Current"})]},oe.id)}):q&&t.jsxs(Fn,{$active:!0,children:[t.jsx(Tn,{children:t.jsx(Ge,{})}),t.jsx(In,{children:(ia=q.primary_email_address)==null?void 0:ia.email}),t.jsx(Ji,{children:"Current"})]}),tt&&t.jsxs(Fn,{onClick:()=>{D(),m(!1)},children:[t.jsx(Tn,{style:{color:"var(--wa-text-muted)"},children:t.jsx(St,{})}),t.jsx(In,{style:{color:"var(--wa-text-muted)"},children:"Add account"})]})]}),t.jsx(Qi,{}),t.jsx(xp,{children:t.jsxs(vp,{onClick:()=>ot(me),children:[t.jsx(Ma,{}),"Sign out"]})})]}),t.jsxs(F0,{ref:M,$top:j.top,$left:j.left,$isOpen:l&&c,$maxHeight:j.maxHeight,children:[p&&t.jsxs(bp,{onClick:()=>d(!1),children:[t.jsx(rn,{size:13}),"Back"]}),(()=>{var _t;if(W)return null;const oe=Ee&&!!ae,xe=!!((_t=Q==null?void 0:Q.eligibility_restriction)!=null&&_t.type)&&Q.eligibility_restriction.type!=="none",Ne=!!B&&!xe&&Tr(Q),J=oe&&!xe&&Vr(re),ve=oe?g:"org",Ye=async()=>{if(ue){b("org");try{await ue(),await U(),d(!1)}catch{}finally{b(null)}}},Ve=async()=>{if(Me){b("ws");try{await Me(),d(!1)}catch{}finally{b(null)}}},jt=()=>{if(!oe)return null;const Be=ve==="org"?"ws":"org",wt=Be==="ws"?"Switch to workspace context":"Switch to organization context";return t.jsx(kp,{type:"button",onClick:()=>x(Be),title:wt,"aria-label":wt,children:t.jsx(Au,{size:12})})};return t.jsxs(_p,{children:[ve==="org"&&B&&t.jsxs(ro,{children:[jt(),t.jsx(io,{children:B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):le(B.name)}),t.jsx(oo,{children:t.jsx(lo,{children:B.name})}),t.jsxs(co,{children:[Ne&&t.jsx(Ts,{onClick:()=>{P.open(),m(!1)},title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Aa,{size:14})}),t.jsx(Ts,{$destructive:!0,onClick:Ye,disabled:w==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(Ma,{size:14})})]})]}),ve==="ws"&&oe&&t.jsxs(ro,{children:[jt(),t.jsx(io,{children:ae.image_url?t.jsx("img",{src:ae.image_url,alt:ae.name}):le(ae.name)}),t.jsx(oo,{children:t.jsx(lo,{children:ae.name})}),t.jsxs(co,{children:[J&&t.jsx(Ts,{onClick:()=>{$.open(),m(!1)},title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Aa,{size:14})}),t.jsx(Ts,{$destructive:!0,onClick:Ve,disabled:w==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(Ma,{size:14})})]})]})]})})(),t.jsxs(yp,{children:[t.jsxs(Xi,{$active:W,onClick:()=>{W||lt(void 0)},disabled:f,style:W?{cursor:"default"}:void 0,children:[t.jsx(to,{$personal:!0,children:q!=null&&q.has_profile_picture?t.jsx("img",{src:q.profile_picture_url,alt:q.first_name}):t.jsx(fs,{size:12})}),t.jsx(so,{children:"Personal account"}),W&&t.jsx(Vn,{children:t.jsx("span",{className:"sp-check",style:{display:"inline-flex"},children:t.jsx(zn,{size:13})})})]}),K.map(oe=>{var Ve,jt;const xe=oe.organization,Ne=xe.id===(B==null?void 0:B.id),J=k.has(xe.id),ve=Ee?G[xe.id]||[]:[],Ye=!!((Ve=oe.eligibility_restriction)!=null&&Ve.type)&&oe.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs(Xi,{$active:Ne,onClick:()=>{Ye||(Ee?z(xe.id):Ne||lt(xe.id))},disabled:f,style:Ye?{opacity:.55,cursor:"not-allowed"}:Ne&&!Ee?{cursor:"default"}:void 0,title:(jt=oe.eligibility_restriction)==null?void 0:jt.message,children:[t.jsx(to,{children:xe.image_url?t.jsx("img",{src:xe.image_url,alt:xe.name}):le(xe.name)}),t.jsx(so,{children:xe.name}),t.jsxs(Vn,{children:[Ye&&t.jsx(Ra,{size:12,color:"var(--wa-error)"}),Ne&&!Ee&&t.jsx(zn,{size:13}),Ee&&t.jsx(jp,{size:11,$open:J})]})]}),Ee&&J&&t.jsxs(t.Fragment,{children:[ve.map(_t=>{var oa,la;const Be=Ne&&(ae==null?void 0:ae.id)===_t.id,wt=_t,Gt=((oa=wt.eligibility_restriction)==null?void 0:oa.type)&&wt.eligibility_restriction.type!=="none";return t.jsxs(eo,{$active:Be,onClick:()=>{!Be&&!Gt&&Ke(_t.id)},disabled:f,style:Gt||Ye?{opacity:.55,cursor:"not-allowed"}:Be?{cursor:"default"}:void 0,title:(la=wt.eligibility_restriction)==null?void 0:la.message,children:[t.jsx(ao,{children:wt.image_url?t.jsx("img",{src:wt.image_url,alt:wt.name}):le(wt.name).charAt(0)}),t.jsx(no,{children:wt.name}),t.jsxs(Vn,{children:[Gt&&t.jsx(Ra,{size:12,color:"var(--wa-error)"}),Be&&t.jsx(zn,{size:12})]})]},_t.id)}),!Ye&&t.jsxs(eo,{onClick:()=>{C(xe.id),S.open()},disabled:f,children:[t.jsx(ao,{style:{background:"transparent",border:"1px dashed var(--wa-border-strong)"},children:t.jsx(St,{size:10})}),t.jsx(no,{children:"New workspace"})]})]})]},xe.id)})]}),(()=>{var Ye,Ve,jt;const oe=((we==null?void 0:we.length)??0)>0,xe=()=>Ie&&t.jsx(uo,{children:t.jsxs(mo,{onClick:()=>{a?(a(),m(!1)):T.open()},disabled:f,children:[t.jsx(po,{children:t.jsx(St,{size:12})}),"New organization"]})});if(!Ee||!oe)return xe();const Ne=!!((Ye=Q==null?void 0:Q.eligibility_restriction)!=null&&Ye.type)&&Q.eligibility_restriction.type!=="none",J=((jt=(Ve=we==null?void 0:we[0])==null?void 0:Ve.organization)==null?void 0:jt.id)??null,ve=B&&!Ne?B.id:J;return t.jsx(uo,{children:t.jsxs(mo,{onClick:()=>{C(ve),S.open()},disabled:f,children:[t.jsx(po,{children:t.jsx(St,{size:12})}),"New workspace"]})})})()]})]}),document.body),t.jsx(O0,{isOpen:A.isOpen,onClose:A.close}),ce&&t.jsxs(t.Fragment,{children:[t.jsx(Yc,{isOpen:T.isOpen,onClose:T.close}),t.jsx(t0,{isOpen:P.isOpen,onClose:P.close}),Ee&&t.jsxs(t.Fragment,{children:[t.jsx(Or,{isOpen:S.isOpen,onClose:()=>{S.close(),C(null)},organizationId:_||void 0}),t.jsx(Hr,{isOpen:$.isOpen,onClose:$.close})]})]})]})})};function T0({notification:e,onAction:a}){const[s,r]=o.useState(!1),i=c=>{c.target.closest("button")||(r(!s),e.is_read||a({type:"read",id:e.id}))},l=c=>{a({type:"custom",payload:c.payload})},m=c=>{const d=new Date(c),u=new Date().getTime()-d.getTime();if(u<6e4)return"Just now";const f=Math.floor(u/6e4);if(f<60)return`${f}m`;const h=Math.floor(f/60);if(h<24)return`${h}h`;const g=Math.floor(h/24);return g<7?`${g}d`:d.toLocaleDateString(void 0,{month:"short",day:"numeric"})};return t.jsxs("div",{className:"w-flex w-gap-3 w-notif-row",onClick:i,"data-unread":e.is_read?void 0:"",children:[t.jsxs("div",{className:"w-grow w-flex-col w-justify-center",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:2},children:[!e.is_read&&t.jsx("span",{className:"w-notif-dot"}),t.jsx("h4",{className:"w-sec w-truncate",style:{margin:0},children:e.title})]}),t.jsx("p",{className:`w-secsub${s?"":" w-truncate"}`,style:{margin:0,wordWrap:s?"break-word":void 0},children:e.body}),e.ctas&&e.ctas.length>0&&t.jsx("div",{className:"w-flex w-wrap w-gap-2",style:{marginTop:10},children:e.ctas.map((c,d)=>t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:()=>l(c),children:c.label},d))})]}),t.jsxs("div",{className:"w-flex-col w-items-end w-gap-2 w-none",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-1 w-notif-actions",children:[e.is_read&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"unread",id:e.id})},title:"Mark as unread",children:t.jsx(Pu,{size:14})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"star",id:e.id})},title:e.is_starred?"Unstar":"Star","data-on":e.is_starred?"":void 0,children:t.jsx(Wu,{size:14,fill:e.is_starred?"currentColor":"none"})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"archive",id:e.id})},title:e.is_archived?"Unarchive":"Archive",children:e.is_archived?t.jsx(Uo,{size:14}):t.jsx(zo,{size:14})})]}),t.jsx("span",{className:"w-secsub",style:{whiteSpace:"nowrap"},children:m(e.created_at)})]})]})}const I0=o.forwardRef(({scope:e="all",onAction:a,fullWidth:s,maxHeight:r,className:i},l)=>{const[m,c]=o.useState("inbox"),[d,p]=o.useState(!1),[u,f]=o.useState(!1),h=o.useRef(null),g={scope:e,limit:20,is_archived:m==="archive",is_starred:m==="starred",is_read:d?!1:void 0},{notifications:x,loading:w,error:b,hasMore:j,loadMore:v,markAsRead:k,markAsUnread:N,markAllAsRead:_,archiveAllRead:C,archiveNotification:y,starNotification:E}=$o(g);o.useEffect(()=>{if(!u)return;const T=P=>{h.current&&!h.current.contains(P.target)&&f(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[u]);const M=async T=>{switch(T.type){case"read":await k(T.id);break;case"unread":await N(T.id);break;case"archive":await y(T.id);break;case"star":await E(T.id);break;case"custom":a==null||a(T.payload);break}},F=()=>{_(),f(!1)},A=()=>{C(),f(!1)};return t.jsxs("div",{ref:l,className:`w-flex-col w-relative w-notif-panel${s?" w-notif-panel--fill":""}${i?` ${i}`:""}`,style:{maxHeight:r||"100%"},children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-none w-notif-head",children:[t.jsxs("div",{className:"w-tabs w-grow",children:[t.jsx("button",{className:`w-tab${m==="inbox"?" w-tab--active":""}`,onClick:()=>c("inbox"),children:"Inbox"}),t.jsx("button",{className:`w-tab${m==="archive"?" w-tab--active":""}`,onClick:()=>c("archive"),children:"Archive"}),t.jsx("button",{className:`w-tab${m==="starred"?" w-tab--active":""}`,onClick:()=>c("starred"),children:"Starred"})]}),t.jsxs("button",{className:"w-btn w-btn--icon w-none w-relative",onClick:()=>f(!u),title:"Options",children:[t.jsx(Zu,{size:16}),d&&t.jsx("span",{className:"w-notif-filter-dot"})]}),u&&t.jsxs("div",{ref:h,className:"w-menu w-notif-menu",children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{p(!d),f(!1)},children:[t.jsx(Hu,{})," Unread only",d&&t.jsx(Ge,{className:"w-menu-check"})]}),m==="inbox"&&t.jsxs("button",{className:"w-menu-item",onClick:F,children:[t.jsx(Lu,{})," Mark all as read"]}),t.jsxs("button",{className:"w-menu-item",onClick:A,children:[t.jsx(zo,{})," Archive all read"]})]})]}),t.jsx("div",{className:"w-grow w-notif-body",children:w?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):b?t.jsx(Nt,{icon:t.jsx(mi,{size:20,className:"w-text-error"}),title:"Failed to load notifications",description:b.message||"An unexpected error occurred."}):x.length===0?t.jsx(Nt,{icon:t.jsx(mi,{size:20}),title:"No notifications",description:"You're all caught up!"}):t.jsxs(t.Fragment,{children:[x.map(T=>t.jsx(T0,{notification:T,onAction:M},T.id)),j&&t.jsx("div",{className:"w-flex w-justify-center",style:{padding:12},children:t.jsx("button",{className:"w-btn w-btn--ghost w-btn--sm",onClick:v,children:"Load more"})})]})})]})}),V0=o.forwardRef(({position:e,scope:a,onAction:s,className:r},i)=>t.jsx("div",{ref:i,className:`w-card w-flex-col w-notif-pop${r?` ${r}`:""}`,style:{top:(e==null?void 0:e.top)!==void 0?e.top:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?e.bottom:void 0,left:(e==null?void 0:e.left)!==void 0?e.left:void 0,right:(e==null?void 0:e.right)!==void 0?e.right:void 0,maxHeight:e!=null&&e.maxHeight?e.maxHeight:"90vh"},children:t.jsx(I0,{scope:a,onAction:s,fullWidth:!0,maxHeight:e!=null&&e.maxHeight?`${e.maxHeight}px`:"100%"})}));function z0({className:e,showBadge:a=!0,scope:s="all",onAction:r}){const[i,l]=o.useState(!1),m=as(),c=o.useRef(null),d=o.useRef(null),p=o.useRef(null),{count:u,refetch:f}=Oo({scope:s}),h=async x=>{await f(),r==null||r(x.payload)},g=bt({triggerRef:p,isOpen:i,minWidth:Math.min(450,typeof window<"u"?window.innerWidth-32:300),defaultMaxHeight:550});return o.useEffect(()=>{if(!i)return;const x=setTimeout(()=>{const w=b=>{var v,k;const j=b.target;(v=c.current)!=null&&v.contains(j)||(k=d.current)!=null&&k.contains(j)||l(!1)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},50);return()=>{clearTimeout(x)}},[i]),t.jsx(Re,{children:t.jsxs("div",{ref:c,className:`w-inline w-relative${e?` ${e}`:""}`,children:[t.jsxs("button",{ref:p,className:"w-btn w-btn--icon w-notif-bell",onClick:()=>l(!i),"aria-label":u>0?`${u} unread notifications`:"Notifications",children:[t.jsx(Mu,{strokeWidth:1}),a&&u>0&&t.jsx("span",{className:"w-notif-badge","data-dot":u<=9?"":void 0,children:u>9?"9+":""})]}),typeof window<"u"&&i&&tn.createPortal(t.jsx("div",{className:"wacht-root",style:m,children:t.jsx(V0,{ref:d,position:g,scope:s,onAction:h,onClose:()=>l(!1)})}),document.body)]})})}const Cp=({showName:e=!0,showNotifications:a=!0})=>t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[a&&t.jsx(z0,{}),t.jsx(Wr,{showName:e})]}),Np=({children:e})=>{var r;const{session:a,loading:s}=it();return s||!((r=a.signins)!=null&&r.length)||!a.active_signin?null:t.jsx(t.Fragment,{children:e})},Sp=({children:e})=>{var r;const{loading:a,session:s}=it();return a||(r=s.signins)!=null&&r.length&&s.active_signin?null:t.jsx(t.Fragment,{children:e})},Ep=({onAccountSelect:e,showAddAccount:a=!0})=>{var _,C,y,E;const{session:s,loading:r,switchSignIn:i,signOut:l}=it(),{deployment:m}=je(),{navigateToSignIn:c,navigate:d}=kt(),[p,u]=o.useState(null),[f,h]=o.useState(null),g=s==null?void 0:s.active_signin,x=(s==null?void 0:s.signins)||[],w=((C=(_=m==null?void 0:m.auth_settings)==null?void 0:_.multi_session_support)==null?void 0:C.enabled)??!1,b=(y=m==null?void 0:m.ui_settings)==null?void 0:y.app_name;o.useEffect(()=>{r||x.length||c()},[r,x,c]);const j=M=>M.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2),v=async M=>{var F;h(M);try{if(await i(M),e)e(M),h(null);else{let A=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));if(A||(A=(F=m.ui_settings)==null?void 0:F.after_signin_redirect_url),A){let T;try{T=new URL(A)}catch{T=new URL(A,window.location.origin)}(m==null?void 0:m.mode)==="staging"&&T.searchParams.set("__dev_session__",xt(m.backend_host)??""),d(T.toString())}else h(null)}}catch{h(null)}},k=async(M,F)=>{M.stopPropagation(),u(F);try{await l(F)}catch{}finally{u(null)}},N=()=>{var F;let M=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));M||(M=(F=m.ui_settings)==null?void 0:F.after_signin_redirect_url),c(M)};return r?t.jsx(_s,{}):x.length?t.jsx(Re,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-sub",style:{fontSize:12.5},children:["Don't have an account?"," ",t.jsx(Et,{to:`${(E=m.ui_settings)==null?void 0:E.sign_up_page_url}${window.location.search}`,className:"w-link",children:"Sign up"})]}),children:[t.jsx(nt,{title:"Choose an account",sub:`Select an account to continue${b?` to ${b}`:""}`}),t.jsx("div",{className:"w-flex-col",children:x.map(({user:M,id:F})=>{var R,O;if(!M)return null;const A=F===(g==null?void 0:g.id),T=f===F,P=p===F,S=`${M.first_name||""} ${M.last_name||""}`.trim(),$=S||((R=M.primary_email_address)==null?void 0:R.email)||M.username||"User",H=((O=M.primary_email_address)==null?void 0:O.email)||M.username;return t.jsxs("button",{className:"w-acct","data-active":A?"":void 0,"data-busy":T?"":void 0,onClick:()=>v(F),children:[t.jsx("div",{className:"w-avatar",children:T?t.jsx(vt,{onAccent:!0}):M.has_profile_picture?t.jsx("img",{src:M.profile_picture_url,alt:S}):j($)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:$}),H&&H!==$&&t.jsx("div",{className:"w-secsub w-truncate",children:H})]}),A&&t.jsxs("span",{className:"w-pill w-pill--current",children:[t.jsx(Ge,{size:11,weight:"bold"}),"current"]}),t.jsx("span",{className:"w-kebab w-acct-out",role:"button","aria-disabled":P,title:"Sign out",onClick:Z=>k(Z,F),children:P?t.jsx(vt,{}):t.jsx(Ma,{size:15})})]},F)})}),a&&w&&t.jsx("div",{className:"w-acct-foot",children:t.jsxs("button",{className:"w-acct-add",onClick:N,children:[t.jsx(St,{size:15}),"Add another account"]})})]})}):null},Ap=()=>{const{navigateToSignIn:e}=kt();return o.useEffect(()=>{e()},[e]),null},Mp=()=>{const{navigateToSignUp:e}=kt();return o.useEffect(()=>{e()},[e]),null},Rp=()=>{var A,T;const{organizationMemberships:e,refetch:a,loading:s}=ga(),{workspaces:r}=xa(),{switchOrganization:i,switchWorkspace:l}=it(),{deployment:m}=je(),[c,d]=o.useState(null),[p,u]=o.useState("orgList"),[f,h]=o.useState(null),g=((m==null?void 0:m.b2b_settings.organizations_enabled)??!1)&&((m==null?void 0:m.b2b_settings.workspaces_enabled)??!1),x=(m==null?void 0:m.b2b_settings.allow_users_to_create_orgs)??!1,w=o.useRef(!1);o.useEffect(()=>{if(!(w.current||!e)){if(w.current=!0,e.length===0){u("createOrg");return}if(!g){u("orgList");return}if(!r||r.length===0){const P=e.find(S=>{var $,H;return!(($=S.eligibility_restriction)!=null&&$.type)||((H=S.eligibility_restriction)==null?void 0:H.type)==="none"});if(P){h(P.organization.id),u("createWorkspace");return}}u("orgList")}},[e,r,g]);const b=P=>P.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=async P=>{if(g){h(P.id),u("workspaceList");return}d(P.id);try{await i(P.id)}finally{d(null)}},v=async P=>{d(P.id);try{await l(P.id)}finally{d(null)}},k=async P=>{var $;await a();const S=(($=P==null?void 0:P.data)==null?void 0:$.organization)||(P==null?void 0:P.organization)||P;if(!g){u("orgList");return}S!=null&&S.id?(h(S.id),u("createWorkspace")):u("orgList")},N=async P=>{var $;const S=(P==null?void 0:P.id)??(($=P==null?void 0:P.workspace)==null?void 0:$.id);if(S){d(S);try{await l(S)}finally{d(null)}}},_=async()=>{h(null),u("orgList")},C=(A=e==null?void 0:e.find(P=>P.organization.id===f))==null?void 0:A.organization,y=f?r==null?void 0:r.filter(P=>P.organization.id===f):[];if(s)return null;if(p==="createOrg")return t.jsx(ze.Body,{style:{padding:0},children:t.jsx(pn,{onSuccess:k,onCancel:()=>u("orgList")})});if(p==="createWorkspace"&&f)return t.jsx(ze.Body,{style:{padding:0},children:t.jsx($r,{organizationId:f,onSuccess:N,onCancel:()=>u("workspaceList"),onCreateOrganization:()=>u("createOrg")})});const E=p==="workspaceList",M=E?"Select a workspace":"Select an organization",F=E?`Choose a workspace in ${(C==null?void 0:C.name)||""}`:`to continue to ${((T=m==null?void 0:m.ui_settings)==null?void 0:T.app_name)||"App"}`;return t.jsxs("div",{className:"w-split",children:[t.jsxs("div",{className:"w-split-aside w-flex-col w-justify-between w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx(Ar,{placement:"left"}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-title",children:M}),t.jsx("p",{className:"w-sub",children:F})]})]}),t.jsx(Wr,{showName:!0})]}),t.jsxs("div",{className:"w-split-main",children:[t.jsxs("div",{className:"w-grow w-flex-col",style:{overflow:"hidden",marginBottom:24},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:8},children:[E&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:_,"aria-label":"Go back",title:"Go back",children:t.jsx(rn,{})}),t.jsx("h2",{className:"w-sec",children:E?"Workspaces":"Your organizations"})]}),t.jsx("div",{className:"w-grow w-flex-col",style:{overflowY:"auto"},children:E?t.jsx(t.Fragment,{children:y&&y.length>0?y.map(P=>{var $,H,R;const S=(($=P.eligibility_restriction)==null?void 0:$.type)!=="none"&&((H=P.eligibility_restriction)==null?void 0:H.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!S&&v(P),disabled:c===P.id||S,title:S?(R=P.eligibility_restriction)==null?void 0:R.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:P.image_url?t.jsx("img",{src:P.image_url,alt:P.name}):b(P.name).charAt(0)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:P.name}),t.jsxs("div",{className:"w-secsub w-inline w-gap-1",children:[t.jsx(ds,{}),"Workspace"]})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[S&&t.jsx(Ra,{size:16,className:"w-text-error"}),t.jsx(Jt,{})]})]},P.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(ds,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No workspaces yet"}),t.jsxs("p",{children:["Create your first workspace for"," ",(C==null?void 0:C.name)||"this organization"]})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createWorkspace"),children:[t.jsx(St,{}),"Create workspace"]})})]})}):e&&e.length>0?e.map(P=>{var D,Y,B,Q,ue;const S=P.organization,$=r==null?void 0:r.filter(we=>we.organization.id===S.id),H=($==null?void 0:$.length)||0,R=S.member_count,O=((Y=(D=P.roles)==null?void 0:D[0])==null?void 0:Y.name)||"No role",Z=P.roles.length-1,L=Z>0?`${O.charAt(0).toUpperCase()+O.slice(1)} +${Z}`:O.charAt(0).toUpperCase()+O.slice(1),U=((B=P.eligibility_restriction)==null?void 0:B.type)!=="none"&&((Q=P.eligibility_restriction)==null?void 0:Q.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!U&&j(S),disabled:c===S.id||U,title:U?(ue=P.eligibility_restriction)==null?void 0:ue.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:S.image_url?t.jsx("img",{src:S.image_url,alt:S.name}):b(S.name)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:S.name}),t.jsx("div",{className:"w-secsub w-inline w-gap-1",children:g?t.jsxs(t.Fragment,{children:[t.jsx(ds,{}),H," ","workspace",H!==1?"s":""]}):t.jsxs(t.Fragment,{children:[t.jsx(hs,{}),L," •"," ",R," member",R!==1?"s":""]})})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[U&&t.jsx(Ra,{size:16,className:"w-text-error"}),t.jsx(Jt,{})]})]},S.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(hs,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No organizations yet"}),t.jsx("p",{children:x?"Create your first organization to get started":"You don't have access to any organizations yet"})]}),x&&t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createOrg"),children:[t.jsx(St,{}),"Create organization"]})})]})})]}),E&&f&&t.jsxs(se,{$outline:!0,onClick:()=>u("createWorkspace"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create workspace"]}),!E&&e&&e.length>0&&x&&t.jsxs(se,{$outline:!0,onClick:()=>u("createOrg"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create new organization"]})]})]})},Lp=({children:e})=>{var f,h,g,x;const{activeOrganization:a}=wa(),{activeWorkspace:s}=Ut(),{deployment:r}=je(),{loading:i,orgMembership:l,workspaceMembership:m}=Eo(),c=((r==null?void 0:r.b2b_settings.organizations_enabled)??!1)&&((r==null?void 0:r.b2b_settings.workspaces_enabled)??!1),d=((f=l==null?void 0:l.eligibility_restriction)==null?void 0:f.type)!=="none"&&((h=l==null?void 0:l.eligibility_restriction)==null?void 0:h.type)!==void 0,p=((g=m==null?void 0:m.eligibility_restriction)==null?void 0:g.type)!=="none"&&((x=m==null?void 0:m.eligibility_restriction)==null?void 0:x.type)!==void 0;return i?null:(d||p||!a?!1:c?s?(m==null?void 0:m.workspace.id)===s.id&&m.organization_id===a.id:!1:!0)?t.jsx(t.Fragment,{children:e}):t.jsx(Re,{children:t.jsx(ze,{isOpen:!0,children:t.jsx(ze.Overlay,{children:t.jsx(ze.Content,{className:"w-flex w-justify-center",style:{padding:0,width:900,maxWidth:"90vw"},children:t.jsx(Rp,{})})})})})},Pp=e=>{const a=e.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(i=>a.startsWith(i))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(i=>a.startsWith(i))},$p=e=>{const a=e.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(r=>a.startsWith(r))};exports.AcceptInvite=Hm;exports.AuthFormImage=Ar;exports.CreateOrganizationForm=pn;exports.CreateWorkspaceDialog=Or;exports.CreateWorkspaceForm=$r;exports.DefaultStylesProvider=Re;exports.DeploymentInitialized=S2;exports.DeploymentInitializing=E2;exports.DeploymentProvider=K0;exports.Dialog=ze;exports.DialogTrigger=Wm;exports.Dropdown=ks;exports.DropdownDivider=Dc;exports.DropdownItem=ta;exports.DropdownItems=Cs;exports.DropdownTrigger=Ns;exports.Form=Uc;exports.FormGroup=We;exports.Input=be;exports.Label=Te;exports.MagicLinkVerification=$m;exports.ManageAccount=$0;exports.ManageAccountDialog=O0;exports.ManageOrganization=e0;exports.ManageWorkspace=s0;exports.ManageWorkspaceDialog=Hr;exports.NavigateToSignIn=Ap;exports.NavigateToSignUp=Mp;exports.NavigationLink=Et;exports.NotificationBell=z0;exports.NotificationItem=T0;exports.NotificationPanel=I0;exports.NotificationPopover=V0;exports.OAuthProvider=fo;exports.ORG_ADMIN_PERMISSIONS=n0;exports.ORG_MANAGEMENT_PERMISSIONS=r0;exports.OTPInput=ba;exports.OrganizationSwitcher=l0;exports.PhoneNumberInput=js;exports.PhoneVerification=Oc;exports.ProfileCompletion=Hc;exports.RequireActiveTenancy=Lp;exports.SignInForm=Mm;exports.SignUpForm=jm;exports.SignedIn=Np;exports.SignedInAccounts=Ep;exports.SignedOut=Sp;exports.SimpleDialog=Um;exports.SocialCallback=Pm;exports.Spinner=_e;exports.Switch=Ha;exports.TwoFactorMethodSelector=$c;exports.TwoFactorVerification=Zc;exports.UserButton=Wr;exports.UserControls=Cp;exports.WORKSPACE_ADMIN_PERMISSIONS=i0;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=o0;exports.WaitlistForm=Lm;exports.canManageOrganization=Tr;exports.canManageWorkspace=Vr;exports.clearTokenCache=$t;exports.hasIncompleteProfile=Om;exports.hasOrgPermission=Fr;exports.hasWorkspacePermission=Ir;exports.isExternalUrl=Pp;exports.isOrgAdmin=F4;exports.isSafeUrl=$p;exports.isWorkspaceAdmin=T4;exports.redirectToProfileCompletion=Zm;exports.useActiveOrganization=wa;exports.useActiveTenancy=Eo;exports.useActiveWorkspace=Ut;exports.useActorMcpServers=Yd;exports.useActorProjectSearch=Fd;exports.useActorProjects=Hd;exports.useActorThreadSearch=Vd;exports.useAgentSession=Rd;exports.useAgentThread=zd;exports.useAgentThreadAssignments=Ud;exports.useAgentThreadConversation=Md;exports.useAgentThreadFilesystem=Dd;exports.useAgentThreadTaskGraphs=qd;exports.useApiAuthAppSession=j2;exports.useApiAuthAuditAnalytics=C2;exports.useApiAuthAuditLogs=k2;exports.useApiAuthAuditTimeseries=N2;exports.useApiAuthKeys=_2;exports.useClient=ye;exports.useCreateWebhookEndpoint=g2;exports.useDeployment=je;exports.useExternalAgentConnections=Qd;exports.useForgotPassword=Lo;exports.useInvitation=Io;exports.useMagicLinkVerification=Ro;exports.useNavigation=kt;exports.useNotificationStream=Po;exports.useNotificationUnreadCount=Oo;exports.useNotifications=$o;exports.useOrganizationList=Dt;exports.useOrganizationMemberships=ga;exports.useProjectTaskBoardItem=Gd;exports.useProjectTaskBoardItemComments=Kd;exports.useProjectTasks=Bd;exports.useProjectThreadFeed=Id;exports.useProjectThreads=Td;exports.useSession=it;exports.useSignIn=wo;exports.useSignUp=go;exports.useSocialCallback=Mo;exports.useThemeOverrideVars=as;exports.useUser=va;exports.useUserSignins=So;exports.useWaitlist=Ao;exports.useWebhookAnalytics=b2;exports.useWebhookAppSession=h2;exports.useWebhookDeliveries=v2;exports.useWebhookEndpoints=w2;exports.useWebhookEvents=x2;exports.useWebhookStats=f2;exports.useWebhookTimeseries=y2;exports.useWorkspaceList=xa;exports.useWorkspaceMemberships=an;Object.keys(Br).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Br[e]})});
119
119
  //# sourceMappingURL=index.cjs.js.map