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

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.
@@ -1,2 +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(`
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-DJJSBLFB.js";import{n as p,t as m}from"./AppsPanel-FqAhi3J1.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-WvBRFdk4.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
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};
@@ -1 +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};
1
+ import{Z as e,vt as t}from"./account-DJJSBLFB.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-WvBRFdk4.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};
@@ -1 +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};
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-DJJSBLFB.js";import{t as f}from"./auth-client-CAuEdTnd.js";import{n as p,t as m}from"./AppsPanel-FqAhi3J1.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-WvBRFdk4.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};
@@ -1,3 +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]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./auth-client-CAuEdTnd.js","./index-WvBRFdk4.js","./index-CKkmmanu.css"])))=>i.map(i=>d[i]);
2
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};
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-CAuEdTnd.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};