@wizeworks/lens-ui 0.3.0-alpha.3 → 0.3.0-alpha.5

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.
@@ -0,0 +1,2 @@
1
+ import{E as e,X as t,Z as n,_ as r,a as i,c as a,i as o,l as s,n as c,o as l,u,v as d,vt as f}from"./account-D29x4uz9.js";import{n as p,t as m}from"./AppsPanel-Dq0tvHKE.js";import{A as h,B as g,F as _,I as v,K as y,L as b,M as x,O as S,P as C,S as w,V as ee,_ as te,b as T,c as E,g as D,j as ne,k as O,l as k,q as A,u as j,x as M,y as N,z as P}from"./index-DYrQC7uL.js";var F={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};F.node;var I=A(F),L=f(),R=b();function z(){let[e,t]=(0,L.useState)(!1),[n,r]=(0,L.useState)(null),[a,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(!1);return{busy:e,error:n,note:a,stale:c,run:(0,L.useCallback)(async(e,n)=>{t(!0),r(null),s(null);try{return await e(),n&&s(n),!0}catch(e){return i(e)?l(!0):r(o(e)),!1}finally{t(!1)}},[]),setNote:s}}function B(){return(0,R.jsxs)(`div`,{className:`wl-banner wl-banner-info`,role:`status`,children:[`For safety, sign in again first.`,` `,(0,R.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>void a(),children:`Sign out and sign in again`})]})}function V({a:e}){return(0,R.jsxs)(R.Fragment,{children:[e.stale&&(0,R.jsx)(B,{}),e.error&&(0,R.jsx)(`div`,{className:`wl-banner wl-banner-error`,role:`alert`,children:e.error}),e.note&&(0,R.jsx)(`p`,{className:`wl-muted wl-small`,role:`status`,children:e.note})]})}var H=e=>t=>{t.preventDefault(),e(Object.fromEntries([...new FormData(t.currentTarget)].map(([e,t])=>[e,String(t)])),t.currentTarget)};function U({account:e}){let t=z(),{dialog:n,confirm:i}=D(),a=e.blockingOrgs??[],o=H(async(n,a)=>{await i({title:`Delete your account?`,body:`Your account and every organization where you are the only member are deleted, with all their data. This cannot be undone.`,confirmLabel:`Delete my account`,danger:!0})&&t.run(async()=>{if(await c(e=>e.deleteUser({password:n.password})),a.reset(),e.mail)return t.setNote(`Check your email to confirm.`);d(r(`delete-account`,[],{done:`1`})),await l()})});return(0,R.jsxs)(v,{className:`wl-panel-danger`,children:[n,(0,R.jsx)(`p`,{className:`wl-muted`,children:`Organizations where you are the only member are deleted with your account, with all their data.`}),a.length>0?(0,R.jsx)(`ul`,{className:`wl-plain-list`,children:a.map(e=>(0,R.jsxs)(`li`,{children:[`Make someone else an owner of `,e,` first, or delete it.`]},e))}):(0,R.jsxs)(`form`,{className:`wl-form`,onSubmit:o,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(M,{label:`Your password`,name:`password`,type:`password`,autoComplete:`current-password`,required:!0}),(0,R.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-danger`,disabled:t.busy,children:`Delete my account`})]}),(0,R.jsx)(V,{a:t})]})]})}var W=()=>t(`./api/me/notifications`),G=e=>n(`PATCH`,`./api/me/notifications`,e),K=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`;function q(e){let t=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return t.includes(e)?t:[e,...t]}var J=[[`daily`,`Daily`],[`weekly`,`Weekly`],[`monthly`,`Monthly`]],re=Array.from({length:24},(e,t)=>t),Y=e=>`${e.toString().padStart(2,`0`)}:00`;function X({rows:e,disabled:t,onChange:n}){let r=[{key:`project`,header:`Project`,cell:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`b`,{children:e.project}),` `,(0,R.jsx)(`span`,{className:`wl-muted wl-small`,children:e.org})]})},...J.map(([e,r])=>({key:e,header:r,cell:i=>(0,R.jsx)(`input`,{type:`checkbox`,className:`wl-notify-box`,"aria-label":`${r} digest for ${i.project}`,checked:i[e],disabled:t,onChange:t=>n(i,e,t.target.checked)})}))];return(0,R.jsx)(N,{columns:r,rows:e,rowKey:e=>e.projectId,empty:(0,R.jsx)(`p`,{className:`wl-muted`,children:`No projects yet.`})})}function ie({n:e,busy:t,save:n}){let r=K();return(0,R.jsxs)(`div`,{className:`wl-form-row wl-notify-when`,children:[(0,R.jsxs)(`label`,{className:`wl-field`,children:[(0,R.jsx)(`span`,{children:`Digests arrive at`}),(0,R.jsx)(`select`,{className:`wl-select`,value:e.digestHour,disabled:t||!e.digests,onChange:e=>n({digestHour:Number(e.target.value)}),children:re.map(e=>(0,R.jsx)(`option`,{value:e,children:Y(e)},e))})]}),(0,R.jsxs)(`label`,{className:`wl-field`,children:[(0,R.jsx)(`span`,{children:`Time zone`}),(0,R.jsx)(`select`,{className:`wl-select`,value:e.timeZone,disabled:t,onChange:e=>n({timeZone:e.target.value}),children:q(e.timeZone).map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))})]}),r!==e.timeZone&&(0,R.jsxs)(`button`,{type:`button`,className:`wl-link-btn`,disabled:t,onClick:()=>n({timeZone:r}),children:[`Use `,r]})]})}function ae(){let e=z(),[t,n]=(0,L.useState)(null),{run:r}=e;(0,L.useEffect)(()=>void r(async()=>n(await W())),[r]);let i=(0,L.useCallback)(e=>void r(async()=>n(await G(e)),`Saved.`),[r]),a=t?.projects.some(e=>e.role===`owner`||e.role===`admin`);return(0,R.jsxs)(v,{children:[(0,R.jsx)(V,{a:e}),t&&!t.mail&&(0,R.jsx)(`div`,{className:`wl-banner wl-banner-info`,children:`Mail is not set up on this cloud, so emails go to its log.`}),t&&(0,R.jsxs)(`div`,{className:`wl-form`,children:[(0,R.jsx)(`p`,{className:`wl-muted wl-small`,children:`Security notices (password, email, two-step sign-in, passkeys, new devices) always go out.`}),a&&(0,R.jsx)(T,{label:`Team changes: members, roles, keys, projects, and single sign-on`,checked:t.team,disabled:e.busy,onChange:e=>i({team:e.target.checked})}),a&&(0,R.jsx)(T,{label:`Project health: a busy project stops sending data`,checked:t.health,disabled:e.busy,onChange:e=>i({health:e.target.checked})}),(0,R.jsx)(T,{label:`Digests`,checked:t.digests,disabled:e.busy,onChange:e=>i({digests:e.target.checked})}),(0,R.jsx)(ie,{n:t,busy:e.busy,save:i}),(0,R.jsx)(X,{rows:t.projects,disabled:e.busy||!t.digests,onChange:(e,t,n)=>i({projects:[{projectId:e.projectId,[t]:n}]})})]})]})}var oe=e=>new Date(e).getTime();function se(){let e=z(),{dialog:t,confirm:n,prompt:r}=D(),[i,a]=(0,L.useState)([]),o=(0,L.useCallback)(()=>void c(e=>e.passkey.listUserPasskeys()).then(e=>a(e),()=>void 0),[]);(0,L.useEffect)(o,[o]);let s=H((t,n)=>void e.run(()=>c(e=>e.passkey.addPasskey({name:t.name||void 0})),`Passkey added.`).then(e=>e&&(n.reset(),o()))),l=async t=>{let n=await r({title:`Rename this passkey`,confirmLabel:`Save`,input:{label:`Name`,initial:t.name??``}});n&&e.run(()=>c(e=>e.passkey.updatePasskey({id:t.id,name:n}))).then(o)},u=async t=>await n({title:`Delete "${t.name||`Passkey`}"?`,body:`You can no longer sign in with it. Your password and other passkeys still work.`,confirmLabel:`Delete passkey`,danger:!0})&&void e.run(()=>c(e=>e.passkey.deletePasskey({id:t.id}))).then(o);return(0,R.jsxs)(v,{title:`Passkeys`,children:[(0,R.jsxs)(`form`,{className:`wl-form`,onSubmit:s,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(M,{label:`Name (optional)`,name:`name`,placeholder:`Work laptop`}),(0,R.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:e.busy,children:`Add a passkey`})]}),(0,R.jsx)(V,{a:e})]}),(0,R.jsx)(N,{columns:[{key:`name`,header:`Passkey`,cell:e=>(0,R.jsx)(`strong`,{children:e.name||`Passkey`})},{key:`kind`,header:`Kind`,cell:e=>e.deviceType===`multiDevice`?`Synced`:`This device only`},{key:`added`,header:`Added`,cell:e=>ne(oe(e.createdAt))},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,R.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,R.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>void l(e),children:`Rename`}),(0,R.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void u(e),children:`Delete`})]})}],rows:i,rowKey:e=>e.id,empty:(0,R.jsx)(C,{children:`No passkeys yet. A passkey signs you in with your fingerprint, face, or device PIN.`})}),t]})}function ce(){let e=z(),t=H((t,n)=>{if(t.newPassword!==t.again)return void e.run(()=>Promise.reject(Error(`The two new passwords are not the same.`)));let r={currentPassword:t.currentPassword,newPassword:t.newPassword,revokeOtherSessions:t.revoke===`on`};e.run(()=>c(e=>e.changePassword(r)),`Password changed.`).then(e=>e&&n.reset())});return(0,R.jsx)(v,{title:`Password`,children:(0,R.jsxs)(`form`,{className:`wl-form`,onSubmit:t,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(M,{label:`Current password`,name:`currentPassword`,type:`password`,autoComplete:`current-password`,required:!0}),(0,R.jsx)(M,{label:`New password (12 characters or more)`,name:`newPassword`,type:`password`,autoComplete:`new-password`,minLength:12,required:!0}),(0,R.jsx)(M,{label:`New password again`,name:`again`,type:`password`,autoComplete:`new-password`,required:!0})]}),(0,R.jsxs)(`div`,{className:`wl-form-actions wl-form-actions-split`,children:[(0,R.jsx)(T,{label:`Sign out my other devices`,name:`revoke`,defaultChecked:!0}),(0,R.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:e.busy,children:`Change password`})]}),(0,R.jsx)(V,{a:e})]})})}function le(e,t){return e.mail?t.emailVerified?`Check your email: we sent a link to ${t.email}. Open it to confirm the change.`:`Check your new email to confirm it.`:`The cloud cannot send email; the link is in its log.`}function ue({account:e,user:t}){let[n,r]=(0,L.useState)(!1),i=z(),a=H((n,a)=>void i.run(()=>c(e=>e.changeEmail({newEmail:n.newEmail})),le(e,t)).then(e=>e&&(a.reset(),r(!1))));return(0,R.jsxs)(`div`,{className:`wl-form`,children:[(0,R.jsxs)(`p`,{className:`wl-account-line`,children:[(0,R.jsx)(`span`,{className:`wl-muted`,children:`Email`}),` `,(0,R.jsx)(`strong`,{children:t.email}),` `,!n&&(0,R.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>r(!0),children:`Change`})]}),n&&(0,R.jsx)(`form`,{onSubmit:a,children:(0,R.jsxs)(w,{children:[(0,R.jsx)(M,{label:`New email`,name:`newEmail`,type:`email`,autoComplete:`email`,required:!0}),(0,R.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:i.busy,children:`Send the link`}),(0,R.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:()=>r(!1),children:`Cancel`})]})}),(0,R.jsx)(V,{a:i})]})}function de({account:e,user:t}){let n=z(),r=H(e=>void n.run(async()=>(await c(t=>t.updateUser({name:e.name.trim()})),await l()),`Saved.`));return(0,R.jsxs)(v,{children:[(0,R.jsxs)(`form`,{className:`wl-form`,onSubmit:r,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(M,{label:`Name`,name:`name`,autoComplete:`name`,required:!0,defaultValue:t.name}),(0,R.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:n.busy,children:`Save`})]}),(0,R.jsx)(V,{a:n})]}),(0,R.jsx)(ue,{account:e,user:t})]})}var Z=e=>new Date(e).getTime();function fe({sessionId:e}){let t=z(),n=z(),[r,i]=(0,L.useState)(null),{run:a}=n,o=(0,L.useCallback)(()=>void a(async()=>i(await c(e=>e.listSessions()))),[a]);(0,L.useEffect)(o,[o]);let s=e=>void t.run(()=>c(t=>t.revokeSession({token:e.token})),`Signed out.`).then(o),l=()=>void t.run(()=>c(e=>e.revokeOtherSessions()),`Signed out of all other devices.`).then(o),u=[{key:`device`,header:`Device`,cell:e=>(0,R.jsx)(`span`,{title:e.userAgent??void 0,children:te(e.userAgent)})},{key:`ip`,header:`Address`,cell:e=>(0,R.jsx)(`span`,{className:`wl-mono wl-small`,children:e.ipAddress||`–`})},{key:`made`,header:`Signed in`,cell:e=>x(Z(e.createdAt)),className:`wl-nowrap`},{key:`seen`,header:`Last active`,cell:e=>h(Z(e.updatedAt)),className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:t=>t.id===e?(0,R.jsx)(S,{tone:`info`,children:`This device`}):(0,R.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>s(t),children:`Sign out`})}],d=(r??[]).some(t=>t.id!==e)&&(0,R.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:l,disabled:t.busy,children:`Sign out all other devices`});return(0,R.jsxs)(v,{title:`Signed in`,action:d,children:[(0,R.jsx)(V,{a:n}),(0,R.jsx)(V,{a:t}),r&&(0,R.jsx)(N,{columns:u,rows:r,rowKey:e=>e.id})]})}var pe=e=>new URL(e).searchParams.get(`secret`)??``;function me({totpURI:e}){let[t,n]=(0,L.useState)(null);(0,L.useEffect)(()=>{let t=!0;return u(()=>import(`./dist-BJrmHKyY.js`).then(r=>t&&n(r.renderSVG(e))),[],import.meta.url),()=>void(t=!1)},[e]);let r=pe(e);return(0,R.jsxs)(`div`,{className:`wl-totp`,children:[(0,R.jsx)(`div`,{className:`wl-totp-qr`,"aria-label":`QR code for your app`,role:`img`,dangerouslySetInnerHTML:t?{__html:t}:void 0}),(0,R.jsxs)(`div`,{className:`wl-totp-text`,children:[(0,R.jsx)(`p`,{children:`Scan the code with your app (for example 1Password, Google Authenticator, or Authy).`}),(0,R.jsx)(`p`,{className:`wl-muted wl-small`,children:`Cannot scan? Type this key into the app:`}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`code`,{className:`wl-mono`,children:r}),` `,(0,R.jsx)(O,{text:r,label:`Copy key`})]})]})]})}function Q({codes:e}){return(0,R.jsxs)(`div`,{className:`wl-share-link`,children:[(0,R.jsx)(`ul`,{className:`wl-backup-codes`,children:e.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(`code`,{className:`wl-mono`,children:e})},e))}),(0,R.jsx)(O,{text:e.join(`
2
+ `),label:`Copy backup codes`}),(0,R.jsx)(`span`,{className:`wl-muted wl-small`,children:`Keep these somewhere safe. Each works once.`})]})}function $({a:e,label:t,title:n,danger:r=!1,onPassword:i}){let{dialog:a,prompt:o}=D(),s=async()=>{let e=await o({title:n,body:`Enter your password to go on.`,confirmLabel:t,danger:r,input:{label:`Your password`,password:!0}});e&&i(e)};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`wl-btn${r?` wl-btn-danger`:``}`,disabled:e.busy,onClick:()=>void s(),children:t}),a]})}function he({setup:e,onDone:t}){let n=z(),r=H(e=>void n.run(async()=>(await c(t=>t.twoFactor.verifyTotp({code:e.code.replace(/\s+/g,``)})),await l())).then(e=>e&&t()));return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(me,{totpURI:e.totpURI}),(0,R.jsx)(Q,{codes:e.backupCodes}),(0,R.jsxs)(`form`,{className:`wl-form`,onSubmit:r,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(M,{label:`Enter a code from your app to finish`,name:`code`,inputMode:`numeric`,autoComplete:`one-time-code`,required:!0}),(0,R.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:n.busy,children:`Finish`})]}),(0,R.jsx)(V,{a:n})]})]})}function ge(){let e=z(),[t,n]=(0,L.useState)(null);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`wl-panel-text`,children:`Sign-in asks for a code from your phone app. Keep your backup codes somewhere safe.`}),t&&(0,R.jsx)(Q,{codes:t}),(0,R.jsxs)(`div`,{className:`wl-form-actions wl-form-actions-start`,children:[(0,R.jsx)($,{a:e,label:`New backup codes`,title:`Make new backup codes?`,onPassword:t=>void e.run(async()=>n((await c(e=>e.twoFactor.generateBackupCodes({password:t}))).backupCodes))}),(0,R.jsx)($,{a:e,label:`Turn off`,title:`Turn off two-step sign-in?`,danger:!0,onPassword:t=>void e.run(async()=>(await c(e=>e.twoFactor.disable({password:t})),await l()))})]}),(0,R.jsx)(V,{a:e})]})}function _e({user:e}){let t=z(),[n,r]=(0,L.useState)(null),i=e=>void t.run(async()=>{let t=await c(t=>t.twoFactor.enable({password:e}));`totpURI`in t&&r(t)}),a=e.twoFactorEnabled?(0,R.jsx)(S,{tone:`success`,children:`On`}):(0,R.jsx)(S,{tone:`neutral`,children:`Off`}),o=(0,R.jsxs)(`h2`,{className:`wl-panel-title-row`,children:[`Two-step sign-in `,a]});return e.twoFactorEnabled?(0,R.jsx)(v,{title:o,children:(0,R.jsx)(ge,{})}):(0,R.jsxs)(v,{title:o,children:[(0,R.jsx)(`p`,{className:`wl-panel-text`,children:`Sign-in also asks for a code from an app on your phone, so a stolen password is not enough.`}),n?(0,R.jsx)(he,{setup:n,onDone:()=>r(null)}):(0,R.jsx)($,{a:t,label:`Turn on`,title:`Turn on two-step sign-in?`,onPassword:i}),(0,R.jsx)(V,{a:t})]})}function ve(){let t=s(),{params:n}=e(),r=t?.user;if(!t||!r)return(0,R.jsx)(v,{children:(0,R.jsx)(C,{title:`Not signed in`})});let i=[{id:`profile`,label:`Profile`,icon:P,render:()=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(k,{title:`Profile`,description:`Your name and email, as your team sees them.`}),(0,R.jsx)(de,{account:t,user:r})]})},{id:`security`,label:`Sign-in and security`,icon:p,render:()=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(k,{title:`Sign-in and security`,description:`Your password, a second step at sign-in, and passkeys. We email you when any of these change.`}),(0,R.jsx)(ce,{}),(0,R.jsx)(_e,{user:r}),(0,R.jsx)(se,{})]})},{id:`devices`,label:`Devices`,icon:I,render:()=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(k,{title:`Devices`,description:`Where you are signed in now. Sign out of any you do not know.`}),(0,R.jsx)(fe,{sessionId:t.sessionId})]})},{id:`apps`,label:`Connected apps`,icon:ee,render:()=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(k,{title:`Connected apps`,description:`AI apps such as Claude that read your data with your sign-in, read-only, for the projects you picked.`}),(0,R.jsx)(m,{list:`./api/me/apps`})]})},{id:`emails`,label:`Emails`,icon:y,render:()=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(k,{title:`Emails`,description:`What WizeLens emails you, and when digests arrive.`}),(0,R.jsx)(ae,{})]})},{id:`delete`,label:`Delete account`,icon:g,render:()=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(k,{title:`Delete account`}),(0,R.jsx)(U,{account:t})]})}];return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(_,{title:`Account`,subtitle:`${r.name} · ${r.email}`}),(0,R.jsx)(E,{thin:!1}),(0,R.jsx)(j,{page:`account`,sections:i,active:n[0]})]})}export{ve as AccountPage};
@@ -0,0 +1 @@
1
+ import{Z as e,vt as t}from"./account-D29x4uz9.js";import{A as n,E as r,I as i,L as a,P as o,T as s,g as c,j as l,q as u,y as d}from"./index-DYrQC7uL.js";var f={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};f.node;var p=u(f),m=t(),h=a(),g=e=>e.allProjects?`All projects`:e.projects.map(e=>e.name).join(`, `)||`No projects left`;function _({list:t,team:a}){let{data:u,error:f,reload:p}=r(t),[_,v]=(0,m.useState)(null),{dialog:y,confirm:b}=c(),x=async n=>{await b({title:`Disconnect ${n.app}?`,body:`${n.app} loses access at once. To use it again, connect it again from the app.`,confirmLabel:`Disconnect`,danger:!0})&&v(await s(()=>e(`DELETE`,`${t}/${n.id}`),p))},S=[{key:`app`,header:`App`,cell:e=>(0,h.jsx)(`strong`,{children:e.app})},...a?[{key:`who`,header:`Connected by`,cell:e=>e.userEmail}]:[{key:`org`,header:`Organization`,cell:e=>e.orgName}],{key:`projects`,header:`Can read`,cell:g,className:`wl-wrap`},{key:`made`,header:`Connected`,cell:e=>l(e.createdMs),className:`wl-nowrap`},{key:`used`,header:`Last used`,cell:e=>e.usedMs?n(e.usedMs):`Never`,className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,h.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void x(e),children:`Disconnect`})}],C=(0,h.jsx)(o,{title:`No connected apps`,children:`Add WizeLens to Claude or another MCP client. It asks you to sign in here and pick projects.`});return(0,h.jsxs)(i,{flush:!0,children:[(f||_)&&(0,h.jsx)(`div`,{className:`wl-banner wl-banner-error`,role:`alert`,children:f??_}),u&&(0,h.jsx)(d,{columns:S,rows:u.apps,rowKey:e=>e.id,empty:C}),y]})}export{p as n,_ as t};
@@ -0,0 +1 @@
1
+ import{B as e,E as t,T as n,X as r,Z as i,_ as a,i as o,l as s,n as c,o as l,r as u,vt as d}from"./account-D29x4uz9.js";import{t as f}from"./auth-client-Bkk9PzK9.js";import{n as p,t as m}from"./AppsPanel-Dq0tvHKE.js";import{A as h,C as g,D as _,E as v,F as y,G as b,H as x,I as S,L as ee,M as te,N as ne,O as C,P as w,R as re,S as T,T as E,U as ie,V as ae,W as D,a as oe,b as se,d as O,f as ce,g as k,h as A,i as j,j as M,k as N,l as P,m as le,n as ue,o as de,p as F,q as I,r as L,s as R,t as fe,u as pe,w as me,x as z,y as B}from"./index-DYrQC7uL.js";var he={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};he.node;var ge=I(he),_e={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};_e.node;var ve=I(_e),V={name:`file-clock`,size:24,node:[[`path`,{d:`M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85`,key:`ryk6xj`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 14v2.2l1.6 1`,key:`6m4bie`}],[`circle`,{cx:`8`,cy:`16`,r:`6`,key:`10v15b`}]]};V.node;var ye=I(V),H={name:`folder-kanban`,size:24,node:[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]};H.node;var be=I(H),U={name:`id-card`,size:24,node:[[`path`,{d:`M13 19a4 4 0 00-8 0`,key:`cugzd5`}],[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]};U.node;var xe=I(U),W={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};W.node;var Se=I(W),G={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};G.node;var Ce=I(G),K=ee();function we({projectId:e,projectName:t}){let{data:r,reload:a}=v(`./api/projects/${e}/shares`),{dialog:o,confirm:s}=k(),c=async t=>await s({title:`Revoke this link?`,body:`Anyone who has it can no longer open the trace.`,confirmLabel:`Revoke link`,danger:!0})&&void E(()=>i(`DELETE`,`./api/projects/${e}/shares/${t.id}`),a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`Shared links`,description:`Read-only links to single traces of ${t}, for people without an account. Make one with Share on a trace.`}),(0,K.jsx)(S,{flush:!0,children:(0,K.jsx)(B,{columns:[{key:`trace`,header:`Trace`,cell:e=>(0,K.jsx)(`a`,{className:`wl-mono`,href:n(e.traceId),children:ne(e.traceId)})},{key:`made`,header:`Shared`,cell:e=>h(e.createdMs),className:`wl-nowrap`},{key:`ends`,header:`Works until`,cell:e=>M(e.expiresMs),className:`wl-nowrap`},{key:`views`,header:`Views`,num:!0,cell:e=>e.views},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void c(e),children:`Revoke`})}],rows:r??[],rowKey:e=>e.id,empty:(0,K.jsx)(w,{title:`No shared links`,children:`Open a trace and use Share to make one.`})})}),o]})}var q=d(),Te={"org.create":`Created the organization`,"org.update":`Changed the organization`,"member.invite":`Invited someone`,"member.join":`Joined`,"member.leave":`Left`,"member.remove":`Removed a member`,"member.role":`Changed a role`,"invite.cancel":`Cancelled an invite`,"project.create":`Added a project`,"project.clear":`Cleared a project's data`,"project.delete":`Deleted a project`,"project.update":`Changed a project's settings`,"service.forget":`Forgot offline hosts`,"key.create":`Made a key`,"key.revoke":`Revoked a key`,"key.rotate":`Rotated a key`,"project.role":`Changed access to a project`,"project.settings":`Changed project settings`,"slo.create":`Added an SLO`,"slo.delete":`Deleted an SLO`,"issue.resolve":`Resolved an issue`,"issue.ignore":`Ignored an issue`,"issue.reopen":`Reopened an issue`,"issue.assign":`Assigned an issue`,"share.create":`Shared a trace`,"share.revoke":`Revoked a shared link`,"sso.create":`Added an identity provider`,"sso.update":`Changed an identity provider`,"sso.delete":`Removed an identity provider`,"sso.verify":`Proved a single sign-on domain`,"mcp.call":`AI agent read data`,"app.connect":`Connected an app`,"app.disconnect":`Disconnected an app`,"uptime.create":`Added an uptime check`,"uptime.update":`Changed an uptime check`,"uptime.delete":`Deleted an uptime check`,"status.enable":`Turned on a status page or made a new link`,"status.disable":`Turned off a status page`,"plan.change":`Changed the plan`,"billing.cap":`Set the spend cap`,"ingest.blocked":`Stopped taking data`,"audit.export":`Exported the audit log`,"scim.token.create":`Made a SCIM token`,"scim.token.revoke":`Revoked a SCIM token`,"scim.user.create":`SCIM added a person`,"scim.user.update":`SCIM changed a person`,"scim.user.delete":`SCIM removed a person`,"scim.group.create":`SCIM added a group`,"scim.group.update":`SCIM changed a group`,"scim.group.delete":`SCIM removed a group`},Ee=e=>Te[e]??e,De={org:`Organization`,member:`Members`,invite:`Invites`,project:`Projects`,key:`API keys`,share:`Shared links`,sso:`Single sign-on`,mcp:`AI agents`,app:`Connected apps`,slo:`SLOs`,issue:`Issues`,service:`Services`,audit:`Audit log`,plan:`Plan`,billing:`Billing`,ingest:`Data intake`,scim:`SCIM`};function Oe(e){return{people:new Map((e?.members??[]).map(e=>[e.userId,e.name])),keys:new Map((e?.keys??[]).map(e=>[e.id,e.name])),projects:new Map((e?.projects??[]).map(e=>[e.id,e.name]))}}function ke(e,t){let[n,r=``]=e.split(`:`);return n===`user`?t.people.get(r)??`Former member`:n===`key`?t.keys.has(r)?`Key ${t.keys.get(r)}`:`Revoked key`:n===`scim`?`Identity provider (SCIM)`:n===`stripe`?`Stripe`:`WizeLens`}var J=(e,t)=>typeof e==`string`?t.projects.get(e)??`deleted project`:null;function Ae(e,t){let n=[];typeof e.keyId==`string`&&t.keys.has(e.keyId)&&n.push(t.keys.get(e.keyId)),typeof e.app==`string`&&n.push(`with ${e.app}`),e.allProjects===!0&&n.push(`all projects`),typeof e.userEmail==`string`&&n.push(`for ${e.userEmail}`),typeof e.name==`string`&&n.push(e.name),typeof e.title==`string`&&n.push(e.title),typeof e.url==`string`&&n.push(e.url),typeof e.email==`string`&&n.push(e.email),typeof e.role==`string`&&n.push(e.role===`none`?`no access`:`as ${e.role}`),typeof e.kind==`string`&&n.push(`${e.kind} key`);let r=J(e.projectId,t);return r&&r!==e.name&&n.push(`project ${r}`),Array.isArray(e.projectIds)&&n.push(`for ${e.projectIds.map(e=>J(e,t)).join(`, `)}`),typeof e.providerId==`string`&&n.push(e.providerId),typeof e.retentionDays==`number`&&n.push(`keep data ${e.retentionDays} days`),typeof e.logRetentionDays==`number`&&n.push(`keep logs ${e.logRetentionDays} days`),e.logRetentionDays===null&&n.push(`logs follow the organization`),typeof e.slowQueryMs==`number`&&n.push(`slow query ${e.slowQueryMs} ms`),typeof e.nPlusOneThreshold==`number`&&n.push(`N+1 at ${e.nPlusOneThreshold}`),Array.isArray(e.redactKeys)&&n.push(`redact ${e.redactKeys.join(`, `)}`),typeof e.userId==`string`&&`role`in e&&n.push(`for ${t.people.get(e.userId)??`a former member`}`),`role`in e&&e.role===null&&n.push(`back to the organization role`),typeof e.lines==`number`&&n.push(`${e.lines} lines`),typeof e.days==`number`&&n.push(`for ${e.days} days`),typeof e.plan==`string`&&n.push(`${typeof e.from==`string`?`${e.from} to `:``}${e.plan}`),e.capUsd!==void 0&&n.push(e.capUsd===null?`no cap`:`$${String(e.capUsd)} a month`),typeof e.reason==`string`&&n.push(e.reason===`cap`?`spend cap reached`:`Free plan data used up`),typeof e.userName==`string`&&n.push(e.userName),typeof e.format==`string`&&n.push(e.format.toUpperCase()),typeof e.removed==`number`&&n.push(`${e.removed} ${e.removed===1?`host`:`hosts`}`),typeof e.line==`string`&&n.length===0&&n.push(e.line),n.join(` · `)}var je={sso:`Single sign-on`,scim:`SCIM provisioning`,auditExport:`Audit log export`},Me={sso:`business`,scim:`business`,auditExport:`business`},Ne={unlimited:`Unlimited`,free:`Free`,team:`Team`,business:`Business`,enterprise:`Enterprise`};function Pe(e,t){let{data:n}=R(e);return{allowed:!n||!n.billing||n.plan.features[t],loaded:!!n,plan:n?.plan.name??``}}function Y({feature:e,plan:t,compact:n=!1}){let r=Ne[Me[e]],i=(0,K.jsxs)(`div`,{className:`wl-plan-prompt`,children:[(0,K.jsx)(Ce,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`strong`,{children:[je[e],` is on the `,r,` plan.`]}),(0,K.jsxs)(`p`,{className:`wl-muted`,children:[`This organization is on `,Ne[t]??t,`. Owners and admins can upgrade on the Billing page; nothing else changes.`]})]}),(0,K.jsxs)(`a`,{className:`wl-btn wl-btn-primary`,href:a(`team`,[`billing`]),children:[`Upgrade to `,r]})]});return n?i:(0,K.jsx)(S,{children:i})}var X=100;function Fe(e,t){let{data:n}=v(`./api/orgs/${e}/audit/facets`);return{what:[[``,`Every action`],...[...new Set((n?.actions??[]).map(e=>e.split(`.`)[0]))].map(e=>[`${e}.`,De[e]??e])],who:[[``,`Anyone`],...(n?.actors??[]).map(e=>[e,ke(e,t)])]}}function Ie(e){let t=v(e),[n,i]=(0,q.useState)([]),[a,o]=(0,q.useState)(!1);(0,q.useEffect)(()=>(i([]),o(!1)),[e]);let s=[...t.data??[],...n];return{rows:s,more:()=>{let t=s.at(-1);t&&r(`${e}&before=${t.timeMs}`).then(e=>(i(t=>[...t,...e]),o(e.length<X)))},done:a||t.data!==null&&t.data.length<X,error:t.error}}function Le({orgId:e,org:t}){let[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(``),o=Oe(t),s=Fe(e,o),c=new URLSearchParams({...n?{action:n}:{},...i?{actor:i}:{}}).toString(),{rows:l,more:u,done:d,error:f}=Ie(`./api/orgs/${e}/audit?limit=${X}${c?`&${c}`:``}`),p=[{key:`time`,header:`When`,cell:e=>(0,K.jsx)(`span`,{title:te(e.timeMs),children:h(e.timeMs)}),className:`wl-nowrap`},{key:`who`,header:`Who`,cell:e=>ke(e.actor,o),className:`wl-nowrap`},{key:`what`,header:`What`,cell:e=>(0,K.jsx)(`strong`,{children:Ee(e.action)}),className:`wl-nowrap`},{key:`detail`,header:`Detail`,cell:e=>(0,K.jsx)(`span`,{className:`wl-muted`,children:Ae(e.detail,o)}),className:`wl-wrap`}],m=Pe(e,`auditExport`),g=t=>`./api/orgs/${e}/audit/export?format=${t}${c?`&${c}`:``}`,v=m.allowed&&(0,K.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,K.jsxs)(`a`,{className:`wl-btn`,href:g(`csv`),download:!0,children:[(0,K.jsx)(D,{"aria-hidden":`true`}),` Export CSV`]}),(0,K.jsxs)(`a`,{className:`wl-btn`,href:g(`json`),download:!0,children:[(0,K.jsx)(D,{"aria-hidden":`true`}),` Export JSON`]})]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`Audit log`,description:`Every change to the organization, its members, projects, keys, settings, links, and plan, and every AI agent call. Newest first. The export follows the filters.`,action:v}),m.loaded&&!m.allowed&&(0,K.jsx)(Y,{feature:`auditExport`,plan:m.plan}),(0,K.jsxs)(`section`,{className:`wl-panel wl-filters`,children:[(0,K.jsx)(_,{label:`What`,value:n,options:s.what,onChange:r}),(0,K.jsx)(_,{label:`Who`,value:i,options:s.who,onChange:a})]}),f&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:f}),(0,K.jsxs)(S,{flush:!0,children:[(0,K.jsx)(B,{columns:p,rows:l,rowKey:e=>`${e.timeMs}:${e.action}:${e.actor}`,empty:(0,K.jsx)(w,{children:c?`Nothing matches these filters.`:`Nothing yet.`})}),!d&&l.length>0&&(0,K.jsx)(`div`,{className:`wl-panel-more`,children:(0,K.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:u,children:`Load older`})})]})]})}function Re({org:e}){let t=R(e.id).data,n=t?.billing?t.maxRetentionDays:400,[r,a]=(0,q.useState)(e.name),[o,s]=(0,q.useState)(e.retentionDays),[c,u]=(0,q.useState)(null);return(0,K.jsx)(S,{title:`General`,children:(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:t=>{t.preventDefault(),E(()=>i(`PATCH`,`./api/orgs/${e.id}`,{name:r,retentionDays:o}),()=>void l()).then(e=>u(e??`Saved.`))},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Name`,required:!0,maxLength:100,value:r,onChange:e=>a(e.target.value)}),(0,K.jsx)(z,{label:`Keep data for (days)`,narrow:!0,type:`number`,min:1,max:n,required:!0,value:o,onChange:e=>s(Number(e.target.value)),hint:`1 to ${n}${n<400?` on the ${t?.plan.name} plan`:``}. Older traces are deleted every few minutes.`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Save`})]}),c&&(0,K.jsx)(`p`,{className:`wl-muted wl-small`,role:`status`,children:c})]})})}function ze(){let[t,n]=(0,q.useState)(``),[r,a]=(0,q.useState)(null);return(0,K.jsxs)(S,{title:`Another organization`,children:[(0,K.jsx)(`p`,{className:`wl-muted wl-settings-note`,children:`For a separate company or client. You own it, and it starts with one project.`}),(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:r=>{r.preventDefault(),E(async()=>{let r=await i(`POST`,`./api/orgs`,{name:t}),a=(await l()).orgs?.find(e=>e.id===r.id)?.projects[0];a&&e(a.id),n(``)},()=>void l()).then(a)},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Name`,required:!0,maxLength:100,value:t,onChange:e=>n(e.target.value),placeholder:`Acme`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Create organization`})]}),r&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:r})]})]})}function Be({org:e}){let[t,n]=(0,q.useState)(``),[r,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(null);return(0,K.jsxs)(S,{title:`Delete this organization`,className:`wl-panel-danger`,children:[(0,K.jsxs)(`p`,{className:`wl-muted wl-settings-note`,children:[`This deletes `,e.name,` with all its projects, keys, alerts, and data. It cannot be undone.`]}),(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:t=>{t.preventDefault(),E(()=>i(`DELETE`,`./api/orgs/${e.id}`,{password:r}),()=>void l()).then(s)},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Type ${e.name} to confirm`,required:!0,value:t,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,K.jsx)(z,{label:`Your password`,type:`password`,required:!0,value:r,onChange:e=>a(e.target.value),autoComplete:`current-password`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-danger`,disabled:t!==e.name,children:`Delete organization`})]}),o&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:o})]})]})}var Ve={free:[`Unlimited users`,`Alerts, MCP, and share links`,`Stops at the included data`],team:[`Everything in Free`,`Extra data billed per GB, no hard stop`,`Optional spend cap`],business:[`Everything in Team`,`SAML and OIDC single sign-on`,`SCIM provisioning and audit log export`],enterprise:[`Data, retention, and SLA set with us`,`Data residency and BAA`,`Up to 400 days of data`]};function He(e,t){return e.monthlyUsd===null?`Custom`:e.monthlyUsd===0?`$0`:t?`${j(e.annualUsd/12)}/mo`:`${j(e.monthlyUsd)}/mo`}function Ue({p:e,usage:t,orgId:n,annual:r,busy:i,run:a}){let o=t.plan.id===e.id,s=t.plan.id===`team`||t.plan.id===`business`;if(o)return(0,K.jsx)(`span`,{className:`wl-badge wl-badge-info`,children:`Current plan`});if(e.id===`enterprise`)return(0,K.jsx)(`a`,{className:`wl-btn`,href:`mailto:hello@wizelens.com?subject=WizeLens%20Enterprise`,children:`Talk to us`});if(e.id===`free`)return s?(0,K.jsx)(`button`,{type:`button`,className:`wl-btn`,disabled:i,onClick:()=>a(()=>fe(n)),children:`Move to Free`}):null;let c=e.id;return(0,K.jsx)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,disabled:i,onClick:()=>a(()=>ue(n,c,r)),children:s?`Switch to ${e.name}`:`Choose ${e.name}`})}function We({usage:e,orgId:t,manage:n}){let[r,i]=(0,q.useState)(e.subscription?.interval===`year`),[a,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null),u=e=>{s(!0),e().catch(e=>(l(o(e)),s(!1)))};return(0,K.jsxs)(S,{title:`Plans`,action:(0,K.jsxs)(`div`,{className:`wl-segmented`,role:`group`,"aria-label":`Billing period`,children:[(0,K.jsx)(`button`,{type:`button`,"aria-pressed":!r,className:r?``:`wl-active`,onClick:()=>i(!1),children:`Monthly`}),(0,K.jsx)(`button`,{type:`button`,"aria-pressed":r,className:r?`wl-active`:``,onClick:()=>i(!0),children:`Yearly, 2 months free`})]}),children:[c&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:c}),(0,K.jsx)(`div`,{className:`wl-plans`,children:e.plans.map(i=>(0,K.jsxs)(`article`,{className:`wl-plan${e.plan.id===i.id?` wl-plan-current`:``}`,children:[(0,K.jsx)(`h3`,{children:i.name}),(0,K.jsx)(`div`,{className:`wl-plan-price`,children:He(i,r)}),(0,K.jsxs)(`p`,{className:`wl-muted wl-small`,children:[i.includedGb===null?`Data set with us`:`${L(i.includedGb)} a month`,` · `,i.maxRetentionDays,` days of data`]}),(0,K.jsx)(`ul`,{children:(Ve[i.id]??[]).map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(b,{"aria-hidden":`true`}),` `,e]},e))}),n&&(0,K.jsx)(Ue,{p:i,usage:e,orgId:t,annual:r,busy:a,run:u})]},i.id))}),(0,K.jsx)(`p`,{className:`wl-muted wl-small`,children:`Extra data on Team and Business, per month: $0.30 a GB for the first 500 GB above the included GB, $0.20 up to 2 TB, then $0.10. Never a seat fee.`})]})}function Ge({usage:e}){let t=e.includedGb;if(t===null)return(0,K.jsxs)(`p`,{className:`wl-muted`,children:[L(e.monthGb),` this month. This plan has no data limit.`]});let n=Math.min(100,e.monthGb/t*100),r=e.blocked?`wl-usage-full`:n>=80?`wl-usage-warn`:``;return(0,K.jsxs)(`div`,{className:`wl-usage`,children:[(0,K.jsxs)(`div`,{className:`wl-usage-head`,children:[(0,K.jsx)(`strong`,{children:L(e.monthGb)}),(0,K.jsxs)(`span`,{className:`wl-muted`,children:[`of `,L(t),` included this month`]})]}),(0,K.jsx)(`div`,{className:`wl-usage-track ${r}`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n),"aria-label":`Data used this month`,children:(0,K.jsx)(`i`,{style:{width:`${n}%`}})})]})}var Ke=e=>new Date(`${e}-01T00:00:00Z`).toLocaleDateString(void 0,{month:`long`,year:`numeric`,timeZone:`UTC`});function qe({month:e,days:t}){if(!t.length)return(0,K.jsx)(`p`,{className:`wl-muted wl-small`,children:`No data yet this month.`});let[n,r]=e.split(`-`).map(Number),i=new Date(Date.UTC(n,r,0)).getUTCDate(),a=new Map(t.map(e=>[e.day,e])),o=Math.max(...t.map(e=>e.gb),1e-6);return(0,K.jsx)(`div`,{className:`wl-usage-days`,"aria-label":`Data per day`,children:Array.from({length:i},(t,n)=>{let r=`${e}-${String(n+1).padStart(2,`0`)}`,i=a.get(r),s=i?`${r}: ${L(i.gb)}, ${i.spans.toLocaleString()} spans, ${i.logs.toLocaleString()} logs, ${i.points.toLocaleString()} metric points`:`${r}: no data`;return(0,K.jsx)(`span`,{title:s,children:i&&i.gb>0&&(0,K.jsx)(`i`,{style:{height:`${Math.max(4,i.gb/o*100)}%`}})},r)})})}function Je({usage:e}){let t=e.plan.overage,n=e.subscription,r=[[`Projected by month end`,`${L(e.projectedGb)}${!t&&e.includedGb!==null&&e.projectedGb>e.includedGb?` (stops at ${L(e.includedGb)})`:``}`],...t?[[`Extra data so far`,j(e.overageUsd)],[`Projected extra data`,j(e.projectedOverageUsd)]]:[],...n?.periodEndMs?[[n.cancelAtPeriodEnd?`Plan ends`:`Renews`,M(n.periodEndMs)]]:[]];return(0,K.jsxs)(S,{title:`Usage in ${Ke(e.month)}`,children:[e.blocked&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:e.blocked}),(0,K.jsx)(Ge,{usage:e}),(0,K.jsx)(`dl`,{className:`wl-usage-facts`,children:r.map(([e,t])=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:e}),(0,K.jsx)(`dd`,{children:t})]},e))}),(0,K.jsx)(qe,{month:e.month,days:e.days}),(0,K.jsx)(`p`,{className:`wl-muted wl-small`,children:`A GB is the size of the data your apps send, as sent. Months are calendar months in UTC.`})]})}function Ye({orgId:e,usage:t,reload:n}){let[r,i]=(0,q.useState)(t.spendCapUsd===null?``:String(t.spendCapUsd)),[a,o]=(0,q.useState)(null);return(0,K.jsxs)(S,{title:`Spend cap`,children:[(0,K.jsx)(`p`,{className:`wl-muted wl-settings-note`,children:`The most extra data may cost in a month. When it is reached, new data is refused until the 1st, so the bill never surprises you.`}),(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:t=>{t.preventDefault();let i=r.trim()===``?null:Number(r);E(()=>de(e,i),n).then(e=>o(e??`Saved.`))},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Monthly limit for extra data (USD)`,narrow:!0,type:`number`,min:0,step:1,value:r,onChange:e=>i(e.target.value),placeholder:`No limit`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Save`})]}),a&&(0,K.jsx)(`p`,{className:`wl-muted wl-small`,role:`status`,children:a})]})]})}function Xe({orgId:e}){let[t,n]=(0,q.useState)(null);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,className:`wl-btn`,onClick:()=>void oe(e).catch(e=>n(o(e))),children:[(0,K.jsx)(ve,{"aria-hidden":`true`}),` Manage billing`]}),t&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:t})]})}function Ze({org:e}){let{data:t,error:n,reload:r}=R(e.id),i=t?.plan.id===`team`||t?.plan.id===`business`,a=t?.subscription?.status===`past_due`?` The last payment failed; Stripe retries it, and the plan stays until the retries end.`:``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`Billing`,description:t?`${e.name} is on the ${t.plan.name} plan.${a}`:`Your plan and this month's data.`,action:i&&(0,K.jsx)(Xe,{orgId:e.id})}),n&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:n}),t&&(0,K.jsx)(Je,{usage:t}),t&&(0,K.jsx)(We,{usage:t,orgId:e.id,manage:!0}),t&&i&&e.role===`owner`&&(0,K.jsx)(Ye,{orgId:e.id,usage:t,reload:r},String(t.spendCapUsd))]})}function Qe({orgId:e,reload:t,onClose:n}){let[r,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null);return(0,K.jsx)(S,{title:`New SCIM token`,className:`wl-panel-form`,action:(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:n,children:o?`Done`:`Close`}),children:(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:n=>{n.preventDefault(),i(`POST`,`./api/orgs/${e}/scim/tokens`,{name:r}).then(e=>(s(e.token),l(null),t()),e=>l(e instanceof Error?e.message:String(e)))},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Name`,value:r,onChange:e=>a(e.target.value),placeholder:`Okta`,hint:`The identity provider that uses it.`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:!!o,children:`Create token`})]}),o&&(0,K.jsxs)(`div`,{className:`wl-share-link`,children:[(0,K.jsx)(`code`,{className:`wl-mono wl-small`,children:o}),` `,(0,K.jsx)(N,{text:o,label:`Copy token`}),(0,K.jsx)(`span`,{className:`wl-muted wl-small`,children:`Copy it now: it is not shown again. Paste it as the bearer token (API token) in the identity provider.`})]}),c&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:c})]})})}function $e({orgId:e,info:t,reload:n}){let{dialog:r,confirm:a}=k(),o=async t=>await a({title:`Revoke ${t.name}?`,body:`The identity provider can no longer add or remove people. People it added stay.`,confirmLabel:`Revoke token`,danger:!0})&&void E(()=>i(`DELETE`,`./api/orgs/${e}/scim/tokens/${t.id}`),n);return(0,K.jsxs)(S,{flush:!0,children:[r,(0,K.jsx)(B,{columns:[{key:`name`,header:`Token`,cell:e=>(0,K.jsxs)(`span`,{className:`wl-who`,children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsxs)(`small`,{className:`wl-mono`,children:[e.prefix,`…`]})]})},{key:`made`,header:`Created`,cell:e=>M(e.createdMs),className:`wl-nowrap`},{key:`used`,header:`Last used`,cell:e=>e.lastUsedMs?h(e.lastUsedMs):`Never`,className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void o(e),children:`Revoke`})}],rows:t.tokens,rowKey:e=>e.id,empty:(0,K.jsx)(w,{title:`No SCIM token yet`,children:`Make one, then paste it with the base URL into Okta, Entra ID, or another identity provider.`})})]})}function et({orgId:e,plan:t}){let{data:n,error:r,reload:i}=v(`./api/orgs/${e}/scim`),[a,o]=(0,q.useState)(!1),s=n?.allowed&&!a&&(0,K.jsxs)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,onClick:()=>o(!0),children:[(0,K.jsx)(x,{"aria-hidden":`true`}),` New token`]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`SCIM provisioning`,description:`Your identity provider adds people as members and removes them when they are deactivated. Admins set roles here.`,action:s}),r&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:r}),n&&!n.allowed&&(0,K.jsx)(Y,{feature:`scim`,plan:t}),n?.allowed&&(0,K.jsx)(S,{children:(0,K.jsxs)(`div`,{className:`wl-share-link`,children:[(0,K.jsx)(`span`,{className:`wl-muted wl-small`,children:`SCIM base URL`}),(0,K.jsx)(`code`,{className:`wl-mono wl-small`,children:n.baseUrl}),` `,(0,K.jsx)(N,{text:n.baseUrl})]})}),a&&(0,K.jsx)(Qe,{orgId:e,reload:i,onClose:()=>o(!1)}),n?.allowed&&(0,K.jsx)($e,{orgId:e,info:n,reload:i})]})}var tt=[[`oidc`,`OpenID Connect`],[`saml`,`SAML 2.0`]],nt=e=>`${f()}/sso/saml2/sp/metadata?providerId=${encodeURIComponent(e)}`;function rt(e,t,n){let r={providerId:n.providerId,domain:n.domain.trim().toLowerCase(),organizationId:t};if(e===`oidc`)return{...r,issuer:n.issuer.trim(),oidcConfig:{clientId:n.clientId,clientSecret:n.clientSecret,pkce:!0}};let i={entityID:n.entityId.trim(),cert:n.cert.trim()};return{...r,issuer:nt(n.providerId),samlConfig:{entryPoint:n.entryPoint.trim(),idpMetadata:i,wantAssertionsSigned:!0}}}function it(){return(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Issuer URL`,name:`issuer`,type:`url`,required:!0,placeholder:`https://acme.okta.com`,hint:`Its origin must be in the cloud's --sso-origins.`}),(0,K.jsx)(z,{label:`Client ID`,name:`clientId`,required:!0,autoComplete:`off`}),(0,K.jsx)(z,{label:`Client secret`,name:`clientSecret`,type:`password`,required:!0,autoComplete:`off`})]})}function at(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Identity provider sign-in URL`,name:`entryPoint`,type:`url`,required:!0,placeholder:`https://idp.acme.com/sso/saml`}),(0,K.jsx)(z,{label:`Identity provider entity ID`,name:`entityId`,required:!0,placeholder:`http://www.okta.com/exk…`})]}),(0,K.jsx)(me,{label:`Signing certificate (PEM)`,name:`cert`,required:!0,placeholder:`-----BEGIN CERTIFICATE-----`,hint:`Send the email as the NameID or as an email attribute.`})]})}function ot({orgId:e,reload:t,onClose:n}){let[r,i]=(0,q.useState)(`oidc`),[a,o]=(0,q.useState)(null);return(0,K.jsx)(S,{title:`Add an identity provider`,className:`wl-panel-form`,action:(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:n,children:`Close`}),children:(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:i=>{i.preventDefault();let a=i.currentTarget,s=Object.fromEntries([...new FormData(a)].map(([e,t])=>[e,String(t)]));E(async()=>{await c(t=>t.sso.register(rt(r,e,s))),a.reset()},t).then(e=>(o(e),e||n()))},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(g,{label:`Protocol`,value:r,options:tt,onChange:i,hint:r===`oidc`?`Okta, Entra ID, Google, Auth0, Keycloak.`:`Any SAML 2.0 identity provider.`}),(0,K.jsx)(z,{label:`Provider id`,name:`providerId`,required:!0,pattern:`[a-z0-9][a-z0-9\\-]{1,39}`,placeholder:`acme`,hint:`2 to 40 lowercase letters, digits, dashes.`}),(0,K.jsx)(z,{label:`Email domain`,name:`domain`,required:!0,placeholder:`acme.com`,hint:`People with emails at this domain can use it.`})]}),r===`oidc`?(0,K.jsx)(it,{}):(0,K.jsx)(at,{}),a&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:a}),(0,K.jsxs)(`div`,{className:`wl-form-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Add provider`})]})]})})}function st(e){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,s]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let t=!0;return c(e=>e.sso.providers()).then(r=>t&&n(r.providers.filter(t=>t.organizationId===e)),e=>t&&i(o(e))),()=>void(t=!1)},[e,a]),{list:t,error:r,reload:()=>s(e=>e+1)}}var Z=({label:e,value:t})=>(0,K.jsxs)(`div`,{className:`wl-share-link`,children:[(0,K.jsx)(`span`,{className:`wl-muted wl-small`,children:e}),(0,K.jsx)(`code`,{className:`wl-mono wl-small`,children:t}),` `,(0,K.jsx)(N,{text:t})]});function ct({p:e}){let t=encodeURIComponent(e.providerId);return e.type===`oidc`?(0,K.jsx)(Z,{label:`Redirect (callback) URL`,value:`${f()}/sso/callback/${t}`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{label:`ACS (reply) URL`,value:`${f()}/sso/saml2/sp/acs/${t}`}),(0,K.jsx)(Z,{label:`Entity ID (audience)`,value:e.issuer}),(0,K.jsx)(Z,{label:`Metadata URL`,value:e.spMetadataUrl})]})}function lt({p:e,reload:t}){let[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(null);return e.domainVerified?null:(0,K.jsxs)(`div`,{className:`wl-sso-proof`,children:[(0,K.jsx)(`p`,{className:`wl-muted wl-small`,children:`Prove you own the domain: add a TXT record, wait for DNS, then check.`}),n&&e.domain.split(`,`).map(t=>(0,K.jsx)(Z,{label:`TXT name for ${t.trim()}`,value:`_wizelens-sso-${e.providerId}.${t.trim()}`},t)),n&&(0,K.jsx)(Z,{label:`TXT value`,value:n}),(0,K.jsxs)(`span`,{className:`wl-row-actions`,children:[!n&&(0,K.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:()=>void c(t=>t.sso.requestDomainVerification({providerId:e.providerId})).then(e=>r(e.domainVerificationToken),e=>a(o(e))),children:`Show the DNS record`}),n&&(0,K.jsx)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,onClick:()=>void E(()=>c(t=>t.sso.verifyDomain({providerId:e.providerId})),t).then(a),children:`Check DNS now`})]}),i&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:i})]})}function ut({p:e,reload:t}){let[n,r]=(0,q.useState)(null),{dialog:i,confirm:a}=k(),o=async()=>await a({title:`Remove ${e.providerId}?`,body:`People who sign in with it can no longer do so. Their accounts stay.`,confirmLabel:`Remove provider`,danger:!0})&&void E(()=>c(t=>t.sso.deleteProvider({providerId:e.providerId})),t).then(r);return(0,K.jsxs)(S,{children:[i,(0,K.jsxs)(`div`,{className:`wl-sso-item`,children:[(0,K.jsxs)(`div`,{className:`wl-sso-head`,children:[(0,K.jsx)(`strong`,{children:e.providerId}),` `,(0,K.jsxs)(`span`,{className:`wl-muted`,children:[e.type===`oidc`?`OpenID Connect`:`SAML`,` · `,e.domain]}),(0,K.jsx)(C,{tone:e.domainVerified?`success`:`warning`,children:e.domainVerified?`Domain proven`:`Domain not proven`}),(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void o(),children:`Remove`})]}),(0,K.jsx)(ct,{p:e}),(0,K.jsx)(lt,{p:e,reload:t}),n&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:n})]})]})}function dt({orgId:e}){let{list:t,error:n,reload:r}=st(e),[i,a]=(0,q.useState)(!1),o=Pe(e,`sso`),s=o.allowed&&!i&&(0,K.jsxs)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,onClick:()=>a(!0),children:[(0,K.jsx)(x,{"aria-hidden":`true`}),` Add provider`]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`Single sign-on`,description:`People with an email at a proven domain sign in with your identity provider (OpenID Connect or SAML). New people join as members.`,action:s}),n&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:n}),!o.allowed&&(0,K.jsx)(Y,{feature:`sso`,plan:o.plan}),i&&(0,K.jsx)(ot,{orgId:e,reload:r,onClose:()=>a(!1)}),o.allowed&&t&&t.length===0&&!i&&(0,K.jsx)(S,{children:(0,K.jsx)(w,{title:`No identity provider yet`,children:`Add Okta, Entra ID, Google Workspace, Auth0, Keycloak, or any SAML 2.0 provider.`})}),t?.map(e=>(0,K.jsx)(ut,{p:e,reload:r},e.providerId))]})}function ft({orgId:e,mail:t,reload:n,onClose:r}){let[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(`member`),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null);return(0,K.jsx)(S,{title:`Invite someone`,className:`wl-panel-form`,action:(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:r,children:`Close`}),children:(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:t=>{t.preventDefault(),E(async()=>{let t=await c(t=>t.organization.inviteMember({email:i,role:o,organizationId:e}));u(O(t.id)),a(``)},n).then(f)},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Email`,type:`email`,required:!0,value:i,onChange:e=>a(e.target.value),placeholder:`sam@company.com`,autoFocus:!0}),(0,K.jsx)(g,{label:`Role`,value:o,options:le,onChange:s,hint:ce[o]}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Send invite`})]}),l&&(0,K.jsxs)(`div`,{className:`wl-share-link`,children:[(0,K.jsx)(`code`,{className:`wl-mono wl-small`,children:l}),` `,(0,K.jsx)(N,{text:l,label:`Copy invite link`}),(0,K.jsxs)(`span`,{className:`wl-muted wl-small`,children:[`Send this link to them. It works once, for 7 days.`,t&&` We emailed it too.`]})]}),d&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:d})]})})}function pt({orgId:e,mail:t,data:n,reload:r}){let[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),{dialog:l,confirm:u}=k(),d=(e,t=null)=>void E(e,r).then(e=>(a(e),s(e?null:t))),f=n=>d(()=>c(t=>t.organization.inviteMember({email:n.email,role:n.role,organizationId:e,resend:!0})),t?`We sent the invite to ${n.email} again.`:`The invite works for 7 more days.`),p=async e=>await u({title:`Cancel this invite?`,body:`The link for ${e.email} stops working.`,confirmLabel:`Cancel invite`,danger:!0})&&d(()=>c(t=>t.organization.cancelInvitation({invitationId:e.id})));return(0,K.jsxs)(S,{title:`Pending invites`,flush:!0,children:[i&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error wl-panel-banner`,children:i}),o&&(0,K.jsx)(`p`,{className:`wl-panel-note`,role:`status`,children:o}),(0,K.jsx)(B,{columns:[{key:`email`,header:`Email`,cell:e=>(0,K.jsx)(`strong`,{children:e.email})},{key:`role`,header:`Role`,cell:e=>F[e.role]},{key:`ends`,header:`Link works until`,cell:e=>M(e.expiresMs),className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,K.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,K.jsx)(N,{text:O(e.id),label:`Copy link`,asLink:!0}),(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>f(e),children:t?`Send again`:`Extend`}),(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void p(e),children:`Cancel`})]})}],rows:n.invites,rowKey:e=>e.id,empty:(0,K.jsx)(w,{children:`No open invites.`})}),l]})}var mt=[[`ingest`,`Ingest: an app sends data`],[`read`,`Read: an AI agent or script reads data`]],Q={ingest:[[`traces`,`Traces`],[`logs`,`Logs`],[`metrics`,`Metrics`]],read:[[`api`,`API (pages, search, exports)`],[`mcp`,`MCP (AI agents)`]]},ht=[[``,`Never`],[`30`,`In 30 days`],[`90`,`In 90 days`],[`180`,`In 180 days`],[`365`,`In 1 year`]];function gt({kind:e,secret:t,note:n}){return(0,K.jsxs)(`div`,{className:`wl-share-link`,children:[(0,K.jsx)(`code`,{className:`wl-mono wl-small`,children:t}),` `,(0,K.jsx)(N,{text:t,label:`Copy key`}),(0,K.jsxs)(`span`,{className:`wl-muted wl-small`,children:[`Copy it now: it is not shown again. `,e===`ingest`?`Set it as WIZELENS_HUB_TOKEN on the app.`:`Send it as Authorization: Bearer <key> to /_wizelens/mcp.`,` `,n]})]})}function _t({kind:e,scopes:t,onChange:n}){return(0,K.jsxs)(`fieldset`,{className:`wl-check-list`,children:[(0,K.jsx)(`legend`,{children:`It may`}),Q[e].map(([e,r])=>(0,K.jsx)(se,{label:r,checked:t.includes(e),onChange:r=>n(r.target.checked?[...t,e]:t.filter(t=>t!==e))},e))]})}function vt({orgId:e,data:t,reload:n,onClose:r}){let[a,o]=(0,q.useState)(`ingest`),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(t.projects[0]?[t.projects[0].id]:[]),[d,f]=(0,q.useState)(Q.ingest.map(([e])=>e)),[p,m]=(0,q.useState)(``),[h,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),b=(e,t)=>u(n=>a===`ingest`?[e]:t?[...n,e]:n.filter(t=>t!==e)),x=e=>(o(e),u(e=>e.slice(0,1)),f(Q[e].map(([e])=>e))),ee=t=>{t.preventDefault();let r={kind:a,name:s,projectIds:a===`ingest`?l.slice(0,1):l,scopes:d,expiresInDays:p?Number(p):null};i(`POST`,`./api/orgs/${e}/keys`,r).then(e=>(_(e.token),c(``),y(null),n()),e=>y(e instanceof Error?e.message:String(e)))},te=t.projects.map(e=>[e.id,e.name]);return(0,K.jsx)(S,{title:`New key`,className:`wl-panel-form`,action:(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:r,children:h?`Done`:`Close`}),children:(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:ee,children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(g,{label:`Kind`,value:a,options:mt,onChange:x}),(0,K.jsx)(z,{label:`Name`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`orders-api`,hint:`Name it after the app or agent that uses it.`}),a===`ingest`&&(0,K.jsx)(g,{label:`Project`,value:l[0]??``,options:te,onChange:e=>u([e])}),(0,K.jsx)(g,{label:`Expires`,value:p,options:ht,onChange:m,hint:`It stops working then. Rotate it before.`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:l.length===0||d.length===0,children:`Create key`})]}),a===`read`&&(0,K.jsxs)(`fieldset`,{className:`wl-check-list`,children:[(0,K.jsx)(`legend`,{children:`Projects it may read`}),t.projects.map(e=>(0,K.jsx)(se,{label:e.name,checked:l.includes(e.id),onChange:t=>b(e.id,t.target.checked)},e.id))]}),(0,K.jsx)(_t,{kind:a,scopes:d,onChange:f}),h&&(0,K.jsx)(gt,{kind:a,secret:h}),v&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:v})]})})}var yt=864e5;function bt(e){if(!e.scopes)return`All`;let t=new Map(Q[e.kind]);return e.scopes.map(e=>t.get(e)?.split(` (`)[0]??e).join(`, `)}function xt({k:e,now:t}){if(e.expiresMs===null)return(0,K.jsx)(`span`,{className:`wl-muted`,children:`Never`});if(e.expiresMs<=t)return(0,K.jsx)(C,{tone:`danger`,children:`Expired`});let n=Math.ceil((e.expiresMs-t)/yt);return n<=14?(0,K.jsx)(C,{tone:`warning`,children:n<=1?`In a day`:`In ${n} days`}):(0,K.jsx)(`span`,{title:M(e.expiresMs),children:M(e.expiresMs)})}function St({orgId:e,data:t,reload:n}){let r=new Map(t.projects.map(e=>[e.id,e.name])),{dialog:a,confirm:o}=k(),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),d=Date.now(),f=async t=>await o({title:`Revoke ${t.name}?`,body:t.kind===`ingest`?`Apps that send with this key stop being recorded at once.`:`Agents and scripts that read with this key lose access at once.`,confirmLabel:`Revoke key`,danger:!0})&&void E(()=>i(`DELETE`,`./api/orgs/${e}/keys/${t.id}`),n).then(u),p=async t=>await o({title:`Rotate ${t.name}?`,body:`You get a new secret for the same key. The old secret keeps working for 24 hours, so you can update the apps that use it.`,confirmLabel:`Rotate key`})&&void E(async()=>c({kind:t.kind,...await i(`POST`,`./api/orgs/${e}/keys/${t.id}/rotate`,{graceHours:24})}),n).then(u);return(0,K.jsxs)(S,{flush:!0,children:[l&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error wl-panel-banner`,children:l}),s&&(0,K.jsx)(`div`,{className:`wl-panel-banner`,children:(0,K.jsx)(gt,{kind:s.kind,secret:s.token,note:`The old secret stops ${M(s.oldExpiresMs)}.`})}),(0,K.jsx)(B,{columns:[{key:`name`,header:`Key`,cell:e=>(0,K.jsxs)(`span`,{className:`wl-who`,children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsxs)(`small`,{className:`wl-mono`,children:[e.prefix,`…`]})]})},{key:`kind`,header:`Kind`,cell:e=>(0,K.jsx)(C,{tone:e.kind===`ingest`?`info`:`neutral`,children:e.kind===`ingest`?`Ingest`:`Read`})},{key:`projects`,header:`Projects`,cell:e=>e.projectIds.map(e=>r.get(e)??`Deleted project`).join(`, `),className:`wl-wrap`},{key:`scopes`,header:`May`,cell:e=>bt(e),className:`wl-wrap`},{key:`made`,header:`Created`,cell:e=>M(e.createdMs),className:`wl-nowrap`},{key:`used`,header:`Last used`,cell:e=>e.lastUsedMs?h(e.lastUsedMs):`Never`,className:`wl-nowrap`},{key:`ends`,header:`Expires`,cell:e=>(0,K.jsx)(xt,{k:e,now:d}),className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,K.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>void p(e),children:`Rotate`}),(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void f(e),children:`Revoke`})]})}],rows:t.keys,rowKey:e=>e.id,empty:(0,K.jsx)(w,{title:`No keys yet`,children:`Make an ingest key for each app that sends data.`})}),a]})}function Ct({orgId:e,me:t,manage:n,onlyOwner:r,run:i,confirm:a},o){let s=async()=>await a({title:`Remove ${o.name}?`,body:`${o.name} loses access to this organization and its data right away.`,confirmLabel:`Remove`,danger:!0})&&i(()=>c(t=>t.organization.removeMember({memberIdOrEmail:o.memberId,organizationId:e}))),u=async()=>await a({title:`Leave this organization?`,body:`You lose access to its data. Someone must invite you again to come back.`,confirmLabel:`Leave`,danger:!0})&&i(async()=>(await c(t=>t.organization.leave({organizationId:e})),await l()));return o.userId===t?r?null:(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void u(),children:`Leave`}):n?(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void s(),children:`Remove`}):null}function wt(e){let t=(t,n)=>e.run(async()=>{await c(r=>r.organization.updateMemberRole({memberId:t.memberId,role:n,organizationId:e.orgId})),t.userId===e.me&&await l()});return[{key:`name`,header:`Name`,cell:t=>(0,K.jsxs)(`span`,{className:`wl-who`,children:[(0,K.jsxs)(`strong`,{children:[t.name,t.userId===e.me&&(0,K.jsx)(`span`,{className:`wl-muted`,children:` (you)`})]}),(0,K.jsx)(`small`,{children:t.email})]})},{key:`role`,header:`Role`,cell:n=>e.manage?(0,K.jsx)(_,{small:!0,label:`Role of ${n.name}`,value:n.role,options:le,onChange:e=>t(n,e)}):F[n.role]},{key:`since`,header:`Member since`,cell:e=>M(e.sinceMs),className:`wl-nowrap`},{key:`x`,header:``,cell:t=>Ct(e,t),className:`wl-cell-actions`}]}function Tt({orgId:e,me:t,data:n,reload:r}){let[i,a]=(0,q.useState)(null),{dialog:o,confirm:s}=k(),c=n.members.filter(e=>e.role===`owner`),l={orgId:e,me:t,manage:A(n.role),onlyOwner:c.length===1&&c[0].userId===t,run:e=>void E(e,r).then(a),confirm:s};return(0,K.jsxs)(S,{title:`Members`,flush:!0,children:[i&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error wl-panel-banner`,children:i}),(0,K.jsx)(B,{columns:wt(l),rows:n.members,rowKey:e=>e.memberId}),o]})}var Et=e=>[[``,`Organization role (${F[e.role]})`],[`none`,`No access`],[`viewer`,`Viewer`],[`member`,`Member`],[`admin`,`Admin of this project`]],Dt=e=>e.role===`member`||e.role===`viewer`;function Ot({orgId:e,project:t,data:n,reload:r,onClose:a}){let[o,s]=(0,q.useState)(null),c=new Map(n.projectRoles.filter(e=>e.projectId===t.id).map(e=>[e.userId,e.role])),l=(n,a)=>void E(()=>i(`PUT`,`./api/orgs/${e}/projects/${t.id}/roles/${n.userId}`,{role:a||null}),r).then(s);return(0,K.jsxs)(S,{title:`Access to ${t.name}`,className:`wl-panel-form`,action:(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:a,children:`Done`}),children:[(0,K.jsx)(`p`,{className:`wl-muted wl-settings-note`,children:`Give a member or viewer more, less, or no access to this project. No access hides it from them, in the dashboard, links, and AI agents.`}),o&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:o}),(0,K.jsx)(B,{columns:[{key:`who`,header:`Person`,cell:e=>(0,K.jsxs)(`span`,{className:`wl-who`,children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`small`,{children:e.email})]})},{key:`role`,header:`On this project`,cell:e=>Dt(e)?(0,K.jsx)(_,{small:!0,label:`${e.name} on ${t.name}`,value:c.get(e.userId)??``,options:Et(e),onChange:t=>l(e,t)}):(0,K.jsxs)(`span`,{className:`wl-muted`,children:[`Always `,F[e.role].toLowerCase()]})}],rows:n.members,rowKey:e=>e.userId})]})}var kt=[1,3,7,14,30,60,90,180,365,400];function At({value:e,traceDays:t,onChange:n}){let r=[...new Set([...kt,...e===null?[]:[e]])].sort((e,t)=>e-t),i=[[``,`Like traces (${t} days)`],...r.map(e=>[String(e),`${e} ${e===1?`day`:`days`}`])];return(0,K.jsx)(_,{small:!0,label:`Logs kept`,value:e===null?``:String(e),options:i,onChange:e=>n(e?Number(e):null)})}function jt({orgId:e,reload:t,onClose:n}){let[r,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(null);return(0,K.jsx)(S,{title:`New project`,className:`wl-panel-form`,action:(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:n,children:`Close`}),children:(0,K.jsxs)(`form`,{className:`wl-form`,onSubmit:a=>{a.preventDefault(),E(()=>i(`POST`,`./api/orgs/${e}/projects`,{name:r}),()=>(t(),void l())).then(e=>(s(e),e||n()))},children:[(0,K.jsxs)(T,{children:[(0,K.jsx)(z,{label:`Name`,required:!0,maxLength:100,value:r,onChange:e=>a(e.target.value),placeholder:`Checkout`,autoFocus:!0,hint:`Usually one app or team. Make an ingest key for it next.`}),(0,K.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Add project`})]}),o&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:o})]})})}function Mt({orgId:e,retentionDays:t,data:n,reload:r}){let[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),u=e=>n.projectRoles.filter(t=>t.projectId===e.id).length,{dialog:d,confirm:f}=k(),p=e=>void E(e,()=>(r(),void l())).then(o),m=e=>n.keys.filter(t=>t.projectIds.includes(e.id)).length,h=async t=>await f({title:`Clear the data of ${t.name}?`,body:`Every trace, log, and metric of this project is deleted. Its keys and alerts stay.`,confirmLabel:`Clear data`,danger:!0,typeToConfirm:t.name})&&p(()=>i(`POST`,`./api/orgs/${e}/projects/${t.id}/clear`)),g=async t=>await f({title:`Delete ${t.name}?`,body:`The project, its data, its keys, and its alerts are deleted. Apps that send with its keys stop being recorded.`,confirmLabel:`Delete project`,danger:!0,typeToConfirm:t.name})&&p(()=>i(`DELETE`,`./api/orgs/${e}/projects/${t.id}`));return(0,K.jsxs)(K.Fragment,{children:[s&&(0,K.jsx)(Ot,{orgId:e,project:s,data:n,reload:r,onClose:()=>c(null)},s.id),(0,K.jsxs)(S,{flush:!0,children:[a&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error wl-panel-banner`,children:a}),(0,K.jsx)(B,{columns:[{key:`name`,header:`Project`,cell:e=>(0,K.jsx)(`strong`,{children:e.name})},{key:`id`,header:`Project id`,cell:e=>(0,K.jsxs)(`span`,{className:`wl-id`,children:[e.id.slice(0,8),`… `,(0,K.jsx)(N,{text:e.id,label:`Copy project id`})]})},{key:`keys`,header:`Keys`,num:!0,cell:e=>m(e)},{key:`logs`,header:`Logs kept`,cell:n=>(0,K.jsx)(At,{value:n.logRetentionDays??null,traceDays:t,onChange:t=>p(()=>i(`PATCH`,`./api/orgs/${e}/projects/${n.id}`,{logRetentionDays:t}))})},{key:`access`,header:`Access`,cell:e=>u(e)?`${u(e)} ${u(e)===1?`person has`:`people have`} their own role`:(0,K.jsx)(`span`,{className:`wl-muted`,children:`Organization roles`}),className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,K.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>c(e),children:`Access`}),(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>void h(e),children:`Clear data`}),(0,K.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void g(e),children:`Delete`})]})}],rows:n.projects,rowKey:e=>e.id}),d]})]})}function $({label:e,open:t,onOpen:n}){return t?null:(0,K.jsxs)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,onClick:n,children:[(0,K.jsx)(x,{"aria-hidden":`true`}),` `,e]})}function Nt({org:e,data:t,me:n,mail:r,reload:i}){let[a,o]=(0,q.useState)(!1),s=A(t.role);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`People`,description:`Who can see this organization's data, and what each person may change.`,action:s&&(0,K.jsx)($,{label:`Invite someone`,open:a,onOpen:()=>o(!0)})}),a&&(0,K.jsx)(ft,{orgId:e.id,mail:r,reload:i,onClose:()=>o(!1)}),(0,K.jsx)(Tt,{orgId:e.id,me:n,data:t,reload:i}),s&&t.invites.length>0&&(0,K.jsx)(pt,{orgId:e.id,mail:r,data:t,reload:i})]})}function Pt({org:e,data:t,reload:n}){let[r,i]=(0,q.useState)(!1);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`Projects`,description:`Each project keeps its own traces, logs, dashboards, and alerts. Logs can be kept for more or less time than traces. A trace that crosses projects still opens whole for people who can read both.`,action:(0,K.jsx)($,{label:`New project`,open:r,onOpen:()=>i(!0)})}),r&&(0,K.jsx)(jt,{orgId:e.id,reload:n,onClose:()=>i(!1)}),(0,K.jsx)(Mt,{orgId:e.id,retentionDays:e.retentionDays,data:t,reload:n})]})}function Ft({org:e,data:t,reload:n}){let[r,i]=(0,q.useState)(!1);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`API keys`,description:`Ingest keys let an app send data to one project. Read keys let an AI agent or script read the projects you pick. Only a hash is kept, so a key is shown once.`,action:(0,K.jsx)($,{label:`New key`,open:r,onOpen:()=>i(!0)})}),r&&(0,K.jsx)(vt,{orgId:e.id,data:t,reload:n,onClose:()=>i(!1)}),(0,K.jsx)(St,{orgId:e.id,data:t,reload:n})]})}function It({org:e}){let t=A(e.role);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`Organization`,description:`${e.name}. Your role: ${e.role}.`}),t&&(0,K.jsx)(Re,{org:e},`settings:${e.id}`),(0,K.jsx)(ze,{}),e.role===`owner`&&(0,K.jsx)(Be,{org:e},`delete:${e.id}`)]})}function Lt(e,t,n){let{org:r,project:i}=t,a=A(r.role);return[!!e&&{id:`people`,label:`People`,icon:re,count:e.data.members.length,render:()=>(0,K.jsx)(Nt,{...e})},!!e&&a&&{id:`projects`,label:`Projects`,icon:be,count:e.data.projects.length,render:()=>(0,K.jsx)(Pt,{...e})},!!e&&a&&{id:`keys`,label:`API keys`,icon:Se,count:e.data.keys.length,render:()=>(0,K.jsx)(Ft,{...e})},a&&{id:`apps`,label:`Connected apps`,icon:ae,render:()=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{title:`Connected apps`,description:`AI apps people here connected with their own sign-in. Each reads only the projects its person picked.`}),(0,K.jsx)(m,{list:`./api/orgs/${r.id}/apps`,team:!0},r.id)]})},a&&{id:`sso`,label:`Single sign-on`,icon:p,render:()=>(0,K.jsx)(dt,{orgId:r.id},r.id)},a&&{id:`scim`,label:`SCIM`,icon:xe,render:()=>(0,K.jsx)(et,{orgId:r.id,plan:r.plan??``},r.id)},{id:`links`,label:`Shared links`,icon:ie,render:()=>(0,K.jsx)(we,{projectId:i.id,projectName:i.name})},a&&{id:`audit`,label:`Audit log`,icon:ye,render:()=>(0,K.jsx)(Le,{orgId:r.id,org:e?.data??null})},n&&a&&{id:`billing`,label:`Billing`,icon:ve,render:()=>(0,K.jsx)(Ze,{org:r},r.id)},{id:`organization`,label:`Organization`,icon:ge,render:()=>(0,K.jsx)(It,{org:r})}].filter(e=>!!e)}function Rt(){let e=s(),n=u(e),{params:r}=t(),{data:i,error:a,reload:o}=v(n?`./api/orgs/${n.org.id}`:null);if(!n)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(y,{title:`Team`,subtitle:`You are not in an organization yet.`}),(0,K.jsx)(S,{children:(0,K.jsx)(w,{title:`No organization`,children:`Make one below, or ask your team for an invite link.`})}),(0,K.jsx)(ze,{})]});let c=i?{org:n.org,data:i,me:e?.user?.id??``,mail:e?.mail??!1,reload:o}:null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(y,{title:`Team`,subtitle:`${n.org.name}: people, projects, keys, and access.`}),a&&(0,K.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:a}),(0,K.jsx)(pe,{page:`team`,sections:Lt(c,n,!!e?.billing),active:r[0]})]})}export{Rt as TeamPage};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./auth-client-Bkk9PzK9.js","./index-DYrQC7uL.js","./index-DcxtAwLW.css"])))=>i.map(i=>d[i]);
2
+ var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var ee={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||ee}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||ee}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function te(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var k=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?te(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function j(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,j(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+A(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(k,`$&/`)+`/`),j(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(k,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+A(a,u),c+=j(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+A(a,u++),c+=j(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return j(ne(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function M(e,t,n){if(e==null)return e;var r=[],i=0;return j(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function re(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var N=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function P(e){var t=w.T,n={};n.types=t===null?null:t.types,w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,N)}catch(e){N(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}}function F(e){var t=w.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else P(F.bind(null,e))}var I={map:M,forEach:function(e,t,n){M(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return M(e,function(){t++}),t},toArray:function(e){return M(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=I,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.addTransitionType=F,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:re}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=P,e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.3.1`})),i=t(((e,t)=>{t.exports=r()})),a=e=>e.category===`http.client`||e.category===`browser`;function o(e,t,n){if(t&&t.service===e.service&&e.startMs+n<t.startMs)return t.startMs-e.startMs;if(!t||e.category!==`http.server`||t.service===e.service||!a(t))return n;let r=e.startMs+n;return r>=t.startMs&&r+e.durationMs<=t.startMs+t.durationMs?n:t.startMs+Math.max(0,(t.durationMs-e.durationMs)/2)-e.startMs}function s(e){let t=new Set(e.map(e=>e.spanId)),n=new Map;for(let r of e){if(!r.parentSpanId||!t.has(r.parentSpanId))continue;let e=n.get(r.parentSpanId);e?e.push(r):n.set(r.parentSpanId,[r])}let r=new Map,i=[],a=(e,t,s)=>{if(r.has(e.spanId))return;let c=o(e,t,s);r.set(e.spanId,c);let l=c?{...e,startMs:e.startMs+c}:e;i.push(l);for(let t of n.get(e.spanId)??[])a(t,l,c)};for(let n of e)(!n.parentSpanId||!t.has(n.parentSpanId))&&a(n,void 0,0);for(let t of e)r.has(t.spanId)||a(t,void 0,0);return{spans:i,offsets:r}}function c(e,t){return e.map(e=>{let n=e.spanId?t.get(e.spanId)??0:0;return n?{...e,timeMs:e.timeMs+n}:e})}function l(e){if(e.length===0)return;let t=[...e].sort((e,t)=>e.startMs-t.startMs),n=t.find(e=>e.parentSpanId===null);if(n)return n;let r=new Set(e.map(e=>e.spanId));return t.find(e=>e.parentSpanId!==null&&!r.has(e.parentSpanId))??t[0]}function u(e,t){let n=e?.attributes[t];return n==null||n===``?null:String(n)}function d(e,t){let n=e?.attributes[t];if(n==null||n===``)return null;let r=Number(n);return Number.isFinite(r)?r:null}function f(e){let t=new Map(e.map(e=>[e.spanId,e])),n=e.filter(e=>e.category===`http.server`).sort((e,t)=>e.startMs-t.startMs);return n.find(e=>{let n=e.parentSpanId?t.get(e.parentSpanId):void 0;return!n||n.category===`browser`})??n[0]}function p(e){let t=d(e,`http.response.status_code`);return t!==null&&t>=400&&t<500}var m=e=>e.status===`error`&&!p(e);function h(e){return p(e)?!1:e.status===`error`||e.events.some(e=>e.name===`exception`)}function ee(e,t){let n=1/0,r=-1/0;for(let t of e)n=Math.min(n,t.startMs),r=Math.max(r,t.startMs+t.durationMs);if(e.length===0)for(let e of t)n=Math.min(n,e.timeMs),r=Math.max(r,e.timeMs);return Number.isFinite(n)?{start:n,end:r}:{start:0,end:0}}function g(e){return e.some(m)?`error`:e.some(e=>e.status===`ok`)?`ok`:`unset`}function _(e,t,n,r){let i=s(t),a=i.spans.sort((e,t)=>e.startMs-t.startMs),o=c(n,i.offsets).sort((e,t)=>e.timeMs-t.timeMs),f=l(a),{start:p,end:m}=ee(a,o),_=g(a),v=new Set;for(let e of a)v.add(e.service);for(let e of o)v.add(e.service);return{traceId:e,rootName:f?.name??`(no spans)`,service:f?.service??o[0]?.service??`unknown`,startMs:p,durationMs:Math.max(0,m-p),status:_,spanCount:a.length,dbCount:a.filter(e=>e.category===`db`).length,httpClientCount:a.filter(e=>e.category===`http.client`).length,errorCount:a.filter(h).length,services:[...v].sort(),rootMethod:u(f,`http.request.method`),rootUrl:u(f,`url.path`)??u(f,`url.full`),rootStatusCode:d(f,`http.response.status_code`),spans:a,logs:o,remotes:[...new Set(r)]}}function v(e){return`${e.timeMs}|${e.service}|${e.spanId??``}|${e.level}|${e.message}`}function y(e,t){let n=new Map,r=new Map,i=new Set;for(let e of t){for(let t of e.spans)n.has(t.spanId)||n.set(t.spanId,t);for(let t of e.logs)r.set(v(t),t);for(let t of e.remotes)i.add(t)}return _(e,[...n.values()],[...r.values()],i)}var b={"15m":{ms:9e5,label:`Last 15 minutes`},"1h":{ms:36e5,label:`Last hour`},"6h":{ms:216e5,label:`Last 6 hours`},"24h":{ms:864e5,label:`Last 24 hours`},"7d":{ms:6048e5,label:`Last 7 days`},"30d":{ms:2592e6,label:`Last 30 days`}},x=864e5,S={"15m":`vs. previous 15 min`,"1h":`vs. previous hour`,"6h":`vs. previous 6 hours`,"24h":`vs. previous day`,"7d":`vs. previous 7 days`,"30d":`vs. previous 30 days`},C=e=>Object.hasOwn(b,e),w=(e,t)=>({from:t-b[e].ms,to:t}),T=e=>({from:e.from-(e.to-e.from),to:e.from}),E=(e,t)=>e>=t.from&&e<t.to;function D(e,t,n){return E(e,t)?Math.min(n-1,Math.floor((e-t.from)/(t.to-t.from)*n)):-1}function O(e,t){let n=(e.to-e.from)/t;return Array.from({length:t},(t,r)=>e.from+r*n)}function te(e,t,n,r,i=`count`,a=()=>1){let o=Array(r).fill(0),s=Array(r).fill(0);for(let i of e){let e=D(t(i),n,r);e<0||(o[e]+=a(i),s[e]++)}return i===`count`?s:i===`sum`?o:o.map((e,t)=>s[t]?e/s[t]:null)}function k(e,t){return e===null||t===null||t===0?null:(e-t)/t*100}var A=(e,t)=>t>0?e/t*100:0;function ne(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i?i.push(r):n.set(e,[r])}return n}function j(e){let t=new WeakMap;return n=>{if(t.has(n))return t.get(n);let r=e(n);return t.set(n,r),r}}var M=/\b(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|(?=[0-9a-f]*\d)[0-9a-f]{16,})\b/gi;function re(e){return e.replace(/'(?:[^']|'')*'/g,`?`).replace(M,`?`).replace(/\b\d+(?:\.\d+)?\b/g,`?`).replace(/\s+/g,` `).trim()}var N=i(),P=class extends Error{status;constructor(e,t){super(t),this.status=e}},F=2e4;async function I(e){let t=await e.text(),n=t?JSON.parse(t):void 0;if(!e.ok)throw new P(e.status,n?.error??`HTTP ${e.status}`);return n}var ie=async e=>I(await fetch(e,{headers:{Accept:`application/json`},credentials:`same-origin`,signal:AbortSignal.timeout(F)})),ae=async(e,t,n)=>I(await fetch(t,{method:e,credentials:`same-origin`,headers:{"Content-Type":`application/json`,Accept:`application/json`,"X-WizeLens-Client":`dashboard`},body:n===void 0?void 0:JSON.stringify(n),signal:AbortSignal.timeout(F)})),L={theme:`wizelens.ui.theme`,range:`wizelens.ui.range`,seen:`wizelens.ui.seen`},R=new Set;function z(e){try{return localStorage.getItem(e)}catch{return null}}var oe=null,se=e=>void(oe=e);function B(e,t){try{localStorage.setItem(e,t)}catch{}for(let e of R)e();oe?.(e,t)}var ce=e=>(R.add(e),()=>R.delete(e)),V=new Map,le=e=>V.get(e)??z(e);function ue(e,t){V.set(e,t),B(e,t)}function H(e,t,n){let r=(0,N.useSyncExternalStore)(ce,()=>V.get(e)??z(e));return[r!==null&&n(r)?r:t,(0,N.useCallback)(t=>{V.set(e,t),B(e,t)},[e])]}var de=e=>e===`light`||e===`dark`||e===`system`,fe=e=>/^\d+$/.test(e),pe=()=>H(L.theme,`light`,de),me=()=>H(L.range,`24h`,C),he=()=>H(L.seen,`0`,fe),U={env:`wizelens.ui.env`,project:`wizelens.ui.project`,service:`wizelens.ui.service`},W=e=>e.length<=100,ge=()=>H(U.env,``,W),_e=()=>H(U.project,``,W),ve=()=>H(U.service,``,W),G=()=>({env:V.get(U.env)??z(U.env)??``,project:V.get(U.project)??z(U.project)??``,service:V.get(U.service)??z(U.service)??``});function ye(e){V.set(U.project,e),B(U.project,e)}var be=ce;function xe(e){document.documentElement.dataset.theme=e}var Se=2e3,Ce=8e3;function we(){return Te(new URL(`./`,window.location.href).href)}var Te=e=>e.replace(/[?#].*$/,``).replace(/\/+$/,``);async function K(e){let t=await fetch(e,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(Ce)});if(!t.ok)throw new P(t.status,t.status===404?`not-found`:t.status===401?`sign-in needed`:`HTTP ${t.status}`);return await t.json()}var Ee=(e,t=null)=>K(`${e}/api/info?${q(t).slice(1)}`),De=(e,t,n=!0)=>(!t.env||e.environment===t.env)&&(!n||!t.project||e.project===t.project),Oe=e=>e.online?`Online`:e.via===`addon`?`Offline`:`Idle`,ke={addon:`WizeLens`,otlp:`OTLP`,uptime:`Uptime checks`},Ae=(e,t=null)=>K(`${e}/api/services?${q(t).slice(1)}`),q=e=>e?`${e.env?`&env=${encodeURIComponent(e.env)}`:``}${e.project?`&project=${encodeURIComponent(e.project)}`:``}`:``;async function je(e,t,n=null,r=Se){return(await K(`${e}/api/traces?${`full=true&limit=${r}${t===null?``:`&since=${Math.floor(t)}`}${q(n)}`}`)).filter(e=>Array.isArray(e.spans))}var Me=async e=>{let t=G().project;return y(e,[await K(`./api/traces/${e}?federate=true${t?`&project=${encodeURIComponent(t)}`:``}`)])};function Ne(e,t){return{endpoint:e,self:t,info:null,status:`pending`,error:null,lastOkMs:null}}var Pe=5e3,Fe=3e4,Ie=1728e5,J=e=>!!e?.capabilities?.includes(`registry`),Le=300,Re=e=>e?.capabilities?.includes(`serverStats`)?Le:void 0,ze=e=>`${e.env}
3
+ ${e.project}`,Be=(e,t)=>(!t.env||e?.environment===t.env)&&(!t.project||e?.project===t.project),Ve=(e,t)=>e.spanCount===t.spanCount&&e.logs.length===t.logs.length&&e.durationMs===t.durationMs&&e.remotes.length===t.remotes.length,He=class{#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=new Map;#a=null;#o=null;#s=G();#c={sources:[],traces:[],info:null,loading:!0,updatedMs:Date.now(),registry:null};subscribe=e=>(this.#r.add(e),()=>this.#r.delete(e));getSnapshot=()=>this.#c;start(){let e=we();this.#e.set(e,Ne(e,!0)),document.addEventListener(`visibilitychange`,()=>!document.hidden&&this.refresh()),be(()=>this.#l(G())),this.refresh()}#l(e){if(ze(e)!==ze(this.#s)){this.#s=e,this.#t.clear(),this.#n.clear(),this.#i.clear();for(let e of this.#e.values())e.self&&(e.info=null);this.#g(),this.refresh()}}refresh(){this.#a&&clearTimeout(this.#a),this.#u().finally(()=>{this.#a=document.hidden?null:setTimeout(()=>this.refresh(),Pe)})}async#u(){let e=new Set;for(let t=0;t<4;t++){let t=[...this.#e.values()].filter(t=>!e.has(t.endpoint));if(t.length===0)break;for(let n of t)e.add(n.endpoint);await Promise.all(t.map(e=>this.#f(e)))}await this.#d(),this.#g()}async#d(){let e=[...this.#e.values()].find(e=>e.self);if(e&&J(e.info))try{this.#o=await Ae(e.endpoint,this.#s)}catch{}}async#f(e){let t=Date.now(),n=this.#i.get(e.endpoint);try{e.info||=await Ee(e.endpoint,e.self?this.#s:null);let r=e.self&&J(e.info),i=[...this.#e.values()].find(e=>e.self)?.info??null,a=!e.self&&J(i)&&!Be(e.info,this.#s),o=n===void 0?null:n-Fe,s=a?[]:await je(e.endpoint,o,r?this.#s:null,Re(e.info));this.#i.set(e.endpoint,t),this.#p(e.endpoint,s),Object.assign(e,{status:`ok`,error:null,lastOkMs:t})}catch(t){Object.assign(e,{status:`down`,error:t instanceof Error?t.message:String(t)})}}#p(e,t){for(let n of t){let t=this.#t.get(n.traceId);t||this.#t.set(n.traceId,t=new Map);let r=t.get(e);if(r&&Ve(r,n))continue;t.set(e,n);let i=[...t.values()];this.#n.set(n.traceId,y(n.traceId,i));for(let e of n.remotes)this.#m(e)}}#m(e){let t=Te(e);this.#e.has(t)||this.#e.set(t,Ne(t,!1))}#h(e){for(let[t,n]of this.#n)n.startMs+n.durationMs>=e-Ie||(this.#n.delete(t),this.#t.delete(t))}#g(){let e=Date.now();this.#h(e);let t=[...this.#e.values()].map(e=>({...e})),n=t.find(e=>e.self),r=[...this.#n.values()].sort((e,t)=>t.startMs-e.startMs),i=n?.info??null,a=J(i)?this.#o:null;this.#c={sources:t,traces:r,info:i,loading:n?.status===`pending`,updatedMs:e,registry:a};for(let e of this.#r)e()}},Y=new class extends He{kind=`local`;loadTrace=e=>Me(e)};function Ue(){return(0,N.useSyncExternalStore)(Y.subscribe,Y.getSnapshot)}var We=[`setup`,`two-factor`,`forgot-password`,`reset-password`,`verify-email`,`invite`,`delete-account`,`oauth`,`oauth-consent`],Ge=[`overview`,`problems`,`search`,`requests`,`traces`,`database`,`rendering`,`errors`,`logs`,`metrics`,`hosts`,`kubernetes`,`services`,`insights`,`settings`,`alerts`,`slos`,`dashboards`,`users`,`uptime`,`team`,`shared`,`status`,`account`,...We],Ke=/^[0-9a-f]{32}$/;function X(e){let t=e.replace(/^#\/?/,``),n=t.indexOf(`?`),r=(n>=0?t.slice(0,n):t).split(`/`).filter(Boolean),i=new URLSearchParams(n>=0?t.slice(n+1):``),[a=`overview`,...o]=r;return a===`traces`&&o[0]&&Ke.test(o[0])?{page:`trace`,params:o,query:i}:{page:Ge.includes(a)?a:`overview`,params:o,query:i}}function Z(e,t=[],n={}){let r=[e===`trace`?`traces`:e===`overview`?``:e,...t].filter(Boolean).join(`/`),i=new URLSearchParams;for(let[e,t]of Object.entries(n))t!=null&&t!==``&&i.set(e,String(t));let a=i.toString();return`#/${r}${a?`?${a}`:``}`}var qe=(e,t)=>Z(`trace`,t?[e,t]:[e]),Q=encodeURIComponent;function Je(e){try{return decodeURIComponent(e)}catch{return e}}var Ye=e=>Z(`errors`,[Q(e)]),Xe=(e,t)=>Z(`services`,[Q(e),`endpoints`,Q(t)]),Ze=e=>Z(`database`,[`queries`,Q(e)]),Qe=e=>Z(`rendering`,[`routes`,Q(e)]),$e=e=>Z(`alerts`,[Q(e)]),et=e=>Z(`slos`,[Q(e)]),tt=e=>Z(`dashboards`,[Q(e)]),nt=e=>Z(`users`,[Q(e)]),rt=e=>Z(`alerts`,[],{new:`1`,...e});function it(e){window.location.hash=e.replace(/^#/,``)}function at(e){let t=X(window.location.hash),n=Object.fromEntries(t.query.entries());for(let[t,r]of Object.entries(e))r==null||r===``?delete n[t]:n[t]=String(r);let r=Z(t.page,t.params,n);history.replaceState(null,``,r),window.dispatchEvent(new HashChangeEvent(`hashchange`))}function ot(){let[e,t]=(0,N.useState)(()=>window.location.hash);return(0,N.useEffect)(()=>{let e=()=>t(window.location.hash);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,N.useMemo)(()=>X(e),[e])}var st=`modulepreload`,ct=function(e,t){return new URL(e,t).href},lt={},ut=function(e){return e.pathname.endsWith(`.css`)},dt=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ft=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ct(t,n);let r=s(t),i=ut(r);return dt(lt,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:st,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pt=new Set,$=null,mt=()=>pt.forEach(e=>e());function ht(e){let t=(e.orgs??[]).flatMap(e=>e.projects);t.length&&!t.some(e=>e.id===G().project)&&ye(t[0].id)}async function gt(){return $=await ie(`./api/me`),$.signedIn&&ht($),mt(),$.signedIn&&Y.refresh(),$}var _t=null,vt=()=>_t??=ft(()=>import(`./auth-client-Bkk9PzK9.js`).then(e=>e.n).then(e=>e.authClient),__vite__mapDeps([0,1,2]),import.meta.url),yt=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};async function bt(e){let{data:t,error:n}=await e(await vt());if(n)throw new yt(n.status,n.code??``,n.message||n.statusText||`HTTP ${n.status}`);return t}var xt=e=>e instanceof yt&&(e.code===`SESSION_NOT_FRESH`||e.status===403&&/fresh/i.test(e.message)),St=e=>e instanceof Error?e.message:String(e);async function Ct(){await bt(e=>e.signOut()),await gt()}var wt=`wl-pending-invite`,Tt={get:()=>{try{return localStorage.getItem(wt)}catch{return null}},set:e=>{try{e?localStorage.setItem(wt,e):localStorage.removeItem(wt)}catch{}}};function Et(){return(0,N.useSyncExternalStore)(e=>(pt.add(e),()=>pt.delete(e)),()=>$)}function Dt(e){let t=G().project;for(let n of e?.orgs??[]){let e=n.projects.find(e=>e.id===t);if(e)return{org:n,project:e}}return null}export{S as $,ke as A,ye as B,at as C,nt as D,ot as E,xe as F,he as G,H,G as I,ue as J,ve as K,be as L,Oe as M,L as N,Y as O,U as P,x as Q,se as R,Qe as S,qe as T,_e as U,ge as V,me as W,ie as X,P as Y,ae as Z,Z as _,y as _t,xt as a,C as at,X as b,n as bt,Ct as c,k as ct,We as d,te as dt,b as et,$e as f,w as ft,Ye as g,m as gt,Xe as h,h as ht,St as i,E as it,De as j,Ue as k,Et as l,A as lt,Je as m,l as mt,bt as n,O as nt,gt as o,j as ot,tt as p,f as pt,pe as q,Dt as r,ne as rt,Tt as s,re as st,yt as t,D as tt,ft as u,T as ut,it as v,i as vt,et as w,Ze as x,rt as y,t as yt,le as z};
@@ -0,0 +1,3 @@
1
+ import{_ as e,bt as t,v as n}from"./account-D29x4uz9.js";import{v as r}from"./index-DYrQC7uL.js";var i={organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`],project:[`read`,`create`,`update`,`delete`],key:[`read`,`create`,`revoke`],alert:[`read`,`create`,`update`,`delete`],share:[`create`,`revoke`],audit:[`read`],tag:[`create`,`update`,`delete`]},a=[`owner`,`admin`,`member`,`viewer`],o={project:[`read`,`create`,`update`,`delete`],key:[`read`,`create`,`revoke`],alert:[`read`,`create`,`update`,`delete`],share:[`create`,`revoke`],audit:[`read`],tag:[`create`,`update`,`delete`]},s={project:[`read`],key:[`read`],alert:[`read`],ac:[`read`]},c={member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],ac:[`create`,`read`,`update`,`delete`]},l={viewer:s,member:{...s,alert:o.alert,share:o.share,tag:o.tag},admin:{...c,...o,organization:[`update`]},owner:{...c,...o,organization:[`update`,`delete`]}};function u(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}var d=u({CHALLENGE_NOT_FOUND:`Challenge not found`,YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY:`You are not allowed to register this passkey`,FAILED_TO_VERIFY_REGISTRATION:`Failed to verify registration`,PASSKEY_NOT_FOUND:`Passkey not found`,AUTHENTICATION_FAILED:`Authentication failed`,UNABLE_TO_CREATE_SESSION:`Unable to create session`,USER_NOT_FOUND:`User not found`,FAILED_TO_UPDATE_PASSKEY:`Failed to update passkey`,PREVIOUSLY_REGISTERED:`Previously registered`,REGISTRATION_CANCELLED:`Registration cancelled`,AUTH_CANCELLED:`Auth cancelled`,UNKNOWN_ERROR:`Unknown error`,SESSION_REQUIRED:`Passkey registration requires an authenticated session`,RESOLVE_USER_REQUIRED:`Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false`,RESOLVED_USER_INVALID:`Resolved user is invalid`}),f=`1.7.10`;function p(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function m(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function h(){return g.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var g={stubThis:e=>e};function _(e){let{id:t}=e;return{...e,id:m(t),transports:e.transports}}function v(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var y=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function b({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new y({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new y({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new y({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new y({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new y({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new y({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new y({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new y({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!v(t))return new y({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new y({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new y({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new y({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var x=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},S=[`cross-platform`,`platform`];function C(e){if(e&&!(S.indexOf(e)<0))return e}async function w(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!h())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:m(t.challenge),user:{...t.user,id:m(t.user.id)},excludeCredentials:t.excludeCredentials?.map(_)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=x.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw b({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){T(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=p(e))}catch(e){T(`getPublicKey()`,e)}let g;if(typeof c.getAuthenticatorData==`function`)try{g=p(c.getAuthenticatorData())}catch(e){T(`getAuthenticatorData()`,e)}return{id:o,rawId:p(s),response:{attestationObject:p(c.attestationObject),clientDataJSON:p(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:g},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:C(a.authenticatorAttachment)}}function T(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function ee(){if(!h())return E.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?E.stubThis(new Promise(e=>e(!1))):E.stubThis(e.isConditionalMediationAvailable())}var E={stubThis:e=>e};function te({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new y({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new y({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!v(t))return new y({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new y({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new y({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function ne(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!h())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(_));let a={...t,challenge:m(t.challenge),allowCredentials:i},o={};if(n){if(!await ee())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=x.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw te({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=p(u.userHandle)),{id:c,rawId:p(l),response:{authenticatorData:p(u.authenticatorData),clientDataJSON:p(u.clientDataJSON),signature:p(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:C(s.authenticatorAttachment)}}var re=`1.7.10`,D=Symbol.for(`better-auth:broadcast-channel`),ie=()=>Math.floor(Date.now()/1e3),ae=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window<`u`)try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:ie()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function O(e=`better-auth.message`){return globalThis[D]||(globalThis[D]=new ae(e)),globalThis[D]}var k=[],A=0,oe=null,se=4,ce=globalThis.nanostoresGlobal||={epoch:0},le=()=>{let e,t;for(;A<k.length;){t=A,A+=se;let n=oe?.get(k[t]);if(n){if(!n.has(k[t+1]))continue;n.clear()}try{k[t](k[t+1].value,k[t+2],k[t+3])}catch(t){e=t}}if(k.length=A=0,e)throw e},j=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{oe?.get(e)?.delete(n);for(let t=A;t<k.length;)k[t]===e&&k[t+1]===n?k.splice(t,se):t+=se;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){ce.epoch++;let i=!k.length&&!0;for(let i of t)k.push(i,n,e,r);i&&le()},off(){},set(e){let t=n.value;n.eq(t,e)||(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},ue=2,de=5,M=6,N=10,fe=(e,t,n,r)=>(e.events=e.events||{},e.events[n+N]||(e.events[n+N]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);~i&&(r.splice(i,1),r.length||(e.events[n+N](),delete e.events[n+N]))}),pe=(e,t)=>fe(e,t,ue,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),me=1e3,P=(e,t)=>fe(e,n=>{let r=t(n);r&&e.events[M].push(r)},de,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[M]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[M])t();e.events[M]=[]}},me)},()=>{e.listen=n,e.off=r}});function he(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function F(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!F(e[n],t[n]))return!1;return!0}if(he(e)&&he(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!F(e[r],t[r]))return!1;return!0}return!1}function ge(e,t){return pe(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var I=Symbol.for(`better-auth:focus-manager`),_e=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function ve(){return globalThis[I]||(globalThis[I]=new _e),globalThis[I]}var L=Symbol.for(`better-auth:online-manager`),ye=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function R(){return globalThis[L]||(globalThis[L]=new ye),globalThis[L]}var be={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},xe=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Se={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},Ce=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function we(e){return e instanceof Date&&!isNaN(e.getTime())}function Te(e){let t=Ce.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return we(f)?f:null}function Ee(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in Se)return Se[s];if(!xe.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(be).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t)r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);else{if(a&&typeof t==`string`){let e=Te(t);if(e)return e}return i?i(e,t):t}})}catch(t){if(n)throw t;return e}}function De(e,t={strict:!0}){return Ee(e,t)}var Oe=Symbol.for(`better-auth:auth-query`);function ke(e){let t=j(e);return Object.defineProperty(t,Oe,{value:!0}),t}var Ae=()=>typeof window>`u`;function je(e,t){return F(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var z=(e,t,n,r)=>{let i=ke({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>o(e)});P(i,()=>ge(i,je));let a=0,o=async e=>{let o=++a;return new Promise(s=>{let c=typeof r==`function`?r({data:i.get().data,error:i.get().error,isPending:i.get().isPending}):r;n(t,{...c,query:{...c?.query,...e?.query},async onSuccess(e){if(o===a){let t=i.get(),n=t.data!=null&&e.data!=null&&F(t.data,e.data)?t.data:e.data;i.set({data:n,error:null,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}await c?.onSuccess?.(e)},async onError(e){let{request:t}=e,n=typeof t.retry==`number`?t.retry:t.retry?.attempts,r=t.retryAttempt||0;if(!(n&&r<n)){if(o===a){let t=e.error.status===401;i.set({error:e.error,data:t?null:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}await c?.onError?.(e)}},async onRequest(e){if(o===a){let e=i.get();i.set({isPending:e.data===null,data:e.data,error:null,isRefetching:!0,refetch:i.value.refetch})}await c?.onRequest?.(e)}}).catch(e=>{o===a&&i.set({error:e,data:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}).finally(()=>{s(void 0)})})};e=Array.isArray(e)?e:[e];let s=!1,c=!1,l=!1,u=()=>{s?l=!0:(s=!0,o().finally(()=>{s=!1;let e=l&&c;l=!1,e&&u()}))};return P(i,()=>{if(Ae())return;c=!0;let t=!1,n,r=e.map(e=>e.listen(()=>{t?o():(t=!0,clearTimeout(n),u())}));return n=setTimeout(()=>{t=!0,u()},0),()=>{c=!1;for(let e of r)e();clearTimeout(n)}}),i},B=()=>Math.floor(Date.now()/1e3),Me=5;function Ne(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={isInitialized:!1,lastSessionRequest:0},l=()=>s||R().isOnline,u=e=>{if(l()){if(e?.event===`storage`)t();else if(e?.event===`poll`)c.lastSessionRequest=B(),t();else if(e?.event===`visibilitychange`){if(B()-c.lastSessionRequest<Me)return;c.lastSessionRequest=B(),t()}else t()}},d=e=>{O().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},f=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{n()&&u({event:`poll`})},a*1e3))},p=()=>{c.unsubscribeBroadcast=O().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=ve().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=R().subscribe(e=>{e&&u({event:`visibilitychange`})})},g=()=>{c.unsubscribeSignal=r.listen(()=>{t()})};return{init:()=>{c.isInitialized||(c.isInitialized=!0,f(),p(),m(),h(),g(),c.cleanupBroadcastSetup=O().setup(),c.cleanupFocusSetup=ve().setup(),c.cleanupOnlineSetup=R().setup())},cleanup:()=>{c.isInitialized&&(c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.unsubscribeSignal&&=(c.unsubscribeSignal(),void 0),c.cleanupBroadcastSetup&&=(c.cleanupBroadcastSetup(),void 0),c.cleanupFocusSetup&&=(c.cleanupFocusSetup(),void 0),c.cleanupOnlineSetup&&=(c.cleanupOnlineSetup(),void 0),c.isInitialized=!1,c.lastSessionRequest=0)},triggerRefetch:u,broadcastSessionUpdate:d}}var V=Object.create(null),H=e=>({}),U=new Proxy(V,{get(e,t){return H()[t]??V[t]},has(e,t){return t in H()||t in V},set(e,t,n){let r=H(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=H(!0);return delete n[t],!0},ownKeys(){let e=H(!0);return Object.keys(e)}});U.NODE_ENV;function W(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return W(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return W(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return W(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return W(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return W(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return W(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return W(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function Pe(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function Fe(e){let t=e.split(`
2
+ at `);return t.length<=1?e:(t.splice(1,1),t.join(`
3
+ at `))}function Ie(e,t){class n extends e{#e;constructor(...e){if(Pe()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Fe(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var Le={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Ie(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:Le[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var G=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},Re=47;function ze(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===Re;)t--;return t===e.length?e:e.slice(0,t)}function Be(e){try{return(ze(new URL(e).pathname)||`/`)!==`/`}catch{throw new G(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function Ve(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new G(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof G?t:new G(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function K(e,t=`/api/auth`){if(Ve(e),Be(e))return e;let n=ze(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function He(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[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])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function Ue(e,t,n,r,i){if(e)return K(e,t);if(r!==!1){let e=U.BETTER_AUTH_URL||U.NEXT_PUBLIC_BETTER_AUTH_URL||U.PUBLIC_BETTER_AUTH_URL||U.NUXT_PUBLIC_BETTER_AUTH_URL||U.NUXT_PUBLIC_AUTH_URL||(U.BASE_URL===`/`?void 0:U.BASE_URL);if(e)return K(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&He(o,`proto`)&&He(a,`host`))try{return K(`${o}://${a}`,t)}catch{}if(n){let e=We(n.url);if(!e)throw new G(`Could not get origin from request. Please provide a valid base URL.`);return K(e,t)}if(typeof window<`u`&&window.location)return K(window.location.origin,t)}function We(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var Ge=[`javascript:`,`data:`,`vbscript:`];function Ke(e){let t;try{t=new URL(e)}catch{return!0}return!Ge.includes(t.protocol)}var qe={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&Ke(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},Je=()=>typeof window>`u`,Ye=me;function Xe(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function Ze(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function Qe(e){return!e||e.session===null&&e.user===null?null:e}function $e(e,t){return F(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function et(e,t){let n=j(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>u(e),s=ke({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});ge(s,$e);let c=async(t,n)=>{let r=s.value;if(s.set({...r,isPending:r.data===null,isRefetching:!0,error:null,refetch:o}),t.aborted)return`aborted`;try{let r=await e(`/get-session`,{method:`GET`,query:n?.query,signal:t});if(t.aborted)return`aborted`;let{data:i,error:a}=Ze(r),c=`fresh`;if(i?.needsRefresh)try{let n=await e(`/get-session`,{method:`POST`,signal:t});if(t.aborted)return`aborted`;({data:i,error:a}=Ze(n))}catch{if(t.aborted)return`aborted`;c=`stale`}if(a){let e=s.value,t=a?.status===401;return s.set({data:t?null:e.data,error:a,isPending:!1,isRefetching:!1,refetch:o}),`failed`}let l=Qe(i),u=s.value,d=u.data!=null&&l!=null&&F(u.data,l)?u.data:l;return s.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:o}),c}catch(e){if(t.aborted)return`aborted`;let n=s.value;return s.set({data:n.data,error:e,isPending:!1,isRefetching:!1,refetch:o}),`failed`}},l=()=>{let e=s.value.data?.session?.expiresAt,t=e instanceof Date?e.getTime():1/0;return Math.min(Date.now()+Ye,t)},u=e=>{i=0,r?.cancel();let t=new AbortController,n={cancel:()=>t.abort(),promise:Promise.resolve().then(()=>t.signal.aborted?`aborted`:c(t.signal,e)),revision:a};r=n;let o=e=>{r===n&&(r=void 0,e===`fresh`&&n.revision===a&&(i=l()))};return n.promise.then(o,()=>o(`failed`)),n.promise.then(()=>void 0)},d=()=>r?.revision===a?r.promise.then(()=>void 0):Date.now()<i?Promise.resolve():u(),f=()=>{};return P(s,()=>{let e;Je()||(e=setTimeout(()=>{d()},0));let r=Ne({fetchSession:u,shouldPollSession:()=>s.value.data!=null,sessionSignal:n,options:t});return r.init(),f=r.broadcastSessionUpdate,()=>{e&&clearTimeout(e),r.cleanup()}}),{session:s,$sessionSignal:n,broadcastSessionUpdate:e=>f(e)}}function q(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function J(e,t,n=`.`,r){if(!q(t))return J(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:q(a)&&q(i[t])?J(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function tt(e){return(...t)=>t.reduce((t,n)=>J(t,n,``,e),{})}var nt=tt(),rt=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},it=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let t=await i.init?.call(i,e.toString(),n);n=t.options||n,e=t.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},at=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},ot=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function st(e){if(typeof e==`number`)return new at({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new at(e);case`exponential`:return new ot(e);default:throw Error(`Invalid retry strategy`)}}var ct=[`get`,`post`,`put`,`patch`,`delete`];function Y(e){if(!e.startsWith(`@`))return{method:void 0,path:e};let t=e.indexOf(`/`),n=e.slice(1,t===-1?void 0:t);return ct.includes(n)?{method:n,path:t===-1?e:e.slice(t+1)}:{method:void 0,path:e}}var lt=e=>e===`.`||e===`..`,ut=e=>e.split(`:`).map(e=>encodeURIComponent(e)).join(`:`);function dt(e,t){let n=t.get(e);if(n===void 0)return ut(e);if(lt(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function ft(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``,{path:o}=Y(e);o!==e&&(e=`/${o}`),a.endsWith(`/`)||(a+=`/`);let[s,c]=e.replace(a,``).split(`?`),l=new URLSearchParams(c);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)l.append(e,n);continue}else n=JSON.stringify(t);l.set(e,n)}let u=new Map;if(r){if(Array.isArray(r)){let e=s.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];u.set(n,String(e))}}else for(let[e,t]of Object.entries(r))u.set(`:${e}`,String(t))}s=s.split(`/`).map(e=>dt(e,u)).join(`/`),s=s.replace(/^\/+/,``);let d=l.toString();return d=d.length>0?`?${d}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${s}${d}`,a):`${a}${s}${d}`}var pt=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},mt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function ht(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return mt.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function gt(e){try{return JSON.parse(e),!0}catch{return!1}}function _t(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function vt(e){try{return JSON.parse(e)}catch{return e}}function yt(e){return typeof e==`function`}function bt(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&yt(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&yt(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function xt(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function St(e){let t=new Headers(xt(e?.headers,await pt(e)));if(!t.has(`content-type`)){let n=Ct(e?.body);n&&t.set(`content-type`,n)}return t}function Ct(e){return _t(e)?`application/json`:null}function wt(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Tt(e,t){let{body:n}=e;return n?!_t(n)||typeof n==`string`?n:wt(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function Et(e,t){if(t?.method)return t.method.toUpperCase();let{method:n}=Y(e);return n?n.toUpperCase():t?.body?`POST`:`GET`}function Dt(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Ot=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function X(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Ot(n.issues);return n.value}function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Z(e)}function kt(e,t){if(Z(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Z(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function At(e){var t=kt(e,`string`);return Z(t)==`symbol`?t:t+``}function jt(e,t,n){return(t=At(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Mt(Object(n),!0).forEach(function(t){jt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var $=async(e,t)=>{var n;let{hooks:r,url:i,options:a}=await it(e,t),o=bt(a),s=new AbortController,c=a.signal??s.signal,l=ft(i,a),u=await St(a),d=Tt(a,u),f=Et(i,a),p=Q(Q({},a),{},{url:l,headers:u,body:d,method:f,signal:c});for(let e of r.onRequest)if(e){let t=await e(p);typeof t==`object`&&t&&Object.assign(p,t)}(`pipeTo`in p&&typeof p.pipeTo==`function`||typeof(t==null||(n=t.body)==null?void 0:n.pipe)==`function`)&&(`duplex`in p||(p.duplex=`half`));let{clearTimeout:m}=Dt(a,s),h=await o(p.url,p);m();let g={response:h,request:p};for(let e of r.onResponse)if(e){var _;let n=await e(Q(Q({},g),{},{response:t!=null&&(_=t.hookOptions)!=null&&_.cloneResponse?h.clone():h}));n instanceof Response?h=n:typeof n==`object`&&n&&(h=n.response)}if(h.ok){if(p.method===`HEAD`)return{data:``,error:null};let e=ht(h),n={data:null,response:h,request:p};if(e===`json`||e===`text`){let e=await h.text();n.data=await(p.jsonParser??vt)(e)}else n.data=await h[e]();p?.output&&p.output&&!p.disableValidation&&(n.data=await X(p.output,n.data));for(let e of r.onSuccess)if(e){var v;await e(Q(Q({},n),{},{response:t!=null&&(v=t.hookOptions)!=null&&v.cloneResponse?h.clone():h}))}return t?.throw?n.data:{data:n.data,error:null}}let y=t?.jsonParser??vt,b=await h.text(),x=gt(b),S=x?await y(b):null,C={response:h,responseText:b,request:p,error:Q(Q({},S),{},{status:h.status,statusText:h.statusText})};for(let e of r.onError)if(e){var w;await e(Q(Q({},C),{},{response:t!=null&&(w=t.hookOptions)!=null&&w.cloneResponse?h.clone():h}))}if(t?.retry){let n=st(t.retry),i=t.retryAttempt??0;if(await n.shouldAttemptRetry(i,h)){for(let e of r.onRetry)e&&await e(g);let a=n.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await $(e,Q(Q({},t),{},{retryAttempt:i+1}))}}if(t?.throw)throw new rt(h.status,h.statusText,x?S:b);return{data:null,error:Q(Q({},S),{},{status:h.status,statusText:h.statusText})}},Nt=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){var r;let i=Q(Q({},n),e.query!==void 0&&{query:Q(Q({},e.query),n?.query)}),a=((r=e.plugins)==null||(r=r.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1))==null?void 0:r.schema)||e.schema;if(a){let r=t;a.config?.prefix&&r.startsWith(a.config.prefix)&&(r=r.replace(a.config.prefix,``),a.config.baseURL&&(t=t.replace(a.config.prefix,a.config.baseURL))),a.config?.baseURL&&r.startsWith(a.config.baseURL)&&(r=r.replace(a.config.baseURL,``)),r.startsWith(`/`)&&r.charAt(1)===`@`&&(r=r.substring(1));let o=a.schema[r];if(o){let{method:a,path:s}=Y(r);a&&(t=t.slice(0,t.length-r.length)+s);let c=n?.headers;if(o.headers&&!n?.disableValidation){let e={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((t,n)=>{e[n.toLowerCase()]=t});else if(typeof n.headers==`object`)for(let[t,r]of Object.entries(n.headers))r!=null&&(e[t.toLowerCase()]=r)}let t=await X(o.headers,e),r={};for(let[e,n]of Object.entries(t))r[e.toLowerCase()]=n;c=r}let l=o.method??a;if(i=Q(Q(Q(Q({},i),l!==void 0&&{method:l}),o.output!==void 0&&{output:o.output}),c!==void 0&&{headers:c}),!n?.disableValidation){if(o.query&&(i.query=await X(o.query,n?.query),i.query!==null&&typeof i.query==`object`)){let t=Q({},e.query);for(let e of Object.keys(t))n?.query&&Object.prototype.hasOwnProperty.call(n.query,e)&&(t[e]=n.query[e]);i.query=Q(Q({},t),i.query)}i=Q(Q({},i),{},{body:o.input?await X(o.input,n?.body):n?.body,params:o.params?await X(o.params,n?.params):n?.params})}return{url:t,options:i}}}return Q({url:t},(n!==void 0||e.query!==void 0)&&{options:i})}}),Pt=e=>{async function t(t,n){let r=Q(Q(Q({},e),n),{},{headers:xt(e?.headers,n?.headers),plugins:[...e?.plugins||[],Nt(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await $(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await $(t,r)}return t},Ft=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},It=e=>e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`,Lt=(e,t)=>{let n=`credentials`in Request.prototype,r=Ue(e?.baseURL,e?.basePath,void 0,t)??Ft(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=Pt({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?De(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[qe],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=et(d,e),h=!1,g=e=>{h||e===null||(h=!0,Xe(p,e))},_=e?.plugins||[],v={},y={$sessionSignal:f,session:p},b={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},x=[{signal:`$sessionSignal`,matcher:It,callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of _)e.getAtoms&&Object.assign(y,e.getAtoms?.(d)),e.pathMethods&&Object.assign(b,e.pathMethods),e.atomListeners&&x.push(...e.atomListeners);let S={notify:e=>{y[e].set(!y[e].get())},listen:(e,t)=>{y[e].subscribe(t)},atoms:y};for(let t of _)t.getActions&&(v=nt(t.getActions?.(d,S,e)??{},v));return{get baseURL(){return r},pluginsActions:v,pluginsAtoms:y,pluginPathMethods:b,atomListeners:x,hydrateSession:g,$sessionSignal:f,$fetch:d,$store:S}};function Rt(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Bt=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,Vt=/['\u2019]/g;function Ht(e){return e.replace(Vt,``).match(Bt)??[]}function Ut(e){return Ht(e).map(e=>e.toLowerCase()).join(`-`)}function Wt(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function Gt(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||Rt(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(Ut).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=Wt(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function Kt(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=Lt(e),c={};for(let[e,t]of Object.entries(r))c[`use${zt(e)}`]=t;return Gt({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}var qt=(e,{$listPasskeys:t,$store:n})=>({signIn:{passkey:async(r,i)=>{let a=await e(`/passkey/generate-authenticate-options`,{method:`GET`,throw:!1});if(!a.data)return a;let o=a.data.extensions||r?.extensions?{...a.data.extensions||{},...r?.extensions||{}}:void 0,s;try{s=await ne({optionsJSON:{...a.data,extensions:o},useBrowserAutofill:r?.autoFill})}catch(e){return{data:null,error:{code:e instanceof y?e.code:`AUTH_CANCELLED`,message:d.AUTH_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}}try{let{clientExtensionResults:a,...o}=s,c=await e(`/passkey/verify-authentication`,{body:{response:o},...r?.fetchOptions,...i,method:`POST`,throw:!1});return t.set(Math.random()),n.notify(`$sessionSignal`),r?.returnWebAuthnResponse?{...c,webauthn:{response:s,clientExtensionResults:a}}:c}catch(e){return console.error(`[Better Auth] Error verifying passkey`,e),{data:null,error:{code:`AUTH_CANCELLED`,message:d.AUTH_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}}}},passkey:{addPasskey:async(r,i)=>{let a=await e(`/passkey/generate-register-options`,{method:`GET`,query:{...r?.authenticatorAttachment&&{authenticatorAttachment:r.authenticatorAttachment},...r?.name&&{name:r.name},...r?.context&&{context:r.context}},throw:!1});if(!a.data)return a;try{let o=a.data.extensions||r?.extensions?{...a.data.extensions||{},...r?.extensions||{}}:void 0,s=await w({optionsJSON:{...a.data,extensions:o},useAutoRegister:r?.useAutoRegister}),{clientExtensionResults:c,...l}=s,u=await e(`/passkey/verify-registration`,{...r?.fetchOptions,...i,body:{response:l,name:r?.name,...r?.createSession&&{createSession:!0}},method:`POST`,throw:!1});return u.data?(t.set(Math.random()),u.data.session&&n.notify(`$sessionSignal`),r?.returnWebAuthnResponse?{...u,webauthn:{response:s,clientExtensionResults:c}}:u):u}catch(e){return e instanceof y?e.code===`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`?{data:null,error:{code:e.code,message:d.PREVIOUSLY_REGISTERED.message,status:400,statusText:`BAD_REQUEST`}}:e.code===`ERROR_CEREMONY_ABORTED`?{data:null,error:{code:e.code,message:d.REGISTRATION_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}:{data:null,error:{code:e.code,message:e.message,status:400,statusText:`BAD_REQUEST`}}:{data:null,error:{code:`UNKNOWN_ERROR`,message:e instanceof Error?e.message:d.UNKNOWN_ERROR.message,status:500,statusText:`INTERNAL_SERVER_ERROR`}}}}},$Infer:{}}),Jt=()=>{let e=j();return{id:`passkey`,version:f,$InferServerPlugin:{},getActions:(t,n)=>qt(t,{$listPasskeys:e,$store:n}),getAtoms(t){return{listPasskeys:z(e,`/passkey/list-user-passkeys`,t,{method:`GET`}),$listPasskeys:e}},pathMethods:{"/passkey/register":`POST`,"/passkey/authenticate":`POST`},atomListeners:[{matcher(e){return e===`/passkey/verify-registration`||e===`/passkey/delete-passkey`||e===`/passkey/update-passkey`||e===`/sign-out`},signal:`$listPasskeys`},{matcher:e=>e===`/passkey/verify-authentication`,signal:`$sessionSignal`}],$ERROR_CODES:d}},Yt=`1.7.10`,Xt=e=>({id:`sso-client`,version:Yt,$InferServerPlugin:{},pathMethods:{"/sso/providers":`GET`,"/sso/get-provider":`GET`}});function Zt(e){return{success:!1,error:`You are not allowed to access resource: ${e}`}}function Qt(e){return{success:!1,error:`unauthorized to access resource "${e}"`}}function $t(e){return e===`OR`?`OR`:`AND`}function en(e){return Array.isArray(e)}function tn(e){if(en(e))return{actions:e,connector:`AND`};if(!e||typeof e!=`object`)throw new G(`Invalid access control request`);let{actions:t,connector:n}=e;return en(t)?{actions:t,connector:$t(n)}:{actions:[],connector:$t(n)}}function nn(e,t){return typeof t==`string`&&e.includes(t)}function rn(e,{actions:t,connector:n}){return t.length===0?!1:n===`OR`?t.some(t=>nn(e,t)):t.every(t=>nn(e,t))}function an(e){return{authorize(t,n=`AND`){let r=!1;for(let[i,a]of Object.entries(t)){let t=e[i];if(!t){if(n===`AND`)return Zt(i);continue}let o=rn(t,tn(a));if(o&&(r=!0),o&&n===`OR`)return{success:!0};if(!o&&n===`AND`)return Qt(i)}return r?{success:!0}:{success:!1,error:`Not authorized`}},statements:e}}function on(e){return{newRole(e){return an(e)},statements:e}}var sn=u({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:`You are not allowed to create a new organization`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:`You have reached the maximum number of organizations`,ORGANIZATION_ALREADY_EXISTS:`Organization already exists`,ORGANIZATION_SLUG_ALREADY_TAKEN:`Organization slug already taken`,ORGANIZATION_NOT_FOUND:`Organization not found`,USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:`User is not a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:`You are not allowed to update this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:`You are not allowed to delete this organization`,NO_ACTIVE_ORGANIZATION:`No active organization`,USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:`User is already a member of this organization`,MEMBER_NOT_FOUND:`Member not found`,ROLE_NOT_FOUND:`Role not found`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:`You are not allowed to create a new team`,TEAM_ALREADY_EXISTS:`Team already exists`,TEAM_NOT_FOUND:`Team not found`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:`You cannot leave the organization as the only owner`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:`You cannot leave the organization without an owner`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:`You are not allowed to delete this member`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:`You are not allowed to invite users to this organization`,USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:`User is already invited to this organization`,INVITATION_NOT_FOUND:`Invitation not found`,YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:`You are not the recipient of the invitation`,EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:`Email verification required before accepting or rejecting invitation`,EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION:`Email verification required to view or list invitations for the session email`,YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:`You are not allowed to cancel this invitation`,INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:`Inviter is no longer a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:`You are not allowed to invite a user with this role`,FAILED_TO_RETRIEVE_INVITATION:`Failed to retrieve invitation`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:`You have reached the maximum number of teams`,UNABLE_TO_REMOVE_LAST_TEAM:`Unable to remove last team`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:`You are not allowed to update this member`,ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:`Organization membership limit reached`,YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to create teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to delete teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:`You are not allowed to update this team`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:`You are not allowed to delete this team`,INVITATION_LIMIT_REACHED:`Invitation limit reached`,TEAM_MEMBER_LIMIT_REACHED:`Team member limit reached`,USER_IS_NOT_A_MEMBER_OF_THE_TEAM:`User is not a member of the team`,YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:`You are not allowed to list the members of this team`,YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:`You do not have an active team`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:`You are not allowed to create a new member`,YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:`You are not allowed to remove a team member`,YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:`You are not allowed to access this organization as an owner`,YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:`You are not a member of this organization`,MISSING_AC_INSTANCE:`Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information`,YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:`You must be in an organization to create a role`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:`You are not allowed to create a role`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:`You are not allowed to update a role`,YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:`You are not allowed to delete a role`,YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:`You are not allowed to read a role`,YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:`You are not allowed to list a role`,YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:`You are not allowed to get a role`,TOO_MANY_ROLES:`This organization has too many roles`,INVALID_RESOURCE:`The provided permission includes an invalid resource`,ROLE_NAME_IS_ALREADY_TAKEN:`That role name is already taken`,CANNOT_DELETE_A_PRE_DEFINED_ROLE:`Cannot delete a pre-defined role`,ROLE_IS_ASSIGNED_TO_MEMBERS:`Cannot delete a role that is assigned to members. Please reassign the members to a different role first`,INVALID_TEAM_ID:`Team id contains a reserved character`}),cn=on({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),ln=cn.newRole({organization:[`update`],invitation:[`create`,`cancel`],member:[`create`,`update`,`delete`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),un=cn.newRole({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),dn=cn.newRole({organization:[],member:[],invitation:[],team:[],ac:[`read`]}),fn={admin:ln,owner:un,member:dn},pn=(e,t)=>{if(!e.permissions)return!1;let n=e.role.split(`,`),r=e.options.creatorRole||`owner`,i=n.includes(r),a=e.allowCreatorAllPermissions||!1;if(i&&a)return!0;for(let r of n)if(t[r]?.authorize(e.permissions)?.success)return!0;return!1},mn=e=>pn(e,e.options.roles||fn),hn=e=>{let t=j(!1),n=j(!1),r=j(!1),i=j(!1),a={admin:ln,member:dn,owner:un,...e?.roles};return{id:`organization`,version:re,$InferServerPlugin:{},getActions:(t,n,r)=>({$Infer:{ActiveOrganization:{},Organization:{},Invitation:{},Member:{},Team:{}},organization:{checkRolePermission:t=>mn({role:t.role,options:{ac:e?.ac,roles:a},permissions:t.permissions})}}),getAtoms:e=>{let a=z(t,`/organization/list`,e,{method:`GET`});return{$listOrg:t,$activeOrgSignal:n,$activeMemberSignal:r,$activeMemberRoleSignal:i,activeOrganization:z([n],`/organization/get-full-organization`,e,()=>({method:`GET`})),listOrganizations:a,activeMember:z([n,r],`/organization/get-active-member`,e,{method:`GET`}),activeMemberRole:z([n,i],`/organization/get-active-member-role`,e,{method:`GET`})}},pathMethods:{"/organization/get-full-organization":`GET`,"/organization/list-user-teams":`GET`},atomListeners:[{matcher(e){return e===`/organization/create`||e===`/organization/delete`||e===`/organization/update`},signal:`$listOrg`},{matcher(e){return It(e)||e.startsWith(`/organization`)},signal:`$activeOrgSignal`},{matcher(e){return e.startsWith(`/organization/set-active`)||e===`/organization/create`||e===`/organization/delete`||e===`/organization/remove-member`||e===`/organization/leave`||e===`/organization/accept-invitation`},signal:`$sessionSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberRoleSignal`}],$ERROR_CODES:sn}},gn=u({OTP_NOT_ENABLED:`OTP not enabled`,OTP_NOT_CONFIGURED:`OTP is not available`,OTP_HAS_EXPIRED:`OTP has expired`,TOTP_NOT_ENABLED:`TOTP not enabled`,TOTP_ALREADY_ENABLED:`TOTP is already enabled`,TOTP_NOT_CONFIGURED:`TOTP is not available`,TWO_FACTOR_NOT_ENABLED:`Two factor isn't enabled`,BACKUP_CODES_NOT_ENABLED:`Backup codes aren't enabled`,INVALID_BACKUP_CODE:`Invalid backup code`,INVALID_CODE:`Invalid code`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`Too many attempts. Please request a new code.`,ACCOUNT_TEMPORARILY_LOCKED:`Too many failed verification attempts. Your account is temporarily locked. Please try again later.`,INVALID_TWO_FACTOR_COOKIE:`Invalid two factor cookie`}),_n=e=>({id:`two-factor`,version:re,$InferServerPlugin:{},atomListeners:[{matcher:e=>e.startsWith(`/two-factor/`),signal:`$sessionSignal`}],pathMethods:{"/two-factor/disable":`POST`,"/two-factor/enable":`POST`,"/two-factor/send-otp":`POST`,"/two-factor/generate-backup-codes":`POST`,"/two-factor/get-totp-uri":`POST`,"/two-factor/verify-totp":`POST`,"/two-factor/verify-otp":`POST`,"/two-factor/verify-backup-code":`POST`},fetchPlugins:[{id:`two-factor`,name:`two-factor`,hooks:{async onSuccess(t){if(t.data?.twoFactorRedirect){if(e?.onTwoFactorRedirect){await e.onTwoFactorRedirect({twoFactorMethods:t.data.twoFactorMethods});return}e?.twoFactorPage&&typeof window<`u`&&Ke(e.twoFactorPage)&&(window.location.href=e.twoFactorPage)}}}}],$ERROR_CODES:gn}),vn=t({authBase:()=>Cn,authClient:()=>Sn}),yn=on(i),bn=Object.fromEntries(a.map(e=>[e,yn.newRole(l[e])])),xn=/\/(sign-in\/|sign-up\/|two-factor\/verify|passkey\/verify-authentication|oauth2\/(consent|continue)|wizelens\/oauth-grant)/,Sn=Kt({baseURL:new URL(`api/auth`,window.location.origin+window.location.pathname).toString(),fetchOptions:{credentials:`same-origin`,headers:{"X-WizeLens-Client":`dashboard`}},plugins:[hn({ac:yn,roles:bn}),_n({onTwoFactorRedirect:()=>n(e(`two-factor`))}),Jt(),Xt({domainVerification:{enabled:!0}}),{id:`wizelens-oauth-query`,$InferServerPlugin:{},fetchPlugins:[{id:`wizelens-oauth-query`,name:`wizelens-oauth-query`,hooks:{async onRequest(e){let t=r.get();if(!t||e.method===`GET`||!xn.test(String(e.url)))return;let n=typeof e.body==`string`?JSON.parse(e.body||`{}`):e.body??{};n.oauth_query||(e.body=JSON.stringify({...n,oauth_query:t}))}}}]}]}),Cn=()=>new URL(`api/auth`,window.location.origin+window.location.pathname).toString();export{vn as n,Cn as t};