@preventive/triage 1.0.0-alpha.67 → 1.0.0-alpha.68

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 (35) hide show
  1. package/common/managed/routes.js +19 -12
  2. package/out/activity.js +1 -1
  3. package/out/{chunk-LBJVV6UB.js → chunk-2F3CYNPZ.js} +1 -1
  4. package/out/{chunk-U5C2TNNQ.js → chunk-2HGKTQ5Q.js} +1 -1
  5. package/out/chunk-4RS3NDOG.js +1 -0
  6. package/out/{chunk-VR3NRE5V.js → chunk-D37M7J4B.js} +1 -1
  7. package/out/{chunk-LDO42LAC.js → chunk-GZ46SSTF.js} +1 -1
  8. package/out/{chunk-R3WUYD4F.js → chunk-HETCVNO4.js} +1 -1
  9. package/out/{chunk-5F5FPI75.js → chunk-MPXVKVPF.js} +1 -1
  10. package/out/{chunk-A5A3LEMV.js → chunk-OAWY4T6R.js} +1 -1
  11. package/out/{chunk-6YGH7BJG.js → chunk-QPGM3DTI.js} +1 -1
  12. package/out/{chunk-FUHRMY7R.js → chunk-SCN2TBP2.js} +5 -5
  13. package/out/client-managed-import.js +1 -1
  14. package/out/client-managed.js +2 -2
  15. package/out/compare.js +8 -8
  16. package/out/dialogs.js +2 -2
  17. package/out/graph.js +1 -1
  18. package/out/index.html +7 -7
  19. package/out/scan.js +1 -1
  20. package/out/view.css +1 -1
  21. package/out/view.js +1 -1
  22. package/package.json +1 -1
  23. package/server-managed/bundle-build-worker.js +59 -7
  24. package/server-managed/bundle-build.ts +9 -4
  25. package/server-managed/db-neon.ts +4 -1
  26. package/server-managed/dependency-review-comments.ts +13 -10
  27. package/server-managed/dependency-reviews.ts +17 -14
  28. package/server-managed/http.ts +65 -25
  29. package/server-managed/npm-patch.ts +101 -43
  30. package/server-managed/pull-dependencies.ts +9 -6
  31. package/server-managed/pull-dependency-reviews.ts +20 -11
  32. package/server-managed/repository-dependency-reviews.ts +4 -2
  33. package/server-managed/repository-issues.ts +3 -3
  34. package/server-managed/stasis-dependencies.ts +29 -12
  35. package/out/chunk-6ATPGDDI.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as e,c as t}from"./chunk-VG5RH6KN.js";import{g as n,n as r,r as i,s as a,t as o,u as s,v as c,w as l,x as u}from"./chunk-LBJVV6UB.js";import{a as d}from"./chunk-NRPC74AM.js";import{e as f,i as p}from"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import"./chunk-R3WUYD4F.js";import"./chunk-6ATPGDDI.js";import{D as m}from"./chunk-QRKFPLA4.js";import"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{a as h,c as g,g as _}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var v=`h1{font-size:1.35rem;margin-bottom:.5rem}h2{font-size:1.1rem;margin-bottom:.5rem}.triage-import{display:flex;gap:1rem;align-items:center;margin:1.5rem 0 2rem}.triage-import .btn{flex-shrink:0}.triage-import p{margin:0}.workspace-drop{display:grid;gap:.8rem;padding:2rem;margin:1.5rem 0;border:1px dashed var(--border);border-radius:var(--ui-radius, 8px)}.workspace-drop.dragging{border-color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.workspace-drop span,p,li span{color:var(--muted);line-height:1.5}.actions,.local-choice{display:flex;gap:.8rem;flex-wrap:wrap;align-items:center}.local-choice{margin-bottom:1.5rem}.import-preview{display:grid;gap:.8rem}input:not([type=radio]),select{padding:.55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);color:var(--text);background:var(--bg);font:inherit}.import-preview input:not([type=radio]),.import-preview select{width:100%;box-sizing:border-box}fieldset{display:grid;gap:.8rem;padding:1rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px)}fieldset label{display:flex;gap:.5rem;align-items:center}li{padding:.4rem 0;overflow-wrap:anywhere}li span{display:block;font-size:.8rem}ul{padding-left:1.2rem}.primary{justify-self:start;color:var(--accent)}.error{color:var(--critical)}button:disabled{opacity:.5}input:focus-visible,select:focus-visible,button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
1
+ import{a as e,c as t}from"./chunk-VG5RH6KN.js";import{g as n,n as r,r as i,s as a,t as o,u as s,v as c,w as l,x as u}from"./chunk-2F3CYNPZ.js";import{a as d}from"./chunk-NRPC74AM.js";import{e as f,i as p}from"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import"./chunk-HETCVNO4.js";import"./chunk-4RS3NDOG.js";import{D as m}from"./chunk-QRKFPLA4.js";import"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{a as h,c as g,g as _}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var v=`h1{font-size:1.35rem;margin-bottom:.5rem}h2{font-size:1.1rem;margin-bottom:.5rem}.triage-import{display:flex;gap:1rem;align-items:center;margin:1.5rem 0 2rem}.triage-import .btn{flex-shrink:0}.triage-import p{margin:0}.workspace-drop{display:grid;gap:.8rem;padding:2rem;margin:1.5rem 0;border:1px dashed var(--border);border-radius:var(--ui-radius, 8px)}.workspace-drop.dragging{border-color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.workspace-drop span,p,li span{color:var(--muted);line-height:1.5}.actions,.local-choice{display:flex;gap:.8rem;flex-wrap:wrap;align-items:center}.local-choice{margin-bottom:1.5rem}.import-preview{display:grid;gap:.8rem}input:not([type=radio]),select{padding:.55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);color:var(--text);background:var(--bg);font:inherit}.import-preview input:not([type=radio]),.import-preview select{width:100%;box-sizing:border-box}fieldset{display:grid;gap:.8rem;padding:1rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px)}fieldset label{display:flex;gap:.5rem;align-items:center}li{padding:.4rem 0;overflow-wrap:anywhere}li span{display:block;font-size:.8rem}ul{padding-left:1.2rem}.primary{justify-self:start;color:var(--accent)}.error{color:var(--critical)}button:disabled{opacity:.5}input:focus-visible,select:focus-visible,button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
2
2
  `;async function y(e,{session:t,confirmImport:n,...r}){if(t?.role!==`admin`||!t.csrfToken)throw Error(`An administrator session is required.`);if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw Error(`Invalid local triage.`);let i=Object.create(null);for(let[t,n]of Object.entries(e??{})){let{ignoredReports:e,scopedIgnoredReports:r,...a}=f(n)??{};Object.keys(a).length!==0&&(i[t]=a)}let a=Object.keys(i).length,o=new Set,s=[],c;if(a>0)do{r.signal?.throwIfAborted();let e=`/api/admin/reports/finding-ids`+(c?`?after=${encodeURIComponent(c)}`:``),{reports:t,nextCursor:n}=await r.api.send(e);r.signal?.throwIfAborted();for(let e of t){let t=e.findingIds.filter(e=>Object.hasOwn(i,e)&&!o.has(e));t.length>0&&s.push({id:e.id,ids:t});for(let e of t)o.add(e)}c=n}while(c);for(let e of o){if(!e||e.length>100)throw Error(`Triage finding IDs must be between 1 and 100 characters.`);if(u(i[e])===`invalid`)throw Error(`Triage for ${e} exceeds the managed server limits.`)}if(r.signal?.throwIfAborted(),n){let e=await n({matched:o.size,available:a});if(r.signal?.throwIfAborted(),!e)return null}let l=r.importedIds??new Set;for(let e of s)await C(i,{...r,importedIds:l,ids:e.ids,path:`/api/admin/reports/${encodeURIComponent(e.id)}/import-triage`});return o.size}function b(e,t){let n=[],r=Object.create(null);for(let[i,a]of Object.entries(e)){let e=t[i];if(!e)throw Error(`The server did not return the requested triage snapshot.`);let o=e.entry??{},s=r[i]={...o};delete s.comment;for(let[t,r]of Object.entries(a))if(t===`comment`){if(e.comments.some(e=>e.body===r))continue;e.comments.length>0?n.push({id:i,property:t,local:e.comments.map(e=>e.body).join(`
3
3
 
4
4
  `),imported:r}):s.comment=r}else if(o[t]!==void 0&&o[t]!==r){let e=e=>t===`flagged`?e?`flagged`:`not flagged`:e;n.push({id:i,property:t,local:e(o[t]),imported:e(r)})}else s[t]=r}return{entries:r,conflicts:n}}async function x(e,t,n,r,i){i?.throwIfAborted();let{entries:a,conflicts:o}=b(e,t);if(o.length===0)return a;let s=await r(o,n,{title:`Triage conflicts on import`,intro:`disagree with stored triage on`,trailingNote:`Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.`,importedSideLabel:`Apply imported`});if(i?.throwIfAborted(),!s)throw Object.assign(Error(`Triage conflict resolution was cancelled.`),{cancelled:!0});for(let t of o){let n=s[`${t.id}:${t.property}`];if(![`local`,`imported`].includes(n))throw Error(`Resolve every triage conflict before importing.`);n===`imported`&&(a[t.id][t.property]=e[t.id][t.property])}return a}function S(e,t){let n=[],r={entries:{},expected:{}};for(let[i,a]of Object.entries(e)){let e={entries:{...r.entries,[i]:a},expected:{...r.expected,[i]:t[i].version}};if(new TextEncoder().encode(JSON.stringify(e)).length<=262144)r=e;else{if(Object.keys(r.entries).length===0)throw Error(`This triage entry is too large to import.`);n.push(r),r={entries:{[i]:a},expected:{[i]:t[i].version}}}}return Object.keys(r.entries).length>0&&n.push(r),n}async function C(e,{api:t,path:n,ids:r=Object.keys(e),importedIds:i=new Set,lookup:a=new Map,resolveConflicts:o,signal:s}){r=r.filter(t=>Object.hasOwn(e,t)&&!i.has(t));for(let c=0;c<r.length;c+=200){let l=r.slice(c,c+200);for(let r=0;r<5&&l.length>0;r++){s?.throwIfAborted();let{snapshots:r}=await t.send(n,{findingIds:l}),c=await x(Object.fromEntries(l.map(t=>[t,e[t]])),r,a,o,s);for(let e of S(c,r)){if(s?.throwIfAborted(),(await t.send(n,e)).conflict)break;Object.keys(e.entries).forEach(e=>i.add(e))}l=l.filter(e=>!i.has(e))}if(l.length>0)throw Error(`Stored triage keeps changing. Retry to resolve it against the latest values.`)}}var w=`You can retry the remaining steps.`;function T(e){return String(e?.detail??e?.message??e).replace(/\.$/u,``)}function E(e,t){return t?.aborted===!0||e?.name===`AbortError`||e?.cancelled===!0}function D(e){if(typeof e!=`string`)return{ok:!0,path:null};if(/\p{Cc}/u.test(e)||e.includes(`\\`)||e!==e.trim())return{ok:!1};let t=[];for(let n of e.split(`/`))if(n!==``&&n!==`.`){if(n===`..`||n!==n.trim())return{ok:!1};t.push(n)}let n=t.join(`/`);return n.length>500?{ok:!1}:{ok:!0,path:n===``?null:n}}async function O(e,t){let n=new Uint8Array(await e.arrayBuffer());return r(n)?t({tryPassword:e=>i(n,e)}):n[0]===31&&n[1]===139?i(n):a(new TextDecoder(`utf-8`,{fatal:!0}).decode(n))}function k(e,t,n,r,i=``){let a=e?d(e,t,r,i):null,o=n.find(t=>a?t.repoId===a.repoId:t.fullName.toLowerCase()===e?.toLowerCase());return{repoId:o?.repoId??null,directory:a?.directory??t,github:o?.fullName??e}}async function A(e,t,r=[]){let i=new Map,a=[];for(let n of e.reports){if(typeof n?.name!=`string`||!n.name||typeof n.content!=`string`)throw Error(`Every report must have a name and content.`);let u=o(n.content,n.name);if(!u.data)throw Error(`${n.name}: ${u.reason??`Unsupported report`}`);let d=m(u.data),f=d??m(n)??m({repo:{github:e.repoUrls?.[n.name]}})??c(u.data),p=d?``:l(u.data),h=D(u.data.repo?.directory);if(!h.ok)throw Error(`${n.name}: invalid repository directory`);let g=u.format===`links`?[]:(await s(n.content,n.name))?.findings??[];for(let e of g)e.id&&i.set(e.id,e);let _=h.path??``;a.push({...n,links:u.format===`links`,...k(f,_,t,r,p),declaredGithub:f,declaredDirectory:_,filePrefix:p,embedded:d,ids:[...new Set(g.map(e=>e.id).filter(Boolean))],uploaded:null})}let u=Object.create(null);if(e.triage!=null&&(typeof e.triage!=`object`||Array.isArray(e.triage)))throw Error(`Invalid workspace triage.`);let d=await n(e.triage,t=>e.reports.find(e=>e.name===t)?.content);for(let[e,t]of Object.entries(d.entries)){if(!i.has(e))continue;let n=f(t);if(!n)continue;let{ignoredReports:r,scopedIgnoredReports:a,...o}=n;Object.keys(o).length!==0&&(u[e]=o)}let p=[];for(let t of e.bundleBlobs??[]){let e=Uint8Array.fromBase64(t.data),n=`sha512-${new Uint8Array(await crypto.subtle.digest(`SHA-512`,e)).toBase64()}`;if(n!==t.integrity)throw Error(`${t.name}: bundle integrity mismatch`);p.push({name:t.name,integrity:n,bytes:e,uploaded:null})}return{name:e.workspace.name.slice(0,100),reports:a,bundles:p,triage:u,lookup:i,references:e.bundles??[],team:null,completed:new Set,importedIds:new Set}}function j(e,t,n){async function r(r,i,a={}){n?.throwIfAborted();let o=await e(r,{credentials:`same-origin`,signal:n,...i===void 0?{}:{method:`POST`,body:i instanceof File?i:JSON.stringify(i)},headers:{...i instanceof File?{}:{"content-type":`application/json`},"x-csrf-token":t.csrfToken,...a}});if(n?.throwIfAborted(),o.status===409)return{conflict:!0};if(!o.ok){let e=await o.json().then(e=>typeof e?.error==`string`?e.error:``,()=>``);n?.throwIfAborted();let t=`Import request failed (HTTP ${o.status}${e?`: ${e}`:``}).`;throw Object.assign(Error(`${t} ${w}`),{detail:t})}let s=await o.json();return n?.throwIfAborted(),s}return{send:r}}async function M(e,t,n,r,i,a){if(e.bundles.length===0&&e.references.length===0)return;let o=i??(await n.send(`/api/admin/bundles`)).bundles,s=new Set(e.bundles.map(e=>e.uploaded.id));if([...s].some(e=>!o.some(t=>t.id===e)))throw Error(`Could not verify the uploaded source bundles. Retry the import.`);let c=new Set(e.references);for(let i of o){if(!s.has(i.id)&&!c.has(i.integrity))continue;let o=!a.has(i.repoId),l=o?t:i.repoId;o&&await r(`bundle-repo:${i.id}:${l}`,()=>n.send(`/api/admin/bundles/set-repo`,{bundleId:i.id,repoId:l}));let u=o?``:i.repoDirectory??``;await r(`repo:${l}:${u}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:e.team.id,repoId:l,path:u}))}}async function N(e,t){e.uploaded||=await t.send(`/api/admin/deduplication`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name)})}async function P(e,t){let n=(await t.send(`/api/admin/repositories/browsable`)).repos,r=e.reports.filter(e=>!e.links&&e.declaredGithub&&!e.uploaded);if(r.length>0){let{aliases:e=[]}=await t.send(`/api/admin/repositories/aliases`);for(let t of r)Object.assign(t,k(t.declaredGithub,t.declaredDirectory,n,e,t.filePrefix))}return new Set(n.map(e=>e.repoId))}async function F(e,{plan:t,api:n,step:r,activeRepos:i,defaultRepo:a,includeTriage:o,resolveConflicts:s,signal:c}){if(e.links){await N(e,n);return}let l=i.has(e.repoId)?e.repoId:a;if(!e.uploaded){let t=await n.send(`/api/admin/reports`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name),"x-repo-id":String(l),"x-repo-directory":encodeURIComponent(e.directory)});if(t.conflict)throw Error(`Could not reuse the stored report ${e.name}. Retry the import.`);e.uploaded=t}let u=e.uploaded;i.has(u.repoId)||await r(`report-repo:${u.id}:${l}:${e.directory}`,async()=>{if((await n.send(`/api/admin/reports/set-repo`,{reportId:u.id,repoId:l,directory:e.directory})).conflict)throw Error(`Could not assign the stored report ${e.name} to its repository.`);u.repoId=l,u.repoDirectory=e.directory});let d=u.repoDirectory??``;await r(`repo:${u.repoId}:${d}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:t.team.id,repoId:u.repoId,path:d})),o&&await C(t.triage,{api:n,resolveConflicts:s,signal:c,ids:e.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(e.uploaded.id)}/import-triage`}),await r(`publish:${e.uploaded.id}`,()=>n.send(`/api/admin/reports/set-visible`,{reportId:e.uploaded.id,visible:!0}))}async function I(e,{api:t,session:n,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o,progress:s=()=>{}}){if(n?.role!==`admin`||!n.csrfToken)throw Error(`An administrator session is required.`);if(!e.name.trim()||e.name.trim().length>100)throw Error(`Enter a team name of up to 100 characters.`);if(i)for(let[t,n]of Object.entries(e.triage)){if(!t||t.length>100)throw Error(`Triage finding IDs must be between 1 and 100 characters. Choose Skip triage to import the files without it.`);if(u(n)===`invalid`)throw Error(`Triage for ${t} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}o?.throwIfAborted();let c=null;if(e.bundles.length===0){let n=new Set(e.references);c=n.size>0?(await t.send(`/api/admin/bundles`)).bundles.filter(e=>n.has(e.integrity)):[]}if(e.reports.length===0&&e.bundles.length===0&&c.length===0)throw Error(e.references.length>0?`None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.`:`This workspace contains no report or bundle files.`);let l=await P(e,t);for(let t of e.reports.filter(e=>!e.links)){if(t.embedded&&!l.has(t.repoId))throw Error(`Connect ${t.embedded} in Repositories before importing ${t.name}.`);if(!l.has(t.repoId)&&!l.has(r))throw Error(`Choose an active repository for ${t.name}.`)}if((e.bundles.length>0||c.some(e=>!l.has(e.repoId)))&&!l.has(r))throw Error(`Choose an active repository for the source bundles.`);let d=()=>o?.throwIfAborted(),f=async(t,n)=>{d(),e.completed.has(t)||(await n(),e.completed.add(t))};if(d(),!e.team){let n=await t.send(`/api/admin/teams`,{name:e.name.trim()});if(n.conflict)throw Error(`A team already has this name. Choose another name.`);e.team=n}await f(`member`,()=>t.send(`/api/admin/teams/set-member`,{teamId:e.team.id,userId:n.id,security:!0,dependencies:!0}));for(let n of e.bundles)d(),s(`Importing ${n.name}\u2026`),n.uploaded||=await t.send(`/api/admin/bundles`,new File([n.bytes],n.name),{"x-bundle-filename":encodeURIComponent(n.name)});await M(e,r,t,f,c,l);let p=[];for(let n of e.reports){d(),s(`Importing ${n.name}\u2026`);try{await F(n,{plan:e,api:t,step:f,activeRepos:l,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o})}catch(e){if(E(e,o))throw e;p.push(`${n.name}: ${T(e)}`)}}if(p.length>0)throw Error(`Could not import ${p.length} of ${e.reports.length} files: ${p.join(`; `)}. ${w}`);return e.team}function L(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),async read({signal:n}={}){let r=!1,i=e.onVaultStateChange(()=>{r=!0}),a=()=>{if(n?.throwIfAborted(),t()||r)throw Error(`Local data was locked or changed. Unlock it and import triage again.`)};try{a();let t=await e.readTriageBlob();return a(),t}finally{i()}}}}function R(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();async function n(){let t=JSON.parse(await e.hydrateKey(`deepview.workspaces`)||`[]`);return(Array.isArray(t)?t:t.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`)}async function r(n,r){let i=!1,a=[e.onVaultStateChange,e.onFileMutated,e.onBundleMutated].map(e=>e(()=>{i=!0})),o=()=>{if(r?.throwIfAborted(),t()||i)throw Error(`Local data was locked or changed. Unlock it and select the workspace again.`)};try{o();let e=await n(o);return o(),e}finally{a.forEach(e=>e())}}return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),list:({signal:e}={})=>r(async()=>(await n()).map(e=>({id:e.id,name:e.name})),e),read:(t,{signal:i}={})=>r(async r=>{let i=(await n()).find(e=>e.id===t);if(!i)throw Error(`This local workspace no longer exists.`);let a=JSON.stringify(i),o=JSON.parse(await e.hydrateKey(`deepview.repoUrls`)||`{}`),s=[];for(let t of i.reports??[]){r();let n=await e.withStoredItem(`report`,t,()=>e.readFile(t));r(),s.push({name:t,content:n,...o[t]?{repo:{github:o[t]}}:{}})}let c=await e.listBundles(),l=[];for(let t of i.bundles??[]){r();let n=c.find(e=>e.integrity===t);if(!n)continue;let i=await e.withStoredItem(`bundle`,t,()=>e.readBundle(t));r(),l.push({integrity:t,name:n.name,data:i.toBase64()})}let u=await e.readTriageBlob()??{};if(JSON.stringify((await n()).find(e=>e.id===t))!==a)throw Error(`The local workspace changed. Select it again.`);return{version:1,workspace:{id:t,name:i.name,privateKey:``},reports:s,bundles:i.bundles??[],bundleBlobs:l,triage:u,repoUrls:o}},i)}}var z=e=>e===`bundle`?`bundles`:`reports`,B=(e,t)=>JSON.stringify([e,t||``]),V=(e,t)=>new Set(t.map(t=>e===`bundle`?t.integrity:B(t.sha256,t.analyzer)));async function H(e){let t=new Uint8Array(await e.arrayBuffer()),n=o(new TextDecoder().decode(t),e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);let r=new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)).toBase64({alphabet:`base64url`,omitPadding:!0});return{hash:r,key:B(r,typeof n.data.source==`string`?n.data.source:null)}}async function U(e,{source:t,deps:n,api:r,signal:i}){let a=JSON.parse(await n.hydrateKey(`deepview.workspaces`)||`[]`),o=(Array.isArray(a)?a:a.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`);i.throwIfAborted();let s=await t.list(e),c=V(e,(await r.send(`/api/admin/${z(e)}`))[z(e)]),l=o.map(e=>({id:e.id,name:e.name,items:[]})),u={id:null,name:`Not in a workspace`,items:[]},d=[];for(let r of s){i.throwIfAborted();let a={value:r.value,name:r.label,key:r.value,synced:!1,present:!1,error:``};if(e===`report`)try{Object.assign(a,await t.importItem(e,a.value,H,{signal:i})),a.syncHash=await n.reportSyncHash(a.value)}catch(e){i.throwIfAborted(),a.error=String(e?.message??e)}i.throwIfAborted(),a.present=c.has(a.key);let s=!1;o.forEach((t,r)=>{if(!t[z(e)]?.includes(a.value))return;let i=n.localContentSyncStatus(t.id,e,a.value,a.syncHash);a.synced||=i.synced,l[r].items.push({item:a,...i}),s=!0}),s||u.items.push({item:a,synced:!1,cached:!1}),d.push(a)}return{kind:e,items:d,groups:[...l,u].filter(e=>e.items.length>0)}}async function W(e,t,{source:n,api:r,signal:i,progress:a=()=>{},imported:o=new Set}){let{kind:s}=e,c=V(s,(await r.send(`/api/admin/${z(s)}`))[z(s)]),l=new Set(t),u=[],d=0;for(let t of e.items)if(i.throwIfAborted(),!(!l.has(t.value)||t.error||t.present)){if(c.has(t.key)){t.present=!0;continue}a(`Importing ${t.name}\u2026`),d++;try{await n.importItem(s,t.value,async e=>{let n=s===`report`?(await H(e)).key:await p(new Uint8Array(await e.arrayBuffer()));if(i.throwIfAborted(),n!==t.key)throw Error(`${t.name} changed. Choose files again before importing.`);if((await r.send(`/api/admin/${z(s)}`,e,{[`x-${s}-filename`]:encodeURIComponent(e.name)})).conflict)throw Error(`Could not import ${t.name}. Try again.`)},{signal:i})}catch(e){if(E(e,i))throw e;u.push(`${t.name}: ${T(e)}`);continue}c.add(t.key),t.present=!0,o.add(t.value)}if(u.length>0)throw Error(`Imported ${d-u.length} of ${d} ${s}s. Could not import ${u.join(`; `)}. Import again to retry them.`);return o.size}var G=(e,t)=>e===void 0?`managed-only`:t===void 0?`local-only`:`mismatch`;function K(e,t){let n=t.slice(),r=e.map(e=>{let t=n.indexOf(e);return t!==-1&&n.splice(t,1),{text:e,different:t===-1}}),i=e.slice(),a=t.map(e=>{let t=i.indexOf(e);return t!==-1&&i.splice(t,1),{text:e,different:t===-1}});return!r.some(e=>e.different)&&!a.some(e=>e.different)?null:{property:`comment`,local:r,managed:a,kind:r.some(e=>e.different)?a.some(e=>e.different)?`mismatch`:`local-only`:`managed-only`}}function q(e,t){let n=f(e)??{},r=f(t.entry)??{},i=[];for(let e of[`triage`,`color`,`fix`,`flagged`])n[e]!==r[e]&&i.push({property:e,local:n[e],managed:r[e],kind:G(n[e],r[e])});let a=K(n.comment?[n.comment]:[],t.comments.map(e=>e.body));return a&&i.push(a),n.ignoredReports?.length&&i.push({property:`ignoredReports`,local:[...new Set(n.ignoredReports)],managed:void 0,kind:`local-only`}),i}async function J(e,{lookup:t,triage:n,matched:r,findings:i,api:a,signal:o}){let s=[...new Set(e.findingIds)].filter(e=>t.has(e)&&!r.has(e));for(let c=0;c<s.length;c+=200){let l=s.slice(c,c+200);if(l.some(e=>e.length>100))throw Error(`A shared finding ID exceeds the managed triage limit.`);o.throwIfAborted();let{snapshots:u}=await a.send(`/api/admin/reports/${encodeURIComponent(e.id)}/import-triage`,{findingIds:l});o.throwIfAborted();for(let e of l){if(!u?.[e])throw Error(`The server did not return the requested triage snapshot.`);let a=q(n[e],u[e]);a.length>0&&i.push({id:e,finding:t.get(e),differences:a}),r.add(e)}}}async function Y({source:e,readTriage:t,api:n,signal:r,progress:i=()=>{}}){let a=new Map,c=[];for(let t of await e.list(`report`)){r.throwIfAborted(),i(`Reading ${t.label}\u2026`);try{let n=await e.importItem(`report`,t.value,async e=>{let t=await e.text(),n=o(t,e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);return n.format===`links`?[]:(await s(t,e.name))?.findings??[]},{signal:r});r.throwIfAborted();for(let e of n)typeof e.id!=`string`||!e.id||(a.has(e.id)||a.set(e.id,{...e,reports:[]}),a.get(e.id).reports.push(t.label))}catch(e){r.throwIfAborted(),c.push({name:t.label,reason:String(e?.message??e)})}}let l=await t()??{};if(r.throwIfAborted(),typeof l!=`object`||Array.isArray(l))throw TypeError(`Invalid local triage.`);let u=[],d=new Set;if(a.size===0)return{matched:0,localFindings:0,findings:u,skipped:c};let f;do{r.throwIfAborted(),i(`Comparing local and managed triage…`);let e=await n.send(`/api/admin/reports/finding-ids`+(f?`?after=${encodeURIComponent(f)}`:``));r.throwIfAborted();for(let t of e.reports)await J(t,{lookup:a,triage:l,matched:d,findings:u,api:n,signal:r});f=e.nextCursor}while(f);return r.throwIfAborted(),{matched:d.size,localFindings:a.size,findings:u,skipped:c}}function X(n,r){if(customElements.get(`managed-admin-import`))return;class i extends n{static styles=[h(t),h(v)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error=``,this._message=``,this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId=``,this._triage=``,this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),this._drag=!0)},this._drop=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...e.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId=``,!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage||this._importingContent||this._comparingTriage)&&(this._operation?.abort(),this._message=``,this._error=this._comparingTriage?`Local data changed or was locked. Compare triage again to continue.`:this._importingContent?`Local data changed or was locked. Choose files again to continue.`:this._importingTriage?`Local data changed or was locked. Import triage again to continue.`:`Local data changed or was locked. Choose the workspace again.`))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener(`dragover`,this._over),this.addEventListener(`drop`,this._drop),globalThis.addEventListener(`blur`,this._blur),globalThis.addEventListener(`storage`,this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener(`dragover`,this._over),this.removeEventListener(`drop`,this._drop),globalThis.removeEventListener(`blur`,this._blur),globalThis.removeEventListener(`storage`,this._localChanged),super.disconnectedCallback()}updated(e){e.has(`session`)&&(this._role!==`admin`||e.get(`session`)?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(e){if(this._busy||this._role!==`admin`)return;let t=this._operation=new AbortController,n=AbortSignal.any([t.signal,this.appState.sessionController.signal]);this._busy=!0,this._error=``;try{await e(n),n.throwIfAborted()}catch(e){n.aborted||(this._error=String(e?.message??e))}finally{this._operation===t&&(this._busy=!1)}}async _loadCatalog(){if(this._role===`admin`)try{await this._loadCollection(`workspace-import:catalog`,`import options`,async e=>{let t=j(r,this.session,e),[n,i,a,o]=await Promise.all([t.send(`/api/admin/reports`),t.send(`/api/admin/teams`),t.send(`/api/admin/bundles`),t.send(`/api/admin/repositories/aliases`)]);return{repos:n.repos,teams:i.teams,bundles:a.bundles,aliases:o.aliases}},e=>{this._catalog=e})}catch(e){this._error=String(e?.message??e)}}_browse(){let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`.enc,.gz,.json`,e.addEventListener(`change`,()=>{this._files.push(...e.files),this._nextFile()},{once:!0}),e.click()}async _prepare(e,t){if(!e)return;if(this._catalog||await this._loadCatalog(),t.throwIfAborted(),!this._catalog)throw Error(`Could not load repositories. Try again.`);let n=await A(e,this._catalog.repos,this._catalog.aliases);t.throwIfAborted();let r=new Set(this._catalog.teams.map(e=>e.name)),i=n.name||`Imported workspace`,a=2;for(;r.has(n.name);){let e=` (${a++})`;n.name=i.slice(0,100-e.length)+e}let o=new Set(n.reports.map(e=>e.repoId).filter(e=>e!=null));this._repo=o.size===1?[...o][0]:null,this._triage=Object.keys(n.triage).length>0?``:`skip`,this._plan=n,this._message=``}async _nextFile(){if(this._files.length===0||this._busy)return;let e=this._files.shift();this._local=!1,this._plan=null,await this._action(async t=>{let n=await O(e,this.promptPassword);t.throwIfAborted(),await this._prepare(n,t)})}async _unlock(e,t){this._unlocking=!0;try{return!e.locked||await e.unlock({signal:t})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async e=>{let t=R(this.localDeps);await this._unlock(t,e)&&(e.throwIfAborted(),this._workspaces=await t.list({signal:e}))})}async _readLocal(){if(!this._localId)return;let e=this._localId;this._local=!0,this._plan=null,await this._action(async t=>{let n=R(this.localDeps);if(await this._unlock(n,t)){this._readingLocal=!0;try{await this._prepare(await n.read(e,{signal:t}),t)}finally{this._readingLocal=!1}}})}async _import(){this._plan&&this._triage&&this._csrf&&(await this._action(async e=>{if(this._local&&R(this.localDeps).locked)throw Error(`Unlock local data and choose the workspace again.`);let t=this._plan,n=[`teams`,`reports`,`bundles`,`history`,`workspace-import`,`scan-sources`,`repo-impact`];try{let i=await this.appState.mutate(()=>I(t,{api:j(r,this.session,e),session:this.session,defaultRepo:this._repo,includeTriage:this._triage===`include`,resolveConflicts:this.resolveConflicts,signal:e,progress:e=>{this._message=e}}),n);this._catalog.teams.push(i),this._message=`Imported into ${i.name}.`,this._plan=null}finally{this.appState.invalidate(n),t.team&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async e=>{this._importingTriage=!0,this._message=``;let t=new Set,n=[`reports`,`history`];try{let n=L(this.localDeps);if(!await this._unlock(n,e))return;this._readingLocal=!0;let i;try{i=await n.read({signal:e})}finally{this._readingLocal=!1}let a=await y(i,{api:j(r,this.session,e),session:this.session,resolveConflicts:this.resolveConflicts,signal:e,importedIds:t,confirmImport:async t=>(await this.confirmTriageImport({...t,signal:e}))?.confirmed===!0});if(e.throwIfAborted(),a===null)return;this._message=a?`Imported triage for ${a} finding${a===1?``:`s`}.`:`No local triage matches findings in managed reports.`}finally{this._importingTriage=!1,this.appState.invalidate(n),t.size>0&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}})}async _compareLocalTriage(){this._csrf&&await this._action(async e=>{this._comparingTriage=!0,this._message=``;let t=this.localImportSource,n=t.subscribe(this._localChanged);try{if(!await this._unlock(t,e))return;e.throwIfAborted(),this._readingLocal=!0;let n=L(this.localDeps),i=await Y({source:t,signal:e,readTriage:()=>n.read({signal:e}),api:j(r,this.session,e),progress:e=>{this._message=e}});e.throwIfAborted(),this._message=``,await this.showTriageComparison({comparison:i,signal:e})}finally{n(),this._readingLocal=!1,this._comparingTriage=!1,this._message=``}})}async _importLocalContent(e){this._csrf&&await this._action(async t=>{this._importingContent=!0,this._message=``;let n=this.localImportSource,i=[`reports`,`bundles`,`bundle-metadata`,`history`,`workspace-import`,`scan-sources`,`repo-impact`],a=new Set,o=n.subscribe(this._localChanged);try{if(!await this._unlock(n,t))return;t.throwIfAborted(),this._readingLocal=!0;let i=j(r,this.session,t),o=await U(e,{source:n,deps:this.localDeps,api:i,signal:t}),s=await this.confirmContentImport({plan:o,signal:t});if(t.throwIfAborted(),!s?.confirmed)return;let c=await W(o,s.selected,{source:n,api:i,signal:t,imported:a,progress:e=>{this._message=e}});this._message=`Imported ${c} ${e}${c===1?``:`s`}.`}finally{o(),this._readingLocal=!1,this._importingContent=!1,this.appState.invalidate(i),a.size>0&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}})}render(){if(this._role!==`admin`)return _;let t=this._plan,n=t?Object.keys(t.triage).length:0,r=new Set([...t?.references??[],...t?.bundles.map(e=>e.integrity)??[]]),i=(this._catalog?.bundles??[]).filter(e=>r.has(e.integrity)),a=t?.references.filter(e=>!t.bundles.some(t=>t.integrity===e)).length??0;return g`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${e(`manage-import`,this._role,this.allowShare)}<h1>Import</h1><section class="triage-import" aria-label="Import local files"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`bundle`)}">Import bundles</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`report`)}">Import reports</button></div><p>Choose files from this browser, grouped by workspace. Import files without teams or triage.</p></section><section class="triage-import" aria-label="Local triage"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._compareLocalTriage()}">Compare triage</button></div><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?`dragging`:``}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?g`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${e=>{this._localId=e.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(e=>g`<option value="${e.id}">${e.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?g`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:_}</section>`:_} ${t?g`<section class="import-preview" aria-label="Import options">${t.team?g`<p>Team ${t.team.name} has been created. Retry continues its remaining import steps.</p>`:_} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${t.name}" ?disabled="${this._busy||!!t.team}" @input="${e=>{t.name=e.target.value,this.requestUpdate()}}"><p>${t.reports.length} reports / links · ${r.size} source bundles · ${n} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??``)}" ?disabled="${this._busy||!!t.team}" @change="${e=>{this._repo=e.target.value?Number(e.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(e=>g`<option value="${String(e.repoId)}" ?selected="${this._repo===e.repoId}">${e.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${t.reports.map(e=>g`<li>${e.name}<span>${e.links?`Global deduplication — enabled for all teams`:e.github??`Uses selected repository`}${e.links||e.github==null||e.repoId!=null?``:e.embedded?` — connect this repository first`:` — not connected; uses selected repository`}</span></li>`)}</ul>${i.length>0?g`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${i.map(e=>g`<li>${e.filename}<span>${e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:``}`:`Uses selected repository`}</span></li>`)}</ul>`:_} ${a?g`<p>${a} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:_} ${n?g`<fieldset ?disabled="${this._busy||!!t.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage===`include`}" @change="${()=>{this._triage=`include`}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage===`skip`}" @change="${()=>{this._triage=`skip`}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:_} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?`Importing…`:t.team?`Retry remaining import`:`Import workspace`}</button></section>`:_} ${this._message?g`<p role="status">${this._message}</p>`:_} ${this._error?g`<p class="error" role="alert">${this._error}${this._catalog?_:g`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:_} ${this._files.length>0&&!this._busy?g`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:_}</div>`}}customElements.define(`managed-admin-import`,i)}export{X as registerWorkspaceImport};
@@ -1,6 +1,6 @@
1
- import{b as e,d as t,i as n}from"./chunk-LDO42LAC.js";import{a as r,b as i,c as a}from"./chunk-VG5RH6KN.js";import{A as o,B as s,a as c,b as l,c as u,d,e as f,f as ee,g as te,h as ne,i as re,j as ie,k as ae,l as oe,m as se,n as ce,o as le,p as ue,q as de,r as fe,s as pe,t as me,u as he,v as ge,w as _e,x as ve,y as ye,z as be}from"./chunk-5F5FPI75.js";import"./chunk-6CCSTJWB.js";import{Ba as xe,E as Se,F as Ce,Ja as we,Oa as Te,Pa as Ee,Qa as De,Ra as Oe,Sa as ke,Ta as Ae,ba as je,ca as Me,e as Ne,fa as Pe,g as p,j as Fe,k as m,w as Ie}from"./chunk-U5C2TNNQ.js";import{y as Le}from"./chunk-WFDXHPT2.js";import{b as Re}from"./chunk-NRPC74AM.js";import"./chunk-PNHBZGDD.js";import"./chunk-VFWMQ3LG.js";import{a as h,e as ze}from"./chunk-D6NVKGGG.js";import"./chunk-IYPY47MC.js";import{a as Be,d as Ve}from"./chunk-PWFUOLZK.js";import{m as He,r as g}from"./chunk-6ATPGDDI.js";import{B as Ue,D as We,J as Ge}from"./chunk-QRKFPLA4.js";import{C as Ke,D as qe,d as _,h as Je,i as Ye,j as Xe,x as Ze,y as Qe}from"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{a as v,b as $e,c as y,d as et,g as b,j as tt}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var x=class extends tt{static properties={session:{attribute:!1},allowShare:{attribute:!1},_loading:{state:!0}};constructor(){super(),this.session=null,this.allowShare=!1,this.appState=f,this._loading=!1,this._loadRequest=null}get _role(){return this.session?.role??null}get _csrf(){return this.session?.csrfToken??null}get _me(){return this.session?.id??null}disconnectedCallback(){this._loadRequest?.abort(),super.disconnectedCallback()}async _loadCollection(e,t,n,r){this._loadRequest?.abort();let i=new AbortController;this._loadRequest=i,this._loading=!0;try{await this.appState.load(e,t,n,{signal:i.signal,apply:r})}catch(t){!i.signal.aborted&&t?.name!==`AbortError`&&this.appState.read(e)===void 0&&(this._error=String(t?.message??t))}finally{this._loadRequest===i&&(this._loading=!1)}}};function S(e){return y`<div class="loading-rows" role="status"><span class="sr-only">${e}</span><div aria-hidden="true">${[0,1,2,3].map(()=>y`<div class="loading-row"><span></span><span></span></div>`)}</div></div>`}function nt(e){let t=e.split(`/`);return t.at(-1)===`stasis.config.json`&&!t.includes(`node_modules`)}var rt=class extends we{get changeEvent(){return`local-item-change`}get searchLabel(){return`Search local files`}get optionsLabel(){return`Local files`}get noMatchesLabel(){return`No matching files.`}get emptyLabel(){return`No local files available.`}choices(){let e=this._query.trim().toLocaleLowerCase(),t=this.options.filter(t=>`${t.label} ${t.secondary??``}`.toLocaleLowerCase().includes(e));return{pinned:[],sections:[{options:t}],count:t.length,total:this.options.length,showFacets:!1}}};customElements.define(`managed-local-item-selector`,rt);var it=class{constructor(e,t,n){this.host=e,this.kind=t,this.upload=n,this.source=null,this.hasData=!1,this.open=!1,this.options=[],this.value=null,this.busy=!1,this.loading=!1,this.error=``,this.success=``,this.generation=0,this.readAbort=null,this.onChange=e=>{if(e?.kind){if(e.kind!==this.kind)return;if(e.value!==this.value){this.refresh();return}}this.readAbort&&!this.readAbort.signal.aborted&&(this.readAbort.abort(),this.error=`The local ${this.kind} changed or the list was refreshed. Select it again before importing.`),this.options=[],this.value=null,this.success=``,this.refresh()},this.onBlur=()=>{this.readAbort&&!this.readAbort.signal.aborted&&this.onChange()},this.onVisibilityChange=()=>{globalThis.document?.visibilityState===`hidden`&&this.onBlur()},e.addController(this)}hostConnected(){globalThis.addEventListener(`focus`,this.onChange),globalThis.addEventListener(`blur`,this.onBlur),globalThis.addEventListener(`storage`,this.onChange),globalThis.document?.addEventListener(`visibilitychange`,this.onVisibilityChange),this.connectSource()}hostUpdated(){this.connectSource()}connectSource(){this.source!==this.host.localImportSource&&(this.unsubscribe?.(),this.abort?.abort(),this.source=this.host.localImportSource,this.unsubscribe=this.source?.subscribe(this.onChange),this.onChange())}hostDisconnected(){++this.generation,this.abort?.abort(),this.unsubscribe?.(),this.source=null,globalThis.removeEventListener(`focus`,this.onChange),globalThis.removeEventListener(`blur`,this.onBlur),globalThis.removeEventListener(`storage`,this.onChange),globalThis.document?.removeEventListener(`visibilitychange`,this.onVisibilityChange)}async refresh(){let e=++this.generation,t=this.source;this.loading=!0,this.host.requestUpdate();try{let n=t?await t.hasData(this.kind):!1;if(e!==this.generation)return;this.hasData=n;let r=this.open&&!t?.locked?await t?.list(this.kind)??[]:[];if(e!==this.generation)return;this.options=r,r.some(e=>e.value===this.value)||(this.value=null)}catch(t){e===this.generation&&(this.error=String(t?.message??t))}finally{e===this.generation&&(this.loading=!1,this.host.requestUpdate())}}toggle(){this.busy||(this.open=!this.open,this.error=``,this.success=``,this.options=[],this.value=null,this.refresh())}async unlock(){if(this.busy)return;this.busy=!0,this.error=``;let e=this.abort=new AbortController;this.host.requestUpdate();try{await this.source.unlock({signal:e.signal})&&!e.signal.aborted&&await this.refresh()}catch(t){e.signal.aborted||(this.error=String(t?.message??t))}finally{this.busy=!1,this.host.requestUpdate()}}async importSelected(){if(this.busy||this.loading||!this.value||this.source?.locked)return;this.busy=!0,this.error=``,this.success=``;let e=this.options.find(e=>e.value===this.value)?.label,t=this.abort=new AbortController;this.readAbort=t,this.host.requestUpdate();try{await this.source.importItem(this.kind,this.value,e=>(this.readAbort=null,this.upload(e)),{signal:t.signal}),!t.signal.aborted&&!this.source?.locked&&(this.success=`Imported ${e}.`,this.value=null)}catch(e){t.signal.aborted||(this.error=String(e?.message??e))}finally{this.readAbort===t&&(this.readAbort=null),this.busy=!1,this.host.requestUpdate()}}renderAction(){return this.hasData||this.open?y`<button type="button" class="local-import-toggle" aria-expanded="${this.open}" aria-controls="local-import-panel" ?disabled="${this.busy}" @click="${()=>this.toggle()}">Import</button>`:b}renderPanel(e){if(!this.open)return b;let t=this.source?.locked;return y`<section class="local-import-panel" id="local-import-panel" aria-label="${`Import local ${this.kind}`}"><div class="local-import-copy"><strong>Import local ${this.kind}</strong><p>${t?`Unlock local data with your passkey to choose a file.`:`Copy a file from this browser to the managed workspace. The local copy stays on this device.`}</p></div><div class="local-import-controls">${t?y`<button type="button" class="local-import-submit" ?disabled="${this.busy}" @click="${()=>this.unlock()}">${this.busy?`Waiting for passkey…`:`Unlock with passkey`}</button>`:y`<managed-local-item-selector label="${`Choose local ${this.kind}`}" placeholder="${this.loading?`Loading local files…`:`Choose local ${this.kind}\u2026`}" .options="${this.options}" .value="${this.value}" ?disabled="${this.busy||this.loading}" @local-item-change="${e=>{this.value=e.detail.value,this.success=``,this.host.requestUpdate()}}"></managed-local-item-selector><button type="button" class="local-import-submit" ?disabled="${e||this.busy||this.loading||!this.value}" @click="${()=>this.importSelected()}">${this.busy?`Importing…`:`Import ${this.kind}`}</button>`} <button type="button" class="local-import-close" ?disabled="${this.busy}" @click="${()=>this.toggle()}">Close</button></div>${!t&&!this.loading&&this.options.length===0?y`<p class="local-import-message">No local ${this.kind}s available.</p>`:b} ${this.error?y`<p class="local-import-message error" role="alert">${this.error} <button type="button" ?disabled="${this.busy}" @click="${()=>{this.error=``,this.refresh()}}">Retry</button></p>`:b} ${this.success?y`<p class="local-import-message" role="status">${this.success}</p>`:b}</section>`}};async function at({signal:e}={}){e=e?AbortSignal.any([e,f.sessionController.signal]):f.sessionController.signal,e.throwIfAborted();let t=await d(`/api/admin/bundles`,{credentials:`same-origin`,signal:e});if(e.throwIfAborted(),!t.ok)throw Object.assign(Error(`Bundle catalogue request failed (${t.status})`),{status:t.status});let n=await t.json();return e.throwIfAborted(),n.bundles??[]}async function C(e,t,n){let r=f.generation,i=await d(`/api/bundles/${encodeURIComponent(e)}/${t}`,{credentials:`same-origin`,signal:n});if(n?.throwIfAborted(),!i.ok)throw Object.assign(Error(`Bundle ${t} request failed (${i.status})`),{status:i.status});let a=t===`contents`?await i.text():await i.json();if(n?.throwIfAborted(),r!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);return a}function ot(e,{signal:t}={}){return f.load(`bundle-metadata:${e}`,`bundle metadata`,t=>C(e,`metadata`,t),{signal:t,retryInvalidated:!0})}async function st(e,{signal:t}={}){t=t?AbortSignal.any([t,f.sessionController.signal]):f.sessionController.signal;let n=await C(e,`metadata`,t),r=n?.bundle?.repo??null,i=We({repo:r});if(!i)return r;let a=new URLSearchParams({repo:i,directory:r.directory??``}),o=new Set(n.unsized??[]),s=Re((n.files??[]).filter(([e,t])=>t!=null||o.has(e)).map(([e])=>e));s&&a.set(`filePrefix`,s);let c=await d(`/api/admin/repositories/resolve?${a}`,{credentials:`same-origin`,cache:`no-store`,signal:t});if(t.throwIfAborted(),!c.ok)throw Error(`Repository suggestion request failed (${c.status})`);let{location:l}=await c.json();return t.throwIfAborted(),l?{...r,github:l.github,...l.mapped?{directory:l.directory}:{},repoId:l.repoId}:r}async function ct(e,{signal:t}={}){t=t?AbortSignal.any([t,f.sessionController.signal]):f.sessionController.signal;try{return await C(e,`contents`,t)}catch(e){throw e.name!==`AbortError`&&f.notify(`Couldn't load bundle contents: ${e.message}`),e}}function lt(e,t,n=``,r=!1,i=!1){let a=n?`${n.startsWith(`entry:`)?`entry`:`reason`}=${encodeURIComponent(n.slice(n.indexOf(`:`)+1))}`:``,o=[t?`team=${encodeURIComponent(t)}`:``,a,r?`repoAdvisories=true`:``,i?`details=true`:``].filter(Boolean).join(`&`);return C(e,`advisories${o?`?${o}`:``}`,f.sessionController.signal)}var ut={"patch-not-found":`The patch isn’t at the commit it was read at.`,"patch-mismatch":`The file at the commit the patch was read at isn’t the patch its lockfile names.`,"patch-unreadable":`The patch couldn’t be read as git writes one.`,"patch-unsupported":`The patch changes a file’s bytes, which isn’t reviewed here.`,"patch-does-not-apply":`The patch doesn’t apply to this version.`,"patch-too-large":`The patch is too large to read here.`,"no-repository":`The repository the patch is in isn’t available to you.`,"no-directory":`Only some of the repository the patch is in is available to you.`,"github-token-required":`Reading the patch needs your GitHub sign-in.`},dt=e=>e?{patchHash:e.hash,patchRepoId:String(e.repoId),patchCommit:e.commit,patchPath:e.path}:{},w={...ut,"bad-tarball":`This package's tarball couldn't be read.`,"upstream-invalid":`The npm registry's answer for this package couldn't be read.`,"upstream-too-large":`The npm registry's answer for this package is too large to read here.`,400:`Not an npm package name and version.`,404:`No such package version, or it is not available to you.`,413:`This package is too large to open here.`,429:`Too many packages are loading. Try again shortly.`,502:`The npm registry couldn't be reached.`},ft=15e3,T=new Map;function pt(e){if(T.has(e))return;let t=new AbortController,n=d(e,{credentials:`same-origin`,signal:AbortSignal.any([t.signal,f.sessionController.signal])});n.catch(()=>{});let r={reading:n,until:Date.now()+ft,generation:f.generation};T.set(e,r),setTimeout(()=>{T.get(e)===r&&(T.delete(e),t.abort())},ft)}function mt(e,t){let n=T.get(e);return n?(T.delete(e),n.until>Date.now()&&n.generation===t?n.reading:null):null}var ht=(e,t)=>new Promise((n,r)=>{let i=()=>r(t.reason);t.aborted?i():(t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i)))});async function E(e,t,n,r,i={}){r=r?AbortSignal.any([r,f.sessionController.signal]):f.sessionController.signal;let a=f.generation,o=()=>d(e,{credentials:`same-origin`,...i,signal:r}),s=i.method?null:mt(e,a),c=s&&await ht(s,r).then(e=>e.ok?e:null,e=>{if(r.aborted)throw e;return null})||await o();if(r.throwIfAborted(),!c.ok){let e=await c.json().catch(()=>null),n=e?.error??null;throw Object.assign(Error(t[n]??t[c.status]??`Request failed (${c.status})`),{status:c.status,code:n,...typeof e?.commit==`string`?{commit:e.commit}:{}})}let l=await n(c);if(r.throwIfAborted(),a!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);return l}var D=(e,t,n)=>E(`/api/npm/${e}?${new URLSearchParams(t)}`,w,e=>e.json(),n),gt={"no-repository":`This repository is not available to you.`,"no-directory":`This directory is not at that commit, or not available to you.`,"directory-too-large":`This directory is too large to open here. Open one of its directories instead.`,"directory-unreadable":`GitHub’s archive of this directory couldn’t be read here, as when a symlink in it points outside the repository.`,"repository-busy":`Too many directories and packages are loading. Try again shortly.`,"repository-changed":`The repository changed while it was read. Try again.`,"github-rate-limited":`GitHub’s API rate limit has been reached. Try again later.`,"github-unauthorized":`GitHub authentication has expired or was revoked. Sign in again.`,"github-status-403":`GitHub denied this request. Check repository access and the GitHub App’s read permissions.`,"github-malformed":`GitHub’s archive of this directory could not be verified against its commit.`,"github-unreachable":`Could not connect to GitHub. Try again shortly.`,"github-timeout":`GitHub took too long to answer. Try again shortly.`,400:`Not a repository directory and commit.`,403:`Repository access is required to read its files.`,404:`This repository, commit or directory is unavailable.`,413:`This directory is too large to open here.`,429:`Too many directories and packages are loading. Try again shortly.`,502:`GitHub couldn’t be reached.`},O=(e,t,n)=>E(`/api/admin/repositories/${e}?${new URLSearchParams(t)}`,gt,e=>e.json(),n);function _t(e,t,n,{signal:r}={}){return O(`code`,{repoId:e,ref:t,path:n},r)}async function vt({signal:e}={}){return(await O(`browsable`,{},e)).repos??[]}function yt(e,{signal:t}={}){return O(`refs`,{repoId:e},t)}function bt(e,t,n,{signal:r,commitOnly:i=!1}={}){return O(`contents`,{repoId:e,ref:t,path:n,...i?{listing:`none`}:{}},r)}var xt={...gt,"no-directory":`This directory’s history is not available to you.`,"github-malformed":`GitHub answered with a history that couldn’t be read.`,"github-token-required":`Reading every branch needs your GitHub sign-in.`,400:`Not a repository’s history.`};function St(e,t,n,{page:r=1,all:i=!1,fresh:a=!1,from:o=null,signal:s}={}){return E(`/api/admin/repositories/history?${new URLSearchParams({repoId:e,ref:t,path:n,page:r,...i?{all:`true`}:{},...a?{fresh:`true`}:{},...o?{from:o.join(`,`)}:{}})}`,xt,e=>e.json(),s)}var Ct={...xt,"no-directory":`This directory’s changes are not available to you.`,"github-malformed":`GitHub answered with a commit’s files that couldn’t be read.`,400:`Not a repository’s commits.`};function wt(e,t,n,{signal:r}={}){return E(`/api/admin/repositories/changes?${new URLSearchParams({repoId:e,path:t,shas:n.join(`,`)})}`,Ct,e=>e.json(),r)}function Tt(e,t,n,{signal:r}={}){return E(`/api/admin/repositories/tree?${new URLSearchParams({repoId:e,path:t,commit:n})}`,Ct,e=>e.json(),r)}var k={...gt,"no-directory":`Issues and pull requests show only with access to the whole repository.`,"github-malformed":`GitHub answered with a list that couldn’t be read.`,"github-token-required":`Reading issues and pull requests needs your GitHub sign-in.`,"github-status-403":`GitHub refused to list these. The GitHub App reading this repository needs Issues: read and Pull requests: read, which an owner of its installation approves.`,400:`Not a repository’s issues or pull requests.`},Et=(e,t,n,r)=>`/api/admin/repositories/issues?${new URLSearchParams({repoId:e,kind:t,state:n,...r?{after:r}:{}})}`;function Dt(e,t,{state:n=`open`,after:r=null,signal:i}={}){return E(Et(e,t,n,r),k,e=>e.json(),i)}var Ot={...k,"no-directory":`Agents show only with access to the whole repository.`,"github-token-required":`Reading what the agents did needs your GitHub sign-in.`,400:`Not a repository’s agents.`},kt=(e,t,n)=>`/api/admin/repositories/agents?${new URLSearchParams({repoId:e,...t?{pulls:t}:{},...n?{commits:n}:{}})}`;function At(e,{pulls:t=null,commits:n=null,signal:r}={}){return E(kt(e,t,n),Ot,e=>e.json(),r)}var jt={...k,"github-not-found":`GitHub has no issue or pull request of that number here.`,400:`Not an issue or pull request of a repository.`};function Mt(e,t,{signal:n}={}){return E(`/api/admin/repositories/item?${new URLSearchParams({repoId:e,number:t})}`,jt,e=>e.json(),n)}var Nt={...jt,"github-not-found":`GitHub has no pull request of that number here.`,"github-malformed":`GitHub answered with a pull request or lockfile that couldn’t be read.`,"github-status-403":`GitHub refused to read its lockfiles. The GitHub App reading this repository needs Contents: read and Pull requests: read, which an owner of its installation approves.`,400:`Not a pull request of a repository.`},Pt=({review:e,listed:t})=>({...e?{review:`1`}:{},...t?{listed:`1`}:{}});function Ft(e,t,{review:n=!1,listed:r=!1,signal:i}={}){return E(`/api/admin/repositories/pull-dependencies?${new URLSearchParams({repoId:e,number:t,...Pt({review:n,listed:r})})}`,Nt,e=>e.json(),i)}async function It(e,t,{review:n=!1,listed:r=!1,signal:i}={}){let{pulls:a}=await E(`/api/admin/repositories/pull-dependencies?${new URLSearchParams({repoId:e,numbers:t.join(`,`),...Pt({review:n,listed:r})})}`,Nt,e=>e.json(),i);return Lt(a)}var Lt=e=>new Map((Array.isArray(e)?e:[]).filter(e=>Number.isSafeInteger(e?.number)).map(e=>[e.number,typeof e.error==`string`?Object.assign(Error(Nt[e.error]??`It couldn\u2019t be read (${e.error}).`),{code:e.error}):e])),Rt={...jt,"github-not-found":`GitHub has none of a lockfile it lists on the default branch.`,"github-malformed":`GitHub answered with a lockfile that couldn’t be read.`,"github-status-403":`GitHub refused to read its lockfiles. The GitHub App reading this repository needs Contents: read, which an owner of its installation approves.`,400:`Not a repository.`},zt={...Rt,"no-bundle":`This bundle is not available to you.`,"bundle-unavailable":`This bundle’s packages couldn’t be read.`,"payload-too-large":`This bundle holds too many packages to check here.`,"repository-changed":`The bundle or its repository changed while it was read. Try again.`,"github-not-found":`GitHub has none of the commit this bundle was built from, or of a lockfile it lists there.`,400:`Not a bundle.`};function Bt(e,{signal:t}={}){return E(`/api/bundles/${encodeURIComponent(e)}/dependency-review`,zt,e=>e.json(),t)}var Vt={...zt,"unsupported-bundle":`Only Stasis bundles are validated.`,"validation-busy":`Other bundles are being validated. Try again shortly.`,"validation-failed":`The validation failed. Try again.`,"csrf-missing":`Your session is missing its request token. Reload the page.`,"csrf-mismatch":`Your session changed. Reload the page.`,429:`Other bundles are being validated. Try again shortly.`},Ht=e=>`/api/bundles/${encodeURIComponent(e)}/validation`;function Ut(e,{signal:t}={}){return E(Ht(e),Vt,e=>e.json(),t)}function Wt(e,t,{signal:n}={}){return E(Ht(e),Vt,e=>e.json().catch(()=>null),n,{method:`POST`,headers:{"x-csrf-token":t}})}var Gt={"no-team":`This team is not available to you.`,400:`Not a team’s repositories.`},Kt=`GitHub failed to answer. Try again shortly.`,qt={...k,"github-status-502":Kt,"github-status-504":Kt,"time-up":`Reading them took too long.`},Jt=e=>`Not all its open pull requests were read. ${qt[e]??`(${e})`}`;function Yt(e,t,{repoIds:n=null,signal:r}={}){let i=n?`?${new URLSearchParams({repoIds:n.join(`,`)})}`:``;return E(`/api/teams/${encodeURIComponent(e)}/dependencies${i}`,Gt,async e=>{let n=f.generation;for await(let r of j(e)){if(n!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);t(typeof r.error==`string`?{...r,error:Rt[r.error]??Rt[r.status]??`It couldn\u2019t be read (${r.error}).`,code:r.error}:Array.isArray(r.dependencies)?{...r,dependencies:Lt(r.dependencies)}:typeof r.pulls?.error==`string`?{...r,pulls:{...r.pulls,error:Jt(r.pulls.error)}}:r)}},r)}var Xt={...k,"no-directory":`Pulse shows only with access to the whole repository.`,"github-malformed":`GitHub answered with statistics that couldn’t be read.`,"github-token-required":`Reading a repository’s pulse needs your GitHub sign-in.`,"github-status-403":`GitHub refused to read these. The GitHub App reading this repository needs Contents, Issues and Pull requests: read, which an owner of its installation approves.`,400:`Not a repository’s pulse.`},Zt=(e,t)=>`/api/admin/repositories/pulse?${new URLSearchParams({repoId:e,weeks:t})}`;function Qt(e,t,{signal:n}={}){return E(Zt(e,t),Xt,e=>e.json(),n)}function $t(e,t,{state:n=`open`,weeks:r=4}={}){t===`issues`||t===`pulls`?pt(Et(e,t,n,null)):t===`agents`?pt(kt(e,null,null)):t===`pulse`&&pt(Zt(e,r))}function en(e,t,{from:n,to:r=null,authors:i=[]},{signal:a}={}){return E(`/api/admin/repositories/pulse/items?${new URLSearchParams({repoId:e,weeks:t,from:n,...r===null?{}:{to:r},...i.length>0?{authors:i.join(`,`)}:{}})}`,Xt,e=>e.json(),a)}function tn(e,t,{signal:n,patch:r=null}={}){return D(`package`,{name:e,version:t,...dt(r)},n)}function nn(e,{signal:t}={}){return D(`versions`,{name:e},t)}function rn(e,{signal:t}={}){return D(`stats`,{name:e},t)}function an(e,{signal:t}={}){return D(`advisories`,{name:e},t)}function on(e,t,{signal:n}={}){return D(`tags`,{name:e,version:t},n)}function sn(e,t,{signal:n}={}){return D(`socket`,{name:e,version:t},n)}function cn(e,t,n=null,{signal:r}={}){return D(`risk`,{name:e,version:t,...n===null?{}:{otherVersion:n}},r)}function ln(e,t,{signal:n}={}){return D(`provenance`,{name:e,version:t},n)}var A={404:`This file is no longer available.`,409:`This file has changed since it was opened.`,413:`This file is too large to pretty-print.`,422:`This file couldn't be read as code.`,"pretty-mismatch":`Pretty-printing would change more than its layout, so it is shown as published.`,unsupported:`This kind of file can't be checked once pretty-printed, so it is shown as published.`,429:`Too many files are being pretty-printed. Try again shortly.`,502:`The npm registry couldn't be reached.`};function un(e,t,n,{signal:r}={}){return E(`/api/bundles/${encodeURIComponent(e)}/pretty?${new URLSearchParams({path:t,hash:n})}`,A,fn,r)}function dn(e,t,n,r,{signal:i}={}){return E(`/api/npm/pretty?${new URLSearchParams({name:e,version:t,path:n,hash:r})}`,{...w,...A},fn,i)}var fn=async e=>({text:await e.text(),source:e.headers.get(`x-source-hash`)});async function*j(e){let t=e.body.pipeThrough(new TextDecoderStream).getReader(),n=[];for(;;){let{done:e,value:r}=await t.read();if(e)return;let i=0;for(let e=r.indexOf(`
1
+ import{b as e,d as t,i as n}from"./chunk-GZ46SSTF.js";import{a as r,b as i,c as a}from"./chunk-VG5RH6KN.js";import{A as o,B as s,a as c,b as l,c as u,d,e as f,f as ee,g as te,h as ne,i as re,j as ie,k as ae,l as oe,m as se,n as ce,o as le,p as ue,q as de,r as fe,s as pe,t as me,u as he,v as ge,w as _e,x as ve,y as ye,z as be}from"./chunk-MPXVKVPF.js";import"./chunk-6CCSTJWB.js";import{Ba as xe,E as Se,F as Ce,Ja as we,Oa as Te,Pa as Ee,Qa as De,Ra as Oe,Sa as ke,Ta as Ae,ba as je,ca as Me,e as Ne,fa as Pe,g as p,j as Fe,k as m,w as Ie}from"./chunk-2HGKTQ5Q.js";import{y as Le}from"./chunk-WFDXHPT2.js";import{b as Re}from"./chunk-NRPC74AM.js";import"./chunk-PNHBZGDD.js";import"./chunk-VFWMQ3LG.js";import{a as h,e as ze}from"./chunk-D6NVKGGG.js";import"./chunk-IYPY47MC.js";import{a as Be,d as Ve}from"./chunk-PWFUOLZK.js";import{m as He,r as g}from"./chunk-4RS3NDOG.js";import{B as Ue,D as We,J as Ge}from"./chunk-QRKFPLA4.js";import{C as Ke,D as qe,d as _,h as Je,i as Ye,j as Xe,x as Ze,y as Qe}from"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{a as v,b as $e,c as y,d as et,g as b,j as tt}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var x=class extends tt{static properties={session:{attribute:!1},allowShare:{attribute:!1},_loading:{state:!0}};constructor(){super(),this.session=null,this.allowShare=!1,this.appState=f,this._loading=!1,this._loadRequest=null}get _role(){return this.session?.role??null}get _csrf(){return this.session?.csrfToken??null}get _me(){return this.session?.id??null}disconnectedCallback(){this._loadRequest?.abort(),super.disconnectedCallback()}async _loadCollection(e,t,n,r){this._loadRequest?.abort();let i=new AbortController;this._loadRequest=i,this._loading=!0;try{await this.appState.load(e,t,n,{signal:i.signal,apply:r})}catch(t){!i.signal.aborted&&t?.name!==`AbortError`&&this.appState.read(e)===void 0&&(this._error=String(t?.message??t))}finally{this._loadRequest===i&&(this._loading=!1)}}};function S(e){return y`<div class="loading-rows" role="status"><span class="sr-only">${e}</span><div aria-hidden="true">${[0,1,2,3].map(()=>y`<div class="loading-row"><span></span><span></span></div>`)}</div></div>`}function nt(e){let t=e.split(`/`);return t.at(-1)===`stasis.config.json`&&!t.includes(`node_modules`)}var rt=class extends we{get changeEvent(){return`local-item-change`}get searchLabel(){return`Search local files`}get optionsLabel(){return`Local files`}get noMatchesLabel(){return`No matching files.`}get emptyLabel(){return`No local files available.`}choices(){let e=this._query.trim().toLocaleLowerCase(),t=this.options.filter(t=>`${t.label} ${t.secondary??``}`.toLocaleLowerCase().includes(e));return{pinned:[],sections:[{options:t}],count:t.length,total:this.options.length,showFacets:!1}}};customElements.define(`managed-local-item-selector`,rt);var it=class{constructor(e,t,n){this.host=e,this.kind=t,this.upload=n,this.source=null,this.hasData=!1,this.open=!1,this.options=[],this.value=null,this.busy=!1,this.loading=!1,this.error=``,this.success=``,this.generation=0,this.readAbort=null,this.onChange=e=>{if(e?.kind){if(e.kind!==this.kind)return;if(e.value!==this.value){this.refresh();return}}this.readAbort&&!this.readAbort.signal.aborted&&(this.readAbort.abort(),this.error=`The local ${this.kind} changed or the list was refreshed. Select it again before importing.`),this.options=[],this.value=null,this.success=``,this.refresh()},this.onBlur=()=>{this.readAbort&&!this.readAbort.signal.aborted&&this.onChange()},this.onVisibilityChange=()=>{globalThis.document?.visibilityState===`hidden`&&this.onBlur()},e.addController(this)}hostConnected(){globalThis.addEventListener(`focus`,this.onChange),globalThis.addEventListener(`blur`,this.onBlur),globalThis.addEventListener(`storage`,this.onChange),globalThis.document?.addEventListener(`visibilitychange`,this.onVisibilityChange),this.connectSource()}hostUpdated(){this.connectSource()}connectSource(){this.source!==this.host.localImportSource&&(this.unsubscribe?.(),this.abort?.abort(),this.source=this.host.localImportSource,this.unsubscribe=this.source?.subscribe(this.onChange),this.onChange())}hostDisconnected(){++this.generation,this.abort?.abort(),this.unsubscribe?.(),this.source=null,globalThis.removeEventListener(`focus`,this.onChange),globalThis.removeEventListener(`blur`,this.onBlur),globalThis.removeEventListener(`storage`,this.onChange),globalThis.document?.removeEventListener(`visibilitychange`,this.onVisibilityChange)}async refresh(){let e=++this.generation,t=this.source;this.loading=!0,this.host.requestUpdate();try{let n=t?await t.hasData(this.kind):!1;if(e!==this.generation)return;this.hasData=n;let r=this.open&&!t?.locked?await t?.list(this.kind)??[]:[];if(e!==this.generation)return;this.options=r,r.some(e=>e.value===this.value)||(this.value=null)}catch(t){e===this.generation&&(this.error=String(t?.message??t))}finally{e===this.generation&&(this.loading=!1,this.host.requestUpdate())}}toggle(){this.busy||(this.open=!this.open,this.error=``,this.success=``,this.options=[],this.value=null,this.refresh())}async unlock(){if(this.busy)return;this.busy=!0,this.error=``;let e=this.abort=new AbortController;this.host.requestUpdate();try{await this.source.unlock({signal:e.signal})&&!e.signal.aborted&&await this.refresh()}catch(t){e.signal.aborted||(this.error=String(t?.message??t))}finally{this.busy=!1,this.host.requestUpdate()}}async importSelected(){if(this.busy||this.loading||!this.value||this.source?.locked)return;this.busy=!0,this.error=``,this.success=``;let e=this.options.find(e=>e.value===this.value)?.label,t=this.abort=new AbortController;this.readAbort=t,this.host.requestUpdate();try{await this.source.importItem(this.kind,this.value,e=>(this.readAbort=null,this.upload(e)),{signal:t.signal}),!t.signal.aborted&&!this.source?.locked&&(this.success=`Imported ${e}.`,this.value=null)}catch(e){t.signal.aborted||(this.error=String(e?.message??e))}finally{this.readAbort===t&&(this.readAbort=null),this.busy=!1,this.host.requestUpdate()}}renderAction(){return this.hasData||this.open?y`<button type="button" class="local-import-toggle" aria-expanded="${this.open}" aria-controls="local-import-panel" ?disabled="${this.busy}" @click="${()=>this.toggle()}">Import</button>`:b}renderPanel(e){if(!this.open)return b;let t=this.source?.locked;return y`<section class="local-import-panel" id="local-import-panel" aria-label="${`Import local ${this.kind}`}"><div class="local-import-copy"><strong>Import local ${this.kind}</strong><p>${t?`Unlock local data with your passkey to choose a file.`:`Copy a file from this browser to the managed workspace. The local copy stays on this device.`}</p></div><div class="local-import-controls">${t?y`<button type="button" class="local-import-submit" ?disabled="${this.busy}" @click="${()=>this.unlock()}">${this.busy?`Waiting for passkey…`:`Unlock with passkey`}</button>`:y`<managed-local-item-selector label="${`Choose local ${this.kind}`}" placeholder="${this.loading?`Loading local files…`:`Choose local ${this.kind}\u2026`}" .options="${this.options}" .value="${this.value}" ?disabled="${this.busy||this.loading}" @local-item-change="${e=>{this.value=e.detail.value,this.success=``,this.host.requestUpdate()}}"></managed-local-item-selector><button type="button" class="local-import-submit" ?disabled="${e||this.busy||this.loading||!this.value}" @click="${()=>this.importSelected()}">${this.busy?`Importing…`:`Import ${this.kind}`}</button>`} <button type="button" class="local-import-close" ?disabled="${this.busy}" @click="${()=>this.toggle()}">Close</button></div>${!t&&!this.loading&&this.options.length===0?y`<p class="local-import-message">No local ${this.kind}s available.</p>`:b} ${this.error?y`<p class="local-import-message error" role="alert">${this.error} <button type="button" ?disabled="${this.busy}" @click="${()=>{this.error=``,this.refresh()}}">Retry</button></p>`:b} ${this.success?y`<p class="local-import-message" role="status">${this.success}</p>`:b}</section>`}};async function at({signal:e}={}){e=e?AbortSignal.any([e,f.sessionController.signal]):f.sessionController.signal,e.throwIfAborted();let t=await d(`/api/admin/bundles`,{credentials:`same-origin`,signal:e});if(e.throwIfAborted(),!t.ok)throw Object.assign(Error(`Bundle catalogue request failed (${t.status})`),{status:t.status});let n=await t.json();return e.throwIfAborted(),n.bundles??[]}async function C(e,t,n){let r=f.generation,i=await d(`/api/bundles/${encodeURIComponent(e)}/${t}`,{credentials:`same-origin`,signal:n});if(n?.throwIfAborted(),!i.ok)throw Object.assign(Error(`Bundle ${t} request failed (${i.status})`),{status:i.status});let a=t===`contents`?await i.text():await i.json();if(n?.throwIfAborted(),r!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);return a}function ot(e,{signal:t}={}){return f.load(`bundle-metadata:${e}`,`bundle metadata`,t=>C(e,`metadata`,t),{signal:t,retryInvalidated:!0})}async function st(e,{signal:t}={}){t=t?AbortSignal.any([t,f.sessionController.signal]):f.sessionController.signal;let n=await C(e,`metadata`,t),r=n?.bundle?.repo??null,i=We({repo:r});if(!i)return r;let a=new URLSearchParams({repo:i,directory:r.directory??``}),o=new Set(n.unsized??[]),s=Re((n.files??[]).filter(([e,t])=>t!=null||o.has(e)).map(([e])=>e));s&&a.set(`filePrefix`,s);let c=await d(`/api/admin/repositories/resolve?${a}`,{credentials:`same-origin`,cache:`no-store`,signal:t});if(t.throwIfAborted(),!c.ok)throw Error(`Repository suggestion request failed (${c.status})`);let{location:l}=await c.json();return t.throwIfAborted(),l?{...r,github:l.github,...l.mapped?{directory:l.directory}:{},repoId:l.repoId}:r}async function ct(e,{signal:t}={}){t=t?AbortSignal.any([t,f.sessionController.signal]):f.sessionController.signal;try{return await C(e,`contents`,t)}catch(e){throw e.name!==`AbortError`&&f.notify(`Couldn't load bundle contents: ${e.message}`),e}}function lt(e,t,n=``,r=!1,i=!1){let a=n?`${n.startsWith(`entry:`)?`entry`:`reason`}=${encodeURIComponent(n.slice(n.indexOf(`:`)+1))}`:``,o=[t?`team=${encodeURIComponent(t)}`:``,a,r?`repoAdvisories=true`:``,i?`details=true`:``].filter(Boolean).join(`&`);return C(e,`advisories${o?`?${o}`:``}`,f.sessionController.signal)}var ut={"patch-not-found":`The patch isn’t at the commit it was looked for at.`,"patch-mismatch":`The file at the commit the patch was read at isn’t the patch its lockfile names.`,"patch-unreadable":`The patch couldn’t be read as git writes one.`,"patch-unsupported":`The patch changes a file’s bytes, which isn’t reviewed here.`,"patch-does-not-apply":`The patch doesn’t apply to this version.`,"patch-too-large":`The patch is too large to read here.`,"no-repository":`The repository the patch is in isn’t available to you.`,"no-directory":`Only some of the repository the patch is in is available to you.`,"github-token-required":`Reading the patch needs your GitHub sign-in.`,"patch-not-kept":`The patch isn’t kept here: a review of a version it patches keeps it, as does a team’s Dependencies tab of its repository’s default branch.`},dt=e=>e?{patchHash:e.hash,...e.repoId==null?{}:{patchRepoId:String(e.repoId),patchCommit:e.commit},...e.path==null?{}:{patchPath:e.path}}:{},w={...ut,"bad-tarball":`This package's tarball couldn't be read.`,"upstream-invalid":`The npm registry's answer for this package couldn't be read.`,"upstream-too-large":`The npm registry's answer for this package is too large to read here.`,400:`Not an npm package name and version.`,404:`No such package version, or it is not available to you.`,413:`This package is too large to open here.`,429:`Too many packages are loading. Try again shortly.`,502:`The npm registry couldn't be reached.`},ft=15e3,T=new Map;function pt(e){if(T.has(e))return;let t=new AbortController,n=d(e,{credentials:`same-origin`,signal:AbortSignal.any([t.signal,f.sessionController.signal])});n.catch(()=>{});let r={reading:n,until:Date.now()+ft,generation:f.generation};T.set(e,r),setTimeout(()=>{T.get(e)===r&&(T.delete(e),t.abort())},ft)}function mt(e,t){let n=T.get(e);return n?(T.delete(e),n.until>Date.now()&&n.generation===t?n.reading:null):null}var ht=(e,t)=>new Promise((n,r)=>{let i=()=>r(t.reason);t.aborted?i():(t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i)))});async function E(e,t,n,r,i={}){r=r?AbortSignal.any([r,f.sessionController.signal]):f.sessionController.signal;let a=f.generation,o=()=>d(e,{credentials:`same-origin`,...i,signal:r}),s=i.method?null:mt(e,a),c=s&&await ht(s,r).then(e=>e.ok?e:null,e=>{if(r.aborted)throw e;return null})||await o();if(r.throwIfAborted(),!c.ok){let e=await c.json().catch(()=>null),n=e?.error??null;throw Object.assign(Error(t[n]??t[c.status]??`Request failed (${c.status})`),{status:c.status,code:n,...typeof e?.commit==`string`?{commit:e.commit}:{}})}let l=await n(c);if(r.throwIfAborted(),a!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);return l}var D=(e,t,n)=>E(`/api/npm/${e}?${new URLSearchParams(t)}`,w,e=>e.json(),n),gt={"no-repository":`This repository is not available to you.`,"no-directory":`This directory is not at that commit, or not available to you.`,"directory-too-large":`This directory is too large to open here. Open one of its directories instead.`,"directory-unreadable":`GitHub’s archive of this directory couldn’t be read here, as when a symlink in it points outside the repository.`,"repository-busy":`Too many directories and packages are loading. Try again shortly.`,"repository-changed":`The repository changed while it was read. Try again.`,"github-rate-limited":`GitHub’s API rate limit has been reached. Try again later.`,"github-unauthorized":`GitHub authentication has expired or was revoked. Sign in again.`,"github-status-403":`GitHub denied this request. Check repository access and the GitHub App’s read permissions.`,"github-malformed":`GitHub’s archive of this directory could not be verified against its commit.`,"github-unreachable":`Could not connect to GitHub. Try again shortly.`,"github-timeout":`GitHub took too long to answer. Try again shortly.`,400:`Not a repository directory and commit.`,403:`Repository access is required to read its files.`,404:`This repository, commit or directory is unavailable.`,413:`This directory is too large to open here.`,429:`Too many directories and packages are loading. Try again shortly.`,502:`GitHub couldn’t be reached.`},O=(e,t,n)=>E(`/api/admin/repositories/${e}?${new URLSearchParams(t)}`,gt,e=>e.json(),n);function _t(e,t,n,{signal:r}={}){return O(`code`,{repoId:e,ref:t,path:n},r)}async function vt({signal:e}={}){return(await O(`browsable`,{},e)).repos??[]}function yt(e,{signal:t}={}){return O(`refs`,{repoId:e},t)}function bt(e,t,n,{signal:r,commitOnly:i=!1}={}){return O(`contents`,{repoId:e,ref:t,path:n,...i?{listing:`none`}:{}},r)}var xt={...gt,"no-directory":`This directory’s history is not available to you.`,"github-malformed":`GitHub answered with a history that couldn’t be read.`,"github-token-required":`Reading every branch needs your GitHub sign-in.`,400:`Not a repository’s history.`};function St(e,t,n,{page:r=1,all:i=!1,fresh:a=!1,from:o=null,signal:s}={}){return E(`/api/admin/repositories/history?${new URLSearchParams({repoId:e,ref:t,path:n,page:r,...i?{all:`true`}:{},...a?{fresh:`true`}:{},...o?{from:o.join(`,`)}:{}})}`,xt,e=>e.json(),s)}var Ct={...xt,"no-directory":`This directory’s changes are not available to you.`,"github-malformed":`GitHub answered with a commit’s files that couldn’t be read.`,400:`Not a repository’s commits.`};function wt(e,t,n,{signal:r}={}){return E(`/api/admin/repositories/changes?${new URLSearchParams({repoId:e,path:t,shas:n.join(`,`)})}`,Ct,e=>e.json(),r)}function Tt(e,t,n,{signal:r}={}){return E(`/api/admin/repositories/tree?${new URLSearchParams({repoId:e,path:t,commit:n})}`,Ct,e=>e.json(),r)}var k={...gt,"no-directory":`Issues and pull requests show only with access to the whole repository.`,"github-malformed":`GitHub answered with a list that couldn’t be read.`,"github-token-required":`Reading issues and pull requests needs your GitHub sign-in.`,"github-status-403":`GitHub refused to list these. The GitHub App reading this repository needs Issues: read and Pull requests: read, which an owner of its installation approves.`,400:`Not a repository’s issues or pull requests.`},Et=(e,t,n,r)=>`/api/admin/repositories/issues?${new URLSearchParams({repoId:e,kind:t,state:n,...r?{after:r}:{}})}`;function Dt(e,t,{state:n=`open`,after:r=null,signal:i}={}){return E(Et(e,t,n,r),k,e=>e.json(),i)}var Ot={...k,"no-directory":`Agents show only with access to the whole repository.`,"github-token-required":`Reading what the agents did needs your GitHub sign-in.`,400:`Not a repository’s agents.`},kt=(e,t,n)=>`/api/admin/repositories/agents?${new URLSearchParams({repoId:e,...t?{pulls:t}:{},...n?{commits:n}:{}})}`;function At(e,{pulls:t=null,commits:n=null,signal:r}={}){return E(kt(e,t,n),Ot,e=>e.json(),r)}var jt={...k,"github-not-found":`GitHub has no issue or pull request of that number here.`,400:`Not an issue or pull request of a repository.`};function Mt(e,t,{signal:n}={}){return E(`/api/admin/repositories/item?${new URLSearchParams({repoId:e,number:t})}`,jt,e=>e.json(),n)}var Nt={...jt,"github-not-found":`GitHub has no pull request of that number here.`,"github-malformed":`GitHub answered with a pull request or lockfile that couldn’t be read.`,"github-status-403":`GitHub refused to read its lockfiles. The GitHub App reading this repository needs Contents: read and Pull requests: read, which an owner of its installation approves.`,400:`Not a pull request of a repository.`},Pt=({review:e,listed:t})=>({...e?{review:`1`}:{},...t?{listed:`1`}:{}});function Ft(e,t,{review:n=!1,listed:r=!1,signal:i}={}){return E(`/api/admin/repositories/pull-dependencies?${new URLSearchParams({repoId:e,number:t,...Pt({review:n,listed:r})})}`,Nt,e=>e.json(),i)}async function It(e,t,{review:n=!1,listed:r=!1,signal:i}={}){let{pulls:a}=await E(`/api/admin/repositories/pull-dependencies?${new URLSearchParams({repoId:e,numbers:t.join(`,`),...Pt({review:n,listed:r})})}`,Nt,e=>e.json(),i);return Lt(a)}var Lt=e=>new Map((Array.isArray(e)?e:[]).filter(e=>Number.isSafeInteger(e?.number)).map(e=>[e.number,typeof e.error==`string`?Object.assign(Error(Nt[e.error]??`It couldn\u2019t be read (${e.error}).`),{code:e.error}):e])),Rt={...jt,"github-not-found":`GitHub has none of a lockfile it lists on the default branch.`,"github-malformed":`GitHub answered with a lockfile that couldn’t be read.`,"github-status-403":`GitHub refused to read its lockfiles. The GitHub App reading this repository needs Contents: read, which an owner of its installation approves.`,400:`Not a repository.`},zt={...Rt,"no-bundle":`This bundle is not available to you.`,"bundle-unavailable":`This bundle’s packages couldn’t be read.`,"payload-too-large":`This bundle holds too many packages to check here.`,"repository-changed":`The bundle or its repository changed while it was read. Try again.`,"github-not-found":`GitHub has none of the commit this bundle was built from, or of a lockfile it lists there.`,400:`Not a bundle.`};function Bt(e,{signal:t}={}){return E(`/api/bundles/${encodeURIComponent(e)}/dependency-review`,zt,e=>e.json(),t)}var Vt={...zt,"unsupported-bundle":`Only Stasis bundles are validated.`,"validation-busy":`Other bundles are being validated. Try again shortly.`,"validation-failed":`The validation failed. Try again.`,"csrf-missing":`Your session is missing its request token. Reload the page.`,"csrf-mismatch":`Your session changed. Reload the page.`,429:`Other bundles are being validated. Try again shortly.`},Ht=e=>`/api/bundles/${encodeURIComponent(e)}/validation`;function Ut(e,{signal:t}={}){return E(Ht(e),Vt,e=>e.json(),t)}function Wt(e,t,{signal:n}={}){return E(Ht(e),Vt,e=>e.json().catch(()=>null),n,{method:`POST`,headers:{"x-csrf-token":t}})}var Gt={"no-team":`This team is not available to you.`,400:`Not a team’s repositories.`},Kt=`GitHub failed to answer. Try again shortly.`,qt={...k,"github-status-502":Kt,"github-status-504":Kt,"time-up":`Reading them took too long.`},Jt=e=>`Not all its open pull requests were read. ${qt[e]??`(${e})`}`;function Yt(e,t,{repoIds:n=null,signal:r}={}){let i=n?`?${new URLSearchParams({repoIds:n.join(`,`)})}`:``;return E(`/api/teams/${encodeURIComponent(e)}/dependencies${i}`,Gt,async e=>{let n=f.generation;for await(let r of j(e)){if(n!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);t(typeof r.error==`string`?{...r,error:Rt[r.error]??Rt[r.status]??`It couldn\u2019t be read (${r.error}).`,code:r.error}:Array.isArray(r.dependencies)?{...r,dependencies:Lt(r.dependencies)}:typeof r.pulls?.error==`string`?{...r,pulls:{...r.pulls,error:Jt(r.pulls.error)}}:r)}},r)}var Xt={...k,"no-directory":`Pulse shows only with access to the whole repository.`,"github-malformed":`GitHub answered with statistics that couldn’t be read.`,"github-token-required":`Reading a repository’s pulse needs your GitHub sign-in.`,"github-status-403":`GitHub refused to read these. The GitHub App reading this repository needs Contents, Issues and Pull requests: read, which an owner of its installation approves.`,400:`Not a repository’s pulse.`},Zt=(e,t)=>`/api/admin/repositories/pulse?${new URLSearchParams({repoId:e,weeks:t})}`;function Qt(e,t,{signal:n}={}){return E(Zt(e,t),Xt,e=>e.json(),n)}function $t(e,t,{state:n=`open`,weeks:r=4}={}){t===`issues`||t===`pulls`?pt(Et(e,t,n,null)):t===`agents`?pt(kt(e,null,null)):t===`pulse`&&pt(Zt(e,r))}function en(e,t,{from:n,to:r=null,authors:i=[]},{signal:a}={}){return E(`/api/admin/repositories/pulse/items?${new URLSearchParams({repoId:e,weeks:t,from:n,...r===null?{}:{to:r},...i.length>0?{authors:i.join(`,`)}:{}})}`,Xt,e=>e.json(),a)}function tn(e,t,{signal:n,patch:r=null}={}){return D(`package`,{name:e,version:t,...dt(r)},n)}function nn(e,{signal:t}={}){return D(`versions`,{name:e},t)}function rn(e,{signal:t}={}){return D(`stats`,{name:e},t)}function an(e,{signal:t}={}){return D(`advisories`,{name:e},t)}function on(e,t,{signal:n}={}){return D(`tags`,{name:e,version:t},n)}function sn(e,t,{signal:n}={}){return D(`socket`,{name:e,version:t},n)}function cn(e,t,n=null,{signal:r}={}){return D(`risk`,{name:e,version:t,...n===null?{}:{otherVersion:n}},r)}function ln(e,t,{signal:n}={}){return D(`provenance`,{name:e,version:t},n)}var A={404:`This file is no longer available.`,409:`This file has changed since it was opened.`,413:`This file is too large to pretty-print.`,422:`This file couldn't be read as code.`,"pretty-mismatch":`Pretty-printing would change more than its layout, so it is shown as published.`,unsupported:`This kind of file can't be checked once pretty-printed, so it is shown as published.`,429:`Too many files are being pretty-printed. Try again shortly.`,502:`The npm registry couldn't be reached.`};function un(e,t,n,{signal:r}={}){return E(`/api/bundles/${encodeURIComponent(e)}/pretty?${new URLSearchParams({path:t,hash:n})}`,A,fn,r)}function dn(e,t,n,r,{signal:i}={}){return E(`/api/npm/pretty?${new URLSearchParams({name:e,version:t,path:n,hash:r})}`,{...w,...A},fn,i)}var fn=async e=>({text:await e.text(),source:e.headers.get(`x-source-hash`)});async function*j(e){let t=e.body.pipeThrough(new TextDecoderStream).getReader(),n=[];for(;;){let{done:e,value:r}=await t.read();if(e)return;let i=0;for(let e=r.indexOf(`
2
2
  `);e!==-1;i=e+1,e=r.indexOf(`
3
- `,i))n.push(r.slice(i,e)),yield JSON.parse(n.join(``)),n=[];n.push(r.slice(i))}}function pn(e,t,n,{signal:r}={}){return M(`/api/npm/pretty?${new URLSearchParams({name:e,version:t})}`,w,n,r)}function mn(e,t,n,{signal:r}={}){return M(`/api/bundles/${encodeURIComponent(e)}/pretty?${new URLSearchParams({other:t})}`,A,n,r)}function hn(e,t,n,r,{signal:i}={}){return M(`/api/npm/pretty?${new URLSearchParams({name:e,version:t,otherVersion:n})}`,w,r,i)}function M(e,t,n,r,i=A){return E(e,t,async e=>{let t=f.generation;for await(let{error:r,status:a,...o}of j(e)){if(t!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);await n(r?{...o,status:a,message:i[r]??i[a]??`Request failed (${a})`}:o)}},r)}var gn={...A,413:`This file is too large to compare with renamed names hidden.`,422:`This file couldn't be compared as code.`,"diff-busy":`Too many files are being compared. Try again shortly.`,504:`Comparing this file took too long.`},_n=(e,t)=>E(e,gn,e=>e.json(),t);function vn(e,t,{path:n,hash:r,otherPath:i,otherHash:a},{signal:o}={}){return _n(`/api/bundles/${encodeURIComponent(e)}/rename-diff?${new URLSearchParams({path:n,hash:r,other:t,otherPath:i,otherHash:a})}`,o)}function yn(e,t,n,{path:r,hash:i,otherPath:a,otherHash:o},{signal:s}={}){return _n(`/api/npm/rename-diff?${new URLSearchParams({name:e,version:t,path:r,hash:i,otherVersion:n,otherPath:a,otherHash:o})}`,s)}var bn=(e,t)=>new URLSearchParams({other:e,...t?{scope:t}:{}});function xn(e,t,n,{signal:r,scope:i=``}={}){return M(`/api/bundles/${encodeURIComponent(e)}/rename-diff?${bn(t,i)}`,A,n,r,gn)}function Sn(e,t,n,r,{signal:i}={}){return M(`/api/npm/rename-diff?${new URLSearchParams({name:e,version:t,otherVersion:n})}`,w,r,i,gn)}function Cn(e,t,n,{signal:r,scope:i=``}={}){return M(`/api/bundles/${encodeURIComponent(e)}/type-only?${bn(t,i)}&runs=1`,A,n,r)}function wn(e,t,n,r,{signal:i}={}){return M(`/api/npm/type-only?${new URLSearchParams({name:e,version:t,otherVersion:n,runs:`1`})}`,w,r,i)}var Tn={...w,"delta-busy":`Too many packages are being counted. Try again shortly.`,"delta-timeout":`Counting its lines took too long.`,"delta-failed":`Its lines couldn’t be counted.`};function En(e,t,{signal:n}={}){return E(`/api/npm/deltas?${new URLSearchParams({versions:JSON.stringify(e)})}`,Tn,async e=>{let n=f.generation;for await(let{error:r,status:i,...a}of j(e)){if(n!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);t(r?{...a,error:Tn[r]??Tn[i]??`Request failed (${i})`}:a)}},n)}var Dn={404:`This bundle is no longer available.`,422:`This bundle couldn't be read.`,429:`Too many bundles are being compared. Try again shortly.`},On=async e=>{let t=await e.json();return t.files.basePaths=new Map(t.files.basePaths),t};function kn(e,t,{signal:n,scope:r=``}={}){return E(`/api/bundles/${encodeURIComponent(e)}/comparison?${bn(t,r)}`,Dn,On,n)}function An(e,t,n,{signal:r,otherName:i=e,patch:a=null}={}){return E(`/api/npm/comparison?${new URLSearchParams({name:e,version:t,otherVersion:n,...i===e?{}:{otherName:i},...dt(a)})}`,w,On,r)}async function N(e,t){let n=await d(e,{signal:t,credentials:`same-origin`,headers:{accept:`application/json`}});if(!n.ok)throw Error(`HTTP ${n.status}`);return n.json()}function P(e,t,n){let r={"content-type":`application/json`};return t&&(r[`x-csrf-token`]=t),d(e,{method:`POST`,credentials:`same-origin`,headers:r,body:JSON.stringify(n)})}async function F(e){let t=await e.json().then(e=>typeof e?.error==`string`?e.error:``,()=>``);return[`repo-forbidden`,`forbidden`].includes(t)?`choose a repository and directory within your team access`:`HTTP 403${t?`: ${t}`:``}`}async function jn(e,t,n){let r=n?{"x-csrf-token":n}:{},i=await d(`/api/admin/${e}/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`same-origin`,headers:r});if(!i.ok)throw Error(`HTTP ${i.status}`)}async function Mn(e,t,n,r,i,a){let o=new URLSearchParams({page:String(t),limit:`100`,kind:n,q:r.trim()});i&&o.set(`repo`,i),a&&o.set(`actor`,a);let s=await N(`/api/admin/history?${o}`,e);if(!Array.isArray(s?.history)||!Number.isSafeInteger(s.total)||s.total<0||!Number.isSafeInteger(s.page)||s.page<1)throw Error(`No history returned`);return s}async function Nn(e){let t=await N(`/api/admin/users`,e);return Array.isArray(t?.users)?t.users:[]}async function Pn(e,t,n){let r=await P(`/api/admin/set-role`,n,{userId:e,role:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function Fn(e,t,n,r){let i=new URLSearchParams({scope:e});return e===`installed`&&i.set(`showAll`,String(t)),n&&i.set(`refresh`,`true`),await N(`/api/admin/repositories?${i}`,r)}async function In(e,t,n){let r=await P(`/api/admin/repositories/select`,n,{repoId:e,selected:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function Ln(e,{enabled:t,required:n,since:r,lockfiles:i},a){let o=await P(`/api/admin/repositories/dependency-review`,a,{repoId:e,enabled:t,required:n,since:r,...i?{lockfiles:i}:{}});if(!o.ok)throw Error(o.status===400?`Enter 1 to 10 required reviews, the commit as its full 40-character id, and at most 100 lockfiles by their paths in the repository; a stasis.config.json only among those reviewed alone.`:`HTTP ${o.status}`);return(await o.json()).dependencyReview}async function Rn(e,t){let n=await N(`/api/admin/repositories/lockfiles?repoId=${encodeURIComponent(e)}`,t);return{paths:Array.isArray(n?.lockfiles)?n.lockfiles.flatMap(e=>typeof e?.path==`string`?[e.path]:[]):[],configs:Array.isArray(n?.configs)?n.configs.filter(e=>typeof e==`string`):[]}}async function zn(e,t){let n=await d(`/api/admin/repositories/add-public`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,"x-csrf-token":t},body:JSON.stringify({repository:e})});if(!n.ok)throw Error({400:`Enter a repository as owner/repo or a GitHub repository URL.`,403:`You do not have permission to add arbitrary public repositories.`,404:`No public repository was found at that address.`,409:`Choose a public, non-archived repository.`}[n.status]??`GitHub lookup failed (HTTP ${n.status}). Try again.`)}async function Bn(e,t){let n=await N(`/api/admin/repositories/impact?repoId=${encodeURIComponent(e)}`,t);if(n?.repoId!==e||!Array.isArray(n.reports)||!Array.isArray(n.bundles)||!Number.isSafeInteger(n.triageCount)||n.triageCount<0)throw Error(`Invalid repository data`);return n}async function Vn(e,t){let n=await d(`/api/admin/repositories/connect-app`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,"x-csrf-token":t},body:JSON.stringify({repoId:e})}),r=await n.json();if(!n.ok)throw Error({"github-app-not-configured":`The GitHub App is not configured on this server.`,"repo-identity-changed":`The repository has changed on GitHub. Refresh and check its connection.`,"repo-connection-changed":`The connection or your permissions changed. Refresh and try again.`,"repo-not-connected":`This repository is no longer connected.`,forbidden:`Administrator access is required to connect the GitHub App.`}[r.error]??`Could not connect the GitHub App (HTTP ${n.status}). Try again.`);if(r.connected===!0)return r;if(r.connected!==!1||typeof r.installUrl!=`string`||!/^https:\/\/github\.com\/apps\/[^/?#]+\/installations\/new$/u.test(r.installUrl))throw Error(`Invalid GitHub installation response.`);return r}async function Hn(e,t,n,r){let i=await P(`/api/admin/repositories/remove`,r,{repoId:e,fullName:t,acknowledge:!0,deleteTriage:n});if(!i.ok)throw Error(`HTTP ${i.status}`);return i.json()}async function Un(e){return await N(`/api/admin/reports`,e)}async function Wn(e,t,n){let r=await d(`/api/admin/bundles/create`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{"content-type":`application/json`,"x-csrf-token":t},body:JSON.stringify(e)}),i=await r.json();if(!r.ok)throw Error({"unsupported-entries":`Select JavaScript/TypeScript files (including JSX/TSX) or Solidity files. Stasis cannot mix languages or use JSON or Rust as remote entry points.`,"bad-conditions":`Check the export conditions and selected platforms.`,"metro-conditions":`Stasis’s Metro preset requires the react-native condition without manual changes.`,"config-invalid":`Stasis can’t read the stasis.config.json these entry points are under, build them with the options it sets, or lay out the lockfiles it names. Check it at this revision.`,"config-mixed":`Entry points listed in a stasis.config.json are built with its options, alone. Select only those it lists, or only other files.`,"config-conditions":`These entry points are listed in stasis.config.json, which sets their options, so they take no conditions. Reload the directory and try again.`,"config-runs-code":`stasis.config.json sets an option for these entry points that runs the repository’s code, such as babel. Bundles built here never run it.`,"config-policy":`The bundle holds a path or package that stasis.config.json’s allowedPaths, disallowedPaths, allowedModules or disallowedModules refuses, or that its excludeModules excludes.`,"stasis-lock":`The build doesn’t agree with the repository’s stasis.lock.json, or stasis.config.json’s lock = frozen needs one that isn’t there. Update it at this revision.`,"commit-not-own":`Stasis can’t find this commit in the history of the repository’s branches or tags: it may be a fork’s, which GitHub serves through the repository too. Pick a commit of its default branch, a branch or a tag.`,"build-lockfile":`Stasis needs a supported lockfile: pnpm-lock.yaml, yarn.lock (Yarn 1), package-lock.json, or soldeer.lock.`,"build-scope":`Your team needs access to the bundle’s project root, including its lockfile and dependencies.`,"build-busy":`A bundle is already being built, or the server is busy. Try again shortly.`,"build-timeout":`The bundle build timed out. Try a smaller selection or retry.`,"too-large":`This bundle exceeds the server’s size limit.`,"build-memory":`Building this selection needs more memory than the server gives a build. Select fewer entry points, or build it with stasis github-bundle and upload the bundle.`,"github-rate-limited":`GitHub’s API rate limit has been reached. Retry after the limit resets.`,"github-build-failed":`Could not fetch the repository from GitHub. Check access and retry.`,"repository-changed":`The repository connection changed during the build. Reload and try again.`,"bundle-conflict":`This bundle already exists but is outside your current access.`,"build-failed":`Stasis could not build this selection. Check that its lockfile is supported and all entry points and imports exist at this commit.`}[i.error]??(r.status===401?`Sign in again to create a bundle.`:r.status===403||r.status===404?`Repository access is required to create this bundle.`:`Could not create the bundle. Try again.`));return i}async function Gn(e,t,n=null,r=``){let i=(await N(`/api/config`)).managed?.uploadMaxBytes?.reports;if(Number.isSafeInteger(i)&&i>0){if(e.size>i)throw Error(`too large`)}else if(e.size>3145728)return Kn(e,t,n,r);let a=De(await e.text(),e.name);if(!a)return Kn(e,t,n,r);let o=[],s=[];for(let{name:e,content:i}of a)try{s.push(await Kn(new File([i],e,{type:`application/json`}),t,n,r))}catch(t){o.push(`${e}: ${String(t?.message??t)}`)}if(o.length>0)throw Error(`${o.length} of ${a.length} products failed (${o.join(`; `)})`);return s.at(-1)}async function Kn(e,t,n,r){let i={"content-type":e.type||`application/json`,"x-report-filename":encodeURIComponent(e.name)};t&&(i[`x-csrf-token`]=t),n!=null&&(i[`x-repo-id`]=String(n)),r!==``&&(i[`x-repo-directory`]=encodeURIComponent(r));let a=await d(`/api/admin/reports`,{method:`POST`,credentials:`same-origin`,headers:i,body:e});if(!a.ok){if(a.status===413)throw Error(`too large`);if(a.status===403)throw Error(await F(a));let e=await a.json().catch(()=>null);if(e?.error===`storage-encryption-required`)throw Error(`Link reports require managed storage encryption. Configure MANAGED_STORAGE_ENCRYPTION_KEY.`);if(e?.error===`invalid-report`)throw Error(typeof e.reason==`string`&&e.reason?`This file is not a report: ${e.reason}`:`This file is not a recognized report.`);let t=e?.error===`repo-not-connected`&&typeof e.repo==`string`?`: ${e.repo} is not connected`:``;throw Error(`HTTP ${a.status}${t}`)}return a.json()}async function qn(e,t,n){let r=await P(`/api/admin/reports/set-visible`,n,{reportId:e,visible:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function Jn(e,t,n,r){let i=await P(`/api/admin/reports/set-repo`,r,{reportId:e,repoId:t,directory:n});if(!i.ok)throw i.status===409?Error(`this report already defines its repository`):i.status===403?Error(await F(i)):Error(i.status===400?`invalid repository or directory`:`HTTP ${i.status}`);return i.json()}async function Yn(e,t){let n=await d(`/api/admin/reports/${encodeURIComponent(e)}/location`,{signal:t,credentials:`same-origin`});if(!n.ok)throw Error(`Report location suggestion request failed (${n.status})`);return(await n.json())?.location??null}async function Xn(e,t){await jn(`reports`,e,t)}async function Zn(e){return await N(`/api/admin/bundles`,e)}async function Qn(e,t,n,r=``){let i={"content-type":`application/octet-stream`,"x-bundle-filename":encodeURIComponent(e.name)};t&&(i[`x-csrf-token`]=t),n!=null&&(i[`x-repo-id`]=String(n)),r&&(i[`x-repo-directory`]=encodeURIComponent(r));let a=await d(`/api/admin/bundles`,{method:`POST`,credentials:`same-origin`,headers:i,body:e});if(!a.ok)throw Error(a.status===413?`too large`:a.status===403?await F(a):`HTTP ${a.status}`);return a.json()}async function $n(e,t){let n=await N(`/api/admin/bundles/${encodeURIComponent(e)}/usage`,t);if(n?.bundleId!==e||!Array.isArray(n.reports)||!n.reports.every(e=>typeof e?.filename==`string`)||!Number.isSafeInteger(n.otherReports)||n.otherReports<0)throw Error(`Invalid bundle usage`);return n}async function er(e,t){await jn(`bundles`,e,t)}async function tr(e,t,n){let r=await P(`/api/admin/bundles/set-visible`,n,{bundleId:e,visible:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function nr(e,t,n,r){let i=await P(`/api/admin/bundles/set-repo`,r,{bundleId:e,repoId:t,directory:n});if(!i.ok)throw Error(i.status===403?await F(i):i.status===400?`invalid repository or directory`:`HTTP ${i.status}`)}async function rr(e){return await N(`/api/admin/teams`,e)}async function I(e,t,n){let r=await P(e,t,n);if(!r.ok)throw Error(r.status===409?`name already taken`:`HTTP ${r.status}`)}function ir(e,t=!0){let n=document.createElement(`input`);n.type=`file`,n.multiple=t,n.addEventListener(`change`,()=>{e([...n.files])},{once:!0}),n.click()}function ar(e,t,n){let r=0,i=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),a=e=>{i(e)&&(e.preventDefault(),r+=1,n(!0))},o=e=>{i(e)&&e.preventDefault()},s=e=>{i(e)&&(r=Math.max(0,r-1),r===0&&n(!1))},c=e=>{i(e)&&(e.preventDefault(),e.stopPropagation(),r=0,n(!1),t([...e.dataTransfer.files]))};return e.addEventListener(`dragenter`,a),e.addEventListener(`dragover`,o),e.addEventListener(`dragleave`,s),e.addEventListener(`drop`,c),()=>{e.removeEventListener(`dragenter`,a),e.removeEventListener(`dragover`,o),e.removeEventListener(`dragleave`,s),e.removeEventListener(`drop`,c)}}async function or(e,t,n,r){let i=e.appState.generation;try{return await e.appState.mutate(()=>n(t),r)}catch(t){throw i===e.appState.generation&&e.appState.invalidate(r),t}}async function sr(e,t,n,r){if(e._busy||!e._csrf)throw Error(`Wait for the current operation to finish, then try again.`);e._busy=!0;try{await or(e,t,n,r)}finally{await e._load(),e._busy=!1;let t=e._queue.splice(0);t.length>0&&e._upload(t)}}async function L(e,t,n,r){if(t.length===0||(e._queue.push(...t),e._busy))return;e._busy=!0,e._error=null;let i=e.appState.generation,a=[],o=0;try{for(;e._queue.length>0;){if(e.appState.generation!==i){e._queue=[];break}let t=e._queue.shift();try{await or(e,t,n,r)}catch(n){if(n?.name===`AbortError`||e.appState.generation!==i){e._queue=[];break}a.push(`${t.name}: ${String(n?.message??n)}`)}o++}}finally{a.length>0&&(e._error=o===1?`Upload failed: ${a[0]}`:`Upload failed for ${a.length} of ${o} files: ${a.join(`; `)}`),e._busy=!1,await e._load({preserveError:!0})}}var cr=`.local-import-toggle{flex-shrink:0;margin-block:calc(-.25rem - 1px);margin-left:auto;padding:.25rem .6rem;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);background:transparent;color:var(--muted);font:inherit;font-size:.75rem;line-height:1.5}.local-import-toggle:hover,.local-import-toggle[aria-expanded=true]{color:var(--text);background:rgb(from var(--text) r g b / .06)}.local-import-panel{display:grid;gap:.8rem;padding:1rem;margin-bottom:1.25rem;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:rgb(from var(--accent) r g b / .025)}.local-import-copy strong{font-size:.82rem;font-weight:600}.local-import-copy p,.local-import-message{margin:.3rem 0 0;color:var(--muted);font-size:.75rem;line-height:1.5}.local-import-controls{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}managed-local-item-selector{flex:1 1 16rem;min-width:0}.local-import-controls button,.local-import-message button{padding:.35rem .7rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:transparent;color:var(--text);font:inherit;font-size:.75rem;line-height:1.5}.local-import-controls .local-import-submit{border-color:rgb(from var(--accent) r g b / .4);background:rgb(from var(--accent) r g b / .1);color:var(--accent)}.local-import-controls .local-import-close{color:var(--muted)}.local-import-panel button:disabled,.local-import-toggle:disabled{opacity:.5}.local-import-panel button:focus-visible,.local-import-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.local-import-message.error{color:var(--critical)}
3
+ `,i))n.push(r.slice(i,e)),yield JSON.parse(n.join(``)),n=[];n.push(r.slice(i))}}function pn(e,t,n,{signal:r}={}){return M(`/api/npm/pretty?${new URLSearchParams({name:e,version:t})}`,w,n,r)}function mn(e,t,n,{signal:r}={}){return M(`/api/bundles/${encodeURIComponent(e)}/pretty?${new URLSearchParams({other:t})}`,A,n,r)}function hn(e,t,n,r,{signal:i}={}){return M(`/api/npm/pretty?${new URLSearchParams({name:e,version:t,otherVersion:n})}`,w,r,i)}function M(e,t,n,r,i=A){return E(e,t,async e=>{let t=f.generation;for await(let{error:r,status:a,...o}of j(e)){if(t!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);await n(r?{...o,status:a,message:i[r]??i[a]??`Request failed (${a})`}:o)}},r)}var gn={...A,413:`This file is too large to compare with renamed names hidden.`,422:`This file couldn't be compared as code.`,"diff-busy":`Too many files are being compared. Try again shortly.`,504:`Comparing this file took too long.`},_n=(e,t)=>E(e,gn,e=>e.json(),t);function vn(e,t,{path:n,hash:r,otherPath:i,otherHash:a},{signal:o}={}){return _n(`/api/bundles/${encodeURIComponent(e)}/rename-diff?${new URLSearchParams({path:n,hash:r,other:t,otherPath:i,otherHash:a})}`,o)}function yn(e,t,n,{path:r,hash:i,otherPath:a,otherHash:o},{signal:s}={}){return _n(`/api/npm/rename-diff?${new URLSearchParams({name:e,version:t,path:r,hash:i,otherVersion:n,otherPath:a,otherHash:o})}`,s)}var bn=(e,t)=>new URLSearchParams({other:e,...t?{scope:t}:{}});function xn(e,t,n,{signal:r,scope:i=``}={}){return M(`/api/bundles/${encodeURIComponent(e)}/rename-diff?${bn(t,i)}`,A,n,r,gn)}function Sn(e,t,n,r,{signal:i}={}){return M(`/api/npm/rename-diff?${new URLSearchParams({name:e,version:t,otherVersion:n})}`,w,r,i,gn)}function Cn(e,t,n,{signal:r,scope:i=``}={}){return M(`/api/bundles/${encodeURIComponent(e)}/type-only?${bn(t,i)}&runs=1`,A,n,r)}function wn(e,t,n,r,{signal:i}={}){return M(`/api/npm/type-only?${new URLSearchParams({name:e,version:t,otherVersion:n,runs:`1`})}`,w,r,i)}var Tn={...w,"delta-busy":`Too many packages are being counted. Try again shortly.`,"delta-timeout":`Counting its lines took too long.`,"delta-failed":`Its lines couldn’t be counted.`};function En(e,t,{signal:n}={}){return E(`/api/npm/deltas?${new URLSearchParams({versions:JSON.stringify(e)})}`,Tn,async e=>{let n=f.generation;for await(let{error:r,status:i,...a}of j(e)){if(n!==f.generation)throw new DOMException(`Managed session changed`,`AbortError`);t(r?{...a,error:Tn[r]??Tn[i]??`Request failed (${i})`}:a)}},n)}var Dn={404:`This bundle is no longer available.`,422:`This bundle couldn't be read.`,429:`Too many bundles are being compared. Try again shortly.`},On=async e=>{let t=await e.json();return t.files.basePaths=new Map(t.files.basePaths),t};function kn(e,t,{signal:n,scope:r=``}={}){return E(`/api/bundles/${encodeURIComponent(e)}/comparison?${bn(t,r)}`,Dn,On,n)}function An(e,t,n,{signal:r,otherName:i=e,patch:a=null,otherPatch:o=null}={}){return E(`/api/npm/comparison?${new URLSearchParams({name:e,version:t,otherVersion:n,...i===e?{}:{otherName:i},...dt(a),...o?{otherPatchHash:o.hash}:{}})}`,w,On,r)}async function N(e,t){let n=await d(e,{signal:t,credentials:`same-origin`,headers:{accept:`application/json`}});if(!n.ok)throw Error(`HTTP ${n.status}`);return n.json()}function P(e,t,n){let r={"content-type":`application/json`};return t&&(r[`x-csrf-token`]=t),d(e,{method:`POST`,credentials:`same-origin`,headers:r,body:JSON.stringify(n)})}async function F(e){let t=await e.json().then(e=>typeof e?.error==`string`?e.error:``,()=>``);return[`repo-forbidden`,`forbidden`].includes(t)?`choose a repository and directory within your team access`:`HTTP 403${t?`: ${t}`:``}`}async function jn(e,t,n){let r=n?{"x-csrf-token":n}:{},i=await d(`/api/admin/${e}/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`same-origin`,headers:r});if(!i.ok)throw Error(`HTTP ${i.status}`)}async function Mn(e,t,n,r,i,a){let o=new URLSearchParams({page:String(t),limit:`100`,kind:n,q:r.trim()});i&&o.set(`repo`,i),a&&o.set(`actor`,a);let s=await N(`/api/admin/history?${o}`,e);if(!Array.isArray(s?.history)||!Number.isSafeInteger(s.total)||s.total<0||!Number.isSafeInteger(s.page)||s.page<1)throw Error(`No history returned`);return s}async function Nn(e){let t=await N(`/api/admin/users`,e);return Array.isArray(t?.users)?t.users:[]}async function Pn(e,t,n){let r=await P(`/api/admin/set-role`,n,{userId:e,role:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function Fn(e,t,n,r){let i=new URLSearchParams({scope:e});return e===`installed`&&i.set(`showAll`,String(t)),n&&i.set(`refresh`,`true`),await N(`/api/admin/repositories?${i}`,r)}async function In(e,t,n){let r=await P(`/api/admin/repositories/select`,n,{repoId:e,selected:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function Ln(e,{enabled:t,required:n,since:r,lockfiles:i},a){let o=await P(`/api/admin/repositories/dependency-review`,a,{repoId:e,enabled:t,required:n,since:r,...i?{lockfiles:i}:{}});if(!o.ok)throw Error(o.status===400?`Enter 1 to 10 required reviews, the commit as its full 40-character id, and at most 100 lockfiles by their paths in the repository; a stasis.config.json only among those reviewed alone.`:`HTTP ${o.status}`);return(await o.json()).dependencyReview}async function Rn(e,t){let n=await N(`/api/admin/repositories/lockfiles?repoId=${encodeURIComponent(e)}`,t);return{paths:Array.isArray(n?.lockfiles)?n.lockfiles.flatMap(e=>typeof e?.path==`string`?[e.path]:[]):[],configs:Array.isArray(n?.configs)?n.configs.filter(e=>typeof e==`string`):[]}}async function zn(e,t){let n=await d(`/api/admin/repositories/add-public`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,"x-csrf-token":t},body:JSON.stringify({repository:e})});if(!n.ok)throw Error({400:`Enter a repository as owner/repo or a GitHub repository URL.`,403:`You do not have permission to add arbitrary public repositories.`,404:`No public repository was found at that address.`,409:`Choose a public, non-archived repository.`}[n.status]??`GitHub lookup failed (HTTP ${n.status}). Try again.`)}async function Bn(e,t){let n=await N(`/api/admin/repositories/impact?repoId=${encodeURIComponent(e)}`,t);if(n?.repoId!==e||!Array.isArray(n.reports)||!Array.isArray(n.bundles)||!Number.isSafeInteger(n.triageCount)||n.triageCount<0)throw Error(`Invalid repository data`);return n}async function Vn(e,t){let n=await d(`/api/admin/repositories/connect-app`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,"x-csrf-token":t},body:JSON.stringify({repoId:e})}),r=await n.json();if(!n.ok)throw Error({"github-app-not-configured":`The GitHub App is not configured on this server.`,"repo-identity-changed":`The repository has changed on GitHub. Refresh and check its connection.`,"repo-connection-changed":`The connection or your permissions changed. Refresh and try again.`,"repo-not-connected":`This repository is no longer connected.`,forbidden:`Administrator access is required to connect the GitHub App.`}[r.error]??`Could not connect the GitHub App (HTTP ${n.status}). Try again.`);if(r.connected===!0)return r;if(r.connected!==!1||typeof r.installUrl!=`string`||!/^https:\/\/github\.com\/apps\/[^/?#]+\/installations\/new$/u.test(r.installUrl))throw Error(`Invalid GitHub installation response.`);return r}async function Hn(e,t,n,r){let i=await P(`/api/admin/repositories/remove`,r,{repoId:e,fullName:t,acknowledge:!0,deleteTriage:n});if(!i.ok)throw Error(`HTTP ${i.status}`);return i.json()}async function Un(e){return await N(`/api/admin/reports`,e)}async function Wn(e,t,n){let r=await d(`/api/admin/bundles/create`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{"content-type":`application/json`,"x-csrf-token":t},body:JSON.stringify(e)}),i=await r.json();if(!r.ok)throw Error({"unsupported-entries":`Select JavaScript/TypeScript files (including JSX/TSX) or Solidity files. Stasis cannot mix languages or use JSON or Rust as remote entry points.`,"bad-conditions":`Check the export conditions and selected platforms.`,"metro-conditions":`Stasis’s Metro preset requires the react-native condition without manual changes.`,"config-invalid":`Stasis can’t read the stasis.config.json these entry points are under, build them with the options it sets, or lay out the lockfiles it names. Check it at this revision.`,"config-mixed":`Entry points listed in a stasis.config.json are built with its options, alone. Select only those it lists, or only other files.`,"config-conditions":`These entry points are listed in stasis.config.json, which sets their options, so they take no conditions. Reload the directory and try again.`,"config-runs-code":`stasis.config.json sets an option for these entry points that runs the repository’s code, such as babel. Bundles built here never run it.`,"config-policy":`The bundle holds a path or package that stasis.config.json’s allowedPaths, disallowedPaths, allowedModules or disallowedModules refuses, or that its excludeModules excludes.`,"stasis-lock":`The build doesn’t agree with the repository’s stasis.lock.json, or stasis.config.json’s lock = frozen needs one that isn’t there. Update it at this revision.`,"commit-not-own":`Stasis can’t find this commit in the history of the repository’s branches or tags: it may be a fork’s, which GitHub serves through the repository too. Pick a commit of its default branch, a branch or a tag.`,"build-lockfile":`Stasis needs a supported lockfile: pnpm-lock.yaml, yarn.lock (Yarn 1), package-lock.json, or soldeer.lock.`,"build-scope":`Your team needs access to the bundle’s project root, including its lockfile and dependencies.`,"build-busy":`A bundle is already being built, or the server is busy. Try again shortly.`,"build-timeout":`The bundle build timed out. Try a smaller selection or retry.`,"too-large":`This bundle exceeds the server’s size limit.`,"build-memory":`Building this selection needs more memory than the server gives a build. Select fewer entry points, or build it with stasis github-bundle and upload the bundle.`,"github-rate-limited":`GitHub’s API rate limit has been reached. Retry after the limit resets.`,"github-build-failed":`Could not fetch the repository from GitHub. Check access and retry.`,"repository-changed":`The repository connection changed during the build. Reload and try again.`,"bundle-conflict":`This bundle already exists but is outside your current access.`,"build-failed":`Stasis could not build this selection. Check that its lockfile is supported and all entry points and imports exist at this commit.`}[i.error]??(r.status===401?`Sign in again to create a bundle.`:r.status===403||r.status===404?`Repository access is required to create this bundle.`:`Could not create the bundle. Try again.`));return i}async function Gn(e,t,n=null,r=``){let i=(await N(`/api/config`)).managed?.uploadMaxBytes?.reports;if(Number.isSafeInteger(i)&&i>0){if(e.size>i)throw Error(`too large`)}else if(e.size>3145728)return Kn(e,t,n,r);let a=De(await e.text(),e.name);if(!a)return Kn(e,t,n,r);let o=[],s=[];for(let{name:e,content:i}of a)try{s.push(await Kn(new File([i],e,{type:`application/json`}),t,n,r))}catch(t){o.push(`${e}: ${String(t?.message??t)}`)}if(o.length>0)throw Error(`${o.length} of ${a.length} products failed (${o.join(`; `)})`);return s.at(-1)}async function Kn(e,t,n,r){let i={"content-type":e.type||`application/json`,"x-report-filename":encodeURIComponent(e.name)};t&&(i[`x-csrf-token`]=t),n!=null&&(i[`x-repo-id`]=String(n)),r!==``&&(i[`x-repo-directory`]=encodeURIComponent(r));let a=await d(`/api/admin/reports`,{method:`POST`,credentials:`same-origin`,headers:i,body:e});if(!a.ok){if(a.status===413)throw Error(`too large`);if(a.status===403)throw Error(await F(a));let e=await a.json().catch(()=>null);if(e?.error===`storage-encryption-required`)throw Error(`Link reports require managed storage encryption. Configure MANAGED_STORAGE_ENCRYPTION_KEY.`);if(e?.error===`invalid-report`)throw Error(typeof e.reason==`string`&&e.reason?`This file is not a report: ${e.reason}`:`This file is not a recognized report.`);let t=e?.error===`repo-not-connected`&&typeof e.repo==`string`?`: ${e.repo} is not connected`:``;throw Error(`HTTP ${a.status}${t}`)}return a.json()}async function qn(e,t,n){let r=await P(`/api/admin/reports/set-visible`,n,{reportId:e,visible:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function Jn(e,t,n,r){let i=await P(`/api/admin/reports/set-repo`,r,{reportId:e,repoId:t,directory:n});if(!i.ok)throw i.status===409?Error(`this report already defines its repository`):i.status===403?Error(await F(i)):Error(i.status===400?`invalid repository or directory`:`HTTP ${i.status}`);return i.json()}async function Yn(e,t){let n=await d(`/api/admin/reports/${encodeURIComponent(e)}/location`,{signal:t,credentials:`same-origin`});if(!n.ok)throw Error(`Report location suggestion request failed (${n.status})`);return(await n.json())?.location??null}async function Xn(e,t){await jn(`reports`,e,t)}async function Zn(e){return await N(`/api/admin/bundles`,e)}async function Qn(e,t,n,r=``){let i={"content-type":`application/octet-stream`,"x-bundle-filename":encodeURIComponent(e.name)};t&&(i[`x-csrf-token`]=t),n!=null&&(i[`x-repo-id`]=String(n)),r&&(i[`x-repo-directory`]=encodeURIComponent(r));let a=await d(`/api/admin/bundles`,{method:`POST`,credentials:`same-origin`,headers:i,body:e});if(!a.ok)throw Error(a.status===413?`too large`:a.status===403?await F(a):`HTTP ${a.status}`);return a.json()}async function $n(e,t){let n=await N(`/api/admin/bundles/${encodeURIComponent(e)}/usage`,t);if(n?.bundleId!==e||!Array.isArray(n.reports)||!n.reports.every(e=>typeof e?.filename==`string`)||!Number.isSafeInteger(n.otherReports)||n.otherReports<0)throw Error(`Invalid bundle usage`);return n}async function er(e,t){await jn(`bundles`,e,t)}async function tr(e,t,n){let r=await P(`/api/admin/bundles/set-visible`,n,{bundleId:e,visible:t});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function nr(e,t,n,r){let i=await P(`/api/admin/bundles/set-repo`,r,{bundleId:e,repoId:t,directory:n});if(!i.ok)throw Error(i.status===403?await F(i):i.status===400?`invalid repository or directory`:`HTTP ${i.status}`)}async function rr(e){return await N(`/api/admin/teams`,e)}async function I(e,t,n){let r=await P(e,t,n);if(!r.ok)throw Error(r.status===409?`name already taken`:`HTTP ${r.status}`)}function ir(e,t=!0){let n=document.createElement(`input`);n.type=`file`,n.multiple=t,n.addEventListener(`change`,()=>{e([...n.files])},{once:!0}),n.click()}function ar(e,t,n){let r=0,i=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),a=e=>{i(e)&&(e.preventDefault(),r+=1,n(!0))},o=e=>{i(e)&&e.preventDefault()},s=e=>{i(e)&&(r=Math.max(0,r-1),r===0&&n(!1))},c=e=>{i(e)&&(e.preventDefault(),e.stopPropagation(),r=0,n(!1),t([...e.dataTransfer.files]))};return e.addEventListener(`dragenter`,a),e.addEventListener(`dragover`,o),e.addEventListener(`dragleave`,s),e.addEventListener(`drop`,c),()=>{e.removeEventListener(`dragenter`,a),e.removeEventListener(`dragover`,o),e.removeEventListener(`dragleave`,s),e.removeEventListener(`drop`,c)}}async function or(e,t,n,r){let i=e.appState.generation;try{return await e.appState.mutate(()=>n(t),r)}catch(t){throw i===e.appState.generation&&e.appState.invalidate(r),t}}async function sr(e,t,n,r){if(e._busy||!e._csrf)throw Error(`Wait for the current operation to finish, then try again.`);e._busy=!0;try{await or(e,t,n,r)}finally{await e._load(),e._busy=!1;let t=e._queue.splice(0);t.length>0&&e._upload(t)}}async function L(e,t,n,r){if(t.length===0||(e._queue.push(...t),e._busy))return;e._busy=!0,e._error=null;let i=e.appState.generation,a=[],o=0;try{for(;e._queue.length>0;){if(e.appState.generation!==i){e._queue=[];break}let t=e._queue.shift();try{await or(e,t,n,r)}catch(n){if(n?.name===`AbortError`||e.appState.generation!==i){e._queue=[];break}a.push(`${t.name}: ${String(n?.message??n)}`)}o++}}finally{a.length>0&&(e._error=o===1?`Upload failed: ${a[0]}`:`Upload failed for ${a.length} of ${o} files: ${a.join(`; `)}`),e._busy=!1,await e._load({preserveError:!0})}}var cr=`.local-import-toggle{flex-shrink:0;margin-block:calc(-.25rem - 1px);margin-left:auto;padding:.25rem .6rem;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);background:transparent;color:var(--muted);font:inherit;font-size:.75rem;line-height:1.5}.local-import-toggle:hover,.local-import-toggle[aria-expanded=true]{color:var(--text);background:rgb(from var(--text) r g b / .06)}.local-import-panel{display:grid;gap:.8rem;padding:1rem;margin-bottom:1.25rem;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:rgb(from var(--accent) r g b / .025)}.local-import-copy strong{font-size:.82rem;font-weight:600}.local-import-copy p,.local-import-message{margin:.3rem 0 0;color:var(--muted);font-size:.75rem;line-height:1.5}.local-import-controls{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}managed-local-item-selector{flex:1 1 16rem;min-width:0}.local-import-controls button,.local-import-message button{padding:.35rem .7rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:transparent;color:var(--text);font:inherit;font-size:.75rem;line-height:1.5}.local-import-controls .local-import-submit{border-color:rgb(from var(--accent) r g b / .4);background:rgb(from var(--accent) r g b / .1);color:var(--accent)}.local-import-controls .local-import-close{color:var(--muted)}.local-import-panel button:disabled,.local-import-toggle:disabled{opacity:.5}.local-import-panel button:focus-visible,.local-import-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.local-import-message.error{color:var(--critical)}
4
4
  `,lr=`.home-section{margin-top:1.1rem;margin-bottom:2rem}.section-heading{display:flex;align-items:baseline;gap:1rem;margin-bottom:.85rem}.section-heading h2{margin:0;font-size:.86rem;font-weight:600}.section-heading>span{color:var(--muted);font-size:.75rem}.pages{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.9rem}.page{display:flex;flex-direction:column;gap:.85rem;padding:1.35rem;border:1px solid var(--border);border-radius:var(--ui-radius, 12px);color:var(--text);background:var(--panel);text-align:left;font:inherit}.page:hover{background:var(--panel-hover);border-color:color-mix(in srgb,var(--muted) 60%,var(--border))}.page-top{display:flex;align-items:center;gap:.75rem;width:100%}.page-icon{display:grid;place-items:center;flex-shrink:0;width:2.5rem;height:2.5rem;border:1px solid color-mix(in srgb,var(--accent) 16%,var(--border));border-radius:var(--ui-radius, 9px);background:color-mix(in srgb,var(--accent) 7%,var(--panel));color:var(--accent)}.page-bundle .page-icon{color:var(--green);border-color:color-mix(in srgb,var(--green) 18%,var(--border));background:color-mix(in srgb,var(--green) 6%,var(--panel))}.page-scan .page-icon{color:var(--scan-icon-color, var(--yellow));border-color:color-mix(in srgb,var(--scan-icon-color, var(--yellow)) 18%,var(--border));background:color-mix(in srgb,var(--scan-icon-color, var(--yellow)) 6%,var(--panel))}:host-context(body.theme-light) .page-scan .page-icon{--scan-icon-color: #bf8700}:host-context(body.theme-green) :is(.page-bundle,.page-scan) .page-icon,:host-context(body.theme-pink) :is(.page-bundle,.page-scan) .page-icon{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 16%,var(--border));background:color-mix(in srgb,var(--accent) 7%,var(--panel))}.page-icon svg{width:1.2rem;height:1.2rem}.arrow{display:flex;margin-left:auto;flex-shrink:0;color:var(--muted)}.arrow svg{width:1rem;height:1rem}.page:hover .arrow{color:var(--text)}.page-copy{display:grid;gap:.45rem}.page>.page-copy{margin-inline-start:3.25rem}.page-copy strong,.page-title{font-size:1rem;font-weight:600;letter-spacing:-.015em}.page-copy>span{color:var(--muted);font-size:.8rem;line-height:1.65}.workspace-pages .page{gap:.85rem;padding:1.2rem 1.35rem}.workspace-pages .page-icon{width:2rem;height:2rem;color:var(--muted);background:transparent;border-color:var(--border)}.workspace-pages .page-title{font-size:.9rem}.workspace-pages .page-copy{margin-inline-start:2.75rem}.history-link{display:flex;align-items:center;gap:1rem;width:100%;padding:1.25rem 0;border:0;border-top:1px solid var(--border);text-align:left;color:var(--text);background:transparent}.history-link>.page-icon{color:var(--muted);background:transparent;border-color:var(--border)}.history-link .page-copy strong{font-size:.85rem}.history-cta{display:flex;align-items:center;gap:.6rem;flex-shrink:0;margin-left:auto;color:var(--muted);font-size:.78rem}.history-cta svg{width:1rem;height:1rem}.history-link:hover .history-cta{color:var(--accent)}@container (max-width: 48rem){.pages{grid-template-columns:1fr;gap:.65rem}.page,.workspace-pages .page{gap:.65rem;padding:1.15rem}.page-top .arrow{display:none}.workspace-pages .page-icon{width:2.5rem;height:2.5rem}.workspace-pages .page-copy{margin-inline-start:3.25rem}.page-copy{gap:.2rem}.page-copy strong,.page-title{font-size:.95rem}.section-heading>span{display:none}.history-cta{font-size:0}}
5
5
  `,ur=`.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;margin-bottom:.9rem}.toolbar input{flex:2 1 12rem}.toolbar select{flex:0 1 9rem}.kind-filter,.kind-filter::picker(select){appearance:base-select}.toolbar .kind-filter{display:flex;align-items:center;gap:.5rem;font-size:.76rem}.kind-filter:hover:not(:disabled){border-color:var(--muted)}.kind-filter:focus-visible{outline-offset:-2px}.kind-filter>button{display:flex;align-items:center;gap:.5rem;flex:1;min-width:0}.kind-filter selectedcontent{display:flex;align-items:center;min-width:0}.kind-filter::picker-icon{display:none}.kind-filter>button svg{flex:none;width:.9rem;height:.9rem;margin-inline-start:auto;color:var(--muted)}.kind-filter::picker(select){margin-block:4px;padding:.3rem;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:var(--bg);color:var(--text);box-shadow:0 .6rem 1.6rem #0006}.kind-filter option{display:flex;align-items:center;gap:.5rem;min-height:1.9rem;padding:.3rem .5rem;border-radius:var(--ui-radius, 4px);font-size:.76rem}.kind-filter option::checkmark{color:var(--accent)}.kind-filter option:is(:hover,:focus-visible){outline:none;background:rgb(from var(--text) r g b / .05)}.kind-filter option:checked{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.toolbar repository-selector{flex:1 1 12rem}.toolbar user-selector{flex:1.5 1 16rem}.toolbar>*{min-width:0}.toolbar input[type=search],.toolbar select,.toolbar .btn{min-height:2rem;padding:.28rem .5rem;border-radius:var(--ui-radius, 5px)}.history{overflow-x:auto;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);background:var(--panel)}.row,.history-head{display:grid;grid-template-columns:4.7rem minmax(16rem,1fr) minmax(12rem,1fr) 12rem;align-items:center;gap:.85rem;min-width:52rem;padding:.45rem .85rem}.history-head{background:rgb(from var(--text) r g b / .025);color:var(--muted);font-size:.7rem}.row{border-top:1px solid var(--border);min-height:2.35rem}.row:hover{background:var(--panel-hover)}.kind{display:inline-flex;align-items:center;justify-content:center;width:fit-content;padding:.05rem .35rem;border:1px solid var(--border);border-radius:4px;color:var(--muted);font-size:.65rem;text-transform:capitalize}.kind.triage{color:var(--accent);border-color:rgb(from var(--accent) r g b / .25);background:rgb(from var(--accent) r g b / .06)}.kind.upload{color:var(--green);border-color:rgb(from var(--green) r g b / .25);background:rgb(from var(--green) r g b / .06)}.kind.visibility{color:var(--yellow);border-color:rgb(from var(--yellow) r g b / .25);background:rgb(from var(--yellow) r g b / .06)}.activity{display:flex;align-items:center;gap:.5rem;min-width:0}.activity .avatar{position:relative;display:inline-grid;place-items:center;flex:none;width:1.35rem;height:1.35rem;overflow:hidden;border-radius:50%;font-size:.6rem;font-weight:600}.activity .avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.activity .avatar img[hidden]{display:none}.activity-description,.detail{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.75rem}.activity-description{flex:1;min-width:0}.actor{color:var(--text);font-weight:500}.action,.detail{color:var(--muted)}.history-time{display:flex;align-items:center;gap:.35rem;color:var(--muted);font-size:.7rem;white-space:nowrap;font-variant-numeric:tabular-nums}.history .empty{border:0;margin:0}.pagination{display:flex;align-items:center;flex-wrap:wrap;gap:.65rem;margin-top:1rem;color:var(--muted);font-size:.75rem}.pagination>span:first-child{margin-right:auto}
6
6
  `,dr=`.icon-btn{display:inline-grid;place-items:center;flex:0 0 auto;width:1.8rem;height:1.8rem;padding:0;border:1px solid transparent;border-radius:var(--ui-radius, 5px);color:var(--muted);background:transparent}.icon-btn:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.icon-btn.danger:hover:not(:disabled){color:var(--critical, #e5534b);background:rgb(from var(--critical, #e5534b) r g b / .1)}.icon-btn svg,.btn svg{width:.9rem;height:.9rem}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.avatar img.broken{display:none}.list-head{color:var(--muted);font-size:.7rem;font-weight:500;min-height:2.25rem;border-bottom:1px solid var(--border);background:rgb(from var(--text) r g b / .025)}.users{list-style:none;margin:0;padding:0}.users li+li{border-top:1px solid var(--border)}.who{display:grid;gap:.15rem;min-width:0}.name-text,.login{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.login{color:var(--muted);font-size:.75rem}.last-seen time,.last-activity time{color:var(--text)}.activity-link{display:block;min-width:0;padding:.15rem .2rem;border:0;border-radius:var(--ui-radius, 4px);color:inherit;background:transparent;text-align:left}.activity-link:hover{color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.you{padding:.05rem .35rem;border-radius:4px;color:var(--accent);background:rgb(from var(--accent) r g b / .1);font-size:.75rem;font-weight:500}.permission-granted{color:var(--accent)}.permission-denied{color:var(--muted)}.no-team{color:var(--muted);font-size:.75rem}.access{display:flex;align-items:center;min-width:0}.role{width:100%;height:auto;font-size:.78rem}.self-note{display:flex;align-items:center;gap:.5rem;margin:1rem 0;color:var(--muted);font-size:.75rem}.users li:hover{background:var(--panel-hover)}.avatar{position:relative;display:inline-grid;place-items:center;flex:0 0 auto;width:1.85rem;height:1.85rem;border-radius:50%;overflow:hidden;font-size:.85rem;font-weight:600}.directory{border:1px solid var(--border);border-radius:var(--ui-radius, 11px);overflow:hidden;background:var(--panel);overflow-x:auto}.list-head,.users{min-width:53rem}.list-head,.users li{display:grid;grid-template-columns:minmax(11rem,1fr) minmax(16rem,1.2fr) 6.2rem 6.2rem 6.5rem 2rem;gap:.7rem;padding:.5rem .85rem;align-items:center}.users li{padding-top:.6rem;padding-bottom:.6rem;cursor:default}.person{display:flex;align-items:center;gap:.65rem;min-width:0}.name{display:flex;align-items:center;gap:.4rem;font-size:.8rem;font-weight:500}.last-seen,.last-activity{display:grid;gap:.08rem;color:var(--muted);font-size:.68rem;font-variant-numeric:tabular-nums}.memberships{display:grid;gap:.1rem;min-width:0}.team-access{display:flex;gap:.2rem .5rem;min-width:0;font-size:.7rem;line-height:1.4;align-items:center;flex-wrap:nowrap}.team-access strong{display:inline-flex;align-items:center;gap:.25rem;color:var(--text);font-weight:500;min-width:0;max-width:8rem}.team-access strong.team-access-role{flex-shrink:0;max-width:none;white-space:nowrap}.team-access strong svg{width:.8rem;height:.8rem;flex-shrink:0;color:var(--muted)}.team-access strong span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.team-perms{display:inline-flex;flex-wrap:nowrap;gap:.45rem;font-size:inherit;flex-shrink:0}.view-as{display:flex;justify-content:flex-end}