@wacht/jsx 1.0.0-beta.52 → 1.0.0-beta.53

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
@@ -99,7 +99,7 @@ Read more about this at https://styled-components.com/docs/basics#react-native`)
99
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[$s]+=1);const J8='.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}',X8='.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, #6b3df5, #9277ff));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--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 16px;border-bottom:.5px solid var(--wa-border)}.w-notif-row[data-unread]{background:var(--wa-surface-subtle)}.w-notif-dot{width:8px;height:8px;border-radius:50%;background:var(--wa-primary);flex:none}.w-btn--icon[data-on]{color:var(--wa-warning)}.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{padding:12px 16px;border-bottom:.5px solid var(--wa-border)}.w-notif-body{overflow-y:auto;background:var(--wa-surface)}.w-notif-menu{position:absolute;top:48px;right:12px;width:200px;z-index:100000}.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}',em=Q8`
100
100
  ${J8}
101
101
  ${X8}
102
- `,tm={display:"contents"};function am(e){const a={};if(!e)return a;const s=(n,i)=>{if(i)for(const l in i){const m=i[l];typeof m=="string"&&m.trim()!==""&&(a[`--wa-ov-${n}-${l}`]=m)}};return s("light",e.light),s("dark",e.dark),a}function ts(){var s,n;const e=o.useContext(fr),a=(n=(s=e==null?void 0:e.deployment)==null?void 0:s.ui_settings)==null?void 0:n.theme_tokens;return o.useMemo(()=>am(a),[a])}const Si=o.createContext(!1),sm=o.memo(function(){return t.jsx(em,{})});function Pe({children:e,className:a,style:s,...n}){const i=o.useContext(Si),l=ts(),[m,c]=o.useState(!1);if(o.useEffect(()=>c(!0),[]),!m)return null;const d=t.jsx("div",{...n,className:a?`wacht-root ${a}`:"wacht-root",style:{...tm,...l,...s},children:e});return i?d:t.jsxs(Si.Provider,{value:!0,children:[t.jsx(sm,{}),d]})}function va({length:e=6,onComplete:a,onResend:s,error:n,isSubmitting:i=!1}){const[l,m]=o.useState(new Array(e).fill("")),[c,d]=o.useState(60),[p,u]=o.useState(!1),h=o.useRef([]),f=o.useCallback(()=>{const j=setInterval(()=>{d(v=>v<=1?(u(!0),clearInterval(j),0):v-1)},1e3);return j},[]);o.useEffect(()=>{const j=f();return()=>clearInterval(j)},[f]);const g=async()=>{var j;!p||i||!s||(await s(),u(!1),d(60),m(new Array(e).fill("")),(j=h.current[0])==null||j.focus(),f())},x=(j,v)=>{var C;if(i)return;const _=j.value,N=[...l];N[v]=_.replace(/[^0-9]/g,""),m(N);const k=N.join("");k.length===e&&a(k),_&&v<e-1&&((C=h.current[v+1])==null||C.focus())},w=(j,v)=>{var _;i||j.key==="Backspace"&&!l[v]&&v>0&&((_=h.current[v-1])==null||_.focus())},b=(j,v)=>{var C,y;if(i)return;j.preventDefault();const _=j.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!_.length)return;const N=[...l];for(let E=0;E<_.length&&v+E<e;E++)N[v+E]=_[E];if(v===0&&_.length===e)for(let E=0;E<e;E++)N[E]=_[E];m(N);const k=N.join("");if(k.length===e)a(k),(C=h.current[e-1])==null||C.focus();else{const E=N.findIndex((M,F)=>F>=v&&!M);E!==-1&&((y=h.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":n?"":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:_=>x(_.target,v),onKeyDown:_=>w(_,v),onPaste:_=>b(_,v),ref:_=>{h.current[v]=_},disabled:i,autoFocus:v===0},v))}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[n&&t.jsx("span",{className:"w-input-err",children:n}),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 bc=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"})]}),yc=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"})]}),jc=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"})}),nm=()=>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"})}),_c=()=>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"})}),kc=()=>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"})]}),rm=()=>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"})}),Cc=()=>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"}})]}),im={google_oauth:{label:"Continue with Google",icon:t.jsx(yc,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(bc,{})},x_oauth:{label:"Continue with X",icon:t.jsx(jc,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(nm,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(_c,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(kc,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(rm,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(Cc,{})}},Nr=({connections:e,callback:a})=>{const s=e.map(n=>({connection:n,config:im[n.provider]})).filter(n=>n.config);if(!s.length)return null;if(s.length>3){const n=Math.min(s.length,4);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${n}, 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:n,config:i})=>t.jsxs("button",{type:"button",className:"w-social",onClick:()=>a(n),children:[i.icon,t.jsx("span",{className:"w-social-label",children:i.label})]},n.provider))})},St=({to:e,replace:a,children:s,...n})=>{const{navigate:i}=_t(),l=o.useCallback(m=>{m.preventDefault(),i(e,{replace:a})},[e,a,i]);return t.jsx("a",{href:e||void 0,onClick:l,...n,children:s})},qt=o.forwardRef(({onFocus:e,readOnly:a,...s},n)=>{const[i,l]=o.useState(!1);return t.jsx("input",{ref:n,...s,readOnly:a||!i,onFocus:m=>{i||l(!0),e==null||e(m)}})});qt.displayName="NoPrefillInput";const Gs=[{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:"🇿🇼"}],ys=({value:e,onChange:a,error:s,countryCode:n,setCountryCode:i})=>{const[l,m]=o.useState(!1),[c,d]=o.useState(Gs.find(x=>x.code===n)||Gs[0]),p=o.useRef(null),[u,h]=o.useState(""),f=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=Gs.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(Dt,{weight:"bold"})]}),l&&t.jsxs("div",{className:"w-country-pop",children:[t.jsxs("div",{className:"w-country-search",children:[t.jsx(Cl,{}),t.jsx("input",{type:"text",placeholder:"Search country…",value:u,onChange:x=>h(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=f.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:f,value:e,onChange:a,placeholder:"Phone number","aria-invalid":!!s,pattern:"^\\d{7,15}$"})]})};function Sr({placement:e="center"}){var m;const{deployment:a}=ke(),[s,n]=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:()=>n(!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 st({title:e,sub:a,children:s}){return t.jsxs("div",{className:"w-auth-head",children:[t.jsx(Sr,{}),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 gt({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 js(){return t.jsx(Pe,{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 om(e){const a=e.indexOf(":");return a>=0?e.slice(0,a):e}function lm(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 cm(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 dm(e,a){return!e||!a?!1:e===a?!0:e.endsWith(`.${a}`)}function um(e,a){if(!a)return!1;const s=cm(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 n=lm(om(e.frontend_host));return n?dm(s.hostname.toLowerCase(),n):!1}function ft(e,a){return a&&um(e,a)?a:null}function mm(){var B,Q,ue,we,se,te,oe,Ee,K,Ge,Ie,Ye,Ae,ce,D,G;const{loading:e,signUp:a,signupAttempt:s,discardSignupAttempt:n}=ho(),{signIn:i}=ls("oauth"),{deployment:l}=ke(),{navigate:m}=_t(),{session:c,refetch:d,loading:p}=rt(),[u,h]=o.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[f,g]=o.useState({}),[x,w]=o.useState(!1),[b,j]=o.useState(void 0),[v,_]=o.useState(null),[N,k]=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 q;if(!p&&(c!=null&&c.active_signin)&&!F&&!C){y(!0);let V=ft(l,new URLSearchParams(window.location.search).get("redirect_uri"));V||(V=((q=l==null?void 0:l.ui_settings)==null?void 0:q.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&&(k(V),a.validateDeploymentInvitation(V).then(z=>{_(z),z.valid&&h(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,I]=o.useState(!1),[$,S]=o.useState(""),Z=q=>{let{name:V,value:de}=q.target;V==="phone_number"?de=de.replace(/[^0-9-]/g,""):V==="email"&&(de=de.toLowerCase()),h(z=>({...z,[V]:de})),g(z=>({...z,[V]:""}))},P=()=>{h({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),g({}),I(!1),S(""),n()},L=async q=>{if(q.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}$/,it=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(R!=null&&R.first_name.enabled&&(R!=null&&R.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")),R!=null&&R.last_name.enabled&&(R!=null&&R.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")),R!=null&&R.username.enabled&&(R!=null&&R.username.required&&!u.username?V.username="Username is required":u.username&&!z.test(u.username)&&(V.username="Username must be 3-20 characters")),R!=null&&R.email_address.enabled&&(R!=null&&R.email_address.required&&!u.email?V.email="Email address is required":u.email&&!le.test(u.email)&&(V.email="Invalid email address")),R!=null&&R.phone_number.enabled&&(R!=null&&R.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")),R!=null&&R.password.enabled&&(u.password?it.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)}}},H=async q=>{if(!(e||x)){w(!0);try{const V=new URLSearchParams(window.location.search),de=ft(l,V.get("redirect_uri"))||void 0,{data:z}=await i.create({provider:q.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)}}},O=(l==null?void 0:l.social_connections.filter(q=>q.enabled))||[],R=l==null?void 0:l.auth_settings,U=!!((se=R==null?void 0:R.first_name)!=null&&se.enabled&&((te=R==null?void 0:R.last_name)!=null&&te.enabled)),W=async q=>{var de;if(q.preventDefault(),e||x)return;w(!0);const V={};if(!$){V.otp="OTP code is required",g(V),w(!1);return}g(V);try{const z=await a.completeVerification($);"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 q;if(s){if(s.completed){let V=ft(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(V||(V=((q=l==null?void 0:l.ui_settings)==null?void 0:q.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__",wt(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}I(!0)}}},[s,a,A,l,c,m]),p||C)return t.jsx(js,{});const Y=((oe=l==null?void 0:l.ui_settings)==null?void 0:oe.app_name)||"App";if(E)return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx(St,{className:"w-link",to:(Ee=l==null?void 0:l.ui_settings)!=null&&Ee.sign_in_page_url?`${l.ui_settings.sign_in_page_url}?help=true`:"#",children:"Get help"})]}),children:[t.jsx(st,{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 q=(s==null?void 0:s.current_step)==="verify_phone";return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{className:"w-link",to:((K=l==null?void 0:l.ui_settings)==null?void 0:K.support_page_url)||"#",children:"Get help"})]}),children:[t.jsx(st,{title:q?"Check your phone":"Enter the code",sub:q?"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:P,children:[t.jsx(Al,{weight:"bold"}),q?`+${u.phone_number}`:u.email]})}),t.jsxs("form",{onSubmit:W,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(va,{onComplete:async V=>{S(V)},onResend:async()=>{const V=q?"phone_otp":"email_otp";await a.prepareVerification({strategy:V})},error:f.otp,isSubmitting:x}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!$,children:x&&$?t.jsx(gt,{size:15,onAccent:!0}):`Continue to ${Y}`})]})]})})}return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Already have an account?"," ",t.jsx(St,{className:"w-link",to:`${((Ge=l==null?void 0:l.ui_settings)==null?void 0:Ge.sign_in_page_url)??""}${window.location.search}`,children:"Sign in"})]}),children:[t.jsx(st,{title:"Create your account",sub:v!=null&&v.valid?"You've been invited — complete your registration below.":"Get started in a few seconds."}),O.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Nr,{connections:O,callback:H}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})})]}),t.jsxs("form",{onSubmit:L,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[(((Ie=R==null?void 0:R.first_name)==null?void 0:Ie.enabled)||((Ye=R==null?void 0:R.last_name)==null?void 0:Ye.enabled))&&t.jsxs("div",{className:U?"w-grid-2":"",children:[((Ae=R==null?void 0:R.first_name)==null?void 0:Ae.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["First name",((ce=R==null?void 0:R.first_name)==null?void 0:ce.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{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:Z,placeholder:"Jane","aria-invalid":!!f.first_name,pattern:"^[a-zA-Z]{3,30}$"}),f.first_name&&t.jsx("span",{className:"w-input-err",children:f.first_name})]}),((D=R==null?void 0:R.last_name)==null?void 0:D.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Last name",((G=R==null?void 0:R.last_name)==null?void 0:G.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{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:Z,placeholder:"Doe","aria-invalid":!!f.last_name,pattern:"^[a-zA-Z]{3,30}$"}),f.last_name&&t.jsx("span",{className:"w-input-err",children:f.last_name})]})]}),(R==null?void 0:R.username.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Username",R.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",autoComplete:"username",minLength:3,maxLength:20,value:u.username,onChange:Z,placeholder:"yourname","aria-invalid":!!f.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),f.username&&t.jsx("span",{className:"w-input-err",children:f.username})]}),(R==null?void 0:R.email_address.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Email address",R.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",maxLength:320,value:u.email,onChange:Z,placeholder:"you@company.com","aria-invalid":!!f.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,}$"}),f.email&&t.jsx("span",{className:"w-input-err",children:f.email})]}),(R==null?void 0:R.phone_number.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Phone number",R.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(ys,{value:u.phone_number,onChange:Z,error:f.phone_number,countryCode:b,setCountryCode:j}),f.phone_number&&t.jsx("span",{className:"w-input-err",children:f.phone_number})]}),(R==null?void 0:R.password.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Password",R.password.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"new-password",value:u.password,onChange:Z,placeholder:"Create a password","aria-invalid":!!f.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"}),f.password&&t.jsx("span",{className:"w-input-err",children:f.password})]}),f.submit&&t.jsx("span",{className:"w-input-err",children:f.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e,children:x?t.jsx(gt,{size:15,onAccent:!0}):"Continue"}),(()=>{var de,z;const q=(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!q&&!V?null:t.jsxs("p",{className:"w-fineprint",children:["By continuing you agree to our"," ",q&&t.jsx(St,{className:"w-link w-link--muted",to:q,children:"Terms of Service"}),q&&V&&" and ",V&&t.jsx(St,{className:"w-link w-link--muted",to:V,children:"Privacy Policy"}),"."]})})()]})]})})}function Nc({icon:e,label:a,description:s,onClick:n,disabled:i,type:l="button"}){return t.jsxs("button",{type:l,className:"w-method",onClick:n,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(Qt,{})})]})}const Sc=o.createContext(void 0);function Ec(){const e=o.useContext(Sc);if(!e)throw new Error("useSignIn must be used within a SignInProvider");return e}function pm({children:e}){var j;const{deployment:a}=ke(),[s,n]=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),[h,f]=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 _;const v=(_=a==null?void 0:a.auth_settings)==null?void 0:_.first_factor;!i.current&&v&&(n(v),i.current=!0)},[(j=a==null?void 0:a.auth_settings)==null?void 0:j.first_factor]),t.jsx(Sc.Provider,{value:{email:l,showOtherOptions:c,showForgotPassword:p,otpSent:h,setFirstFactor:n,setEmail:m,setShowOtherOptions:d,setShowForgotPassword:u,setOtpSent:f,enabledSocialsProviders:w,authSettings:b,firstFactor:s,signInStep:g,setSignInStep:x},children:e})}const hm=[{key:"email_magic_link",icon:t.jsx(Ru,{}),label:"Magic link",description:"We'll email you a one-click sign-in link"},{key:"email_password",icon:t.jsx(Mu,{}),label:"Email and password",description:"Sign in with your email and password"},{key:"email_otp",icon:t.jsx(xl,{}),label:"Email one-time code",description:"We'll send a verification code to your email"},{key:"phone_otp",icon:t.jsx(Nu,{}),label:"Phone number",description:"We'll send a verification code via SMS"},{key:"username_password",icon:t.jsx(hs,{}),label:"Username and password",description:"Sign in with your username and password"}];function Ac(){const{deployment:e}=ke(),{signIn:a}=ls("oauth"),{setFirstFactor:s,firstFactor:n,setShowOtherOptions:i,setSignInStep:l}=Ec(),[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)}}},h=hm.filter(x=>{if(x.key===n)return!1;const w=d==null?void 0:d.auth_factors_enabled;return w?w[x.key]:!1}),f=p.length>0,g=h.length>0;return t.jsxs(t.Fragment,{children:[f&&t.jsx(Nr,{connections:p,callback:u}),f&&g&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"or"})}),g&&t.jsx("div",{className:"w-method-stack",children:h.map(x=>t.jsx(Nc,{icon:x.icon,label:x.label,description:x.description,onClick:()=>{s(x.key),l("identifier"),i(!1)}},x.key))})]})}function fm({onBack:e}){var F;const{deployment:a}=ke(),{navigate:s}=_t(),[n,i]=o.useState("start"),[l,m]=o.useState(""),[c,d]=o.useState(""),[p,u]=o.useState(""),[h,f]=o.useState(""),[g,x]=o.useState(""),{forgotPassword:w,verifyOtp:b,resetPassword:j}=Ao(),[v,_]=o.useState(!1),[N,k]=o.useState(null),C=async A=>{if(A.preventDefault(),!!l){_(!0),k(null);try{await w(l),i("otp")}catch(I){k(I)}finally{_(!1)}}},y=async A=>{if(A.preventDefault(),c.length===6){_(!0),k(null);try{const I=await b(l,c);I.data&&(u(I.data.token),i("reset"))}catch(I){k(I)}finally{_(!1)}}},E=async A=>{var I,$;if(A.preventDefault(),h===g&&!(h.length<8)){_(!0),k(null);try{const S=await j(p,h);if(S.data){const Z=S.data,P=Z.signin_attempts&&Z.signin_attempts.length>0?Z.signin_attempts[Z.signin_attempts.length-1]:null;if(P&&!P.completed){const L=(I=a==null?void 0:a.ui_settings)==null?void 0:I.sign_in_page_url;if(L){const H=new URL(L,window.location.origin);H.searchParams.set("signin_attempt_id",P.id),s(H.toString())}else e()}else{const L=(($=a==null?void 0:a.ui_settings)==null?void 0:$.after_signin_redirect_url)||"/";s(L)}}}catch(S){k(S)}finally{_(!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(Pe,{children:[n==="start"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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(Ac,{}),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"})]})]}),n==="email"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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(gt,{size:15,onAccent:!0}):"Send code"})]})]}),n==="otp"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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(va,{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(gt,{size:15,onAccent:!0}):"Verify"})]})]}),n==="reset"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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:h,onChange:A=>f(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(gt,{size:15,onAccent:!0}):"Reset password"})]})]})]})}function wm({onBack:e}){var n;const{deployment:a}=ke(),s=(n=a==null?void 0:a.ui_settings)==null?void 0:n.app_name;return t.jsx(Pe,{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(st,{title:"All sign-in methods",sub:`Choose another way to sign in to ${s||"your account"}`}),t.jsx(Ac,{})]})})}function Mc({methods:e,onSelectMethod:a,onBack:s}){return t.jsx(Pe,{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(st,{title:"Two-factor authentication",sub:"Choose how you'd like to verify your identity"}),t.jsx("div",{className:"w-method-stack",children:e.map(n=>t.jsx(Nc,{icon:n.icon,label:n.name,description:n.phoneNumber?`${n.description} ${n.phoneNumber}`:n.description,onClick:()=>a(n.id),disabled:!n.available},n.id))})]})})}function Rc({onVerify:e,onBack:a,loading:s}){const[n,i]=o.useState(""),[l,m]=o.useState(""),c=p=>{if(p.preventDefault(),n.length!==4){m("Please enter the last 4 digits of your phone number");return}e(n)},d=p=>{const u=p.target.value.replace(/\D/g,"").slice(0,4);i(u),m("")};return t.jsx(Pe,{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(st,{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:n,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||n.length!==4,children:s?t.jsx(gt,{onAccent:!0}):"Send code"})]})]})})}const gm=()=>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"})}),xm=()=>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"})]}),vm=()=>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 Lc({onBack:e,attempt:a,completeVerification:s,prepareVerification:n}){const{deployment:i}=ke(),[l,m]=o.useState(""),[c,d]=o.useState({}),[p,u]=o.useState(!1),[h,f]=o.useState(null),[g,x]=o.useState(!0),[w,b]=o.useState(!1),[j,v]=o.useState(""),[_,N]=o.useState(!1),{navigate:k}=_t(),C=(a==null?void 0:a.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(gm,{}),available:C.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(xm,{}),available:C.includes("phone_otp"),phoneNumber:j},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(vm,{}),available:C.includes("backup_code")}].filter($=>$.available),E=async $=>{f($),x(!1),$==="phone_otp"&&b(!0)},M=async $=>{var S,Z;if(a){u(!0);try{const P=await n({strategy:"phone_otp",lastDigits:$});P&&"data"in P&&((S=P.data)!=null&&S.otp_sent)?((Z=P.data)!=null&&Z.masked_phone&&v(P.data.masked_phone),b(!1)):d({phone:"Phone number verification failed"})}catch(P){d({phone:P.message})}finally{u(!1)}}},F=async($,S)=>{if($.preventDefault(),p)return;const Z=S||l,P={};if(Z?h==="authenticator"&&Z.length!==6?P.code="Authentication code must be 6 digits":h==="phone_otp"&&Z.length!==6&&(P.code="SMS code must be 6 digits"):P.code="Verification code is required",d(P),!(Object.keys(P).length>0)){u(!0);try{await s(Z)}catch(L){d({submit:L.message})}finally{u(!1)}}},A=$=>{let S=$.target.value;h!=="backup_code"&&(S=S.replace(/\D/g,"").slice(0,6)),m(S),d(Z=>({...Z,code:""}))};if(o.useEffect(()=>{var $;if(a.completed){N(!0);let S=ft(i,new URLSearchParams(window.location.search).get("redirect_uri"));if(S||(S=(($=i==null?void 0:i.ui_settings)==null?void 0:$.after_signin_redirect_url)||null),!S&&(i!=null&&i.frontend_host)&&(S=`https://${i.frontend_host}`),S){let Z;try{Z=new URL(S)}catch{Z=new URL(S,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&Z.searchParams.set("__dev_session__",wt(i.backend_host)||""),k(Z.toString())}return}},[a,i]),_)return t.jsx(js,{});if(g)return y.length===0?t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(st,{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(Mc,{methods:y,onSelectMethod:E,onBack:e});if(w&&h==="phone_otp")return t.jsx(Rc,{onVerify:M,onBack:()=>{b(!1),x(!0),f(null)},loading:p});const I=h==="authenticator"?"Enter the 6-digit code from your authenticator app":h==="phone_otp"?`Enter the 6-digit code sent to your phone ${j}`:"Enter one of your backup codes";return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(st,{title:"Two-factor authentication",sub:I}),t.jsxs("form",{onSubmit:F,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[h==="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(va,{onComplete:async $=>{if(m($),h!=="backup_code"){const S=new Event("submit",{bubbles:!0,cancelable:!0});await F(S,$)}},onResend:h==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:j.slice(-4)})}catch($){d({submit:$.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(gt,{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),f(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 Pc({attempt:e,onBack:a,completeProfile:s,completeVerification:n,prepareVerification:i}){var O,R,U,W,Y,B,Q,ue,we;const{deployment:l}=ke(),{navigate:m}=_t(),[c,d]=o.useState({}),[p,u]=o.useState({}),[h,f]=o.useState("US"),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(null),[_,N]=o.useState(!1),k=j,C=w,y=()=>{var te;N(!0);let se=ft(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(se||(se=((te=l==null?void 0:l.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!se&&(l!=null&&l.frontend_host)&&(se=`https://${l.frontend_host}`),se){let oe;try{oe=new URL(se)}catch{oe=new URL(se,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&oe.searchParams.set("__dev_session__",wt(l.backend_host)||""),m(oe.toString())}},E=async se=>{b(!0),v(null);try{await s(se)&&y()}catch(te){const oe=te;throw v(oe),oe}finally{b(!1)}},M=async se=>{b(!0),v(null);try{return await n(se)&&y(),!0}catch(te){return v(te),!1}finally{b(!1)}};if(_||!e)return t.jsx(js,{});const F=e.missing_fields||[],A=l==null?void 0:l.auth_settings,I=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||g,$=se=>{const{name:te,value:oe}=se.target;d(Ee=>({...Ee,[te]:oe})),p[te]&&u(Ee=>({...Ee,[te]:""}))},S=()=>{const se={};return F.forEach(te=>{var K,Ge,Ie,Ye,Ae;const oe=c[te];let Ee=!1;switch(te){case"first_name":Ee=((K=A==null?void 0:A.first_name)==null?void 0:K.enabled)||!1;break;case"last_name":Ee=((Ge=A==null?void 0:A.last_name)==null?void 0:Ge.enabled)||!1;break;case"username":Ee=((Ie=A==null?void 0:A.username)==null?void 0:Ie.enabled)||!1;break;case"phone_number":Ee=((Ye=A==null?void 0:A.phone_number)==null?void 0:Ye.enabled)||!1;break;case"email_address":Ee=((Ae=A==null?void 0:A.email_address)==null?void 0:Ae.enabled)||!1;break;default:Ee=!0}if(Ee&&(!oe||oe.trim()==="")){const ce=te.replace("_"," ").replace(/\b\w/g,D=>D.toUpperCase());se[te]=`${ce} is required`}}),c.username&&F.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(c.username)||(se.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)||(se.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)||(se.email_address="Please enter a valid email address")),u(se),Object.keys(se).length===0},Z=async se=>{if(se.preventDefault(),!S())return;const te={...c};c.phone_number&&h&&(te.phone_country_code=h),await E(te)},P=se=>{const te=se.target.value;d(oe=>({...oe,phone_number:te})),p.phone_number&&u(oe=>({...oe,phone_number:""}))},L=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{to:(l==null?void 0:l.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]});if(I){const se=e.current_step==="verify_phone_otp"?"Verify your phone number":"Verify your email",te=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",oe=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx(Pe,{children:t.jsxs(et,{footer:L,children:[t.jsx(st,{title:se,sub:te}),t.jsxs("form",{onSubmit:Ee=>Ee.preventDefault(),noValidate:!0,style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsx(va,{onComplete:M,onResend:async()=>{await i({strategy:oe})},error:k==null?void 0:k.message,isSubmitting:C}),k&&t.jsx("span",{className:"w-input-err",children:k.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 H=!!((O=A==null?void 0:A.first_name)!=null&&O.enabled&&((R=A==null?void 0:A.last_name)!=null&&R.enabled)&&F.includes("first_name")&&F.includes("last_name"));return t.jsx(Pe,{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"})}):L,children:[t.jsx(st,{title:"Complete your profile",sub:"Please provide the following information to continue"}),t.jsxs("form",{onSubmit:Z,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)||((W=A==null?void 0:A.last_name)==null?void 0:W.enabled))&&t.jsxs("div",{className:H?"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:$,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:$,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:$,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(ys,{value:c.phone_number||"",onChange:P,error:p.phone_number,countryCode:h,setCountryCode:f}),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:$,placeholder:"Enter your email address",disabled:C,autoComplete:"email"}),p.email_address&&t.jsx("span",{className:"w-input-err",children:p.email_address})]}),k&&t.jsx("span",{className:"w-input-err",children:k.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:C,children:C?t.jsx(gt,{onAccent:!0}):"Continue"})]})]})})}function $c({onComplete:e,onSkip:a}){var u;const[s,n]=o.useState(!1),[i,l]=o.useState(null),{registerPasskey:m}=xa(),{deployment:c}=ke(),d=async()=>{n(!0),l(null);try{await m(),e==null||e()}catch(h){l(h instanceof Error?h.message:"Failed to register passkey")}finally{n(!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(ar,{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(gt,{size:15,onAccent:!0}),"Registering…"]}):t.jsxs(t.Fragment,{children:[t.jsx(ar,{}),"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 bm(){return t.jsx(pm,{children:t.jsx(ym,{})})}function ym(){var Wt,ba,ya,bt,aa,sa,na,ra,ie,xe,Ne,J,ve,qe,Ve,yt,jt,We,ht,Bt,ia,oa,la;const{deployment:e}=ke(),{navigate:a}=_t(),{session:s,loading:n,refetch:i,exchangeTicket:l,switchSignIn:m}=rt(),c=((ba=(Wt=e==null?void 0:e.auth_settings)==null?void 0:Wt.multi_session_support)==null?void 0:ba.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:u,showForgotPassword:h,setShowForgotPassword:f,showOtherOptions:g,setShowOtherOptions:x,enabledSocialsProviders:w,firstFactor:b,setFirstFactor:j,signInStep:v,setSignInStep:_}=Ec(),{loading:N,signIn:k,signinAttempt:C,discardSignInAttempt:y,setSignInAttempt:E}=ls("generic"),{signIn:M}=ls("oauth"),{signIn:F}=ls("passkey"),[A,I]=o.useState({email:"",username:"",password:"",phone:""}),[$,S]=o.useState({}),[Z,P]=o.useState(!1),[L,H]=o.useState(""),[O,R]=o.useState("US"),[U,W]=o.useState(!1),[Y,B]=o.useState(null),[Q,ue]=o.useState(!1),[we,se]=o.useState(!1),[te,oe]=o.useState(!1),[Ee,K]=o.useState(60),[Ge,Ie]=o.useState(!1),[Ye,Ae]=o.useState(null),ce=[...(s==null?void 0:s.signins)||[]].sort((ee,ae)=>{var pe,Oe;return ee.id===((pe=s==null?void 0:s.active_signin)==null?void 0:pe.id)?-1:ae.id===((Oe=s==null?void 0:s.active_signin)==null?void 0:Oe.id)?1:0});o.useEffect(()=>{const ee=new URLSearchParams(window.location.search),ae=ee.get("error"),pe=ee.get("error_description");if(ae==="access_denied"&&pe){B(pe),ee.delete("error"),ee.delete("error_description");const Oe=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Oe)}},[]),o.useEffect(()=>{if(b!=="email_magic_link"||!p)return;K(60),Ie(!1);const ee=setInterval(()=>{K(ae=>ae<=1?(Ie(!0),clearInterval(ee),0):ae-1)},1e3);return()=>clearInterval(ee)},[b,p]),o.useEffect(()=>{var ee,ae,pe,Oe;if(!n&&(s!=null&&s.active_signin)&&!c&&!U&&!Q){let Re=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));Re||(Re=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!Re&&(e!=null&&e.frontend_host)&&(Re=`https://${e.frontend_host}`);const ct=(ae=e==null?void 0:e.auth_settings)==null?void 0:ae.passkey;(ct==null?void 0:ct.enabled)&&(ct==null?void 0:ct.prompt_registration_on_auth)&&!((Oe=(pe=s.active_signin)==null?void 0:pe.user)!=null&&Oe.has_passkeys)?(Ae(Re),ue(!0)):Re&&(W(!0),a(Re))}},[s,n,c,e,a,U]);const D=ee=>{let{name:ae,value:pe}=ee.target;ae==="phone"?pe=pe.replace(/[^0-9]/g,""):ae==="email"&&(d(pe),pe=pe.toLowerCase()),I(Oe=>({...Oe,[ae]:pe})),S(Oe=>({...Oe,[ae]:""}))},G=()=>{I({email:"",username:"",password:"",phone:""}),S({}),R("US"),_("identifier")},q=async ee=>{if(!ee){S({email:"Email address is required"});return}P(!0),S({});try{const ae=await k.identify(ee);if(ae.strategy==="sso"&&ae.connection_id){const pe=new URLSearchParams(window.location.search),Oe=ft(e,pe.get("redirect_uri"))||void 0,Re=await k.initEnterpriseSso(ae.connection_id,Oe);if(Re&&Re.sso_url){W(!0),window.location.href=Re.sso_url;return}}else if(ae.strategy==="social"&&ae.provider){const pe=w.find(Oe=>Oe.provider===ae.provider);if(pe){const Oe=new URLSearchParams(window.location.search),Re=ft(e,Oe.get("redirect_uri"))||void 0,{data:ct}=await M.create({provider:pe.provider,redirectUri:Re});if(ct&&typeof ct=="object"&&"oauth_url"in ct){W(!0),window.location.href=ct.oauth_url;return}}else _("password")}else _("password")}catch(ae){S({submit:ae.message})}finally{U||P(!1)}},V=async ee=>{if(ee.preventDefault(),N||Z)return;y();const ae={};if(v==="identifier"&&b==="email_password"){if(!A.email){S({email:"Email address is required"});return}await q(A.email);return}if(v==="identifier"&&b==="username_password"){if(!A.username){S({username:"Username is required"});return}S({}),_("password");return}if(b==="email_password"?(A.email||(ae.email="Email address is required"),A.password||(ae.password="Password is required")):b==="username_password"?(A.username||(ae.username="Username is required"),A.password||(ae.password="Password is required")):b==="email_otp"||b==="email_magic_link"?A.email||(ae.email="Email address is required"):b==="phone_otp"&&(A.phone?/^\d{7,15}$/.test(A.phone)||(ae.phone="Phone number must contain 7-15 digits"):ae.phone="Phone number is required"),S(ae),Object.keys(ae).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 Oe=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";P(!0);try{const Re={...A,strategy:pe};b==="phone_otp"&&O&&(Re.phone_country_code=O),await k.create(Re),Oe||P(!1)}catch(Re){S({submit:Re.message}),P(!1)}},de=async ee=>{if(ee.preventDefault(),N||Z)return;const ae={};if(!L){ae.otp="OTP code is required",S(ae);return}P(!0),S({});try{await k.completeVerification(L),u(!1),H("")}catch(pe){S({otp:pe.message||"Verification failed"})}finally{P(!1)}},z=async ee=>{if(!(N||Z)){P(!0);try{const ae=new URLSearchParams(window.location.search),pe=ft(e,ae.get("redirect_uri"))||void 0,{data:Oe}=await M.create({provider:ee.provider,redirectUri:pe});Oe&&typeof Oe=="object"&&"oauth_url"in Oe&&(window.location.href=Oe.oauth_url)}catch(ae){S({submit:ae.message})}finally{P(!1)}}},le=async()=>{var ee;if(!(N||Z)){P(!0),S({});try{const ae=await F.create();if("data"in ae&&ae.data){await i();let pe=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));pe||(pe=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!pe&&(e!=null&&e.frontend_host)&&(pe=`https://${e.frontend_host}`),W(!0),pe&&a(pe)}}catch(ae){S({submit:ae.message||"Passkey sign-in failed"})}finally{P(!1)}}},Je=()=>{var pe;let ee=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(ee||(ee=((pe=e==null?void 0:e.ui_settings)==null?void 0:pe.after_signin_redirect_url)||null),!ee&&(e!=null&&e.frontend_host)&&(ee=`https://${e.frontend_host}`),!ee)return null;let ae;try{ae=new URL(ee)}catch{ae=new URL(ee,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&ae.searchParams.set("__dev_session__",wt(e.backend_host)||""),ae.toString()},it=async ee=>{if(!(N||Z)){S({}),P(!0);try{await m(ee);const ae=Je();ae&&(W(!0),a(ae))}catch(ae){S({submit:ae.message||"Failed to continue with selected account"})}finally{P(!1)}}},ge=(ee,ae)=>`${ee||""} ${ae||""}`.trim().split(" ").filter(Boolean).map(pe=>pe[0]).join("").toUpperCase().slice(0,2)||"?",ot=o.useRef(!1);if(o.useEffect(()=>{if(n)return;const ee=new URLSearchParams(window.location.search),ae=ee.get("ticket");if(ae&&!ot.current&&!N){ot.current=!0,ee.delete("ticket");const Oe=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Oe),(async()=>{var ct;try{P(!0),await l(ae),W(!0);let Tt=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(Tt||(Tt=((ct=e==null?void 0:e.ui_settings)==null?void 0:ct.after_signin_redirect_url)||null),!Tt&&(e!=null&&e.frontend_host)&&(Tt=`https://${e.frontend_host}`),Tt){let Ns;try{Ns=new URL(Tt)}catch{Ns=new URL(Tt,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Ns.searchParams.set("__dev_session__",wt(e.backend_host)||""),a(Ns.toString())}return}catch(Tt){S({submit:Tt.message||"Failed to exchange ticket"}),ot.current=!1}finally{P(!1)}})();return}const pe=ee.get("signin_attempt_id");if(pe&&(s!=null&&s.signin_attempts)&&!C){const Oe=s.signin_attempts.find(Re=>Re.id===pe);if(Oe){E(Oe),ee.delete("signin_attempt_id");const Re=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Re)}}},[s,n,C,E,N]),o.useEffect(()=>{var Oe;if(!C)return;if(C.completed){W(!0);let Re=new URLSearchParams(window.location.search).get("redirect_uri");if(Re||(Re=((Oe=e==null?void 0:e.ui_settings)==null?void 0:Oe.after_signin_redirect_url)||null),!Re&&(e!=null&&e.frontend_host)&&(Re=`https://${e.frontend_host}`),Re){let ct;try{ct=new URL(Re)}catch{ct=new URL(Re,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&ct.searchParams.set("__dev_session__",wt(e.backend_host)||""),a(ct.toString())}return}if(!k||p)return;const ae={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(!ae)return;(async()=>{try{await k.prepareVerification({strategy:ae}),P(!1),u(!0)}catch{S({submit:"Failed to send verification. Please try again."}),P(!1)}})()},[C,k,p,u,a,e]),g)return t.jsx(wm,{onBack:()=>x(!1)});if(h)return t.jsx(fm,{onBack:()=>f(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return t.jsx(Lc,{attempt:C,completeVerification:k.completeVerification,prepareVerification:k.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return t.jsx(Pc,{attempt:C,completeProfile:k.completeProfile,completeVerification:k.completeVerification,prepareVerification:k.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if(Q){const ee=()=>{ue(!1),Ye&&(W(!0),a(Ye))},ae=()=>{ue(!1),Ye&&(W(!0),a(Ye))};return t.jsx(Pe,{children:t.jsx(et,{children:t.jsx($c,{onComplete:ee,onSkip:ae})})})}if(n||U)return t.jsx(js,{});const X=((ya=e==null?void 0:e.ui_settings)==null?void 0:ya.app_name)||"App",me=(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,Le=b==="email_magic_link",Me=c&&!me&&ce.length>0&&!te,Qe=()=>{u(!1),y(),G()};let vt;if(me){const ee=b==="phone_otp"?"Check your phone":Le?"Check your inbox":"Enter the code",ae=Le?"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"||Le)&&A.email?A.email:b==="phone_otp"&&A.phone?`+${A.phone}`:null;vt=t.jsx(st,{title:ee,sub:ae,children:pe&&t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:Qe,children:[t.jsx(Al,{weight:"bold"}),pe]})})}else vt=t.jsx(st,{title:"Sign in to your account",sub:`Please enter your details to continue to ${X}.`});let Ut;me?Ut=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{className:"w-link",to:((bt=e==null?void 0:e.ui_settings)==null?void 0:bt.support_page_url)||"#",children:"Get help"})]}):Ut=t.jsxs("span",{className:"w-auth-foot",children:["Don't have an account?"," ",t.jsx(St,{className:"w-link",to:`${((aa=e==null?void 0:e.ui_settings)==null?void 0:aa.sign_up_page_url)??""}${window.location.search}`,children:"Sign up"})]});let Ft;if(me&&Le)Ft=t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,padding:"12px 0 4px"},children:Ge?t.jsx("button",{type:"button",className:"w-link w-linkbtn",onClick:async()=>{Ie(!1),K(60);try{await k.prepareVerification({strategy:"magic_link"})}catch{}},children:"Resend magic link"}):t.jsxs("span",{className:"w-secsub",children:["Resend in ",Ee,"s"]})});else if(me)Ft=t.jsxs("form",{onSubmit:de,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(va,{onComplete:async ee=>{if(H(ee),ee&&ee.length===6){P(!0),S({});try{await k.completeVerification(ee),u(!1)}catch(ae){S({otp:ae.message||"Verification failed"})}finally{P(!1)}}},onResend:async()=>{const ee=b==="email_otp"?"email_otp":"phone_otp";await k.prepareVerification({strategy:ee})},error:$.otp,isSubmitting:Z}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:Z||N||!L,children:Z&&L?t.jsx(gt,{size:15,onAccent:!0}):`Continue to ${X}`})]});else{const ee=(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((na=(sa=e==null?void 0:e.auth_settings)==null?void 0:sa.email_address)==null?void 0:na.enabled),ae=b==="username_password"&&((ie=(ra=e==null?void 0:e.auth_settings)==null?void 0:ra.username)==null?void 0:ie.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),Oe=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);Ft=t.jsxs(t.Fragment,{children:[w.length>0&&t.jsx(Nr,{connections:w,callback:z}),((Ve=(qe=e==null?void 0:e.auth_settings)==null?void 0:qe.passkey)==null?void 0:Ve.enabled)&&t.jsxs("button",{type:"button",className:"w-social",style:{marginTop:w.length>0?10:0},onClick:le,disabled:Z,children:[t.jsx(ar,{}),t.jsx("span",{children:"Sign in with a passkey"})]}),(w.length>0||((jt=(yt=e==null?void 0:e.auth_settings)==null?void 0:yt.passkey)==null?void 0:jt.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:[ee&&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(ui,{})}),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:()=>_("identifier"),children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",value:A.email,onChange:D,placeholder:"you@company.com","aria-invalid":!!$.email}),$.email&&t.jsx("span",{className:"w-input-err",children:$.email})]}),ae&&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(ui,{})}),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:()=>{_("identifier"),I(Re=>({...Re,password:""}))},children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",value:A.username,onChange:D,placeholder:"yourname","aria-invalid":!!$.username,autoComplete:"username"}),$.username&&t.jsx("span",{className:"w-input-err",children:$.username})]}),pe&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(ys,{value:A.phone,onChange:D,error:$.phone,countryCode:O,setCountryCode:R}),$.phone&&t.jsx("span",{className:"w-input-err",children:$.phone})]}),Oe&&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:()=>f(!0),children:"Forgot?"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"current-password",value:A.password,onChange:D,placeholder:"••••••••","aria-invalid":!!$.password}),$.password&&t.jsx("span",{className:"w-input-err",children:$.password})]}),$.submit&&t.jsx("span",{className:"w-input-err",children:$.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:Z||N,children:Z?t.jsx(gt,{size:15,onAccent:!0}):t.jsxs(t.Fragment,{children:[v==="identifier"?"Continue":"Sign in",t.jsx(Qt,{weight:"bold"})]})}),v==="password"&&((ht=(We=e==null?void 0:e.auth_settings)==null?void 0:We.auth_factors_enabled)==null?void 0:ht.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:Z,onClick:async()=>{P(!0),S({});try{await k.create({email:A.email,strategy:"email_otp"}),j("email_otp")}catch(Re){S({submit:Re.message}),P(!1)}},children:[t.jsx("span",{className:"w-method-ic",children:t.jsx(xl,{})}),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(Qt,{})})]})]})]})]})}return t.jsx(Pe,{children:t.jsxs(et,{footer:Ut,children:[vt,Y&&t.jsxs("div",{className:"w-banner w-banner--error",style:{marginBottom:18},children:[t.jsx(Fa,{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"})]})]}),Me&&(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(ee=>{var ae,pe,Oe,Re;return t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>it(ee.id),disabled:Z||N,children:[t.jsx("span",{className:"w-avatar",children:ee.user.has_profile_picture?t.jsx("img",{src:ee.user.profile_picture_url,alt:((ae=ee.user.primary_email_address)==null?void 0:ae.email)||"account"}):ge(ee.user.first_name,ee.user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsx("span",{className:"w-acct-name",children:ee.user.first_name&&ee.user.last_name?`${ee.user.first_name} ${ee.user.last_name}`:ee.user.first_name||((Oe=(pe=ee.user.primary_email_address)==null?void 0:pe.email)==null?void 0:Oe.split("@")[0])||"Account"}),t.jsx("span",{className:"w-secsub",children:(Re=ee.user.primary_email_address)==null?void 0:Re.email})]}),t.jsx(Qt,{className:"w-acct-go"})]},ee.id)}),t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>{se(!1),oe(!0),G()},children:[t.jsx("span",{className:"w-avatar",style:{background:"var(--wa-surface-subtle)",color:"var(--wa-text-muted)"},children:t.jsx(Hu,{size:16})}),t.jsx("span",{className:"w-acct-text w-acct-name",children:"Use a different account"}),t.jsx(Qt,{className:"w-acct-go"})]})]})]}):t.jsxs("button",{type:"button",className:"w-acct","data-active":!0,style:{marginBottom:18},onClick:()=>it(ce[0].id),disabled:Z||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:((Bt=ce[0].user.primary_email_address)==null?void 0:Bt.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||((oa=(ia=ce[0].user.primary_email_address)==null?void 0:ia.email)==null?void 0:oa.split("@")[0])||"back"]}),t.jsx("span",{className:"w-secsub",children:(la=ce[0].user.primary_email_address)==null?void 0:la.email})]}),t.jsx("span",{className:"w-link w-link--muted w-link--sm",style:{flex:"none"},onClick:ee=>{ee.stopPropagation(),ce.length>1?se(!0):(oe(!0),G())},children:"Not you?"})]})),Ft]})})}function jm(){var b,j,v,_,N,k,C,y,E,M,F,A;const{deployment:e}=ke(),{loading:a,joinWaitlist:s}=No(),[n,i]=o.useState({first_name:"",last_name:"",email:""}),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(null),h=()=>{if(p)return p.message},f=e==null?void 0:e.auth_settings,g=!!((b=f==null?void 0:f.first_name)!=null&&b.enabled&&((j=f==null?void 0:f.last_name)!=null&&j.enabled)),x=I=>{const{name:$,value:S}=I.target;i(Z=>({...Z,[$]:S}))},w=async I=>{if(I.preventDefault(),!!f){d(!0),u(null);try{(await s(n)).data&&m(!0)}catch($){u($)}finally{d(!1)}}};return l?t.jsx(Pe,{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(Be,{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"," ",n.email," when we're ready for you to join."]})]})})}):t.jsx(Pe,{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(st,{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=f==null?void 0:f.first_name)==null?void 0:v.enabled)||((_=f==null?void 0:f.last_name)==null?void 0:_.enabled))&&t.jsxs("div",{className:g?"w-grid-2":"",children:[((N=f==null?void 0:f.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",((k=f==null?void 0:f.first_name)==null?void 0:k.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"first_name",name:"first_name",required:(C=f==null?void 0:f.first_name)==null?void 0:C.required,minLength:2,maxLength:50,value:n.first_name,onChange:x,placeholder:"First name"})]}),((y=f==null?void 0:f.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=f==null?void 0:f.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=f==null?void 0:f.last_name)==null?void 0:M.required,minLength:2,maxLength:50,value:n.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=f==null?void 0:f.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=f==null?void 0:f.email_address)==null?void 0:A.required,value:n.email,onChange:x,placeholder:"Enter your email address"})]}),h()&&t.jsx("span",{className:"w-input-err",children:h()}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:c||a,children:c||a?t.jsx(gt,{onAccent:!0}):"Join waitlist"})]})]})})}function On({title:e,sub:a,icon:s,message:n,action:i,footer:l}){return t.jsx(Pe,{children:t.jsxs(et,{footer:l,children:[t.jsx(st,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:n}),i]})]})})}function _m(){const{deployment:e}=ke(),{navigate:a}=_t(),{error:s,session:n,processed:i,signinAttempt:l,redirectUri:m,loading:c}=So(),[d,p]=o.useState(!1),[u,h]=o.useState(null),f=()=>{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,_,N;if(!(!i||c||d)){if(l&&!l.completed){const k=(b=e==null?void 0:e.ui_settings)==null?void 0:b.sign_in_page_url;if(k){const C=new URL(k,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=ft(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__",wt(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=(_=n==null?void 0:n.active_signin)==null?void 0:_.user)!=null&&N.has_passkeys)?(h(y.toString()),p(!0)):a(y.toString())}}}},[n,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(Pe,{children:t.jsx(et,{children:t.jsx($c,{onComplete:x,onSkip:w})})});if(n&&i&&!s)return t.jsx(On,{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(Be,{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(On,{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(La,{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:f,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(On,{title:"Completing sign in",sub:"Please wait while we authenticate you",icon:t.jsx(gt,{size:32}),message:"Verifying your credentials… this will only take a moment."})}function km({onSuccess:e,onError:a}={}){const[s,n]=o.useState("loading"),[i,l]=o.useState(""),{token:m,attempt:c,redirectUri:d}=W1(),{verifyMagicLink:p}=Eo(),{navigate:u}=_t(),{deployment:h}=ke(),f=o.useRef(!1);o.useEffect(()=>{(async()=>{if(!f.current){if(!m||!c){n("error"),l("The magic link appears to be malformed. Please try signing in again."),a==null||a("Invalid magic link parameters");return}f.current=!0,n("loading"),l("Please wait while we verify your magic link.");try{await p({token:m,attempt:c,redirectUri:d}),n("success"),l("You will be redirected to your account shortly."),e==null||e(),setTimeout(()=>{var b;let w=ft(h,d);if(w||(w=(b=h==null?void 0:h.ui_settings)==null?void 0:b.after_signin_redirect_url),!w&&(h!=null&&h.frontend_host)&&(w=`https://${h.frontend_host}`),w){const j=new URL(w);(h==null?void 0:h.mode)==="staging"&&j.searchParams.set("__dev_session__",wt(h.backend_host)||""),u(j.toString())}},2e3)}catch(w){n("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=h==null?void 0:h.ui_settings)!=null&&x.sign_in_page_url&&u(h.ui_settings.sign_in_page_url)};return t.jsx(Pe,{children:t.jsxs(et,{children:[t.jsx(st,{title:"Magic link",sub:"Verifying your magic link"}),t.jsxs("div",{className:"w-auth-status",children:[s==="loading"&&t.jsx(gt,{size:32}),s==="success"&&t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Be,{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(La,{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 Cm(e){var n,i;return e?((n=e.signin_attempts)==null?void 0:n.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 Nm(e){const a=e?`/profile-completion?redirect_uri=${encodeURIComponent(e)}`:"/profile-completion";window.location.href=a}function ns({kind:e}){const a=e==="success"?"w-success":e==="error"?"w-success w-success--error":"w-success w-success--info",s=e==="success"?Be:e==="error"?La:Au;return t.jsxs("div",{className:a,children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(s,{weight:"bold"})})]})}function _a({title:e,sub:a,icon:s,message:n,action:i,footer:l}){return t.jsx(Pe,{children:t.jsxs(et,{footer:l,children:[t.jsx(st,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:n}),i]})]})})}function Sm({token:e,onSuccess:a,onError:s}){var b;const{acceptInvitation:n,invitationData:i,loading:l,error:m}=Ho(),{navigate:c}=_t(),{deployment:d}=ke(),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:ft(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,n(j))},[n]),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 h=()=>{const{redirectUri:j}=u();c(j)},f=()=>{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",_=((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?_:v}?${N.toString()}`)},g=()=>{const{token:j}=u();j&&(p.current=!1,n(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(_a,{title:"Invalid invitation",sub:"No invitation token found",icon:t.jsx(ns,{kind:"error"}),message:"The invitation link appears to be invalid or incomplete.",action:x("Go to home",()=>c("/"))});if(l)return t.jsx(_a,{title:"Processing invitation",sub:"Please wait while we verify your invitation",icon:t.jsx(gt,{size:32}),message:"Verifying invitation… this will only take a moment."});if(i!=null&&i.organization&&!i.requires_signin)return t.jsx(_a,{title:"Invitation accepted",sub:"You've successfully joined the organization",icon:t.jsx(ns,{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",h)});if(i!=null&&i.already_member)return t.jsx(_a,{title:"Already a member",sub:"You're already part of this organization",icon:t.jsx(ns,{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",h)});if(i!=null&&i.requires_signin){const j=i.error_code==="INVITATION_REQUIRES_SIGNUP";return t.jsx(_a,{title:j?"Sign up required":"Sign in required",sub:"To accept this invitation",icon:t.jsx(ns,{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",f)})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?t.jsx(_a,{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(Cu,{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(_a,{title:"Invitation error",sub:"Unable to process invitation",icon:t.jsx(ns,{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:f,children:"Sign in manually"})]})}):null}const Oc=o.createContext(void 0),Zc=()=>{const e=o.useContext(Oc);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},Em=({isOpen:e,onClose:a,children:s})=>{const[n,i]=o.useState(!1),l=ts();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||!n?null:en.createPortal(t.jsx("div",{className:"wacht-root",style:l,children:t.jsx(Oc.Provider,{value:{isOpen:e,onClose:a},children:s})}),document.body)},Am=({children:e})=>{const{onClose:a}=Zc(),s=o.useRef(null),n=i=>{s.current&&!s.current.contains(i.target)&&(a==null||a())};return t.jsx("div",{className:"w-modal",onClick:n,children:t.jsx("div",{ref:s,style:{maxWidth:"100%",minWidth:0},children:e})})},Mm=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog${s?` ${s}`:""}`,style:{maxHeight:"90vh",overflowY:"auto",...a},children:e}),Rm=({children:e,showCloseButton:a=!0})=>{const{onClose:s}=Zc();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(La,{size:18})})]})},Lm=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog-body${s?` ${s}`:""}`,style:a,children:e}),Pm=({children:e})=>t.jsx("div",{className:"w-dialog-foot",children:e}),ze=Object.assign(Em,{Overlay:Am,Content:Mm,Header:Rm,Body:Lm,Footer:Pm}),$m=({isOpen:e,onClose:a,title:s,children:n,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:n})]})})}),Om=({trigger:e,renderDialog:a})=>{const[s,n]=o.useState(!1),i=()=>n(!0),l=()=>n(!1);return t.jsxs(t.Fragment,{children:[e({onClick:i}),a({isOpen:s,onClose:l})]})},Hc=o.createContext(void 0),Fc=()=>{const e=o.useContext(Hc);if(!e)throw new Error("useDropdownContext must be used within a DropdownProvider");return e},_s=({children:e,open:a,openChange:s,style:n})=>{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(Hc.Provider,{value:{open:l,openChange:c=>m(c)},children:t.jsx("div",{style:{width:"fit-content",...n},ref:i,children:e})})},ks=({children:e,style:a,className:s})=>{const{open:n}=Fc(),[i,l]=o.useState({top:0,left:0}),[m,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{n&&d.current?(c(!1),requestAnimationFrame(()=>{var h,f;const p=(h=d.current)==null?void 0:h.parentElement;if(!p)return;const u=p.querySelector("[data-dropdown-trigger]")||p.firstElementChild;if(u&&u!==d.current){const g=u.getBoundingClientRect(),x=(f=d.current)==null?void 0:f.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)},[n]),n?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},Cs=({children:e})=>{const{openChange:a,open:s}=Fc(),n=o.useCallback(()=>{a(!s)},[s,a]);return t.jsx("div",{style:{position:"relative",display:"inline-flex"},onClick:n,"data-dropdown-trigger":!0,children:e})},ea=o.forwardRef(({$destructive:e,className:a,...s},n)=>t.jsx("button",{ref:n,className:`w-menu-item${e?" w-menu-item--danger":""}${a?` ${a}`:""}`,...s}));ea.displayName="DropdownItem";const Tc=()=>t.jsx("div",{style:{height:"0.5px",background:"var(--wa-border)",width:"100%",margin:"4px 0"}}),Ic=o.forwardRef(({className:e,style:a,...s},n)=>t.jsx("form",{ref:n,className:e,style:{display:"flex",flexDirection:"column",gap:16,...a},...s}));Ic.displayName="Form";const Ue=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:`w-field${e?` ${e}`:""}`,...a}));Ue.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},n)=>{const i=`w-input${a?` ${a}`:""}`;return e==="textarea"?t.jsx("textarea",{className:i,...s}):t.jsx("input",{ref:n,className:i,...s})});be.displayName="Input";const je=({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}})}),Za=({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"})})]}),Kt=(e=!1)=>{const[a,s]=o.useState(e),n=o.useCallback(()=>{s(!0)},[]),i=o.useCallback(()=>{s(!1)},[]),l=o.useCallback(()=>{s(m=>!m)},[]);return{isOpen:a,open:n,close:i,toggle:l}},Vc=({onChange:e,placeholder:a,value:s})=>t.jsxs("div",{className:"w-search",children:[t.jsx(Cl,{}),t.jsx("input",{type:"text",placeholder:a,value:s,onChange:n=>e(n.target.value)})]}),ne=o.forwardRef(({$primary:e,$outline:a,$destructive:s,$fullWidth:n,$size:i,className:l,style:m,...c},d)=>{const h=`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:h,style:n?{width:"100%",...m}:m,...c})});ne.displayName="Button";const zc=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"}),Dc={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},Qs=({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}),un=({options:e,value:a,onChange:s,placeholder:n="Select an option",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[h,f]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],_=(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,k=(y,E=!1)=>{E||(s(y),f(!1),x(""))},C=()=>{i||f(!h)};return o.useEffect(()=>{h&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[h,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(f(!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":h?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":h,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":_?void 0:"",children:_?_.label:n}),h?t.jsx(Jo,{size:16}):t.jsx(Dt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:zc(h),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Dc,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(Qs,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a||""})]})},Uc=({options:e,value:a,onChange:s,placeholder:n="Select options",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[h,f]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],_=(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,k=(y,E=!1)=>{E||(a.includes(y)?s(a.filter(M=>M!==y)):s([...a,y]))},C=()=>{i||f(!h)};return o.useEffect(()=>{h&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[h,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(f(!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":h?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":h,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":_.length>0?void 0:"",children:_.length>0?_.map(y=>y.label).join(", "):n}),h?t.jsx(Jo,{size:16}):t.jsx(Dt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:zc(h),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Dc,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(Qs,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a.join(",")})]})},Os=e=>e.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)||"?",Ei=e=>e.trim().replace(/[<>"'&]/g,""),Zm=e=>e.length>=2&&e.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(e),Hm=e=>/.+@.+\..+/.test(e),Ai=(e,a)=>e.length?e.find(s=>s.name===a)||e[0]:null,Fm=({roles:e,value:a,onChange:s,fullWidth:n})=>{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${n?" w-full":" w-none"}`,children:[t.jsxs("button",{type:"button",className:`w-combo${n?" 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(Dt,{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(Be,{size:13})})]},c.id))})]})},Wc=({mode:e,organizationId:a,onSuccess:s,onCancel:n,onCreateOrganization:i})=>{var ce;const l=e==="org",m=l?"organization":"workspace",c=l?"Organization":"Workspace",{createOrganization:d,getOrganizationRoles:p,inviteOrganizationMember:u}=Vt(),{createWorkspace:h,getWorkspaceRoles:f,createWorkspaceInvitation:g}=ga(),{organizationMemberships:x}=wa(),{refetch:w}=rt(),[b,j]=o.useState(0),[v,_]=o.useState(""),[N,k]=o.useState(""),[C,y]=o.useState(),[E,M]=o.useState(null),[F,A]=o.useState(!1),[I,$]=o.useState(null),[S,Z]=o.useState(a),[P,L]=o.useState(!1),H=o.useRef(null),O=o.useRef(null),[R,U]=o.useState(null),[W,Y]=o.useState([]),[B,Q]=o.useState([]),[ue,we]=o.useState(""),[se,te]=o.useState(null),oe=(ce=x==null?void 0:x.find(D=>D.organization.id===S))==null?void 0:ce.organization;o.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]),o.useEffect(()=>{if(!P)return;const D=G=>{H.current&&!H.current.contains(G.target)&&L(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[P]);const Ee=D=>{var q;const G=(q=D.target.files)==null?void 0:q[0];if(G){if(G.size>2*1024*1024){$("Image must be under 2 MB.");return}if(!G.type.startsWith("image/")){$("Please choose a valid image file.");return}E&&URL.revokeObjectURL(E),$(null),y(G),M(URL.createObjectURL(G))}},K=async()=>{var q;const D=Ei(v),G=Ei(N);if(!Zm(D)){$(`Enter a valid ${m} name (2–100 characters).`);return}if(!l&&!S){$("Select an organization first.");return}A(!0),$(null);try{if(l){const V=await d({name:D,description:G,image:C}),de=((q=V==null?void 0:V.data)==null?void 0:q.organization)??(V==null?void 0:V.organization)??V;U(de);const z=await p(de).catch(()=>[]);Y(z),te(Ai(z,"Member"))}else{const V=await h(S,D,C,G),de=(V==null?void 0:V.workspace)??V,z={...de,organization:{id:S}};U(z);const le=await f(de).catch(()=>[]);Y(le),te(Ai(le,"Editor"))}await w(),j(1)}catch(V){$((V==null?void 0:V.message)||`Failed to create ${m}.`)}finally{A(!1)}},Ge=()=>{const D=ue.trim();!Hm(D)||B.some(G=>G.email===D)||se&&(Q(G=>[...G,{email:D,roleId:se.id,roleName:se.name}]),we(""))},Ie=D=>{(D.key==="Enter"||D.key===",")&&(D.preventDefault(),Ge())},Ye=async()=>{if(!B.length){j(2);return}A(!0),$(null);try{for(const D of B)l?await u(R,{email:D.email,organizationRole:{id:D.roleId}}):await g(R,D.email,D.roleId);j(2)}catch(D){$((D==null?void 0:D.message)||"Some invitations could not be sent.")}finally{A(!1)}},Ae=()=>{j(0),_(""),k(""),y(void 0),E&&URL.revokeObjectURL(E),M(null),U(null),Y([]),Q([]),we(""),$(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 D;return(D=O.current)==null?void 0:D.click()},title:`Upload ${m} logo`,"aria-label":`Upload ${m} logo`,children:[E?t.jsx("img",{src:E,alt:`${c} logo`}):l?t.jsx(ps,{}):t.jsx(di,{}),t.jsx("span",{className:"w-avatar-veil",children:t.jsx(sn,{})})]}),t.jsx("input",{ref:O,type:"file",className:"w-none",hidden:!0,accept:"image/png, image/jpeg, image/gif, image/svg+xml",onChange:Ee,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(La,{})})]}):t.jsx("span",{className:`w-ibadge${b===2?" w-ibadge--done":""}`,children:b===2?t.jsx(Be,{}):l?t.jsx(ps,{}):t.jsx(di,{})}),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})]}),I&&t.jsx("div",{className:"w-banner w-banner--error w-mb-4",children:I}),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:H,children:[t.jsxs("button",{type:"button",className:"w-combo w-full","data-open":P?"":void 0,onClick:()=>L(D=>!D),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:oe!=null&&oe.image_url?t.jsx("img",{src:oe.image_url,alt:oe.name}):Os((oe==null?void 0:oe.name)||"O").charAt(0)}),t.jsx("span",{children:(oe==null?void 0:oe.name)||"Select organization"})]}),t.jsx(Dt,{size:14})]}),P&&t.jsxs("div",{className:"w-combo-menu w-combo-menu--pop",children:[x==null?void 0:x.map(D=>{var q;const G=!!((q=D.eligibility_restriction)!=null&&q.type)&&D.eligibility_restriction.type!=="none";return t.jsxs("button",{type:"button",className:"w-combo-opt",disabled:G,"data-disabled":G?"":void 0,onClick:()=>{G||(Z(D.organization.id),L(!1))},children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:D.organization.image_url?t.jsx("img",{src:D.organization.image_url,alt:D.organization.name}):Os(D.organization.name).charAt(0)}),t.jsx("span",{children:D.organization.name})]},D.organization.id)}),i&&t.jsxs("button",{type:"button",className:"w-combo-opt w-text-primary",onClick:()=>{L(!1),i()},children:[t.jsx(Nt,{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:D=>_(D.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:D=>k(D.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.jsxs("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:K,disabled:F||!v.trim(),children:[F?t.jsx(je,{size:15}):null,"Continue",!F&&t.jsx(Qt,{size:15})]}),n&&t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-btn--block",onClick:n,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:D=>we(D.target.value),onKeyDown:Ie,placeholder:"teammate@acme.com"}),t.jsx(Fm,{roles:W,value:se,onChange:te})]}),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(D=>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:Os(D.email)}),t.jsx("span",{className:"w-truncate w-text-secondary",children:D.email})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-pill",children:D.roleName}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",title:"Remove",onClick:()=>Q(G=>G.filter(q=>q.email!==D.email)),children:t.jsx(La,{size:13})})]})]},D.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.jsxs("button",{type:"button",className:"w-btn w-btn--primary w-grow",onClick:Ye,disabled:F,children:[F?t.jsx(je,{size:15}):null,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}):Os(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(R),children:["Go to ",m,t.jsx(Qt,{size:15})]}),t.jsxs("button",{type:"button",className:"w-link w-link--muted w-linkbtn w-inline w-gap-1",onClick:Ae,children:[t.jsx(Vo,{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."})})]})},mn=({onSuccess:e,onCancel:a})=>t.jsx(Pe,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Wc,{mode:"org",onSuccess:e,onCancel:a})})}),Bc=({isOpen:e,onClose:a,onCreated:s})=>{const n=()=>{s==null||s(),a==null||a()};return t.jsx(Pe,{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(mn,{onSuccess:n,onCancel:a})})})})})},Er=o.createContext({screen:null,setScreen:()=>{},toast:(e,a)=>{}}),kt=()=>{const e=o.useContext(Er);if(!e)throw new Error("useScreenContext must be used within a ScreenContextProvider");return e},Qa=({title:e,description:a,onConfirm:s,onCancel:n,style:i})=>{const l=o.useRef(null);return o.useEffect(()=>{const m=c=>{l.current&&!l.current.contains(c.target)&&n()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[n]),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:n,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:s,children:"Confirm"})]})]})},Mi=[{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:{}}],Tm=({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(Xt,{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)})},Im=({organization:e})=>{const{getEnterpriseConnections:a,createEnterpriseConnection:s,deleteEnterpriseConnection:n,testEnterpriseConnection:i,generateSCIMToken:l,getSCIMToken:m,revokeSCIMToken:c}=Vt(),{toast:d}=kt(),[p,u]=o.useState(!1),[h,f]=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(n==null?void 0:n(e,j)),w(),d("SSO connection deleted","info")}catch(v){d(v.message||"Failed to delete connection","error")}f(null)};return x?t.jsx("div",{className:"w-loading",children:t.jsx(je,{})}):p?t.jsx(zm,{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(Xt,{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(ne,{onClick:()=>u(!0),children:[t.jsx(Nt,{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(Vm,{connection:j,onDelete:v=>f(v),connectionToDelete:h,onConfirmDelete:b,onCancelDelete:()=>f(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))]})})},Vm=({connection:e,onDelete:a,connectionToDelete:s,onConfirmDelete:n,onCancelDelete:i,testConnection:l,generateSCIMToken:m,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var F,A,I,$,S;const[u,h]=o.useState(null),[f,g]=o.useState(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),[v,_]=o.useState(!1),[N,k]=o.useState(null);o.useEffect(()=>{c&&e.id&&c(e.id).then(h).catch(()=>{})},[e.id,c]);const C=async()=>{if(l){_(!0),k(null);try{const Z=await l(e.id);k(Z)}catch(Z){k({success:!1,checks:{},errors:{general:Z.message||"Test failed"}})}finally{_(!1)}}},y=async()=>{if(m){g(!0);try{const Z=await m(e.id);w(Z.token),h({exists:!0,token:Z}),p("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(Z){p(Z.message||"Failed to generate token","error")}finally{g(!1)}}},E=async()=>{if(d){g(!0);try{await d(e.id),h({exists:!1,scim_base_url:u==null?void 0:u.scim_base_url}),w(null),p("SCIM token revoked","info")}catch(Z){p(Z.message||"Failed to revoke token","error")}finally{g(!1)}}},M=(Z,P)=>{navigator.clipboard.writeText(Z),j(P),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(Xt,{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(ne,{$size:"sm",onClick:C,disabled:v,children:v?t.jsx(je,{size:14}):"Test"}),t.jsxs("div",{className:"w-relative",children:[t.jsx(ne,{$size:"sm",$outline:!0,onClick:()=>a(e.id),className:"w-text-error",children:"Remove"}),s===e.id&&t.jsx(Qa,{title:"Delete this SSO connection?",onConfirm:()=>n(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(([Z,P])=>t.jsxs("div",{children:[Z.replace(/_/g," "),": ",P]},Z))]})}),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(Xt,{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(ne,{$size:"sm",onClick:y,disabled:f,children:f?t.jsx(je,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(ne,{$size:"sm",onClick:y,disabled:f,children:f?t.jsx(je,{size:14}):"Rotate"}),t.jsx(ne,{$size:"sm",$outline:!0,onClick:E,disabled:f,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:((I=u==null?void 0:u.token)==null?void 0:I.scim_base_url)||"Loading..."}),(($=u==null?void 0:u.token)==null?void 0:$.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(Be,{size:12}):t.jsx(Ga,{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(Be,{size:12}):t.jsx(Ga,{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()]})]})]})]})},zm=({onCreate:e,organization:a})=>{const{getOrganizationDomains:s,testEnterpriseConnectionConfig:n}=Vt(),{deployment:i}=ke(),{toast:l}=kt(),[m,c]=o.useState(!1),[d,p]=o.useState(null),[u,h]=o.useState("saml"),[f,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,_]=o.useState(!1),[N,k]=o.useState(null),{data:C=[],isLoading:y}=Ce("wacht-org-verified-domains-for-sso-screen",async()=>(await(s==null?void 0:s(a))||[]).filter(L=>L.verified),{revalidateOnFocus:!1}),E=P=>{p(P),h(P.protocol),P.protocol==="saml"?j(L=>{var H,O,R;return{...L,idp_entity_id:P.placeholders.entityId||"",idp_sso_url:P.placeholders.ssoUrl||"",attr_first_name:((H=P.attributeMapping)==null?void 0:H.first_name)||"",attr_last_name:((O=P.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((R=P.attributeMapping)==null?void 0:R.email)||""}}):j(L=>{var H,O,R;return{...L,oidc_issuer_url:P.placeholders.issuerUrl||"",oidc_scopes:P.placeholders.scopes||"openid profile email",attr_first_name:((H=P.attributeMapping)==null?void 0:H.first_name)||"",attr_last_name:((O=P.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((R=P.attributeMapping)==null?void 0:R.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`:"",I=(P,L)=>{navigator.clipboard.writeText(P),g(L),setTimeout(()=>g(null),2e3)},$=async P=>{P.preventDefault();const L=H=>H.includes("{")||H.includes("}");if(u==="saml"){if(!b.idp_entity_id||L(b.idp_entity_id)){l("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||L(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||L(b.oidc_issuer_url)){l("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||L(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 H={};b.attr_first_name&&(H.first_name=b.attr_first_name),b.attr_last_name&&(H.last_name=b.attr_last_name),b.attr_email&&(H.email=b.attr_email);const O=Object.keys(H).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,...O&&{attribute_mapping:H}}):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,...O&&{attribute_mapping:H}})}finally{c(!1)}},S=async()=>{_(!0),k(null);const P=O=>O.includes("{")||O.includes("}"),L={},H={};if(u==="saml"?(b.idp_entity_id?P(b.idp_entity_id)?(H.entity_id_valid=!1,L.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):H.entity_id_valid=!0:(H.entity_id_valid=!1,L.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?P(b.idp_sso_url)?(H.sso_url_valid=!1,L.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):H.sso_url_valid=!0:(H.sso_url_valid=!1,L.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?H.certificate_provided=!0:(H.certificate_provided=!1,L.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?P(b.oidc_issuer_url)?(H.issuer_url_valid=!1,L.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):H.issuer_url_valid=!0:(H.issuer_url_valid=!1,L.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?P(b.oidc_client_id)?(H.client_id_valid=!1,L.client_id_valid="Client ID contains placeholder values - please replace with actual values"):H.client_id_valid=!0:(H.client_id_valid=!1,L.client_id_valid="Client ID is required")),Object.keys(L).length>0){k({success:!1,checks:H,errors:L}),_(!1);return}try{const O=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},R=await(n==null?void 0:n(a,O));R&&k(R)}catch(O){k({success:!1,checks:{},errors:{general:"Test failed: "+O.message}})}finally{_(!1)}},Z=P=>t.jsx(Tm,{template:P});return t.jsxs("form",{onSubmit:$,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:[Z(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(ne,{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:Mi.filter(P=>P.protocol==="saml").map(P=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(P),children:[Z(P),t.jsx("span",{className:"w-secsub",children:P.name})]},P.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:Mi.filter(P=>P.protocol==="oidc").map(P=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(P),children:[Z(P),t.jsx("span",{className:"w-secsub",children:P.name})]},P.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:()=>I(A,"acs"),children:f==="acs"?t.jsx(Be,{size:12}):t.jsx(Ga,{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:()=>I(F,"metadata"),children:f==="metadata"?t.jsx(Be,{size:12}):t.jsx(Ga,{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:()=>I(M,"callback"),children:f==="callback"?t.jsx(Be,{size:12}):t.jsx(Ga,{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(vu,{size:12})," Docs"]}),t.jsx(ne,{type:"button",$size:"sm",$outline:!0,onClick:S,disabled:v||!d,children:v?t.jsx(je,{size:16}):"Test Connection"}),t.jsx(ne,{$size:"sm",type:"submit",disabled:m||C.length===0||!d,children:m?t.jsx(je,{size:16}):"Create Connection"})]})]}),N&&(()=>{const P={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(([L,H])=>{var O;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 ${H?"w-text-success":"w-text-error"}`,children:H?"✓":"✗"}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:P[L]||L.replace(/_/g," ").replace(/\b\w/g,R=>R.toUpperCase())}),((O=N.errors)==null?void 0:O[L])&&t.jsx("div",{className:"w-secsub w-text-error",children:N.errors[L]})]})]},L)})})]})})(),t.jsxs("div",{className:"w-grid-2",children:[!d&&t.jsxs(Ue,{children:[t.jsx(Te,{children:"Protocol *"}),t.jsxs("select",{className:"w-input",value:u,onChange:P=>h(P.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(Ue,{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:P=>j({...b,domain_id:P.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),C.map(P=>t.jsx("option",{value:P.id,children:P.fqdn},P.id))]})]}),u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(Ue,{children:[t.jsx(Te,{children:"IdP Entity ID *"}),t.jsx(be,{type:"text",value:b.idp_entity_id,onChange:P=>j({...b,idp_entity_id:P.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"IdP SSO URL *"}),t.jsx(be,{type:"url",value:b.idp_sso_url,onChange:P=>j({...b,idp_sso_url:P.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(Ue,{className:"w-col-full",children:[t.jsx(Te,{children:"X.509 Certificate *"}),t.jsx(be,{as:"textarea",value:b.idp_certificate,onChange:P=>j({...b,idp_certificate:P.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0,className:"w-input--area w-input--mono"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Ue,{children:[t.jsx(Te,{children:"Issuer URL *"}),t.jsx(be,{type:"url",value:b.oidc_issuer_url,onChange:P=>j({...b,oidc_issuer_url:P.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Client ID *"}),t.jsx(be,{type:"text",value:b.oidc_client_id,onChange:P=>j({...b,oidc_client_id:P.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Client Secret *"}),t.jsx(be,{type:"password",value:b.oidc_client_secret,onChange:P=>j({...b,oidc_client_secret:P.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Scopes"}),t.jsx(be,{type:"text",value:b.oidc_scopes,onChange:P=>j({...b,oidc_scopes:P.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(Ue,{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(Za,{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(Ue,{children:[t.jsx(Te,{children:"First Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_first_name,onChange:P=>j({...b,attr_first_name:P.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Last Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_last_name,onChange:P=>j({...b,attr_last_name:P.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Email Attribute"}),t.jsx(be,{type:"text",value:b.attr_email,onChange:P=>j({...b,attr_email:P.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},mt=(...e)=>e.filter(Boolean).join(" "),Ri=({className:e,...a})=>t.jsx("div",{className:mt("w-contents",e),...a}),Zn=({className:e,...a})=>t.jsx("div",{className:mt("w-card","w-flex-col","w-full","w-minh-full",e),...a}),Dm=({className:e,...a})=>t.jsx("div",{className:mt("w-tabsbar",e),...a}),Um=({className:e,...a})=>t.jsx("div",{className:mt("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),za=({className:e,$isActive:a,...s})=>t.jsx("button",{className:mt("w-tab",a&&"w-tab--active",e),...s}),Da=({className:e,...a})=>t.jsx("span",{className:mt("w-inline","w-gap-2",e),...a}),Wm=({className:e,children:a,...s})=>t.jsx("div",{className:mt("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Ar=({className:e,...a})=>t.jsx("div",{className:mt("w-sechead",e),...a}),Li=({className:e,...a})=>t.jsx("div",{className:mt("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Pi=({className:e,...a})=>t.jsx("div",{className:mt("w-grow",e),...a}),$i=({className:e,...a})=>t.jsx("div",{className:mt("w-flex","w-items-center","w-gap-3","w-none",e),...a}),pn=({className:e,...a})=>t.jsx("div",{className:mt("w-full",e),...a}),Bm=({className:e,...a})=>t.jsx("div",{className:mt("w-page-head",e),...a}),Gm=({className:e,...a})=>t.jsx("div",{className:mt("w-grow","w-flex-col","w-gap-1",e),...a}),qm=({className:e,...a})=>t.jsx("div",{className:mt("w-sec","w-truncate",e),...a}),Km=({className:e,...a})=>t.jsx("div",{className:mt("w-secsub","w-truncate",e),...a}),Ym={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},pa=({className:e,$variant:a="neutral",children:s,...n})=>t.jsxs("span",{className:mt("w-pill",Ym[a],e),...n,children:[t.jsx("span",{className:"w-dot"}),s]}),Oi=({className:e,$first:a,...s})=>t.jsx("div",{className:mt("w-sec",e),...s}),Qm=({organization:e})=>{var A,I,$,S,Z,P;const{switchOrganization:a,refetch:s}=rt(),{workspaces:n}=ga(),{deployment:i}=ke(),{deleteOrganization:l,updateOrganization:m}=Vt(),{toast:c}=kt(),[d,p]=o.useState((e==null?void 0:e.name)||""),[u,h]=o.useState((e==null?void 0:e.description)||""),[f,g]=o.useState(!1),[x,w]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,j]=o.useState(""),[v,_]=o.useState(!1),[N,k]=o.useState(!1),C=o.useRef({name:d,description:u,security:x,isSaving:f});o.useEffect(()=>{C.current={name:d,description:u,security:x,isSaving:f}},[d,u,x,f]);const y=o.useCallback(async()=>{if(!e)return;const L=C.current;try{g(!0),await m(e,{name:L.name,description:L.description,whitelisted_ips:L.security.allowed_ips.split(`
102
+ `,tm={display:"contents"};function am(e){const a={};if(!e)return a;const s=(n,i)=>{if(i)for(const l in i){const m=i[l];typeof m=="string"&&m.trim()!==""&&(a[`--wa-ov-${n}-${l}`]=m)}};return s("light",e.light),s("dark",e.dark),a}function ts(){var s,n;const e=o.useContext(fr),a=(n=(s=e==null?void 0:e.deployment)==null?void 0:s.ui_settings)==null?void 0:n.theme_tokens;return o.useMemo(()=>am(a),[a])}const Si=o.createContext(!1),sm=o.memo(function(){return t.jsx(em,{})});function Pe({children:e,className:a,style:s,...n}){const i=o.useContext(Si),l=ts(),[m,c]=o.useState(!1);if(o.useEffect(()=>c(!0),[]),!m)return null;const d=t.jsx("div",{...n,className:a?`wacht-root ${a}`:"wacht-root",style:{...tm,...l,...s},children:e});return i?d:t.jsxs(Si.Provider,{value:!0,children:[t.jsx(sm,{}),d]})}function va({length:e=6,onComplete:a,onResend:s,error:n,isSubmitting:i=!1}){const[l,m]=o.useState(new Array(e).fill("")),[c,d]=o.useState(60),[p,u]=o.useState(!1),h=o.useRef([]),f=o.useCallback(()=>{const j=setInterval(()=>{d(v=>v<=1?(u(!0),clearInterval(j),0):v-1)},1e3);return j},[]);o.useEffect(()=>{const j=f();return()=>clearInterval(j)},[f]);const g=async()=>{var j;!p||i||!s||(await s(),u(!1),d(60),m(new Array(e).fill("")),(j=h.current[0])==null||j.focus(),f())},x=(j,v)=>{var C;if(i)return;const _=j.value,N=[...l];N[v]=_.replace(/[^0-9]/g,""),m(N);const k=N.join("");k.length===e&&a(k),_&&v<e-1&&((C=h.current[v+1])==null||C.focus())},w=(j,v)=>{var _;i||j.key==="Backspace"&&!l[v]&&v>0&&((_=h.current[v-1])==null||_.focus())},b=(j,v)=>{var C,y;if(i)return;j.preventDefault();const _=j.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!_.length)return;const N=[...l];for(let E=0;E<_.length&&v+E<e;E++)N[v+E]=_[E];if(v===0&&_.length===e)for(let E=0;E<e;E++)N[E]=_[E];m(N);const k=N.join("");if(k.length===e)a(k),(C=h.current[e-1])==null||C.focus();else{const E=N.findIndex((M,F)=>F>=v&&!M);E!==-1&&((y=h.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":n?"":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:_=>x(_.target,v),onKeyDown:_=>w(_,v),onPaste:_=>b(_,v),ref:_=>{h.current[v]=_},disabled:i,autoFocus:v===0},v))}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[n&&t.jsx("span",{className:"w-input-err",children:n}),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 bc=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"})]}),yc=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"})]}),jc=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"})}),nm=()=>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"})}),_c=()=>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"})}),kc=()=>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"})]}),rm=()=>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"})}),Cc=()=>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"}})]}),im={google_oauth:{label:"Continue with Google",icon:t.jsx(yc,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(bc,{})},x_oauth:{label:"Continue with X",icon:t.jsx(jc,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(nm,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(_c,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(kc,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(rm,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(Cc,{})}},Nr=({connections:e,callback:a})=>{const s=e.map(n=>({connection:n,config:im[n.provider]})).filter(n=>n.config);if(!s.length)return null;if(s.length>3){const n=Math.min(s.length,4);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${n}, 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:n,config:i})=>t.jsxs("button",{type:"button",className:"w-social",onClick:()=>a(n),children:[i.icon,t.jsx("span",{className:"w-social-label",children:i.label})]},n.provider))})},St=({to:e,replace:a,children:s,...n})=>{const{navigate:i}=_t(),l=o.useCallback(m=>{m.preventDefault(),i(e,{replace:a})},[e,a,i]);return t.jsx("a",{href:e||void 0,onClick:l,...n,children:s})},qt=o.forwardRef(({onFocus:e,readOnly:a,...s},n)=>{const[i,l]=o.useState(!1);return t.jsx("input",{ref:n,...s,readOnly:a||!i,onFocus:m=>{i||l(!0),e==null||e(m)}})});qt.displayName="NoPrefillInput";const Gs=[{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:"🇿🇼"}],ys=({value:e,onChange:a,error:s,countryCode:n,setCountryCode:i})=>{const[l,m]=o.useState(!1),[c,d]=o.useState(Gs.find(x=>x.code===n)||Gs[0]),p=o.useRef(null),[u,h]=o.useState(""),f=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=Gs.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(Dt,{weight:"bold"})]}),l&&t.jsxs("div",{className:"w-country-pop",children:[t.jsxs("div",{className:"w-country-search",children:[t.jsx(Cl,{}),t.jsx("input",{type:"text",placeholder:"Search country…",value:u,onChange:x=>h(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=f.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:f,value:e,onChange:a,placeholder:"Phone number","aria-invalid":!!s,pattern:"^\\d{7,15}$"})]})};function Sr({placement:e="center"}){var m;const{deployment:a}=ke(),[s,n]=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:()=>n(!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 st({title:e,sub:a,children:s}){return t.jsxs("div",{className:"w-auth-head",children:[t.jsx(Sr,{}),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 gt({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 js(){return t.jsx(Pe,{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 om(e){const a=e.indexOf(":");return a>=0?e.slice(0,a):e}function lm(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 cm(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 dm(e,a){return!e||!a?!1:e===a?!0:e.endsWith(`.${a}`)}function um(e,a){if(!a)return!1;const s=cm(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 n=lm(om(e.frontend_host));return n?dm(s.hostname.toLowerCase(),n):!1}function ft(e,a){return a&&um(e,a)?a:null}function mm(){var B,Q,ue,we,se,te,oe,Ee,K,Ge,Ie,Ye,Ae,ce,D,G;const{loading:e,signUp:a,signupAttempt:s,discardSignupAttempt:n}=ho(),{signIn:i}=ls("oauth"),{deployment:l}=ke(),{navigate:m}=_t(),{session:c,refetch:d,loading:p}=rt(),[u,h]=o.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[f,g]=o.useState({}),[x,w]=o.useState(!1),[b,j]=o.useState(void 0),[v,_]=o.useState(null),[N,k]=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 q;if(!p&&(c!=null&&c.active_signin)&&!F&&!C){y(!0);let V=ft(l,new URLSearchParams(window.location.search).get("redirect_uri"));V||(V=((q=l==null?void 0:l.ui_settings)==null?void 0:q.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&&(k(V),a.validateDeploymentInvitation(V).then(z=>{_(z),z.valid&&h(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,I]=o.useState(!1),[$,S]=o.useState(""),Z=q=>{let{name:V,value:de}=q.target;V==="phone_number"?de=de.replace(/[^0-9-]/g,""):V==="email"&&(de=de.toLowerCase()),h(z=>({...z,[V]:de})),g(z=>({...z,[V]:""}))},P=()=>{h({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),g({}),I(!1),S(""),n()},L=async q=>{if(q.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}$/,it=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(R!=null&&R.first_name.enabled&&(R!=null&&R.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")),R!=null&&R.last_name.enabled&&(R!=null&&R.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")),R!=null&&R.username.enabled&&(R!=null&&R.username.required&&!u.username?V.username="Username is required":u.username&&!z.test(u.username)&&(V.username="Username must be 3-20 characters")),R!=null&&R.email_address.enabled&&(R!=null&&R.email_address.required&&!u.email?V.email="Email address is required":u.email&&!le.test(u.email)&&(V.email="Invalid email address")),R!=null&&R.phone_number.enabled&&(R!=null&&R.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")),R!=null&&R.password.enabled&&(u.password?it.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)}}},H=async q=>{if(!(e||x)){w(!0);try{const V=new URLSearchParams(window.location.search),de=ft(l,V.get("redirect_uri"))||void 0,{data:z}=await i.create({provider:q.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)}}},O=(l==null?void 0:l.social_connections.filter(q=>q.enabled))||[],R=l==null?void 0:l.auth_settings,U=!!((se=R==null?void 0:R.first_name)!=null&&se.enabled&&((te=R==null?void 0:R.last_name)!=null&&te.enabled)),W=async q=>{var de;if(q.preventDefault(),e||x)return;w(!0);const V={};if(!$){V.otp="OTP code is required",g(V),w(!1);return}g(V);try{const z=await a.completeVerification($);"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 q;if(s){if(s.completed){let V=ft(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(V||(V=((q=l==null?void 0:l.ui_settings)==null?void 0:q.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__",wt(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}I(!0)}}},[s,a,A,l,c,m]),p||C)return t.jsx(js,{});const Y=((oe=l==null?void 0:l.ui_settings)==null?void 0:oe.app_name)||"App";if(E)return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx(St,{className:"w-link",to:(Ee=l==null?void 0:l.ui_settings)!=null&&Ee.sign_in_page_url?`${l.ui_settings.sign_in_page_url}?help=true`:"#",children:"Get help"})]}),children:[t.jsx(st,{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 q=(s==null?void 0:s.current_step)==="verify_phone";return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{className:"w-link",to:((K=l==null?void 0:l.ui_settings)==null?void 0:K.support_page_url)||"#",children:"Get help"})]}),children:[t.jsx(st,{title:q?"Check your phone":"Enter the code",sub:q?"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:P,children:[t.jsx(Al,{weight:"bold"}),q?`+${u.phone_number}`:u.email]})}),t.jsxs("form",{onSubmit:W,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(va,{onComplete:async V=>{S(V)},onResend:async()=>{const V=q?"phone_otp":"email_otp";await a.prepareVerification({strategy:V})},error:f.otp,isSubmitting:x}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!$,children:x&&$?t.jsx(gt,{size:15,onAccent:!0}):`Continue to ${Y}`})]})]})})}return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Already have an account?"," ",t.jsx(St,{className:"w-link",to:`${((Ge=l==null?void 0:l.ui_settings)==null?void 0:Ge.sign_in_page_url)??""}${window.location.search}`,children:"Sign in"})]}),children:[t.jsx(st,{title:"Create your account",sub:v!=null&&v.valid?"You've been invited — complete your registration below.":"Get started in a few seconds."}),O.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Nr,{connections:O,callback:H}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})})]}),t.jsxs("form",{onSubmit:L,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[(((Ie=R==null?void 0:R.first_name)==null?void 0:Ie.enabled)||((Ye=R==null?void 0:R.last_name)==null?void 0:Ye.enabled))&&t.jsxs("div",{className:U?"w-grid-2":"",children:[((Ae=R==null?void 0:R.first_name)==null?void 0:Ae.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["First name",((ce=R==null?void 0:R.first_name)==null?void 0:ce.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{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:Z,placeholder:"Jane","aria-invalid":!!f.first_name,pattern:"^[a-zA-Z]{3,30}$"}),f.first_name&&t.jsx("span",{className:"w-input-err",children:f.first_name})]}),((D=R==null?void 0:R.last_name)==null?void 0:D.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Last name",((G=R==null?void 0:R.last_name)==null?void 0:G.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{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:Z,placeholder:"Doe","aria-invalid":!!f.last_name,pattern:"^[a-zA-Z]{3,30}$"}),f.last_name&&t.jsx("span",{className:"w-input-err",children:f.last_name})]})]}),(R==null?void 0:R.username.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Username",R.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",autoComplete:"username",minLength:3,maxLength:20,value:u.username,onChange:Z,placeholder:"yourname","aria-invalid":!!f.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),f.username&&t.jsx("span",{className:"w-input-err",children:f.username})]}),(R==null?void 0:R.email_address.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Email address",R.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",maxLength:320,value:u.email,onChange:Z,placeholder:"you@company.com","aria-invalid":!!f.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,}$"}),f.email&&t.jsx("span",{className:"w-input-err",children:f.email})]}),(R==null?void 0:R.phone_number.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Phone number",R.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(ys,{value:u.phone_number,onChange:Z,error:f.phone_number,countryCode:b,setCountryCode:j}),f.phone_number&&t.jsx("span",{className:"w-input-err",children:f.phone_number})]}),(R==null?void 0:R.password.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Password",R.password.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"new-password",value:u.password,onChange:Z,placeholder:"Create a password","aria-invalid":!!f.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"}),f.password&&t.jsx("span",{className:"w-input-err",children:f.password})]}),f.submit&&t.jsx("span",{className:"w-input-err",children:f.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e,children:x?t.jsx(gt,{size:15,onAccent:!0}):"Continue"}),(()=>{var de,z;const q=(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!q&&!V?null:t.jsxs("p",{className:"w-fineprint",children:["By continuing you agree to our"," ",q&&t.jsx(St,{className:"w-link w-link--muted",to:q,children:"Terms of Service"}),q&&V&&" and ",V&&t.jsx(St,{className:"w-link w-link--muted",to:V,children:"Privacy Policy"}),"."]})})()]})]})})}function Nc({icon:e,label:a,description:s,onClick:n,disabled:i,type:l="button"}){return t.jsxs("button",{type:l,className:"w-method",onClick:n,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(Qt,{})})]})}const Sc=o.createContext(void 0);function Ec(){const e=o.useContext(Sc);if(!e)throw new Error("useSignIn must be used within a SignInProvider");return e}function pm({children:e}){var j;const{deployment:a}=ke(),[s,n]=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),[h,f]=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 _;const v=(_=a==null?void 0:a.auth_settings)==null?void 0:_.first_factor;!i.current&&v&&(n(v),i.current=!0)},[(j=a==null?void 0:a.auth_settings)==null?void 0:j.first_factor]),t.jsx(Sc.Provider,{value:{email:l,showOtherOptions:c,showForgotPassword:p,otpSent:h,setFirstFactor:n,setEmail:m,setShowOtherOptions:d,setShowForgotPassword:u,setOtpSent:f,enabledSocialsProviders:w,authSettings:b,firstFactor:s,signInStep:g,setSignInStep:x},children:e})}const hm=[{key:"email_magic_link",icon:t.jsx(Ru,{}),label:"Magic link",description:"We'll email you a one-click sign-in link"},{key:"email_password",icon:t.jsx(Mu,{}),label:"Email and password",description:"Sign in with your email and password"},{key:"email_otp",icon:t.jsx(xl,{}),label:"Email one-time code",description:"We'll send a verification code to your email"},{key:"phone_otp",icon:t.jsx(Nu,{}),label:"Phone number",description:"We'll send a verification code via SMS"},{key:"username_password",icon:t.jsx(hs,{}),label:"Username and password",description:"Sign in with your username and password"}];function Ac(){const{deployment:e}=ke(),{signIn:a}=ls("oauth"),{setFirstFactor:s,firstFactor:n,setShowOtherOptions:i,setSignInStep:l}=Ec(),[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)}}},h=hm.filter(x=>{if(x.key===n)return!1;const w=d==null?void 0:d.auth_factors_enabled;return w?w[x.key]:!1}),f=p.length>0,g=h.length>0;return t.jsxs(t.Fragment,{children:[f&&t.jsx(Nr,{connections:p,callback:u}),f&&g&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"or"})}),g&&t.jsx("div",{className:"w-method-stack",children:h.map(x=>t.jsx(Nc,{icon:x.icon,label:x.label,description:x.description,onClick:()=>{s(x.key),l("identifier"),i(!1)}},x.key))})]})}function fm({onBack:e}){var F;const{deployment:a}=ke(),{navigate:s}=_t(),[n,i]=o.useState("start"),[l,m]=o.useState(""),[c,d]=o.useState(""),[p,u]=o.useState(""),[h,f]=o.useState(""),[g,x]=o.useState(""),{forgotPassword:w,verifyOtp:b,resetPassword:j}=Ao(),[v,_]=o.useState(!1),[N,k]=o.useState(null),C=async A=>{if(A.preventDefault(),!!l){_(!0),k(null);try{await w(l),i("otp")}catch(I){k(I)}finally{_(!1)}}},y=async A=>{if(A.preventDefault(),c.length===6){_(!0),k(null);try{const I=await b(l,c);I.data&&(u(I.data.token),i("reset"))}catch(I){k(I)}finally{_(!1)}}},E=async A=>{var I,$;if(A.preventDefault(),h===g&&!(h.length<8)){_(!0),k(null);try{const S=await j(p,h);if(S.data){const Z=S.data,P=Z.signin_attempts&&Z.signin_attempts.length>0?Z.signin_attempts[Z.signin_attempts.length-1]:null;if(P&&!P.completed){const L=(I=a==null?void 0:a.ui_settings)==null?void 0:I.sign_in_page_url;if(L){const H=new URL(L,window.location.origin);H.searchParams.set("signin_attempt_id",P.id),s(H.toString())}else e()}else{const L=(($=a==null?void 0:a.ui_settings)==null?void 0:$.after_signin_redirect_url)||"/";s(L)}}}catch(S){k(S)}finally{_(!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(Pe,{children:[n==="start"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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(Ac,{}),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"})]})]}),n==="email"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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(gt,{size:15,onAccent:!0}):"Send code"})]})]}),n==="otp"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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(va,{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(gt,{size:15,onAccent:!0}):"Verify"})]})]}),n==="reset"&&t.jsxs(et,{footer:M,children:[t.jsx(st,{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:h,onChange:A=>f(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(gt,{size:15,onAccent:!0}):"Reset password"})]})]})]})}function wm({onBack:e}){var n;const{deployment:a}=ke(),s=(n=a==null?void 0:a.ui_settings)==null?void 0:n.app_name;return t.jsx(Pe,{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(st,{title:"All sign-in methods",sub:`Choose another way to sign in to ${s||"your account"}`}),t.jsx(Ac,{})]})})}function Mc({methods:e,onSelectMethod:a,onBack:s}){return t.jsx(Pe,{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(st,{title:"Two-factor authentication",sub:"Choose how you'd like to verify your identity"}),t.jsx("div",{className:"w-method-stack",children:e.map(n=>t.jsx(Nc,{icon:n.icon,label:n.name,description:n.phoneNumber?`${n.description} ${n.phoneNumber}`:n.description,onClick:()=>a(n.id),disabled:!n.available},n.id))})]})})}function Rc({onVerify:e,onBack:a,loading:s}){const[n,i]=o.useState(""),[l,m]=o.useState(""),c=p=>{if(p.preventDefault(),n.length!==4){m("Please enter the last 4 digits of your phone number");return}e(n)},d=p=>{const u=p.target.value.replace(/\D/g,"").slice(0,4);i(u),m("")};return t.jsx(Pe,{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(st,{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:n,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||n.length!==4,children:s?t.jsx(gt,{onAccent:!0}):"Send code"})]})]})})}const gm=()=>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"})}),xm=()=>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"})]}),vm=()=>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 Lc({onBack:e,attempt:a,completeVerification:s,prepareVerification:n}){const{deployment:i}=ke(),[l,m]=o.useState(""),[c,d]=o.useState({}),[p,u]=o.useState(!1),[h,f]=o.useState(null),[g,x]=o.useState(!0),[w,b]=o.useState(!1),[j,v]=o.useState(""),[_,N]=o.useState(!1),{navigate:k}=_t(),C=(a==null?void 0:a.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(gm,{}),available:C.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(xm,{}),available:C.includes("phone_otp"),phoneNumber:j},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(vm,{}),available:C.includes("backup_code")}].filter($=>$.available),E=async $=>{f($),x(!1),$==="phone_otp"&&b(!0)},M=async $=>{var S,Z;if(a){u(!0);try{const P=await n({strategy:"phone_otp",lastDigits:$});P&&"data"in P&&((S=P.data)!=null&&S.otp_sent)?((Z=P.data)!=null&&Z.masked_phone&&v(P.data.masked_phone),b(!1)):d({phone:"Phone number verification failed"})}catch(P){d({phone:P.message})}finally{u(!1)}}},F=async($,S)=>{if($.preventDefault(),p)return;const Z=S||l,P={};if(Z?h==="authenticator"&&Z.length!==6?P.code="Authentication code must be 6 digits":h==="phone_otp"&&Z.length!==6&&(P.code="SMS code must be 6 digits"):P.code="Verification code is required",d(P),!(Object.keys(P).length>0)){u(!0);try{await s(Z)}catch(L){d({submit:L.message})}finally{u(!1)}}},A=$=>{let S=$.target.value;h!=="backup_code"&&(S=S.replace(/\D/g,"").slice(0,6)),m(S),d(Z=>({...Z,code:""}))};if(o.useEffect(()=>{var $;if(a.completed){N(!0);let S=ft(i,new URLSearchParams(window.location.search).get("redirect_uri"));if(S||(S=(($=i==null?void 0:i.ui_settings)==null?void 0:$.after_signin_redirect_url)||null),!S&&(i!=null&&i.frontend_host)&&(S=`https://${i.frontend_host}`),S){let Z;try{Z=new URL(S)}catch{Z=new URL(S,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&Z.searchParams.set("__dev_session__",wt(i.backend_host)||""),k(Z.toString())}return}},[a,i]),_)return t.jsx(js,{});if(g)return y.length===0?t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(st,{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(Mc,{methods:y,onSelectMethod:E,onBack:e});if(w&&h==="phone_otp")return t.jsx(Rc,{onVerify:M,onBack:()=>{b(!1),x(!0),f(null)},loading:p});const I=h==="authenticator"?"Enter the 6-digit code from your authenticator app":h==="phone_otp"?`Enter the 6-digit code sent to your phone ${j}`:"Enter one of your backup codes";return t.jsx(Pe,{children:t.jsxs(et,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(st,{title:"Two-factor authentication",sub:I}),t.jsxs("form",{onSubmit:F,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[h==="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(va,{onComplete:async $=>{if(m($),h!=="backup_code"){const S=new Event("submit",{bubbles:!0,cancelable:!0});await F(S,$)}},onResend:h==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:j.slice(-4)})}catch($){d({submit:$.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(gt,{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),f(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 Pc({attempt:e,onBack:a,completeProfile:s,completeVerification:n,prepareVerification:i}){var O,R,U,W,Y,B,Q,ue,we;const{deployment:l}=ke(),{navigate:m}=_t(),[c,d]=o.useState({}),[p,u]=o.useState({}),[h,f]=o.useState("US"),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(null),[_,N]=o.useState(!1),k=j,C=w,y=()=>{var te;N(!0);let se=ft(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(se||(se=((te=l==null?void 0:l.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!se&&(l!=null&&l.frontend_host)&&(se=`https://${l.frontend_host}`),se){let oe;try{oe=new URL(se)}catch{oe=new URL(se,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&oe.searchParams.set("__dev_session__",wt(l.backend_host)||""),m(oe.toString())}},E=async se=>{b(!0),v(null);try{await s(se)&&y()}catch(te){const oe=te;throw v(oe),oe}finally{b(!1)}},M=async se=>{b(!0),v(null);try{return await n(se)&&y(),!0}catch(te){return v(te),!1}finally{b(!1)}};if(_||!e)return t.jsx(js,{});const F=e.missing_fields||[],A=l==null?void 0:l.auth_settings,I=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||g,$=se=>{const{name:te,value:oe}=se.target;d(Ee=>({...Ee,[te]:oe})),p[te]&&u(Ee=>({...Ee,[te]:""}))},S=()=>{const se={};return F.forEach(te=>{var K,Ge,Ie,Ye,Ae;const oe=c[te];let Ee=!1;switch(te){case"first_name":Ee=((K=A==null?void 0:A.first_name)==null?void 0:K.enabled)||!1;break;case"last_name":Ee=((Ge=A==null?void 0:A.last_name)==null?void 0:Ge.enabled)||!1;break;case"username":Ee=((Ie=A==null?void 0:A.username)==null?void 0:Ie.enabled)||!1;break;case"phone_number":Ee=((Ye=A==null?void 0:A.phone_number)==null?void 0:Ye.enabled)||!1;break;case"email_address":Ee=((Ae=A==null?void 0:A.email_address)==null?void 0:Ae.enabled)||!1;break;default:Ee=!0}if(Ee&&(!oe||oe.trim()==="")){const ce=te.replace("_"," ").replace(/\b\w/g,D=>D.toUpperCase());se[te]=`${ce} is required`}}),c.username&&F.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(c.username)||(se.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)||(se.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)||(se.email_address="Please enter a valid email address")),u(se),Object.keys(se).length===0},Z=async se=>{if(se.preventDefault(),!S())return;const te={...c};c.phone_number&&h&&(te.phone_country_code=h),await E(te)},P=se=>{const te=se.target.value;d(oe=>({...oe,phone_number:te})),p.phone_number&&u(oe=>({...oe,phone_number:""}))},L=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{to:(l==null?void 0:l.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]});if(I){const se=e.current_step==="verify_phone_otp"?"Verify your phone number":"Verify your email",te=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",oe=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx(Pe,{children:t.jsxs(et,{footer:L,children:[t.jsx(st,{title:se,sub:te}),t.jsxs("form",{onSubmit:Ee=>Ee.preventDefault(),noValidate:!0,style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsx(va,{onComplete:M,onResend:async()=>{await i({strategy:oe})},error:k==null?void 0:k.message,isSubmitting:C}),k&&t.jsx("span",{className:"w-input-err",children:k.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 H=!!((O=A==null?void 0:A.first_name)!=null&&O.enabled&&((R=A==null?void 0:A.last_name)!=null&&R.enabled)&&F.includes("first_name")&&F.includes("last_name"));return t.jsx(Pe,{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"})}):L,children:[t.jsx(st,{title:"Complete your profile",sub:"Please provide the following information to continue"}),t.jsxs("form",{onSubmit:Z,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)||((W=A==null?void 0:A.last_name)==null?void 0:W.enabled))&&t.jsxs("div",{className:H?"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:$,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:$,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:$,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(ys,{value:c.phone_number||"",onChange:P,error:p.phone_number,countryCode:h,setCountryCode:f}),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:$,placeholder:"Enter your email address",disabled:C,autoComplete:"email"}),p.email_address&&t.jsx("span",{className:"w-input-err",children:p.email_address})]}),k&&t.jsx("span",{className:"w-input-err",children:k.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:C,children:C?t.jsx(gt,{onAccent:!0}):"Continue"})]})]})})}function $c({onComplete:e,onSkip:a}){var u;const[s,n]=o.useState(!1),[i,l]=o.useState(null),{registerPasskey:m}=xa(),{deployment:c}=ke(),d=async()=>{n(!0),l(null);try{await m(),e==null||e()}catch(h){l(h instanceof Error?h.message:"Failed to register passkey")}finally{n(!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(ar,{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(gt,{size:15,onAccent:!0}),"Registering…"]}):t.jsxs(t.Fragment,{children:[t.jsx(ar,{}),"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 bm(){return t.jsx(pm,{children:t.jsx(ym,{})})}function ym(){var Wt,ba,ya,bt,aa,sa,na,ra,ie,xe,Ne,J,ve,qe,Ve,yt,jt,We,ht,Bt,ia,oa,la;const{deployment:e}=ke(),{navigate:a}=_t(),{session:s,loading:n,refetch:i,exchangeTicket:l,switchSignIn:m}=rt(),c=((ba=(Wt=e==null?void 0:e.auth_settings)==null?void 0:Wt.multi_session_support)==null?void 0:ba.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:u,showForgotPassword:h,setShowForgotPassword:f,showOtherOptions:g,setShowOtherOptions:x,enabledSocialsProviders:w,firstFactor:b,setFirstFactor:j,signInStep:v,setSignInStep:_}=Ec(),{loading:N,signIn:k,signinAttempt:C,discardSignInAttempt:y,setSignInAttempt:E}=ls("generic"),{signIn:M}=ls("oauth"),{signIn:F}=ls("passkey"),[A,I]=o.useState({email:"",username:"",password:"",phone:""}),[$,S]=o.useState({}),[Z,P]=o.useState(!1),[L,H]=o.useState(""),[O,R]=o.useState("US"),[U,W]=o.useState(!1),[Y,B]=o.useState(null),[Q,ue]=o.useState(!1),[we,se]=o.useState(!1),[te,oe]=o.useState(!1),[Ee,K]=o.useState(60),[Ge,Ie]=o.useState(!1),[Ye,Ae]=o.useState(null),ce=[...(s==null?void 0:s.signins)||[]].sort((ee,ae)=>{var pe,Oe;return ee.id===((pe=s==null?void 0:s.active_signin)==null?void 0:pe.id)?-1:ae.id===((Oe=s==null?void 0:s.active_signin)==null?void 0:Oe.id)?1:0});o.useEffect(()=>{const ee=new URLSearchParams(window.location.search),ae=ee.get("error"),pe=ee.get("error_description");if(ae==="access_denied"&&pe){B(pe),ee.delete("error"),ee.delete("error_description");const Oe=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Oe)}},[]),o.useEffect(()=>{if(b!=="email_magic_link"||!p)return;K(60),Ie(!1);const ee=setInterval(()=>{K(ae=>ae<=1?(Ie(!0),clearInterval(ee),0):ae-1)},1e3);return()=>clearInterval(ee)},[b,p]),o.useEffect(()=>{var ee,ae,pe,Oe;if(!n&&(s!=null&&s.active_signin)&&!c&&!U&&!Q){let Re=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));Re||(Re=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!Re&&(e!=null&&e.frontend_host)&&(Re=`https://${e.frontend_host}`);const ct=(ae=e==null?void 0:e.auth_settings)==null?void 0:ae.passkey;(ct==null?void 0:ct.enabled)&&(ct==null?void 0:ct.prompt_registration_on_auth)&&!((Oe=(pe=s.active_signin)==null?void 0:pe.user)!=null&&Oe.has_passkeys)?(Ae(Re),ue(!0)):Re&&(W(!0),a(Re))}},[s,n,c,e,a,U]);const D=ee=>{let{name:ae,value:pe}=ee.target;ae==="phone"?pe=pe.replace(/[^0-9]/g,""):ae==="email"&&(d(pe),pe=pe.toLowerCase()),I(Oe=>({...Oe,[ae]:pe})),S(Oe=>({...Oe,[ae]:""}))},G=()=>{I({email:"",username:"",password:"",phone:""}),S({}),R("US"),_("identifier")},q=async ee=>{if(!ee){S({email:"Email address is required"});return}P(!0),S({});try{const ae=await k.identify(ee);if(ae.strategy==="sso"&&ae.connection_id){const pe=new URLSearchParams(window.location.search),Oe=ft(e,pe.get("redirect_uri"))||void 0,Re=await k.initEnterpriseSso(ae.connection_id,Oe);if(Re&&Re.sso_url){W(!0),window.location.href=Re.sso_url;return}}else if(ae.strategy==="social"&&ae.provider){const pe=w.find(Oe=>Oe.provider===ae.provider);if(pe){const Oe=new URLSearchParams(window.location.search),Re=ft(e,Oe.get("redirect_uri"))||void 0,{data:ct}=await M.create({provider:pe.provider,redirectUri:Re});if(ct&&typeof ct=="object"&&"oauth_url"in ct){W(!0),window.location.href=ct.oauth_url;return}}else _("password")}else _("password")}catch(ae){S({submit:ae.message})}finally{U||P(!1)}},V=async ee=>{if(ee.preventDefault(),N||Z)return;y();const ae={};if(v==="identifier"&&b==="email_password"){if(!A.email){S({email:"Email address is required"});return}await q(A.email);return}if(v==="identifier"&&b==="username_password"){if(!A.username){S({username:"Username is required"});return}S({}),_("password");return}if(b==="email_password"?(A.email||(ae.email="Email address is required"),A.password||(ae.password="Password is required")):b==="username_password"?(A.username||(ae.username="Username is required"),A.password||(ae.password="Password is required")):b==="email_otp"||b==="email_magic_link"?A.email||(ae.email="Email address is required"):b==="phone_otp"&&(A.phone?/^\d{7,15}$/.test(A.phone)||(ae.phone="Phone number must contain 7-15 digits"):ae.phone="Phone number is required"),S(ae),Object.keys(ae).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 Oe=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";P(!0);try{const Re={...A,strategy:pe};b==="phone_otp"&&O&&(Re.phone_country_code=O),await k.create(Re),Oe||P(!1)}catch(Re){S({submit:Re.message}),P(!1)}},de=async ee=>{if(ee.preventDefault(),N||Z)return;const ae={};if(!L){ae.otp="OTP code is required",S(ae);return}P(!0),S({});try{await k.completeVerification(L),u(!1),H("")}catch(pe){S({otp:pe.message||"Verification failed"})}finally{P(!1)}},z=async ee=>{if(!(N||Z)){P(!0);try{const ae=new URLSearchParams(window.location.search),pe=ft(e,ae.get("redirect_uri"))||void 0,{data:Oe}=await M.create({provider:ee.provider,redirectUri:pe});Oe&&typeof Oe=="object"&&"oauth_url"in Oe&&(window.location.href=Oe.oauth_url)}catch(ae){S({submit:ae.message})}finally{P(!1)}}},le=async()=>{var ee;if(!(N||Z)){P(!0),S({});try{const ae=await F.create();if("data"in ae&&ae.data){await i();let pe=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));pe||(pe=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!pe&&(e!=null&&e.frontend_host)&&(pe=`https://${e.frontend_host}`),W(!0),pe&&a(pe)}}catch(ae){S({submit:ae.message||"Passkey sign-in failed"})}finally{P(!1)}}},Je=()=>{var pe;let ee=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(ee||(ee=((pe=e==null?void 0:e.ui_settings)==null?void 0:pe.after_signin_redirect_url)||null),!ee&&(e!=null&&e.frontend_host)&&(ee=`https://${e.frontend_host}`),!ee)return null;let ae;try{ae=new URL(ee)}catch{ae=new URL(ee,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&ae.searchParams.set("__dev_session__",wt(e.backend_host)||""),ae.toString()},it=async ee=>{if(!(N||Z)){S({}),P(!0);try{await m(ee);const ae=Je();ae&&(W(!0),a(ae))}catch(ae){S({submit:ae.message||"Failed to continue with selected account"})}finally{P(!1)}}},ge=(ee,ae)=>`${ee||""} ${ae||""}`.trim().split(" ").filter(Boolean).map(pe=>pe[0]).join("").toUpperCase().slice(0,2)||"?",ot=o.useRef(!1);if(o.useEffect(()=>{if(n)return;const ee=new URLSearchParams(window.location.search),ae=ee.get("ticket");if(ae&&!ot.current&&!N){ot.current=!0,ee.delete("ticket");const Oe=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Oe),(async()=>{var ct;try{P(!0),await l(ae),W(!0);let Tt=ft(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(Tt||(Tt=((ct=e==null?void 0:e.ui_settings)==null?void 0:ct.after_signin_redirect_url)||null),!Tt&&(e!=null&&e.frontend_host)&&(Tt=`https://${e.frontend_host}`),Tt){let Ns;try{Ns=new URL(Tt)}catch{Ns=new URL(Tt,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Ns.searchParams.set("__dev_session__",wt(e.backend_host)||""),a(Ns.toString())}return}catch(Tt){S({submit:Tt.message||"Failed to exchange ticket"}),ot.current=!1}finally{P(!1)}})();return}const pe=ee.get("signin_attempt_id");if(pe&&(s!=null&&s.signin_attempts)&&!C){const Oe=s.signin_attempts.find(Re=>Re.id===pe);if(Oe){E(Oe),ee.delete("signin_attempt_id");const Re=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Re)}}},[s,n,C,E,N]),o.useEffect(()=>{var Oe;if(!C)return;if(C.completed){W(!0);let Re=new URLSearchParams(window.location.search).get("redirect_uri");if(Re||(Re=((Oe=e==null?void 0:e.ui_settings)==null?void 0:Oe.after_signin_redirect_url)||null),!Re&&(e!=null&&e.frontend_host)&&(Re=`https://${e.frontend_host}`),Re){let ct;try{ct=new URL(Re)}catch{ct=new URL(Re,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&ct.searchParams.set("__dev_session__",wt(e.backend_host)||""),a(ct.toString())}return}if(!k||p)return;const ae={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(!ae)return;(async()=>{try{await k.prepareVerification({strategy:ae}),P(!1),u(!0)}catch{S({submit:"Failed to send verification. Please try again."}),P(!1)}})()},[C,k,p,u,a,e]),g)return t.jsx(wm,{onBack:()=>x(!1)});if(h)return t.jsx(fm,{onBack:()=>f(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return t.jsx(Lc,{attempt:C,completeVerification:k.completeVerification,prepareVerification:k.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return t.jsx(Pc,{attempt:C,completeProfile:k.completeProfile,completeVerification:k.completeVerification,prepareVerification:k.prepareVerification,onBack:()=>{y(),G(),u(!1)}});if(Q){const ee=()=>{ue(!1),Ye&&(W(!0),a(Ye))},ae=()=>{ue(!1),Ye&&(W(!0),a(Ye))};return t.jsx(Pe,{children:t.jsx(et,{children:t.jsx($c,{onComplete:ee,onSkip:ae})})})}if(n||U)return t.jsx(js,{});const X=((ya=e==null?void 0:e.ui_settings)==null?void 0:ya.app_name)||"App",me=(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,Le=b==="email_magic_link",Me=c&&!me&&ce.length>0&&!te,Qe=()=>{u(!1),y(),G()};let vt;if(me){const ee=b==="phone_otp"?"Check your phone":Le?"Check your inbox":"Enter the code",ae=Le?"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"||Le)&&A.email?A.email:b==="phone_otp"&&A.phone?`+${A.phone}`:null;vt=t.jsx(st,{title:ee,sub:ae,children:pe&&t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:Qe,children:[t.jsx(Al,{weight:"bold"}),pe]})})}else vt=t.jsx(st,{title:"Sign in to your account",sub:`Please enter your details to continue to ${X}.`});let Ut;me?Ut=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(St,{className:"w-link",to:((bt=e==null?void 0:e.ui_settings)==null?void 0:bt.support_page_url)||"#",children:"Get help"})]}):Ut=t.jsxs("span",{className:"w-auth-foot",children:["Don't have an account?"," ",t.jsx(St,{className:"w-link",to:`${((aa=e==null?void 0:e.ui_settings)==null?void 0:aa.sign_up_page_url)??""}${window.location.search}`,children:"Sign up"})]});let Ft;if(me&&Le)Ft=t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,padding:"12px 0 4px"},children:Ge?t.jsx("button",{type:"button",className:"w-link w-linkbtn",onClick:async()=>{Ie(!1),K(60);try{await k.prepareVerification({strategy:"magic_link"})}catch{}},children:"Resend magic link"}):t.jsxs("span",{className:"w-secsub",children:["Resend in ",Ee,"s"]})});else if(me)Ft=t.jsxs("form",{onSubmit:de,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(va,{onComplete:async ee=>{if(H(ee),ee&&ee.length===6){P(!0),S({});try{await k.completeVerification(ee),u(!1)}catch(ae){S({otp:ae.message||"Verification failed"})}finally{P(!1)}}},onResend:async()=>{const ee=b==="email_otp"?"email_otp":"phone_otp";await k.prepareVerification({strategy:ee})},error:$.otp,isSubmitting:Z}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:Z||N||!L,children:Z&&L?t.jsx(gt,{size:15,onAccent:!0}):`Continue to ${X}`})]});else{const ee=(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((na=(sa=e==null?void 0:e.auth_settings)==null?void 0:sa.email_address)==null?void 0:na.enabled),ae=b==="username_password"&&((ie=(ra=e==null?void 0:e.auth_settings)==null?void 0:ra.username)==null?void 0:ie.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),Oe=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);Ft=t.jsxs(t.Fragment,{children:[w.length>0&&t.jsx(Nr,{connections:w,callback:z}),((Ve=(qe=e==null?void 0:e.auth_settings)==null?void 0:qe.passkey)==null?void 0:Ve.enabled)&&t.jsxs("button",{type:"button",className:"w-social",style:{marginTop:w.length>0?10:0},onClick:le,disabled:Z,children:[t.jsx(ar,{}),t.jsx("span",{children:"Sign in with a passkey"})]}),(w.length>0||((jt=(yt=e==null?void 0:e.auth_settings)==null?void 0:yt.passkey)==null?void 0:jt.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:[ee&&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(ui,{})}),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:()=>_("identifier"),children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",value:A.email,onChange:D,placeholder:"you@company.com","aria-invalid":!!$.email}),$.email&&t.jsx("span",{className:"w-input-err",children:$.email})]}),ae&&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(ui,{})}),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:()=>{_("identifier"),I(Re=>({...Re,password:""}))},children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",value:A.username,onChange:D,placeholder:"yourname","aria-invalid":!!$.username,autoComplete:"username"}),$.username&&t.jsx("span",{className:"w-input-err",children:$.username})]}),pe&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(ys,{value:A.phone,onChange:D,error:$.phone,countryCode:O,setCountryCode:R}),$.phone&&t.jsx("span",{className:"w-input-err",children:$.phone})]}),Oe&&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:()=>f(!0),children:"Forgot?"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"current-password",value:A.password,onChange:D,placeholder:"••••••••","aria-invalid":!!$.password}),$.password&&t.jsx("span",{className:"w-input-err",children:$.password})]}),$.submit&&t.jsx("span",{className:"w-input-err",children:$.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:Z||N,children:Z?t.jsx(gt,{size:15,onAccent:!0}):t.jsxs(t.Fragment,{children:[v==="identifier"?"Continue":"Sign in",t.jsx(Qt,{weight:"bold"})]})}),v==="password"&&((ht=(We=e==null?void 0:e.auth_settings)==null?void 0:We.auth_factors_enabled)==null?void 0:ht.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:Z,onClick:async()=>{P(!0),S({});try{await k.create({email:A.email,strategy:"email_otp"}),j("email_otp")}catch(Re){S({submit:Re.message}),P(!1)}},children:[t.jsx("span",{className:"w-method-ic",children:t.jsx(xl,{})}),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(Qt,{})})]})]})]})]})}return t.jsx(Pe,{children:t.jsxs(et,{footer:Ut,children:[vt,Y&&t.jsxs("div",{className:"w-banner w-banner--error",style:{marginBottom:18},children:[t.jsx(Fa,{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"})]})]}),Me&&(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(ee=>{var ae,pe,Oe,Re;return t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>it(ee.id),disabled:Z||N,children:[t.jsx("span",{className:"w-avatar",children:ee.user.has_profile_picture?t.jsx("img",{src:ee.user.profile_picture_url,alt:((ae=ee.user.primary_email_address)==null?void 0:ae.email)||"account"}):ge(ee.user.first_name,ee.user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsx("span",{className:"w-acct-name",children:ee.user.first_name&&ee.user.last_name?`${ee.user.first_name} ${ee.user.last_name}`:ee.user.first_name||((Oe=(pe=ee.user.primary_email_address)==null?void 0:pe.email)==null?void 0:Oe.split("@")[0])||"Account"}),t.jsx("span",{className:"w-secsub",children:(Re=ee.user.primary_email_address)==null?void 0:Re.email})]}),t.jsx(Qt,{className:"w-acct-go"})]},ee.id)}),t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>{se(!1),oe(!0),G()},children:[t.jsx("span",{className:"w-avatar",style:{background:"var(--wa-surface-subtle)",color:"var(--wa-text-muted)"},children:t.jsx(Hu,{size:16})}),t.jsx("span",{className:"w-acct-text w-acct-name",children:"Use a different account"}),t.jsx(Qt,{className:"w-acct-go"})]})]})]}):t.jsxs("button",{type:"button",className:"w-acct","data-active":!0,style:{marginBottom:18},onClick:()=>it(ce[0].id),disabled:Z||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:((Bt=ce[0].user.primary_email_address)==null?void 0:Bt.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||((oa=(ia=ce[0].user.primary_email_address)==null?void 0:ia.email)==null?void 0:oa.split("@")[0])||"back"]}),t.jsx("span",{className:"w-secsub",children:(la=ce[0].user.primary_email_address)==null?void 0:la.email})]}),t.jsx("span",{className:"w-link w-link--muted w-link--sm",style:{flex:"none"},onClick:ee=>{ee.stopPropagation(),ce.length>1?se(!0):(oe(!0),G())},children:"Not you?"})]})),Ft]})})}function jm(){var b,j,v,_,N,k,C,y,E,M,F,A;const{deployment:e}=ke(),{loading:a,joinWaitlist:s}=No(),[n,i]=o.useState({first_name:"",last_name:"",email:""}),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(null),h=()=>{if(p)return p.message},f=e==null?void 0:e.auth_settings,g=!!((b=f==null?void 0:f.first_name)!=null&&b.enabled&&((j=f==null?void 0:f.last_name)!=null&&j.enabled)),x=I=>{const{name:$,value:S}=I.target;i(Z=>({...Z,[$]:S}))},w=async I=>{if(I.preventDefault(),!!f){d(!0),u(null);try{(await s(n)).data&&m(!0)}catch($){u($)}finally{d(!1)}}};return l?t.jsx(Pe,{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(Be,{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"," ",n.email," when we're ready for you to join."]})]})})}):t.jsx(Pe,{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(st,{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=f==null?void 0:f.first_name)==null?void 0:v.enabled)||((_=f==null?void 0:f.last_name)==null?void 0:_.enabled))&&t.jsxs("div",{className:g?"w-grid-2":"",children:[((N=f==null?void 0:f.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",((k=f==null?void 0:f.first_name)==null?void 0:k.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"first_name",name:"first_name",required:(C=f==null?void 0:f.first_name)==null?void 0:C.required,minLength:2,maxLength:50,value:n.first_name,onChange:x,placeholder:"First name"})]}),((y=f==null?void 0:f.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=f==null?void 0:f.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=f==null?void 0:f.last_name)==null?void 0:M.required,minLength:2,maxLength:50,value:n.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=f==null?void 0:f.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=f==null?void 0:f.email_address)==null?void 0:A.required,value:n.email,onChange:x,placeholder:"Enter your email address"})]}),h()&&t.jsx("span",{className:"w-input-err",children:h()}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:c||a,children:c||a?t.jsx(gt,{onAccent:!0}):"Join waitlist"})]})]})})}function On({title:e,sub:a,icon:s,message:n,action:i,footer:l}){return t.jsx(Pe,{children:t.jsxs(et,{footer:l,children:[t.jsx(st,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:n}),i]})]})})}function _m(){const{deployment:e}=ke(),{navigate:a}=_t(),{error:s,session:n,processed:i,signinAttempt:l,redirectUri:m,loading:c}=So(),[d,p]=o.useState(!1),[u,h]=o.useState(null),f=()=>{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,_,N;if(!(!i||c||d)){if(l&&!l.completed){const k=(b=e==null?void 0:e.ui_settings)==null?void 0:b.sign_in_page_url;if(k){const C=new URL(k,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=ft(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__",wt(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=(_=n==null?void 0:n.active_signin)==null?void 0:_.user)!=null&&N.has_passkeys)?(h(y.toString()),p(!0)):a(y.toString())}}}},[n,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(Pe,{children:t.jsx(et,{children:t.jsx($c,{onComplete:x,onSkip:w})})});if(n&&i&&!s)return t.jsx(On,{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(Be,{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(On,{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(La,{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:f,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(On,{title:"Completing sign in",sub:"Please wait while we authenticate you",icon:t.jsx(gt,{size:32}),message:"Verifying your credentials… this will only take a moment."})}function km({onSuccess:e,onError:a}={}){const[s,n]=o.useState("loading"),[i,l]=o.useState(""),{token:m,attempt:c,redirectUri:d}=W1(),{verifyMagicLink:p}=Eo(),{navigate:u}=_t(),{deployment:h}=ke(),f=o.useRef(!1);o.useEffect(()=>{(async()=>{if(!f.current){if(!m||!c){n("error"),l("The magic link appears to be malformed. Please try signing in again."),a==null||a("Invalid magic link parameters");return}f.current=!0,n("loading"),l("Please wait while we verify your magic link.");try{await p({token:m,attempt:c,redirectUri:d}),n("success"),l("You will be redirected to your account shortly."),e==null||e(),setTimeout(()=>{var b;let w=ft(h,d);if(w||(w=(b=h==null?void 0:h.ui_settings)==null?void 0:b.after_signin_redirect_url),!w&&(h!=null&&h.frontend_host)&&(w=`https://${h.frontend_host}`),w){const j=new URL(w);(h==null?void 0:h.mode)==="staging"&&j.searchParams.set("__dev_session__",wt(h.backend_host)||""),u(j.toString())}},2e3)}catch(w){n("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=h==null?void 0:h.ui_settings)!=null&&x.sign_in_page_url&&u(h.ui_settings.sign_in_page_url)};return t.jsx(Pe,{children:t.jsxs(et,{children:[t.jsx(st,{title:"Magic link",sub:"Verifying your magic link"}),t.jsxs("div",{className:"w-auth-status",children:[s==="loading"&&t.jsx(gt,{size:32}),s==="success"&&t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Be,{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(La,{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 Cm(e){var n,i;return e?((n=e.signin_attempts)==null?void 0:n.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 Nm(e){const a=e?`/profile-completion?redirect_uri=${encodeURIComponent(e)}`:"/profile-completion";window.location.href=a}function ns({kind:e}){const a=e==="success"?"w-success":e==="error"?"w-success w-success--error":"w-success w-success--info",s=e==="success"?Be:e==="error"?La:Au;return t.jsxs("div",{className:a,children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(s,{weight:"bold"})})]})}function _a({title:e,sub:a,icon:s,message:n,action:i,footer:l}){return t.jsx(Pe,{children:t.jsxs(et,{footer:l,children:[t.jsx(st,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:n}),i]})]})})}function Sm({token:e,onSuccess:a,onError:s}){var b;const{acceptInvitation:n,invitationData:i,loading:l,error:m}=Ho(),{navigate:c}=_t(),{deployment:d}=ke(),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:ft(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,n(j))},[n]),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 h=()=>{const{redirectUri:j}=u();c(j)},f=()=>{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",_=((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?_:v}?${N.toString()}`)},g=()=>{const{token:j}=u();j&&(p.current=!1,n(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(_a,{title:"Invalid invitation",sub:"No invitation token found",icon:t.jsx(ns,{kind:"error"}),message:"The invitation link appears to be invalid or incomplete.",action:x("Go to home",()=>c("/"))});if(l)return t.jsx(_a,{title:"Processing invitation",sub:"Please wait while we verify your invitation",icon:t.jsx(gt,{size:32}),message:"Verifying invitation… this will only take a moment."});if(i!=null&&i.organization&&!i.requires_signin)return t.jsx(_a,{title:"Invitation accepted",sub:"You've successfully joined the organization",icon:t.jsx(ns,{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",h)});if(i!=null&&i.already_member)return t.jsx(_a,{title:"Already a member",sub:"You're already part of this organization",icon:t.jsx(ns,{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",h)});if(i!=null&&i.requires_signin){const j=i.error_code==="INVITATION_REQUIRES_SIGNUP";return t.jsx(_a,{title:j?"Sign up required":"Sign in required",sub:"To accept this invitation",icon:t.jsx(ns,{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",f)})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?t.jsx(_a,{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(Cu,{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(_a,{title:"Invitation error",sub:"Unable to process invitation",icon:t.jsx(ns,{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:f,children:"Sign in manually"})]})}):null}const Oc=o.createContext(void 0),Zc=()=>{const e=o.useContext(Oc);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},Em=({isOpen:e,onClose:a,children:s})=>{const[n,i]=o.useState(!1),l=ts();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||!n?null:en.createPortal(t.jsx("div",{className:"wacht-root",style:l,children:t.jsx(Oc.Provider,{value:{isOpen:e,onClose:a},children:s})}),document.body)},Am=({children:e})=>{const{onClose:a}=Zc(),s=o.useRef(null),n=i=>{s.current&&!s.current.contains(i.target)&&(a==null||a())};return t.jsx("div",{className:"w-modal",onClick:n,children:t.jsx("div",{ref:s,style:{maxWidth:"100%",minWidth:0},children:e})})},Mm=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog${s?` ${s}`:""}`,style:{maxHeight:"90vh",overflowY:"auto",...a},children:e}),Rm=({children:e,showCloseButton:a=!0})=>{const{onClose:s}=Zc();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(La,{size:18})})]})},Lm=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog-body${s?` ${s}`:""}`,style:a,children:e}),Pm=({children:e})=>t.jsx("div",{className:"w-dialog-foot",children:e}),ze=Object.assign(Em,{Overlay:Am,Content:Mm,Header:Rm,Body:Lm,Footer:Pm}),$m=({isOpen:e,onClose:a,title:s,children:n,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:n})]})})}),Om=({trigger:e,renderDialog:a})=>{const[s,n]=o.useState(!1),i=()=>n(!0),l=()=>n(!1);return t.jsxs(t.Fragment,{children:[e({onClick:i}),a({isOpen:s,onClose:l})]})},Hc=o.createContext(void 0),Fc=()=>{const e=o.useContext(Hc);if(!e)throw new Error("useDropdownContext must be used within a DropdownProvider");return e},_s=({children:e,open:a,openChange:s,style:n})=>{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(Hc.Provider,{value:{open:l,openChange:c=>m(c)},children:t.jsx("div",{style:{width:"fit-content",...n},ref:i,children:e})})},ks=({children:e,style:a,className:s})=>{const{open:n}=Fc(),[i,l]=o.useState({top:0,left:0}),[m,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{n&&d.current?(c(!1),requestAnimationFrame(()=>{var h,f;const p=(h=d.current)==null?void 0:h.parentElement;if(!p)return;const u=p.querySelector("[data-dropdown-trigger]")||p.firstElementChild;if(u&&u!==d.current){const g=u.getBoundingClientRect(),x=(f=d.current)==null?void 0:f.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)},[n]),n?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},Cs=({children:e})=>{const{openChange:a,open:s}=Fc(),n=o.useCallback(()=>{a(!s)},[s,a]);return t.jsx("div",{style:{position:"relative",display:"inline-flex"},onClick:n,"data-dropdown-trigger":!0,children:e})},ea=o.forwardRef(({$destructive:e,className:a,...s},n)=>t.jsx("button",{ref:n,className:`w-menu-item${e?" w-menu-item--danger":""}${a?` ${a}`:""}`,...s}));ea.displayName="DropdownItem";const Tc=()=>t.jsx("div",{style:{height:"0.5px",background:"var(--wa-border)",width:"100%",margin:"4px 0"}}),Ic=o.forwardRef(({className:e,style:a,...s},n)=>t.jsx("form",{ref:n,className:e,style:{display:"flex",flexDirection:"column",gap:16,...a},...s}));Ic.displayName="Form";const Ue=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:`w-field${e?` ${e}`:""}`,...a}));Ue.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},n)=>{const i=`w-input${a?` ${a}`:""}`;return e==="textarea"?t.jsx("textarea",{className:i,...s}):t.jsx("input",{ref:n,className:i,...s})});be.displayName="Input";const je=({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}})}),Za=({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"})})]}),Kt=(e=!1)=>{const[a,s]=o.useState(e),n=o.useCallback(()=>{s(!0)},[]),i=o.useCallback(()=>{s(!1)},[]),l=o.useCallback(()=>{s(m=>!m)},[]);return{isOpen:a,open:n,close:i,toggle:l}},Vc=({onChange:e,placeholder:a,value:s})=>t.jsxs("div",{className:"w-search",children:[t.jsx(Cl,{}),t.jsx("input",{type:"text",placeholder:a,value:s,onChange:n=>e(n.target.value)})]}),ne=o.forwardRef(({$primary:e,$outline:a,$destructive:s,$fullWidth:n,$size:i,className:l,style:m,...c},d)=>{const h=`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:h,style:n?{width:"100%",...m}:m,...c})});ne.displayName="Button";const zc=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"}),Dc={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},Qs=({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}),un=({options:e,value:a,onChange:s,placeholder:n="Select an option",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[h,f]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],_=(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,k=(y,E=!1)=>{E||(s(y),f(!1),x(""))},C=()=>{i||f(!h)};return o.useEffect(()=>{h&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[h,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(f(!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":h?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":h,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":_?void 0:"",children:_?_.label:n}),h?t.jsx(Jo,{size:16}):t.jsx(Dt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:zc(h),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Dc,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(Qs,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a||""})]})},Uc=({options:e,value:a,onChange:s,placeholder:n="Select options",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[h,f]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],_=(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,k=(y,E=!1)=>{E||(a.includes(y)?s(a.filter(M=>M!==y)):s([...a,y]))},C=()=>{i||f(!h)};return o.useEffect(()=>{h&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[h,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(f(!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":h?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":h,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":_.length>0?void 0:"",children:_.length>0?_.map(y=>y.label).join(", "):n}),h?t.jsx(Jo,{size:16}):t.jsx(Dt,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:zc(h),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Dc,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(Qs,{children:"No options available"}):y.options.map(M=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":M.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},M.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>k(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(Be,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a.join(",")})]})},Os=e=>e.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)||"?",Ei=e=>e.trim().replace(/[<>"'&]/g,""),Zm=e=>e.length>=2&&e.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(e),Hm=e=>/.+@.+\..+/.test(e),Ai=(e,a)=>e.length?e.find(s=>s.name===a)||e[0]:null,Fm=({roles:e,value:a,onChange:s,fullWidth:n})=>{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${n?" w-full":" w-none"}`,children:[t.jsxs("button",{type:"button",className:`w-combo${n?" 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(Dt,{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(Be,{size:13})})]},c.id))})]})},Wc=({mode:e,organizationId:a,onSuccess:s,onCancel:n,onCreateOrganization:i})=>{var ce;const l=e==="org",m=l?"organization":"workspace",c=l?"Organization":"Workspace",{createOrganization:d,getOrganizationRoles:p,inviteOrganizationMember:u}=Vt(),{createWorkspace:h,getWorkspaceRoles:f,createWorkspaceInvitation:g}=ga(),{organizationMemberships:x}=wa(),{refetch:w}=rt(),[b,j]=o.useState(0),[v,_]=o.useState(""),[N,k]=o.useState(""),[C,y]=o.useState(),[E,M]=o.useState(null),[F,A]=o.useState(!1),[I,$]=o.useState(null),[S,Z]=o.useState(a),[P,L]=o.useState(!1),H=o.useRef(null),O=o.useRef(null),[R,U]=o.useState(null),[W,Y]=o.useState([]),[B,Q]=o.useState([]),[ue,we]=o.useState(""),[se,te]=o.useState(null),oe=(ce=x==null?void 0:x.find(D=>D.organization.id===S))==null?void 0:ce.organization;o.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]),o.useEffect(()=>{if(!P)return;const D=G=>{H.current&&!H.current.contains(G.target)&&L(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[P]);const Ee=D=>{var q;const G=(q=D.target.files)==null?void 0:q[0];if(G){if(G.size>2*1024*1024){$("Image must be under 2 MB.");return}if(!G.type.startsWith("image/")){$("Please choose a valid image file.");return}E&&URL.revokeObjectURL(E),$(null),y(G),M(URL.createObjectURL(G))}},K=async()=>{var q;const D=Ei(v),G=Ei(N);if(!Zm(D)){$(`Enter a valid ${m} name (2–100 characters).`);return}if(!l&&!S){$("Select an organization first.");return}A(!0),$(null);try{if(l){const V=await d({name:D,description:G,image:C}),de=((q=V==null?void 0:V.data)==null?void 0:q.organization)??(V==null?void 0:V.organization)??V;U(de);const z=await p(de).catch(()=>[]);Y(z),te(Ai(z,"Member"))}else{const V=await h(S,D,C,G),de=(V==null?void 0:V.workspace)??V,z={...de,organization:{id:S}};U(z);const le=await f(de).catch(()=>[]);Y(le),te(Ai(le,"Editor"))}await w(),j(1)}catch(V){$((V==null?void 0:V.message)||`Failed to create ${m}.`)}finally{A(!1)}},Ge=()=>{const D=ue.trim();!Hm(D)||B.some(G=>G.email===D)||se&&(Q(G=>[...G,{email:D,roleId:se.id,roleName:se.name}]),we(""))},Ie=D=>{(D.key==="Enter"||D.key===",")&&(D.preventDefault(),Ge())},Ye=async()=>{if(!B.length){j(2);return}A(!0),$(null);try{for(const D of B)l?await u(R,{email:D.email,organizationRole:{id:D.roleId}}):await g(R,D.email,D.roleId);j(2)}catch(D){$((D==null?void 0:D.message)||"Some invitations could not be sent.")}finally{A(!1)}},Ae=()=>{j(0),_(""),k(""),y(void 0),E&&URL.revokeObjectURL(E),M(null),U(null),Y([]),Q([]),we(""),$(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 D;return(D=O.current)==null?void 0:D.click()},title:`Upload ${m} logo`,"aria-label":`Upload ${m} logo`,children:[E?t.jsx("img",{src:E,alt:`${c} logo`}):l?t.jsx(ps,{}):t.jsx(di,{}),t.jsx("span",{className:"w-avatar-veil",children:t.jsx(sn,{})})]}),t.jsx("input",{ref:O,type:"file",className:"w-none",hidden:!0,accept:"image/png, image/jpeg, image/gif, image/svg+xml",onChange:Ee,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(La,{})})]}):t.jsx("span",{className:`w-ibadge${b===2?" w-ibadge--done":""}`,children:b===2?t.jsx(Be,{}):l?t.jsx(ps,{}):t.jsx(di,{})}),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})]}),I&&t.jsx("div",{className:"w-banner w-banner--error w-mb-4",children:I}),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:H,children:[t.jsxs("button",{type:"button",className:"w-combo w-full","data-open":P?"":void 0,onClick:()=>L(D=>!D),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:oe!=null&&oe.image_url?t.jsx("img",{src:oe.image_url,alt:oe.name}):Os((oe==null?void 0:oe.name)||"O").charAt(0)}),t.jsx("span",{children:(oe==null?void 0:oe.name)||"Select organization"})]}),t.jsx(Dt,{size:14})]}),P&&t.jsxs("div",{className:"w-combo-menu w-combo-menu--pop",children:[x==null?void 0:x.map(D=>{var q;const G=!!((q=D.eligibility_restriction)!=null&&q.type)&&D.eligibility_restriction.type!=="none";return t.jsxs("button",{type:"button",className:"w-combo-opt",disabled:G,"data-disabled":G?"":void 0,onClick:()=>{G||(Z(D.organization.id),L(!1))},children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:D.organization.image_url?t.jsx("img",{src:D.organization.image_url,alt:D.organization.name}):Os(D.organization.name).charAt(0)}),t.jsx("span",{children:D.organization.name})]},D.organization.id)}),i&&t.jsxs("button",{type:"button",className:"w-combo-opt w-text-primary",onClick:()=>{L(!1),i()},children:[t.jsx(Nt,{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:D=>_(D.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:D=>k(D.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:K,disabled:F||!v.trim(),children:F?t.jsx(je,{size:15}):t.jsxs(t.Fragment,{children:["Continue",t.jsx(Qt,{size:15})]})}),n&&t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-btn--block",onClick:n,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:D=>we(D.target.value),onKeyDown:Ie,placeholder:"teammate@acme.com"}),t.jsx(Fm,{roles:W,value:se,onChange:te})]}),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(D=>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:Os(D.email)}),t.jsx("span",{className:"w-truncate w-text-secondary",children:D.email})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-pill",children:D.roleName}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",title:"Remove",onClick:()=>Q(G=>G.filter(q=>q.email!==D.email)),children:t.jsx(La,{size:13})})]})]},D.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:Ye,disabled:F,children:F?t.jsx(je,{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}):Os(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(R),children:["Go to ",m,t.jsx(Qt,{size:15})]}),t.jsxs("button",{type:"button",className:"w-link w-link--muted w-linkbtn w-inline w-gap-1",onClick:Ae,children:[t.jsx(Vo,{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."})})]})},mn=({onSuccess:e,onCancel:a})=>t.jsx(Pe,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Wc,{mode:"org",onSuccess:e,onCancel:a})})}),Bc=({isOpen:e,onClose:a,onCreated:s})=>{const n=()=>{s==null||s(),a==null||a()};return t.jsx(Pe,{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(mn,{onSuccess:n,onCancel:a})})})})})},Er=o.createContext({screen:null,setScreen:()=>{},toast:(e,a)=>{}}),kt=()=>{const e=o.useContext(Er);if(!e)throw new Error("useScreenContext must be used within a ScreenContextProvider");return e},Qa=({title:e,description:a,onConfirm:s,onCancel:n,style:i})=>{const l=o.useRef(null);return o.useEffect(()=>{const m=c=>{l.current&&!l.current.contains(c.target)&&n()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[n]),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:n,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:s,children:"Confirm"})]})]})},Mi=[{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:{}}],Tm=({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(Xt,{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)})},Im=({organization:e})=>{const{getEnterpriseConnections:a,createEnterpriseConnection:s,deleteEnterpriseConnection:n,testEnterpriseConnection:i,generateSCIMToken:l,getSCIMToken:m,revokeSCIMToken:c}=Vt(),{toast:d}=kt(),[p,u]=o.useState(!1),[h,f]=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(n==null?void 0:n(e,j)),w(),d("SSO connection deleted","info")}catch(v){d(v.message||"Failed to delete connection","error")}f(null)};return x?t.jsx("div",{className:"w-loading",children:t.jsx(je,{})}):p?t.jsx(zm,{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(Xt,{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(ne,{onClick:()=>u(!0),children:[t.jsx(Nt,{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(Vm,{connection:j,onDelete:v=>f(v),connectionToDelete:h,onConfirmDelete:b,onCancelDelete:()=>f(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))]})})},Vm=({connection:e,onDelete:a,connectionToDelete:s,onConfirmDelete:n,onCancelDelete:i,testConnection:l,generateSCIMToken:m,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var F,A,I,$,S;const[u,h]=o.useState(null),[f,g]=o.useState(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),[v,_]=o.useState(!1),[N,k]=o.useState(null);o.useEffect(()=>{c&&e.id&&c(e.id).then(h).catch(()=>{})},[e.id,c]);const C=async()=>{if(l){_(!0),k(null);try{const Z=await l(e.id);k(Z)}catch(Z){k({success:!1,checks:{},errors:{general:Z.message||"Test failed"}})}finally{_(!1)}}},y=async()=>{if(m){g(!0);try{const Z=await m(e.id);w(Z.token),h({exists:!0,token:Z}),p("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(Z){p(Z.message||"Failed to generate token","error")}finally{g(!1)}}},E=async()=>{if(d){g(!0);try{await d(e.id),h({exists:!1,scim_base_url:u==null?void 0:u.scim_base_url}),w(null),p("SCIM token revoked","info")}catch(Z){p(Z.message||"Failed to revoke token","error")}finally{g(!1)}}},M=(Z,P)=>{navigator.clipboard.writeText(Z),j(P),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(Xt,{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(ne,{$size:"sm",onClick:C,disabled:v,children:v?t.jsx(je,{size:14}):"Test"}),t.jsxs("div",{className:"w-relative",children:[t.jsx(ne,{$size:"sm",$outline:!0,onClick:()=>a(e.id),className:"w-text-error",children:"Remove"}),s===e.id&&t.jsx(Qa,{title:"Delete this SSO connection?",onConfirm:()=>n(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(([Z,P])=>t.jsxs("div",{children:[Z.replace(/_/g," "),": ",P]},Z))]})}),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(Xt,{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(ne,{$size:"sm",onClick:y,disabled:f,children:f?t.jsx(je,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(ne,{$size:"sm",onClick:y,disabled:f,children:f?t.jsx(je,{size:14}):"Rotate"}),t.jsx(ne,{$size:"sm",$outline:!0,onClick:E,disabled:f,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:((I=u==null?void 0:u.token)==null?void 0:I.scim_base_url)||"Loading..."}),(($=u==null?void 0:u.token)==null?void 0:$.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(Be,{size:12}):t.jsx(Ga,{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(Be,{size:12}):t.jsx(Ga,{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()]})]})]})]})},zm=({onCreate:e,organization:a})=>{const{getOrganizationDomains:s,testEnterpriseConnectionConfig:n}=Vt(),{deployment:i}=ke(),{toast:l}=kt(),[m,c]=o.useState(!1),[d,p]=o.useState(null),[u,h]=o.useState("saml"),[f,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,_]=o.useState(!1),[N,k]=o.useState(null),{data:C=[],isLoading:y}=Ce("wacht-org-verified-domains-for-sso-screen",async()=>(await(s==null?void 0:s(a))||[]).filter(L=>L.verified),{revalidateOnFocus:!1}),E=P=>{p(P),h(P.protocol),P.protocol==="saml"?j(L=>{var H,O,R;return{...L,idp_entity_id:P.placeholders.entityId||"",idp_sso_url:P.placeholders.ssoUrl||"",attr_first_name:((H=P.attributeMapping)==null?void 0:H.first_name)||"",attr_last_name:((O=P.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((R=P.attributeMapping)==null?void 0:R.email)||""}}):j(L=>{var H,O,R;return{...L,oidc_issuer_url:P.placeholders.issuerUrl||"",oidc_scopes:P.placeholders.scopes||"openid profile email",attr_first_name:((H=P.attributeMapping)==null?void 0:H.first_name)||"",attr_last_name:((O=P.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((R=P.attributeMapping)==null?void 0:R.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`:"",I=(P,L)=>{navigator.clipboard.writeText(P),g(L),setTimeout(()=>g(null),2e3)},$=async P=>{P.preventDefault();const L=H=>H.includes("{")||H.includes("}");if(u==="saml"){if(!b.idp_entity_id||L(b.idp_entity_id)){l("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||L(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||L(b.oidc_issuer_url)){l("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||L(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 H={};b.attr_first_name&&(H.first_name=b.attr_first_name),b.attr_last_name&&(H.last_name=b.attr_last_name),b.attr_email&&(H.email=b.attr_email);const O=Object.keys(H).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,...O&&{attribute_mapping:H}}):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,...O&&{attribute_mapping:H}})}finally{c(!1)}},S=async()=>{_(!0),k(null);const P=O=>O.includes("{")||O.includes("}"),L={},H={};if(u==="saml"?(b.idp_entity_id?P(b.idp_entity_id)?(H.entity_id_valid=!1,L.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):H.entity_id_valid=!0:(H.entity_id_valid=!1,L.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?P(b.idp_sso_url)?(H.sso_url_valid=!1,L.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):H.sso_url_valid=!0:(H.sso_url_valid=!1,L.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?H.certificate_provided=!0:(H.certificate_provided=!1,L.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?P(b.oidc_issuer_url)?(H.issuer_url_valid=!1,L.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):H.issuer_url_valid=!0:(H.issuer_url_valid=!1,L.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?P(b.oidc_client_id)?(H.client_id_valid=!1,L.client_id_valid="Client ID contains placeholder values - please replace with actual values"):H.client_id_valid=!0:(H.client_id_valid=!1,L.client_id_valid="Client ID is required")),Object.keys(L).length>0){k({success:!1,checks:H,errors:L}),_(!1);return}try{const O=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},R=await(n==null?void 0:n(a,O));R&&k(R)}catch(O){k({success:!1,checks:{},errors:{general:"Test failed: "+O.message}})}finally{_(!1)}},Z=P=>t.jsx(Tm,{template:P});return t.jsxs("form",{onSubmit:$,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:[Z(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(ne,{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:Mi.filter(P=>P.protocol==="saml").map(P=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(P),children:[Z(P),t.jsx("span",{className:"w-secsub",children:P.name})]},P.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:Mi.filter(P=>P.protocol==="oidc").map(P=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(P),children:[Z(P),t.jsx("span",{className:"w-secsub",children:P.name})]},P.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:()=>I(A,"acs"),children:f==="acs"?t.jsx(Be,{size:12}):t.jsx(Ga,{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:()=>I(F,"metadata"),children:f==="metadata"?t.jsx(Be,{size:12}):t.jsx(Ga,{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:()=>I(M,"callback"),children:f==="callback"?t.jsx(Be,{size:12}):t.jsx(Ga,{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(vu,{size:12})," Docs"]}),t.jsx(ne,{type:"button",$size:"sm",$outline:!0,onClick:S,disabled:v||!d,children:v?t.jsx(je,{size:16}):"Test Connection"}),t.jsx(ne,{$size:"sm",type:"submit",disabled:m||C.length===0||!d,children:m?t.jsx(je,{size:16}):"Create Connection"})]})]}),N&&(()=>{const P={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(([L,H])=>{var O;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 ${H?"w-text-success":"w-text-error"}`,children:H?"✓":"✗"}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:P[L]||L.replace(/_/g," ").replace(/\b\w/g,R=>R.toUpperCase())}),((O=N.errors)==null?void 0:O[L])&&t.jsx("div",{className:"w-secsub w-text-error",children:N.errors[L]})]})]},L)})})]})})(),t.jsxs("div",{className:"w-grid-2",children:[!d&&t.jsxs(Ue,{children:[t.jsx(Te,{children:"Protocol *"}),t.jsxs("select",{className:"w-input",value:u,onChange:P=>h(P.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(Ue,{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:P=>j({...b,domain_id:P.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),C.map(P=>t.jsx("option",{value:P.id,children:P.fqdn},P.id))]})]}),u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(Ue,{children:[t.jsx(Te,{children:"IdP Entity ID *"}),t.jsx(be,{type:"text",value:b.idp_entity_id,onChange:P=>j({...b,idp_entity_id:P.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"IdP SSO URL *"}),t.jsx(be,{type:"url",value:b.idp_sso_url,onChange:P=>j({...b,idp_sso_url:P.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(Ue,{className:"w-col-full",children:[t.jsx(Te,{children:"X.509 Certificate *"}),t.jsx(be,{as:"textarea",value:b.idp_certificate,onChange:P=>j({...b,idp_certificate:P.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0,className:"w-input--area w-input--mono"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Ue,{children:[t.jsx(Te,{children:"Issuer URL *"}),t.jsx(be,{type:"url",value:b.oidc_issuer_url,onChange:P=>j({...b,oidc_issuer_url:P.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Client ID *"}),t.jsx(be,{type:"text",value:b.oidc_client_id,onChange:P=>j({...b,oidc_client_id:P.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Client Secret *"}),t.jsx(be,{type:"password",value:b.oidc_client_secret,onChange:P=>j({...b,oidc_client_secret:P.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Scopes"}),t.jsx(be,{type:"text",value:b.oidc_scopes,onChange:P=>j({...b,oidc_scopes:P.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(Ue,{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(Za,{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(Ue,{children:[t.jsx(Te,{children:"First Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_first_name,onChange:P=>j({...b,attr_first_name:P.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Last Name Attribute"}),t.jsx(be,{type:"text",value:b.attr_last_name,onChange:P=>j({...b,attr_last_name:P.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),t.jsxs(Ue,{children:[t.jsx(Te,{children:"Email Attribute"}),t.jsx(be,{type:"text",value:b.attr_email,onChange:P=>j({...b,attr_email:P.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},mt=(...e)=>e.filter(Boolean).join(" "),Ri=({className:e,...a})=>t.jsx("div",{className:mt("w-contents",e),...a}),Zn=({className:e,...a})=>t.jsx("div",{className:mt("w-card","w-flex-col","w-full","w-minh-full",e),...a}),Dm=({className:e,...a})=>t.jsx("div",{className:mt("w-tabsbar",e),...a}),Um=({className:e,...a})=>t.jsx("div",{className:mt("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),za=({className:e,$isActive:a,...s})=>t.jsx("button",{className:mt("w-tab",a&&"w-tab--active",e),...s}),Da=({className:e,...a})=>t.jsx("span",{className:mt("w-inline","w-gap-2",e),...a}),Wm=({className:e,children:a,...s})=>t.jsx("div",{className:mt("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Ar=({className:e,...a})=>t.jsx("div",{className:mt("w-sechead",e),...a}),Li=({className:e,...a})=>t.jsx("div",{className:mt("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Pi=({className:e,...a})=>t.jsx("div",{className:mt("w-grow",e),...a}),$i=({className:e,...a})=>t.jsx("div",{className:mt("w-flex","w-items-center","w-gap-3","w-none",e),...a}),pn=({className:e,...a})=>t.jsx("div",{className:mt("w-full",e),...a}),Bm=({className:e,...a})=>t.jsx("div",{className:mt("w-page-head",e),...a}),Gm=({className:e,...a})=>t.jsx("div",{className:mt("w-grow","w-flex-col","w-gap-1",e),...a}),qm=({className:e,...a})=>t.jsx("div",{className:mt("w-sec","w-truncate",e),...a}),Km=({className:e,...a})=>t.jsx("div",{className:mt("w-secsub","w-truncate",e),...a}),Ym={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},pa=({className:e,$variant:a="neutral",children:s,...n})=>t.jsxs("span",{className:mt("w-pill",Ym[a],e),...n,children:[t.jsx("span",{className:"w-dot"}),s]}),Oi=({className:e,$first:a,...s})=>t.jsx("div",{className:mt("w-sec",e),...s}),Qm=({organization:e})=>{var A,I,$,S,Z,P;const{switchOrganization:a,refetch:s}=rt(),{workspaces:n}=ga(),{deployment:i}=ke(),{deleteOrganization:l,updateOrganization:m}=Vt(),{toast:c}=kt(),[d,p]=o.useState((e==null?void 0:e.name)||""),[u,h]=o.useState((e==null?void 0:e.description)||""),[f,g]=o.useState(!1),[x,w]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,j]=o.useState(""),[v,_]=o.useState(!1),[N,k]=o.useState(!1),C=o.useRef({name:d,description:u,security:x,isSaving:f});o.useEffect(()=>{C.current={name:d,description:u,security:x,isSaving:f}},[d,u,x,f]);const y=o.useCallback(async()=>{if(!e)return;const L=C.current;try{g(!0),await m(e,{name:L.name,description:L.description,whitelisted_ips:L.security.allowed_ips.split(`
103
103
  `).filter(H=>H.trim()),enable_ip_restriction:L.security.ip_restrictions,enforce_mfa:L.security.mfa_required,auto_assigned_workspace_id:L.security.default_workspace_id||"0"}),c("Changes saved","info")}catch(H){c(H.message||"Failed to save changes","error")}finally{g(!1)}},[e,m,c]),E=o.useCallback(()=>{C.current.isSaving||y()},[y]);o.useEffect(()=>{var L;e&&(p(e.name||""),h(e.description||""),w({allowed_ips:((L=e.whitelisted_ips)==null?void 0:L.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(()=>n.filter(L=>L.organization.id===(e==null?void 0:e.id)),[n,e==null?void 0:e.id]),F=async()=>{if(!(!e||b!==e.name))try{_(!0),await a(""),await l(e),await s(),c("Organization deleted","info")}catch{c("Failed to delete organization","error")}finally{_(!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(Ue,{children:[t.jsx(Te,{htmlFor:"name",children:"Organization name"}),t.jsx(be,{id:"name",value:d,onChange:L=>p(L.target.value),onBlur:E,placeholder:"Organization name",required:!0})]}),t.jsxs(Ue,{children:[t.jsx(Te,{htmlFor:"description",children:"Description"}),t.jsx(be,{id:"description",as:"textarea",value:u,onChange:L=>h(L.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(Ue,{children:[t.jsx(Te,{htmlFor:"default_workspace",children:"Default workspace"}),t.jsx(un,{options:M.map(L=>({value:L.id,label:L.name})),value:x.default_workspace_id,onChange:L=>{w(H=>({...H,default_workspace_id:L})),setTimeout(E,0)},placeholder:"Select default workspace"})]})]}),(((I=i==null?void 0:i.b2b_settings)==null?void 0:I.enforce_mfa_per_org_enabled)||(($=i==null?void 0:i.b2b_settings)==null?void 0:$.ip_allowlist_per_org_enabled))&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Oi,{children:"Security"}),((S=i==null?void 0:i.b2b_settings)==null?void 0:S.enforce_mfa_per_org_enabled)&&t.jsxs(Li,{children:[t.jsxs(Pi,{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($i,{children:t.jsx(Za,{checked:x.mfa_required,onChange:()=>{const L=!x.mfa_required;w(H=>({...H,mfa_required:L})),setTimeout(E,0)}})})]}),((Z=i==null?void 0:i.b2b_settings)==null?void 0:Z.ip_allowlist_per_org_enabled)&&t.jsxs(t.Fragment,{children:[t.jsxs(Li,{children:[t.jsxs(Pi,{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($i,{children:t.jsx(Za,{checked:x.ip_restrictions,onChange:()=>{const L=!x.ip_restrictions;w(H=>({...H,ip_restrictions:L})),setTimeout(E,0)}})})]}),x.ip_restrictions&&t.jsxs(Ue,{children:[t.jsx(Te,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(be,{id:"allowed_ips",as:"textarea",value:x.allowed_ips,onChange:L=>w(H=>({...H,allowed_ips:L.target.value})),onBlur:E,placeholder:`192.168.1.1
105
105
  10.0.0.0/24`,className:"w-input--area w-input--mono"})]})]})]}),((P=i==null?void 0:i.b2b_settings)==null?void 0:P.allow_org_deletion)&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Oi,{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(ne,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{k(!N),j("")},children:N?"Cancel":"Delete organization"})]}),N&&t.jsxs("div",{className:"w-flex-col w-gap-3 w-full",children:[t.jsxs(Ue,{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:L=>j(L.target.value),placeholder:e.name})]}),t.jsx(ne,{$size:"sm",$destructive:!0,onClick:F,disabled:b!==e.name||v,children:v?t.jsx(je,{size:12}):"Delete forever"})]})]})]})]}):t.jsx(je,{})},Mr=(e,a)=>a?`${e} ${a}`:e,$t=o.forwardRef(({className:e,...a},s)=>t.jsx("table",{ref:s,className:Mr("w-table",e),...a}));$t.displayName="Table";const Ot=o.forwardRef((e,a)=>t.jsx("thead",{ref:a,...e}));Ot.displayName="TableHead";const Zt=o.forwardRef((e,a)=>t.jsx("tbody",{ref:a,...e}));Zt.displayName="TableBody";const nt=o.forwardRef((e,a)=>t.jsx("tr",{ref:a,...e}));nt.displayName="TableRow";const He=o.forwardRef((e,a)=>t.jsx("th",{ref:a,...e}));He.displayName="TableHeader";const Ke=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:e,...a}));Ke.displayName="TableCell";const Jm=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Mr("w-td--flex",e),...a}));Jm.displayName="TableCellFlex";const Ht=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Mr("w-td--actions",e),...a}));Ht.displayName="ActionsCell";const Ct=({title:e,description:a,icon:s,action:n})=>t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:s??t.jsx(Zu,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:e}),t.jsx("p",{children:a})]}),n&&t.jsx("div",{className:"w-empty-action",children:n})]}),xt=({triggerRef:e,isOpen:a,minWidth:s=300,defaultMaxHeight:n=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(),h=window.innerWidth,f=window.innerHeight,g=((N=l==null?void 0:l.current)==null?void 0:N.offsetWidth)||s,x=f-u.bottom,w=u.top,b={};x>=w?(b.top=u.bottom+i,b.maxHeight=Math.min(n,x-i*2)):(b.bottom=f-u.top+i,b.maxHeight=Math.min(n,w-i*2));const j=h-u.left,v=u.right,_=j>=v?u.left:u.right-g;b.left=Math.max(i,Math.min(h-g-i,_)),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,n,i,l]),m},Zi=({onClose:e,domain:a,triggerRef:s})=>{const n=o.useRef(null),[i,l]=o.useState(),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,h]=o.useState(!1),{addDomain:f,verifyDomain:g}=fa(),{toast:x}=kt(),w=xt({contentRef:n,triggerRef:s??{current:null},isOpen:u,minWidth:360,defaultMaxHeight:420}),b=k=>/^[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(k),j=k=>k.trim().toLowerCase().replace(/^https?:\/\//,""),v=async()=>{const k=j(m);if(!k){x("Please enter a domain name","error");return}if(!b(k)){x("Please enter a valid domain (e.g., example.com)","error");return}if(k.length>253){x("Domain name is too long","error");return}p(!0);try{const C=await f({fqdn:k});x("Domain added","info"),l(C.data)}catch(C){x(C.message||"Failed to add domain. Please try again.","error")}finally{p(!1)}},_=async()=>{if(!(!i||d)){p(!0);try{await g(i),e==null||e(),x("Domain verified","info")}catch(k){x(k.message||"Failed to verify domain. Check DNS records and try again.","error")}finally{p(!1)}}};if(o.useEffect(()=>{h(!0);const k=y=>{n.current&&!n.current.contains(y.target)&&(e==null||e())},C=y=>{y.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",k),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:n,className:"w-pop w-pop--wide",style:N,onClick:k=>k.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:_,disabled:d,children:d?t.jsx(je,{size:12}):"Verify"})]})]}):t.jsxs("div",{ref:n,className:"w-pop w-pop--wide",style:N,onClick:k=>k.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:k=>c(k.target.value),onKeyDown:k=>{k.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(je,{size:12}):"Continue"})]})]})},Xm=({organization:e})=>{const{getOrganizationDomains:a,removeOrganizationDomain:s}=Vt(),[n,i]=o.useState(null),[l,m]=o.useState(!1),[c,d]=o.useState(null),[p,u]=o.useState(new Set),h=o.useRef(null),f=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(_=>({..._,verified:_.verified!==void 0?_.verified:!1}))),b=(v,_)=>{u(N=>{const k=new Set(N);return _?k.add(v):k.delete(v),k})},j=async v=>{b(v.id,!0);try{await s(e,v),w()}finally{b(v.id,!1),i(null)}};return x?t.jsx(je,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Ar,{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(ne,{ref:h,onClick:()=>m(!0),$size:"sm",children:"Add domain"}),l&&t.jsx(Zi,{onClose:()=>{m(!1),w()},triggerRef:h})]}),g!=null&&g.length?t.jsx(pn,{children:t.jsxs($t,{children:[t.jsx(Ot,{children:t.jsxs(nt,{children:[t.jsx(He,{children:"Domain"}),t.jsx(He,{children:"Status"}),t.jsx(He,{children:"Added"}),t.jsx(He,{})]})}),t.jsx(Zt,{children:g.map(v=>{const _=p.has(v.id);return t.jsxs(nt,{children:[t.jsx(Ke,{children:v.fqdn}),t.jsx(Ke,{children:v.verified?t.jsx(pa,{$variant:"success",children:"Verified"}):t.jsx(pa,{$variant:"warning",children:"Pending"})}),t.jsx(Ke,{children:new Date(v.created_at).toLocaleDateString()}),t.jsx(Ht,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(ne,{ref:N=>{N&&(f.current[v.id]=N)},$size:"sm",$outline:!0,disabled:_,onClick:()=>d(v.id),children:v.verified?"View DNS":"Verify"}),t.jsx(ne,{$size:"sm",$outline:!0,$destructive:!0,disabled:_,onClick:()=>i(v.id),children:_?t.jsx(je,{size:12}):"Remove"})]})})]},v.id)})})]})}):t.jsx(Ct,{title:"No domains added",description:"Users with verified domain emails automatically join this organization."}),n&&t.jsx(Qa,{title:"Remove domain?",description:"Active users aren't affected, but new users with this domain won't auto-join.",onConfirm:()=>{const v=g.find(_=>_.id===n);v&&j(v)},onCancel:()=>i(null)}),c&&t.jsx(Zi,{domain:g.find(v=>v.id===c),onClose:()=>d(null),triggerRef:{current:f.current[c]}})]})},Gc=({onClose:e,onSuccess:a,roles:s,triggerRef:n})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[h,f]=o.useState(!1),{inviteMember:g}=fa(),{toast:x}=kt(),w=xt({contentRef:i,triggerRef:n??{current:null},isOpen:h,minWidth:360,defaultMaxHeight:360}),b=s.map(_=>({value:_.id,label:_.name})),j=_=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_),v=async()=>{const _=l.trim().toLowerCase();if(!(!_||!c)){if(!j(_)){x("Please enter a valid email address","error");return}if(_.length>320){x("Email address is too long","error");return}u(!0);try{await g({email:_,organizationRole:c}),a==null||a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{u(!1)}}};return o.useEffect(()=>{f(!0);const _=k=>{i.current&&!i.current.contains(k.target)&&(e==null||e())},N=k=>{k.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",N)}},[e]),h?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:_=>_.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:_=>m(_.target.value),onKeyDown:_=>{_.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(un,{options:b,value:c==null?void 0:c.id,onChange:_=>d(s.find(N=>N.id===_)),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(je,{size:12}):"Send invite"})]})]}):null},e4=({organization:e})=>{const{getOrganizationMembers:a,getOrganizationRoles:s,addRoleToOrganizationMember:n,removeRoleFromOrganizationMember:i,removeOrganizationMember:l}=Vt(),{session:m}=rt(),{toast:c}=kt(),[d,p]=o.useState(""),[u,h]=o.useState(1),[f]=o.useState(10),[g,x]=o.useState(!1),[w,b]=o.useState(new Set),j=o.useRef(null),[v,_]=o.useState(d);o.useEffect(()=>{const S=setTimeout(()=>{_(d),h(1)},500);return()=>clearTimeout(S)},[d]);const{data:N,mutate:k}=Ce(e?`wacht-api-organizations:${e.id}:members:${u}:${f}:${v}`:null,()=>a==null?void 0:a(e,{page:u,limit:f,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,Z)=>{b(P=>{const L=new Set(P);return Z?L.add(S):L.delete(S),L})},I=async(S,Z,P)=>{A(S.id,!0);try{P?(await i(e,S,Z),c("Role removed","info")):(await n(e,S,Z),c("Role added","info")),k()}catch(L){c(L.message||"Failed to update role","error")}finally{A(S.id,!1)}},$=async S=>{A(S.id,!0);try{await l(e,S),k(),c("Member removed","info")}catch(Z){c(Z.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(Vc,{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(ne,{ref:j,onClick:()=>x(!0),$size:"sm",children:"Invite"})]})]}),g&&t.jsx(Gc,{onClose:()=>x(!1),onSuccess:()=>{k(),x(!1)},roles:F,triggerRef:j}),C.length===0?t.jsx(Ct,{title:d?"No members match":"No members yet",description:"Invite someone or connect a corporate domain to auto-join."}):t.jsx(pn,{children:t.jsxs($t,{children:[t.jsx(Ot,{children:t.jsxs(nt,{children:[t.jsx(He,{children:"Member"}),t.jsx(He,{children:"Joined"}),t.jsx(He,{children:"Roles"}),t.jsx(He,{})]})}),t.jsx(Zt,{children:C.map(S=>{var L,H;const Z=((L=S.user)==null?void 0:L.id)===((H=m==null?void 0:m.active_signin)==null?void 0:H.user_id),P=w.has(S.id);return t.jsxs(nt,{children:[t.jsx(Ke,{children:t.jsx(t4,{member:S,isCurrentUser:Z})}),t.jsx(Ke,{children:new Date(S.created_at).toLocaleDateString()}),t.jsx(Ke,{children:t.jsx(a4,{member:S,roles:F,onToggle:I,disabled:P})}),t.jsx(Ht,{children:t.jsx("div",{className:"w-actions",children:t.jsx(ne,{$size:"sm",$outline:!0,$destructive:!0,disabled:P||Z,onClick:()=>$(S),title:Z?"You cannot remove yourself":"Remove member",children:P?t.jsx(je,{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(ne,{onClick:()=>h(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(ne,{onClick:()=>h(S=>Math.min(E,S+1)),disabled:u===E,$size:"sm",$outline:!0,children:"Next"})]})]}):t.jsx(je,{})},t4=({member:e,isCurrentUser:a})=>{var l,m;const s=e.user,n=(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}):n(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(pa,{$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})]})]})},a4=({member:e,roles:a,onToggle:s,disabled:n})=>{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(_s,{children:[t.jsx(Cs,{children:t.jsxs(ne,{$size:"sm",$outline:!0,disabled:n,className:"w-justify-between w-rolepick-btn",children:[m,t.jsx(Dt,{size:12})]})}),t.jsx(ks,{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(ea,{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(Be,{size:13,className:"w-text-primary"})]})},d.id)})})]})},s4=e=>{const a=e.expires_at;return a?new Date(a).getTime()<Date.now():!1},n4=({organization:e})=>{const{getOrganizationInvitations:a,getOrganizationRoles:s,discardOrganizationInvitation:n,resendOrganizationInvitation:i}=Vt(),{toast:l}=kt(),[m,c]=o.useState(!1),[d,p]=o.useState(new Set),u=o.useRef(null),{data:h=[],isLoading:f,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,k)=>{p(C=>{const y=new Set(C);return k?y.add(N):y.delete(N),y})},v=async N=>{j(N.id,!0);try{await n(e,N),g(),l("Invitation cancelled","info")}catch(k){l(k.message||"Failed to cancel invitation","error")}finally{j(N.id,!1)}},_=async N=>{j(N.id,!0);try{await i(e,N),l("Invitation resent","info")}catch(k){l(k.message||"Failed to resend invitation","error")}finally{j(N.id,!1)}};return f||w?t.jsx(je,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Ar,{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(ne,{ref:u,onClick:()=>c(!0),$size:"sm",children:"Invite"})]}),m&&t.jsx(Gc,{onClose:()=>c(!1),onSuccess:()=>{g(),c(!1)},roles:b,triggerRef:u}),h.length===0?t.jsx(Ct,{title:"No pending invitations",description:"Invite members to collaborate."}):t.jsx(pn,{children:t.jsxs($t,{children:[t.jsx(Ot,{children:t.jsxs(nt,{children:[t.jsx(He,{children:"Email"}),t.jsx(He,{children:"Role"}),t.jsx(He,{children:"Status"}),t.jsx(He,{children:"Invited"}),t.jsx(He,{})]})}),t.jsx(Zt,{children:h.map(N=>{var y;const k=s4(N),C=d.has(N.id);return t.jsxs(nt,{children:[t.jsx(Ke,{children:N.email}),t.jsx(Ke,{children:((y=N.initial_organization_role)==null?void 0:y.name)||"No role"}),t.jsx(Ke,{children:k?t.jsx(pa,{$variant:"danger",children:"Expired"}):t.jsx(pa,{$variant:"warning",children:"Pending"})}),t.jsx(Ke,{children:new Date(N.created_at).toLocaleDateString()}),t.jsx(Ht,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(ne,{$size:"sm",$outline:!0,disabled:C,onClick:()=>_(N),children:"Resend"}),t.jsx(ne,{$size:"sm",$outline:!0,$destructive:!0,disabled:C,onClick:()=>v(N),children:C?t.jsx(je,{size:12}):"Cancel"})]})})]},N.id)})})]})})]})},Hi=({onClose:e,onSuccess:a,role:s,triggerRef:n})=>{var k;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),[h,f]=o.useState(!1),{deployment:g}=ke(),{toast:x}=kt(),w=xt({contentRef:i,triggerRef:n??{current:null},isOpen:h,minWidth:400,defaultMaxHeight:500}),b=!!s,j=Array.isArray((k=g==null?void 0:g.b2b_settings)==null?void 0:k.organization_permissions)?g.b2b_settings.organization_permissions.map(C=>({value:C,label:C})):[];o.useEffect(()=>{f(!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,""),_=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(!_(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 h?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(Uc,{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(je,{size:12}):b?"Update":"Create"})]})]}):null};function Rr(e){return typeof e=="object"&&e!==null}function qc(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 r4(e,a){const s=e[a];return typeof s=="boolean"?s:null}function Kc(e){if(!Rr(e))return!1;const a=r4(e,"is_deployment_level");return a!==null?a:!1}function i4(e){return!Rr(e)||Kc(e)?!1:qc(e,"organization_id")}function ur(e){return!Rr(e)||Kc(e)?!1:qc(e,"workspace_id")}const o4=({organization:e})=>{var k;const{getOrganizationRoles:a,removeOrganizationRoles:s}=Vt(),{deployment:n}=ke(),[i,l]=o.useState({isOpen:!1}),[m,c]=o.useState(null),[d,p]=o.useState(null),[u,h]=o.useState(new Set),f=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)=>{h(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)}},_=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(je,{});const N=C=>{const y=i4(C),E=u.has(C.id),M=C.permissions.length;return t.jsxs(nt,{children:[t.jsx(Ke,{children:t.jsxs("span",{className:"w-inline w-gap-2 w-sec",children:[C.name,!y&&t.jsx(pa,{$variant:"neutral",children:"Default"})]})}),t.jsx(Ke,{children:M===0?t.jsx(pa,{$variant:"neutral",children:"No permissions"}):t.jsxs("div",{className:"w-inline w-items-center w-gap-2",children:[t.jsxs(pa,{$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(Ht,{children:y?t.jsxs("div",{className:"w-actions",children:[t.jsx(ne,{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(ne,{$size:"sm",$outline:!0,$destructive:!0,disabled:E,onClick:()=>p(C.id),children:E?t.jsx(je,{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(Be,{size:16}):t.jsx(Fa,{size:16}),t.jsx("span",{className:"w-banner-txt",children:m.text})]}),t.jsxs(Ar,{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."})]}),((k=n==null?void 0:n.b2b_settings)==null?void 0:k.custom_org_role_enabled)&&t.jsx(ne,{ref:f,onClick:()=>l({isOpen:!0,triggerElement:f.current}),$size:"sm",children:"Add role"})]}),i.isOpen&&!i.role&&t.jsx(Hi,{onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||f.current}}),x.length===0?t.jsx(Ct,{title:"No roles yet",description:"Define custom roles to manage granular permissions."}):t.jsx(t.Fragment,{children:t.jsx(pn,{children:t.jsxs($t,{children:[t.jsx(Ot,{children:t.jsxs(nt,{children:[t.jsx(He,{children:"Role"}),t.jsx(He,{children:"Permissions"}),t.jsx(He,{})]})}),t.jsx(Zt,{children:x.map(N)})]})})}),d&&t.jsx(Qa,{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&&_(C)},onCancel:()=>p(null)}),i.isOpen&&i.role&&t.jsx(Hi,{role:i.role,onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||null}})]})},l4=()=>{const{activeOrganization:e,loading:a}=fa(),[s,n]=o.useState(null);return o.useEffect(()=>{e?n(e):!a&&!e&&s&&n(null)},[e,a,s]),{activeOrganization:s||e,loading:a}},Yc=()=>{var w,b,j;const{loading:e,activeOrganization:a}=l4(),{updateOrganization:s}=fa(),{deployment:n}=ke(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,h]=o.useState(!1),f=o.useRef(null),g=o.useCallback((v,_="info")=>{c(v),p(_),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const _=(N=v.target.files)==null?void 0:N[0];if(_){if(_.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!_.type.startsWith("image/")){g("Please select a valid image file","error");return}try{h(!0),await s({image:_}),g("Logo updated","info")}catch(k){g((k==null?void 0:k.message)||"Failed to update logo","error")}finally{h(!1),f.current&&(f.current.value="")}}};return e&&!a?t.jsx(Pe,{children:t.jsx(Zn,{className:"w-items-center w-justify-center",children:t.jsx(je,{})})}):a?t.jsx(Pe,{children:t.jsx(Ri,{children:t.jsx(Er.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(Zn,{className:"w-relative",children:[t.jsxs(Bm,{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=f.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(je,{size:14}):t.jsx(sn,{size:16})})]}),t.jsx("input",{ref:f,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(Gm,{children:[t.jsx(qm,{children:a.name}),t.jsx(Km,{children:a.member_count!=null?`${a.member_count} members`:"Organization settings"})]})]}),t.jsx(Dm,{children:t.jsxs(Um,{children:[t.jsx(za,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Da,{children:[t.jsx(Ea,{size:16})," General"]})}),t.jsx(za,{$isActive:i==="domains",onClick:()=>l("domains"),children:t.jsxs(Da,{children:[t.jsx(Eu,{size:16})," Domains"]})}),t.jsx(za,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Da,{children:[t.jsx(cs,{size:16})," Members"]})}),t.jsx(za,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Da,{children:[t.jsx(dl,{size:16})," Invitations"]})}),((b=n==null?void 0:n.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&t.jsx(za,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Da,{children:[t.jsx(Xt,{size:16})," Roles"]})}),((j=n==null?void 0:n.b2b_settings)==null?void 0:j.enterprise_sso_enabled)&&t.jsx(za,{$isActive:i==="sso",onClick:()=>l("sso"),children:t.jsxs(Da,{children:[t.jsx(Xt,{size:16})," SSO"]})})]})}),t.jsxs(Wm,{children:[i==="general"&&t.jsx(Qm,{organization:a}),i==="domains"&&t.jsx(Xm,{organization:a}),i==="members"&&t.jsx(e4,{organization:a}),i==="invitations"&&t.jsx(n4,{organization:a}),i==="roles"&&t.jsx(o4,{organization:a}),i==="sso"&&t.jsx(Im,{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(Fa,{size:12}):t.jsx(Be,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})}):t.jsx(Pe,{children:t.jsx(Ri,{children:t.jsx(Zn,{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(ps,{size:20})}),t.jsx("h4",{children:"No Organization Selected"}),t.jsx(n0,{})]})})})})},Qc=({isOpen:e,onClose:a,title:s,showHeader:n,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:[n&&t.jsx(ze.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(Yc,{}),l&&t.jsx(ze.Footer,{children:l})]})})}),Lr=({organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:n})=>t.jsx(Pe,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Wc,{mode:"ws",organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:n})})}),Pr=({isOpen:e,onClose:a,onCreated:s,organizationId:n})=>{const[i,l]=o.useState(!1),[m,c]=o.useState(n),d=()=>{s==null||s(),a==null||a()},p=()=>{l(!0)},u=h=>{var g,x,w;const f=((x=(g=h==null?void 0:h.data)==null?void 0:g.organization)==null?void 0:x.id)??((w=h==null?void 0:h.organization)==null?void 0:w.id)??(h==null?void 0:h.id);f&&c(f),l(!1)};return t.jsx(Pe,{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(mn,{onSuccess:u,onCancel:()=>l(!1)}):t.jsx(Lr,{organizationId:m||n,onSuccess:d,onCancel:a,onCreateOrganization:p})})})})})},pt=(...e)=>e.filter(Boolean).join(" "),c4=({className:e,...a})=>t.jsx("div",{className:pt("w-contents",e),...a}),Fi=({className:e,...a})=>t.jsx("div",{className:pt("w-card","w-flex-col","w-full","w-minh-full",e),...a}),d4=({className:e,...a})=>t.jsx("div",{className:pt("w-tabsbar",e),...a}),u4=({className:e,...a})=>t.jsx("div",{className:pt("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),Zs=({$isActive:e,className:a,...s})=>t.jsx("button",{className:pt("w-tab",e&&"w-tab--active",a),...s}),Hs=({className:e,...a})=>t.jsx("span",{className:pt("w-inline","w-gap-2",e),...a}),m4=({className:e,children:a,...s})=>t.jsx("div",{className:pt("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Js=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:pt("w-kebab",e),...a}));Js.displayName="IconButton";const Jc=({className:e,...a})=>t.jsx("div",{className:pt("w-sechead",e),...a}),Ti=({className:e,...a})=>t.jsx("div",{className:pt("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Ii=({className:e,...a})=>t.jsx("div",{className:pt("w-grow",e),...a}),Vi=({className:e,...a})=>t.jsx("div",{className:pt("w-flex","w-items-center","w-gap-3","w-none",e),...a}),$r=({className:e,...a})=>t.jsx("div",{className:pt("w-full",e),...a}),p4=({className:e,...a})=>t.jsx("div",{className:pt("w-page-head",e),...a}),h4=({className:e,...a})=>t.jsx("div",{className:pt("w-grow","w-flex-col","w-gap-1",e),...a}),f4=({className:e,...a})=>t.jsx("div",{className:pt("w-sec","w-truncate",e),...a}),w4=({className:e,...a})=>t.jsx("div",{className:pt("w-secsub","w-truncate",e),...a}),zi=({$first:e,className:a,...s})=>t.jsx("div",{className:pt("w-sec",a),...s}),g4=()=>{var E,M;const{activeWorkspace:e,loading:a,updateWorkspace:s}=zt(),{deleteWorkspace:n}=ga(),{deployment:i}=ke(),{toast:l}=kt(),[m,c]=o.useState((e==null?void 0:e.name)||""),[d,p]=o.useState((e==null?void 0:e.description)||""),[u,h]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[f,g]=o.useState(!1),[x,w]=o.useState(""),[b,j]=o.useState(!1),[v,_]=o.useState(!1);o.useEffect(()=>{var F;e&&(c(e.name||""),p(e.description||""),h({mfa_required:e.enforce_2fa||!1,ip_restrictions:e.enable_ip_restriction||!1,allowed_ips:((F=e.whitelisted_ips)==null?void 0:F.join(`