cogpit 3.0.0 → 3.0.1

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.
Files changed (29) hide show
  1. package/dist/cli.js +136 -90
  2. package/dist/web/assets/CommandPaletteHost-B-n0sXM6.js +1 -0
  3. package/dist/web/assets/{ConfigBrowser-CXvr5BFb.js → ConfigBrowser-DOdqaQra.js} +1 -1
  4. package/dist/web/assets/{HighlightedEditor-DWc-xoSc.js → HighlightedEditor-D75svkum.js} +1 -1
  5. package/dist/web/assets/{KeyboardShortcutsDialog-C1of2PBc.js → KeyboardShortcutsDialog-DeIXxXmj.js} +1 -1
  6. package/dist/web/assets/{MobileFileChanges-BAEIKapA.js → MobileFileChanges-Dze0jsvc.js} +1 -1
  7. package/dist/web/assets/{PluginsDialog-BgnTB0-z.js → PluginsDialog-qcJTbfeg.js} +1 -1
  8. package/dist/web/assets/{PreviewPanel-DgbgRibz.js → PreviewPanel-DChL85Uq.js} +1 -1
  9. package/dist/web/assets/{ProjectFilesPanel-BGpyS_aw.js → ProjectFilesPanel-DJ-_Lb_R.js} +3 -3
  10. package/dist/web/assets/{ProjectSwitcherModal-CEypvUNm.js → ProjectSwitcherModal-BUV_fZ5V.js} +1 -1
  11. package/dist/web/assets/{TerminalOutput-Dq6QP83Y.js → TerminalOutput-BCG6Ppu3.js} +1 -1
  12. package/dist/web/assets/{ThemeSelectorModal-DeYABHF9.js → ThemeSelectorModal-t2P0tZVJ.js} +1 -1
  13. package/dist/web/assets/WorkflowsPanel-Bv2RwtYI.js +1 -0
  14. package/dist/web/assets/WorktreePanel-F9QlbnAH.js +1 -0
  15. package/dist/web/assets/{edition-ui-CFlDe2_U.js → edition-ui-C0x29noh.js} +1 -1
  16. package/dist/web/assets/index-BO-Nd-ib.css +1 -0
  17. package/dist/web/assets/{index-DYugSKH5.js → index-BtmLHL6v.js} +4 -4
  18. package/dist/web/assets/{index-Ch-IpPaH.js → index-C4W7tiDS.js} +1 -1
  19. package/dist/web/assets/{index-Bm91RnFy.js → index-CRUYvx2l.js} +1 -1
  20. package/dist/web/assets/{index-DsnL-sXV.js → index-CW9tjG1S.js} +86 -86
  21. package/dist/web/assets/index-bXbR7jwp.js +1 -0
  22. package/dist/web/assets/{session-parser.worker-CXlsiJzz.js → session-parser.worker-CkTPpg3t.js} +11 -11
  23. package/dist/web/index.html +2 -2
  24. package/package.json +1 -1
  25. package/dist/web/assets/CommandPaletteHost-fa5vgo7-.js +0 -1
  26. package/dist/web/assets/WorkflowsPanel-CNxUSC9Q.js +0 -1
  27. package/dist/web/assets/WorktreePanel-DJYEUobs.js +0 -1
  28. package/dist/web/assets/index-DVp2Xjmx.js +0 -1
  29. package/dist/web/assets/index-TCQKag8a.css +0 -1
@@ -1,2 +1,2 @@
1
1
  /*! Cogpit Team UI - proprietary, not covered by the MIT license */
2
- import{c as A,r as _,j as s}from"./vendor-react-gGw_S5I_.js";import{U as me,b5 as As,bX as re,c5 as ks,c6 as Ye,A as ee,aV as le,p as te,ac as he,B as F,a6 as Es,a7 as Ds,a8 as Ts,a5 as Ps,aa as Os,a9 as Us,ab as Rs,a4 as Ls,a3 as Is,bU as Ms,af as We,aX as Ct,Z as ne,aL as _e,aK as $e,aM as Ae,aO as ke,a$ as J,aH as Fs,C as X,c7 as _t,v as Gs,bR as zs,L as Ee,M as De,N as Ke,O as Te,Q as Pe,c8 as Bs,c9 as Hs,ca as Vs,cb as Ys,_ as Ws,cc as qe,cd as Je,ce as ae,cf as Q,cg as Xe,ch as Z,ci as Qe,G as Ze,aW as et,b4 as de,b0 as tt,n as Ks,I as qs,E as Js,m as Xs,h as $t,D as At,H as Oe,i as kt,j as Et,k as Dt,T as st,z as Tt,c3 as Qs,aI as Zs,aT as Pt,cj as Ot,ck as V,aq as Ue,cl as Se,cm as ve,cn as pt,J as se,co as q,cp as en,cq as tn,cr as sn,cs as xe,q as nn,ct as ln,y as Ut,cu as an,bZ as rn,cv as on,cw as cn,cx as dn,cy as un,ar as fn,R as nt,cz as mn,at as Rt,cA as Lt,aN as hn,be as It,bc as Mt,bd as Ft,bf as Gt,bg as zt,bh as Bt,Y as xn,cB as pn,cC as gn,cD as jn}from"./index-DsnL-sXV.js";import{J as Ht,aE as Vt,aF as lt,aG as at,aH as bn,ae as Yt,a2 as wn,a9 as yn,aa as Sn,aI as Nn,aJ as vn,aK as Cn,aL as _n,X as Wt,af as rt,aM as $n,aN as Kt,m as An,aO as qt,a5 as kn,aP as En,aQ as Dn,aR as Tn,aS as Pn}from"./vendor-ui-Br3ZTAXZ.js";import{P as ue}from"./password-BV9mqUzz.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";async function On(n,e){const t=await me(n,{signal:e});if(!t.ok)throw new Error(await As(t,`Request failed (${t.status})`));const l=await re(t);if(!l)throw new Error("The server returned an unexpected response");return l}function ce(n){const e=A.c(11);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={data:null,dataPath:null,error:null,loading:!0},e[0]=t):t=e[0];const[l,r]=_.useState(t),[a,i]=_.useState(0);let o;e[1]!==n?(o=()=>{const m=new AbortController;return r(Rn),On(n,m.signal).then(h=>{m.signal.aborted||r({data:h,dataPath:n,error:null,loading:!1})}).catch(h=>{if(m.signal.aborted)return;const x=h instanceof Error?h.message:"Request failed";r(p=>{const g=p.dataPath===n;return{data:g?p.data:null,dataPath:g?n:null,error:x,loading:!1}})}),()=>m.abort()},e[1]=n,e[2]=o):o=e[2];let c;e[3]!==a||e[4]!==n?(c=[n,a],e[3]=a,e[4]=n,e[5]=c):c=e[5],_.useEffect(o,c);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i(Un),e[6]=d):d=e[6];const u=d;let f;return e[7]!==l.data||e[8]!==l.error||e[9]!==l.loading?(f={data:l.data,error:l.error,loading:l.loading,refresh:u},e[7]=l.data,e[8]=l.error,e[9]=l.loading,e[10]=f):f=e[10],f}function Un(n){return n+1}function Rn(n){return{...n,loading:!0,error:null}}function Jt(n){const{from:e,to:t}=n;return ce(`/api/team/usage?from=${e}&to=${t}`)}function Ln(n){return n===null||!("role"in n)?!1:n.role==="admin"||n.role==="member"}const Xt=864e5,Me=90,gt=Me*Xt;function In({from:n,to:e},t){return e-n>gt?"too_long":e<t-gt?"too_old":null}const it={admin:"Admin",member:"Member"},Ce={text:"—",title:"Price unavailable"},Qt="No one can become an admin while the license keeps members out.";function Zt(n,e){return{from:e-n*Xt,to:e}}function es(n){return n.input+n.output+n.cacheRead+n.cacheWrite}const Fe="cogpit:lockout-return-to-people";function Mn(){try{sessionStorage.setItem(Fe,"1")}catch{return}window.history.replaceState(null,"",`${ks()}/`)}function Fn(){try{return sessionStorage.getItem(Fe)===null?!1:(sessionStorage.removeItem(Fe),!0)}catch{return!1}}function K(n){return new Date(n).toLocaleDateString(void 0,{dateStyle:"medium"})}function Ge(n){const e=new Date(n),t=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${t}-${l}`}function ts(n,e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(!t)return null;const[l,r,a]=[Number(t[1]),Number(t[2])-1,Number(t[3])],i=new Date(l,r,a);return i.getFullYear()!==l||i.getMonth()!==r||i.getDate()!==a?null:(i.setDate(i.getDate()+e),i.getTime())}function Gn(n){return ts(n,0)}function zn(n){const e=ts(n,1);return e===null?null:e-1}const Bn={"shares.local.json":" Every share link was reset and its guests signed out; share each session again.","sessions.json":" Everyone was signed out and must sign in again."};function Hn({store:n,detectedAt:e,kind:t}){if(t==="baseline")return`The audit log started on ${K(e)}; existing data was accepted as-is.`;const l=`detected ${K(e)}`;return(t==="unverifiable"?`${n} could not be checked against the audit log (${l}).`:`${n} was changed outside Cogpit (${l}).`)+(Bn[n]??"")}const Vn={expired:{cause:"The license has expired.",remedy:"install a new key"},over_seats:{cause:"More accounts are enabled than the license has seats.",remedy:"disable accounts or install a license with more seats"}};function Yn({state:n,reason:e,graceEndsAt:t}){if(n==="valid"||e===null)return null;const{cause:l,remedy:r}=Vn[e];return n==="locked"?`${l} Only admins can sign in until you ${r}.`:t===null?`${l} Members will be locked out unless you ${r}.`:`${l} Members can sign in until ${K(t)}; ${r} before then.`}function Wn(n){const e=[],{audit:t}=n;if(t.writable||e.push({id:"audit-writable",message:"The audit log cannot be written. Prompts and admin actions are not being recorded."}),t.missed>0){const r=t.missed===1?"1 audit event":`${t.missed} audit events`,a=t.since===null?"":` since ${K(t.since)}`;e.push({id:"audit-missed",message:`${r} could not be recorded${a}.`})}t.clockAhead&&e.push({id:"audit-clock",message:"The audit log is dated ahead of this server's clock, so new entries carry the log's time. Check the system clock."});for(const r of n.integrity)e.push({id:`integrity-${r.store}-${r.detectedAt}`,message:Hn(r),acceptance:r.kind==="baseline"?{store:r.store,subject:"the existing data",trust:"Cogpit will keep trusting the stores' current contents, and the audit log will record that you accepted them."}:{store:r.store,subject:r.store,trust:"Cogpit will trust the file's current contents from now on, and the audit log will record that you accepted them."}});for(const{store:r,since:a}of n.storeWrites)e.push({id:`store-write-${r}`,message:`${r} could not be saved since ${K(a)}. Changes made since then, revoked access included, apply until the server restarts, then are lost. Free disk space or fix the data directory's permissions.`});const l=Yn(n.license);return l&&e.push({id:"license",message:l}),e}const Kn="Every seat on the license is in use. Disable someone or install a license with more seats.";async function pe(n,e,t){let l;try{l=await Ye(n,t,{method:e})}catch{return{ok:!1,error:"Could not reach the server."}}const r=await re(l);if(l.ok&&r)return{ok:!0,value:r};const a=r;return(a==null?void 0:a.code)==="SEAT_LIMIT"?{ok:!1,error:Kn}:{ok:!1,error:typeof(a==null?void 0:a.error)=="string"&&a.error?a.error:`Request failed (${l.status})`}}function qn(n){return pe("/api/team/users","POST",n)}function ss(n,e){return pe(`/api/team/users/${encodeURIComponent(n)}`,"PATCH",e)}function Jn(n){return pe("/api/team/session-access/assign","POST",n)}function Xn(n){return pe("/api/team/license","POST",{key:n})}function Qn(n){return pe("/api/team/health/acknowledge","POST",{store:n})}function ge(){const[n,e]=_.useState(!1),[t,l]=_.useState(null);async function r(a){e(!0),l(null);try{const i=await a();return i.ok?i.value:(l(i.error),null)}finally{e(!1)}}return{busy:n,error:t,setError:l,run:r}}function Zn(n){const e=A.c(40),{acceptance:t,warning:l,onAccepted:r}=n,{store:a,subject:i,trust:o}=t,{busy:c,error:d,run:u}=ge(),[f,m]=_.useState(!1);let h;e[0]!==r||e[1]!==u||e[2]!==a||e[3]!==i?(h=async function(){m(!1),await u(()=>Qn(a))&&(he.success(`Accepted the current state of ${i}`),r())},e[0]=r,e[1]=u,e[2]=a,e[3]=i,e[4]=h):h=e[4];const x=h,p=`Accept the current state of ${i}`;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=()=>m(!0),e[5]=g):g=e[5];let j;e[6]!==c||e[7]!==p?(j=s.jsx(F,{variant:"outline",size:"xs",disabled:c,"aria-label":p,onClick:g,children:"Accept current state"}),e[6]=c,e[7]=p,e[8]=j):j=e[8];let b;e[9]!==d?(b=d&&s.jsx("span",{role:"alert",className:"text-destructive",children:d}),e[9]=d,e[10]=b):b=e[10];let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Es,{className:"bg-warning/10 text-warning",children:s.jsx(Vt,{})}),e[11]=S):S=e[11];const w=`Accept the current state of ${i}?`;let y;e[12]!==w?(y=s.jsx(Ds,{children:w}),e[12]=w,e[13]=y):y=e[13];let N;e[14]!==l?(N=s.jsx("span",{children:l}),e[14]=l,e[15]=N):N=e[15];let v;e[16]!==o?(v=s.jsx("span",{children:o}),e[16]=o,e[17]=v):v=e[17];let C;e[18]!==N||e[19]!==v?(C=s.jsxs(Ts,{className:"flex flex-col gap-2",children:[N,v]}),e[18]=N,e[19]=v,e[20]=C):C=e[20];let $;e[21]!==C||e[22]!==y?($=s.jsxs(Ps,{children:[S,y,C]}),e[21]=C,e[22]=y,e[23]=$):$=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(Os,{size:"sm",children:"Cancel"}),e[24]=k):k=e[24];let T;e[25]!==x?(T=()=>void x(),e[25]=x,e[26]=T):T=e[26];let U;e[27]!==c||e[28]!==T?(U=s.jsxs(Us,{children:[k,s.jsx(Rs,{size:"sm",disabled:c,onClick:T,children:"Accept current state"})]}),e[27]=c,e[28]=T,e[29]=U):U=e[29];let O;e[30]!==$||e[31]!==U?(O=s.jsxs(Ls,{children:[$,U]}),e[30]=$,e[31]=U,e[32]=O):O=e[32];let D;e[33]!==f||e[34]!==O?(D=s.jsx(Is,{open:f,onOpenChange:m,children:O}),e[33]=f,e[34]=O,e[35]=D):D=e[35];let E;return e[36]!==D||e[37]!==j||e[38]!==b?(E=s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[j,b,D]}),e[36]=D,e[37]=j,e[38]=b,e[39]=E):E=e[39],E}function el(n){const e=A.c(28),{health:t,onChanged:l}=n;let r,a,i,o,c,d,u,f,m;if(e[0]!==t||e[1]!==l){m=Symbol.for("react.early_return_sentinel");e:{const g=Wn(t);if(g.length===0){m=null;break e}a=ee,d="border-warning/30 bg-warning/10 text-warning",e[11]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ht,{}),f=s.jsx(le,{children:"This team server needs attention"}),e[11]=u,e[12]=f):(u=e[11],f=e[12]),r=te,c="text-warning/90",i="flex list-disc flex-col gap-1 pl-4";let j;e[13]!==l?(j=b=>s.jsxs("li",{children:[s.jsx("span",{className:"mr-2",children:b.message}),b.acceptance&&s.jsx(Zn,{acceptance:b.acceptance,warning:b.message,onAccepted:l})]},b.id),e[13]=l,e[14]=j):j=e[14],o=g.map(j)}e[0]=t,e[1]=l,e[2]=r,e[3]=a,e[4]=i,e[5]=o,e[6]=c,e[7]=d,e[8]=u,e[9]=f,e[10]=m}else r=e[2],a=e[3],i=e[4],o=e[5],c=e[6],d=e[7],u=e[8],f=e[9],m=e[10];if(m!==Symbol.for("react.early_return_sentinel"))return m;let h;e[15]!==i||e[16]!==o?(h=s.jsx("ul",{className:i,children:o}),e[15]=i,e[16]=o,e[17]=h):h=e[17];let x;e[18]!==r||e[19]!==c||e[20]!==h?(x=s.jsx(r,{className:c,children:h}),e[18]=r,e[19]=c,e[20]=h,e[21]=x):x=e[21];let p;return e[22]!==a||e[23]!==d||e[24]!==u||e[25]!==f||e[26]!==x?(p=s.jsxs(a,{className:d,children:[u,f,x]}),e[22]=a,e[23]=d,e[24]=u,e[25]=f,e[26]=x,e[27]=p):p=e[27],p}function fe(n){const e=A.c(11),{title:t,message:l,onRetry:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(lt,{}),e[0]=a):a=e[0];let i;e[1]!==t?(i=s.jsx(le,{children:t}),e[1]=t,e[2]=i):i=e[2];let o;e[3]!==l?(o=s.jsx(te,{children:l}),e[3]=l,e[4]=o):o=e[4];let c;e[5]!==r?(c=s.jsx(Ms,{children:s.jsx(F,{variant:"outline",size:"xs",onClick:r,children:"Retry"})}),e[5]=r,e[6]=c):c=e[6];let d;return e[7]!==i||e[8]!==o||e[9]!==c?(d=s.jsxs(ee,{variant:"destructive",children:[a,i,o,c]}),e[7]=i,e[8]=o,e[9]=c,e[10]=d):d=e[10],d}function ot(n){const e=A.c(3),{label:t}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx(We,{className:"size-4"}),e[0]=l):l=e[0];let r;return e[1]!==t?(r=s.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[l,t]}),e[1]=t,e[2]=r):r=e[2],r}const tl={valid:{label:"Active",variant:"secondary"},grace:{label:"Grace period",variant:"outline",className:"border-warning/30 bg-warning/10 text-warning"},locked:{label:"Members locked out",variant:"destructive"}};function sl(n){const e=A.c(20),{license:t}=n;let l;e[0]!==t.customer?(l=["Customer",t.customer],e[0]=t.customer,e[1]=l):l=e[1];const r=`${t.activeUsers} of ${t.seats} used`;let a;e[2]!==r?(a=["Seats",r],e[2]=r,e[3]=a):a=e[3];const i=t.reason==="expired"?"Expired":"Expires";let o;e[4]!==t.expiresAt?(o=K(t.expiresAt),e[4]=t.expiresAt,e[5]=o):o=e[5];let c;e[6]!==i||e[7]!==o?(c=[i,o],e[6]=i,e[7]=o,e[8]=c):c=e[8];let d;if(e[9]!==t.graceEndsAt||e[10]!==l||e[11]!==a||e[12]!==c){if(d=[l,a,c],t.graceEndsAt!==null){let f;e[14]!==t.graceEndsAt?(f=K(t.graceEndsAt),e[14]=t.graceEndsAt,e[15]=f):f=e[15];let m;e[16]!==f?(m=["Grace ends",f],e[16]=f,e[17]=m):m=e[17],d.push(m)}e[9]=t.graceEndsAt,e[10]=l,e[11]=a,e[12]=c,e[13]=d}else d=e[13];let u;return e[18]!==d?(u=s.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5",children:d.map(nl)}),e[18]=d,e[19]=u):u=e[19],u}function nl(n){const[e,t]=n;return s.jsxs("div",{className:"contents",children:[s.jsx("dt",{className:"text-muted-foreground",children:e}),s.jsx("dd",{className:"text-foreground tabular-nums",children:t})]},e)}function ll(n){const e=A.c(23),{onDone:t,onInstalled:l}=n,r=_.useId(),[a,i]=_.useState(""),{busy:o,error:c,setError:d,run:u}=ge();let f;e[0]!==a||e[1]!==t||e[2]!==l||e[3]!==u||e[4]!==d?(f=async function(){if(!a.trim()){d("Paste a license key.");return}await u(()=>Xn(a.trim()))&&(he.success("License installed"),l(),t())},e[0]=a,e[1]=t,e[2]=l,e[3]=u,e[4]=d,e[5]=f):f=e[5];const m=f;let h;e[6]!==m?(h=()=>void m(),e[6]=m,e[7]=h):h=e[7];const x=`${r}-key`;let p;e[8]!==x?(p=s.jsx(J,{htmlFor:x,children:"License key"}),e[8]=x,e[9]=p):p=e[9];const g=`${r}-key`;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=y=>i(y.target.value),e[10]=j):j=e[10];let b;e[11]!==a||e[12]!==g?(b=s.jsx(Fs,{id:g,value:a,onChange:j,placeholder:"Paste the key from your Cogpit Team license",rows:3,spellCheck:!1,autoFocus:!0,className:"font-mono text-xs break-all"}),e[11]=a,e[12]=g,e[13]=b):b=e[13];let S;e[14]!==p||e[15]!==b?(S=s.jsxs(X,{children:[p,b]}),e[14]=p,e[15]=b,e[16]=S):S=e[16];let w;return e[17]!==o||e[18]!==c||e[19]!==t||e[20]!==h||e[21]!==S?(w=s.jsx(_t,{error:c,busy:o,saveLabel:"Install",onCancel:t,onSave:h,className:"px-0 pb-0",children:S}),e[17]=o,e[18]=c,e[19]=t,e[20]=h,e[21]=S,e[22]=w):w=e[22],w}function al(n){const e=A.c(24),{license:t,onInstalled:l}=n,[r,a]=_.useState(!1),i=t.data,o=i?tl[i.state]:null;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(_e,{children:"License"}),e[0]=c):c=e[0];let d;e[1]!==o?(d=o&&s.jsx(Ct,{children:s.jsx(ne,{variant:o.variant,className:o.className,children:o.label})}),e[1]=o,e[2]=d):d=e[2];let u;e[3]!==d?(u=s.jsxs($e,{children:[c,d]}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==t.error||e[6]!==t.refresh?(f=t.error&&s.jsx(fe,{title:"License status could not load",message:t.error,onRetry:t.refresh}),e[5]=t.error,e[6]=t.refresh,e[7]=f):f=e[7];let m;e[8]!==i?(m=i&&s.jsx(sl,{license:i}),e[8]=i,e[9]=m):m=e[9];let h;e[10]!==t.loading||e[11]!==i?(h=!i&&t.loading&&s.jsx(ot,{label:"Loading license…"}),e[10]=t.loading,e[11]=i,e[12]=h):h=e[12];let x;e[13]!==r||e[14]!==l?(x=r?s.jsx(ll,{onDone:()=>a(!1),onInstalled:l}):s.jsxs(F,{variant:"outline",size:"sm",className:"self-start",onClick:()=>a(!0),children:[s.jsx(at,{"data-icon":"inline-start"}),"Install license key"]}),e[13]=r,e[14]=l,e[15]=x):x=e[15];let p;e[16]!==f||e[17]!==m||e[18]!==h||e[19]!==x?(p=s.jsxs(Ae,{className:"flex flex-col gap-3",children:[f,m,h,x]}),e[16]=f,e[17]=m,e[18]=h,e[19]=x,e[20]=p):p=e[20];let g;return e[21]!==u||e[22]!==p?(g=s.jsxs(ke,{children:[u,p]}),e[21]=u,e[22]=p,e[23]=g):g=e[23],g}function jt(n){return n===1?"1 session":`${n} sessions`}function rl(n){const e=A.c(54),{project:t,path:l,name:r,assignees:a,onAssigned:i}=n,o=_.useId(),{busy:c,error:d,run:u}=ge();let f;e[0]!==t.dirName?(f=Vs(Ys(t.dirName)),e[0]=t.dirName,e[1]=f):f=e[1];const m=f;let h;e[2]!==r||e[3]!==i||e[4]!==t.dirName||e[5]!==u?(h=async function(I){const G=await u(()=>Jn({userId:I.id,dirName:t.dirName}));G&&(he.success(`Assigned ${jt(G.assigned)} in ${r} to ${I.displayName}`),qe(),i())},e[2]=r,e[3]=i,e[4]=t.dirName,e[5]=u,e[6]=h):h=e[6];const x=h;let p;e[7]!==r||e[8]!==o?(p=s.jsx("span",{id:o,className:"truncate font-medium text-foreground",children:r}),e[7]=r,e[8]=o,e[9]=p):p=e[9];let g;e[10]!==m?(g=m&&s.jsx(ne,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:m}),e[10]=m,e[11]=g):g=e[11];let j;e[12]!==p||e[13]!==g?(j=s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p,g]}),e[12]=p,e[13]=g,e[14]=j):j=e[14];let b;e[15]!==l?(b=s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:l}),e[15]=l,e[16]=b):b=e[16];let S;e[17]!==t.sessionCount?(S=jt(t.sessionCount),e[17]=t.sessionCount,e[18]=S):S=e[18];let w;e[19]!==t.lastActivityAt?(w=Ws(new Date(t.lastActivityAt).toISOString()),e[19]=t.lastActivityAt,e[20]=w):w=e[20];let y;e[21]!==S||e[22]!==w?(y=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[S," · last active ",w]}),e[21]=S,e[22]=w,e[23]=y):y=e[23];let N;e[24]!==j||e[25]!==b||e[26]!==y?(N=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[j,b,y]}),e[24]=j,e[25]=b,e[26]=y,e[27]=N):N=e[27];const v=c||a.length===0;let C;e[28]!==o||e[29]!==v?(C=s.jsx(F,{variant:"outline",size:"sm",disabled:v,"aria-describedby":o}),e[28]=o,e[29]=v,e[30]=C):C=e[30];let $;e[31]!==c?($=c&&s.jsx(Yt,{"data-icon":"inline-start",className:"animate-spin"}),e[31]=c,e[32]=$):$=e[32];let k;e[33]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(wn,{"data-icon":"inline-end"}),e[33]=k):k=e[33];let T;e[34]!==C||e[35]!==$?(T=s.jsxs(Je,{render:C,children:[$,"Assign to…",k]}),e[34]=C,e[35]=$,e[36]=T):T=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(ae,{children:"Owner for every unassigned session"}),e[37]=U):U=e[37];let O;if(e[38]!==x||e[39]!==a){let R;e[41]!==x?(R=I=>s.jsxs(Q,{onClick:()=>void x(I),children:[s.jsx("span",{className:"truncate",children:I.displayName}),s.jsxs("span",{className:"ml-auto truncate text-xs text-muted-foreground",children:["@",I.username]})]},I.id),e[41]=x,e[42]=R):R=e[42],O=a.map(R),e[38]=x,e[39]=a,e[40]=O}else O=e[40];let D;e[43]!==O?(D=s.jsx(Xe,{align:"end",className:"w-56",children:s.jsxs(Z,{children:[U,O]})}),e[43]=O,e[44]=D):D=e[44];let E;e[45]!==T||e[46]!==D?(E=s.jsxs(Qe,{children:[T,D]}),e[45]=T,e[46]=D,e[47]=E):E=e[47];let P;e[48]!==d?(P=d&&s.jsx(Ze,{className:"w-full",children:d}),e[48]=d,e[49]=P):P=e[49];let L;return e[50]!==N||e[51]!==E||e[52]!==P?(L=s.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 py-2.5",children:[N,E,P]}),e[50]=N,e[51]=E,e[52]=P,e[53]=L):L=e[53],L}function il(n){var j;const e=A.c(24),{users:t}=n,l=ce("/api/team/unassigned");let r;e[0]!==t?(r=t.filter(cl),e[0]=t,e[1]=r):r=e[1];const a=r,i=(j=l.data)==null?void 0:j.projects,o=Gs(!0);let c;e[2]!==o?(c=new Map(o.map(ol)),e[2]=o,e[3]=c):c=e[3];const d=c,{names:u}=zs();let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsxs($e,{children:[s.jsx(_e,{children:"Unassigned sessions"}),s.jsx(et,{children:"Only admins can see sessions without an owner. Assign each project to the person who works in it."})]}),e[4]=f):f=e[4];let m;e[5]!==l.error||e[6]!==l.refresh?(m=l.error&&s.jsx(fe,{title:"Unassigned sessions could not load",message:l.error,onRetry:l.refresh}),e[5]=l.error,e[6]=l.refresh,e[7]=m):m=e[7];let h;e[8]!==i?(h=i&&i.length===0&&s.jsx(Ee,{className:"py-6",children:s.jsxs(De,{children:[s.jsx(Ke,{variant:"icon",children:s.jsx(bn,{})}),s.jsx(Te,{children:"Every session has an owner."}),s.jsx(Pe,{children:"New sessions belong to whoever starts them."})]})}),e[8]=i,e[9]=h):h=e[9];let x;e[10]!==a||e[11]!==d||e[12]!==u||e[13]!==i||e[14]!==l.refresh?(x=i&&i.length>0&&s.jsx("ul",{className:"divide-y",children:i.map(b=>{const S=d.get(b.dirName)??Bs(b.dirName);return s.jsx(rl,{project:b,path:S,name:u[b.dirName]??Hs(S),assignees:a,onAssigned:l.refresh},b.dirName)})}),e[10]=a,e[11]=d,e[12]=u,e[13]=i,e[14]=l.refresh,e[15]=x):x=e[15];let p;e[16]!==i||e[17]!==l.loading?(p=!i&&l.loading&&s.jsx(ot,{label:"Loading unassigned sessions…"}),e[16]=i,e[17]=l.loading,e[18]=p):p=e[18];let g;return e[19]!==m||e[20]!==h||e[21]!==x||e[22]!==p?(g=s.jsxs(ke,{children:[f,s.jsxs(Ae,{className:"flex flex-col gap-3",children:[m,h,x,p]})]}),e[19]=m,e[20]=h,e[21]=x,e[22]=p,e[23]=g):g=e[23],g}function ol(n){return[n.dirName,n.path]}function cl(n){return!n.disabled}function ns({username:n,displayName:e,password:t}){return{username:n.trim(),password:t,...e.trim()?{displayName:e.trim()}:{}}}function ls(n){const e=A.c(14),{id:t,value:l,onChange:r,autoComplete:a,autoFocus:i}=n;let o;e[0]!==t?(o=s.jsx(J,{htmlFor:t,children:"Username"}),e[0]=t,e[1]=o):o=e[1];let c;e[2]!==r?(c=m=>r(m.target.value),e[2]=r,e[3]=c):c=e[3];let d;e[4]!==a||e[5]!==i||e[6]!==t||e[7]!==c||e[8]!==l?(d=s.jsx(de,{id:t,type:"text",value:l,onChange:c,placeholder:"Username",autoComplete:a,autoFocus:i,spellCheck:!1}),e[4]=a,e[5]=i,e[6]=t,e[7]=c,e[8]=l,e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(tt,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."}),e[10]=u):u=e[10];let f;return e[11]!==o||e[12]!==d?(f=s.jsxs(X,{children:[o,d,u]}),e[11]=o,e[12]=d,e[13]=f):f=e[13],f}function as(n){const e=A.c(13),{id:t,value:l,onChange:r,autoComplete:a}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"}),e[0]=i):i=e[0];let o;e[1]!==t?(o=s.jsxs(J,{htmlFor:t,children:["Display name ",i]}),e[1]=t,e[2]=o):o=e[2];let c;e[3]!==r?(c=f=>r(f.target.value),e[3]=r,e[4]=c):c=e[4];let d;e[5]!==a||e[6]!==t||e[7]!==c||e[8]!==l?(d=s.jsx(de,{id:t,type:"text",value:l,onChange:c,placeholder:"Display name (optional)",autoComplete:a}),e[5]=a,e[6]=t,e[7]=c,e[8]=l,e[9]=d):d=e[9];let u;return e[10]!==o||e[11]!==d?(u=s.jsxs(X,{children:[o,d]}),e[10]=o,e[11]=d,e[12]=u):u=e[12],u}function ct(n){const e=A.c(28),{id:t,label:l,placeholder:r,value:a,onChange:i,visible:o,onVisibleChange:c,autoFocus:d}=n;let u;e[0]!==t||e[1]!==l?(u=s.jsx(J,{htmlFor:t,children:l}),e[0]=t,e[1]=l,e[2]=u):u=e[2];const f=o?"text":"password";let m;e[3]!==i?(m=y=>i(y.target.value),e[3]=i,e[4]=m):m=e[4];let h;e[5]!==d||e[6]!==t||e[7]!==r||e[8]!==f||e[9]!==m||e[10]!==a?(h=s.jsx(Ks,{id:t,type:f,value:a,onChange:m,placeholder:r,autoComplete:"new-password",autoFocus:d}),e[5]=d,e[6]=t,e[7]=r,e[8]=f,e[9]=m,e[10]=a,e[11]=h):h=e[11];let x;e[12]!==c||e[13]!==o?(x=()=>c(!o),e[12]=c,e[13]=o,e[14]=x):x=e[14];const p=o?"Hide password":"Show password";let g;e[15]!==o?(g=o?s.jsx(yn,{}):s.jsx(Sn,{}),e[15]=o,e[16]=g):g=e[16];let j;e[17]!==x||e[18]!==p||e[19]!==g?(j=s.jsx(qs,{align:"inline-end",children:s.jsx(Js,{size:"icon-xs",onClick:x,"aria-label":p,children:g})}),e[17]=x,e[18]=p,e[19]=g,e[20]=j):j=e[20];let b;e[21]!==h||e[22]!==j?(b=s.jsxs(Xs,{children:[h,j]}),e[21]=h,e[22]=j,e[23]=b):b=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsxs(tt,{children:["Use at least ",ue," characters."]}),e[24]=S):S=e[24];let w;return e[25]!==u||e[26]!==b?(w=s.jsxs(X,{children:[u,b,S]}),e[25]=u,e[26]=b,e[27]=w):w=e[27],w}const dl=["member","admin"],ul=["member"];function fl(n){const e=A.c(10),{open:t,onOpenChange:l,onCreated:r,noNewAdmins:a}=n;let i;e[0]!==r||e[1]!==l?(i=()=>{l(!1),r()},e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;e[3]!==a||e[4]!==i?(o=s.jsx($t,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md",children:s.jsx(ml,{noNewAdmins:a,onCreated:i})}),e[3]=a,e[4]=i,e[5]=o):o=e[5];let c;return e[6]!==l||e[7]!==t||e[8]!==o?(c=s.jsx(At,{open:t,onOpenChange:l,children:o}),e[6]=l,e[7]=t,e[8]=o,e[9]=c):c=e[9],c}function ml(n){const e=A.c(59),{onCreated:t,noNewAdmins:l}=n,r=_.useId(),a=l?ul:dl,[i,o]=_.useState(""),[c,d]=_.useState(""),[u,f]=_.useState("member"),[m,h]=_.useState(""),[x,p]=_.useState(!1),{busy:g,error:j,run:b}=ge();let S;e[0]!==m||e[1]!==i?(S=!i.trim()||m.length<ue,e[0]=m,e[1]=i,e[2]=S):S=e[2];const w=S;let y;if(e[3]!==c||e[4]!==w||e[5]!==t||e[6]!==m||e[7]!==u||e[8]!==b||e[9]!==i){const Le=async function(Ie){if(Ie.preventDefault(),w)return;const xt=await b(()=>qn({...ns({username:i,displayName:c,password:m}),role:u}));xt&&(he.success(`Added ${xt.user.displayName}`),t())};y=oe=>void Le(oe),e[3]=c,e[4]=w,e[5]=t,e[6]=m,e[7]=u,e[8]=b,e[9]=i,e[10]=y}else y=e[10];let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsxs(kt,{children:[s.jsx(Et,{children:"Add user"}),s.jsx(Dt,{children:"They sign in with this username and password. Their prompts are recorded and visible to admins."})]}),e[11]=N):N=e[11];const v=`${r}-username`;let C;e[12]!==v||e[13]!==i?(C=s.jsx(ls,{id:v,value:i,onChange:o,autoComplete:"off",autoFocus:!0}),e[12]=v,e[13]=i,e[14]=C):C=e[14];const $=`${r}-display-name`;let k;e[15]!==c||e[16]!==$?(k=s.jsx(as,{id:$,value:c,onChange:d,autoComplete:"off"}),e[15]=c,e[16]=$,e[17]=k):k=e[17];const T=`${r}-role`;let U;e[18]!==T?(U=s.jsx(J,{id:T,children:"Role"}),e[18]=T,e[19]=U):U=e[19];let O;e[20]!==u?(O=[u],e[20]=u,e[21]=O):O=e[21];let D;e[22]!==a?(D=Le=>{const oe=a.find(Ie=>Ie===Le.at(-1));oe&&f(oe)},e[22]=a,e[23]=D):D=e[23];const E=`${r}-role`;let P;e[24]!==a?(P=a.map(hl),e[24]=a,e[25]=P):P=e[25];let L;e[26]!==O||e[27]!==D||e[28]!==E||e[29]!==P?(L=s.jsx(st,{value:O,onValueChange:D,variant:"outline",size:"sm",spacing:0,"aria-labelledby":E,children:P}),e[26]=O,e[27]=D,e[28]=E,e[29]=P,e[30]=L):L=e[30];let R;e[31]!==l?(R=l&&s.jsx(tt,{children:Qt}),e[31]=l,e[32]=R):R=e[32];let I;e[33]!==L||e[34]!==R||e[35]!==U?(I=s.jsxs(X,{children:[U,L,R]}),e[33]=L,e[34]=R,e[35]=U,e[36]=I):I=e[36];const G=`${r}-password`;let H;e[37]!==m||e[38]!==x||e[39]!==G?(H=s.jsx(ct,{id:G,label:"Password",placeholder:"Password",value:m,onChange:h,visible:x,onVisibleChange:p}),e[37]=m,e[38]=x,e[39]=G,e[40]=H):H=e[40];let z;e[41]!==I||e[42]!==H||e[43]!==C||e[44]!==k?(z=s.jsxs(Tt,{children:[C,k,I,H]}),e[41]=I,e[42]=H,e[43]=C,e[44]=k,e[45]=z):z=e[45];let B;e[46]!==j?(B=j&&s.jsxs(ee,{variant:"destructive",children:[s.jsx(lt,{}),s.jsx(te,{children:j})]}),e[46]=j,e[47]=B):B=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Qs,{render:s.jsx(F,{type:"button",variant:"outline"}),children:"Cancel"}),e[48]=M):M=e[48];const ie=g||w;let Y;e[49]!==g?(Y=g&&s.jsx(Yt,{"data-icon":"inline-start",className:"animate-spin"}),e[49]=g,e[50]=Y):Y=e[50];let W;e[51]!==ie||e[52]!==Y?(W=s.jsxs(Zs,{children:[M,s.jsxs(F,{type:"submit",disabled:ie,children:[Y,"Add user"]})]}),e[51]=ie,e[52]=Y,e[53]=W):W=e[53];let je;return e[54]!==z||e[55]!==y||e[56]!==B||e[57]!==W?(je=s.jsxs("form",{onSubmit:y,className:"flex flex-col gap-4",children:[N,z,B,W]}),e[54]=z,e[55]=y,e[56]=B,e[57]=W,e[58]=je):je=e[58],je}function hl(n){return s.jsx(Oe,{value:n,children:it[n]},n)}const dt={"7d":{label:"7 days",days:7},"30d":{label:"30 days",days:30}},rs="30d",xl={too_long:`Choose a range of ${Me} days or less.`,too_old:`Usage is kept for the last ${Me} days only.`};function pl(n){return n==="custom"||typeof n=="string"&&Object.hasOwn(dt,n)}function is(n,e){return Zt(dt[n].days,e)}function gl(n,e,t){const l=Gn(n),r=zn(e);if(l===null||r===null)return{ok:!1,error:"Enter a start and an end date."};if(l>t)return{ok:!1,error:"The range cannot start in the future."};const a={from:l,to:Math.min(r,t)};if(a.from>a.to)return{ok:!1,error:"The start date must be on or before the end date."};const i=In(a,t);return i?{ok:!1,error:xl[i]}:{ok:!0,range:a}}function jl({from:n,to:e}){return`${K(n)} – ${K(e)}`}function bl(n){const e=A.c(29),{range:t,onRangeChange:l}=n,r=_.useId(),[a,i]=_.useState(rs);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={from:"",to:""},e[0]=o):o=e[0];const[c,d]=_.useState(o),[u,f]=_.useState(null),[m]=_.useState(yl);let h;e[1]!==l||e[2]!==t?(h=function(k){i(k),f(null),k==="custom"?d({from:Ge(t.from),to:Ge(t.to)}):l(is(k,Date.now()))},e[1]=l,e[2]=t,e[3]=h):h=e[3];const x=h;let p;e[4]!==l?(p=function(k){d(k);const T=gl(k.from,k.to,Date.now());f(T.ok?null:T.error),T.ok&&l(T.range)},e[4]=l,e[5]=p):p=e[5];const g=p;let j;e[6]!==a?(j=[a],e[6]=a,e[7]=j):j=e[7];let b;e[8]!==a||e[9]!==x?(b=$=>{const k=$.at(-1);pl(k)&&k!==a&&x(k)},e[8]=a,e[9]=x,e[10]=b):b=e[10];let S,w;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=Object.entries(dt).map(wl),w=s.jsx(Oe,{value:"custom",children:"Custom"}),e[11]=S,e[12]=w):(S=e[11],w=e[12]);let y;e[13]!==j||e[14]!==b?(y=s.jsxs(st,{value:j,onValueChange:b,variant:"outline",size:"sm",spacing:0,"aria-label":"Usage range",children:[S,w]}),e[13]=j,e[14]=b,e[15]=y):y=e[15];let N;e[16]!==a||e[17]!==c||e[18]!==g||e[19]!==u||e[20]!==r||e[21]!==m?(N=a==="custom"&&s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[s.jsxs(X,{className:"w-40",children:[s.jsx(J,{htmlFor:`${r}-from`,children:"From"}),s.jsx(de,{id:`${r}-from`,type:"date",value:c.from,max:m,"aria-invalid":u!==null,onChange:$=>g({...c,from:$.target.value})})]}),s.jsxs(X,{className:"w-40",children:[s.jsx(J,{htmlFor:`${r}-to`,children:"To"}),s.jsx(de,{id:`${r}-to`,type:"date",value:c.to,max:m,"aria-invalid":u!==null,onChange:$=>g({...c,to:$.target.value})})]})]}),e[16]=a,e[17]=c,e[18]=g,e[19]=u,e[20]=r,e[21]=m,e[22]=N):N=e[22];let v;e[23]!==u?(v=u&&s.jsx(Ze,{children:u}),e[23]=u,e[24]=v):v=e[24];let C;return e[25]!==v||e[26]!==y||e[27]!==N?(C=s.jsxs("div",{className:"flex flex-col gap-2",children:[y,N,v]}),e[25]=v,e[26]=y,e[27]=N,e[28]=C):C=e[28],C}function wl(n){const[e,t]=n;return s.jsx(Oe,{value:e,children:t.label},e)}function yl(){return Ge(Date.now())}const be="text-right tabular-nums",we="—";function Sl(n){const e=A.c(3),{usd:t}=n;if(t===null){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx("span",{title:Ce.title,children:Ce.text}),e[0]=r):r=e[0],r}let l;return e[1]!==t?(l=t===0?"$0":Ot(t),e[1]=t,e[2]=l):l=e[2],l}function os(n){const e=A.c(17),{figures:t}=n,l=(t==null?void 0:t.sessions)??we;let r;e[0]!==l?(r=s.jsx(V,{className:be,children:l}),e[0]=l,e[1]=r):r=e[1];const a=(t==null?void 0:t.prompts)??we;let i;e[2]!==a?(i=s.jsx(V,{className:be,children:a}),e[2]=a,e[3]=i):i=e[3];let o;e[4]!==t?(o=t?Pt(es(t.tokens)):we,e[4]=t,e[5]=o):o=e[5];let c;e[6]!==o?(c=s.jsx(V,{className:be,children:o}),e[6]=o,e[7]=c):c=e[7];let d;e[8]!==t?(d=t?s.jsx(Sl,{usd:t.costUsd}):we,e[8]=t,e[9]=d):d=e[9];let u;e[10]!==d?(u=s.jsx(V,{className:be,children:d}),e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==r||e[13]!==i||e[14]!==c||e[15]!==u?(f=s.jsxs(s.Fragment,{children:[r,i,c,u]}),e[12]=r,e[13]=i,e[14]=c,e[15]=u,e[16]=f):f=e[16],f}const Nl=8,vl={tokens:{input:0,output:0,cacheRead:0,cacheWrite:0},costUsd:0,sessions:0,prompts:0};function Cl(n,e){return e?Ue()?"This hub signs in to the device as you, so the change signs the hub out there too. Afterwards, update the password this hub saved for the device in Devices.":"You are signed out everywhere, this browser included, and sign in again with the new password.":`${n.displayName} is signed out everywhere and signs in with the new password.`}function _l(n){const e=A.c(29),{user:t,isSelf:l,onDone:r}=n,a=_.useId(),[i,o]=_.useState(""),[c,d]=_.useState(!1),{busy:u,error:f,setError:m,run:h}=ge();let x;e[0]!==l||e[1]!==r||e[2]!==i||e[3]!==h||e[4]!==m||e[5]!==t?(x=async function(){if(i.length<ue){m(`Use at least ${ue} characters.`);return}await h(()=>ss(t.id,{password:i}))&&(he.success(l?"Password changed":`Password reset for ${t.displayName}`),r())},e[0]=l,e[1]=r,e[2]=i,e[3]=h,e[4]=m,e[5]=t,e[6]=x):x=e[6];const p=x,g=l?"Change password":"Reset password";let j;e[7]!==p?(j=()=>void p(),e[7]=p,e[8]=j):j=e[8];const b=`${a}-password`,S=l?"Your new password":`New password for ${t.displayName}`;let w;e[9]!==i||e[10]!==b||e[11]!==S||e[12]!==c?(w=s.jsx(ct,{id:b,label:S,placeholder:"New password",value:i,onChange:o,visible:c,onVisibleChange:d,autoFocus:!0}),e[9]=i,e[10]=b,e[11]=S,e[12]=c,e[13]=w):w=e[13];let y;e[14]!==l||e[15]!==t?(y=Cl(t,l),e[14]=l,e[15]=t,e[16]=y):y=e[16];let N;e[17]!==y?(N=s.jsx("p",{className:"text-xs text-muted-foreground",children:y}),e[17]=y,e[18]=N):N=e[18];let v;e[19]!==w||e[20]!==N?(v=s.jsxs("div",{className:"flex max-w-md flex-col gap-2",children:[w,N]}),e[19]=w,e[20]=N,e[21]=v):v=e[21];let C;return e[22]!==u||e[23]!==f||e[24]!==r||e[25]!==g||e[26]!==j||e[27]!==v?(C=s.jsx(_t,{error:f,busy:u,saveLabel:g,onCancel:r,onSave:j,className:"border-t-0 bg-muted/40",children:v}),e[22]=u,e[23]=f,e[24]=r,e[25]=g,e[26]=j,e[27]=v,e[28]=C):C=e[28],C}function $l(n){const e=A.c(33),{user:t,isSelf:l,noNewAdmins:r,onSelect:a}=n,i=r&&t.role==="member"&&!t.disabled,o=r&&t.role==="admin"&&t.disabled===!0;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(ae,{className:"font-normal",children:Qt}),e[0]=c):c=e[0];const d=c,u=`Actions for ${t.displayName}`;let f;e[1]!==u?(f=s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":u}),e[1]=u,e[2]=f):f=e[2];let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Cn,{}),e[3]=m):m=e[3];let h;e[4]!==f?(h=s.jsx(Je,{render:f,children:m}),e[4]=f,e[5]=h):h=e[5];const x=l||i||o?"w-56":"w-44";let p;e[6]!==a?(p=()=>a("password"),e[6]=a,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(at,{}),e[8]=g):g=e[8];const j=l?"Change password":"Reset password";let b;e[9]!==p||e[10]!==j?(b=s.jsxs(Q,{onClick:p,children:[g,j]}),e[9]=p,e[10]=j,e[11]=b):b=e[11];let S;e[12]!==l||e[13]!==a||e[14]!==i||e[15]!==t.role?(S=l?null:i?d:s.jsxs(Q,{onClick:()=>a("role"),children:[s.jsx(Vt,{}),t.role==="admin"?"Make member":"Make admin"]}),e[12]=l,e[13]=a,e[14]=i,e[15]=t.role,e[16]=S):S=e[16];let w;e[17]!==b||e[18]!==S?(w=s.jsxs(Z,{children:[b,S]}),e[17]=b,e[18]=S,e[19]=w):w=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Se,{}),e[20]=y):y=e[20];let N;e[21]!==o||e[22]!==l||e[23]!==a||e[24]!==t.disabled?(N=s.jsx(Z,{children:l?s.jsx(ae,{className:"font-normal",children:"Ask another admin to change your role or disable your account."}):o?d:t.disabled?s.jsxs(Q,{onClick:()=>a("status"),children:[s.jsx(Nn,{}),"Enable"]}):s.jsxs(Q,{variant:"destructive",onClick:()=>a("status"),children:[s.jsx(vn,{}),"Disable"]})}),e[21]=o,e[22]=l,e[23]=a,e[24]=t.disabled,e[25]=N):N=e[25];let v;e[26]!==w||e[27]!==N||e[28]!==x?(v=s.jsxs(Xe,{align:"end",className:x,children:[w,y,N]}),e[26]=w,e[27]=N,e[28]=x,e[29]=v):v=e[29];let C;return e[30]!==v||e[31]!==h?(C=s.jsxs(Qe,{children:[h,v]}),e[30]=v,e[31]=h,e[32]=C):C=e[32],C}function Al(n){const e=A.c(61),{user:t,usage:l,isSelf:r,noNewAdmins:a,onChanged:i}=n,[o,c]=_.useState(null),d=t.displayName;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=function(Y){Y||c(null)},e[0]=u):u=e[0];const f=u;let m;e[1]!==i||e[2]!==t.id?(m=async function(Y){const W=await ss(t.id,Y);return W.ok?(c(null),i(),null):W.error},e[1]=i,e[2]=t.id,e[3]=m):m=e[3];const h=m;let x;e[4]!==d?(x=s.jsx("span",{className:"truncate",children:d}),e[4]=d,e[5]=x):x=e[5];let p;e[6]!==r?(p=r&&s.jsx(ne,{variant:"outline",children:"You"}),e[6]=r,e[7]=p):p=e[7];let g;e[8]!==x||e[9]!==p?(g=s.jsxs("span",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[x,p]}),e[8]=x,e[9]=p,e[10]=g):g=e[10];let j;e[11]!==t.username?(j=s.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",t.username]}),e[11]=t.username,e[12]=j):j=e[12];let b;e[13]!==g||e[14]!==j?(b=s.jsx(V,{children:s.jsxs("div",{className:"flex min-w-0 flex-col",children:[g,j]})}),e[13]=g,e[14]=j,e[15]=b):b=e[15];const S=t.role==="admin"?"secondary":"outline",w=it[t.role];let y;e[16]!==S||e[17]!==w?(y=s.jsx(V,{children:s.jsx(ne,{variant:S,children:w})}),e[16]=S,e[17]=w,e[18]=y):y=e[18];let N;e[19]!==t.disabled?(N=s.jsx(V,{children:t.disabled?s.jsx(ne,{variant:"destructive",children:"Disabled"}):s.jsx("span",{className:"text-muted-foreground",children:"Active"})}),e[19]=t.disabled,e[20]=N):N=e[20];let v;e[21]!==l?(v=s.jsx(os,{figures:l}),e[21]=l,e[22]=v):v=e[22];let C;e[23]!==r||e[24]!==a||e[25]!==t?(C=s.jsx(V,{className:"text-right",children:s.jsx($l,{user:t,isSelf:r,noNewAdmins:a,onSelect:c})}),e[23]=r,e[24]=a,e[25]=t,e[26]=C):C=e[26];let $;e[27]!==y||e[28]!==N||e[29]!==v||e[30]!==C||e[31]!==b?($=s.jsxs(ve,{children:[b,y,N,v,C]}),e[27]=y,e[28]=N,e[29]=v,e[30]=C,e[31]=b,e[32]=$):$=e[32];let k;e[33]!==o||e[34]!==r||e[35]!==t?(k=o==="password"&&s.jsx(ve,{className:"hover:bg-transparent",children:s.jsx(V,{colSpan:Nl,className:"p-0 whitespace-normal",children:s.jsx(_l,{user:t,isSelf:r,onDone:()=>c(null)})})}),e[33]=o,e[34]=r,e[35]=t,e[36]=k):k=e[36];const T=o==="role",U=t.role==="admin"?`Make ${d} a member?`:`Make ${d} an admin?`,O=t.role==="admin"?`${d} loses access to People, the license and other members' sessions, and is signed out.`:`${d} can manage people, the license and every session, and is signed out to pick up the new role.`,D=t.role==="admin"?"Make member":"Make admin";let E;e[37]!==h||e[38]!==t.role?(E=()=>h({role:t.role==="admin"?"member":"admin"}),e[37]=h,e[38]=t.role,e[39]=E):E=e[39];let P;e[40]!==T||e[41]!==U||e[42]!==O||e[43]!==D||e[44]!==E?(P=s.jsx(pt,{open:T,onOpenChange:f,title:U,description:O,confirmLabel:D,onConfirm:E}),e[40]=T,e[41]=U,e[42]=O,e[43]=D,e[44]=E,e[45]=P):P=e[45];const L=o==="status",R=t.disabled?`Enable ${d}?`:`Disable ${d}?`,I=t.disabled?`${d} can sign in again and takes a license seat.`:`${d} is signed out now and cannot sign in until enabled again. Their sessions stay on this server.`,G=t.disabled?"Enable user":"Disable user",H=!t.disabled;let z;e[46]!==h||e[47]!==t.disabled?(z=()=>h({disabled:!t.disabled}),e[46]=h,e[47]=t.disabled,e[48]=z):z=e[48];let B;e[49]!==L||e[50]!==R||e[51]!==I||e[52]!==G||e[53]!==H||e[54]!==z?(B=s.jsx(pt,{open:L,onOpenChange:f,title:R,description:I,confirmLabel:G,destructive:H,onConfirm:z}),e[49]=L,e[50]=R,e[51]=I,e[52]=G,e[53]=H,e[54]=z,e[55]=B):B=e[55];let M;return e[56]!==$||e[57]!==k||e[58]!==P||e[59]!==B?(M=s.jsxs(s.Fragment,{children:[$,k,P,B]}),e[56]=$,e[57]=k,e[58]=P,e[59]=B,e[60]=M):M=e[60],M}function kl(n){const e=A.c(33),{users:t,usage:l,usageLoading:r,currentUserId:a,noNewAdmins:i,onUserChanged:o}=n;let c;e[0]!==(l==null?void 0:l.rows)?(c=new Map(l==null?void 0:l.rows.map(El)),e[0]=l==null?void 0:l.rows,e[1]=c):c=e[1];const d=c,u=r&&"opacity-60";let f;e[2]!==u?(f=se("transition-opacity",u),e[2]=u,e[3]=f):f=e[3];let m,h,x,p,g,j,b;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(q,{children:"User"}),x=s.jsx(q,{children:"Role"}),p=s.jsx(q,{children:"Status"}),g=s.jsx(q,{className:"text-right",children:"Sessions"}),j=s.jsx(q,{className:"text-right",children:"Prompts"}),b=s.jsx(q,{className:"text-right",children:"Tokens"}),m=s.jsx(q,{className:"text-right",children:"Est. cost"}),e[4]=m,e[5]=h,e[6]=x,e[7]=p,e[8]=g,e[9]=j,e[10]=b):(m=e[4],h=e[5],x=e[6],p=e[7],g=e[8],j=e[9],b=e[10]);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(en,{children:s.jsxs(ve,{className:"hover:bg-transparent",children:[h,x,p,g,j,b,m,s.jsx(q,{children:s.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e[11]=S):S=e[11];let w;if(e[12]!==a||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==d||e[17]!==t){let C;e[19]!==a||e[20]!==i||e[21]!==o||e[22]!==l||e[23]!==d?(C=$=>s.jsx(Al,{user:$,usage:l?d.get($.id)??vl:null,isSelf:$.id===a,noNewAdmins:i,onChanged:o},$.id),e[19]=a,e[20]=i,e[21]=o,e[22]=l,e[23]=d,e[24]=C):C=e[24],w=t.map(C),e[12]=a,e[13]=i,e[14]=o,e[15]=l,e[16]=d,e[17]=t,e[18]=w}else w=e[18];let y;e[25]!==l?(y=(l==null?void 0:l.unattributed)&&s.jsxs(ve,{className:"text-muted-foreground",children:[s.jsx(V,{children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"font-medium",children:"Unattributed"}),s.jsx("span",{className:"text-xs",children:"Not tied to a recorded prompt"})]})}),s.jsx(V,{}),s.jsx(V,{}),s.jsx(os,{figures:l.unattributed}),s.jsx(V,{})]}),e[25]=l,e[26]=y):y=e[26];let N;e[27]!==w||e[28]!==y?(N=s.jsxs(tn,{children:[w,y]}),e[27]=w,e[28]=y,e[29]=N):N=e[29];let v;return e[30]!==N||e[31]!==f?(v=s.jsxs(sn,{className:f,children:[S,N]}),e[30]=N,e[31]=f,e[32]=v):v=e[32],v}function El(n){return[n.user.id,n]}function Dl(n){const e=A.c(37),{users:t,onUsersChanged:l,noNewAdmins:r}=n,[a,i]=_.useState(Tl),o=Jt(a),[c,d]=_.useState(!1),{user:u}=xe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_e,{children:"Users"}),e[0]=f):f=e[0];let m;e[1]!==a?(m=jl(a),e[1]=a,e[2]=m):m=e[2];let h;e[3]!==m?(h=s.jsxs(et,{children:["Usage ",m,", estimated at API prices."]}),e[3]=m,e[4]=h):h=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Ct,{children:s.jsxs(F,{size:"sm",onClick:()=>d(!0),children:[s.jsx(_n,{"data-icon":"inline-start"}),"Add user"]})}),e[5]=x):x=e[5];let p;e[6]!==h?(p=s.jsxs($e,{children:[f,h,x]}),e[6]=h,e[7]=p):p=e[7];let g;e[8]!==a?(g=s.jsx(bl,{range:a,onRangeChange:i}),e[8]=a,e[9]=g):g=e[9];let j;e[10]!==t.error||e[11]!==t.refresh?(j=t.error&&s.jsx(fe,{title:"Users could not load",message:t.error,onRetry:t.refresh}),e[10]=t.error,e[11]=t.refresh,e[12]=j):j=e[12];let b;e[13]!==o.error||e[14]!==o.refresh?(b=o.error&&s.jsx(fe,{title:"Usage could not load",message:o.error,onRetry:o.refresh}),e[13]=o.error,e[14]=o.refresh,e[15]=b):b=e[15];let S;e[16]!==(u==null?void 0:u.id)||e[17]!==r||e[18]!==l||e[19]!==o.data||e[20]!==o.loading||e[21]!==t.data||e[22]!==t.loading?(S=t.data?s.jsx(kl,{users:t.data.users,usage:o.data,usageLoading:o.loading,currentUserId:(u==null?void 0:u.id)??null,noNewAdmins:r,onUserChanged:l}):t.loading&&s.jsx(ot,{label:"Loading users…"}),e[16]=u==null?void 0:u.id,e[17]=r,e[18]=l,e[19]=o.data,e[20]=o.loading,e[21]=t.data,e[22]=t.loading,e[23]=S):S=e[23];let w;e[24]!==g||e[25]!==j||e[26]!==b||e[27]!==S?(w=s.jsxs(Ae,{className:"flex flex-col gap-3",children:[g,j,b,S]}),e[24]=g,e[25]=j,e[26]=b,e[27]=S,e[28]=w):w=e[28];let y;e[29]!==c||e[30]!==r||e[31]!==l?(y=s.jsx(fl,{open:c,onOpenChange:d,onCreated:l,noNewAdmins:r}),e[29]=c,e[30]=r,e[31]=l,e[32]=y):y=e[32];let N;return e[33]!==w||e[34]!==y||e[35]!==p?(N=s.jsxs(ke,{children:[p,w,y]}),e[33]=w,e[34]=y,e[35]=p,e[36]=N):N=e[36],N}function Tl(){return is(rs,Date.now())}function cs(n){var $,k,T,U;const e=A.c(35),{onClose:t,lockout:l}=n,r=ce("/api/team/users"),a=ce("/api/team/license"),i=ce("/api/team/health"),o=l==null?void 0:l.onRestored,c=($=a.data)==null?void 0:$.state;let d,u;e[0]!==c||e[1]!==o?(d=()=>{c&&c!=="locked"&&(o==null||o())},u=[c,o],e[0]=c,e[1]=o,e[2]=d,e[3]=u):(d=e[2],u=e[3]),_.useEffect(d,u);let f;e[4]!==i||e[5]!==a?(f=function(){a.refresh(),i.refresh()},e[4]=i,e[5]=a,e[6]=f):f=e[6];const m=f;let h;e[7]!==m||e[8]!==r?(h=function(){r.refresh(),m()},e[7]=m,e[8]=r,e[9]=h):h=e[9];const x=h;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx("h2",{className:"truncate text-sm font-semibold",children:"People"}),e[10]=p):p=e[10];let g;e[11]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(Wt,{}),e[11]=g):g=e[11];let j;e[12]!==t?(j=s.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-3 border-b px-4 py-2",children:[p,s.jsx(F,{variant:"ghost",size:"icon-sm",className:"ml-auto","aria-label":"Close People",onClick:t,children:g})]}),e[12]=t,e[13]=j):j=e[13];let b;e[14]!==i.data||e[15]!==i.refresh?(b=i.data&&s.jsx(el,{health:i.data,onChanged:i.refresh}),e[14]=i.data,e[15]=i.refresh,e[16]=b):b=e[16];const S=c==="locked";let w;e[17]!==x||e[18]!==S||e[19]!==r?(w=s.jsx(Dl,{users:r,onUsersChanged:x,noNewAdmins:S}),e[17]=x,e[18]=S,e[19]=r,e[20]=w):w=e[20];let y;e[21]!==l||e[22]!==((k=r.data)==null?void 0:k.users)?(y=!l&&s.jsx(il,{users:((T=r.data)==null?void 0:T.users)??[]}),e[21]=l,e[22]=(U=r.data)==null?void 0:U.users,e[23]=y):y=e[23];let N;e[24]!==m||e[25]!==a?(N=s.jsx(al,{license:a,onInstalled:m}),e[24]=m,e[25]=a,e[26]=N):N=e[26];let v;e[27]!==w||e[28]!==y||e[29]!==N||e[30]!==b?(v=s.jsx(nn,{className:"min-h-0 flex-1",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 p-4",children:[b,w,y,N]})}),e[27]=w,e[28]=y,e[29]=N,e[30]=b,e[31]=v):v=e[31];let C;return e[32]!==v||e[33]!==j?(C=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,v]}),e[32]=v,e[33]=j,e[34]=C):C=e[34],C}const ds="people";function us(n){return n.edition==="team"&&n.user!==null&&n.can("manageUsers")}const Pl={id:ds,label:"People",icon:rt,keywords:"team users members accounts usage cost license unassigned sessions admin",isAvailable:us,openOnStart:Fn,locksSwipe:!0,Component:cs};function fs(n){const e=A.c(5),{className:t}=n;let l;e[0]!==t?(l=se("flex items-start gap-1.5 text-xs text-muted-foreground",t),e[0]=t,e[1]=l):l=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx($n,{"aria-hidden":"true",className:"mt-px size-3.5 shrink-0"}),e[2]=r):r=e[2];let a;return e[3]!==l?(a=s.jsxs("p",{className:l,children:[r,"Your prompts are recorded and visible to admins."]}),e[3]=l,e[4]=a):a=e[4],a}const ms=30;function Ol(n){const e=A.c(25),{onLogout:t,onOpenMainView:l,mobile:r,className:a}=n,i=r===void 0?!1:r,{user:o,hubUser:c}=xe();let d;e[0]!==o?(d=Ln(o)?o:null,e[0]=o,e[1]=d):d=e[1];const u=d,f=u??c;if(!f)return null;const m=i?"icon-lg":"icon-sm",h=`Account: ${f.displayName}`;let x;e[2]!==a?(x=se("rounded-full",a),e[2]=a,e[3]=x):x=e[3];let p;e[4]!==m||e[5]!==h||e[6]!==x?(p=s.jsx(F,{variant:"ghost",size:m,"aria-label":h,className:x}),e[4]=m,e[5]=h,e[6]=x,e[7]=p):p=e[7];let g;e[8]!==f?(g=Ml(f),e[8]=f,e[9]=g):g=e[9];let j;e[10]!==g?(j=s.jsx("span",{"aria-hidden":"true",className:"flex size-6 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-foreground",children:g}),e[10]=g,e[11]=j):j=e[11];let b;e[12]!==p||e[13]!==j?(b=s.jsx(Je,{render:p,children:j}),e[12]=p,e[13]=j,e[14]=b):b=e[14];let S;e[15]!==f||e[16]!==c||e[17]!==i||e[18]!==t||e[19]!==l||e[20]!==u?(S=s.jsx(Xe,{align:"end",sideOffset:6,className:"w-72",children:u?s.jsx(Ul,{user:u,hubUser:c,onLogout:t,onOpenMainView:l,mobile:i}):s.jsx(hs,{hubUser:f,onLogout:t,mobile:i})}),e[15]=f,e[16]=c,e[17]=i,e[18]=t,e[19]=l,e[20]=u,e[21]=S):S=e[21];let w;return e[22]!==S||e[23]!==b?(w=s.jsxs(Qe,{children:[b,S]}),e[22]=S,e[23]=b,e[24]=w):w=e[24],w}function Ul(n){const e=A.c(31),{user:t,hubUser:l,onLogout:r,onOpenMainView:a,mobile:i}=n,[o]=_.useState(Rl),c=Jt(o).data,d=ln();let u;e[0]!==d?(u=us(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=Ue(),e[2]=m):m=e[2];const h=m;let x;e[3]!==t.displayName?(x=s.jsx("span",{className:"truncate text-sm text-foreground",children:t.displayName}),e[3]=t.displayName,e[4]=x):x=e[4];const p=it[t.role];let g;e[5]!==p||e[6]!==t.username?(g=s.jsxs("span",{className:"truncate font-normal",children:["@",t.username," · ",p]}),e[5]=p,e[6]=t.username,e[7]=g):g=e[7];let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=h&&s.jsx(Ll,{}),e[8]=j):j=e[8];let b;e[9]!==x||e[10]!==g?(b=s.jsx(Z,{children:s.jsxs(ae,{className:"flex flex-col gap-0.5",children:[x,g,j]})}),e[9]=x,e[10]=g,e[11]=b):b=e[11];let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Se,{}),e[12]=S):S=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsxs(ae,{children:["My usage · ",ms," days"]}),e[13]=w):w=e[13];let y;e[14]!==c||e[15]!==t.id?(y=s.jsxs(Z,{children:[w,s.jsx(Il,{usage:c,userId:t.id})]}),e[14]=c,e[15]=t.id,e[16]=y):y=e[16];let N;e[17]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(fs,{className:"px-1.5 pt-1 pb-1.5"}),e[17]=N):N=e[17];let v;e[18]!==i||e[19]!==a||e[20]!==f?(v=f&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{}),s.jsx(Z,{children:s.jsxs(Q,{onClick:()=>a(ds),className:se(i&&"min-h-10"),children:[s.jsx(rt,{}),"People"]})})]}),e[18]=i,e[19]=a,e[20]=f,e[21]=v):v=e[21];let C;e[22]!==l||e[23]!==i||e[24]!==r?(C=l&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{}),s.jsx(hs,{hubUser:l,onLogout:r,mobile:i})]}),e[22]=l,e[23]=i,e[24]=r,e[25]=C):C=e[25];let $;return e[26]!==y||e[27]!==v||e[28]!==C||e[29]!==b?($=s.jsxs(s.Fragment,{children:[b,S,y,N,v,C]}),e[26]=y,e[27]=v,e[28]=C,e[29]=b,e[30]=$):$=e[30],$}function Rl(){return Zt(ms,Date.now())}function hs(n){const e=A.c(12),{hubUser:t,onLogout:l,mobile:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ue(),e[0]=a):a=e[0];const i=a;let o;e[1]!==t?(o=i&&s.jsxs(ae,{className:"font-normal",children:["Signed in to this hub as ",t.displayName]}),e[1]=t,e[2]=o):o=e[2];const c=r&&"min-h-10";let d;e[3]!==c?(d=se(c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Kt,{}),e[5]=u):u=e[5];let f;e[6]!==l||e[7]!==d?(f=s.jsxs(Q,{onClick:l,className:d,children:[u,i?"Log out of this hub":"Log out"]}),e[6]=l,e[7]=d,e[8]=f):f=e[8];let m;return e[9]!==o||e[10]!==f?(m=s.jsxs(Z,{children:[o,f]}),e[9]=o,e[10]=f,e[11]=m):m=e[11],m}function Ll(){const n=A.c(2),{activeDevice:e,activeDeviceId:t}=Ut(),l=(e==null?void 0:e.name)??t;let r;return n[0]!==l?(r=s.jsxs("span",{className:"truncate font-normal",children:["On ",l]}),n[0]=l,n[1]=r):r=n[1],r}function Il(n){const e=A.c(6),{usage:t,userId:l}=n;if(!t){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx("p",{className:"px-1.5 pb-1 text-sm text-muted-foreground",children:"—"}),e[0]=a):a=e[0],a}let r;if(e[1]!==t.rows||e[2]!==l){let a;e[4]!==l?(a=c=>c.user.id===l,e[4]=l,e[5]=a):a=e[5];const i=t.rows.find(a),o=i?i.costUsd:0;r=s.jsxs("p",{className:"flex items-baseline justify-between gap-2 px-1.5 pb-1 text-sm tabular-nums",children:[s.jsxs("span",{children:[Pt(i?es(i.tokens):0)," tokens"]}),o===null?s.jsx("span",{className:"text-muted-foreground",title:Ce.title,children:Ce.text}):s.jsxs("span",{className:"text-muted-foreground",title:"Estimated cost",children:["≈ ",Ot(o)]})]}),e[1]=t.rows,e[2]=l,e[3]=r}else r=e[3];return r}function Ml(n){const e=n.displayName.trim().split(/\s+/).filter(Boolean);return(e.length>0?e.slice(0,2).map(l=>l[0]):[n.username[0]??"?"]).join("").toUpperCase()}const bt="Until then, members cannot sign in and admins can only manage the license and accounts.",Re={expired:{title:"Your Cogpit Team license has expired",deviceTitle:n=>`${n}’s Cogpit Team license has expired`,description:`Install a new key in People. ${bt}`},over_seats:{title:"More accounts are enabled than your license has seats",deviceTitle:n=>`${n} has more accounts enabled than its license has seats`,description:`Disable accounts or install a license with more seats in People. ${bt}`}};function Fl(n){return Object.hasOwn(Re,n)}const Gl=15e3;function zl(n){const e=A.c(3);let t,l;e[0]!==n?(t=()=>{const r=new AbortController,a=setInterval(()=>{me("/api/me",{signal:r.signal}).then(Hl).then(i=>{!i||i.gate||(clearInterval(a),n())}).catch(Bl)},Gl);return()=>{clearInterval(a),r.abort()}},l=[n],e[0]=n,e[1]=t,e[2]=l):(t=e[1],l=e[2]),_.useEffect(t,l)}function Bl(){}function Hl(n){return n.ok?re(n):null}function Vl(n){const e=A.c(6),{gate:t,onRestored:l,onLogout:r}=n;if(!Fl(t)){let i;return e[0]!==n?(i=s.jsx(an,{...n}),e[0]=n,e[1]=i):i=e[1],i}let a;return e[2]!==t||e[3]!==r||e[4]!==l?(a=s.jsx(Yl,{lapse:t,onRestored:l,onLogout:r}),e[2]=t,e[3]=r,e[4]=l,e[5]=a):a=e[5],a}function Yl(n){const e=A.c(17),{lapse:t,onRestored:l,onLogout:r}=n,[a,i]=_.useState(!1);let o;e[0]!==l||e[1]!==a?(o=()=>{a&&Mn(),l()},e[0]=l,e[1]=a,e[2]=o):o=e[2];const c=o;zl(c);let d;e[3]!==a||e[4]!==c?(d={open:a,setOpen:i,onRestored:c},e[3]=a,e[4]=c,e[5]=d):d=e[5];const u=d;if(Ue()){let p;return e[6]!==t||e[7]!==u?(p=s.jsx(Wl,{lapse:t,people:u}),e[6]=t,e[7]=u,e[8]=p):p=e[8],p}const f=Re[t];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Kt,{"data-icon":"inline-start"}),e[9]=m):m=e[9];let h;e[10]!==r?(h=s.jsxs(F,{variant:"outline",size:"sm",onClick:r,children:[m,"Sign out"]}),e[10]=r,e[11]=h):h=e[11];let x;return e[12]!==t||e[13]!==u||e[14]!==f.title||e[15]!==h?(x=s.jsx(xs,{title:f.title,lapse:t,people:u,children:h}),e[12]=t,e[13]=u,e[14]=f.title,e[15]=h,e[16]=x):x=e[16],x}function Wl(n){const e=A.c(9),{lapse:t,people:l}=n,{activeDevice:r,activeDeviceId:a}=Ut(),i=Re[t];let o;e[0]!==(r==null?void 0:r.name)||e[1]!==a||e[2]!==i?(o=i.deviceTitle((r==null?void 0:r.name)??a),e[0]=r==null?void 0:r.name,e[1]=a,e[2]=i,e[3]=o):o=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsxs(F,{variant:"outline",size:"sm",onClick:Kl,children:[s.jsx(An,{"data-icon":"inline-start"}),"Switch to this machine"]}),e[4]=c):c=e[4];let d;return e[5]!==t||e[6]!==l||e[7]!==o?(d=s.jsx(xs,{title:o,lapse:t,people:l,children:c}),e[5]=t,e[6]=l,e[7]=o,e[8]=d):d=e[8],d}function Kl(){return on(cn)}function xs(n){const e=A.c(26),{title:t,lapse:l,people:r,children:a}=n,{open:i,setOpen:o,onRestored:c}=r;if(i){let S;e[0]!==o?(S=()=>o(!1),e[0]=o,e[1]=S):S=e[1];let w;e[2]!==c?(w={onRestored:c},e[2]=c,e[3]=w):w=e[3];let y;return e[4]!==S||e[5]!==w?(y=s.jsx("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:s.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:s.jsx(cs,{onClose:S,lockout:w})})}),e[4]=S,e[5]=w,e[6]=y):y=e[6],y}let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Ke,{variant:"icon",children:s.jsx(at,{className:"text-destructive"})}),e[7]=d):d=e[7];let u;e[8]!==t?(u=s.jsx(Te,{children:t}),e[8]=t,e[9]=u):u=e[9];const f=Re[l];let m;e[10]!==f.description?(m=s.jsx(Pe,{children:f.description}),e[10]=f.description,e[11]=m):m=e[11];let h;e[12]!==u||e[13]!==m?(h=s.jsxs(De,{children:[d,u,m]}),e[12]=u,e[13]=m,e[14]=h):h=e[14];let x;e[15]!==o?(x=()=>o(!0),e[15]=o,e[16]=x):x=e[16];let p;e[17]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(rt,{"data-icon":"inline-start"}),e[17]=p):p=e[17];let g;e[18]!==x?(g=s.jsxs(F,{size:"sm",onClick:x,children:[p,"Open People"]}),e[18]=x,e[19]=g):g=e[19];let j;e[20]!==a||e[21]!==g?(j=s.jsxs(rn,{className:"flex-row justify-center",children:[g,a]}),e[20]=a,e[21]=g,e[22]=j):j=e[22];let b;return e[23]!==j||e[24]!==h?(b=s.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:s.jsxs(Ee,{children:[h,j]})}),e[23]=j,e[24]=h,e[25]=b):b=e[25],b}const ps="cogpit-session-scope",ql=["all","mine","shared","unassigned"],gs=["all","mine","shared"],Jl=[...gs,"unassigned"],Xl={scope:null,options:[]},ze=new Set,Ql={all:"All",mine:"Mine",shared:"Shared",unassigned:"Unassigned"};function Zl(){try{const n=localStorage.getItem(nt(ps));return ql.find(e=>e===n)??"all"}catch{return"all"}}function js(n){try{localStorage.setItem(nt(ps),n)}catch{}for(const e of ze)e()}function bs(n){ze.add(n);const e=dn(n);return()=>{ze.delete(n),e()}}const wt=new Map;function Be(){if(un().edition!=="team")return Xl;const n=fn("viewAllSessions"),e=n?Jl:gs,t=Zl(),l=e.includes(t)?t:"all",r=`${n?"admin":"member"}:${l}`;let a=wt.get(r);return a||(a={scope:l,options:e},wt.set(r,a)),a}function ws(){return _.useSyncExternalStore(bs,Be,Be)}function ys(n){return n===null||n==="all"?null:n}const ea=Object.freeze({}),ta={mine:Object.freeze({scope:"mine"}),shared:Object.freeze({scope:"shared"}),unassigned:Object.freeze({scope:"unassigned"})};function yt(){return ys(Be().scope)}const sa={subscribe:bs,getKey:yt,getQuery(){const n=yt();return n===null?ea:ta[n]}},He=new Map;function Ss(){return nt("share-notices")}function Ns(n){for(const e of n.known)n.listed.add(e);mn(),qe()}function na(n){const e=Ss(),t=new Set(n.filter(a=>a.kind==="access").map(a=>a.id)),l=He.get(e),r={known:t,listed:(l==null?void 0:l.listed)??new Set};He.set(e,r),l&&[...t].some(a=>!l.known.has(a))&&Ns(r)}function la(){const n=He.get(Ss());n&&[...n.known].some(e=>!n.listed.has(e))&&Ns(n)}const aa={mine:{title:"You have no sessions here",description:"Sessions you start show up here."},shared:{title:"Nothing shared with you here",description:"Sessions teammates share with you show up here."},unassigned:{title:"Every session here has an owner",description:"New sessions belong to whoever starts them."}};function ra(n){const e=A.c(17),{className:t}=n,l=ws();let r;e[0]!==l.scope?(r=ys(l.scope),e[0]=l.scope,e[1]=r):r=e[1];const a=r;let i,o;if(e[2]!==a?(i=()=>{a==="shared"&&la()},o=[a],e[2]=a,e[3]=i,e[4]=o):(i=e[3],o=e[4]),_.useEffect(i,o),a===null)return null;const{title:c,description:d}=aa[a];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ke,{variant:"icon",children:s.jsx(qt,{})}),e[5]=u):u=e[5];let f;e[6]!==c?(f=s.jsx(Te,{children:c}),e[6]=c,e[7]=f):f=e[7];let m;e[8]!==d?(m=s.jsx(Pe,{children:d}),e[8]=d,e[9]=m):m=e[9];let h;e[10]!==f||e[11]!==m?(h=s.jsxs(De,{children:[u,f,m]}),e[10]=f,e[11]=m,e[12]=h):h=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsxs(F,{variant:"outline",size:"sm",onClick:ia,children:[s.jsx(kn,{"data-icon":"inline-start"}),"Show all"]}),e[13]=x):x=e[13];let p;return e[14]!==t||e[15]!==h?(p=s.jsxs(Ee,{className:t,children:[h,x]}),e[14]=t,e[15]=h,e[16]=p):p=e[16],p}function ia(){return js("all")}function oa(n){return"owner"in n&&"inheritsFrom"in n}function ca({owner:n,inheritsFrom:e}){return n?{label:n.displayName,title:`Owned by ${n.displayName}`}:e?{label:"Unassigned parent",title:"Its parent session has no owner yet"}:{label:"Unassigned",title:"No owner yet"}}function da(n){const e=A.c(8),{access:t}=n;if(!t||t.mine||!oa(t))return null;let l;e[0]!==t?(l=ca(t),e[0]=t,e[1]=l):l=e[1];const{label:r,title:a}=l;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(En,{"data-icon":"inline-start"}),e[2]=i):i=e[2];let o;e[3]!==r?(o=s.jsx("span",{className:"truncate",children:r}),e[3]=r,e[4]=o):o=e[4];let c;return e[5]!==o||e[6]!==a?(c=s.jsxs(ne,{variant:"outline","data-session-owner":!0,className:"max-w-36",title:a,children:[i,o]}),e[5]=o,e[6]=a,e[7]=c):c=e[7],c}function ua(){const n=A.c(11),{scope:e,options:t}=ws();if(e===null)return null;let l;n[0]!==e?(l=[e],n[0]=e,n[1]=l):l=n[1];let r;n[2]!==t||n[3]!==e?(r=o=>{const c=t.find(d=>d===o.at(-1));c&&c!==e&&js(c)},n[2]=t,n[3]=e,n[4]=r):r=n[4];let a;n[5]!==t?(a=t.map(fa),n[5]=t,n[6]=a):a=n[6];let i;return n[7]!==l||n[8]!==r||n[9]!==a?(i=s.jsx("div",{className:"shrink-0 border-b px-2.5 py-2",children:s.jsx(st,{value:l,onValueChange:r,variant:"outline",size:"sm",spacing:0,className:"w-full","aria-label":"Whose sessions to list",children:a})}),n[7]=l,n[8]=r,n[9]=a,n[10]=i):i=n[10],i}function fa(n){return s.jsx(Oe,{value:n,className:"min-w-fit flex-1 px-2 text-xs",children:Ql[n]},n)}const ma="Could not update access. Try again.",ha=["view","interact","own"];function ut(n){return`/api/team/session-access/${encodeURIComponent(n)}`}function vs(n,e){return`${ut(n)}/grants/${encodeURIComponent(e)}`}function Cs(n){const e=n;return ha.includes(e==null?void 0:e.level)&&Array.isArray(e==null?void 0:e.grants)}async function ft(n){try{return await n()}catch{return null}}async function mt(n){const e=await ft(n),t=await re(e);return e!=null&&e.ok&&Cs(t)?{ok:!0,detail:t}:{ok:!1,superseded:(e==null?void 0:e.status)===409&&(t==null?void 0:t.code)==="superseded",error:typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:ma}}async function Ve(n,e){const t=Rt(),l=await ft(()=>me(ut(n),{signal:e})),r=await re(l);return!(l!=null&&l.ok)||!Cs(r)?null:(Lt(n,r.level,t),r)}async function xa(n){const e=await re(await ft(()=>me("/api/team/directory",{signal:n}))),t=e==null?void 0:e.users;return Array.isArray(t)?t:null}function pa(n,e,t){return mt(()=>Ye(vs(n,e),{mode:t},{method:"PUT"}))}function ga(n,e){return mt(()=>me(vs(n,e),{method:"DELETE"}))}function ja(n,e){return mt(()=>Ye(`${ut(n)}/owner`,{userId:e},{method:"PUT"}))}function ba(n){const e=A.c(3),{sessionId:t}=n,[l,r]=_.useState(null);let a,i;e[0]!==t?(a=()=>{const c=new AbortController;return Ve(t,c.signal).then(d=>{!c.signal.aborted&&d&&r({sessionId:t,user:d.owner})}),()=>c.abort()},i=[t],e[0]=t,e[1]=a,e[2]=i):(a=e[1],i=e[2]),_.useEffect(a,i);const o=(l==null?void 0:l.sessionId)===t?l.user:null;return o?`Shared with you by ${o.displayName} · view only`:"View only"}const Ne="__cogpitBootstrapToken";function wa(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},l=e||(typeof t[Ne]=="string"?t[Ne]:"");return e&&window.history.replaceState({...t,[Ne]:e},"",`${window.location.pathname}${window.location.search}`),l}function St(){const n={...window.history.state||{}};delete n[Ne],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function ya({onAuthenticated:n,onSetupClosed:e}){const[t]=_.useState(wa),[l,r]=_.useState(""),[a,i]=_.useState(""),[o,c]=_.useState(""),[d,u]=_.useState(""),[f,m]=_.useState(!1),[h,x]=_.useState(null),[p,g]=_.useState(!1),j=d.length>0&&d!==o,b=!t||!l.trim()||o.length<ue||d!==o,S=_.useCallback(async w=>{if(w.preventDefault(),!b){g(!0),x(null);try{const y=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify(ns({username:l,displayName:a,password:o}))}),N=await y.json();if(y.ok){St(),c(""),u(""),r(""),i(""),await e(),n();return}if(y.status===410){St(),await e();return}x(N.error||"Could not create the admin account")}catch{x("Failed to connect to server")}finally{g(!1)}}},[t,a,b,n,e,o,l]);return s.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:s.jsx("form",{onSubmit:S,className:"w-full max-w-md",children:s.jsxs(ke,{children:[s.jsxs($e,{children:[s.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:s.jsx(Dn,{className:"size-4"})}),s.jsx(_e,{children:"Create the first admin"}),s.jsx(et,{children:"Set up the account that will manage this Cogpit team server."})]}),s.jsxs(Ae,{className:"flex flex-col gap-4",children:[!t&&s.jsxs(ee,{children:[s.jsx(Ht,{"aria-hidden":"true"}),s.jsx(le,{children:"Setup link required"}),s.jsx(te,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),s.jsxs(Tt,{children:[s.jsx(ls,{id:"bootstrap-username",value:l,onChange:r,autoComplete:"username",autoFocus:!0}),s.jsx(as,{id:"bootstrap-display-name",value:a,onChange:i,autoComplete:"name"}),s.jsx(ct,{id:"bootstrap-password",label:"Password",placeholder:"Password",value:o,onChange:c,visible:f,onVisibleChange:m}),s.jsxs(X,{"data-invalid":j,children:[s.jsx(J,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),s.jsx(de,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:w=>u(w.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":j}),j&&s.jsx(Ze,{children:"Passwords do not match"})]})]}),h&&s.jsxs(ee,{variant:"destructive",children:[s.jsx(lt,{"aria-hidden":"true"}),s.jsx(le,{children:"Could not create the account"}),s.jsx(te,{children:h})]})]}),s.jsx(hn,{children:s.jsxs(F,{type:"submit",className:"w-full",disabled:p||b,children:[p&&s.jsx(We,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}const Nt=[{value:"view",label:"Can view"},{value:"interact",label:"Can interact"}];function ht(n){const e=A.c(10),{user:t,className:l}=n;let r;e[0]!==l?(r=se("flex min-w-0 items-baseline gap-1.5",l),e[0]=l,e[1]=r):r=e[1];let a;e[2]!==t.displayName?(a=s.jsx("span",{className:"truncate text-sm text-foreground",children:t.displayName}),e[2]=t.displayName,e[3]=a):a=e[3];let i;e[4]!==t.username?(i=s.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",t.username]}),e[4]=t.username,e[5]=i):i=e[5];let o;return e[6]!==r||e[7]!==a||e[8]!==i?(o=s.jsxs("span",{className:r,children:[a,i]}),e[6]=r,e[7]=a,e[8]=i,e[9]=o):o=e[9],o}function _s(n){const e=A.c(12),{label:t,value:l,onChange:r,size:a}=n;let i;e[0]!==r||e[1]!==l?(i=f=>{f&&f!==l&&r(f)},e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Gt,{}),e[3]=o):o=e[3];let c;e[4]!==t||e[5]!==a?(c=s.jsx(zt,{size:a,"aria-label":t,className:"w-32 shrink-0",children:o}),e[4]=t,e[5]=a,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Mt,{children:s.jsx(Ft,{children:Nt.map(Sa)})}),e[7]=d):d=e[7];let u;return e[8]!==i||e[9]!==c||e[10]!==l?(u=s.jsxs(Bt,{items:Nt,value:l,onValueChange:i,children:[c,d]}),e[8]=i,e[9]=c,e[10]=l,e[11]=u):u=e[11],u}function Sa(n){return s.jsx(It,{value:n.value,children:n.label},n.value)}function $s(n){const e=A.c(24),{label:t,users:l,value:r,placeholder:a,onChange:i,triggerRef:o,className:c}=n;let d;e[0]!==l?(d=l.map(va),e[0]=l,e[1]=d):d=e[1];const u=d,f=l.length===0;let m;e[2]!==i||e[3]!==l||e[4]!==r?(m=b=>{const S=l.find(w=>w.id===b);S&&S.id!==r&&i(S)},e[2]=i,e[3]=l,e[4]=r,e[5]=m):m=e[5];let h;e[6]!==a?(h=s.jsx(Gt,{placeholder:a}),e[6]=a,e[7]=h):h=e[7];let x;e[8]!==c||e[9]!==t||e[10]!==h||e[11]!==o?(x=s.jsx(zt,{ref:o,"aria-label":t,className:c,children:h}),e[8]=c,e[9]=t,e[10]=h,e[11]=o,e[12]=x):x=e[12];let p;e[13]!==l?(p=l.map(Na),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==p?(g=s.jsx(Mt,{children:s.jsx(Ft,{children:p})}),e[15]=p,e[16]=g):g=e[16];let j;return e[17]!==u||e[18]!==f||e[19]!==m||e[20]!==x||e[21]!==g||e[22]!==r?(j=s.jsxs(Bt,{items:u,value:r,disabled:f,onValueChange:m,children:[x,g]}),e[17]=u,e[18]=f,e[19]=m,e[20]=x,e[21]=g,e[22]=r,e[23]=j):j=e[23],j}function Na(n){return s.jsx(It,{value:n.id,children:s.jsx(ht,{user:n})},n.id)}function va(n){return{value:n.id,label:n.displayName}}function Ca(n){const e=A.c(10),{grants:t,onModeChange:l,onRemove:r}=n;if(t.length===0){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ee,{className:"gap-1 border p-4",children:s.jsxs(De,{children:[s.jsx(Te,{children:"Not shared with anyone yet"}),s.jsx(Pe,{className:"text-xs",children:"Only the owner and admins can open this session."})]})}),e[0]=o):o=e[0],o}let a;if(e[1]!==t||e[2]!==l||e[3]!==r){let o;e[5]!==l||e[6]!==r?(o=c=>s.jsxs("li",{className:"flex items-center gap-1.5 py-1.5 pr-1.5 pl-3",children:[s.jsx(ht,{user:c.user,className:"flex-1"}),s.jsx(_s,{size:"sm",label:`Access for ${c.user.displayName}`,value:c.mode,onChange:d=>l(c.user,d)}),s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${c.user.displayName}`,onClick:()=>r(c.user),children:s.jsx(Wt,{"data-icon":"inline-start"})})]},c.user.id),e[5]=l,e[6]=r,e[7]=o):o=e[7],a=t.map(o),e[1]=t,e[2]=l,e[3]=r,e[4]=a}else a=e[4];let i;return e[8]!==a?(i=s.jsx("ul",{"aria-label":"People with access",className:"flex flex-col divide-y rounded-lg border bg-card",children:a}),e[8]=a,e[9]=i):i=e[9],i}const _a="Someone else changed access — refreshed.";function ye(n,e){return t=>{const l=t.grants.filter(a=>a.user.id!==n),r=e?[...l,e].sort((a,i)=>a.grantedAt-i.grantedAt):l;return{...t,grants:r}}}function vt(n){return e=>({...e,...n})}function $a(n){const e=A.c(31),{user:t}=xe(),[l,r]=_.useState(!0),[a,i]=_.useState(null),[o,c]=_.useState(null),[d,u]=_.useState(null),[f,m]=_.useState(0),h=_.useRef(0),x=_.useRef(null);let p;e[0]!==n?(p=()=>{const D=new AbortController;return Promise.all([Ve(n,D.signal),xa(D.signal)]).then(E=>{var R;const[P,L]=E;D.signal.aborted||(x.current=((R=P==null?void 0:P.owner)==null?void 0:R.id)??null,i(P),c(L),r(!1))}),()=>D.abort()},e[0]=n,e[1]=p):p=e[1];let g;e[2]!==f||e[3]!==n?(g=[n,f],e[2]=f,e[3]=n,e[4]=g):g=e[4],_.useEffect(p,g);let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=function(){r(!0),m(Aa)},e[5]=j):j=e[5];const b=j;let S;e[6]!==n?(S=async function(E,P,L){var z,B;const R=h.current=h.current+1,I=Rt();u(null),i(M=>M&&E(M));const G=await L();if(G.ok){R===h.current&&i(G.detail),Lt(n,G.detail.level,I);const M=((z=G.detail.owner)==null?void 0:z.id)??null;M!==x.current&&qe(),x.current=M;return}if(i(M=>M&&P(M)),!G.superseded){u({tone:"error",text:G.error});return}u({tone:"notice",text:_a});const H=await Ve(n);H&&(x.current=((B=H.owner)==null?void 0:B.id)??null,i(H))},e[6]=n,e[7]=S):S=e[7];const w=S;let y;e[8]!==(a==null?void 0:a.grants)?(y=function(E){return(a==null?void 0:a.grants.find(P=>P.user.id===E))??null},e[8]=a==null?void 0:a.grants,e[9]=y):y=e[9];const N=y;let v;e[10]!==N||e[11]!==w||e[12]!==n||e[13]!==(t==null?void 0:t.id)?(v=function(E,P){const L=N(E.id),R=L?{...L,mode:P}:{user:E,mode:P,grantedBy:(t==null?void 0:t.id)??"",grantedAt:Date.now()};w(ye(E.id,R),ye(E.id,L),()=>pa(n,E.id,P))},e[10]=N,e[11]=w,e[12]=n,e[13]=t==null?void 0:t.id,e[14]=v):v=e[14];const C=v;let $;e[15]!==N||e[16]!==w||e[17]!==n?($=function(E){w(ye(E.id,null),ye(E.id,N(E.id)),()=>ga(n,E.id))},e[15]=N,e[16]=w,e[17]=n,e[18]=$):$=e[18];const k=$;let T;e[19]!==a||e[20]!==w||e[21]!==n?(T=function(E){if(!a)return;const{inheritsFrom:P,canHoldGrants:L}=a;w(vt({owner:E,inheritsFrom:null,canHoldGrants:!0}),vt({owner:a.owner,inheritsFrom:P,canHoldGrants:L}),()=>ja(n,E.id))},e[19]=a,e[20]=w,e[21]=n,e[22]=T):T=e[22];const U=T;let O;return e[23]!==U||e[24]!==a||e[25]!==o||e[26]!==C||e[27]!==l||e[28]!==d||e[29]!==k?(O={loading:l,detail:a,directory:o,message:d,retry:b,grant:C,revoke:k,changeOwner:U},e[23]=U,e[24]=a,e[25]=o,e[26]=C,e[27]=l,e[28]=d,e[29]=k,e[30]=O):O=e[30],O}function Aa(n){return n+1}function ka(n){const e=A.c(10),{sessionId:t,open:l,onOpenChange:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsxs(kt,{children:[s.jsx(Et,{children:"Share with team"}),s.jsx(Dt,{children:"View: read the session. Interact: also send messages, stop, and answer prompts."})]}),e[0]=a):a=e[0];let i;e[1]!==r?(i=()=>r(!1),e[1]=r,e[2]=i):i=e[2];let o;e[3]!==t||e[4]!==i?(o=s.jsxs($t,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md",children:[a,s.jsx(Da,{sessionId:t,onClose:i},t)]}),e[3]=t,e[4]=i,e[5]=o):o=e[5];let c;return e[6]!==r||e[7]!==l||e[8]!==o?(c=s.jsx(At,{open:l,onOpenChange:r,children:o}),e[6]=r,e[7]=l,e[8]=o,e[9]=c):c=e[9],c}function Ea(n,e){return e&&!n.some(t=>t.id===e.id)?[e,...n]:n}function Da(n){var L;const e=A.c(44),{sessionId:t,onClose:l}=n,{user:r}=xe(),a=xn("manageUsers"),{loading:i,detail:o,directory:c,message:d,retry:u,grant:f,revoke:m,changeOwner:h}=$a(t);if(i){let R;return e[0]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsxs("p",{className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[s.jsx(We,{className:"size-4"})," Loading…"]}),e[0]=R):R=e[0],R}if(!o){let R;return e[1]!==u?(R=s.jsx(fe,{title:"Couldn't load who has access",message:"The server did not answer. Try again in a moment.",onRetry:u}),e[1]=u,e[2]=R):R=e[2],R}const x=r==null?void 0:r.id,p=(L=o.owner)==null?void 0:L.id;let g;e[3]!==o.grants||e[4]!==x||e[5]!==p?(g=new Set([x,p,...o.grants.map(Ta)]),e[3]=o.grants,e[4]=x,e[5]=p,e[6]=g):g=e[6];const j=g;let b;e[7]!==c||e[8]!==j?(b=(c==null?void 0:c.filter(R=>!j.has(R.id)))??null,e[7]=c,e[8]=j,e[9]=b):b=e[9];const S=b,{inheritsFrom:w}=o,y=w?null:o.owner;let N;e[10]!==c||e[11]!==a||e[12]!==y?(N=a&&c?Ea(c,y):null,e[10]=c,e[11]=a,e[12]=y,e[13]=N):N=e[13];const v=N,C=w?o.owner?`Through parent: ${o.owner.displayName}`:"Unassigned parent":"Unassigned";let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx("span",{className:"text-sm text-muted-foreground",children:"Owner"}),e[14]=$):$=e[14];let k;e[15]!==h||e[16]!==y||e[17]!==v||e[18]!==C?(k=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[$,v?s.jsx($s,{label:"Change owner",users:v,value:(y==null?void 0:y.id)??null,placeholder:C,onChange:h,className:"min-w-44"}):y?s.jsx(ht,{user:y,className:"justify-end"}):s.jsx("span",{className:"text-sm text-muted-foreground",children:C})]}),e[15]=h,e[16]=y,e[17]=v,e[18]=C,e[19]=k):k=e[19];let T;e[20]!==w||e[21]!==v?(T=v&&w&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"An owner of its own makes this session independent: it stops sharing its parent session's access."}),e[20]=w,e[21]=v,e[22]=T):T=e[22];let U;e[23]!==k||e[24]!==T?(U=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[k,T]}),e[23]=k,e[24]=T,e[25]=U):U=e[25];let O;e[26]!==S||e[27]!==o.canHoldGrants||e[28]!==f||e[29]!==w||e[30]!==l?(O=o.canHoldGrants?s.jsx(Oa,{candidates:S,onAdd:f}):s.jsx(Pa,{inheritsFrom:w,onParentOpened:l}),e[26]=S,e[27]=o.canHoldGrants,e[28]=f,e[29]=w,e[30]=l,e[31]=O):O=e[31];let D;e[32]!==d?(D=d&&s.jsx(Ua,{message:d}),e[32]=d,e[33]=D):D=e[33];let E;e[34]!==o.canHoldGrants||e[35]!==o.grants||e[36]!==f||e[37]!==m?(E=o.canHoldGrants&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-xs font-medium text-muted-foreground",children:"People with access"}),s.jsx(Ca,{grants:o.grants,onModeChange:f,onRemove:m})]}),e[34]=o.canHoldGrants,e[35]=o.grants,e[36]=f,e[37]=m,e[38]=E):E=e[38];let P;return e[39]!==O||e[40]!==D||e[41]!==E||e[42]!==U?(P=s.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[U,O,D,E]}),e[39]=O,e[40]=D,e[41]=E,e[42]=U,e[43]=P):P=e[43],P}function Ta(n){return n.user.id}function Pa(n){const e=A.c(14),{inheritsFrom:t,onParentOpened:l}=n,[r,a]=_.useState(!1);if(!t){let x;return e[0]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsxs(ee,{role:"note",children:[s.jsx(Tn,{}),s.jsx(le,{children:"Assign an owner first"}),s.jsx(te,{children:"Only a session with an owner can be shared."})]}),e[0]=x):x=e[0],x}let i;e[1]!==l?(i=async function(p){a(!1),await pn(p)?l():a(!0)},e[1]=l,e[2]=i):i=e[2];const o=i;let c,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(Pn,{}),d=s.jsx(le,{children:"Shared through its parent session"}),e[3]=c,e[4]=d):(c=e[3],d=e[4]);let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("span",{children:"Whoever can open the parent can open this one. Share the parent to change who."}),e[5]=u):u=e[5];let f;e[6]!==t||e[7]!==o?(f=s.jsx(F,{variant:"link",className:"h-auto p-0",onClick:()=>void o(t),children:"Open parent session"}),e[6]=t,e[7]=o,e[8]=f):f=e[8];let m;e[9]!==r?(m=r&&s.jsx("span",{role:"alert",className:"text-destructive",children:"Couldn't open the parent session."}),e[9]=r,e[10]=m):m=e[10];let h;return e[11]!==f||e[12]!==m?(h=s.jsxs(ee,{role:"note",children:[c,d,s.jsxs(te,{className:"flex flex-col items-start gap-1",children:[u,f,m]})]}),e[11]=f,e[12]=m,e[13]=h):h=e[13],h}function Oa(n){const e=A.c(22),{candidates:t,onAdd:l}=n,[r,a]=_.useState(null),[i,o]=_.useState("view"),c=_.useRef(null);let d;e[0]!==t?(d=t??[],e[0]=t,e[1]=d):d=e[1];const u=d;let f;e[2]!==u||e[3]!==r?(f=r&&u.some(N=>N.id===r.id)?r:null,e[2]=u,e[3]=r,e[4]=f):f=e[4];const m=f;let h;e[5]!==i||e[6]!==l||e[7]!==m?(h=function(v){var C;v.preventDefault(),m&&(l(m,i),a(null),(C=c.current)==null||C.focus())},e[5]=i,e[6]=l,e[7]=m,e[8]=h):h=e[8];const x=h,p=(m==null?void 0:m.id)??null,g=t===null?"Couldn't load teammates":u.length===0?"No one else to add":"Choose a teammate";let j;e[9]!==u||e[10]!==p||e[11]!==g?(j=s.jsx($s,{label:"Teammate",users:u,value:p,placeholder:g,onChange:a,triggerRef:c,className:"min-w-0 flex-1"}),e[9]=u,e[10]=p,e[11]=g,e[12]=j):j=e[12];let b;e[13]!==i?(b=s.jsx(_s,{label:"Access for new teammate",value:i,onChange:o}),e[13]=i,e[14]=b):b=e[14];const S=!m;let w;e[15]!==S?(w=s.jsx(F,{type:"submit",disabled:S,children:"Add"}),e[15]=S,e[16]=w):w=e[16];let y;return e[17]!==x||e[18]!==j||e[19]!==b||e[20]!==w?(y=s.jsxs("form",{onSubmit:x,className:"flex items-center gap-2",children:[j,b,w]}),e[17]=x,e[18]=j,e[19]=b,e[20]=w,e[21]=y):y=e[21],y}function Ua(n){const e=A.c(6),{message:t}=n,l=t.tone==="error",r=l?"alert":"status",a=l?"text-destructive":"text-muted-foreground";let i;e[0]!==a?(i=se("text-xs",a),e[0]=a,e[1]=i):i=e[1];let o;return e[2]!==t.text||e[3]!==r||e[4]!==i?(o=s.jsx("p",{role:r,className:i,children:t.text}),e[2]=t.text,e[3]=r,e[4]=i,e[5]=o):o=e[5],o}function Ra(n){const e=A.c(4),{sessionId:t}=n,{edition:l}=xe(),{permissions:r}=gn(),[a,i]=_.useState(!1);if(l!=="team"||!r.canOwn)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(jn,{icon:qt,label:"Share with team…",size:"default",onClick:()=>i(!0)}),e[0]=o):o=e[0];let c;return e[1]!==a||e[2]!==t?(c=s.jsxs(s.Fragment,{children:[o,s.jsx(ka,{sessionId:t,open:a,onOpenChange:i})]}),e[1]=a,e[2]=t,e[3]=c):c=e[3],c}const La={SetupScreen:ya,LoginNotice:fs,GateScreen:Vl,AccountControl:Ol,SessionHeaderActions:Ra,SessionBadges:da,ReadOnlyNote:ba,mainViews:[Pl],sessionListFilter:{...sa,Control:ua,Empty:ra},onInboxRead:na},Ha={edition:"team",ui:La};export{Ha as default};
2
+ import{c as A,r as _,j as s}from"./vendor-react-gGw_S5I_.js";import{U as me,b7 as As,bZ as re,c7 as ks,c8 as Ye,A as ee,aX as le,p as te,ad as he,B as F,a7 as Es,a8 as Ds,a9 as Ts,a6 as Ps,ab as Os,aa as Us,ac as Rs,a5 as Ls,a4 as Is,bW as Ms,ag as We,aZ as Ct,Z as ne,aN as _e,aM as $e,aO as Ae,aQ as ke,b1 as q,aJ as Fs,C as Q,c9 as _t,v as Gs,bT as zs,L as Ee,M as De,N as Ke,O as Te,Q as Pe,ca as Bs,cb as Hs,cc as Vs,cd as Ys,$ as Ws,ce as Je,cf as qe,cg as ae,ch as X,ci as Qe,cj as Z,ck as Xe,G as Ze,aY as et,b6 as de,b2 as tt,n as Ks,I as Js,E as qs,m as Qs,h as $t,D as At,H as Oe,i as kt,j as Et,k as Dt,T as st,z as Tt,c5 as Xs,aK as Zs,aV as Pt,cl as Ot,cm as V,as as Ue,cn as Se,co as ve,cp as pt,J as se,cq as J,cr as en,cs as tn,ct as sn,cu as xe,q as nn,cv as ln,y as Ut,cw as an,b$ as rn,cx as on,cy as cn,cz as dn,cA as un,at as fn,R as nt,cB as mn,av as Rt,cC as Lt,aP as hn,bg as It,be as Mt,bf as Ft,bh as Gt,bi as zt,bj as Bt,Y as xn,cD as pn,cE as gn,cF as jn}from"./index-CW9tjG1S.js";import{J as Ht,aE as Vt,aF as lt,aG as at,aH as bn,ae as Yt,a2 as wn,a9 as yn,aa as Sn,aI as Nn,aJ as vn,aK as Cn,aL as _n,X as Wt,af as rt,aM as $n,aN as Kt,m as An,aO as Jt,a5 as kn,aP as En,aQ as Dn,aR as Tn,aS as Pn}from"./vendor-ui-Br3ZTAXZ.js";import{P as ue}from"./password-BV9mqUzz.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";async function On(n,e){const t=await me(n,{signal:e});if(!t.ok)throw new Error(await As(t,`Request failed (${t.status})`));const l=await re(t);if(!l)throw new Error("The server returned an unexpected response");return l}function ce(n){const e=A.c(11);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={data:null,dataPath:null,error:null,loading:!0},e[0]=t):t=e[0];const[l,r]=_.useState(t),[a,i]=_.useState(0);let o;e[1]!==n?(o=()=>{const m=new AbortController;return r(Rn),On(n,m.signal).then(h=>{m.signal.aborted||r({data:h,dataPath:n,error:null,loading:!1})}).catch(h=>{if(m.signal.aborted)return;const x=h instanceof Error?h.message:"Request failed";r(p=>{const g=p.dataPath===n;return{data:g?p.data:null,dataPath:g?n:null,error:x,loading:!1}})}),()=>m.abort()},e[1]=n,e[2]=o):o=e[2];let c;e[3]!==a||e[4]!==n?(c=[n,a],e[3]=a,e[4]=n,e[5]=c):c=e[5],_.useEffect(o,c);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i(Un),e[6]=d):d=e[6];const u=d;let f;return e[7]!==l.data||e[8]!==l.error||e[9]!==l.loading?(f={data:l.data,error:l.error,loading:l.loading,refresh:u},e[7]=l.data,e[8]=l.error,e[9]=l.loading,e[10]=f):f=e[10],f}function Un(n){return n+1}function Rn(n){return{...n,loading:!0,error:null}}function qt(n){const{from:e,to:t}=n;return ce(`/api/team/usage?from=${e}&to=${t}`)}function Ln(n){return n===null||!("role"in n)?!1:n.role==="admin"||n.role==="member"}const Qt=864e5,Me=90,gt=Me*Qt;function In({from:n,to:e},t){return e-n>gt?"too_long":e<t-gt?"too_old":null}const it={admin:"Admin",member:"Member"},Ce={text:"—",title:"Price unavailable"},Xt="No one can become an admin while the license keeps members out.";function Zt(n,e){return{from:e-n*Qt,to:e}}function es(n){return n.input+n.output+n.cacheRead+n.cacheWrite}const Fe="cogpit:lockout-return-to-people";function Mn(){try{sessionStorage.setItem(Fe,"1")}catch{return}window.history.replaceState(null,"",`${ks()}/`)}function Fn(){try{return sessionStorage.getItem(Fe)===null?!1:(sessionStorage.removeItem(Fe),!0)}catch{return!1}}function K(n){return new Date(n).toLocaleDateString(void 0,{dateStyle:"medium"})}function Ge(n){const e=new Date(n),t=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${t}-${l}`}function ts(n,e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(!t)return null;const[l,r,a]=[Number(t[1]),Number(t[2])-1,Number(t[3])],i=new Date(l,r,a);return i.getFullYear()!==l||i.getMonth()!==r||i.getDate()!==a?null:(i.setDate(i.getDate()+e),i.getTime())}function Gn(n){return ts(n,0)}function zn(n){const e=ts(n,1);return e===null?null:e-1}const Bn={"shares.local.json":" Every share link was reset and its guests signed out; share each session again.","sessions.json":" Everyone was signed out and must sign in again."};function Hn({store:n,detectedAt:e,kind:t}){if(t==="baseline")return`The audit log started on ${K(e)}; existing data was accepted as-is.`;const l=`detected ${K(e)}`;return(t==="unverifiable"?`${n} could not be checked against the audit log (${l}).`:`${n} was changed outside Cogpit (${l}).`)+(Bn[n]??"")}const Vn={expired:{cause:"The license has expired.",remedy:"install a new key"},over_seats:{cause:"More accounts are enabled than the license has seats.",remedy:"disable accounts or install a license with more seats"}};function Yn({state:n,reason:e,graceEndsAt:t}){if(n==="valid"||e===null)return null;const{cause:l,remedy:r}=Vn[e];return n==="locked"?`${l} Only admins can sign in until you ${r}.`:t===null?`${l} Members will be locked out unless you ${r}.`:`${l} Members can sign in until ${K(t)}; ${r} before then.`}function Wn(n){const e=[],{audit:t}=n;if(t.writable||e.push({id:"audit-writable",message:"The audit log cannot be written. Prompts and admin actions are not being recorded."}),t.missed>0){const r=t.missed===1?"1 audit event":`${t.missed} audit events`,a=t.since===null?"":` since ${K(t.since)}`;e.push({id:"audit-missed",message:`${r} could not be recorded${a}.`})}t.clockAhead&&e.push({id:"audit-clock",message:"The audit log is dated ahead of this server's clock, so new entries carry the log's time. Check the system clock."});for(const r of n.integrity)e.push({id:`integrity-${r.store}-${r.detectedAt}`,message:Hn(r),acceptance:r.kind==="baseline"?{store:r.store,subject:"the existing data",trust:"Cogpit will keep trusting the stores' current contents, and the audit log will record that you accepted them."}:{store:r.store,subject:r.store,trust:"Cogpit will trust the file's current contents from now on, and the audit log will record that you accepted them."}});for(const{store:r,since:a}of n.storeWrites)e.push({id:`store-write-${r}`,message:`${r} could not be saved since ${K(a)}. Changes made since then, revoked access included, apply until the server restarts, then are lost. Free disk space or fix the data directory's permissions.`});const l=Yn(n.license);return l&&e.push({id:"license",message:l}),e}const Kn="Every seat on the license is in use. Disable someone or install a license with more seats.";async function pe(n,e,t){let l;try{l=await Ye(n,t,{method:e})}catch{return{ok:!1,error:"Could not reach the server."}}const r=await re(l);if(l.ok&&r)return{ok:!0,value:r};const a=r;return(a==null?void 0:a.code)==="SEAT_LIMIT"?{ok:!1,error:Kn}:{ok:!1,error:typeof(a==null?void 0:a.error)=="string"&&a.error?a.error:`Request failed (${l.status})`}}function Jn(n){return pe("/api/team/users","POST",n)}function ss(n,e){return pe(`/api/team/users/${encodeURIComponent(n)}`,"PATCH",e)}function qn(n){return pe("/api/team/session-access/assign","POST",n)}function Qn(n){return pe("/api/team/license","POST",{key:n})}function Xn(n){return pe("/api/team/health/acknowledge","POST",{store:n})}function ge(){const[n,e]=_.useState(!1),[t,l]=_.useState(null);async function r(a){e(!0),l(null);try{const i=await a();return i.ok?i.value:(l(i.error),null)}finally{e(!1)}}return{busy:n,error:t,setError:l,run:r}}function Zn(n){const e=A.c(40),{acceptance:t,warning:l,onAccepted:r}=n,{store:a,subject:i,trust:o}=t,{busy:c,error:d,run:u}=ge(),[f,m]=_.useState(!1);let h;e[0]!==r||e[1]!==u||e[2]!==a||e[3]!==i?(h=async function(){m(!1),await u(()=>Xn(a))&&(he.success(`Accepted the current state of ${i}`),r())},e[0]=r,e[1]=u,e[2]=a,e[3]=i,e[4]=h):h=e[4];const x=h,p=`Accept the current state of ${i}`;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=()=>m(!0),e[5]=g):g=e[5];let j;e[6]!==c||e[7]!==p?(j=s.jsx(F,{variant:"outline",size:"xs",disabled:c,"aria-label":p,onClick:g,children:"Accept current state"}),e[6]=c,e[7]=p,e[8]=j):j=e[8];let b;e[9]!==d?(b=d&&s.jsx("span",{role:"alert",className:"text-destructive",children:d}),e[9]=d,e[10]=b):b=e[10];let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Es,{className:"bg-warning/10 text-warning",children:s.jsx(Vt,{})}),e[11]=S):S=e[11];const w=`Accept the current state of ${i}?`;let y;e[12]!==w?(y=s.jsx(Ds,{children:w}),e[12]=w,e[13]=y):y=e[13];let N;e[14]!==l?(N=s.jsx("span",{children:l}),e[14]=l,e[15]=N):N=e[15];let v;e[16]!==o?(v=s.jsx("span",{children:o}),e[16]=o,e[17]=v):v=e[17];let C;e[18]!==N||e[19]!==v?(C=s.jsxs(Ts,{className:"flex flex-col gap-2",children:[N,v]}),e[18]=N,e[19]=v,e[20]=C):C=e[20];let $;e[21]!==C||e[22]!==y?($=s.jsxs(Ps,{children:[S,y,C]}),e[21]=C,e[22]=y,e[23]=$):$=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(Os,{size:"sm",children:"Cancel"}),e[24]=k):k=e[24];let T;e[25]!==x?(T=()=>void x(),e[25]=x,e[26]=T):T=e[26];let U;e[27]!==c||e[28]!==T?(U=s.jsxs(Us,{children:[k,s.jsx(Rs,{size:"sm",disabled:c,onClick:T,children:"Accept current state"})]}),e[27]=c,e[28]=T,e[29]=U):U=e[29];let O;e[30]!==$||e[31]!==U?(O=s.jsxs(Ls,{children:[$,U]}),e[30]=$,e[31]=U,e[32]=O):O=e[32];let D;e[33]!==f||e[34]!==O?(D=s.jsx(Is,{open:f,onOpenChange:m,children:O}),e[33]=f,e[34]=O,e[35]=D):D=e[35];let E;return e[36]!==D||e[37]!==j||e[38]!==b?(E=s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[j,b,D]}),e[36]=D,e[37]=j,e[38]=b,e[39]=E):E=e[39],E}function el(n){const e=A.c(28),{health:t,onChanged:l}=n;let r,a,i,o,c,d,u,f,m;if(e[0]!==t||e[1]!==l){m=Symbol.for("react.early_return_sentinel");e:{const g=Wn(t);if(g.length===0){m=null;break e}a=ee,d="border-warning/30 bg-warning/10 text-warning",e[11]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ht,{}),f=s.jsx(le,{children:"This team server needs attention"}),e[11]=u,e[12]=f):(u=e[11],f=e[12]),r=te,c="text-warning/90",i="flex list-disc flex-col gap-1 pl-4";let j;e[13]!==l?(j=b=>s.jsxs("li",{children:[s.jsx("span",{className:"mr-2",children:b.message}),b.acceptance&&s.jsx(Zn,{acceptance:b.acceptance,warning:b.message,onAccepted:l})]},b.id),e[13]=l,e[14]=j):j=e[14],o=g.map(j)}e[0]=t,e[1]=l,e[2]=r,e[3]=a,e[4]=i,e[5]=o,e[6]=c,e[7]=d,e[8]=u,e[9]=f,e[10]=m}else r=e[2],a=e[3],i=e[4],o=e[5],c=e[6],d=e[7],u=e[8],f=e[9],m=e[10];if(m!==Symbol.for("react.early_return_sentinel"))return m;let h;e[15]!==i||e[16]!==o?(h=s.jsx("ul",{className:i,children:o}),e[15]=i,e[16]=o,e[17]=h):h=e[17];let x;e[18]!==r||e[19]!==c||e[20]!==h?(x=s.jsx(r,{className:c,children:h}),e[18]=r,e[19]=c,e[20]=h,e[21]=x):x=e[21];let p;return e[22]!==a||e[23]!==d||e[24]!==u||e[25]!==f||e[26]!==x?(p=s.jsxs(a,{className:d,children:[u,f,x]}),e[22]=a,e[23]=d,e[24]=u,e[25]=f,e[26]=x,e[27]=p):p=e[27],p}function fe(n){const e=A.c(11),{title:t,message:l,onRetry:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(lt,{}),e[0]=a):a=e[0];let i;e[1]!==t?(i=s.jsx(le,{children:t}),e[1]=t,e[2]=i):i=e[2];let o;e[3]!==l?(o=s.jsx(te,{children:l}),e[3]=l,e[4]=o):o=e[4];let c;e[5]!==r?(c=s.jsx(Ms,{children:s.jsx(F,{variant:"outline",size:"xs",onClick:r,children:"Retry"})}),e[5]=r,e[6]=c):c=e[6];let d;return e[7]!==i||e[8]!==o||e[9]!==c?(d=s.jsxs(ee,{variant:"destructive",children:[a,i,o,c]}),e[7]=i,e[8]=o,e[9]=c,e[10]=d):d=e[10],d}function ot(n){const e=A.c(3),{label:t}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx(We,{className:"size-4"}),e[0]=l):l=e[0];let r;return e[1]!==t?(r=s.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[l,t]}),e[1]=t,e[2]=r):r=e[2],r}const tl={valid:{label:"Active",variant:"secondary"},grace:{label:"Grace period",variant:"outline",className:"border-warning/30 bg-warning/10 text-warning"},locked:{label:"Members locked out",variant:"destructive"}};function sl(n){const e=A.c(20),{license:t}=n;let l;e[0]!==t.customer?(l=["Customer",t.customer],e[0]=t.customer,e[1]=l):l=e[1];const r=`${t.activeUsers} of ${t.seats} used`;let a;e[2]!==r?(a=["Seats",r],e[2]=r,e[3]=a):a=e[3];const i=t.reason==="expired"?"Expired":"Expires";let o;e[4]!==t.expiresAt?(o=K(t.expiresAt),e[4]=t.expiresAt,e[5]=o):o=e[5];let c;e[6]!==i||e[7]!==o?(c=[i,o],e[6]=i,e[7]=o,e[8]=c):c=e[8];let d;if(e[9]!==t.graceEndsAt||e[10]!==l||e[11]!==a||e[12]!==c){if(d=[l,a,c],t.graceEndsAt!==null){let f;e[14]!==t.graceEndsAt?(f=K(t.graceEndsAt),e[14]=t.graceEndsAt,e[15]=f):f=e[15];let m;e[16]!==f?(m=["Grace ends",f],e[16]=f,e[17]=m):m=e[17],d.push(m)}e[9]=t.graceEndsAt,e[10]=l,e[11]=a,e[12]=c,e[13]=d}else d=e[13];let u;return e[18]!==d?(u=s.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5",children:d.map(nl)}),e[18]=d,e[19]=u):u=e[19],u}function nl(n){const[e,t]=n;return s.jsxs("div",{className:"contents",children:[s.jsx("dt",{className:"text-muted-foreground",children:e}),s.jsx("dd",{className:"text-foreground tabular-nums",children:t})]},e)}function ll(n){const e=A.c(23),{onDone:t,onInstalled:l}=n,r=_.useId(),[a,i]=_.useState(""),{busy:o,error:c,setError:d,run:u}=ge();let f;e[0]!==a||e[1]!==t||e[2]!==l||e[3]!==u||e[4]!==d?(f=async function(){if(!a.trim()){d("Paste a license key.");return}await u(()=>Qn(a.trim()))&&(he.success("License installed"),l(),t())},e[0]=a,e[1]=t,e[2]=l,e[3]=u,e[4]=d,e[5]=f):f=e[5];const m=f;let h;e[6]!==m?(h=()=>void m(),e[6]=m,e[7]=h):h=e[7];const x=`${r}-key`;let p;e[8]!==x?(p=s.jsx(q,{htmlFor:x,children:"License key"}),e[8]=x,e[9]=p):p=e[9];const g=`${r}-key`;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=y=>i(y.target.value),e[10]=j):j=e[10];let b;e[11]!==a||e[12]!==g?(b=s.jsx(Fs,{id:g,value:a,onChange:j,placeholder:"Paste the key from your Cogpit Team license",rows:3,spellCheck:!1,autoFocus:!0,className:"font-mono text-xs break-all"}),e[11]=a,e[12]=g,e[13]=b):b=e[13];let S;e[14]!==p||e[15]!==b?(S=s.jsxs(Q,{children:[p,b]}),e[14]=p,e[15]=b,e[16]=S):S=e[16];let w;return e[17]!==o||e[18]!==c||e[19]!==t||e[20]!==h||e[21]!==S?(w=s.jsx(_t,{error:c,busy:o,saveLabel:"Install",onCancel:t,onSave:h,className:"px-0 pb-0",children:S}),e[17]=o,e[18]=c,e[19]=t,e[20]=h,e[21]=S,e[22]=w):w=e[22],w}function al(n){const e=A.c(24),{license:t,onInstalled:l}=n,[r,a]=_.useState(!1),i=t.data,o=i?tl[i.state]:null;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(_e,{children:"License"}),e[0]=c):c=e[0];let d;e[1]!==o?(d=o&&s.jsx(Ct,{children:s.jsx(ne,{variant:o.variant,className:o.className,children:o.label})}),e[1]=o,e[2]=d):d=e[2];let u;e[3]!==d?(u=s.jsxs($e,{children:[c,d]}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==t.error||e[6]!==t.refresh?(f=t.error&&s.jsx(fe,{title:"License status could not load",message:t.error,onRetry:t.refresh}),e[5]=t.error,e[6]=t.refresh,e[7]=f):f=e[7];let m;e[8]!==i?(m=i&&s.jsx(sl,{license:i}),e[8]=i,e[9]=m):m=e[9];let h;e[10]!==t.loading||e[11]!==i?(h=!i&&t.loading&&s.jsx(ot,{label:"Loading license…"}),e[10]=t.loading,e[11]=i,e[12]=h):h=e[12];let x;e[13]!==r||e[14]!==l?(x=r?s.jsx(ll,{onDone:()=>a(!1),onInstalled:l}):s.jsxs(F,{variant:"outline",size:"sm",className:"self-start",onClick:()=>a(!0),children:[s.jsx(at,{"data-icon":"inline-start"}),"Install license key"]}),e[13]=r,e[14]=l,e[15]=x):x=e[15];let p;e[16]!==f||e[17]!==m||e[18]!==h||e[19]!==x?(p=s.jsxs(Ae,{className:"flex flex-col gap-3",children:[f,m,h,x]}),e[16]=f,e[17]=m,e[18]=h,e[19]=x,e[20]=p):p=e[20];let g;return e[21]!==u||e[22]!==p?(g=s.jsxs(ke,{children:[u,p]}),e[21]=u,e[22]=p,e[23]=g):g=e[23],g}function jt(n){return n===1?"1 session":`${n} sessions`}function rl(n){const e=A.c(54),{project:t,path:l,name:r,assignees:a,onAssigned:i}=n,o=_.useId(),{busy:c,error:d,run:u}=ge();let f;e[0]!==t.dirName?(f=Vs(Ys(t.dirName)),e[0]=t.dirName,e[1]=f):f=e[1];const m=f;let h;e[2]!==r||e[3]!==i||e[4]!==t.dirName||e[5]!==u?(h=async function(I){const G=await u(()=>qn({userId:I.id,dirName:t.dirName}));G&&(he.success(`Assigned ${jt(G.assigned)} in ${r} to ${I.displayName}`),Je(),i())},e[2]=r,e[3]=i,e[4]=t.dirName,e[5]=u,e[6]=h):h=e[6];const x=h;let p;e[7]!==r||e[8]!==o?(p=s.jsx("span",{id:o,className:"truncate font-medium text-foreground",children:r}),e[7]=r,e[8]=o,e[9]=p):p=e[9];let g;e[10]!==m?(g=m&&s.jsx(ne,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:m}),e[10]=m,e[11]=g):g=e[11];let j;e[12]!==p||e[13]!==g?(j=s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p,g]}),e[12]=p,e[13]=g,e[14]=j):j=e[14];let b;e[15]!==l?(b=s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:l}),e[15]=l,e[16]=b):b=e[16];let S;e[17]!==t.sessionCount?(S=jt(t.sessionCount),e[17]=t.sessionCount,e[18]=S):S=e[18];let w;e[19]!==t.lastActivityAt?(w=Ws(new Date(t.lastActivityAt).toISOString()),e[19]=t.lastActivityAt,e[20]=w):w=e[20];let y;e[21]!==S||e[22]!==w?(y=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[S," · last active ",w]}),e[21]=S,e[22]=w,e[23]=y):y=e[23];let N;e[24]!==j||e[25]!==b||e[26]!==y?(N=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[j,b,y]}),e[24]=j,e[25]=b,e[26]=y,e[27]=N):N=e[27];const v=c||a.length===0;let C;e[28]!==o||e[29]!==v?(C=s.jsx(F,{variant:"outline",size:"sm",disabled:v,"aria-describedby":o}),e[28]=o,e[29]=v,e[30]=C):C=e[30];let $;e[31]!==c?($=c&&s.jsx(Yt,{"data-icon":"inline-start",className:"animate-spin"}),e[31]=c,e[32]=$):$=e[32];let k;e[33]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(wn,{"data-icon":"inline-end"}),e[33]=k):k=e[33];let T;e[34]!==C||e[35]!==$?(T=s.jsxs(qe,{render:C,children:[$,"Assign to…",k]}),e[34]=C,e[35]=$,e[36]=T):T=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(ae,{children:"Owner for every unassigned session"}),e[37]=U):U=e[37];let O;if(e[38]!==x||e[39]!==a){let R;e[41]!==x?(R=I=>s.jsxs(X,{onClick:()=>void x(I),children:[s.jsx("span",{className:"truncate",children:I.displayName}),s.jsxs("span",{className:"ml-auto truncate text-xs text-muted-foreground",children:["@",I.username]})]},I.id),e[41]=x,e[42]=R):R=e[42],O=a.map(R),e[38]=x,e[39]=a,e[40]=O}else O=e[40];let D;e[43]!==O?(D=s.jsx(Qe,{align:"end",className:"w-56",children:s.jsxs(Z,{children:[U,O]})}),e[43]=O,e[44]=D):D=e[44];let E;e[45]!==T||e[46]!==D?(E=s.jsxs(Xe,{children:[T,D]}),e[45]=T,e[46]=D,e[47]=E):E=e[47];let P;e[48]!==d?(P=d&&s.jsx(Ze,{className:"w-full",children:d}),e[48]=d,e[49]=P):P=e[49];let L;return e[50]!==N||e[51]!==E||e[52]!==P?(L=s.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 py-2.5",children:[N,E,P]}),e[50]=N,e[51]=E,e[52]=P,e[53]=L):L=e[53],L}function il(n){var j;const e=A.c(24),{users:t}=n,l=ce("/api/team/unassigned");let r;e[0]!==t?(r=t.filter(cl),e[0]=t,e[1]=r):r=e[1];const a=r,i=(j=l.data)==null?void 0:j.projects,o=Gs(!0);let c;e[2]!==o?(c=new Map(o.map(ol)),e[2]=o,e[3]=c):c=e[3];const d=c,{names:u}=zs();let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsxs($e,{children:[s.jsx(_e,{children:"Unassigned sessions"}),s.jsx(et,{children:"Only admins can see sessions without an owner. Assign each project to the person who works in it."})]}),e[4]=f):f=e[4];let m;e[5]!==l.error||e[6]!==l.refresh?(m=l.error&&s.jsx(fe,{title:"Unassigned sessions could not load",message:l.error,onRetry:l.refresh}),e[5]=l.error,e[6]=l.refresh,e[7]=m):m=e[7];let h;e[8]!==i?(h=i&&i.length===0&&s.jsx(Ee,{className:"py-6",children:s.jsxs(De,{children:[s.jsx(Ke,{variant:"icon",children:s.jsx(bn,{})}),s.jsx(Te,{children:"Every session has an owner."}),s.jsx(Pe,{children:"New sessions belong to whoever starts them."})]})}),e[8]=i,e[9]=h):h=e[9];let x;e[10]!==a||e[11]!==d||e[12]!==u||e[13]!==i||e[14]!==l.refresh?(x=i&&i.length>0&&s.jsx("ul",{className:"divide-y",children:i.map(b=>{const S=d.get(b.dirName)??Bs(b.dirName);return s.jsx(rl,{project:b,path:S,name:u[b.dirName]??Hs(S),assignees:a,onAssigned:l.refresh},b.dirName)})}),e[10]=a,e[11]=d,e[12]=u,e[13]=i,e[14]=l.refresh,e[15]=x):x=e[15];let p;e[16]!==i||e[17]!==l.loading?(p=!i&&l.loading&&s.jsx(ot,{label:"Loading unassigned sessions…"}),e[16]=i,e[17]=l.loading,e[18]=p):p=e[18];let g;return e[19]!==m||e[20]!==h||e[21]!==x||e[22]!==p?(g=s.jsxs(ke,{children:[f,s.jsxs(Ae,{className:"flex flex-col gap-3",children:[m,h,x,p]})]}),e[19]=m,e[20]=h,e[21]=x,e[22]=p,e[23]=g):g=e[23],g}function ol(n){return[n.dirName,n.path]}function cl(n){return!n.disabled}function ns({username:n,displayName:e,password:t}){return{username:n.trim(),password:t,...e.trim()?{displayName:e.trim()}:{}}}function ls(n){const e=A.c(14),{id:t,value:l,onChange:r,autoComplete:a,autoFocus:i}=n;let o;e[0]!==t?(o=s.jsx(q,{htmlFor:t,children:"Username"}),e[0]=t,e[1]=o):o=e[1];let c;e[2]!==r?(c=m=>r(m.target.value),e[2]=r,e[3]=c):c=e[3];let d;e[4]!==a||e[5]!==i||e[6]!==t||e[7]!==c||e[8]!==l?(d=s.jsx(de,{id:t,type:"text",value:l,onChange:c,placeholder:"Username",autoComplete:a,autoFocus:i,spellCheck:!1}),e[4]=a,e[5]=i,e[6]=t,e[7]=c,e[8]=l,e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(tt,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."}),e[10]=u):u=e[10];let f;return e[11]!==o||e[12]!==d?(f=s.jsxs(Q,{children:[o,d,u]}),e[11]=o,e[12]=d,e[13]=f):f=e[13],f}function as(n){const e=A.c(13),{id:t,value:l,onChange:r,autoComplete:a}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"}),e[0]=i):i=e[0];let o;e[1]!==t?(o=s.jsxs(q,{htmlFor:t,children:["Display name ",i]}),e[1]=t,e[2]=o):o=e[2];let c;e[3]!==r?(c=f=>r(f.target.value),e[3]=r,e[4]=c):c=e[4];let d;e[5]!==a||e[6]!==t||e[7]!==c||e[8]!==l?(d=s.jsx(de,{id:t,type:"text",value:l,onChange:c,placeholder:"Display name (optional)",autoComplete:a}),e[5]=a,e[6]=t,e[7]=c,e[8]=l,e[9]=d):d=e[9];let u;return e[10]!==o||e[11]!==d?(u=s.jsxs(Q,{children:[o,d]}),e[10]=o,e[11]=d,e[12]=u):u=e[12],u}function ct(n){const e=A.c(28),{id:t,label:l,placeholder:r,value:a,onChange:i,visible:o,onVisibleChange:c,autoFocus:d}=n;let u;e[0]!==t||e[1]!==l?(u=s.jsx(q,{htmlFor:t,children:l}),e[0]=t,e[1]=l,e[2]=u):u=e[2];const f=o?"text":"password";let m;e[3]!==i?(m=y=>i(y.target.value),e[3]=i,e[4]=m):m=e[4];let h;e[5]!==d||e[6]!==t||e[7]!==r||e[8]!==f||e[9]!==m||e[10]!==a?(h=s.jsx(Ks,{id:t,type:f,value:a,onChange:m,placeholder:r,autoComplete:"new-password",autoFocus:d}),e[5]=d,e[6]=t,e[7]=r,e[8]=f,e[9]=m,e[10]=a,e[11]=h):h=e[11];let x;e[12]!==c||e[13]!==o?(x=()=>c(!o),e[12]=c,e[13]=o,e[14]=x):x=e[14];const p=o?"Hide password":"Show password";let g;e[15]!==o?(g=o?s.jsx(yn,{}):s.jsx(Sn,{}),e[15]=o,e[16]=g):g=e[16];let j;e[17]!==x||e[18]!==p||e[19]!==g?(j=s.jsx(Js,{align:"inline-end",children:s.jsx(qs,{size:"icon-xs",onClick:x,"aria-label":p,children:g})}),e[17]=x,e[18]=p,e[19]=g,e[20]=j):j=e[20];let b;e[21]!==h||e[22]!==j?(b=s.jsxs(Qs,{children:[h,j]}),e[21]=h,e[22]=j,e[23]=b):b=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsxs(tt,{children:["Use at least ",ue," characters."]}),e[24]=S):S=e[24];let w;return e[25]!==u||e[26]!==b?(w=s.jsxs(Q,{children:[u,b,S]}),e[25]=u,e[26]=b,e[27]=w):w=e[27],w}const dl=["member","admin"],ul=["member"];function fl(n){const e=A.c(10),{open:t,onOpenChange:l,onCreated:r,noNewAdmins:a}=n;let i;e[0]!==r||e[1]!==l?(i=()=>{l(!1),r()},e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;e[3]!==a||e[4]!==i?(o=s.jsx($t,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md",children:s.jsx(ml,{noNewAdmins:a,onCreated:i})}),e[3]=a,e[4]=i,e[5]=o):o=e[5];let c;return e[6]!==l||e[7]!==t||e[8]!==o?(c=s.jsx(At,{open:t,onOpenChange:l,children:o}),e[6]=l,e[7]=t,e[8]=o,e[9]=c):c=e[9],c}function ml(n){const e=A.c(59),{onCreated:t,noNewAdmins:l}=n,r=_.useId(),a=l?ul:dl,[i,o]=_.useState(""),[c,d]=_.useState(""),[u,f]=_.useState("member"),[m,h]=_.useState(""),[x,p]=_.useState(!1),{busy:g,error:j,run:b}=ge();let S;e[0]!==m||e[1]!==i?(S=!i.trim()||m.length<ue,e[0]=m,e[1]=i,e[2]=S):S=e[2];const w=S;let y;if(e[3]!==c||e[4]!==w||e[5]!==t||e[6]!==m||e[7]!==u||e[8]!==b||e[9]!==i){const Le=async function(Ie){if(Ie.preventDefault(),w)return;const xt=await b(()=>Jn({...ns({username:i,displayName:c,password:m}),role:u}));xt&&(he.success(`Added ${xt.user.displayName}`),t())};y=oe=>void Le(oe),e[3]=c,e[4]=w,e[5]=t,e[6]=m,e[7]=u,e[8]=b,e[9]=i,e[10]=y}else y=e[10];let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsxs(kt,{children:[s.jsx(Et,{children:"Add user"}),s.jsx(Dt,{children:"They sign in with this username and password. Their prompts are recorded and visible to admins."})]}),e[11]=N):N=e[11];const v=`${r}-username`;let C;e[12]!==v||e[13]!==i?(C=s.jsx(ls,{id:v,value:i,onChange:o,autoComplete:"off",autoFocus:!0}),e[12]=v,e[13]=i,e[14]=C):C=e[14];const $=`${r}-display-name`;let k;e[15]!==c||e[16]!==$?(k=s.jsx(as,{id:$,value:c,onChange:d,autoComplete:"off"}),e[15]=c,e[16]=$,e[17]=k):k=e[17];const T=`${r}-role`;let U;e[18]!==T?(U=s.jsx(q,{id:T,children:"Role"}),e[18]=T,e[19]=U):U=e[19];let O;e[20]!==u?(O=[u],e[20]=u,e[21]=O):O=e[21];let D;e[22]!==a?(D=Le=>{const oe=a.find(Ie=>Ie===Le.at(-1));oe&&f(oe)},e[22]=a,e[23]=D):D=e[23];const E=`${r}-role`;let P;e[24]!==a?(P=a.map(hl),e[24]=a,e[25]=P):P=e[25];let L;e[26]!==O||e[27]!==D||e[28]!==E||e[29]!==P?(L=s.jsx(st,{value:O,onValueChange:D,variant:"outline",size:"sm",spacing:0,"aria-labelledby":E,children:P}),e[26]=O,e[27]=D,e[28]=E,e[29]=P,e[30]=L):L=e[30];let R;e[31]!==l?(R=l&&s.jsx(tt,{children:Xt}),e[31]=l,e[32]=R):R=e[32];let I;e[33]!==L||e[34]!==R||e[35]!==U?(I=s.jsxs(Q,{children:[U,L,R]}),e[33]=L,e[34]=R,e[35]=U,e[36]=I):I=e[36];const G=`${r}-password`;let H;e[37]!==m||e[38]!==x||e[39]!==G?(H=s.jsx(ct,{id:G,label:"Password",placeholder:"Password",value:m,onChange:h,visible:x,onVisibleChange:p}),e[37]=m,e[38]=x,e[39]=G,e[40]=H):H=e[40];let z;e[41]!==I||e[42]!==H||e[43]!==C||e[44]!==k?(z=s.jsxs(Tt,{children:[C,k,I,H]}),e[41]=I,e[42]=H,e[43]=C,e[44]=k,e[45]=z):z=e[45];let B;e[46]!==j?(B=j&&s.jsxs(ee,{variant:"destructive",children:[s.jsx(lt,{}),s.jsx(te,{children:j})]}),e[46]=j,e[47]=B):B=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Xs,{render:s.jsx(F,{type:"button",variant:"outline"}),children:"Cancel"}),e[48]=M):M=e[48];const ie=g||w;let Y;e[49]!==g?(Y=g&&s.jsx(Yt,{"data-icon":"inline-start",className:"animate-spin"}),e[49]=g,e[50]=Y):Y=e[50];let W;e[51]!==ie||e[52]!==Y?(W=s.jsxs(Zs,{children:[M,s.jsxs(F,{type:"submit",disabled:ie,children:[Y,"Add user"]})]}),e[51]=ie,e[52]=Y,e[53]=W):W=e[53];let je;return e[54]!==z||e[55]!==y||e[56]!==B||e[57]!==W?(je=s.jsxs("form",{onSubmit:y,className:"flex flex-col gap-4",children:[N,z,B,W]}),e[54]=z,e[55]=y,e[56]=B,e[57]=W,e[58]=je):je=e[58],je}function hl(n){return s.jsx(Oe,{value:n,children:it[n]},n)}const dt={"7d":{label:"7 days",days:7},"30d":{label:"30 days",days:30}},rs="30d",xl={too_long:`Choose a range of ${Me} days or less.`,too_old:`Usage is kept for the last ${Me} days only.`};function pl(n){return n==="custom"||typeof n=="string"&&Object.hasOwn(dt,n)}function is(n,e){return Zt(dt[n].days,e)}function gl(n,e,t){const l=Gn(n),r=zn(e);if(l===null||r===null)return{ok:!1,error:"Enter a start and an end date."};if(l>t)return{ok:!1,error:"The range cannot start in the future."};const a={from:l,to:Math.min(r,t)};if(a.from>a.to)return{ok:!1,error:"The start date must be on or before the end date."};const i=In(a,t);return i?{ok:!1,error:xl[i]}:{ok:!0,range:a}}function jl({from:n,to:e}){return`${K(n)} – ${K(e)}`}function bl(n){const e=A.c(29),{range:t,onRangeChange:l}=n,r=_.useId(),[a,i]=_.useState(rs);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={from:"",to:""},e[0]=o):o=e[0];const[c,d]=_.useState(o),[u,f]=_.useState(null),[m]=_.useState(yl);let h;e[1]!==l||e[2]!==t?(h=function(k){i(k),f(null),k==="custom"?d({from:Ge(t.from),to:Ge(t.to)}):l(is(k,Date.now()))},e[1]=l,e[2]=t,e[3]=h):h=e[3];const x=h;let p;e[4]!==l?(p=function(k){d(k);const T=gl(k.from,k.to,Date.now());f(T.ok?null:T.error),T.ok&&l(T.range)},e[4]=l,e[5]=p):p=e[5];const g=p;let j;e[6]!==a?(j=[a],e[6]=a,e[7]=j):j=e[7];let b;e[8]!==a||e[9]!==x?(b=$=>{const k=$.at(-1);pl(k)&&k!==a&&x(k)},e[8]=a,e[9]=x,e[10]=b):b=e[10];let S,w;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=Object.entries(dt).map(wl),w=s.jsx(Oe,{value:"custom",children:"Custom"}),e[11]=S,e[12]=w):(S=e[11],w=e[12]);let y;e[13]!==j||e[14]!==b?(y=s.jsxs(st,{value:j,onValueChange:b,variant:"outline",size:"sm",spacing:0,"aria-label":"Usage range",children:[S,w]}),e[13]=j,e[14]=b,e[15]=y):y=e[15];let N;e[16]!==a||e[17]!==c||e[18]!==g||e[19]!==u||e[20]!==r||e[21]!==m?(N=a==="custom"&&s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[s.jsxs(Q,{className:"w-40",children:[s.jsx(q,{htmlFor:`${r}-from`,children:"From"}),s.jsx(de,{id:`${r}-from`,type:"date",value:c.from,max:m,"aria-invalid":u!==null,onChange:$=>g({...c,from:$.target.value})})]}),s.jsxs(Q,{className:"w-40",children:[s.jsx(q,{htmlFor:`${r}-to`,children:"To"}),s.jsx(de,{id:`${r}-to`,type:"date",value:c.to,max:m,"aria-invalid":u!==null,onChange:$=>g({...c,to:$.target.value})})]})]}),e[16]=a,e[17]=c,e[18]=g,e[19]=u,e[20]=r,e[21]=m,e[22]=N):N=e[22];let v;e[23]!==u?(v=u&&s.jsx(Ze,{children:u}),e[23]=u,e[24]=v):v=e[24];let C;return e[25]!==v||e[26]!==y||e[27]!==N?(C=s.jsxs("div",{className:"flex flex-col gap-2",children:[y,N,v]}),e[25]=v,e[26]=y,e[27]=N,e[28]=C):C=e[28],C}function wl(n){const[e,t]=n;return s.jsx(Oe,{value:e,children:t.label},e)}function yl(){return Ge(Date.now())}const be="text-right tabular-nums",we="—";function Sl(n){const e=A.c(3),{usd:t}=n;if(t===null){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx("span",{title:Ce.title,children:Ce.text}),e[0]=r):r=e[0],r}let l;return e[1]!==t?(l=t===0?"$0":Ot(t),e[1]=t,e[2]=l):l=e[2],l}function os(n){const e=A.c(17),{figures:t}=n,l=(t==null?void 0:t.sessions)??we;let r;e[0]!==l?(r=s.jsx(V,{className:be,children:l}),e[0]=l,e[1]=r):r=e[1];const a=(t==null?void 0:t.prompts)??we;let i;e[2]!==a?(i=s.jsx(V,{className:be,children:a}),e[2]=a,e[3]=i):i=e[3];let o;e[4]!==t?(o=t?Pt(es(t.tokens)):we,e[4]=t,e[5]=o):o=e[5];let c;e[6]!==o?(c=s.jsx(V,{className:be,children:o}),e[6]=o,e[7]=c):c=e[7];let d;e[8]!==t?(d=t?s.jsx(Sl,{usd:t.costUsd}):we,e[8]=t,e[9]=d):d=e[9];let u;e[10]!==d?(u=s.jsx(V,{className:be,children:d}),e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==r||e[13]!==i||e[14]!==c||e[15]!==u?(f=s.jsxs(s.Fragment,{children:[r,i,c,u]}),e[12]=r,e[13]=i,e[14]=c,e[15]=u,e[16]=f):f=e[16],f}const Nl=8,vl={tokens:{input:0,output:0,cacheRead:0,cacheWrite:0},costUsd:0,sessions:0,prompts:0};function Cl(n,e){return e?Ue()?"This hub signs in to the device as you, so the change signs the hub out there too. Afterwards, update the password this hub saved for the device in Devices.":"You are signed out everywhere, this browser included, and sign in again with the new password.":`${n.displayName} is signed out everywhere and signs in with the new password.`}function _l(n){const e=A.c(29),{user:t,isSelf:l,onDone:r}=n,a=_.useId(),[i,o]=_.useState(""),[c,d]=_.useState(!1),{busy:u,error:f,setError:m,run:h}=ge();let x;e[0]!==l||e[1]!==r||e[2]!==i||e[3]!==h||e[4]!==m||e[5]!==t?(x=async function(){if(i.length<ue){m(`Use at least ${ue} characters.`);return}await h(()=>ss(t.id,{password:i}))&&(he.success(l?"Password changed":`Password reset for ${t.displayName}`),r())},e[0]=l,e[1]=r,e[2]=i,e[3]=h,e[4]=m,e[5]=t,e[6]=x):x=e[6];const p=x,g=l?"Change password":"Reset password";let j;e[7]!==p?(j=()=>void p(),e[7]=p,e[8]=j):j=e[8];const b=`${a}-password`,S=l?"Your new password":`New password for ${t.displayName}`;let w;e[9]!==i||e[10]!==b||e[11]!==S||e[12]!==c?(w=s.jsx(ct,{id:b,label:S,placeholder:"New password",value:i,onChange:o,visible:c,onVisibleChange:d,autoFocus:!0}),e[9]=i,e[10]=b,e[11]=S,e[12]=c,e[13]=w):w=e[13];let y;e[14]!==l||e[15]!==t?(y=Cl(t,l),e[14]=l,e[15]=t,e[16]=y):y=e[16];let N;e[17]!==y?(N=s.jsx("p",{className:"text-xs text-muted-foreground",children:y}),e[17]=y,e[18]=N):N=e[18];let v;e[19]!==w||e[20]!==N?(v=s.jsxs("div",{className:"flex max-w-md flex-col gap-2",children:[w,N]}),e[19]=w,e[20]=N,e[21]=v):v=e[21];let C;return e[22]!==u||e[23]!==f||e[24]!==r||e[25]!==g||e[26]!==j||e[27]!==v?(C=s.jsx(_t,{error:f,busy:u,saveLabel:g,onCancel:r,onSave:j,className:"border-t-0 bg-muted/40",children:v}),e[22]=u,e[23]=f,e[24]=r,e[25]=g,e[26]=j,e[27]=v,e[28]=C):C=e[28],C}function $l(n){const e=A.c(33),{user:t,isSelf:l,noNewAdmins:r,onSelect:a}=n,i=r&&t.role==="member"&&!t.disabled,o=r&&t.role==="admin"&&t.disabled===!0;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(ae,{className:"font-normal",children:Xt}),e[0]=c):c=e[0];const d=c,u=`Actions for ${t.displayName}`;let f;e[1]!==u?(f=s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":u}),e[1]=u,e[2]=f):f=e[2];let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Cn,{}),e[3]=m):m=e[3];let h;e[4]!==f?(h=s.jsx(qe,{render:f,children:m}),e[4]=f,e[5]=h):h=e[5];const x=l||i||o?"w-56":"w-44";let p;e[6]!==a?(p=()=>a("password"),e[6]=a,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(at,{}),e[8]=g):g=e[8];const j=l?"Change password":"Reset password";let b;e[9]!==p||e[10]!==j?(b=s.jsxs(X,{onClick:p,children:[g,j]}),e[9]=p,e[10]=j,e[11]=b):b=e[11];let S;e[12]!==l||e[13]!==a||e[14]!==i||e[15]!==t.role?(S=l?null:i?d:s.jsxs(X,{onClick:()=>a("role"),children:[s.jsx(Vt,{}),t.role==="admin"?"Make member":"Make admin"]}),e[12]=l,e[13]=a,e[14]=i,e[15]=t.role,e[16]=S):S=e[16];let w;e[17]!==b||e[18]!==S?(w=s.jsxs(Z,{children:[b,S]}),e[17]=b,e[18]=S,e[19]=w):w=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Se,{}),e[20]=y):y=e[20];let N;e[21]!==o||e[22]!==l||e[23]!==a||e[24]!==t.disabled?(N=s.jsx(Z,{children:l?s.jsx(ae,{className:"font-normal",children:"Ask another admin to change your role or disable your account."}):o?d:t.disabled?s.jsxs(X,{onClick:()=>a("status"),children:[s.jsx(Nn,{}),"Enable"]}):s.jsxs(X,{variant:"destructive",onClick:()=>a("status"),children:[s.jsx(vn,{}),"Disable"]})}),e[21]=o,e[22]=l,e[23]=a,e[24]=t.disabled,e[25]=N):N=e[25];let v;e[26]!==w||e[27]!==N||e[28]!==x?(v=s.jsxs(Qe,{align:"end",className:x,children:[w,y,N]}),e[26]=w,e[27]=N,e[28]=x,e[29]=v):v=e[29];let C;return e[30]!==v||e[31]!==h?(C=s.jsxs(Xe,{children:[h,v]}),e[30]=v,e[31]=h,e[32]=C):C=e[32],C}function Al(n){const e=A.c(61),{user:t,usage:l,isSelf:r,noNewAdmins:a,onChanged:i}=n,[o,c]=_.useState(null),d=t.displayName;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=function(Y){Y||c(null)},e[0]=u):u=e[0];const f=u;let m;e[1]!==i||e[2]!==t.id?(m=async function(Y){const W=await ss(t.id,Y);return W.ok?(c(null),i(),null):W.error},e[1]=i,e[2]=t.id,e[3]=m):m=e[3];const h=m;let x;e[4]!==d?(x=s.jsx("span",{className:"truncate",children:d}),e[4]=d,e[5]=x):x=e[5];let p;e[6]!==r?(p=r&&s.jsx(ne,{variant:"outline",children:"You"}),e[6]=r,e[7]=p):p=e[7];let g;e[8]!==x||e[9]!==p?(g=s.jsxs("span",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[x,p]}),e[8]=x,e[9]=p,e[10]=g):g=e[10];let j;e[11]!==t.username?(j=s.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",t.username]}),e[11]=t.username,e[12]=j):j=e[12];let b;e[13]!==g||e[14]!==j?(b=s.jsx(V,{children:s.jsxs("div",{className:"flex min-w-0 flex-col",children:[g,j]})}),e[13]=g,e[14]=j,e[15]=b):b=e[15];const S=t.role==="admin"?"secondary":"outline",w=it[t.role];let y;e[16]!==S||e[17]!==w?(y=s.jsx(V,{children:s.jsx(ne,{variant:S,children:w})}),e[16]=S,e[17]=w,e[18]=y):y=e[18];let N;e[19]!==t.disabled?(N=s.jsx(V,{children:t.disabled?s.jsx(ne,{variant:"destructive",children:"Disabled"}):s.jsx("span",{className:"text-muted-foreground",children:"Active"})}),e[19]=t.disabled,e[20]=N):N=e[20];let v;e[21]!==l?(v=s.jsx(os,{figures:l}),e[21]=l,e[22]=v):v=e[22];let C;e[23]!==r||e[24]!==a||e[25]!==t?(C=s.jsx(V,{className:"text-right",children:s.jsx($l,{user:t,isSelf:r,noNewAdmins:a,onSelect:c})}),e[23]=r,e[24]=a,e[25]=t,e[26]=C):C=e[26];let $;e[27]!==y||e[28]!==N||e[29]!==v||e[30]!==C||e[31]!==b?($=s.jsxs(ve,{children:[b,y,N,v,C]}),e[27]=y,e[28]=N,e[29]=v,e[30]=C,e[31]=b,e[32]=$):$=e[32];let k;e[33]!==o||e[34]!==r||e[35]!==t?(k=o==="password"&&s.jsx(ve,{className:"hover:bg-transparent",children:s.jsx(V,{colSpan:Nl,className:"p-0 whitespace-normal",children:s.jsx(_l,{user:t,isSelf:r,onDone:()=>c(null)})})}),e[33]=o,e[34]=r,e[35]=t,e[36]=k):k=e[36];const T=o==="role",U=t.role==="admin"?`Make ${d} a member?`:`Make ${d} an admin?`,O=t.role==="admin"?`${d} loses access to People, the license and other members' sessions, and is signed out.`:`${d} can manage people, the license and every session, and is signed out to pick up the new role.`,D=t.role==="admin"?"Make member":"Make admin";let E;e[37]!==h||e[38]!==t.role?(E=()=>h({role:t.role==="admin"?"member":"admin"}),e[37]=h,e[38]=t.role,e[39]=E):E=e[39];let P;e[40]!==T||e[41]!==U||e[42]!==O||e[43]!==D||e[44]!==E?(P=s.jsx(pt,{open:T,onOpenChange:f,title:U,description:O,confirmLabel:D,onConfirm:E}),e[40]=T,e[41]=U,e[42]=O,e[43]=D,e[44]=E,e[45]=P):P=e[45];const L=o==="status",R=t.disabled?`Enable ${d}?`:`Disable ${d}?`,I=t.disabled?`${d} can sign in again and takes a license seat.`:`${d} is signed out now and cannot sign in until enabled again. Their sessions stay on this server.`,G=t.disabled?"Enable user":"Disable user",H=!t.disabled;let z;e[46]!==h||e[47]!==t.disabled?(z=()=>h({disabled:!t.disabled}),e[46]=h,e[47]=t.disabled,e[48]=z):z=e[48];let B;e[49]!==L||e[50]!==R||e[51]!==I||e[52]!==G||e[53]!==H||e[54]!==z?(B=s.jsx(pt,{open:L,onOpenChange:f,title:R,description:I,confirmLabel:G,destructive:H,onConfirm:z}),e[49]=L,e[50]=R,e[51]=I,e[52]=G,e[53]=H,e[54]=z,e[55]=B):B=e[55];let M;return e[56]!==$||e[57]!==k||e[58]!==P||e[59]!==B?(M=s.jsxs(s.Fragment,{children:[$,k,P,B]}),e[56]=$,e[57]=k,e[58]=P,e[59]=B,e[60]=M):M=e[60],M}function kl(n){const e=A.c(33),{users:t,usage:l,usageLoading:r,currentUserId:a,noNewAdmins:i,onUserChanged:o}=n;let c;e[0]!==(l==null?void 0:l.rows)?(c=new Map(l==null?void 0:l.rows.map(El)),e[0]=l==null?void 0:l.rows,e[1]=c):c=e[1];const d=c,u=r&&"opacity-60";let f;e[2]!==u?(f=se("transition-opacity",u),e[2]=u,e[3]=f):f=e[3];let m,h,x,p,g,j,b;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(J,{children:"User"}),x=s.jsx(J,{children:"Role"}),p=s.jsx(J,{children:"Status"}),g=s.jsx(J,{className:"text-right",children:"Sessions"}),j=s.jsx(J,{className:"text-right",children:"Prompts"}),b=s.jsx(J,{className:"text-right",children:"Tokens"}),m=s.jsx(J,{className:"text-right",children:"Est. cost"}),e[4]=m,e[5]=h,e[6]=x,e[7]=p,e[8]=g,e[9]=j,e[10]=b):(m=e[4],h=e[5],x=e[6],p=e[7],g=e[8],j=e[9],b=e[10]);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(en,{children:s.jsxs(ve,{className:"hover:bg-transparent",children:[h,x,p,g,j,b,m,s.jsx(J,{children:s.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e[11]=S):S=e[11];let w;if(e[12]!==a||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==d||e[17]!==t){let C;e[19]!==a||e[20]!==i||e[21]!==o||e[22]!==l||e[23]!==d?(C=$=>s.jsx(Al,{user:$,usage:l?d.get($.id)??vl:null,isSelf:$.id===a,noNewAdmins:i,onChanged:o},$.id),e[19]=a,e[20]=i,e[21]=o,e[22]=l,e[23]=d,e[24]=C):C=e[24],w=t.map(C),e[12]=a,e[13]=i,e[14]=o,e[15]=l,e[16]=d,e[17]=t,e[18]=w}else w=e[18];let y;e[25]!==l?(y=(l==null?void 0:l.unattributed)&&s.jsxs(ve,{className:"text-muted-foreground",children:[s.jsx(V,{children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"font-medium",children:"Unattributed"}),s.jsx("span",{className:"text-xs",children:"Not tied to a recorded prompt"})]})}),s.jsx(V,{}),s.jsx(V,{}),s.jsx(os,{figures:l.unattributed}),s.jsx(V,{})]}),e[25]=l,e[26]=y):y=e[26];let N;e[27]!==w||e[28]!==y?(N=s.jsxs(tn,{children:[w,y]}),e[27]=w,e[28]=y,e[29]=N):N=e[29];let v;return e[30]!==N||e[31]!==f?(v=s.jsxs(sn,{className:f,children:[S,N]}),e[30]=N,e[31]=f,e[32]=v):v=e[32],v}function El(n){return[n.user.id,n]}function Dl(n){const e=A.c(37),{users:t,onUsersChanged:l,noNewAdmins:r}=n,[a,i]=_.useState(Tl),o=qt(a),[c,d]=_.useState(!1),{user:u}=xe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_e,{children:"Users"}),e[0]=f):f=e[0];let m;e[1]!==a?(m=jl(a),e[1]=a,e[2]=m):m=e[2];let h;e[3]!==m?(h=s.jsxs(et,{children:["Usage ",m,", estimated at API prices."]}),e[3]=m,e[4]=h):h=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Ct,{children:s.jsxs(F,{size:"sm",onClick:()=>d(!0),children:[s.jsx(_n,{"data-icon":"inline-start"}),"Add user"]})}),e[5]=x):x=e[5];let p;e[6]!==h?(p=s.jsxs($e,{children:[f,h,x]}),e[6]=h,e[7]=p):p=e[7];let g;e[8]!==a?(g=s.jsx(bl,{range:a,onRangeChange:i}),e[8]=a,e[9]=g):g=e[9];let j;e[10]!==t.error||e[11]!==t.refresh?(j=t.error&&s.jsx(fe,{title:"Users could not load",message:t.error,onRetry:t.refresh}),e[10]=t.error,e[11]=t.refresh,e[12]=j):j=e[12];let b;e[13]!==o.error||e[14]!==o.refresh?(b=o.error&&s.jsx(fe,{title:"Usage could not load",message:o.error,onRetry:o.refresh}),e[13]=o.error,e[14]=o.refresh,e[15]=b):b=e[15];let S;e[16]!==(u==null?void 0:u.id)||e[17]!==r||e[18]!==l||e[19]!==o.data||e[20]!==o.loading||e[21]!==t.data||e[22]!==t.loading?(S=t.data?s.jsx(kl,{users:t.data.users,usage:o.data,usageLoading:o.loading,currentUserId:(u==null?void 0:u.id)??null,noNewAdmins:r,onUserChanged:l}):t.loading&&s.jsx(ot,{label:"Loading users…"}),e[16]=u==null?void 0:u.id,e[17]=r,e[18]=l,e[19]=o.data,e[20]=o.loading,e[21]=t.data,e[22]=t.loading,e[23]=S):S=e[23];let w;e[24]!==g||e[25]!==j||e[26]!==b||e[27]!==S?(w=s.jsxs(Ae,{className:"flex flex-col gap-3",children:[g,j,b,S]}),e[24]=g,e[25]=j,e[26]=b,e[27]=S,e[28]=w):w=e[28];let y;e[29]!==c||e[30]!==r||e[31]!==l?(y=s.jsx(fl,{open:c,onOpenChange:d,onCreated:l,noNewAdmins:r}),e[29]=c,e[30]=r,e[31]=l,e[32]=y):y=e[32];let N;return e[33]!==w||e[34]!==y||e[35]!==p?(N=s.jsxs(ke,{children:[p,w,y]}),e[33]=w,e[34]=y,e[35]=p,e[36]=N):N=e[36],N}function Tl(){return is(rs,Date.now())}function cs(n){var $,k,T,U;const e=A.c(35),{onClose:t,lockout:l}=n,r=ce("/api/team/users"),a=ce("/api/team/license"),i=ce("/api/team/health"),o=l==null?void 0:l.onRestored,c=($=a.data)==null?void 0:$.state;let d,u;e[0]!==c||e[1]!==o?(d=()=>{c&&c!=="locked"&&(o==null||o())},u=[c,o],e[0]=c,e[1]=o,e[2]=d,e[3]=u):(d=e[2],u=e[3]),_.useEffect(d,u);let f;e[4]!==i||e[5]!==a?(f=function(){a.refresh(),i.refresh()},e[4]=i,e[5]=a,e[6]=f):f=e[6];const m=f;let h;e[7]!==m||e[8]!==r?(h=function(){r.refresh(),m()},e[7]=m,e[8]=r,e[9]=h):h=e[9];const x=h;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx("h2",{className:"truncate text-sm font-semibold",children:"People"}),e[10]=p):p=e[10];let g;e[11]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(Wt,{}),e[11]=g):g=e[11];let j;e[12]!==t?(j=s.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-3 border-b px-4 py-2",children:[p,s.jsx(F,{variant:"ghost",size:"icon-sm",className:"ml-auto","aria-label":"Close People",onClick:t,children:g})]}),e[12]=t,e[13]=j):j=e[13];let b;e[14]!==i.data||e[15]!==i.refresh?(b=i.data&&s.jsx(el,{health:i.data,onChanged:i.refresh}),e[14]=i.data,e[15]=i.refresh,e[16]=b):b=e[16];const S=c==="locked";let w;e[17]!==x||e[18]!==S||e[19]!==r?(w=s.jsx(Dl,{users:r,onUsersChanged:x,noNewAdmins:S}),e[17]=x,e[18]=S,e[19]=r,e[20]=w):w=e[20];let y;e[21]!==l||e[22]!==((k=r.data)==null?void 0:k.users)?(y=!l&&s.jsx(il,{users:((T=r.data)==null?void 0:T.users)??[]}),e[21]=l,e[22]=(U=r.data)==null?void 0:U.users,e[23]=y):y=e[23];let N;e[24]!==m||e[25]!==a?(N=s.jsx(al,{license:a,onInstalled:m}),e[24]=m,e[25]=a,e[26]=N):N=e[26];let v;e[27]!==w||e[28]!==y||e[29]!==N||e[30]!==b?(v=s.jsx(nn,{className:"min-h-0 flex-1",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 p-4",children:[b,w,y,N]})}),e[27]=w,e[28]=y,e[29]=N,e[30]=b,e[31]=v):v=e[31];let C;return e[32]!==v||e[33]!==j?(C=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,v]}),e[32]=v,e[33]=j,e[34]=C):C=e[34],C}const ds="people";function us(n){return n.edition==="team"&&n.user!==null&&n.can("manageUsers")}const Pl={id:ds,label:"People",icon:rt,keywords:"team users members accounts usage cost license unassigned sessions admin",isAvailable:us,openOnStart:Fn,locksSwipe:!0,Component:cs};function fs(n){const e=A.c(5),{className:t}=n;let l;e[0]!==t?(l=se("flex items-start gap-1.5 text-xs text-muted-foreground",t),e[0]=t,e[1]=l):l=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx($n,{"aria-hidden":"true",className:"mt-px size-3.5 shrink-0"}),e[2]=r):r=e[2];let a;return e[3]!==l?(a=s.jsxs("p",{className:l,children:[r,"Your prompts are recorded and visible to admins."]}),e[3]=l,e[4]=a):a=e[4],a}const ms=30;function Ol(n){const e=A.c(25),{onLogout:t,onOpenMainView:l,mobile:r,className:a}=n,i=r===void 0?!1:r,{user:o,hubUser:c}=xe();let d;e[0]!==o?(d=Ln(o)?o:null,e[0]=o,e[1]=d):d=e[1];const u=d,f=u??c;if(!f)return null;const m=i?"icon-lg":"icon-sm",h=`Account: ${f.displayName}`;let x;e[2]!==a?(x=se("rounded-full",a),e[2]=a,e[3]=x):x=e[3];let p;e[4]!==m||e[5]!==h||e[6]!==x?(p=s.jsx(F,{variant:"ghost",size:m,"aria-label":h,className:x}),e[4]=m,e[5]=h,e[6]=x,e[7]=p):p=e[7];let g;e[8]!==f?(g=Ml(f),e[8]=f,e[9]=g):g=e[9];let j;e[10]!==g?(j=s.jsx("span",{"aria-hidden":"true",className:"flex size-6 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-foreground",children:g}),e[10]=g,e[11]=j):j=e[11];let b;e[12]!==p||e[13]!==j?(b=s.jsx(qe,{render:p,children:j}),e[12]=p,e[13]=j,e[14]=b):b=e[14];let S;e[15]!==f||e[16]!==c||e[17]!==i||e[18]!==t||e[19]!==l||e[20]!==u?(S=s.jsx(Qe,{align:"end",sideOffset:6,className:"w-72",children:u?s.jsx(Ul,{user:u,hubUser:c,onLogout:t,onOpenMainView:l,mobile:i}):s.jsx(hs,{hubUser:f,onLogout:t,mobile:i})}),e[15]=f,e[16]=c,e[17]=i,e[18]=t,e[19]=l,e[20]=u,e[21]=S):S=e[21];let w;return e[22]!==S||e[23]!==b?(w=s.jsxs(Xe,{children:[b,S]}),e[22]=S,e[23]=b,e[24]=w):w=e[24],w}function Ul(n){const e=A.c(31),{user:t,hubUser:l,onLogout:r,onOpenMainView:a,mobile:i}=n,[o]=_.useState(Rl),c=qt(o).data,d=ln();let u;e[0]!==d?(u=us(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=Ue(),e[2]=m):m=e[2];const h=m;let x;e[3]!==t.displayName?(x=s.jsx("span",{className:"truncate text-sm text-foreground",children:t.displayName}),e[3]=t.displayName,e[4]=x):x=e[4];const p=it[t.role];let g;e[5]!==p||e[6]!==t.username?(g=s.jsxs("span",{className:"truncate font-normal",children:["@",t.username," · ",p]}),e[5]=p,e[6]=t.username,e[7]=g):g=e[7];let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=h&&s.jsx(Ll,{}),e[8]=j):j=e[8];let b;e[9]!==x||e[10]!==g?(b=s.jsx(Z,{children:s.jsxs(ae,{className:"flex flex-col gap-0.5",children:[x,g,j]})}),e[9]=x,e[10]=g,e[11]=b):b=e[11];let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Se,{}),e[12]=S):S=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsxs(ae,{children:["My usage · ",ms," days"]}),e[13]=w):w=e[13];let y;e[14]!==c||e[15]!==t.id?(y=s.jsxs(Z,{children:[w,s.jsx(Il,{usage:c,userId:t.id})]}),e[14]=c,e[15]=t.id,e[16]=y):y=e[16];let N;e[17]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(fs,{className:"px-1.5 pt-1 pb-1.5"}),e[17]=N):N=e[17];let v;e[18]!==i||e[19]!==a||e[20]!==f?(v=f&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{}),s.jsx(Z,{children:s.jsxs(X,{onClick:()=>a(ds),className:se(i&&"min-h-10"),children:[s.jsx(rt,{}),"People"]})})]}),e[18]=i,e[19]=a,e[20]=f,e[21]=v):v=e[21];let C;e[22]!==l||e[23]!==i||e[24]!==r?(C=l&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{}),s.jsx(hs,{hubUser:l,onLogout:r,mobile:i})]}),e[22]=l,e[23]=i,e[24]=r,e[25]=C):C=e[25];let $;return e[26]!==y||e[27]!==v||e[28]!==C||e[29]!==b?($=s.jsxs(s.Fragment,{children:[b,S,y,N,v,C]}),e[26]=y,e[27]=v,e[28]=C,e[29]=b,e[30]=$):$=e[30],$}function Rl(){return Zt(ms,Date.now())}function hs(n){const e=A.c(12),{hubUser:t,onLogout:l,mobile:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ue(),e[0]=a):a=e[0];const i=a;let o;e[1]!==t?(o=i&&s.jsxs(ae,{className:"font-normal",children:["Signed in to this hub as ",t.displayName]}),e[1]=t,e[2]=o):o=e[2];const c=r&&"min-h-10";let d;e[3]!==c?(d=se(c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Kt,{}),e[5]=u):u=e[5];let f;e[6]!==l||e[7]!==d?(f=s.jsxs(X,{onClick:l,className:d,children:[u,i?"Log out of this hub":"Log out"]}),e[6]=l,e[7]=d,e[8]=f):f=e[8];let m;return e[9]!==o||e[10]!==f?(m=s.jsxs(Z,{children:[o,f]}),e[9]=o,e[10]=f,e[11]=m):m=e[11],m}function Ll(){const n=A.c(2),{activeDevice:e,activeDeviceId:t}=Ut(),l=(e==null?void 0:e.name)??t;let r;return n[0]!==l?(r=s.jsxs("span",{className:"truncate font-normal",children:["On ",l]}),n[0]=l,n[1]=r):r=n[1],r}function Il(n){const e=A.c(6),{usage:t,userId:l}=n;if(!t){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx("p",{className:"px-1.5 pb-1 text-sm text-muted-foreground",children:"—"}),e[0]=a):a=e[0],a}let r;if(e[1]!==t.rows||e[2]!==l){let a;e[4]!==l?(a=c=>c.user.id===l,e[4]=l,e[5]=a):a=e[5];const i=t.rows.find(a),o=i?i.costUsd:0;r=s.jsxs("p",{className:"flex items-baseline justify-between gap-2 px-1.5 pb-1 text-sm tabular-nums",children:[s.jsxs("span",{children:[Pt(i?es(i.tokens):0)," tokens"]}),o===null?s.jsx("span",{className:"text-muted-foreground",title:Ce.title,children:Ce.text}):s.jsxs("span",{className:"text-muted-foreground",title:"Estimated cost",children:["≈ ",Ot(o)]})]}),e[1]=t.rows,e[2]=l,e[3]=r}else r=e[3];return r}function Ml(n){const e=n.displayName.trim().split(/\s+/).filter(Boolean);return(e.length>0?e.slice(0,2).map(l=>l[0]):[n.username[0]??"?"]).join("").toUpperCase()}const bt="Until then, members cannot sign in and admins can only manage the license and accounts.",Re={expired:{title:"Your Cogpit Team license has expired",deviceTitle:n=>`${n}’s Cogpit Team license has expired`,description:`Install a new key in People. ${bt}`},over_seats:{title:"More accounts are enabled than your license has seats",deviceTitle:n=>`${n} has more accounts enabled than its license has seats`,description:`Disable accounts or install a license with more seats in People. ${bt}`}};function Fl(n){return Object.hasOwn(Re,n)}const Gl=15e3;function zl(n){const e=A.c(3);let t,l;e[0]!==n?(t=()=>{const r=new AbortController,a=setInterval(()=>{me("/api/me",{signal:r.signal}).then(Hl).then(i=>{!i||i.gate||(clearInterval(a),n())}).catch(Bl)},Gl);return()=>{clearInterval(a),r.abort()}},l=[n],e[0]=n,e[1]=t,e[2]=l):(t=e[1],l=e[2]),_.useEffect(t,l)}function Bl(){}function Hl(n){return n.ok?re(n):null}function Vl(n){const e=A.c(6),{gate:t,onRestored:l,onLogout:r}=n;if(!Fl(t)){let i;return e[0]!==n?(i=s.jsx(an,{...n}),e[0]=n,e[1]=i):i=e[1],i}let a;return e[2]!==t||e[3]!==r||e[4]!==l?(a=s.jsx(Yl,{lapse:t,onRestored:l,onLogout:r}),e[2]=t,e[3]=r,e[4]=l,e[5]=a):a=e[5],a}function Yl(n){const e=A.c(17),{lapse:t,onRestored:l,onLogout:r}=n,[a,i]=_.useState(!1);let o;e[0]!==l||e[1]!==a?(o=()=>{a&&Mn(),l()},e[0]=l,e[1]=a,e[2]=o):o=e[2];const c=o;zl(c);let d;e[3]!==a||e[4]!==c?(d={open:a,setOpen:i,onRestored:c},e[3]=a,e[4]=c,e[5]=d):d=e[5];const u=d;if(Ue()){let p;return e[6]!==t||e[7]!==u?(p=s.jsx(Wl,{lapse:t,people:u}),e[6]=t,e[7]=u,e[8]=p):p=e[8],p}const f=Re[t];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Kt,{"data-icon":"inline-start"}),e[9]=m):m=e[9];let h;e[10]!==r?(h=s.jsxs(F,{variant:"outline",size:"sm",onClick:r,children:[m,"Sign out"]}),e[10]=r,e[11]=h):h=e[11];let x;return e[12]!==t||e[13]!==u||e[14]!==f.title||e[15]!==h?(x=s.jsx(xs,{title:f.title,lapse:t,people:u,children:h}),e[12]=t,e[13]=u,e[14]=f.title,e[15]=h,e[16]=x):x=e[16],x}function Wl(n){const e=A.c(9),{lapse:t,people:l}=n,{activeDevice:r,activeDeviceId:a}=Ut(),i=Re[t];let o;e[0]!==(r==null?void 0:r.name)||e[1]!==a||e[2]!==i?(o=i.deviceTitle((r==null?void 0:r.name)??a),e[0]=r==null?void 0:r.name,e[1]=a,e[2]=i,e[3]=o):o=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsxs(F,{variant:"outline",size:"sm",onClick:Kl,children:[s.jsx(An,{"data-icon":"inline-start"}),"Switch to this machine"]}),e[4]=c):c=e[4];let d;return e[5]!==t||e[6]!==l||e[7]!==o?(d=s.jsx(xs,{title:o,lapse:t,people:l,children:c}),e[5]=t,e[6]=l,e[7]=o,e[8]=d):d=e[8],d}function Kl(){return on(cn)}function xs(n){const e=A.c(26),{title:t,lapse:l,people:r,children:a}=n,{open:i,setOpen:o,onRestored:c}=r;if(i){let S;e[0]!==o?(S=()=>o(!1),e[0]=o,e[1]=S):S=e[1];let w;e[2]!==c?(w={onRestored:c},e[2]=c,e[3]=w):w=e[3];let y;return e[4]!==S||e[5]!==w?(y=s.jsx("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:s.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:s.jsx(cs,{onClose:S,lockout:w})})}),e[4]=S,e[5]=w,e[6]=y):y=e[6],y}let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Ke,{variant:"icon",children:s.jsx(at,{className:"text-destructive"})}),e[7]=d):d=e[7];let u;e[8]!==t?(u=s.jsx(Te,{children:t}),e[8]=t,e[9]=u):u=e[9];const f=Re[l];let m;e[10]!==f.description?(m=s.jsx(Pe,{children:f.description}),e[10]=f.description,e[11]=m):m=e[11];let h;e[12]!==u||e[13]!==m?(h=s.jsxs(De,{children:[d,u,m]}),e[12]=u,e[13]=m,e[14]=h):h=e[14];let x;e[15]!==o?(x=()=>o(!0),e[15]=o,e[16]=x):x=e[16];let p;e[17]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(rt,{"data-icon":"inline-start"}),e[17]=p):p=e[17];let g;e[18]!==x?(g=s.jsxs(F,{size:"sm",onClick:x,children:[p,"Open People"]}),e[18]=x,e[19]=g):g=e[19];let j;e[20]!==a||e[21]!==g?(j=s.jsxs(rn,{className:"flex-row justify-center",children:[g,a]}),e[20]=a,e[21]=g,e[22]=j):j=e[22];let b;return e[23]!==j||e[24]!==h?(b=s.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:s.jsxs(Ee,{children:[h,j]})}),e[23]=j,e[24]=h,e[25]=b):b=e[25],b}const ps="cogpit-session-scope",Jl=["all","mine","shared","unassigned"],gs=["all","mine","shared"],ql=[...gs,"unassigned"],Ql={scope:null,options:[]},ze=new Set,Xl={all:"All",mine:"Mine",shared:"Shared",unassigned:"Unassigned"};function Zl(){try{const n=localStorage.getItem(nt(ps));return Jl.find(e=>e===n)??"all"}catch{return"all"}}function js(n){try{localStorage.setItem(nt(ps),n)}catch{}for(const e of ze)e()}function bs(n){ze.add(n);const e=dn(n);return()=>{ze.delete(n),e()}}const wt=new Map;function Be(){if(un().edition!=="team")return Ql;const n=fn("viewAllSessions"),e=n?ql:gs,t=Zl(),l=e.includes(t)?t:"all",r=`${n?"admin":"member"}:${l}`;let a=wt.get(r);return a||(a={scope:l,options:e},wt.set(r,a)),a}function ws(){return _.useSyncExternalStore(bs,Be,Be)}function ys(n){return n===null||n==="all"?null:n}const ea=Object.freeze({}),ta={mine:Object.freeze({scope:"mine"}),shared:Object.freeze({scope:"shared"}),unassigned:Object.freeze({scope:"unassigned"})};function yt(){return ys(Be().scope)}const sa={subscribe:bs,getKey:yt,getQuery(){const n=yt();return n===null?ea:ta[n]}},He=new Map;function Ss(){return nt("share-notices")}function Ns(n){for(const e of n.known)n.listed.add(e);mn(),Je()}function na(n){const e=Ss(),t=new Set(n.filter(a=>a.kind==="access").map(a=>a.id)),l=He.get(e),r={known:t,listed:(l==null?void 0:l.listed)??new Set};He.set(e,r),l&&[...t].some(a=>!l.known.has(a))&&Ns(r)}function la(){const n=He.get(Ss());n&&[...n.known].some(e=>!n.listed.has(e))&&Ns(n)}const aa={mine:{title:"You have no sessions here",description:"Sessions you start show up here."},shared:{title:"Nothing shared with you here",description:"Sessions teammates share with you show up here."},unassigned:{title:"Every session here has an owner",description:"New sessions belong to whoever starts them."}};function ra(n){const e=A.c(17),{className:t}=n,l=ws();let r;e[0]!==l.scope?(r=ys(l.scope),e[0]=l.scope,e[1]=r):r=e[1];const a=r;let i,o;if(e[2]!==a?(i=()=>{a==="shared"&&la()},o=[a],e[2]=a,e[3]=i,e[4]=o):(i=e[3],o=e[4]),_.useEffect(i,o),a===null)return null;const{title:c,description:d}=aa[a];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ke,{variant:"icon",children:s.jsx(Jt,{})}),e[5]=u):u=e[5];let f;e[6]!==c?(f=s.jsx(Te,{children:c}),e[6]=c,e[7]=f):f=e[7];let m;e[8]!==d?(m=s.jsx(Pe,{children:d}),e[8]=d,e[9]=m):m=e[9];let h;e[10]!==f||e[11]!==m?(h=s.jsxs(De,{children:[u,f,m]}),e[10]=f,e[11]=m,e[12]=h):h=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsxs(F,{variant:"outline",size:"sm",onClick:ia,children:[s.jsx(kn,{"data-icon":"inline-start"}),"Show all"]}),e[13]=x):x=e[13];let p;return e[14]!==t||e[15]!==h?(p=s.jsxs(Ee,{className:t,children:[h,x]}),e[14]=t,e[15]=h,e[16]=p):p=e[16],p}function ia(){return js("all")}function oa(n){return"owner"in n&&"inheritsFrom"in n}function ca({owner:n,inheritsFrom:e}){return n?{label:n.displayName,title:`Owned by ${n.displayName}`}:e?{label:"Unassigned parent",title:"Its parent session has no owner yet"}:{label:"Unassigned",title:"No owner yet"}}function da(n){const e=A.c(8),{access:t}=n;if(!t||t.mine||!oa(t))return null;let l;e[0]!==t?(l=ca(t),e[0]=t,e[1]=l):l=e[1];const{label:r,title:a}=l;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(En,{"data-icon":"inline-start"}),e[2]=i):i=e[2];let o;e[3]!==r?(o=s.jsx("span",{className:"truncate",children:r}),e[3]=r,e[4]=o):o=e[4];let c;return e[5]!==o||e[6]!==a?(c=s.jsxs(ne,{variant:"outline","data-session-owner":!0,className:"max-w-36",title:a,children:[i,o]}),e[5]=o,e[6]=a,e[7]=c):c=e[7],c}function ua(){const n=A.c(11),{scope:e,options:t}=ws();if(e===null)return null;let l;n[0]!==e?(l=[e],n[0]=e,n[1]=l):l=n[1];let r;n[2]!==t||n[3]!==e?(r=o=>{const c=t.find(d=>d===o.at(-1));c&&c!==e&&js(c)},n[2]=t,n[3]=e,n[4]=r):r=n[4];let a;n[5]!==t?(a=t.map(fa),n[5]=t,n[6]=a):a=n[6];let i;return n[7]!==l||n[8]!==r||n[9]!==a?(i=s.jsx("div",{className:"shrink-0 border-b px-2.5 py-2",children:s.jsx(st,{value:l,onValueChange:r,variant:"outline",size:"sm",spacing:0,className:"w-full","aria-label":"Whose sessions to list",children:a})}),n[7]=l,n[8]=r,n[9]=a,n[10]=i):i=n[10],i}function fa(n){return s.jsx(Oe,{value:n,className:"min-w-fit flex-1 px-2 text-xs",children:Xl[n]},n)}const ma="Could not update access. Try again.",ha=["view","interact","own"];function ut(n){return`/api/team/session-access/${encodeURIComponent(n)}`}function vs(n,e){return`${ut(n)}/grants/${encodeURIComponent(e)}`}function Cs(n){const e=n;return ha.includes(e==null?void 0:e.level)&&Array.isArray(e==null?void 0:e.grants)}async function ft(n){try{return await n()}catch{return null}}async function mt(n){const e=await ft(n),t=await re(e);return e!=null&&e.ok&&Cs(t)?{ok:!0,detail:t}:{ok:!1,superseded:(e==null?void 0:e.status)===409&&(t==null?void 0:t.code)==="superseded",error:typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:ma}}async function Ve(n,e){const t=Rt(),l=await ft(()=>me(ut(n),{signal:e})),r=await re(l);return!(l!=null&&l.ok)||!Cs(r)?null:(Lt(n,r.level,t),r)}async function xa(n){const e=await re(await ft(()=>me("/api/team/directory",{signal:n}))),t=e==null?void 0:e.users;return Array.isArray(t)?t:null}function pa(n,e,t){return mt(()=>Ye(vs(n,e),{mode:t},{method:"PUT"}))}function ga(n,e){return mt(()=>me(vs(n,e),{method:"DELETE"}))}function ja(n,e){return mt(()=>Ye(`${ut(n)}/owner`,{userId:e},{method:"PUT"}))}function ba(n){const e=A.c(3),{sessionId:t}=n,[l,r]=_.useState(null);let a,i;e[0]!==t?(a=()=>{const c=new AbortController;return Ve(t,c.signal).then(d=>{!c.signal.aborted&&d&&r({sessionId:t,user:d.owner})}),()=>c.abort()},i=[t],e[0]=t,e[1]=a,e[2]=i):(a=e[1],i=e[2]),_.useEffect(a,i);const o=(l==null?void 0:l.sessionId)===t?l.user:null;return o?`Shared with you by ${o.displayName} · view only`:"View only"}const Ne="__cogpitBootstrapToken";function wa(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},l=e||(typeof t[Ne]=="string"?t[Ne]:"");return e&&window.history.replaceState({...t,[Ne]:e},"",`${window.location.pathname}${window.location.search}`),l}function St(){const n={...window.history.state||{}};delete n[Ne],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function ya({onAuthenticated:n,onSetupClosed:e}){const[t]=_.useState(wa),[l,r]=_.useState(""),[a,i]=_.useState(""),[o,c]=_.useState(""),[d,u]=_.useState(""),[f,m]=_.useState(!1),[h,x]=_.useState(null),[p,g]=_.useState(!1),j=d.length>0&&d!==o,b=!t||!l.trim()||o.length<ue||d!==o,S=_.useCallback(async w=>{if(w.preventDefault(),!b){g(!0),x(null);try{const y=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify(ns({username:l,displayName:a,password:o}))}),N=await y.json();if(y.ok){St(),c(""),u(""),r(""),i(""),await e(),n();return}if(y.status===410){St(),await e();return}x(N.error||"Could not create the admin account")}catch{x("Failed to connect to server")}finally{g(!1)}}},[t,a,b,n,e,o,l]);return s.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:s.jsx("form",{onSubmit:S,className:"w-full max-w-md",children:s.jsxs(ke,{children:[s.jsxs($e,{children:[s.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:s.jsx(Dn,{className:"size-4"})}),s.jsx(_e,{children:"Create the first admin"}),s.jsx(et,{children:"Set up the account that will manage this Cogpit team server."})]}),s.jsxs(Ae,{className:"flex flex-col gap-4",children:[!t&&s.jsxs(ee,{children:[s.jsx(Ht,{"aria-hidden":"true"}),s.jsx(le,{children:"Setup link required"}),s.jsx(te,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),s.jsxs(Tt,{children:[s.jsx(ls,{id:"bootstrap-username",value:l,onChange:r,autoComplete:"username",autoFocus:!0}),s.jsx(as,{id:"bootstrap-display-name",value:a,onChange:i,autoComplete:"name"}),s.jsx(ct,{id:"bootstrap-password",label:"Password",placeholder:"Password",value:o,onChange:c,visible:f,onVisibleChange:m}),s.jsxs(Q,{"data-invalid":j,children:[s.jsx(q,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),s.jsx(de,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:w=>u(w.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":j}),j&&s.jsx(Ze,{children:"Passwords do not match"})]})]}),h&&s.jsxs(ee,{variant:"destructive",children:[s.jsx(lt,{"aria-hidden":"true"}),s.jsx(le,{children:"Could not create the account"}),s.jsx(te,{children:h})]})]}),s.jsx(hn,{children:s.jsxs(F,{type:"submit",className:"w-full",disabled:p||b,children:[p&&s.jsx(We,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}const Nt=[{value:"view",label:"Can view"},{value:"interact",label:"Can interact"}];function ht(n){const e=A.c(10),{user:t,className:l}=n;let r;e[0]!==l?(r=se("flex min-w-0 items-baseline gap-1.5",l),e[0]=l,e[1]=r):r=e[1];let a;e[2]!==t.displayName?(a=s.jsx("span",{className:"truncate text-sm text-foreground",children:t.displayName}),e[2]=t.displayName,e[3]=a):a=e[3];let i;e[4]!==t.username?(i=s.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",t.username]}),e[4]=t.username,e[5]=i):i=e[5];let o;return e[6]!==r||e[7]!==a||e[8]!==i?(o=s.jsxs("span",{className:r,children:[a,i]}),e[6]=r,e[7]=a,e[8]=i,e[9]=o):o=e[9],o}function _s(n){const e=A.c(12),{label:t,value:l,onChange:r,size:a}=n;let i;e[0]!==r||e[1]!==l?(i=f=>{f&&f!==l&&r(f)},e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Gt,{}),e[3]=o):o=e[3];let c;e[4]!==t||e[5]!==a?(c=s.jsx(zt,{size:a,"aria-label":t,className:"w-32 shrink-0",children:o}),e[4]=t,e[5]=a,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Mt,{children:s.jsx(Ft,{children:Nt.map(Sa)})}),e[7]=d):d=e[7];let u;return e[8]!==i||e[9]!==c||e[10]!==l?(u=s.jsxs(Bt,{items:Nt,value:l,onValueChange:i,children:[c,d]}),e[8]=i,e[9]=c,e[10]=l,e[11]=u):u=e[11],u}function Sa(n){return s.jsx(It,{value:n.value,children:n.label},n.value)}function $s(n){const e=A.c(24),{label:t,users:l,value:r,placeholder:a,onChange:i,triggerRef:o,className:c}=n;let d;e[0]!==l?(d=l.map(va),e[0]=l,e[1]=d):d=e[1];const u=d,f=l.length===0;let m;e[2]!==i||e[3]!==l||e[4]!==r?(m=b=>{const S=l.find(w=>w.id===b);S&&S.id!==r&&i(S)},e[2]=i,e[3]=l,e[4]=r,e[5]=m):m=e[5];let h;e[6]!==a?(h=s.jsx(Gt,{placeholder:a}),e[6]=a,e[7]=h):h=e[7];let x;e[8]!==c||e[9]!==t||e[10]!==h||e[11]!==o?(x=s.jsx(zt,{ref:o,"aria-label":t,className:c,children:h}),e[8]=c,e[9]=t,e[10]=h,e[11]=o,e[12]=x):x=e[12];let p;e[13]!==l?(p=l.map(Na),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==p?(g=s.jsx(Mt,{children:s.jsx(Ft,{children:p})}),e[15]=p,e[16]=g):g=e[16];let j;return e[17]!==u||e[18]!==f||e[19]!==m||e[20]!==x||e[21]!==g||e[22]!==r?(j=s.jsxs(Bt,{items:u,value:r,disabled:f,onValueChange:m,children:[x,g]}),e[17]=u,e[18]=f,e[19]=m,e[20]=x,e[21]=g,e[22]=r,e[23]=j):j=e[23],j}function Na(n){return s.jsx(It,{value:n.id,children:s.jsx(ht,{user:n})},n.id)}function va(n){return{value:n.id,label:n.displayName}}function Ca(n){const e=A.c(10),{grants:t,onModeChange:l,onRemove:r}=n;if(t.length===0){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ee,{className:"gap-1 border p-4",children:s.jsxs(De,{children:[s.jsx(Te,{children:"Not shared with anyone yet"}),s.jsx(Pe,{className:"text-xs",children:"Only the owner and admins can open this session."})]})}),e[0]=o):o=e[0],o}let a;if(e[1]!==t||e[2]!==l||e[3]!==r){let o;e[5]!==l||e[6]!==r?(o=c=>s.jsxs("li",{className:"flex items-center gap-1.5 py-1.5 pr-1.5 pl-3",children:[s.jsx(ht,{user:c.user,className:"flex-1"}),s.jsx(_s,{size:"sm",label:`Access for ${c.user.displayName}`,value:c.mode,onChange:d=>l(c.user,d)}),s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${c.user.displayName}`,onClick:()=>r(c.user),children:s.jsx(Wt,{"data-icon":"inline-start"})})]},c.user.id),e[5]=l,e[6]=r,e[7]=o):o=e[7],a=t.map(o),e[1]=t,e[2]=l,e[3]=r,e[4]=a}else a=e[4];let i;return e[8]!==a?(i=s.jsx("ul",{"aria-label":"People with access",className:"flex flex-col divide-y rounded-lg border bg-card",children:a}),e[8]=a,e[9]=i):i=e[9],i}const _a="Someone else changed access — refreshed.";function ye(n,e){return t=>{const l=t.grants.filter(a=>a.user.id!==n),r=e?[...l,e].sort((a,i)=>a.grantedAt-i.grantedAt):l;return{...t,grants:r}}}function vt(n){return e=>({...e,...n})}function $a(n){const e=A.c(31),{user:t}=xe(),[l,r]=_.useState(!0),[a,i]=_.useState(null),[o,c]=_.useState(null),[d,u]=_.useState(null),[f,m]=_.useState(0),h=_.useRef(0),x=_.useRef(null);let p;e[0]!==n?(p=()=>{const D=new AbortController;return Promise.all([Ve(n,D.signal),xa(D.signal)]).then(E=>{var R;const[P,L]=E;D.signal.aborted||(x.current=((R=P==null?void 0:P.owner)==null?void 0:R.id)??null,i(P),c(L),r(!1))}),()=>D.abort()},e[0]=n,e[1]=p):p=e[1];let g;e[2]!==f||e[3]!==n?(g=[n,f],e[2]=f,e[3]=n,e[4]=g):g=e[4],_.useEffect(p,g);let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=function(){r(!0),m(Aa)},e[5]=j):j=e[5];const b=j;let S;e[6]!==n?(S=async function(E,P,L){var z,B;const R=h.current=h.current+1,I=Rt();u(null),i(M=>M&&E(M));const G=await L();if(G.ok){R===h.current&&i(G.detail),Lt(n,G.detail.level,I);const M=((z=G.detail.owner)==null?void 0:z.id)??null;M!==x.current&&Je(),x.current=M;return}if(i(M=>M&&P(M)),!G.superseded){u({tone:"error",text:G.error});return}u({tone:"notice",text:_a});const H=await Ve(n);H&&(x.current=((B=H.owner)==null?void 0:B.id)??null,i(H))},e[6]=n,e[7]=S):S=e[7];const w=S;let y;e[8]!==(a==null?void 0:a.grants)?(y=function(E){return(a==null?void 0:a.grants.find(P=>P.user.id===E))??null},e[8]=a==null?void 0:a.grants,e[9]=y):y=e[9];const N=y;let v;e[10]!==N||e[11]!==w||e[12]!==n||e[13]!==(t==null?void 0:t.id)?(v=function(E,P){const L=N(E.id),R=L?{...L,mode:P}:{user:E,mode:P,grantedBy:(t==null?void 0:t.id)??"",grantedAt:Date.now()};w(ye(E.id,R),ye(E.id,L),()=>pa(n,E.id,P))},e[10]=N,e[11]=w,e[12]=n,e[13]=t==null?void 0:t.id,e[14]=v):v=e[14];const C=v;let $;e[15]!==N||e[16]!==w||e[17]!==n?($=function(E){w(ye(E.id,null),ye(E.id,N(E.id)),()=>ga(n,E.id))},e[15]=N,e[16]=w,e[17]=n,e[18]=$):$=e[18];const k=$;let T;e[19]!==a||e[20]!==w||e[21]!==n?(T=function(E){if(!a)return;const{inheritsFrom:P,canHoldGrants:L}=a;w(vt({owner:E,inheritsFrom:null,canHoldGrants:!0}),vt({owner:a.owner,inheritsFrom:P,canHoldGrants:L}),()=>ja(n,E.id))},e[19]=a,e[20]=w,e[21]=n,e[22]=T):T=e[22];const U=T;let O;return e[23]!==U||e[24]!==a||e[25]!==o||e[26]!==C||e[27]!==l||e[28]!==d||e[29]!==k?(O={loading:l,detail:a,directory:o,message:d,retry:b,grant:C,revoke:k,changeOwner:U},e[23]=U,e[24]=a,e[25]=o,e[26]=C,e[27]=l,e[28]=d,e[29]=k,e[30]=O):O=e[30],O}function Aa(n){return n+1}function ka(n){const e=A.c(10),{sessionId:t,open:l,onOpenChange:r}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsxs(kt,{children:[s.jsx(Et,{children:"Share with team"}),s.jsx(Dt,{children:"View: read the session. Interact: also send messages, stop, and answer prompts."})]}),e[0]=a):a=e[0];let i;e[1]!==r?(i=()=>r(!1),e[1]=r,e[2]=i):i=e[2];let o;e[3]!==t||e[4]!==i?(o=s.jsxs($t,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md",children:[a,s.jsx(Da,{sessionId:t,onClose:i},t)]}),e[3]=t,e[4]=i,e[5]=o):o=e[5];let c;return e[6]!==r||e[7]!==l||e[8]!==o?(c=s.jsx(At,{open:l,onOpenChange:r,children:o}),e[6]=r,e[7]=l,e[8]=o,e[9]=c):c=e[9],c}function Ea(n,e){return e&&!n.some(t=>t.id===e.id)?[e,...n]:n}function Da(n){var L;const e=A.c(44),{sessionId:t,onClose:l}=n,{user:r}=xe(),a=xn("manageUsers"),{loading:i,detail:o,directory:c,message:d,retry:u,grant:f,revoke:m,changeOwner:h}=$a(t);if(i){let R;return e[0]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsxs("p",{className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[s.jsx(We,{className:"size-4"})," Loading…"]}),e[0]=R):R=e[0],R}if(!o){let R;return e[1]!==u?(R=s.jsx(fe,{title:"Couldn't load who has access",message:"The server did not answer. Try again in a moment.",onRetry:u}),e[1]=u,e[2]=R):R=e[2],R}const x=r==null?void 0:r.id,p=(L=o.owner)==null?void 0:L.id;let g;e[3]!==o.grants||e[4]!==x||e[5]!==p?(g=new Set([x,p,...o.grants.map(Ta)]),e[3]=o.grants,e[4]=x,e[5]=p,e[6]=g):g=e[6];const j=g;let b;e[7]!==c||e[8]!==j?(b=(c==null?void 0:c.filter(R=>!j.has(R.id)))??null,e[7]=c,e[8]=j,e[9]=b):b=e[9];const S=b,{inheritsFrom:w}=o,y=w?null:o.owner;let N;e[10]!==c||e[11]!==a||e[12]!==y?(N=a&&c?Ea(c,y):null,e[10]=c,e[11]=a,e[12]=y,e[13]=N):N=e[13];const v=N,C=w?o.owner?`Through parent: ${o.owner.displayName}`:"Unassigned parent":"Unassigned";let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx("span",{className:"text-sm text-muted-foreground",children:"Owner"}),e[14]=$):$=e[14];let k;e[15]!==h||e[16]!==y||e[17]!==v||e[18]!==C?(k=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[$,v?s.jsx($s,{label:"Change owner",users:v,value:(y==null?void 0:y.id)??null,placeholder:C,onChange:h,className:"min-w-44"}):y?s.jsx(ht,{user:y,className:"justify-end"}):s.jsx("span",{className:"text-sm text-muted-foreground",children:C})]}),e[15]=h,e[16]=y,e[17]=v,e[18]=C,e[19]=k):k=e[19];let T;e[20]!==w||e[21]!==v?(T=v&&w&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"An owner of its own makes this session independent: it stops sharing its parent session's access."}),e[20]=w,e[21]=v,e[22]=T):T=e[22];let U;e[23]!==k||e[24]!==T?(U=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[k,T]}),e[23]=k,e[24]=T,e[25]=U):U=e[25];let O;e[26]!==S||e[27]!==o.canHoldGrants||e[28]!==f||e[29]!==w||e[30]!==l?(O=o.canHoldGrants?s.jsx(Oa,{candidates:S,onAdd:f}):s.jsx(Pa,{inheritsFrom:w,onParentOpened:l}),e[26]=S,e[27]=o.canHoldGrants,e[28]=f,e[29]=w,e[30]=l,e[31]=O):O=e[31];let D;e[32]!==d?(D=d&&s.jsx(Ua,{message:d}),e[32]=d,e[33]=D):D=e[33];let E;e[34]!==o.canHoldGrants||e[35]!==o.grants||e[36]!==f||e[37]!==m?(E=o.canHoldGrants&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-xs font-medium text-muted-foreground",children:"People with access"}),s.jsx(Ca,{grants:o.grants,onModeChange:f,onRemove:m})]}),e[34]=o.canHoldGrants,e[35]=o.grants,e[36]=f,e[37]=m,e[38]=E):E=e[38];let P;return e[39]!==O||e[40]!==D||e[41]!==E||e[42]!==U?(P=s.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[U,O,D,E]}),e[39]=O,e[40]=D,e[41]=E,e[42]=U,e[43]=P):P=e[43],P}function Ta(n){return n.user.id}function Pa(n){const e=A.c(14),{inheritsFrom:t,onParentOpened:l}=n,[r,a]=_.useState(!1);if(!t){let x;return e[0]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsxs(ee,{role:"note",children:[s.jsx(Tn,{}),s.jsx(le,{children:"Assign an owner first"}),s.jsx(te,{children:"Only a session with an owner can be shared."})]}),e[0]=x):x=e[0],x}let i;e[1]!==l?(i=async function(p){a(!1),await pn(p)?l():a(!0)},e[1]=l,e[2]=i):i=e[2];const o=i;let c,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(Pn,{}),d=s.jsx(le,{children:"Shared through its parent session"}),e[3]=c,e[4]=d):(c=e[3],d=e[4]);let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("span",{children:"Whoever can open the parent can open this one. Share the parent to change who."}),e[5]=u):u=e[5];let f;e[6]!==t||e[7]!==o?(f=s.jsx(F,{variant:"link",className:"h-auto p-0",onClick:()=>void o(t),children:"Open parent session"}),e[6]=t,e[7]=o,e[8]=f):f=e[8];let m;e[9]!==r?(m=r&&s.jsx("span",{role:"alert",className:"text-destructive",children:"Couldn't open the parent session."}),e[9]=r,e[10]=m):m=e[10];let h;return e[11]!==f||e[12]!==m?(h=s.jsxs(ee,{role:"note",children:[c,d,s.jsxs(te,{className:"flex flex-col items-start gap-1",children:[u,f,m]})]}),e[11]=f,e[12]=m,e[13]=h):h=e[13],h}function Oa(n){const e=A.c(22),{candidates:t,onAdd:l}=n,[r,a]=_.useState(null),[i,o]=_.useState("view"),c=_.useRef(null);let d;e[0]!==t?(d=t??[],e[0]=t,e[1]=d):d=e[1];const u=d;let f;e[2]!==u||e[3]!==r?(f=r&&u.some(N=>N.id===r.id)?r:null,e[2]=u,e[3]=r,e[4]=f):f=e[4];const m=f;let h;e[5]!==i||e[6]!==l||e[7]!==m?(h=function(v){var C;v.preventDefault(),m&&(l(m,i),a(null),(C=c.current)==null||C.focus())},e[5]=i,e[6]=l,e[7]=m,e[8]=h):h=e[8];const x=h,p=(m==null?void 0:m.id)??null,g=t===null?"Couldn't load teammates":u.length===0?"No one else to add":"Choose a teammate";let j;e[9]!==u||e[10]!==p||e[11]!==g?(j=s.jsx($s,{label:"Teammate",users:u,value:p,placeholder:g,onChange:a,triggerRef:c,className:"min-w-0 flex-1"}),e[9]=u,e[10]=p,e[11]=g,e[12]=j):j=e[12];let b;e[13]!==i?(b=s.jsx(_s,{label:"Access for new teammate",value:i,onChange:o}),e[13]=i,e[14]=b):b=e[14];const S=!m;let w;e[15]!==S?(w=s.jsx(F,{type:"submit",disabled:S,children:"Add"}),e[15]=S,e[16]=w):w=e[16];let y;return e[17]!==x||e[18]!==j||e[19]!==b||e[20]!==w?(y=s.jsxs("form",{onSubmit:x,className:"flex items-center gap-2",children:[j,b,w]}),e[17]=x,e[18]=j,e[19]=b,e[20]=w,e[21]=y):y=e[21],y}function Ua(n){const e=A.c(6),{message:t}=n,l=t.tone==="error",r=l?"alert":"status",a=l?"text-destructive":"text-muted-foreground";let i;e[0]!==a?(i=se("text-xs",a),e[0]=a,e[1]=i):i=e[1];let o;return e[2]!==t.text||e[3]!==r||e[4]!==i?(o=s.jsx("p",{role:r,className:i,children:t.text}),e[2]=t.text,e[3]=r,e[4]=i,e[5]=o):o=e[5],o}function Ra(n){const e=A.c(4),{sessionId:t}=n,{edition:l}=xe(),{permissions:r}=gn(),[a,i]=_.useState(!1);if(l!=="team"||!r.canOwn)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(jn,{icon:Jt,label:"Share with team…",size:"default",onClick:()=>i(!0)}),e[0]=o):o=e[0];let c;return e[1]!==a||e[2]!==t?(c=s.jsxs(s.Fragment,{children:[o,s.jsx(ka,{sessionId:t,open:a,onOpenChange:i})]}),e[1]=a,e[2]=t,e[3]=c):c=e[3],c}const La={SetupScreen:ya,LoginNotice:fs,GateScreen:Vl,AccountControl:Ol,SessionHeaderActions:Ra,SessionBadges:da,ReadOnlyNote:ba,mainViews:[Pl],sessionListFilter:{...sa,Control:ua,Empty:ra},onInboxRead:na},Ha={edition:"team",ui:La};export{Ha as default};