@preventive/triage 1.0.0-alpha.45 → 1.0.0-alpha.46

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 (79) hide show
  1. package/client/linked-findings.js +3 -0
  2. package/common/bundle-metadata.d.ts +1 -0
  3. package/common/bundle-metadata.js +1 -1
  4. package/common/bundle-sources.js +5 -1
  5. package/common/line-diff.js +5 -4
  6. package/out/{chunk-NPW52BM2.js → chunk-4HI2MSAV.js} +13 -13
  7. package/out/{chunk-AFLZH7WG.js → chunk-4UFAMJAX.js} +1 -1
  8. package/out/{chunk-HMAJDVXN.js → chunk-7XRR4OFU.js} +1 -1
  9. package/out/{chunk-Q6MVYGYV.js → chunk-BOIXMUU5.js} +1 -1
  10. package/out/{chunk-XVBEOGOS.js → chunk-CC4OM6TZ.js} +2 -2
  11. package/out/chunk-G24A42V6.js +2 -0
  12. package/out/{chunk-WI7Z5A2T.js → chunk-JKGQ3O7O.js} +1 -1
  13. package/out/chunk-LE5ZWLG4.js +235 -0
  14. package/out/chunk-MSION3G4.js +36 -0
  15. package/out/{chunk-6HNXNIQY.js → chunk-S6GIXWQW.js} +1 -1
  16. package/out/chunk-V3KWNNMY.js +1 -0
  17. package/out/client-managed-import.js +1 -1
  18. package/out/client-managed.js +25 -25
  19. package/out/compare.js +13 -13
  20. package/out/dialogs.js +40 -40
  21. package/out/graph.js +1 -1
  22. package/out/index.html +6 -6
  23. package/out/scan.js +2 -2
  24. package/out/terminal.js +1 -1
  25. package/out/view.css +1 -1
  26. package/out/view.js +15 -15
  27. package/package.json +3 -1
  28. package/risk/actions/findings.js +14 -9
  29. package/risk/actions/scripts/shell.js +5 -1
  30. package/risk/index.d.ts +5 -2
  31. package/server-e2e/app.ts +5 -4
  32. package/server-e2e/http.ts +5 -2
  33. package/server-managed/bundle-cache.ts +7 -1
  34. package/server-managed/combined.ts +3 -2
  35. package/server-managed/commit-lockfiles.ts +21 -11
  36. package/server-managed/config.ts +6 -0
  37. package/server-managed/db-methods.ts +37 -9
  38. package/server-managed/db-neon.ts +61 -21
  39. package/server-managed/db-schema.ts +4 -0
  40. package/server-managed/db.ts +2 -1
  41. package/server-managed/dependency-reviews.ts +13 -3
  42. package/server-managed/github-app.ts +12 -6
  43. package/server-managed/github-issue-links.ts +11 -5
  44. package/server-managed/github-pulls.ts +2 -2
  45. package/server-managed/github-requests.ts +39 -0
  46. package/server-managed/http-response.ts +10 -2
  47. package/server-managed/http.ts +195 -111
  48. package/server-managed/index.ts +8 -7
  49. package/server-managed/kept-briefly.ts +37 -0
  50. package/server-managed/npm-delta.ts +11 -6
  51. package/server-managed/npm-kept.ts +32 -2
  52. package/server-managed/npm-loads.ts +100 -30
  53. package/server-managed/npm-packages.ts +89 -3
  54. package/server-managed/npm-risk.ts +4 -1
  55. package/server-managed/pretty-print.ts +67 -23
  56. package/server-managed/pull-dependencies.ts +29 -9
  57. package/server-managed/pull-dependency-reviews.ts +8 -8
  58. package/server-managed/queue.ts +16 -0
  59. package/server-managed/rename-diff.ts +22 -13
  60. package/server-managed/report-sources.ts +1 -1
  61. package/server-managed/report-store.ts +42 -9
  62. package/server-managed/repository-actions.ts +15 -6
  63. package/server-managed/repository-browser.ts +119 -31
  64. package/server-managed/repository-dependency-reviews.ts +41 -19
  65. package/server-managed/repository-history.ts +24 -8
  66. package/server-managed/repository-pulse.ts +8 -1
  67. package/server-managed/repository-risk-audit.ts +13 -0
  68. package/server-managed/repository-risk-read.ts +11 -6
  69. package/server-managed/repository-risk.ts +27 -20
  70. package/server-managed/session.ts +18 -4
  71. package/server-managed/sql.ts +5 -2
  72. package/server-managed/storage.ts +4 -2
  73. package/server-managed/team-reports.ts +24 -12
  74. package/server-managed/upstream-cache.ts +12 -0
  75. package/server.ts +14 -5
  76. package/out/chunk-5DHL5NG3.js +0 -2
  77. package/out/chunk-NV7ES4EW.js +0 -1
  78. package/out/chunk-PTGDYLNS.js +0 -36
  79. package/out/chunk-QRD6GIG5.js +0 -229
@@ -63,6 +63,9 @@ function entryId(entry) {
63
63
  // A file whose every link normalises away is still a links file; it
64
64
  // just has no links, which its view says plainly.
65
65
  export function parseLinkedFindings(content) {
66
+ // Only text opening an array can parse to one, so a report — which
67
+ // opens an object — is turned away without being parsed twice.
68
+ if (typeof content === 'string' && !/^\s*\[/u.test(content)) return null
66
69
  let data
67
70
  try { data = JSON.parse(content) } catch { return null }
68
71
  if (!Array.isArray(data) || data.length === 0) return null
@@ -5,6 +5,7 @@ export const FILE_HASH: RegExp
5
5
  export interface BundleIdentity { integrity: string; kind: string | null; size: number }
6
6
  export interface BundleDetails extends BundleIdentity { bundle?: unknown; json?: unknown; map?: SourceMap; edges?: readonly SourcemapEdge[] }
7
7
  export function parseBundleContents(text: string, identity: BundleIdentity): BundleDetails
8
+ export function computeBundleFileHashes(details: BundleDetails): Promise<Map<string, string>>
8
9
  export interface BundleMetadata extends Record<string, unknown> {
9
10
  files: [string, number | null, string | null, number | null][]
10
11
  codeStats: { files: number; lines: number; bytes: number }
@@ -174,7 +174,7 @@ export function parseBundleMetadata(data, integrity) {
174
174
  || [...unsized].some((path) => typeof path !== 'string' || !fileSizes.has(path) || fileSizes.get(path) !== null)) throw new Error('Invalid bundle metadata')
175
175
  const details = { integrity, kind: data.kind, size: data.size, metadataOnly: true, fileSizes, fileHashes, lineCounts, unsizedFiles: unsized, stale }
176
176
  if (data.kind === 'stasis') {
177
- details.bundle = Bundle.parse(JSON.stringify(data.bundle))
177
+ details.bundle = Bundle.fromJSON(data.bundle)
178
178
  const paths = details.bundle.sources
179
179
  if (paths.size !== fileSizes.size || [...paths.keys()].some((path) => !fileSizes.has(path))) throw new Error('Invalid bundle metadata inventory')
180
180
  // A file is hashed exactly when it is source: a resource has bytes and
@@ -282,15 +282,19 @@ export function bundleSourceSizes(details) {
282
282
  //
283
283
  // Returns null for sourcemap bundles (and anything without parsed
284
284
  // modules) — they carry no package metadata, so callers fall back to
285
- // the path heuristic alone.
285
+ // the path heuristic alone. Kept by the bundle, as its sources are:
286
+ // callers only read it.
287
+ const packageDirsCache = new WeakMap()
286
288
  export function bundlePackageDirs(details) {
287
289
  if (details?.kind !== 'stasis' || !details.bundle?.modules) return null
290
+ if (packageDirsCache.has(details.bundle)) return packageDirsCache.get(details.bundle)
288
291
  const map = new Map()
289
292
  for (const [dir, info] of details.bundle.modules) {
290
293
  for (const rel of Object.keys(info.files)) {
291
294
  map.set(dir === '.' ? rel : `${dir}/${rel}`, dir)
292
295
  }
293
296
  }
297
+ packageDirsCache.set(details.bundle, map)
294
298
  return map
295
299
  }
296
300
 
@@ -5,7 +5,7 @@
5
5
  //
6
6
  // Lines are numbered the way the diff numbers them: from zero, a final
7
7
  // newline ending the last line rather than starting an empty one.
8
- import { diff, parseDiff } from '@preventive/diff'
8
+ import { changeSet } from '@preventive/diff'
9
9
 
10
10
  export function textLines(text) {
11
11
  if (text === '') return []
@@ -25,10 +25,11 @@ const spacing = line => line.replace(/[ \t\n\v\f\r]+$/u, '').replaceAll(/[ \t\n\
25
25
 
26
26
  // Each `a[a0..a1)` replaced by `b[b0..b1)`. `ignoreWhitespace` is diff -b:
27
27
  // lines differing only in how much whitespace they have pair up as unchanged,
28
- // whitespace added or removed between other characters still a change.
28
+ // whitespace added or removed between other characters still a change. Those
29
+ // a unified diff with no context shows (horizon 0), found without printing
30
+ // one and reading it back.
29
31
  export function changeBlocks(before, after, ignoreWhitespace = false) {
30
- const text = diff(before, after, { format: 'unified', context: 0, whitespace: ignoreWhitespace ? 'change' : 'none' })
31
- return text ? (parseDiff(text)[0]?.blocks ?? []).map(({ a0, a1, b0, b1 }) => ({ a0, a1, b0, b1 })) : []
32
+ return changeSet(before, after, { horizon: 0, whitespace: ignoreWhitespace ? 'change' : 'none' }).map(({ a0, a1, b0, b1 }) => ({ a0, a1, b0, b1 }))
32
33
  }
33
34
 
34
35
  // Whether `blocks` take `before`'s lines to `after`'s: each in order and apart
@@ -1,17 +1,17 @@
1
1
  import{f as e,g as t,j as n,k as r,l as i,m as a}from"./chunk-PXK7EU4V.js";var o=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: ?(.*?))?\n?$/u,s=/^\*{15,}(?: (.*?))?\n?$/u,c=/^\*{3} (\d+)(?:,(\d+))? \*{4}\n?$/u,l=/^--- (\d+)(?:,(\d+))? ----\n?$/u,u=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n?$/u,d=t,f=t?new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}):null,{isWellFormed:p}=String.prototype;function m(e,t,n){if(t||e.length===n.length)return n;if(p){if(p.call(e))return n;throw TypeError(i)}let r=0,a=n.length-3;for(;r<=a;){let t=n.indexOf(239,r);if(t===-1||t>a)break;if(r=t+1,n[t+1]===191&&n[t+2]===189){if(e===g(n))return n;throw TypeError(i)}}return n}function h(t,n=!1){if(typeof t!=`string`)throw TypeError(r);return t.length===0?new Uint8Array:m(t,n,e.encode(t))}function g(e,t=!1){return n(e),e.byteLength===0?``:t?d.decode(e):f.decode(e)}var _=(e,t=`uint8`)=>a(h(e,!1),t),v=(e,t=`uint8`)=>a(h(e,!0),t),y=e=>g(e,!1),b=e=>g(e,!0),x=/[ \t\n\v\f\r]/gu,ee=/[ \t\n\v\f\r]+/gu,S=/[ \t\n\v\f\r]+$/u,C=e=>e.replace(/[A-Z]/gu,e=>e.toLowerCase());function w({ignoreCase:e=!1,whitespace:t=`none`}={}){let n=null;return t===`all`?n=e=>e.replace(x,``):t===`change`?n=e=>e.replace(S,``).replace(ee,` `):t===`trailing`&&(n=e=>e.replace(S,``)),e?n?e=>C(n(e)):C:n}function T(e){let t=[];for(let n=0;n<e.length;){let r=e.indexOf(`
2
- `,n),i=r<0?e.length:r+1;t.push(e.slice(n,i)),n=i}return t}var E=class extends Error{constructor(e,t){super(t===void 0?e:`${e} at line ${t+1}`),this.name=`PatchError`,this.line=t}},D=(e,t)=>t===0?Number(e):Number(e)-1,O=e=>e!==void 0&&e.startsWith(`\\`),k=e=>e.replace(/\n$/u,``);function A(e){let t=T(e),n=[],r={old:null,new:null},i=!1;for(let e=0;e<t.length;){let a=t[e],c=j(a,i);if(i=!a.startsWith(`***************`)&&a.startsWith(`*** `),c){r=c.names??{...r,[c.slot]:c.name},e++;continue}let l=o.test(a)?`unified`:s.test(a)?`context`:u.test(a)?`normal`:null;if(l===null){e++;continue}let d=[],f=ie[l];for(let n=f(t,e);n!==null&&(d.push(n.hunk),e=n.next,!(e>=t.length||j(t[e],!1)));n=f(t,e));n.push({old:r.old,new:r.new,format:l,hunks:d,blocks:te(d)}),r={old:null,new:null}}return n}function j(e,t){let n=/^diff --git (\S+) (\S+)\n?$/u.exec(e);if(n)return{names:{old:n[1],new:n[2]}};if(c.test(e)||l.test(e))return null;let r=/^(\*\*\* |--- |\+\+\+ )(.*?)(?:\t.*)?\n?$/u.exec(e);return r?r[1]===`--- `?{slot:t?`new`:`old`,name:r[2]}:{slot:r[1]===`*** `?`old`:`new`,name:r[2]}:null}function te(e){let t=[];for(let n of e){let e=n.oldStart,r=n.newStart,i=null,a=()=>{i&&=(t.push(i),e=i.a1,r=i.b1,null)};for(let{tag:t,text:o}of n.lines){if(t===` `){a(),e++,r++;continue}t===`-`&&i?.insert.length&&a(),i??={a0:e,a1:e,b0:r,b1:r,remove:[],insert:[]},t===`-`?(i.a1++,i.remove.push(o)):(i.b1++,i.insert.push(o))}a()}return t}function ne(e,t){let n=o.exec(e[t]??``);if(!n)return null;let r=n[2]===void 0?1:Number(n[2]),i=n[4]===void 0?1:Number(n[4]),a={oldStart:D(n[1],r),newStart:D(n[3],i),label:n[5]||null,lines:[]},s=0,c=t+1,l=0;for(;l<r||s<i;c++){let t=e[c];if(t===void 0)throw new E(`the patch ends inside a hunk`,c);let n=t===`
2
+ `,n),i=r<0?e.length:r+1;t.push(e.slice(n,i)),n=i}return t}var E=class extends Error{constructor(e,t){super(t===void 0?e:`${e} at line ${t+1}`),this.name=`PatchError`,this.line=t}},D=(e,t)=>t===0?Number(e):Number(e)-1,O=e=>e!==void 0&&e.startsWith(`\\`),k=e=>e.replace(/\n$/u,``);function te(e){let t=T(e),n=[],r={old:null,new:null},i=!1;for(let e=0;e<t.length;){let a=t[e],c=A(a,i);if(i=!a.startsWith(`***************`)&&a.startsWith(`*** `),c){r=c.names??{...r,[c.slot]:c.name},e++;continue}let l=o.test(a)?`unified`:s.test(a)?`context`:u.test(a)?`normal`:null;if(l===null){e++;continue}let d=[],f=ae[l];for(let n=f(t,e);n!==null&&(d.push(n.hunk),e=n.next,!(e>=t.length||A(t[e],!1)));n=f(t,e));n.push({old:r.old,new:r.new,format:l,hunks:d,blocks:ne(d)}),r={old:null,new:null}}return n}function A(e,t){let n=/^diff --git (\S+) (\S+)\n?$/u.exec(e);if(n)return{names:{old:n[1],new:n[2]}};if(c.test(e)||l.test(e))return null;let r=/^(\*\*\* |--- |\+\+\+ )(.*?)(?:\t.*)?\n?$/u.exec(e);return r?r[1]===`--- `?{slot:t?`new`:`old`,name:r[2]}:{slot:r[1]===`*** `?`old`:`new`,name:r[2]}:null}function ne(e){let t=[];for(let n of e){let e=n.oldStart,r=n.newStart,i=null,a=()=>{i&&=(t.push(i),e=i.a1,r=i.b1,null)};for(let{tag:t,text:o}of n.lines){if(t===` `){a(),e++,r++;continue}t===`-`&&i?.insert.length&&a(),i??={a0:e,a1:e,b0:r,b1:r,remove:[],insert:[]},t===`-`?(i.a1++,i.remove.push(o)):(i.b1++,i.insert.push(o))}a()}return t}function re(e,t){let n=o.exec(e[t]??``);if(!n)return null;let r=n[2]===void 0?1:Number(n[2]),i=n[4]===void 0?1:Number(n[4]),a={oldStart:D(n[1],r),newStart:D(n[3],i),label:n[5]||null,lines:[]},s=0,c=t+1,l=0;for(;l<r||s<i;c++){let t=e[c];if(t===void 0)throw new E(`the patch ends inside a hunk`,c);let n=t===`
3
3
  `?` `:t[0];if(n!==` `&&n!==`-`&&n!==`+`)throw new E(`a hunk line begins with ${JSON.stringify(n)}`,c);let o=t===`
4
- `?t:t.slice(1);if(O(e[c+1])&&(o=k(o),c++),n!==`+`&&l++,n!==`-`&&s++,l>r||s>i)throw new E(`a hunk has more lines than its header says`,c);a.lines.push({tag:n,text:o})}return{hunk:a,next:c}}function M(e,t){let n=u.exec(e[t]??``);if(!n)return null;let[,r,i,a,o,s]=n,c=a===`a`?0:Number(i??r)-Number(r)+1,l=a===`d`?0:Number(s??o)-Number(o)+1;if(c<0||l<0)throw new E(`a change command counts backwards`,t);let d={oldStart:a===`a`?Number(r):Number(r)-1,newStart:a===`d`?Number(o):Number(o)-1,label:null,lines:[]},f=t+1,p=(t,n,r)=>{for(let i=0;i<t;i++,f++){let t=e[f];if(t===void 0)throw new E(`the patch ends inside a hunk`,f);if(t[0]!==n)throw new E(`${JSON.stringify(n)} expected`,f);let i=t.slice(2);O(e[f+1])&&(i=k(i),f++),d.lines.push({tag:r,text:i})}};if(p(c,`<`,`-`),a===`c`){if(e[f]!==`---
5
- `)throw new E(`'---' expected`,f);f++}return p(l,`>`,`+`),{hunk:d,next:f}}function re(e,t){let n=s.exec(e[t]??``);if(!n)return null;let r=c.exec(e[t+1]??``);if(!r)throw new E(`'*** ' range expected`,t+1);let i=t+2,a=N(e,i,l,`-`);i=a.next;let o=l.exec(e[i]??``);if(!o)throw new E(`'--- ' range expected`,i);let u=N(e,i+1,null,`+`),d=a.lines.length===0?u.lines.filter(e=>e.tag===` `):a.lines,f=u.lines.length===0?a.lines.filter(e=>e.tag===` `):u.lines;return{hunk:{oldStart:D(r[1],d.length),newStart:D(o[1],f.length),label:n[1]||null,lines:P(d,f)},next:u.next}}function N(e,t,n,r){let i=[],a=t;for(;a<e.length;a++){let t=e[a];if(n&&n.test(t)||s.test(t)||c.test(t)||!n&&l.test(t))break;if(O(t)){i[i.length-1].text=k(i.at(-1).text);continue}let o=t===`
4
+ `?t:t.slice(1);if(O(e[c+1])&&(o=k(o),c++),n!==`+`&&l++,n!==`-`&&s++,l>r||s>i)throw new E(`a hunk has more lines than its header says`,c);a.lines.push({tag:n,text:o})}return{hunk:a,next:c}}function j(e,t){let n=u.exec(e[t]??``);if(!n)return null;let[,r,i,a,o,s]=n,c=a===`a`?0:Number(i??r)-Number(r)+1,l=a===`d`?0:Number(s??o)-Number(o)+1;if(c<0||l<0)throw new E(`a change command counts backwards`,t);let d={oldStart:a===`a`?Number(r):Number(r)-1,newStart:a===`d`?Number(o):Number(o)-1,label:null,lines:[]},f=t+1,p=(t,n,r)=>{for(let i=0;i<t;i++,f++){let t=e[f];if(t===void 0)throw new E(`the patch ends inside a hunk`,f);if(t[0]!==n)throw new E(`${JSON.stringify(n)} expected`,f);let i=t.slice(2);O(e[f+1])&&(i=k(i),f++),d.lines.push({tag:r,text:i})}};if(p(c,`<`,`-`),a===`c`){if(e[f]!==`---
5
+ `)throw new E(`'---' expected`,f);f++}return p(l,`>`,`+`),{hunk:d,next:f}}function ie(e,t){let n=s.exec(e[t]??``);if(!n)return null;let r=c.exec(e[t+1]??``);if(!r)throw new E(`'*** ' range expected`,t+1);let i=t+2,a=M(e,i,l,`-`);i=a.next;let o=l.exec(e[i]??``);if(!o)throw new E(`'--- ' range expected`,i);let u=M(e,i+1,null,`+`),d=a.lines.length===0?u.lines.filter(e=>e.tag===` `):a.lines,f=u.lines.length===0?a.lines.filter(e=>e.tag===` `):u.lines;return{hunk:{oldStart:D(r[1],d.length),newStart:D(o[1],f.length),label:n[1]||null,lines:N(d,f)},next:u.next}}function M(e,t,n,r){let i=[],a=t;for(;a<e.length;a++){let t=e[a];if(n&&n.test(t)||s.test(t)||c.test(t)||!n&&l.test(t))break;if(O(t)){i[i.length-1].text=k(i.at(-1).text);continue}let o=t===`
6
6
  `?` `:t[0];if(o!==` `&&o!==`!`&&o!==`-`&&o!==`+`)break;i.push({tag:o===` `?` `:r,text:t===`
7
- `?t:t.slice(2)})}return{lines:i,next:a}}function P(e,t){let n=[],r=0,i=0;for(;r<e.length||i<t.length;){if(e[r]?.tag===` `&&t[i]?.tag===` `){n.push(e[r]),r++,i++;continue}for(;r<e.length&&e[r].tag!==` `;)n.push(e[r]),r++;for(;i<t.length&&t[i].tag!==` `;)n.push(t[i]),i++;e[r]?.tag===` `&&t[i]===void 0?(n.push(e[r]),r++):t[i]?.tag===` `&&e[r]===void 0&&(n.push(t[i]),i++)}return n}var ie={unified:ne,context:re,normal:M},F=class extends Error{constructor(e){super(`the rendered diff does not say what the change set says (${e})`),this.name=`FormatError`}};function I(e,t,n,r){if(n.length===0){if(r!==``)throw new F(`there was nothing to print, and something was printed`);return}let i;try{i=A(r)}catch(e){throw new F(`it does not read back (${e.message})`)}if(i.length!==1)throw new F(`${i.length} files read back, not one`);let a=i[0].blocks;if(a.length!==n.length)throw new F(`${a.length} blocks read back, not ${n.length}`);for(let[e,t]of a.entries()){let r=n[e];if(t.a0!==r.a0||t.a1!==r.a1||t.b0!==r.b0||t.b1!==r.b1)throw new F(`block ${e+1} reads back somewhere else`)}for(let n of i[0].hunks){let r=i[0].format===`context`&&!n.lines.some(({tag:e})=>e===`-`),a=n.oldStart,o=n.newStart;for(let{tag:i,text:s}of n.lines){if(s!==(i===`+`||i===` `&&r?t[o]:e[a]))throw new F(`a ${i===`+`?`added`:i===`-`?`removed`:`kept`} line is not the line it stands for`);i!==`+`&&a++,i!==`-`&&o++}}}function ae(e,t,n,r){let i=[],a=0;for(;a<e.length;){let o=a;for(;o+1<e.length&&e[o+1].a0-e[o].a1<=2*t;)o++;let s=e[a],c=e[o];i.push({blocks:e.slice(a,o+1),a0:Math.max(0,s.a0-t),a1:Math.min(n,c.a1+t),b0:Math.max(0,s.b0-t),b1:Math.min(r,c.b1+t)}),a=o+1}return i}var L=e=>(t,n,r,{context:i,label:a=null})=>{let o=``;for(let s of ae(r,i,t.length,n.length))o+=e(t,n,s,a?a(s.a0):null);return I(t,n,r,o),o},oe=`
7
+ `?t:t.slice(2)})}return{lines:i,next:a}}function N(e,t){let n=[],r=0,i=0;for(;r<e.length||i<t.length;){if(e[r]?.tag===` `&&t[i]?.tag===` `){n.push(e[r]),r++,i++;continue}for(;r<e.length&&e[r].tag!==` `;)n.push(e[r]),r++;for(;i<t.length&&t[i].tag!==` `;)n.push(t[i]),i++;e[r]?.tag===` `&&t[i]===void 0?(n.push(e[r]),r++):t[i]?.tag===` `&&e[r]===void 0&&(n.push(t[i]),i++)}return n}var ae={unified:re,context:ie,normal:j},P=class extends Error{constructor(e){super(`the rendered diff does not say what the change set says (${e})`),this.name=`FormatError`}};function F(e,t,n,r){if(n.length===0){if(r!==``)throw new P(`there was nothing to print, and something was printed`);return}let i;try{i=te(r)}catch(e){throw new P(`it does not read back (${e.message})`)}if(i.length!==1)throw new P(`${i.length} files read back, not one`);let a=i[0].blocks;if(a.length!==n.length)throw new P(`${a.length} blocks read back, not ${n.length}`);for(let[e,t]of a.entries()){let r=n[e];if(t.a0!==r.a0||t.a1!==r.a1||t.b0!==r.b0||t.b1!==r.b1)throw new P(`block ${e+1} reads back somewhere else`)}for(let n of i[0].hunks){let r=i[0].format===`context`&&!n.lines.some(({tag:e})=>e===`-`),a=n.oldStart,o=n.newStart;for(let{tag:i,text:s}of n.lines){if(s!==(i===`+`||i===` `&&r?t[o]:e[a]))throw new P(`a ${i===`+`?`added`:i===`-`?`removed`:`kept`} line is not the line it stands for`);i!==`+`&&a++,i!==`-`&&o++}}}function oe(e,t,n,r){let i=[],a=0;for(;a<e.length;){let o=a;for(;o+1<e.length&&e[o+1].a0-e[o].a1<=2*t;)o++;let s=e[a],c=e[o];i.push({blocks:e.slice(a,o+1),a0:Math.max(0,s.a0-t),a1:Math.min(n,c.a1+t),b0:Math.max(0,s.b0-t),b1:Math.min(r,c.b1+t)}),a=o+1}return i}var I=e=>(t,n,r,{context:i,label:a=null})=>{let o=``;for(let s of oe(r,i,t.length,n.length))o+=e(t,n,s,a?a(s.a0):null);return F(t,n,r,o),o},se=`
8
8
  \
9
- `,R=(e,t)=>e+t+(t.endsWith(`
10
- `)?``:oe);function z(e,t){return t>e+1?`${e+1},${t}`:`${t>e?e+1:e}`}function se(e,t,n){let r=``;for(let{a0:i,a1:a,b0:o,b1:s}of n){let n=i===a?`a`:o===s?`d`:`c`;r+=z(i,a)+n+z(o,s)+`
11
- `;for(let t=i;t<a;t++)r+=R(`< `,e[t]);n===`c`&&(r+=`---
12
- `);for(let e=o;e<s;e++)r+=R(`> `,t[e])}return I(e,t,n,r),r}function B(e,t){return t<=e?`${e},0`:t===e+1?`${e+1}`:`${e+1},${t-e}`}var ce=L((e,t,n,r)=>{let i=`@@ -${B(n.a0,n.a1)} +${B(n.b0,n.b1)} @@${r===null?``:` `+r}
13
- `,a=n.a0,o=n.b0;for(let{a0:r,a1:s,b1:c}of n.blocks){for(;a<r;a++,o++)i+=R(` `,e[a]);for(;a<s;a++)i+=R(`-`,e[a]);for(;o<c;o++)i+=R(`+`,t[o])}for(;a<n.a1;a++,o++)i+=R(` `,e[a]);return i});function V(e,t){return t<=e?`${e}`:t===e+1?`${e+1}`:`${e+1},${t}`}var le=L((e,t,n,r)=>{let i=`***************${r===null?``:` `+r}
14
- `;return i+=`*** ${V(n.a0,n.a1)} ****
15
- `,n.blocks.some(e=>e.a0<e.a1)&&(i+=H(e,n.a0,n.a1,n.blocks,`a`)),i+=`--- ${V(n.b0,n.b1)} ----
16
- `,n.blocks.some(e=>e.b0<e.b1)&&(i+=H(t,n.b0,n.b1,n.blocks,`b`)),i});function H(e,t,n,r,i){let a=i+`1`,o=i+`0`,s=i===`a`?`b`:`a`,c=``,l=t;for(let t of r){for(;l<t[o];l++)c+=R(` `,e[l]);let n=t[s+`0`]<t[s+`1`]?`! `:i===`a`?`- `:`+ `;for(;l<t[a];l++)c+=R(n,e[l])}for(;l<n;l++)c+=R(` `,e[l]);return c}function U(e){let t=[];for(let n=0;;){let r=n;for(;n<e.length&&e[n];)n++;if(t.push(n>r),n===e.length)return t;n++}}function W(e,t,n){let r=t.length,i=U(n),a=0,o=0,s=0,c=()=>{if(a===r||e[s]!==e[a])return!1;for(t[s++]=0,t[a++]=1,o++;a<r&&t[a];)a++;return!0},l=()=>{if(s===0||e[s-1]!==e[a-1])return!1;for(t[--s]=1,t[--a]=0,o--;s>0&&t[s-1];)s--;return!0};for(let e=0;e<r;e++){if(!t[e]){o++;continue}for(s=e,a=e;a<r&&t[a];a++);let n=-1;for(let e=-1;e!==a-s;){for(e=a-s;l(););for(n=i[o]?a:-1;c();)i[o]&&(n=a)}if(n!==-1)for(let e=a-n;e>0;e--)l();e=a-1}}function ue(e){let t=1;for(let n=e;n!==0;n>>=2)t<<=1;return Math.max(256,t)}function G(e,t,{ignoreCase:n=!1,whitespace:r=`none`,minimal:i=!1,discard:a=!0,slide:o=!0,horizon:s=1/0}={}){let c=w({ignoreCase:n,whitespace:r});if(c===null&&J(e,t,null))return[];let{A:l,B:u,classes:d}=pe(e,t,c),f=new Uint8Array(l.length),p=new Uint8Array(u.length),m=de(e,t,s),[h,g]=i||!a?[null,null]:fe(l,u,d,m),_=q(m.lo,m.hiA,h,f),v=q(m.lo,m.hiB,g,p),y=new Uint8Array(_.length),b=new Uint8Array(v.length);me(_.map(e=>l[e]),v.map(e=>u[e]),y,b,i);for(let e=0;e<_.length;e++)y[e]&&(f[_[e]]=1);for(let e=0;e<v.length;e++)b[e]&&(p[v[e]]=1);if(o){let{lo:e,hiA:t,hiB:n}=m;W(l.subarray(e,t),f.subarray(e,t),p.subarray(e,n)),W(u.subarray(e,n),p.subarray(e,n),f.subarray(e,t))}let x=_e(f,p);return Y(e,t,x,c),x}function de(e,t,n){let r=Math.min(e.length,t.length),i=0;for(;i<r&&e[i]===t[i];)i++;let a=Math.max(0,i-n),o=0;for(;o<r-a&&e[e.length-1-o]===t[t.length-1-o];)o++;let s=Math.max(0,o-n);return{lo:a,hiA:e.length-s,hiB:t.length-s}}function fe(e,t,n,{lo:r,hiA:i,hiB:a}){let o=new Int32Array(n),s=new Int32Array(n);for(let t=r;t<i;t++)o[e[t]]++;for(let e=r;e<a;e++)s[t[e]]++;return[K(e.subarray(r,i),s),K(t.subarray(r,a),o)]}function K(e,t){let n=e.length,r=new Uint8Array(n),i=5;for(let e=Math.floor(n/64)>>2;e>0;e>>=2)i*=2;for(let a=0;a<n;a++){let n=t[e[a]];n===0?r[a]=1:n>i&&(r[a]=2)}for(let e=0;e<n;e++){if(r[e]===2){r[e]=0;continue}if(r[e]===0)continue;let t=e,i=0;for(;t<n&&r[t]!==0;t++)r[t]===2&&i++;for(;t>e&&r[t-1]===2;)r[--t]=0,i--;let a=t-e;if(i*4>a){for(;t>e;)r[--t]===2&&(r[t]=0);continue}let o=1;for(let e=a>>4;e>0;e>>=2)o<<=1;o++;for(let t=0,n=0;n<a;n++)r[e+n]===2?o===++t?n-=t:o<t&&(r[e+n]=0):t=0;for(let t=0,n=0;n<a&&!(n>=8&&r[e+n]===1||(r[e+n]===2?(t=0,r[e+n]=0):r[e+n]===0?t=0:t++,t===3));n++);e+=a-1;for(let t=0,n=0;n<a&&!(n>=8&&r[e-n]===1||(r[e-n]===2?(t=0,r[e-n]=0):r[e-n]===0?t=0:t++,t===3));n++);}return r}function q(e,t,n,r){let i=[];for(let a=e;a<t;a++)n!==null&&n[a-e]!==0?r[a]=1:i.push(a);return Int32Array.from(i)}function J(e,t,n=null){if(e.length!==t.length)return!1;let r=n?(e,t)=>n(e)===n(t):(e,t)=>e===t;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function pe(e,t,n){let r=new Map,i=e=>{let t=n?n(e):e,i=r.get(t);return i===void 0&&(i=r.size,r.set(t,i)),i};return{A:Int32Array.from(e,i),B:Int32Array.from(t,i),classes:r.size}}function me(e,t,n,r,i){let a=e.length+t.length+3,o={A:e,B:t,fd:new Int32Array(a),bd:new Int32Array(a),base:t.length+1,limit:ue(e.length+t.length)},s=[{xoff:0,xlim:e.length,yoff:0,ylim:t.length,minimal:i}],c={xmid:0,ymid:0,loMinimal:!1,hiMinimal:!1};for(;s.length;){let{xoff:i,xlim:a,yoff:l,ylim:u,minimal:d}=s.pop();for(;i<a&&l<u&&e[i]===t[l];)i++,l++;for(;i<a&&l<u&&e[a-1]===t[u-1];)a--,u--;if(i===a){for(;l<u;l++)r[l]=1;continue}if(l===u){for(;i<a;i++)n[i]=1;continue}he(o,i,a,l,u,d,c),s.push({xoff:c.xmid,xlim:a,yoff:c.ymid,ylim:u,minimal:c.hiMinimal}),s.push({xoff:i,xlim:c.xmid,yoff:l,ylim:c.ymid,minimal:c.loMinimal})}}function he(e,t,n,r,i,a,o){let{A:s,B:c,fd:l,bd:u,base:d,limit:f}=e,p=n-r,m=t-i,h=n-i,g=t-r,_=h,v=h,y=g,b=g,x=!!(g-h&1);l[d+g]=t,u[d+h]=n;for(let h=1;;h++){b>m?l[d+--b-1]=-1:++b,y<p?l[d+ ++y+1]=-1:--y;for(let e=y;e>=b;e-=2){let t=l[d+e+1],r=l[d+e-1],a=r<t?t:r+1,f=a-e;for(;a<n&&f<i&&s[a]===c[f];)a++,f++;if(l[d+e]=a,x&&v<=e&&e<=_&&u[d+e]<=a){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}v>m?u[d+--v-1]=2147483647:++v,_<p?u[d+ ++_+1]=2147483647:--_;for(let e=_;e>=v;e-=2){let n=u[d+e+1],i=u[d+e-1],a=i<n?i:n-1,f=a-e;for(;t<a&&r<f&&s[a-1]===c[f-1];)a--,f--;if(u[d+e]=a,!x&&b<=e&&e<=y&&a<=l[d+e]){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}if(!(a||h<f)){ge(e,{xoff:t,xlim:n,yoff:r,ylim:i,fmin:b,fmax:y,bmin:v,bmax:_},o);return}}}function ge(e,t,n){let{fd:r,bd:i,base:a}=e,{xoff:o,xlim:s,yoff:c,ylim:l,fmin:u,fmax:d,bmin:f,bmax:p}=t,m=0,h=-1;for(let e=d;e>=u;e-=2){let t=Math.min(r[a+e],s),n=t-e;l<n&&(t=l+e,n=l),h<t+n&&(h=t+n,m=t)}let g=0,_=2147483647;for(let e=p;e>=f;e-=2){let t=Math.max(o,i[a+e]),n=t-e;n<c&&(t=c+e,n=c),t+n<_&&(_=t+n,g=t)}s+l-_<h-(o+c)?(n.xmid=m,n.ymid=h-m,n.loMinimal=!0,n.hiMinimal=!1):(n.xmid=g,n.ymid=_-g,n.loMinimal=!1,n.hiMinimal=!0)}function _e(e,t){let n=[],r=t.length,i=e.length,a=0,o=0;for(;a<i||o<r;){if(a<i&&o<r&&!e[a]&&!t[o]){a++,o++;continue}let s=a,c=o;for(;a<i&&e[a];)a++;for(;o<r&&t[o];)o++;if(s===a&&c===o)throw new X(`a kept line has no counterpart`);n.push({a0:s,a1:a,b0:c,b1:o})}return n}function Y(e,t,n,r=null){let i=r?(e,t)=>r(e)===r(t):(e,t)=>e===t,a=0,o=0;for(let{a0:r,a1:s,b0:c,b1:l}of n){if(r<a||c<o||s<r||l<c||s>e.length||l>t.length)throw new X(`a block is out of order or out of range`);if(r===s&&c===l)throw new X(`a block changes nothing`);if(r-a!==c-o)throw new X(`the kept lines before a block differ in count`);for(;a<r;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`);a=s,o=l}if(e.length-a!==t.length-o)throw new X(`the kept lines after the last block differ in count`);for(;a<e.length;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`)}var X=class extends Error{constructor(e){super(`the computed change set does not reconstruct the second file (${e})`),this.name=`DiffError`}},Z={unified:ce,context:le,normal:se},Q=`Files differ
17
- `;function ve(e,t,n){if(e===t)return``;let r=w(n);return r===null?Q:J(T(e),T(t),r)?``:Q}function $(e,t){if(!(Number.isInteger(e)&&e>=0)&&e!==1/0)throw RangeError(`${t} is a number of lines, not ${e}`);return e}function ye(e,t,{slide:n=!0,horizon:r=3,...i}={}){let a=T(e),o=T(t);return G(a,o,{...i,slide:n,horizon:$(r,`horizon`)}).map(({a0:e,a1:t,b0:n,b1:r})=>({a0:e,a1:t,b0:n,b1:r,remove:a.slice(e,t),insert:o.slice(n,r)}))}function be(e,t,n,{format:r=`unified`,context:i=3,label:a=null,...o}={}){if(!Object.hasOwn(Z,r))throw RangeError(`a change set prints as unified, context or normal, not ${r}`);let s=T(e),c=T(t);return Y(s,c,n,w(o)),n.length===0?``:Z[r](s,c,n,{context:i,label:a})}function xe(e,t,{format:n=`unified`,context:r=3,label:i=null,...a}={}){if(n===`brief`)return ve(e,t,a);let o=T(e),s=T(t),{slide:c=!0,horizon:l=0,...u}=a,d=$(l,`horizon`),f=G(o,s,{...u,slide:c,horizon:n===`normal`?d:Math.max(d,$(r,`context`))});return f.length===0?``:Z[n](o,s,f,{context:r,label:i})}export{o as a,s as b,u as c,A as d,F as e,X as f,ye as g,be as h,xe as i,_ as j,v as k,y as l,b as m};
9
+ `,L=(e,t)=>e+t+(t.endsWith(`
10
+ `)?``:se);function R(e,t){return t>e+1?`${e+1},${t}`:`${t>e?e+1:e}`}function ce(e,t,n){let r=``;for(let{a0:i,a1:a,b0:o,b1:s}of n){let n=i===a?`a`:o===s?`d`:`c`;r+=R(i,a)+n+R(o,s)+`
11
+ `;for(let t=i;t<a;t++)r+=L(`< `,e[t]);n===`c`&&(r+=`---
12
+ `);for(let e=o;e<s;e++)r+=L(`> `,t[e])}return F(e,t,n,r),r}function z(e,t){return t<=e?`${e},0`:t===e+1?`${e+1}`:`${e+1},${t-e}`}var le=I((e,t,n,r)=>{let i=`@@ -${z(n.a0,n.a1)} +${z(n.b0,n.b1)} @@${r===null?``:` `+r}
13
+ `,a=n.a0,o=n.b0;for(let{a0:r,a1:s,b1:c}of n.blocks){for(;a<r;a++,o++)i+=L(` `,e[a]);for(;a<s;a++)i+=L(`-`,e[a]);for(;o<c;o++)i+=L(`+`,t[o])}for(;a<n.a1;a++,o++)i+=L(` `,e[a]);return i});function B(e,t){return t<=e?`${e}`:t===e+1?`${e+1}`:`${e+1},${t}`}var V=I((e,t,n,r)=>{let i=`***************${r===null?``:` `+r}
14
+ `;return i+=`*** ${B(n.a0,n.a1)} ****
15
+ `,n.blocks.some(e=>e.a0<e.a1)&&(i+=H(e,n.a0,n.a1,n.blocks,`a`)),i+=`--- ${B(n.b0,n.b1)} ----
16
+ `,n.blocks.some(e=>e.b0<e.b1)&&(i+=H(t,n.b0,n.b1,n.blocks,`b`)),i});function H(e,t,n,r,i){let a=i+`1`,o=i+`0`,s=i===`a`?`b`:`a`,c=``,l=t;for(let t of r){for(;l<t[o];l++)c+=L(` `,e[l]);let n=t[s+`0`]<t[s+`1`]?`! `:i===`a`?`- `:`+ `;for(;l<t[a];l++)c+=L(n,e[l])}for(;l<n;l++)c+=L(` `,e[l]);return c}function U(e){let t=[];for(let n=0;;){let r=n;for(;n<e.length&&e[n];)n++;if(t.push(n>r),n===e.length)return t;n++}}function W(e,t,n){let r=t.length,i=U(n),a=0,o=0,s=0,c=()=>{if(a===r||e[s]!==e[a])return!1;for(t[s++]=0,t[a++]=1,o++;a<r&&t[a];)a++;return!0},l=()=>{if(s===0||e[s-1]!==e[a-1])return!1;for(t[--s]=1,t[--a]=0,o--;s>0&&t[s-1];)s--;return!0};for(let e=0;e<r;e++){if(!t[e]){o++;continue}for(s=e,a=e;a<r&&t[a];a++);let n=-1;for(let e=-1;e!==a-s;){for(e=a-s;l(););for(n=i[o]?a:-1;c();)i[o]&&(n=a)}if(n!==-1)for(let e=a-n;e>0;e--)l();e=a-1}}function ue(e){let t=1;for(let n=e;n!==0;n>>=2)t<<=1;return Math.max(256,t)}function G(e,t,{ignoreCase:n=!1,whitespace:r=`none`,minimal:i=!1,discard:a=!0,slide:o=!0,horizon:s=1/0}={}){let c=w({ignoreCase:n,whitespace:r});if(c===null&&J(e,t,null))return[];let{A:l,B:u,classes:d}=pe(e,t,c),f=new Uint8Array(l.length),p=new Uint8Array(u.length),m=de(e,t,s),[h,g]=i||!a?[null,null]:fe(l,u,d,m),_=q(m.lo,m.hiA,h,f),v=q(m.lo,m.hiB,g,p),y=new Uint8Array(_.length),b=new Uint8Array(v.length);me(_.map(e=>l[e]),v.map(e=>u[e]),y,b,i);for(let e=0;e<_.length;e++)y[e]&&(f[_[e]]=1);for(let e=0;e<v.length;e++)b[e]&&(p[v[e]]=1);if(o){let{lo:e,hiA:t,hiB:n}=m;W(l.subarray(e,t),f.subarray(e,t),p.subarray(e,n)),W(u.subarray(e,n),p.subarray(e,n),f.subarray(e,t))}let x=_e(f,p);return Y(e,t,x,c),x}function de(e,t,n){let r=Math.min(e.length,t.length),i=0;for(;i<r&&e[i]===t[i];)i++;let a=Math.max(0,i-n),o=0;for(;o<r-a&&e[e.length-1-o]===t[t.length-1-o];)o++;let s=Math.max(0,o-n);return{lo:a,hiA:e.length-s,hiB:t.length-s}}function fe(e,t,n,{lo:r,hiA:i,hiB:a}){let o=new Int32Array(n),s=new Int32Array(n);for(let t=r;t<i;t++)o[e[t]]++;for(let e=r;e<a;e++)s[t[e]]++;return[K(e.subarray(r,i),s),K(t.subarray(r,a),o)]}function K(e,t){let n=e.length,r=new Uint8Array(n),i=5;for(let e=Math.floor(n/64)>>2;e>0;e>>=2)i*=2;for(let a=0;a<n;a++){let n=t[e[a]];n===0?r[a]=1:n>i&&(r[a]=2)}for(let e=0;e<n;e++){if(r[e]===2){r[e]=0;continue}if(r[e]===0)continue;let t=e,i=0;for(;t<n&&r[t]!==0;t++)r[t]===2&&i++;for(;t>e&&r[t-1]===2;)r[--t]=0,i--;let a=t-e;if(i*4>a){for(;t>e;)r[--t]===2&&(r[t]=0);continue}let o=1;for(let e=a>>4;e>0;e>>=2)o<<=1;o++;for(let t=0,n=0;n<a;n++)r[e+n]===2?o===++t?n-=t:o<t&&(r[e+n]=0):t=0;for(let t=0,n=0;n<a&&!(n>=8&&r[e+n]===1||(r[e+n]===2?(t=0,r[e+n]=0):r[e+n]===0?t=0:t++,t===3));n++);e+=a-1;for(let t=0,n=0;n<a&&!(n>=8&&r[e-n]===1||(r[e-n]===2?(t=0,r[e-n]=0):r[e-n]===0?t=0:t++,t===3));n++);}return r}function q(e,t,n,r){let i=[];for(let a=e;a<t;a++)n!==null&&n[a-e]!==0?r[a]=1:i.push(a);return Int32Array.from(i)}function J(e,t,n=null){if(e.length!==t.length)return!1;let r=n?(e,t)=>n(e)===n(t):(e,t)=>e===t;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function pe(e,t,n){let r=new Map,i=e=>{let t=n?n(e):e,i=r.get(t);return i===void 0&&(i=r.size,r.set(t,i)),i};return{A:Int32Array.from(e,i),B:Int32Array.from(t,i),classes:r.size}}function me(e,t,n,r,i){let a=e.length+t.length+3,o={A:e,B:t,fd:new Int32Array(a),bd:new Int32Array(a),base:t.length+1,limit:ue(e.length+t.length)},s=[{xoff:0,xlim:e.length,yoff:0,ylim:t.length,minimal:i}],c={xmid:0,ymid:0,loMinimal:!1,hiMinimal:!1};for(;s.length;){let{xoff:i,xlim:a,yoff:l,ylim:u,minimal:d}=s.pop();for(;i<a&&l<u&&e[i]===t[l];)i++,l++;for(;i<a&&l<u&&e[a-1]===t[u-1];)a--,u--;if(i===a){for(;l<u;l++)r[l]=1;continue}if(l===u){for(;i<a;i++)n[i]=1;continue}he(o,i,a,l,u,d,c),s.push({xoff:c.xmid,xlim:a,yoff:c.ymid,ylim:u,minimal:c.hiMinimal}),s.push({xoff:i,xlim:c.xmid,yoff:l,ylim:c.ymid,minimal:c.loMinimal})}}function he(e,t,n,r,i,a,o){let{A:s,B:c,fd:l,bd:u,base:d,limit:f}=e,p=n-r,m=t-i,h=n-i,g=t-r,_=h,v=h,y=g,b=g,x=!!(g-h&1);l[d+g]=t,u[d+h]=n;for(let h=1;;h++){b>m?l[d+--b-1]=-1:++b,y<p?l[d+ ++y+1]=-1:--y;for(let e=y;e>=b;e-=2){let t=l[d+e+1],r=l[d+e-1],a=r<t?t:r+1,f=a-e;for(;a<n&&f<i&&s[a]===c[f];)a++,f++;if(l[d+e]=a,x&&v<=e&&e<=_&&u[d+e]<=a){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}v>m?u[d+--v-1]=2147483647:++v,_<p?u[d+ ++_+1]=2147483647:--_;for(let e=_;e>=v;e-=2){let n=u[d+e+1],i=u[d+e-1],a=i<n?i:n-1,f=a-e;for(;t<a&&r<f&&s[a-1]===c[f-1];)a--,f--;if(u[d+e]=a,!x&&b<=e&&e<=y&&a<=l[d+e]){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}if(!(a||h<f)){ge(e,{xoff:t,xlim:n,yoff:r,ylim:i,fmin:b,fmax:y,bmin:v,bmax:_},o);return}}}function ge(e,t,n){let{fd:r,bd:i,base:a}=e,{xoff:o,xlim:s,yoff:c,ylim:l,fmin:u,fmax:d,bmin:f,bmax:p}=t,m=0,h=-1;for(let e=d;e>=u;e-=2){let t=Math.min(r[a+e],s),n=t-e;l<n&&(t=l+e,n=l),h<t+n&&(h=t+n,m=t)}let g=0,_=2147483647;for(let e=p;e>=f;e-=2){let t=Math.max(o,i[a+e]),n=t-e;n<c&&(t=c+e,n=c),t+n<_&&(_=t+n,g=t)}s+l-_<h-(o+c)?(n.xmid=m,n.ymid=h-m,n.loMinimal=!0,n.hiMinimal=!1):(n.xmid=g,n.ymid=_-g,n.loMinimal=!1,n.hiMinimal=!0)}function _e(e,t){let n=[],r=t.length,i=e.length,a=0,o=0;for(;a<i||o<r;){if(a<i&&o<r&&!e[a]&&!t[o]){a++,o++;continue}let s=a,c=o;for(;a<i&&e[a];)a++;for(;o<r&&t[o];)o++;if(s===a&&c===o)throw new X(`a kept line has no counterpart`);n.push({a0:s,a1:a,b0:c,b1:o})}return n}function Y(e,t,n,r=null){let i=r?(e,t)=>r(e)===r(t):(e,t)=>e===t,a=0,o=0;for(let{a0:r,a1:s,b0:c,b1:l}of n){if(r<a||c<o||s<r||l<c||s>e.length||l>t.length)throw new X(`a block is out of order or out of range`);if(r===s&&c===l)throw new X(`a block changes nothing`);if(r-a!==c-o)throw new X(`the kept lines before a block differ in count`);for(;a<r;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`);a=s,o=l}if(e.length-a!==t.length-o)throw new X(`the kept lines after the last block differ in count`);for(;a<e.length;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`)}var X=class extends Error{constructor(e){super(`the computed change set does not reconstruct the second file (${e})`),this.name=`DiffError`}},Z={unified:le,context:V,normal:ce},Q=`Files differ
17
+ `;function ve(e,t,n){if(e===t)return``;let r=w(n);return r===null?Q:J(T(e),T(t),r)?``:Q}function $(e,t){if(!(Number.isInteger(e)&&e>=0)&&e!==1/0)throw RangeError(`${t} is a number of lines, not ${e}`);return e}function ye(e,t,{slide:n=!0,horizon:r=3,...i}={}){let a=T(e),o=T(t);return G(a,o,{...i,slide:n,horizon:$(r,`horizon`)}).map(({a0:e,a1:t,b0:n,b1:r})=>({a0:e,a1:t,b0:n,b1:r,remove:a.slice(e,t),insert:o.slice(n,r)}))}function be(e,t,n,{format:r=`unified`,context:i=3,label:a=null,...o}={}){if(!Object.hasOwn(Z,r))throw RangeError(`a change set prints as unified, context or normal, not ${r}`);let s=T(e),c=T(t);return Y(s,c,n,w(o)),n.length===0?``:Z[r](s,c,n,{context:i,label:a})}function xe(e,t,{format:n=`unified`,context:r=3,label:i=null,...a}={}){if(n===`brief`)return ve(e,t,a);let o=T(e),s=T(t),{slide:c=!0,horizon:l=0,...u}=a,d=$(l,`horizon`),f=G(o,s,{...u,slide:c,horizon:n===`normal`?d:Math.max(d,$(r,`context`))});return f.length===0?``:Z[n](o,s,f,{context:r,label:i})}export{o as a,s as b,u as c,P as d,X as e,ye as f,be as g,xe as h,_ as i,v as j,y as k,b as l};
@@ -1 +1 @@
1
- import{z as e}from"./chunk-6HNXNIQY.js";import{m as t,p as n,u as r}from"./chunk-WI7Z5A2T.js";import{a as i}from"./chunk-3PS4KWD2.js";import{b as a}from"./chunk-IYPY47MC.js";import{D as o,J as s,L as c,q as l}from"./chunk-SXV2T5C4.js";function u(e){let{data:t}=c(e);return t&&d(t)>0?t:null}function d(e){return(s(e)??[]).filter(t=>(Array.isArray(t)?t:[t]).some(t=>t&&typeof t==`object`&&l(t,t.source??e.source))).length}function f(e,t){let n=[],r=new Map;for(let{name:t,content:i,fallbackRepo:a}of e){if(typeof i!=`string`)continue;let e=u(i);if(!e)continue;let c=s(e),l=o(e)??o({repo:{github:a}}),f=new Set(l?[l]:[]);if(!l)for(let e of c.flat()){if(/(?:^|\/)(?:node_modules|dependencies)\//u.test(e?.file??``))continue;let t=o(e);t&&f.add(t)}for(let e of f)r.set(e,{id:e,label:e});n.push({id:t,filename:t,repoIds:[...f],analyzer:e.source,appFindings:d(e)})}let i=new Set(n.map(e=>e.id));return{merge:{bundles:[],results:[]},link:{reports:n,repositories:[...r.values()],workspaces:t.map(e=>({id:e.id,label:e.name,reports:e.reports.filter(e=>i.has(e))})).filter(e=>e.reports.length>0)}}}function p(e,t){let n=(e.reports??[]).filter(e=>e.visible&&e.repoId!=null).flatMap(e=>{let t=u(e.content??``);return t?[{id:e.id,filename:e.filename,repoIds:[e.repoId],repo:e.repoFullName,directory:e.repoDirectory,analyzer:e.analyzer,appFindings:d(t)}]:[]}),r=new Map((e.repos??[]).map(e=>[e.repoId,{id:e.repoId,label:e.fullName}]));for(let e of n)r.has(e.repoIds[0])||r.set(e.repoIds[0],{id:e.repoIds[0],label:e.repo??String(e.repoIds[0])});let a=t.results??[],o=new Set(a.map(e=>e.bundleId));return{merge:{bundles:(t.bundles??[]).filter(e=>o.has(e.id)).map(e=>({...e,size:i(e.byteSize)})),results:a},link:{repositories:[...r.values()].filter(e=>n.some(t=>t.repoIds.includes(e.id))),reports:n}}}var m=new Map([[`openai/gpt-6-astra`,`GPT-6 Astra`],[`openai/gpt-6-astra-pro`,`GPT-6 Astra Pro`],[`openai/gpt-5.6-sol`,`GPT-5.6 Sol`],[`openai/gpt-5.6-terra`,`GPT-5.6 Terra`],[`openai/gpt-5.6-luna`,`GPT-5.6 Luna`],[`anthropic/claude-fable-5.1`,`Claude Fable 5.1`],[`anthropic/claude-opus-5`,`Claude Opus 5`],[`anthropic/claude-sonnet-5`,`Claude Sonnet 5`],[`moonshotai/kimi-k3`,`Kimi K3`],[`z-ai/glm-5.3`,`GLM 5.3`],[`qwen/qwen3.8-max`,`Qwen3.8 Max`],[`deepseek/deepseek-v4.1-flash`,`DeepSeek V4.1 Flash`],[`deepseek/deepseek-v4-pro`,`DeepSeek V4 Pro`]]),h=new Map([[`openai`,`OpenAI`],[`anthropic`,`Anthropic`],[`moonshotai`,`Moonshot AI`],[`google`,`Google`],[`nvidia`,`NVIDIA`],[`qwen`,`Qwen`],[`deepseek`,`DeepSeek`],[`x-ai`,`xAI`],[`z-ai`,`Z.ai`],[`mistralai`,`Mistral AI`],[`meta`,`Meta`],[`unbiased`,`Unbiased`]]),g=new Map([[`meta-llama`,`meta`]]),_=new Map([[`gpt`,`GPT`],[`gptoss`,`GPT OSS`],[`oss`,`OSS`],[`o`,`O`],[`ai`,`AI`],[`api`,`API`],[`4o`,`4o`],[`k3`,`K3`],[`k4`,`K4`],[`qwen`,`Qwen`],[`kimi`,`Kimi`],[`mimo`,`MiMo`],[`gemini`,`Gemini`],[`claude`,`Claude`],[`fable`,`Fable`],[`opus`,`Opus`],[`sonnet`,`Sonnet`],[`astra`,`Astra`],[`terra`,`Terra`],[`luna`,`Luna`],[`codex`,`Codex`],[`deepseek`,`DeepSeek`],[`nemotron`,`Nemotron`],[`gemma`,`Gemma`]]);function v(e){let t=e.replace(/:free$/u,``).replaceAll(`_`,`-`).split(`-`).filter(Boolean),n=[];for(let e=0;e<t.length;e++){let r=t[e],i=t[e+1];if(/^\d+$/u.test(r)&&/^\d+$/u.test(i??``)){n.push(`${r}.${i}`),e++;continue}let a=_.get(r.toLowerCase());n.push(a??(/^(?:[a-z]+\d+|\d+[a-z]+)$/iu.test(r)?r.toUpperCase():r[0]?.toUpperCase()+r.slice(1)))}return n.join(` `).replace(/^GPT (\d)/u,`GPT-$1`)}function y(e){return m.get(e)??v(e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e)}function b(e){let t=e.includes(`/`)?e.split(`/`)[0].replace(/^~/u,``):`other`,n=g.get(t)??t;return{key:n,name:h.get(n)??(n===`other`?`Other`:v(n))}}function x(e){return e===`xhigh`?`Extra high`:e?e[0].toUpperCase()+e.slice(1):`Unavailable`}function S(e){return e.efforts.includes(`max`)?`max`:e.efforts.at(-1)??null}async function C(e,t=fetch){let n=await t(`/api/admin/scan/models`,{credentials:`same-origin`,headers:{accept:`application/json`},signal:e});if(!n.ok)throw Error(`HTTP ${n.status}`);return w(await n.json())}function w(e){if(!Array.isArray(e?.models))throw Error(`No model catalogue returned`);let t=e.models.filter(e=>typeof e?.id==`string`&&e.id.length>0).map(e=>({id:e.id,efforts:Array.isArray(e.efforts)?[...new Set(e.efforts.filter(e=>typeof e==`string`&&e.length>0))]:[]}));if(t.length===0)throw Error(`No models available`);return{models:t,defaultModel:t.find(t=>t.id===e.defaultModel)?.id??t[0].id}}function T(e,t=[]){let n=new Map,r=e.flatMap(e=>{let r=t.filter(t=>t.bundles?.includes(e.integrity));return(r.length>0?r.map(e=>({id:e.id,label:e.name})):[{id:`unattached`,label:`Unattached`}]).map(t=>(n.set(t.id,t),{id:e.integrity,integrity:e.integrity,filename:e.name,repoId:t.id,repo:t.label,files:null,reasons:[],size:`—`}))});return{repositories:[...n.values()],bundles:r,reports:[],scans:[]}}function E(o,s){if(s.error)throw Error(s.error);let c=n(s),l=s.kind===`stasis`?s.bundle?.formats:null,u=r(s),d=[...t(s)].filter(([,e])=>e!=null).map(([e,t])=>({path:e,format:l?.get(e)??null,bytes:t,lines:u.get(e)??0,size:i(t),module:a(e,{packageDir:c?.get(e)})})),f=[{id:`all`,label:`All`,filePaths:null},...[...e(s,d.map(e=>e.path))].map(([e,t])=>({id:`reason:${e}`,label:e,filePaths:[...t]}))];return{...o,files:d,reasons:f,size:i(s.size)}}export{T as a,E as b,f as c,p as d,y as e,b as f,x as g,S as h,C as i,w as j};
1
+ import{z as e}from"./chunk-S6GIXWQW.js";import{m as t,p as n,u as r}from"./chunk-JKGQ3O7O.js";import{a as i}from"./chunk-3PS4KWD2.js";import{b as a}from"./chunk-IYPY47MC.js";import{D as o,J as s,L as c,q as l}from"./chunk-SXV2T5C4.js";function u(e){let{data:t}=c(e);return t&&d(t)>0?t:null}function d(e){return(s(e)??[]).filter(t=>(Array.isArray(t)?t:[t]).some(t=>t&&typeof t==`object`&&l(t,t.source??e.source))).length}function f(e,t){let n=[],r=new Map;for(let{name:t,content:i,fallbackRepo:a}of e){if(typeof i!=`string`)continue;let e=u(i);if(!e)continue;let c=s(e),l=o(e)??o({repo:{github:a}}),f=new Set(l?[l]:[]);if(!l)for(let e of c.flat()){if(/(?:^|\/)(?:node_modules|dependencies)\//u.test(e?.file??``))continue;let t=o(e);t&&f.add(t)}for(let e of f)r.set(e,{id:e,label:e});n.push({id:t,filename:t,repoIds:[...f],analyzer:e.source,appFindings:d(e)})}let i=new Set(n.map(e=>e.id));return{merge:{bundles:[],results:[]},link:{reports:n,repositories:[...r.values()],workspaces:t.map(e=>({id:e.id,label:e.name,reports:e.reports.filter(e=>i.has(e))})).filter(e=>e.reports.length>0)}}}function p(e,t){let n=(e.reports??[]).filter(e=>e.visible&&e.repoId!=null).flatMap(e=>{let t=u(e.content??``);return t?[{id:e.id,filename:e.filename,repoIds:[e.repoId],repo:e.repoFullName,directory:e.repoDirectory,analyzer:e.analyzer,appFindings:d(t)}]:[]}),r=new Map((e.repos??[]).map(e=>[e.repoId,{id:e.repoId,label:e.fullName}]));for(let e of n)r.has(e.repoIds[0])||r.set(e.repoIds[0],{id:e.repoIds[0],label:e.repo??String(e.repoIds[0])});let a=t.results??[],o=new Set(a.map(e=>e.bundleId));return{merge:{bundles:(t.bundles??[]).filter(e=>o.has(e.id)).map(e=>({...e,size:i(e.byteSize)})),results:a},link:{repositories:[...r.values()].filter(e=>n.some(t=>t.repoIds.includes(e.id))),reports:n}}}var m=new Map([[`openai/gpt-6-astra`,`GPT-6 Astra`],[`openai/gpt-6-astra-pro`,`GPT-6 Astra Pro`],[`openai/gpt-5.6-sol`,`GPT-5.6 Sol`],[`openai/gpt-5.6-terra`,`GPT-5.6 Terra`],[`openai/gpt-5.6-luna`,`GPT-5.6 Luna`],[`anthropic/claude-fable-5.1`,`Claude Fable 5.1`],[`anthropic/claude-opus-5`,`Claude Opus 5`],[`anthropic/claude-sonnet-5`,`Claude Sonnet 5`],[`moonshotai/kimi-k3`,`Kimi K3`],[`z-ai/glm-5.3`,`GLM 5.3`],[`qwen/qwen3.8-max`,`Qwen3.8 Max`],[`deepseek/deepseek-v4.1-flash`,`DeepSeek V4.1 Flash`],[`deepseek/deepseek-v4-pro`,`DeepSeek V4 Pro`]]),h=new Map([[`openai`,`OpenAI`],[`anthropic`,`Anthropic`],[`moonshotai`,`Moonshot AI`],[`google`,`Google`],[`nvidia`,`NVIDIA`],[`qwen`,`Qwen`],[`deepseek`,`DeepSeek`],[`x-ai`,`xAI`],[`z-ai`,`Z.ai`],[`mistralai`,`Mistral AI`],[`meta`,`Meta`],[`unbiased`,`Unbiased`]]),g=new Map([[`meta-llama`,`meta`]]),_=new Map([[`gpt`,`GPT`],[`gptoss`,`GPT OSS`],[`oss`,`OSS`],[`o`,`O`],[`ai`,`AI`],[`api`,`API`],[`4o`,`4o`],[`k3`,`K3`],[`k4`,`K4`],[`qwen`,`Qwen`],[`kimi`,`Kimi`],[`mimo`,`MiMo`],[`gemini`,`Gemini`],[`claude`,`Claude`],[`fable`,`Fable`],[`opus`,`Opus`],[`sonnet`,`Sonnet`],[`astra`,`Astra`],[`terra`,`Terra`],[`luna`,`Luna`],[`codex`,`Codex`],[`deepseek`,`DeepSeek`],[`nemotron`,`Nemotron`],[`gemma`,`Gemma`]]);function v(e){let t=e.replace(/:free$/u,``).replaceAll(`_`,`-`).split(`-`).filter(Boolean),n=[];for(let e=0;e<t.length;e++){let r=t[e],i=t[e+1];if(/^\d+$/u.test(r)&&/^\d+$/u.test(i??``)){n.push(`${r}.${i}`),e++;continue}let a=_.get(r.toLowerCase());n.push(a??(/^(?:[a-z]+\d+|\d+[a-z]+)$/iu.test(r)?r.toUpperCase():r[0]?.toUpperCase()+r.slice(1)))}return n.join(` `).replace(/^GPT (\d)/u,`GPT-$1`)}function y(e){return m.get(e)??v(e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e)}function b(e){let t=e.includes(`/`)?e.split(`/`)[0].replace(/^~/u,``):`other`,n=g.get(t)??t;return{key:n,name:h.get(n)??(n===`other`?`Other`:v(n))}}function x(e){return e===`xhigh`?`Extra high`:e?e[0].toUpperCase()+e.slice(1):`Unavailable`}function S(e){return e.efforts.includes(`max`)?`max`:e.efforts.at(-1)??null}async function C(e,t=fetch){let n=await t(`/api/admin/scan/models`,{credentials:`same-origin`,headers:{accept:`application/json`},signal:e});if(!n.ok)throw Error(`HTTP ${n.status}`);return w(await n.json())}function w(e){if(!Array.isArray(e?.models))throw Error(`No model catalogue returned`);let t=e.models.filter(e=>typeof e?.id==`string`&&e.id.length>0).map(e=>({id:e.id,efforts:Array.isArray(e.efforts)?[...new Set(e.efforts.filter(e=>typeof e==`string`&&e.length>0))]:[]}));if(t.length===0)throw Error(`No models available`);return{models:t,defaultModel:t.find(t=>t.id===e.defaultModel)?.id??t[0].id}}function T(e,t=[]){let n=new Map,r=e.flatMap(e=>{let r=t.filter(t=>t.bundles?.includes(e.integrity));return(r.length>0?r.map(e=>({id:e.id,label:e.name})):[{id:`unattached`,label:`Unattached`}]).map(t=>(n.set(t.id,t),{id:e.integrity,integrity:e.integrity,filename:e.name,repoId:t.id,repo:t.label,files:null,reasons:[],size:`—`}))});return{repositories:[...n.values()],bundles:r,reports:[],scans:[]}}function E(o,s){if(s.error)throw Error(s.error);let c=n(s),l=s.kind===`stasis`?s.bundle?.formats:null,u=r(s),d=[...t(s)].filter(([,e])=>e!=null).map(([e,t])=>({path:e,format:l?.get(e)??null,bytes:t,lines:u.get(e)??0,size:i(t),module:a(e,{packageDir:c?.get(e)})})),f=[{id:`all`,label:`All`,filePaths:null},...[...e(s,d.map(e=>e.path))].map(([e,t])=>({id:`reason:${e}`,label:e,filePaths:[...t]}))];return{...o,files:d,reasons:f,size:i(s.size)}}export{T as a,E as b,f as c,p as d,y as e,b as f,x as g,S as h,C as i,w as j};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-GO7FT4OD.js";import{c as t,d as n,e as r,h as i,i as a,j as o,m as s,n as c,o as l}from"./chunk-5DHL5NG3.js";import{j as u}from"./chunk-NPW52BM2.js";import"./chunk-PXK7EU4V.js";import{a as d,c as f}from"./chunk-JCIIBLKR.js";import{l as p,p as m,q as h,u as g}from"./chunk-WI7Z5A2T.js";import{b as _}from"./chunk-IYPY47MC.js";import"./chunk-SXV2T5C4.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function v(e){if(typeof e!=`string`)throw TypeError(`a text must be a string, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a text must be a well-formed string`);return{proven:!1,reason:`unsupported`,at:null}}var y=e=>e.subarray(0,8e3).includes(0),b=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,x=e=>Uint8Array.from({length:256},(t,n)=>Number(n===10||e.includes(String.fromCodePoint(n)))),S=x(``),C=x(`,;={}`);function w(e,t=S){let n=!y(e),r=new Map,i=(e,t)=>r.set(e,(r.get(e)??0)+t),a=0,o=0,s=0;for(let r=0;r<e.length;r++){let c=e[r];if(n&&c===13&&e[r+1]===10)continue;let l=a;a=(a<<7^o>>>25)+c>>>0,o=(o<<7^l>>>25)>>>0,!(++s<64&&t[c]===0)&&(i(b(a,o),s),s=0,a=0,o=0)}s>0&&i(b(a,o),s);let c=Uint32Array.from(r.keys()).sort();return{hashes:c,bytes:Float64Array.from(c,e=>r.get(e)),total:r.values().reduce((e,t)=>e+t,0)}}function T(e,t){let n=0;for(let r=0,i=0;r<e.hashes.length&&i<t.hashes.length;)e.hashes[r]<t.hashes[i]?r++:e.hashes[r]>t.hashes[i]?i++:n+=Math.min(e.bytes[r++],t.bytes[i++]);return n}function E(e,t,n){let r=0,i=e.total,a=t.total;for(let o=0,s=0;o<e.hashes.length&&s<t.hashes.length;)if(e.hashes[o]<t.hashes[s]?i-=e.bytes[o++]:(e.hashes[o]>t.hashes[s]||(r+=Math.min(e.bytes[o],t.bytes[s]),i-=e.bytes[o++]),a-=t.bytes[s++]),(r+Math.min(i,a))*6e4<n)return 0;return r}function ee(e,t,n,r,i=!1){if(e===null||t===null||t.length===0)return 0;let a=Math.abs(e.length-t.length),o=Math.max(e.length,t.length);if(o*(6e4-n)<a*6e4)return 0;let s=r(e),c=r(t),l=i?E(s,c,n*o):T(s,c);return Math.trunc(l*6e4/o)}var D=/^[\w-]{6,}$/u,O=/[\dA-Z]/u,te=/^(?:\.[\w-]+)+$/u,ne=/^[\w-]{8,32}$/u;function k(e){let t=[];for(let n=e.length-1;n>0;n--){if(e[n]!==`-`&&e[n]!==`.`)continue;let r=e.indexOf(`.`,n+1),i=e.slice(r),a=e.slice(n+1,r);r!==-1&&ne.test(a)&&te.test(i)&&/[A-Za-z]/u.test(a)&&O.test(a)&&t.push([e.slice(0,n),a,i])}return t}var re=e=>e.replaceAll(/\d/gu,`0`).replaceAll(/[a-z]/gu,`a`).replaceAll(/[A-Z]/gu,`A`);function ie(e,t){let n=k(t);for(let[t,r,i]of k(e)){let e=n.find(e=>e[2]===i);if(e&&e[1]!==r)return e[0]===t&&re(e[1])!==re(r)}return!1}function ae(e){let t=e.lastIndexOf(`/`),n=e.slice(t+1),r=n.lastIndexOf(`.`),i=r>0?n.slice(r):``;return{name:n,key:`${e.slice(0,t+1)}\0${i}\0${n.length}`}}function oe(e,t){let n=e.length,r=0;for(;r<e.length&&e[r]===t[r];)r++;for(;n>r&&e[n-1]===t[n-1];)n--;for(;r>0&&!`-._`.includes(e[r-1]);)r--;for(;n<e.length&&e[n]!==`.`;)n++;let i=e.slice(r,n),a=t.slice(r,n);return r>0&&D.test(i)&&D.test(a)&&(O.test(i)||O.test(a))}function se({sources:e,dests:t,pairs:n,used:r,record:i,punctuatedScoreOf:a},{remaining:o,open:s},c,l){let u=(e,t)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>[t,ae(e[t].path)])),d=u(t,s),f=u(e,o),p=Map.groupBy(f.keys(),e=>f.get(e).key),m=Map.groupBy(d.keys(),e=>d.get(e).key),h=[];for(let[e,t]of m){let n=p.get(e)??[];for(let e of t)for(let t of n)oe(f.get(t).name,d.get(e).name)&&h.push({s:t,d:e})}let g=Map.groupBy(h,({d:e})=>e),_=Map.groupBy(h,({s:e})=>e),v=[];for(let{s:e,d:t}of h){let n=_.get(e).length===1&&g.get(t).length===1&&ie(f.get(e).name,d.get(t).name),r=a(e,t,n?0:c);(n||r>=c)&&v.push({s:e,d:t,score:r})}let y=[],b=new Set,x=new Set;for(let e of v.sort((e,t)=>t.score-e.score))n.has(e.d)||r.has(e.s)||(x.has(e.s)||b.has(e.d)||l(e)?(y.push(e),x.add(e.s),b.add(e.d)):i(e.d,e.s,e.score));return y}function ce(e,t){let n=e.length;if(n!==t.length)return!1;let r=0;if(n>=32&&(e.byteOffset&3)==(t.byteOffset&3)){for(let n=4-(e.byteOffset&3)&3;r<n;r++)if(e[r]!==t[r])return!1;let i=n-r>>>2,a=new Int32Array(e.buffer,e.byteOffset+r,i),o=new Int32Array(t.buffer,t.byteOffset+r,i);for(let e=0;e<i;e++)if(a[e]!==o[e])return!1;r+=i*4}for(;r<n;r++)if(e[r]!==t[r])return!1;return!0}var A=class extends Error{constructor(e,t,n){let r=n===void 0?``:` in the ${n} tree`;super(t===void 0?e:`${e}: ${JSON.stringify(t)}${r}`),this.name=`CompareError`,this.path=t,this.tree=n}},le=new Set([`file`,`contiguous-file`]),ue=new Set([`fifo`,`character-device`,`block-device`]),de=/(?:^|\/)\.{0,2}(?:\/|$)/u;function fe(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function pe(e,t,n,r){if(typeof e!=`string`)throw TypeError(`an entry's name must be a string, not ${typeof e}`);if(e!==`.`||t!==`directory`){if(r?e===``:de.test(e))throw new A(r?`a name must not be empty`:"a name must be a relative path with no empty, `.` or `..` segment",e,n);if(!e.isWellFormed())throw new A(`a name must be well-formed Unicode`,e,n)}}function me(e,t,n){if(typeof e!=`string`||e===``)throw new A(`a link must name its target`,t,n);if(!e.isWellFormed())throw new A(`a link target must be well-formed Unicode`,t,n);return e}function he(e){if(e===void 0)return new Uint8Array;if(e instanceof Uint8Array)return e;if(typeof e!=`string`)throw TypeError(`a file's data must be a string or a Uint8Array, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a file's text must be well-formed Unicode`);return e}var j=e=>typeof e==`string`?u(e):e;function ge(e,t,n){if(typeof e!=`object`||!e)throw TypeError(`an entry must be an object, not ${e===null?`null`:typeof e}`);let{name:r,type:i=`file`,mode:a,linkname:o,data:s}=e;if(pe(r,i,t,n),a!==void 0&&fe(a),le.has(i))return{path:r,type:`file`,mode:a??420,data:he(s)};if(i===`symlink`||i===`hardlink`)return{path:r,type:i,target:me(o,r,t)};if(i===`directory`)return{path:r,type:i};throw ue.has(i)?new A(`a ${i} is neither a file nor a link`,r,t):TypeError(`${JSON.stringify(i)} is not an entry type`)}function M(e,t){return e.type===t.type?e.type===`symlink`?e.target===t.target:e.data===t.data?!0:typeof e.data==`string`&&typeof t.data==`string`?!1:ce(j(e.data),j(t.data)):!1}function _e(e,t,n){let r=new Set([e.path]),i=t.get(e.target);for(;i?.type===`hardlink`;){if(r.has(i.path))throw new A(`a hard link leads back to itself`,e.path,n);r.add(i.path),i=t.get(i.target)}if(i===void 0||i.type===`directory`)throw new A(`a hard link must name a file or a link in the tree`,e.path,n);return{...i,path:e.path}}function N(e,t,n){let r=new Map;for(let i of e){let e=ge(i,t,n);if(e.type!==`directory`||e.path!==`.`){if(r.has(e.path))throw new A(`a name is given twice`,e.path,t);r.set(e.path,e)}}let i=new Map;for(let[e,a]of r){for(let i=n?-1:e.lastIndexOf(`/`);i>0;i=e.lastIndexOf(`/`,i-1)){let n=r.get(e.slice(0,i));if(n!==void 0&&n.type!==`directory`)throw new A(`a path lies under a ${n.type===`symlink`?`link`:`file`}`,e,t)}a.type===`hardlink`?i.set(e,_e(a,r,t)):a.type!==`directory`&&i.set(e,a)}return i}var ve=100,ye=4,P=e=>e.slice(e.lastIndexOf(`/`)+1);function F(t,n){if(t.type===`symlink`)return`l${t.target}`;let r=n(t);return`f${r.length}:${e(r)}`}function be({sources:e,dests:t,sourceNames:n,destNames:r,used:i,record:a,bytes:o}){let s=Map.groupBy(e.keys(),t=>F(e[t],o));for(let c=0;c<t.length;c++){let l=-1,u=ve;for(let a of s.get(F(t[c],o))??[])if(!i.has(a)&&M(e[a],t[c])&&((l===-1||n[a]===r[c])&&(l=a),n[a]===r[c]||--u===0))break;l!==-1&&a(c,l,6e4)}}var xe=new Map([[`.ts`,`.js`],[`.mts`,`.mjs`],[`.cts`,`.cjs`],[`.tsx`,`.jsx`]]),Se=new Map([...[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.mts`,`.cts`,`.tsx`].map(e=>[e,`script`]),...[`.css`,`.scss`,`.sass`,`.less`].map(e=>[e,`style`])]);function I(e){let t=e.split(`/`),n=t.pop(),r=n.lastIndexOf(`.`);return r>0?{dirs:t,stem:n.slice(0,r),extension:n.slice(r)}:{dirs:t,stem:n,extension:``}}function L(e){let{dirs:t,stem:n,extension:r}=I(e);return JSON.stringify([t.map(e=>e===`lib`||e===`src`?null:e),n,xe.get(r)??r])}function Ce(e){let{dirs:t,stem:n,extension:r}=I(e),i=[n,Se.get(r)??r],a=t.lastIndexOf(`node_modules`),o=a===-1?0:a+(t[a+1]?.startsWith(`@`)?3:2),s=[JSON.stringify([...i,t])];for(let e=o;e<t.length;e++)s.push(JSON.stringify([...i,t.toSpliced(e,1,null)]));return s}var R=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function z({pairs:e,used:t,scoreOf:n},{remaining:r,open:i},{s:a,d:o,score:s},c){let l=R(s,c);return i.some(t=>t!==o&&!e.has(t)&&n(a,t,l)>=l)||r.some(e=>e!==a&&!t.has(e)&&n(e,o,l)>=l)}function we(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=Map.groupBy(t.remaining.filter(e=>i[e].type===`file`),e=>L(i[e].path)),d=t.open.filter(e=>a[e].type===`file`).flatMap(e=>(u.get(L(a[e].path))??[]).map(t=>({s:t,d:e,score:l(t,e,0)})));for(let i of d.sort((e,t)=>t.score-e.score))!o.has(i.d)&&!s.has(i.s)&&!(n&&z(e,t,i,r))&&c(i.d,i.s,i.score)}function Te(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=new Map,d=(e,t,n)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>{let r=Ce(e[t].path);for(let e of r)(u.get(e)??u.set(e,{sources:[],dests:[]}).get(e))[n].push(t);return[t,r]})),f=d(a,t.open.filter(e=>!o.has(e)),`dests`),p=d(i,t.remaining.filter(e=>!s.has(e)),`sources`),m=(e,t)=>{let n=new Set(e.flatMap(e=>u.get(e)[t]));return n.size===1?[...n][0]:-1};for(let[i,a]of p){let o=m(a,`dests`);if(o===-1||m(f.get(o),`sources`)!==i)continue;let s={s:i,d:o,score:l(i,o,0)};n&&z(e,t,s,r)||c(o,i,s.score)}}function Ee(e,t,n){let r=H(e),i=t<6e4&&r.remaining.length*r.open.length<=n*n;we(e,r,i,t),Te(e,r,i,t)}function B(e,t){let n=new Map;for(let r of t)n.set(e[r],n.has(e[r])?-1:r);return n}function De({sourceNames:e,destNames:t,record:n,scoreOf:r},{remaining:i,open:a},o){let s=B(t,a),c=B(e,i);for(let t of i){let i=s.get(e[t]);if(i===void 0||i===-1||c.get(e[t])===-1)continue;let a=r(t,i,o);a>=o&&n(i,t,a)}}var V=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function Oe(e,t){if(e.length<ye){e.push(t);return}let n=0;for(let t=1;t<e.length;t++)V(e[t],e[n])>0&&(n=t);V(e[n],t)>0&&(e[n]=t)}function ke({sourceNames:e,destNames:t,pairs:n,used:r,record:i,scoreOf:a},{remaining:o,open:s},c,l){let u=[];for(let n of s){let r=[];for(let i of o)Oe(r,{score:a(i,n,c),nameScore:+(e[i]===t[n]),dst:n,src:i});u.push(...r)}let d=0,f=e=>{for(;d<l.length&&R(l[d].score,c)>e;d++){let{s:e,d:t,score:a}=l[d];!n.has(t)&&!r.has(e)&&i(t,e,a)}};for(let{dst:e,src:t,score:a}of u.sort(V)){if(a<c)break;f(a),!n.has(e)&&!r.has(t)&&i(e,t,a)}f(-1/0)}var H=({sources:e,dests:t,pairs:n,used:r})=>({remaining:e.keys().filter(e=>!r.has(e)).toArray(),open:t.keys().filter(e=>!n.has(e)).toArray()}),U=e=>e+Math.trunc(.5*(6e4-e));function W(e,t,{minimum:n,limit:r,byPath:i}){let a=new Map,o=new Set;if(e.length===0||t.length===0)return a;let s=new Map,c=new Map,l=new Map,u=e=>e.type===`file`?c.get(e)??c.set(e,j(e.data)).get(e):null,d=e=>s.get(e)??s.set(e,w(e)).get(e),f=e=>l.get(e)??l.set(e,w(e,C)).get(e),p={sources:e,dests:t,pairs:a,used:o,sourceNames:e.map(e=>P(e.path)),destNames:t.map(e=>P(e.path)),record(e,t,n){a.set(e,{source:t,score:n}),o.add(t)},bytes:u,scoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,d),punctuatedScoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,f,!0)};if(be(p),i&&Ee(p,n,r),n>=6e4)return a;De(p,H(p),U(n));let m=H(p);if(m.remaining.length*m.open.length>r*r)return a;let h=i?se(p,m,U(n),e=>z(p,m,e,n)):[];return ke(p,H(p),n,h),a}var Ae=50,je=1e3;function G(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.codePointAt(r)-t.codePointAt(r);return e.length-t.length}function Me(e){if(e===!1)return null;let t=e===!0?Ae:e;if(typeof t!=`number`)throw TypeError(`renames must be a boolean or a percentage, not ${typeof e}`);if(!(t>0&&t<=100))throw RangeError(`renames must be a percentage above 0 and at most 100, not ${e}`);return Math.max(1,Math.trunc(6e4*t/100))}function Ne({renamesByPath:e,renameLimit:t,renameGroup:n,paths:r,lines:i}){if(typeof e!=`boolean`)throw TypeError(`renamesByPath must be a boolean, not ${typeof e}`);if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw RangeError(`renameLimit must be a whole number or Infinity, not ${t}`);if(n!==null&&typeof n!=`function`)throw TypeError(`renameGroup must be a function, not ${typeof n}`);if(r!==`tree`&&r!==`keys`)throw RangeError(`paths must be 'tree' or 'keys', not ${r}`);if(typeof i!=`boolean`)throw TypeError(`lines must be a boolean, not ${typeof i}`)}var Pe=(e,t)=>M(e,t)&&(e.type!==`file`||e.mode===t.mode),K=(e,t,n,r=null)=>({status:e,old:t,new:n,similarity:r}),Fe=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,q=e=>e.endsWith(`.mts`)?`module`:e.endsWith(`.cts`)?`commonjs`:null,Ie=/^export\s*\{\s*\}\s*;?$/u;function J(e){if(e===null)return{proven:!0,runtime:``,loads:!1};let n=t(e);try{return n===void 0?{proven:!1}:v(n)}catch{return{proven:!1}}}function Le(e){if(![e.old,e.new].filter(e=>e!==null).every(e=>e.type===`file`&&Fe.test(e.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let t=J(e.new),n=J(e.old);return!n.proven||!t.proven||n.runtime!==t.runtime&&!(e.old===null&&Ie.test(t.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&q(e.old.path)!==q(e.new.path)?e:{...e,typeOnly:!0}}function Re(e,t){let n=[],r=[],i=[];for(let[n,a]of e){let e=t.get(n);e===void 0?i.push(a):e.type===a.type?Pe(a,e)||r.push(K(`modified`,a,e)):r.push(K(`type-changed`,a,e))}for(let[r,i]of t)e.has(r)||n.push(i);return i.sort((e,t)=>G(e.path,t.path)),n.sort((e,t)=>G(e.path,t.path)),{changes:r,deleted:i,added:n}}function ze(e,t,{group:n,...r}){if(n===null)return W(e,t,r);let i=new Map,a=e=>Map.groupBy(e.keys(),t=>n(e[t].path)),o=a(e);for(let[n,s]of a(t)){let a=o.get(n);if(a!==void 0)for(let[n,{source:o,score:c}]of W(a.map(t=>e[t]),s.map(e=>t[e]),r))i.set(s[n],{source:a[o],score:c})}return i}function Be(e,t,{renames:i=!0,renamesByPath:a=!0,renameLimit:o=je,renameGroup:s=null,paths:c=`tree`,lines:l=!0,horizon:u,whitespace:d,ignoreCase:f}={}){let p=Me(i);Ne({renamesByPath:a,renameLimit:o,renameGroup:s,paths:c,lines:l});let m=n({horizon:u,whitespace:d,ignoreCase:f}),h=c===`keys`,{changes:g,deleted:_,added:v}=Re(N(e,`old`,h),N(t,`new`,h)),y=p===null?new Map:ze(_,v,{minimum:p,limit:o,byPath:a,group:s});for(let[e,t]of v.entries()){let n=y.get(e);g.push(n===void 0?K(`added`,null,t):K(`renamed`,_[n.source],t,Math.trunc(n.score*100/6e4)))}let b=new Set(y.values().map(({source:e})=>e));for(let[e,t]of _.entries())b.has(e)||g.push(K(`deleted`,t,null));return g.sort((e,t)=>G((e.new??e.old).path,(t.new??t.old).path)),(l?g.map(e=>({...e,...r(e.old,e.new,m)})):g).map(Le)}function Y(e,t,n){let r=new Map,o=new Set,s=0;for(let a of e){let e=i(n,a);e===null||!t.has(e)||(r.set(a,e),o.add(e),e!==a&&s++)}for(let n of e)r.has(n)||!t.has(n)||o.has(n)||(r.set(n,n),o.add(n));let c=r.size;for(let s of e){if(r.has(s))continue;let e=i(n,s)??a(n,s);for(;t.has(e)||o.has(e);)e=`../${e}`;r.set(s,e),o.add(e)}return{paths:r,paired:c,moved:s}}function Ve(e,t){let n=new Set(e),r=new Set(t),i=(e,t)=>{let n=new Map;for(let r of e)for(let e=r.indexOf(`/`);e!==-1;e=r.indexOf(`/`,e+1))t.has(r.slice(e+1))&&n.set(r.slice(0,e+1),(n.get(r.slice(0,e+1))??0)+1);let r=null,i=!1;for(let[e,t]of n)t>(n.get(r)??0)?[r,i]=[e,!1]:t===n.get(r)&&(i=!0);return i?null:r},a=Y(n,r,null).paired,o=[[{base:``,other:i(r,n)},n],[{base:i(n,r),other:``},r]].filter(([e])=>e.base!==null&&e.other!==null).map(([e,t])=>({root:e,side:t,...Y(n,r,e)})).filter(({side:e,paired:t,moved:n})=>t>a&&n*2>=e.size);return o.length===2&&o[0].paired===o[1].paired?null:o.toSorted((e,t)=>t.paired-e.paired)[0]?.root??null}function X(e,t){let n=[...e],r=new Set(t),i=Ve(n,r);return{root:i,paths:Y(n,r,i).paths}}function He(e,t,n){if(!e&&!t)return null;let r=Map.groupBy([...e??[]],([,e])=>e),i=new Map([...r].map(([e,t])=>[e,o(n,e,t.map(([t])=>t.slice(e.length+1)))]));return new Map([...[...e??[]].map(([e,t])=>[n.paths.get(e)??e,i.get(t)]),...t??[]])}function Ue(e,t,n=new Map,r=new Map,i=null){let a=e=>{let t=n.get(e)??r.get(e);return t===void 0?[...new Set([e,Xe(i,e)??e])]:[t]},o=[];for(let n of e.values()){let e=a(n.parent).map(e=>t.get(c(e,n.specifier,n.conditions,n.platform))).find(Boolean);if(e&&!a(n.target).includes(e.target)){let{target:t,...i}=e;o.push({...i,baseTarget:r.get(n.target)??n.target,otherTarget:t})}}return o.sort((e,t)=>e.key.localeCompare(t.key)),{changed:o,totalChanges:o.length}}function Z(e){return p(e)??0}function Q(e,t){return e===t||e?.format===`base64`&&t?.format===`base64`&&e.data===t.data||e?.format===`digest`&&t?.format===`digest`&&e.digest===t.digest}function We(e){if(e?.kind!==`stasis`||!e.bundle)return null;let{formats:t,executable:n,entries:r}=e.bundle;return e=>({format:t?.get(e),executable:n?.has(e)??!1,entry:r?.has(e)??!1})}function Ge(e,t){return!e||!t?[]:[`format`,`executable`,`entry`].filter(n=>e[n]!==t[n]).map(n=>({field:n,from:e[n],to:t[n]}))}function Ke(e){return(t,n)=>Math.abs(n.delta)-Math.abs(t.delta)||t[e].localeCompare(n[e])}function $(e){return(t,n)=>n.bytes-t.bytes||t[e].localeCompare(n[e])}function qe(e,t){return typeof e==`string`?`\0text\0${e.toWellFormed()}`:e?.format===`base64`?`\0base64\0${e.data}`:e?.format===`digest`?`\0digest\0${e.digest}`:`\0none\0${t}`}var Je=250;function Ye(e,t,n,r,i){let a=(e,t,n)=>e.filter(({path:e})=>e!==``&&e.isWellFormed()).map(({path:e},r)=>({name:e,data:qe(t.get(e),`${n}${r}`)})),o={paths:`keys`,renameGroup:i,renameLimit:Je,lines:!1},s=Be(a(e,n,`a`),a(t,r,`b`),o);return new Map(s.filter(({status:e})=>e===`renamed`).map(e=>[e.old.path,e.new.path]))}function Xe(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function Ze(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function Qe(e,t,n,r=X(e.keys(),t.keys()),i=[]){let{root:a,paths:o}=r,s=new Map([...o].map(([e,t])=>[t,e]));e=new Map([...e].map(([e,t])=>[o.get(e),t]));let c=e=>s.get(e)===e?{}:{basePath:s.get(e)},l=(e,t)=>{let n=Ge(i[0]?.(e),i[1]?.(t));return n.length>0?{meta:n}:{}},u=[],d=[],f=[],p=0,m=0,h=0,g=0,_=0,v=0,y=new Map,b=e=>{let t=n(e),r=y.get(t);return r||(r=Ze(),y.set(t,r)),r},x=new Set([...e.keys(),...t.keys()]);for(let n of x){let r=e.has(n),i=t.has(n),a=b(n);if(r&&i){let r=e.get(n),i=t.get(n),o=Q(r,i),u=l(s.get(n),n),d=Z(r),h=o?d:Z(i);if(p+=d,m+=h,a.baseBytes+=d,a.otherBytes+=h,o&&!u.meta)v++;else{let e=h-d;f.push({path:n,...c(n),baseBytes:d,otherBytes:h,delta:e,...u,...o?{modified:!1}:{}}),_+=e,a.changedFiles++}}else if(r){let t=Z(e.get(n));p+=t,h+=t,a.baseBytes+=t,a.onlyBaseFiles++,u.push({path:n,...c(n),bytes:t})}else{let e=Z(t.get(n));m+=e,g+=e,a.otherBytes+=e,a.onlyOtherFiles++,d.push({path:n,bytes:e})}}let S=Ye(u,d,e,t,n);if(S.size>0){let n=new Set(S.values());for(let[n,r]of S){let i=e.get(n),a=t.get(r),o=Q(i,a),c=Z(i),u=o?c:Z(a);h-=c,g-=u,f.push({path:r,renamedFrom:n,basePath:s.get(n),baseBytes:c,otherBytes:u,delta:u-c,modified:!o,...l(s.get(n),r)}),_+=u-c;let d=b(n);d.onlyBaseFiles--,d.onlyOtherFiles--,d.changedFiles++}u.splice(0,u.length,...u.filter(e=>!S.has(e.path))),d.splice(0,d.length,...d.filter(e=>!n.has(e.path)))}let C=[],w=[],T=[],E=[];for(let[e,t]of y){let n=t.baseBytes>0||t.onlyBaseFiles>0||t.changedFiles>0,r=t.otherBytes>0||t.onlyOtherFiles>0||t.changedFiles>0,i=t.onlyBaseFiles+t.onlyOtherFiles+t.changedFiles;n&&!r?C.push({pkg:e,bytes:t.baseBytes}):r&&!n?w.push({pkg:e,bytes:t.otherBytes}):i>0||t.baseBytes!==t.otherBytes?T.push({pkg:e,baseBytes:t.baseBytes,otherBytes:t.otherBytes,delta:t.otherBytes-t.baseBytes}):E.push({pkg:e,bytes:t.baseBytes})}return u.sort($(`path`)),d.sort($(`path`)),f.sort(Ke(`path`)),C.sort($(`pkg`)),w.sort($(`pkg`)),T.sort(Ke(`pkg`)),{totals:{baseFiles:e.size,baseBytes:p,otherFiles:t.size,otherBytes:m,onlyBaseFiles:u.length,onlyBaseBytes:h,onlyOtherFiles:d.length,onlyOtherBytes:g,changedFiles:f.length,renamedFiles:S.size,changedDelta:_,unchangedFiles:v,fileDelta:t.size-e.size,byteDelta:m-p,identical:u.length===0&&d.length===0&&f.length===0},files:{onlyBase:u,onlyOther:d,changed:f,root:a,basePaths:o},packages:{onlyBase:C,onlyOther:w,changed:T,unchanged:E}}}function $e(e,t,n=null){let[r,i]=[e,t],a=s(r,n),o=s(i,n),c=X(a.keys(),o.keys()),u=He(m(r),m(i),c),p=Qe(a,o,e=>_(e,{packageDir:u?.get(e)}),c,[We(r),We(i)]),v=g(r),y=g(i),b=(e,t)=>{let n=0;for(let r of t)n+=e.get(r)??0;return n};Object.assign(p.totals,{baseLines:b(v,a.keys()),otherLines:b(y,o.keys())});for(let e of p.files.onlyBase)e.lines=v.get(e.basePath??e.path)??0;for(let e of p.files.onlyOther)e.lines=y.get(e.path)??0;for(let e of p.files.changed)Object.assign(e,{baseLines:v.get(e.basePath??e.path)??0,otherLines:y.get(e.path)??0});p.resolutions=Ue(l(r,n),l(i,n),new Map(p.files.changed.filter(e=>e.renamedFrom!=null).map(e=>[e.basePath,e.path])),p.files.basePaths,p.files.root);let x=e=>_(``,{packageDir:e}),S=h(r,n?a.keys():null,x),C=h(i,n?o.keys():null,x);return p.versionUpdates=f(S,C),p.packageRows=d(p.packages,S,C),p.scope=n??``,p}export{$e as prepareComparison};
1
+ import{a as e}from"./chunk-GO7FT4OD.js";import{c as t,d as n,e as r,h as i,i as a,j as o,m as s,n as c,o as l}from"./chunk-G24A42V6.js";import{i as u}from"./chunk-4HI2MSAV.js";import"./chunk-PXK7EU4V.js";import{a as d,c as f}from"./chunk-JCIIBLKR.js";import{l as p,p as m,q as h,u as g}from"./chunk-JKGQ3O7O.js";import{b as _}from"./chunk-IYPY47MC.js";import"./chunk-SXV2T5C4.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function v(e){if(typeof e!=`string`)throw TypeError(`a text must be a string, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a text must be a well-formed string`);return{proven:!1,reason:`unsupported`,at:null}}var y=e=>e.subarray(0,8e3).includes(0),b=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,x=e=>Uint8Array.from({length:256},(t,n)=>Number(n===10||e.includes(String.fromCodePoint(n)))),S=x(``),C=x(`,;={}`);function w(e,t=S){let n=!y(e),r=new Map,i=(e,t)=>r.set(e,(r.get(e)??0)+t),a=0,o=0,s=0;for(let r=0;r<e.length;r++){let c=e[r];if(n&&c===13&&e[r+1]===10)continue;let l=a;a=(a<<7^o>>>25)+c>>>0,o=(o<<7^l>>>25)>>>0,!(++s<64&&t[c]===0)&&(i(b(a,o),s),s=0,a=0,o=0)}s>0&&i(b(a,o),s);let c=Uint32Array.from(r.keys()).sort();return{hashes:c,bytes:Float64Array.from(c,e=>r.get(e)),total:r.values().reduce((e,t)=>e+t,0)}}function T(e,t){let n=0;for(let r=0,i=0;r<e.hashes.length&&i<t.hashes.length;)e.hashes[r]<t.hashes[i]?r++:e.hashes[r]>t.hashes[i]?i++:n+=Math.min(e.bytes[r++],t.bytes[i++]);return n}function E(e,t,n){let r=0,i=e.total,a=t.total;for(let o=0,s=0;o<e.hashes.length&&s<t.hashes.length;)if(e.hashes[o]<t.hashes[s]?i-=e.bytes[o++]:(e.hashes[o]>t.hashes[s]||(r+=Math.min(e.bytes[o],t.bytes[s]),i-=e.bytes[o++]),a-=t.bytes[s++]),(r+Math.min(i,a))*6e4<n)return 0;return r}function ee(e,t,n,r,i=!1){if(e===null||t===null||t.length===0)return 0;let a=Math.abs(e.length-t.length),o=Math.max(e.length,t.length);if(o*(6e4-n)<a*6e4)return 0;let s=r(e),c=r(t),l=i?E(s,c,n*o):T(s,c);return Math.trunc(l*6e4/o)}var D=/^[\w-]{6,}$/u,O=/[\dA-Z]/u,te=/^(?:\.[\w-]+)+$/u,ne=/^[\w-]{8,32}$/u;function k(e){let t=[];for(let n=e.length-1;n>0;n--){if(e[n]!==`-`&&e[n]!==`.`)continue;let r=e.indexOf(`.`,n+1),i=e.slice(r),a=e.slice(n+1,r);r!==-1&&ne.test(a)&&te.test(i)&&/[A-Za-z]/u.test(a)&&O.test(a)&&t.push([e.slice(0,n),a,i])}return t}var re=e=>e.replaceAll(/\d/gu,`0`).replaceAll(/[a-z]/gu,`a`).replaceAll(/[A-Z]/gu,`A`);function ie(e,t){let n=k(t);for(let[t,r,i]of k(e)){let e=n.find(e=>e[2]===i);if(e&&e[1]!==r)return e[0]===t&&re(e[1])!==re(r)}return!1}function ae(e){let t=e.lastIndexOf(`/`),n=e.slice(t+1),r=n.lastIndexOf(`.`),i=r>0?n.slice(r):``;return{name:n,key:`${e.slice(0,t+1)}\0${i}\0${n.length}`}}function oe(e,t){let n=e.length,r=0;for(;r<e.length&&e[r]===t[r];)r++;for(;n>r&&e[n-1]===t[n-1];)n--;for(;r>0&&!`-._`.includes(e[r-1]);)r--;for(;n<e.length&&e[n]!==`.`;)n++;let i=e.slice(r,n),a=t.slice(r,n);return r>0&&D.test(i)&&D.test(a)&&(O.test(i)||O.test(a))}function se({sources:e,dests:t,pairs:n,used:r,record:i,punctuatedScoreOf:a},{remaining:o,open:s},c,l){let u=(e,t)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>[t,ae(e[t].path)])),d=u(t,s),f=u(e,o),p=Map.groupBy(f.keys(),e=>f.get(e).key),m=Map.groupBy(d.keys(),e=>d.get(e).key),h=[];for(let[e,t]of m){let n=p.get(e)??[];for(let e of t)for(let t of n)oe(f.get(t).name,d.get(e).name)&&h.push({s:t,d:e})}let g=Map.groupBy(h,({d:e})=>e),_=Map.groupBy(h,({s:e})=>e),v=[];for(let{s:e,d:t}of h){let n=_.get(e).length===1&&g.get(t).length===1&&ie(f.get(e).name,d.get(t).name),r=a(e,t,n?0:c);(n||r>=c)&&v.push({s:e,d:t,score:r})}let y=[],b=new Set,x=new Set;for(let e of v.sort((e,t)=>t.score-e.score))n.has(e.d)||r.has(e.s)||(x.has(e.s)||b.has(e.d)||l(e)?(y.push(e),x.add(e.s),b.add(e.d)):i(e.d,e.s,e.score));return y}function ce(e,t){let n=e.length;if(n!==t.length)return!1;let r=0;if(n>=32&&(e.byteOffset&3)==(t.byteOffset&3)){for(let n=4-(e.byteOffset&3)&3;r<n;r++)if(e[r]!==t[r])return!1;let i=n-r>>>2,a=new Int32Array(e.buffer,e.byteOffset+r,i),o=new Int32Array(t.buffer,t.byteOffset+r,i);for(let e=0;e<i;e++)if(a[e]!==o[e])return!1;r+=i*4}for(;r<n;r++)if(e[r]!==t[r])return!1;return!0}var A=class extends Error{constructor(e,t,n){let r=n===void 0?``:` in the ${n} tree`;super(t===void 0?e:`${e}: ${JSON.stringify(t)}${r}`),this.name=`CompareError`,this.path=t,this.tree=n}},le=new Set([`file`,`contiguous-file`]),ue=new Set([`fifo`,`character-device`,`block-device`]),de=/(?:^|\/)\.{0,2}(?:\/|$)/u;function fe(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function pe(e,t,n,r){if(typeof e!=`string`)throw TypeError(`an entry's name must be a string, not ${typeof e}`);if(e!==`.`||t!==`directory`){if(r?e===``:de.test(e))throw new A(r?`a name must not be empty`:"a name must be a relative path with no empty, `.` or `..` segment",e,n);if(!e.isWellFormed())throw new A(`a name must be well-formed Unicode`,e,n)}}function me(e,t,n){if(typeof e!=`string`||e===``)throw new A(`a link must name its target`,t,n);if(!e.isWellFormed())throw new A(`a link target must be well-formed Unicode`,t,n);return e}function he(e){if(e===void 0)return new Uint8Array;if(e instanceof Uint8Array)return e;if(typeof e!=`string`)throw TypeError(`a file's data must be a string or a Uint8Array, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a file's text must be well-formed Unicode`);return e}var j=e=>typeof e==`string`?u(e):e;function ge(e,t,n){if(typeof e!=`object`||!e)throw TypeError(`an entry must be an object, not ${e===null?`null`:typeof e}`);let{name:r,type:i=`file`,mode:a,linkname:o,data:s}=e;if(pe(r,i,t,n),a!==void 0&&fe(a),le.has(i))return{path:r,type:`file`,mode:a??420,data:he(s)};if(i===`symlink`||i===`hardlink`)return{path:r,type:i,target:me(o,r,t)};if(i===`directory`)return{path:r,type:i};throw ue.has(i)?new A(`a ${i} is neither a file nor a link`,r,t):TypeError(`${JSON.stringify(i)} is not an entry type`)}function M(e,t){return e.type===t.type?e.type===`symlink`?e.target===t.target:e.data===t.data?!0:typeof e.data==`string`&&typeof t.data==`string`?!1:ce(j(e.data),j(t.data)):!1}function _e(e,t,n){let r=new Set([e.path]),i=t.get(e.target);for(;i?.type===`hardlink`;){if(r.has(i.path))throw new A(`a hard link leads back to itself`,e.path,n);r.add(i.path),i=t.get(i.target)}if(i===void 0||i.type===`directory`)throw new A(`a hard link must name a file or a link in the tree`,e.path,n);return{...i,path:e.path}}function N(e,t,n){let r=new Map;for(let i of e){let e=ge(i,t,n);if(e.type!==`directory`||e.path!==`.`){if(r.has(e.path))throw new A(`a name is given twice`,e.path,t);r.set(e.path,e)}}let i=new Map;for(let[e,a]of r){for(let i=n?-1:e.lastIndexOf(`/`);i>0;i=e.lastIndexOf(`/`,i-1)){let n=r.get(e.slice(0,i));if(n!==void 0&&n.type!==`directory`)throw new A(`a path lies under a ${n.type===`symlink`?`link`:`file`}`,e,t)}a.type===`hardlink`?i.set(e,_e(a,r,t)):a.type!==`directory`&&i.set(e,a)}return i}var ve=100,ye=4,P=e=>e.slice(e.lastIndexOf(`/`)+1);function F(t,n){if(t.type===`symlink`)return`l${t.target}`;let r=n(t);return`f${r.length}:${e(r)}`}function be({sources:e,dests:t,sourceNames:n,destNames:r,used:i,record:a,bytes:o}){let s=Map.groupBy(e.keys(),t=>F(e[t],o));for(let c=0;c<t.length;c++){let l=-1,u=ve;for(let a of s.get(F(t[c],o))??[])if(!i.has(a)&&M(e[a],t[c])&&((l===-1||n[a]===r[c])&&(l=a),n[a]===r[c]||--u===0))break;l!==-1&&a(c,l,6e4)}}var xe=new Map([[`.ts`,`.js`],[`.mts`,`.mjs`],[`.cts`,`.cjs`],[`.tsx`,`.jsx`]]),Se=new Map([...[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.mts`,`.cts`,`.tsx`].map(e=>[e,`script`]),...[`.css`,`.scss`,`.sass`,`.less`].map(e=>[e,`style`])]);function I(e){let t=e.split(`/`),n=t.pop(),r=n.lastIndexOf(`.`);return r>0?{dirs:t,stem:n.slice(0,r),extension:n.slice(r)}:{dirs:t,stem:n,extension:``}}function L(e){let{dirs:t,stem:n,extension:r}=I(e);return JSON.stringify([t.map(e=>e===`lib`||e===`src`?null:e),n,xe.get(r)??r])}function Ce(e){let{dirs:t,stem:n,extension:r}=I(e),i=[n,Se.get(r)??r],a=t.lastIndexOf(`node_modules`),o=a===-1?0:a+(t[a+1]?.startsWith(`@`)?3:2),s=[JSON.stringify([...i,t])];for(let e=o;e<t.length;e++)s.push(JSON.stringify([...i,t.toSpliced(e,1,null)]));return s}var R=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function z({pairs:e,used:t,scoreOf:n},{remaining:r,open:i},{s:a,d:o,score:s},c){let l=R(s,c);return i.some(t=>t!==o&&!e.has(t)&&n(a,t,l)>=l)||r.some(e=>e!==a&&!t.has(e)&&n(e,o,l)>=l)}function we(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=Map.groupBy(t.remaining.filter(e=>i[e].type===`file`),e=>L(i[e].path)),d=t.open.filter(e=>a[e].type===`file`).flatMap(e=>(u.get(L(a[e].path))??[]).map(t=>({s:t,d:e,score:l(t,e,0)})));for(let i of d.sort((e,t)=>t.score-e.score))!o.has(i.d)&&!s.has(i.s)&&!(n&&z(e,t,i,r))&&c(i.d,i.s,i.score)}function Te(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=new Map,d=(e,t,n)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>{let r=Ce(e[t].path);for(let e of r)(u.get(e)??u.set(e,{sources:[],dests:[]}).get(e))[n].push(t);return[t,r]})),f=d(a,t.open.filter(e=>!o.has(e)),`dests`),p=d(i,t.remaining.filter(e=>!s.has(e)),`sources`),m=(e,t)=>{let n=new Set(e.flatMap(e=>u.get(e)[t]));return n.size===1?[...n][0]:-1};for(let[i,a]of p){let o=m(a,`dests`);if(o===-1||m(f.get(o),`sources`)!==i)continue;let s={s:i,d:o,score:l(i,o,0)};n&&z(e,t,s,r)||c(o,i,s.score)}}function Ee(e,t,n){let r=H(e),i=t<6e4&&r.remaining.length*r.open.length<=n*n;we(e,r,i,t),Te(e,r,i,t)}function B(e,t){let n=new Map;for(let r of t)n.set(e[r],n.has(e[r])?-1:r);return n}function De({sourceNames:e,destNames:t,record:n,scoreOf:r},{remaining:i,open:a},o){let s=B(t,a),c=B(e,i);for(let t of i){let i=s.get(e[t]);if(i===void 0||i===-1||c.get(e[t])===-1)continue;let a=r(t,i,o);a>=o&&n(i,t,a)}}var V=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function Oe(e,t){if(e.length<ye){e.push(t);return}let n=0;for(let t=1;t<e.length;t++)V(e[t],e[n])>0&&(n=t);V(e[n],t)>0&&(e[n]=t)}function ke({sourceNames:e,destNames:t,pairs:n,used:r,record:i,scoreOf:a},{remaining:o,open:s},c,l){let u=[];for(let n of s){let r=[];for(let i of o)Oe(r,{score:a(i,n,c),nameScore:+(e[i]===t[n]),dst:n,src:i});u.push(...r)}let d=0,f=e=>{for(;d<l.length&&R(l[d].score,c)>e;d++){let{s:e,d:t,score:a}=l[d];!n.has(t)&&!r.has(e)&&i(t,e,a)}};for(let{dst:e,src:t,score:a}of u.sort(V)){if(a<c)break;f(a),!n.has(e)&&!r.has(t)&&i(e,t,a)}f(-1/0)}var H=({sources:e,dests:t,pairs:n,used:r})=>({remaining:e.keys().filter(e=>!r.has(e)).toArray(),open:t.keys().filter(e=>!n.has(e)).toArray()}),U=e=>e+Math.trunc(.5*(6e4-e));function W(e,t,{minimum:n,limit:r,byPath:i}){let a=new Map,o=new Set;if(e.length===0||t.length===0)return a;let s=new Map,c=new Map,l=new Map,u=e=>e.type===`file`?c.get(e)??c.set(e,j(e.data)).get(e):null,d=e=>s.get(e)??s.set(e,w(e)).get(e),f=e=>l.get(e)??l.set(e,w(e,C)).get(e),p={sources:e,dests:t,pairs:a,used:o,sourceNames:e.map(e=>P(e.path)),destNames:t.map(e=>P(e.path)),record(e,t,n){a.set(e,{source:t,score:n}),o.add(t)},bytes:u,scoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,d),punctuatedScoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,f,!0)};if(be(p),i&&Ee(p,n,r),n>=6e4)return a;De(p,H(p),U(n));let m=H(p);if(m.remaining.length*m.open.length>r*r)return a;let h=i?se(p,m,U(n),e=>z(p,m,e,n)):[];return ke(p,H(p),n,h),a}var Ae=50,je=1e3;function G(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.codePointAt(r)-t.codePointAt(r);return e.length-t.length}function Me(e){if(e===!1)return null;let t=e===!0?Ae:e;if(typeof t!=`number`)throw TypeError(`renames must be a boolean or a percentage, not ${typeof e}`);if(!(t>0&&t<=100))throw RangeError(`renames must be a percentage above 0 and at most 100, not ${e}`);return Math.max(1,Math.trunc(6e4*t/100))}function Ne({renamesByPath:e,renameLimit:t,renameGroup:n,paths:r,lines:i}){if(typeof e!=`boolean`)throw TypeError(`renamesByPath must be a boolean, not ${typeof e}`);if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw RangeError(`renameLimit must be a whole number or Infinity, not ${t}`);if(n!==null&&typeof n!=`function`)throw TypeError(`renameGroup must be a function, not ${typeof n}`);if(r!==`tree`&&r!==`keys`)throw RangeError(`paths must be 'tree' or 'keys', not ${r}`);if(typeof i!=`boolean`)throw TypeError(`lines must be a boolean, not ${typeof i}`)}var Pe=(e,t)=>M(e,t)&&(e.type!==`file`||e.mode===t.mode),K=(e,t,n,r=null)=>({status:e,old:t,new:n,similarity:r}),Fe=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,q=e=>e.endsWith(`.mts`)?`module`:e.endsWith(`.cts`)?`commonjs`:null,Ie=/^export\s*\{\s*\}\s*;?$/u;function J(e){if(e===null)return{proven:!0,runtime:``,loads:!1};let n=t(e);try{return n===void 0?{proven:!1}:v(n)}catch{return{proven:!1}}}function Le(e){if(![e.old,e.new].filter(e=>e!==null).every(e=>e.type===`file`&&Fe.test(e.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let t=J(e.new),n=J(e.old);return!n.proven||!t.proven||n.runtime!==t.runtime&&!(e.old===null&&Ie.test(t.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&q(e.old.path)!==q(e.new.path)?e:{...e,typeOnly:!0}}function Re(e,t){let n=[],r=[],i=[];for(let[n,a]of e){let e=t.get(n);e===void 0?i.push(a):e.type===a.type?Pe(a,e)||r.push(K(`modified`,a,e)):r.push(K(`type-changed`,a,e))}for(let[r,i]of t)e.has(r)||n.push(i);return i.sort((e,t)=>G(e.path,t.path)),n.sort((e,t)=>G(e.path,t.path)),{changes:r,deleted:i,added:n}}function ze(e,t,{group:n,...r}){if(n===null)return W(e,t,r);let i=new Map,a=e=>Map.groupBy(e.keys(),t=>n(e[t].path)),o=a(e);for(let[n,s]of a(t)){let a=o.get(n);if(a!==void 0)for(let[n,{source:o,score:c}]of W(a.map(t=>e[t]),s.map(e=>t[e]),r))i.set(s[n],{source:a[o],score:c})}return i}function Be(e,t,{renames:i=!0,renamesByPath:a=!0,renameLimit:o=je,renameGroup:s=null,paths:c=`tree`,lines:l=!0,horizon:u,whitespace:d,ignoreCase:f}={}){let p=Me(i);Ne({renamesByPath:a,renameLimit:o,renameGroup:s,paths:c,lines:l});let m=n({horizon:u,whitespace:d,ignoreCase:f}),h=c===`keys`,{changes:g,deleted:_,added:v}=Re(N(e,`old`,h),N(t,`new`,h)),y=p===null?new Map:ze(_,v,{minimum:p,limit:o,byPath:a,group:s});for(let[e,t]of v.entries()){let n=y.get(e);g.push(n===void 0?K(`added`,null,t):K(`renamed`,_[n.source],t,Math.trunc(n.score*100/6e4)))}let b=new Set(y.values().map(({source:e})=>e));for(let[e,t]of _.entries())b.has(e)||g.push(K(`deleted`,t,null));return g.sort((e,t)=>G((e.new??e.old).path,(t.new??t.old).path)),(l?g.map(e=>({...e,...r(e.old,e.new,m)})):g).map(Le)}function Y(e,t,n){let r=new Map,o=new Set,s=0;for(let a of e){let e=i(n,a);e===null||!t.has(e)||(r.set(a,e),o.add(e),e!==a&&s++)}for(let n of e)r.has(n)||!t.has(n)||o.has(n)||(r.set(n,n),o.add(n));let c=r.size;for(let s of e){if(r.has(s))continue;let e=i(n,s)??a(n,s);for(;t.has(e)||o.has(e);)e=`../${e}`;r.set(s,e),o.add(e)}return{paths:r,paired:c,moved:s}}function Ve(e,t){let n=new Set(e),r=new Set(t),i=(e,t)=>{let n=new Map;for(let r of e)for(let e=r.indexOf(`/`);e!==-1;e=r.indexOf(`/`,e+1))t.has(r.slice(e+1))&&n.set(r.slice(0,e+1),(n.get(r.slice(0,e+1))??0)+1);let r=null,i=!1;for(let[e,t]of n)t>(n.get(r)??0)?[r,i]=[e,!1]:t===n.get(r)&&(i=!0);return i?null:r},a=Y(n,r,null).paired,o=[[{base:``,other:i(r,n)},n],[{base:i(n,r),other:``},r]].filter(([e])=>e.base!==null&&e.other!==null).map(([e,t])=>({root:e,side:t,...Y(n,r,e)})).filter(({side:e,paired:t,moved:n})=>t>a&&n*2>=e.size);return o.length===2&&o[0].paired===o[1].paired?null:o.toSorted((e,t)=>t.paired-e.paired)[0]?.root??null}function X(e,t){let n=[...e],r=new Set(t),i=Ve(n,r);return{root:i,paths:Y(n,r,i).paths}}function He(e,t,n){if(!e&&!t)return null;let r=Map.groupBy([...e??[]],([,e])=>e),i=new Map([...r].map(([e,t])=>[e,o(n,e,t.map(([t])=>t.slice(e.length+1)))]));return new Map([...[...e??[]].map(([e,t])=>[n.paths.get(e)??e,i.get(t)]),...t??[]])}function Ue(e,t,n=new Map,r=new Map,i=null){let a=e=>{let t=n.get(e)??r.get(e);return t===void 0?[...new Set([e,Xe(i,e)??e])]:[t]},o=[];for(let n of e.values()){let e=a(n.parent).map(e=>t.get(c(e,n.specifier,n.conditions,n.platform))).find(Boolean);if(e&&!a(n.target).includes(e.target)){let{target:t,...i}=e;o.push({...i,baseTarget:r.get(n.target)??n.target,otherTarget:t})}}return o.sort((e,t)=>e.key.localeCompare(t.key)),{changed:o,totalChanges:o.length}}function Z(e){return p(e)??0}function Q(e,t){return e===t||e?.format===`base64`&&t?.format===`base64`&&e.data===t.data||e?.format===`digest`&&t?.format===`digest`&&e.digest===t.digest}function We(e){if(e?.kind!==`stasis`||!e.bundle)return null;let{formats:t,executable:n,entries:r}=e.bundle;return e=>({format:t?.get(e),executable:n?.has(e)??!1,entry:r?.has(e)??!1})}function Ge(e,t){return!e||!t?[]:[`format`,`executable`,`entry`].filter(n=>e[n]!==t[n]).map(n=>({field:n,from:e[n],to:t[n]}))}function Ke(e){return(t,n)=>Math.abs(n.delta)-Math.abs(t.delta)||t[e].localeCompare(n[e])}function $(e){return(t,n)=>n.bytes-t.bytes||t[e].localeCompare(n[e])}function qe(e,t){return typeof e==`string`?`\0text\0${e.toWellFormed()}`:e?.format===`base64`?`\0base64\0${e.data}`:e?.format===`digest`?`\0digest\0${e.digest}`:`\0none\0${t}`}var Je=250;function Ye(e,t,n,r,i){let a=(e,t,n)=>e.filter(({path:e})=>e!==``&&e.isWellFormed()).map(({path:e},r)=>({name:e,data:qe(t.get(e),`${n}${r}`)})),o={paths:`keys`,renameGroup:i,renameLimit:Je,lines:!1},s=Be(a(e,n,`a`),a(t,r,`b`),o);return new Map(s.filter(({status:e})=>e===`renamed`).map(e=>[e.old.path,e.new.path]))}function Xe(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function Ze(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function Qe(e,t,n,r=X(e.keys(),t.keys()),i=[]){let{root:a,paths:o}=r,s=new Map([...o].map(([e,t])=>[t,e]));e=new Map([...e].map(([e,t])=>[o.get(e),t]));let c=e=>s.get(e)===e?{}:{basePath:s.get(e)},l=(e,t)=>{let n=Ge(i[0]?.(e),i[1]?.(t));return n.length>0?{meta:n}:{}},u=[],d=[],f=[],p=0,m=0,h=0,g=0,_=0,v=0,y=new Map,b=e=>{let t=n(e),r=y.get(t);return r||(r=Ze(),y.set(t,r)),r},x=new Set([...e.keys(),...t.keys()]);for(let n of x){let r=e.has(n),i=t.has(n),a=b(n);if(r&&i){let r=e.get(n),i=t.get(n),o=Q(r,i),u=l(s.get(n),n),d=Z(r),h=o?d:Z(i);if(p+=d,m+=h,a.baseBytes+=d,a.otherBytes+=h,o&&!u.meta)v++;else{let e=h-d;f.push({path:n,...c(n),baseBytes:d,otherBytes:h,delta:e,...u,...o?{modified:!1}:{}}),_+=e,a.changedFiles++}}else if(r){let t=Z(e.get(n));p+=t,h+=t,a.baseBytes+=t,a.onlyBaseFiles++,u.push({path:n,...c(n),bytes:t})}else{let e=Z(t.get(n));m+=e,g+=e,a.otherBytes+=e,a.onlyOtherFiles++,d.push({path:n,bytes:e})}}let S=Ye(u,d,e,t,n);if(S.size>0){let n=new Set(S.values());for(let[n,r]of S){let i=e.get(n),a=t.get(r),o=Q(i,a),c=Z(i),u=o?c:Z(a);h-=c,g-=u,f.push({path:r,renamedFrom:n,basePath:s.get(n),baseBytes:c,otherBytes:u,delta:u-c,modified:!o,...l(s.get(n),r)}),_+=u-c;let d=b(n);d.onlyBaseFiles--,d.onlyOtherFiles--,d.changedFiles++}u.splice(0,u.length,...u.filter(e=>!S.has(e.path))),d.splice(0,d.length,...d.filter(e=>!n.has(e.path)))}let C=[],w=[],T=[],E=[];for(let[e,t]of y){let n=t.baseBytes>0||t.onlyBaseFiles>0||t.changedFiles>0,r=t.otherBytes>0||t.onlyOtherFiles>0||t.changedFiles>0,i=t.onlyBaseFiles+t.onlyOtherFiles+t.changedFiles;n&&!r?C.push({pkg:e,bytes:t.baseBytes}):r&&!n?w.push({pkg:e,bytes:t.otherBytes}):i>0||t.baseBytes!==t.otherBytes?T.push({pkg:e,baseBytes:t.baseBytes,otherBytes:t.otherBytes,delta:t.otherBytes-t.baseBytes}):E.push({pkg:e,bytes:t.baseBytes})}return u.sort($(`path`)),d.sort($(`path`)),f.sort(Ke(`path`)),C.sort($(`pkg`)),w.sort($(`pkg`)),T.sort(Ke(`pkg`)),{totals:{baseFiles:e.size,baseBytes:p,otherFiles:t.size,otherBytes:m,onlyBaseFiles:u.length,onlyBaseBytes:h,onlyOtherFiles:d.length,onlyOtherBytes:g,changedFiles:f.length,renamedFiles:S.size,changedDelta:_,unchangedFiles:v,fileDelta:t.size-e.size,byteDelta:m-p,identical:u.length===0&&d.length===0&&f.length===0},files:{onlyBase:u,onlyOther:d,changed:f,root:a,basePaths:o},packages:{onlyBase:C,onlyOther:w,changed:T,unchanged:E}}}function $e(e,t,n=null){let[r,i]=[e,t],a=s(r,n),o=s(i,n),c=X(a.keys(),o.keys()),u=He(m(r),m(i),c),p=Qe(a,o,e=>_(e,{packageDir:u?.get(e)}),c,[We(r),We(i)]),v=g(r),y=g(i),b=(e,t)=>{let n=0;for(let r of t)n+=e.get(r)??0;return n};Object.assign(p.totals,{baseLines:b(v,a.keys()),otherLines:b(y,o.keys())});for(let e of p.files.onlyBase)e.lines=v.get(e.basePath??e.path)??0;for(let e of p.files.onlyOther)e.lines=y.get(e.path)??0;for(let e of p.files.changed)Object.assign(e,{baseLines:v.get(e.basePath??e.path)??0,otherLines:y.get(e.path)??0});p.resolutions=Ue(l(r,n),l(i,n),new Map(p.files.changed.filter(e=>e.renamedFrom!=null).map(e=>[e.basePath,e.path])),p.files.basePaths,p.files.root);let x=e=>_(``,{packageDir:e}),S=h(r,n?a.keys():null,x),C=h(i,n?o.keys():null,x);return p.versionUpdates=f(S,C),p.packageRows=d(p.packages,S,C),p.scope=n??``,p}export{$e as prepareComparison};
@@ -1,3 +1,3 @@
1
- import{a as e}from"./chunk-QB4CBOX2.js";import{a as t,b as n,c as r,f as i,g as a}from"./chunk-6HNXNIQY.js";import{i as o}from"./chunk-BC2UCLFJ.js";import{J as s}from"./chunk-SXV2T5C4.js";import{a as c}from"./chunk-TUII34K2.js";var l=[`dependencies`,`security`],u={dependencies:`Dependencies`,security:`Security`},d=e(),f=Object.freeze(d.models),p=d.defaultModel,m=`x-upload-encryption`,h=1,g=1,_={name:`X25519`},ee=34,v=1048576,y=65536,b=`deepview-managed-upload.v1.content-key`;function x(e,t){let n=new Uint8Array(12);return new DataView(n.buffer).setUint32(7,e),n[11]=+!!t,n}async function S(e,t,n){let r=await crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveKey`]);return await crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:t,info:c(b)},r,{name:`AES-GCM`,length:256},!1,[n])}async function te(e){let t=new Uint8Array(await e.slice(0,y).arrayBuffer());if(t.includes(0))return!1;try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(t,{stream:!0}),!0}catch{return!1}}async function C(e,t,n){let r=await te(e),[i,a]=await Promise.all([crypto.subtle.importKey(`raw`,t,_,!1,[]),crypto.subtle.generateKey(_,!1,[`deriveBits`])]),o=new Uint8Array(ee);o[0]=h,o[1]=r?g:0,o.set(new Uint8Array(await crypto.subtle.exportKey(`raw`,a.publicKey)),2);let s=await S(await crypto.subtle.deriveBits({name:`X25519`,public:i},a.privateKey,256),o,`encrypt`),c=[new Blob([o])],l=new Uint8Array(v),u=0,d=0,f=async e=>{c.push(new Blob([await crypto.subtle.encrypt({name:`AES-GCM`,iv:x(d++,e)},s,l.subarray(0,u))])),u=0},p=(r?e.stream().pipeThrough(new CompressionStream(`gzip`)):e.stream()).getReader();try{for(let e=await p.read();!e.done;e=await p.read()){n?.throwIfAborted();for(let t=0;t<e.value.length;){u===v&&await f(!1);let n=Math.min(v-u,e.value.length-t);l.set(e.value.subarray(t,t+n),u),u+=n,t+=n}}}catch(e){throw await p.cancel(e).catch(()=>{}),e}return await f(!0),new Blob(c)}var w=null,T=0;function E(){return w?.user.role??null}function D(e){if(e!==null&&!n(e))throw TypeError(`Unknown managed preview role: ${e}. Expected ${t.join(`, `)}.`);T++,w=e===null?null:{user:{id:`preview:${e}`,login:e,name:e[0].toUpperCase()+e.slice(1),role:e,avatarUrl:null,lastSeenAt:Date.now(),lastActivityAt:null},csrfToken:null}}function O(e,t){let n=new URL(e,`http://managed-preview.invalid`).pathname,i=(t?.method??`GET`).toUpperCase();if(i===`POST`&&n===`/api/auth/logout`)return Response.json({ok:!0});if(i!==`GET`)throw Error(`Changes are not saved in the managed UI preview`);if(n===`/api/auth/session`)return Response.json(w);if(n===`/api/teams`)return Response.json({teams:[]});if(n.startsWith(`/api/admin/`)&&!r(w.user.role,`manage`)||[`/api/admin/users`,`/api/admin/teams`,`/api/admin/repositories`,`/api/admin/repositories/aliases`,`/api/admin/repositories/risk`].includes(n)&&w.user.role!==`admin`)return Response.json({error:`forbidden`},{status:403});if(n===`/api/admin/repositories/risk`)return new Response(`{"type":"repos","repos":[]}
1
+ import{a as e}from"./chunk-QB4CBOX2.js";import{a as t,b as n,c as r,f as i,g as a}from"./chunk-S6GIXWQW.js";import{i as o}from"./chunk-BC2UCLFJ.js";import{J as s}from"./chunk-SXV2T5C4.js";import{a as c}from"./chunk-TUII34K2.js";var l=[`dependencies`,`security`],u={dependencies:`Dependencies`,security:`Security`},d=e(),f=Object.freeze(d.models),p=d.defaultModel,m=`x-upload-encryption`,h=1,g=1,_={name:`X25519`},ee=34,v=1048576,y=65536,b=`deepview-managed-upload.v1.content-key`;function x(e,t){let n=new Uint8Array(12);return new DataView(n.buffer).setUint32(7,e),n[11]=+!!t,n}async function S(e,t,n){let r=await crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveKey`]);return await crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:t,info:c(b)},r,{name:`AES-GCM`,length:256},!1,[n])}async function te(e){let t=new Uint8Array(await e.slice(0,y).arrayBuffer());if(t.includes(0))return!1;try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(t,{stream:!0}),!0}catch{return!1}}async function C(e,t,n){let r=await te(e),[i,a]=await Promise.all([crypto.subtle.importKey(`raw`,t,_,!1,[]),crypto.subtle.generateKey(_,!1,[`deriveBits`])]),o=new Uint8Array(ee);o[0]=h,o[1]=r?g:0,o.set(new Uint8Array(await crypto.subtle.exportKey(`raw`,a.publicKey)),2);let s=await S(await crypto.subtle.deriveBits({name:`X25519`,public:i},a.privateKey,256),o,`encrypt`),c=[new Blob([o])],l=new Uint8Array(v),u=0,d=0,f=async e=>{c.push(new Blob([await crypto.subtle.encrypt({name:`AES-GCM`,iv:x(d++,e)},s,l.subarray(0,u))])),u=0},p=(r?e.stream().pipeThrough(new CompressionStream(`gzip`)):e.stream()).getReader();try{for(let e=await p.read();!e.done;e=await p.read()){n?.throwIfAborted();for(let t=0;t<e.value.length;){u===v&&await f(!1);let n=Math.min(v-u,e.value.length-t);l.set(e.value.subarray(t,t+n),u),u+=n,t+=n}}}catch(e){throw await p.cancel(e).catch(()=>{}),e}return await f(!0),new Blob(c)}var w=null,T=0;function E(){return w?.user.role??null}function D(e){if(e!==null&&!n(e))throw TypeError(`Unknown managed preview role: ${e}. Expected ${t.join(`, `)}.`);T++,w=e===null?null:{user:{id:`preview:${e}`,login:e,name:e[0].toUpperCase()+e.slice(1),role:e,avatarUrl:null,lastSeenAt:Date.now(),lastActivityAt:null},csrfToken:null}}function O(e,t){let n=new URL(e,`http://managed-preview.invalid`).pathname,i=(t?.method??`GET`).toUpperCase();if(i===`POST`&&n===`/api/auth/logout`)return Response.json({ok:!0});if(i!==`GET`)throw Error(`Changes are not saved in the managed UI preview`);if(n===`/api/auth/session`)return Response.json(w);if(n===`/api/teams`)return Response.json({teams:[]});if(n.startsWith(`/api/admin/`)&&!r(w.user.role,`manage`)||[`/api/admin/users`,`/api/admin/teams`,`/api/admin/repositories`,`/api/admin/repositories/aliases`,`/api/admin/repositories/risk`].includes(n)&&w.user.role!==`admin`)return Response.json({error:`forbidden`},{status:403});if(n===`/api/admin/repositories/risk`)return new Response(`{"type":"repos","repos":[]}
2
2
  {"type":"done"}
3
3
  `,{headers:{"content-type":`application/x-ndjson`}});let a={"/api/admin/users":{users:[w.user]},"/api/admin/teams":{teams:[],users:[w.user],repos:[],permissions:l},"/api/admin/links":{shares:[]},"/api/admin/repositories":{repositories:[],total:0,connectedCount:0,installUrl:null,tokenMissing:!1},"/api/admin/repositories/aliases":{aliases:[],repos:[]},"/api/admin/repositories/resolve":{location:null},"/api/admin/reports":{reports:[],repos:[],maxBytes:26214400},"/api/admin/bundles":{bundles:[],repos:[],maxBytes:209715200},"/api/admin/history":{history:[],total:0,page:1,limit:100,filters:{repos:[],users:[]}},"/api/admin/scan/models":{models:f,defaultModel:p},"/api/admin/scan-results":{bundles:[],results:[]},"/api/auth/profile":{profile:{login:w.user.login,name:w.user.name,githubName:w.user.name,nameAccount:null,avatarAccount:null,accounts:[]}}};return Object.hasOwn(a,n)?Response.json(a[n]):Response.json({error:`not-found`},{status:404})}var k=3145728,A=new Set([`/api/admin/reports`,`/api/admin/bundles`,`/api/admin/deduplication`]);async function j(e,t){let n=await t(`/api/admin/uploads/key`,{credentials:`same-origin`,signal:e.signal});if(n.status===404||n.status===405)return e;if(!n.ok)return n;let r=(await n.json())?.key;if(typeof r!=`string`)throw Error(`The server sent an invalid upload key`);let i=new Headers(e.headers);return i.set(m,`1`),{...e,headers:i,body:await C(e.body,Uint8Array.fromBase64(r,{alphabet:`base64url`}),e.signal)}}async function M(e,t,n){let r=null;if(e!==`/api/admin/deduplication`&&t.body.size>k){let i=await n(`/api/config`,{credentials:`same-origin`,signal:t.signal});if(!i.ok)return i;let a=(await i.json()).managed,o=a?.uploadMaxBytes?.[e.endsWith(`/reports`)?`reports`:`bundles`];if(Number.isSafeInteger(o)&&o>0&&t.body.size>o)return Response.json({error:`too-large`},{status:413});let s=a?.uploadChunkBytes;Number.isSafeInteger(s)&&s>0&&s<=k&&(r=s)}let i=await j(t,n);return i instanceof Response?i:r==null||i.body.size<=k?await n(e,i):await N(e,i,n,r)}async function N(e,t,n,r){let i=t.body,a=crypto.randomUUID(),o=e.endsWith(`/reports`)?`reports`:`bundles`,s=Math.ceil(i.size/r),c=new Headers(t.headers);c.set(`content-type`,`application/octet-stream`);let l=0,u=!1;try{for(let e=0;e<s;e++){l=e+1;let s=await n(`/api/admin/uploads/${o}/${a}/${e}`,{...t,headers:c,body:i.slice(e*r,(e+1)*r)});if(!s.ok)return s}let d=new Headers(t.headers);d.set(`x-upload-id`,a),d.set(`x-upload-parts`,String(s)),d.set(`x-upload-size`,String(i.size));let f=await n(e,{...t,headers:d,body:``});return u=f.ok,f}finally{if(!u&&l>0){let e=new Headers(t.headers);e.set(`x-upload-parts`,String(l)),await n(`/api/admin/uploads/${o}/${a}`,{...t,method:`DELETE`,headers:e,body:void 0,signal:AbortSignal.timeout(1e4)}).catch(()=>{})}}}async function P(e){await e.json().then(e=>e?.error,()=>null)===`view-only`&&globalThis.document?.dispatchEvent(new CustomEvent(`managed-view-only`))}async function F(e,t){if(t?.signal?.throwIfAborted(),w)return O(e,t);let n=T;async function r(e,t){if(n!==T)throw new DOMException(`Managed session changed`,`AbortError`);let r=i();if(r){if(new URL(e,globalThis.location.origin).origin!==globalThis.location.origin)throw Error(`Public workspace requests must be same-origin`);let n=new Headers(t?.headers);n.set(`x-deepview-share`,r.token),t={...t,headers:n,credentials:`omit`,redirect:`error`}}let a=await fetch(e,{...t,cache:`no-store`});if(n!==T)throw new DOMException(`Managed session changed`,`AbortError`);return a.status===403&&![`GET`,`HEAD`].includes((t?.method??`GET`).toUpperCase())&&P(a.clone()),a}return t?.method===`POST`&&A.has(e)&&t.body instanceof Blob?await M(e,t,r):await r(e,t)}var I=new class{constructor(e=()=>{}){this.resources=new Map,this.session=null,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=null,this.generation=0,this.sessionController=new AbortController,this.notify=e}setSession(e){(this.session?.id!==e?.id||this.session?.role!==e?.role)&&this.reset(),this.session=e}reset(){this.generation++,this.sessionController.abort(),this.sessionController=new AbortController,this.invalidate(),this.session=null,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=null}setReportCatalog(e){let t=new Set,n=new Map(e.map(e=>[e.id,JSON.stringify([e.cacheKey??null,e.reports.map(e=>[e.id,e.cacheKey??null,e.visible!==!1]).toSorted(),(e.bundles??[]).map(e=>[e.id,e.filename,e.repoFullName,e.repoDirectory??``]).toSorted()])]));for(let e of new Set([...this.teamCatalog?.keys()??[],...n.keys()]))this.teamCatalog?.get(e)!==n.get(e)&&t.add(`team:${e}`);for(let e of this.resources.keys())if(e.startsWith(`reports:content:team:`)){let[t]=e.slice(21).split(`:`);(!n.has(t)||this.teamCatalog?.get(t)!==n.get(t))&&this.invalidate([e])}this.teamCatalog=n;let r=new Map;for(let t of e)for(let e of t.reports){let n=r.get(e.id)??[];n.push(JSON.stringify([t.id,e.cacheKey??null])),r.set(e.id,n)}let i=new Map([...r].map(([e,t])=>[e,JSON.stringify(t.toSorted())])),a=this.reportCatalog;this.reportCatalog=i;let o=new Set(t);for(let e of new Set([...a?.keys()??[],...i.keys()]))a?.get(e)!==i.get(e)&&o.add(e);for(let e of this.resources.keys()){if(!e.startsWith(`reports:content:`)||e.startsWith(`reports:content:team:`))continue;let t=e.slice(16);(!i.has(t)||o.has(t))&&(this.invalidate([e]),o.add(t))}let s=new Map;for(let t of e)for(let e of t.bundles??[]){let n=s.get(e.id)??[];n.push(JSON.stringify([t.id,t.cacheKey??null,e.filename,e.repoFullName,e.repoDirectory??``])),s.set(e.id,n)}let c=!1,l=new Map([...s].map(([e,t])=>[e,JSON.stringify(t.toSorted())]));for(let e of new Set([...this.bundleCatalog?.keys()??[],...l.keys()]))this.bundleCatalog?.get(e)!==l.get(e)&&(c=!0,o.add(`bundle:${e}`),this.invalidate([`bundle-metadata:${e}`]));this.bundleCatalog=l;for(let e of this.resources.keys()){if(!e.startsWith(`report-sources:`)&&!e.startsWith(`finding-history:`))continue;let[,n,r]=e.split(`:`);(n?t.has(`team:${n}`):c||o.has(r))&&this.invalidate([e])}return o}read(e){return this.resources.get(e)?.data}invalidate(e){for(let[t,n]of this.resources)e&&!e.some(e=>t===e||t.startsWith(`${e}:`))||(n.controller?.abort(),this.resources.delete(t))}async mutate(e,t){let n=this.generation,r;try{r=await e()}catch(e){throw n===this.generation&&e?.name!==`AbortError`&&this.notify(`Couldn't save changes: ${e?.message??e}`),e}if(n!==this.generation)throw new DOMException(`Managed session changed`,`AbortError`);return this.invalidate(t),r}async load(e,t,n,{signal:r,apply:i=()=>{},retryInvalidated:a=!1}={}){let o=this.generation;for(;;){r?.throwIfAborted();let s=this.resources.get(e);if(s||(s={},this.resources.set(e,s)),s.data!==void 0&&i(s.data),!s.pending){let e=s.controller=new AbortController;s.pending=(async()=>{try{let t=await n(e.signal);return e.signal.throwIfAborted(),s.data=t,t}catch(n){throw!e.signal.aborted&&n?.name!==`AbortError`&&this.notify(`Couldn't refresh ${t}: ${n?.message??n}`),n}})().finally(()=>{s.pending=null})}try{let t=await s.pending;if(r?.throwIfAborted(),this.resources.get(e)!==s)throw new DOMException(`Managed data changed`,`AbortError`);return i(t),t}catch(t){if(!a||t?.name!==`AbortError`||r?.aborted||o!==this.generation||this.resources.get(e)===s)throw t}}}}(e=>{document.dispatchEvent(new CustomEvent(`managed-notice`,{detail:{message:e}}))});function L(e){I.setSession(e)}function R(e){return I.setReportCatalog(e)}function z(){I.reset()}async function B(e,t=null,n={}){let r;try{r=await F(e,{credentials:`same-origin`,headers:{accept:`application/json`},...n})}catch{return t}if(r.status===401||r.status===403)return null;if(!r.ok)return t;try{return await r.json()}catch{return t}}async function V({fallback:e=null,sent:t}={}){let n=i()||E()!==null?void 0:await t;if(n===null)return null;let r=H(n);if(r!==void 0)return r;let o;try{let t=i(),n=await F(t?a(t):`/api/auth/session`,{credentials:`same-origin`,headers:{accept:`application/json`}});if(n.status===401||n.status===403)return null;if(!n.ok)return e;o=await n.json()}catch{return e}let s=H(o);return s===void 0?e:s}function H(e){let t=e?.user;if(t===null)return null;if(t!==void 0&&typeof t.login==`string`)return{id:t.id,login:t.login,name:typeof t.name==`string`?t.name:null,avatarUrl:typeof t.avatarUrl==`string`?t.avatarUrl:null,role:typeof t.role==`string`?t.role:`none`,csrfToken:typeof e.csrfToken==`string`?e.csrfToken:null,...i()?{publicShare:!0}:{},...typeof e.viewer?.login==`string`?{viewer:{id:e.viewer.id,login:e.viewer.login,name:typeof e.viewer.name==`string`?e.viewer.name:null}}:{},...!i()&&e.dependencyReview===!0?{dependencyReview:!0}:{}}}function U(e){let t=t=>Number.isSafeInteger(e?.[t])&&e[t]>=0;return e?.appMode===!1?{appMode:!1,...t(`appReports`)&&{appReports:e.appReports},...t(`findings`)&&{findings:e.findings}}:e?.appMode===!0&&t(`appFindings`)?{appMode:!0,appFindings:e.appFindings}:null}function W(e){if(typeof e?.sha!=`string`||typeof e.github!=`string`||!Array.isArray(e.tags))return null;let t=e.details,n=e=>typeof e==`string`?e:null,r=e=>Number.isSafeInteger(e)?e:null;return{sha:e.sha,github:e.github,tags:e.tags.filter(e=>typeof e==`string`),details:typeof t?.subject==`string`?{subject:t.subject,authorName:n(t.authorName),authorLogin:n(t.authorLogin),authoredAt:r(t.authoredAt),committedAt:r(t.committedAt)}:null}}async function G({fallback:e=[],signal:t,onRevision:n}={}){let r=i(),o=r?await B(a(r),null,{signal:t}):null,s=r?{teams:o?.team?[o.team]:[]}:await B(`/api/teams`,{teams:e},{signal:t}),c=s?.teams;return Array.isArray(c)?(n?.(typeof s.revision==`string`?s.revision:null),c.filter(e=>e!=null&&typeof e.id==`string`&&typeof e.name==`string`).map(e=>({id:e.id,slug:e.slug,name:e.name,...!r&&e.dependencyReview===!0?{dependencyReview:!0}:{},...e.permissions?{permissions:{dependencies:e.permissions.dependencies===!0,security:e.permissions.security===!0}}:{},...typeof e.cacheKey==`string`?{cacheKey:e.cacheKey}:{},...U(e.app)?{app:U(e.app)}:{},repos:Array.isArray(e.repos)?e.repos.filter(e=>Number.isSafeInteger(e?.repoId)&&e.repoId>0&&typeof e.fullName==`string`).map(e=>({repoId:e.repoId,fullName:e.fullName,path:typeof e.path==`string`&&e.path?e.path:null})):[],reports:Array.isArray(e.reports)?e.reports.filter(e=>e!=null&&typeof e.id==`string`&&typeof e.filename==`string`).map(e=>({id:e.id,slug:e.slug,filename:e.filename,visible:e.visible!==!1,...e.analyzer===null||typeof e.analyzer==`string`?{analyzer:e.analyzer}:{},repoFullName:typeof e.repoFullName==`string`?e.repoFullName:``,repoDirectory:typeof e.repoDirectory==`string`?e.repoDirectory:``,...typeof e.cacheKey==`string`?{cacheKey:e.cacheKey}:{}})):[],bundles:Array.isArray(e.bundles)?e.bundles.filter(e=>e!=null&&typeof e.id==`string`&&typeof e.filename==`string`).map(e=>({id:e.id,slug:e.slug,integrity:e.integrity,byteSize:e.byteSize,repoId:e.repoId,filename:e.filename,kind:e.kind,visible:e.visible!==!1,summary:e.summary??null,summaryRetryAt:Number.isSafeInteger(e.summaryRetryAt)&&e.summaryRetryAt>0?e.summaryRetryAt:null,repoDirectory:typeof e.repoDirectory==`string`?e.repoDirectory:``,repoFullName:typeof e.repoFullName==`string`?e.repoFullName:``,commitInfo:W(e.commitInfo)})):[]}))):s==null?[]:e}function K(e){return e?.links===void 0?[]:Array.isArray(e.links)&&e.links.every(e=>Array.isArray(e)&&e.length>=2&&e.every(e=>typeof e==`string`))?e.links:null}function q(e){return s(e?.data)===null||typeof e.repo?.directory!=`string`||e.repo.github!==null&&typeof e.repo.github!=`string`||K(e)===null?null:{data:e.data,repo:e.repo,...e.links?{links:e.links}:{}}}async function J(e,{signal:t}={}){return q(await B(`/api/reports/${encodeURIComponent(e)}`,null,{signal:t}))}async function Y(e,{signal:t}={}){let n=[...new Set(e)];if(n.length===0)return[];let r=await B(`/api/reports/query`,null,{method:`POST`,signal:t,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({ids:n})});if(!Array.isArray(r?.reports)||r.reports.length!==n.length)return null;let i=new Map;for(let e of r.reports){let t=q(e);if(!t||!n.includes(e.id)||i.has(e.id))return null;i.set(e.id,t)}let a=K(r);return a===null?null:e.map(e=>({...i.get(e),...a.length>0?{links:a}:{}}))}async function X(e,{signal:t,reportId:n=null}={}){let r=n===null?``:`?reportId=${encodeURIComponent(n)}`,i=await B(`/api/teams/${encodeURIComponent(e)}/reports${r}`,null,{signal:t});if(!Array.isArray(i?.reports))return null;let a=[],o=new Set;for(let e of i.reports){let t=q(e);if(!t||typeof e.id!=`string`||typeof e.filename!=`string`||o.has(e.id))return null;o.add(e.id),a.push({id:e.id,filename:e.filename,...t})}let s=K(i);return s===null?null:(Object.defineProperty(a,"links",{value:s}),a)}function Z(e){return e?`?team=${encodeURIComponent(e)}`:``}async function Q(e,{reportId:t,...n}={}){let r=t==null?``:`?reportId=${encodeURIComponent(t)}`,{reports:i,entries:a,comments:o,issues:s={}}=await B(`/api/teams/${encodeURIComponent(e)}/annotations${r}`,null,n)??{};if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a)||!Array.isArray(o)||!s||typeof s!=`object`||Array.isArray(s)||Object.values(i).some(e=>!Array.isArray(e)||e.some(e=>typeof e!=`string`))||o.some(e=>!e||typeof e.findingId!=`string`))return null;let c=new Map;for(let[e,t]of o.entries()){let n=t.findingId,r=c.get(n)??[];r.push(e),c.set(n,r)}let l=new Map,u=new Map;return e=>{if(!Object.hasOwn(i,e))return null;if(u.has(e))return u.get(e);let t=JSON.stringify(i[e]),n=l.get(t);if(!n){let r=[...new Set(i[e])],u=r.flatMap(e=>c.get(e)??[]);n={entries:Object.fromEntries(r.filter(e=>Object.hasOwn(a,e)).map(e=>[e,a[e]])),comments:u.toSorted((e,t)=>e-t).map(e=>o[e]),issues:Object.fromEntries(r.filter(e=>Object.hasOwn(s,e)).map(e=>[e,s[e]]))},l.set(t,n)}return u.set(e,n),n}}async function ne(e,t,n){let r=(await B(`/api/reports/${encodeURIComponent(e)}/triage${Z(t)}`,null,n))?.entries;return typeof r==`object`&&r&&!Array.isArray(r)?r:null}async function re(e,t,n=null){if(i())return[];let r=n===null?``:`?reportId=${encodeURIComponent(n)}`,a=await B(`/api/teams/${encodeURIComponent(e)}/fixes${r}`,null,{signal:t});return Array.isArray(a?.fixes)?a.fixes:null}async function ie(e,t,n){let r=await B(`/api/reports/${encodeURIComponent(e)}/comments${Z(t)}`,null,n);return Array.isArray(r?.comments)?r.comments:null}async function ae(e,{findingId:t,body:n,commentId:r=null,version:i},a,o){let s=r==null?``:`/${encodeURIComponent(r)}`;try{let c=await F(`/api/reports/${encodeURIComponent(e)}/comments${s}${Z(o)}`,{method:r==null?`POST`:`PATCH`,credentials:`same-origin`,headers:{"content-type":`application/json`,...a?{"x-csrf-token":a}:{}},body:JSON.stringify(r==null?{findingId:t,body:n}:{body:n,version:i})});return{status:c.status,comment:c.ok?(await c.json()).comment:null}}catch{return{status:0,comment:null}}}async function oe(e,t,n,r,i){try{return(await F(`/api/reports/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}${Z(i)}`,{method:`DELETE`,credentials:`same-origin`,headers:{"content-type":`application/json`,...r?{"x-csrf-token":r}:{}},body:JSON.stringify({version:n})})).status}catch{return 0}}async function $(e,t,n,r){try{return(await F(`/api/reports/${encodeURIComponent(e)}/triage${Z(r)}`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,...n?{"x-csrf-token":n}:{}},body:JSON.stringify({entries:t})})).status}catch{return 0}}function se(e){e&&(location.href=e)}async function ce(e){if(i()){location.href=`/`;return}try{await F(`/api/auth/logout`,{method:`POST`,credentials:`same-origin`,headers:e?{"x-csrf-token":e}:{}})}catch{}location.reload()}async function le(e,t){let n=await F(`/api/auth/view-as`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,...t?{"x-csrf-token":t}:{}},body:JSON.stringify({userId:e})});if(!n.ok)throw Error(`HTTP ${n.status}`);location.assign(`/`)}async function ue(e){try{await F(`/api/auth/view-as`,{method:`DELETE`,credentials:`same-origin`,headers:e?{"x-csrf-token":e}:{}})}catch{}location.assign(o[`admin-users`])}async function de(e){let t=await F(`/api/teams/${encodeURIComponent(e)}/share`,{credentials:`same-origin`});if(!t.ok)throw Error(`Could not load public links (${t.status})`);return(await t.json()).shares}async function fe(e,t,{id:n,revoke:r=!1,dependencies:i=!1,security:a=!1}={}){let o=n?`/${encodeURIComponent(n)}`:``,s=await F(`/api/teams/${encodeURIComponent(e)}/share${o}`,{method:r?`DELETE`:n?`PATCH`:`POST`,credentials:`same-origin`,headers:{"x-csrf-token":t,"content-type":`application/json`},...r?{}:{body:JSON.stringify({dependencies:i,security:a})}});if(!s.ok)throw Error(`Could not ${r?`revoke`:n?`update`:`create`} public link (${s.status})`);return s.json()}async function pe(e,t){let n=await F(`/api/bundles/${encodeURIComponent(e)}/download`,{credentials:`same-origin`});if(!n.ok)throw Error(`Could not download bundle (${n.status})`);let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}export{u as a,E as b,D as c,F as d,I as e,L as f,R as g,z as h,V as i,G as j,J as k,Y as l,X as m,Z as n,Q as o,ne as p,re as q,ie as r,ae as s,oe as t,$ as u,se as v,ce as w,le as x,ue as y,de as z,fe as A,pe as B};
@@ -1,3 +1,3 @@
1
- import{Bb as e,Sb as t,Yb as n,qb as r,rb as i,sb as a,ub as o,v as s,vb as c,wb as l}from"./chunk-QRD6GIG5.js";import{c as u,d}from"./chunk-PTGDYLNS.js";import{e as f,f as p,g as m,j as h}from"./chunk-SXV2T5C4.js";import{c as g}from"./chunk-2XUEZHIP.js";var _=`.token.comment,.token.prolog,.token.cdata{color:var(--code-comment);font-style:italic}.token.punctuation{color:var(--muted)}.token.string,.token.attr-value,.token.char,.token.regex{color:var(--code-string)}.token.number,.token.boolean,.token.constant,.token.symbol{color:var(--code-number)}.token.keyword,.token.builtin,.token.important,.token.atrule{color:var(--code-keyword)}.token.function,.token.class-name,.token.tag{color:var(--code-function)}.token.operator,.token.entity,.token.url,.token.attr-name,.token.selector{color:var(--code-operator)}.token.variable,.token.property,.token.parameter{color:var(--code-variable)}.token.annotation{color:var(--code-function)}.token.deleted{color:var(--code-deleted)}.token.inserted{color:var(--code-inserted)}.token.italic{font-style:italic}.token.bold{font-weight:700}.code-control{padding:0 .3em;margin:0 .1em;border-radius:3px;font-size:.8em;line-height:0;font-style:normal;font-weight:400;color:var(--warning);background:rgb(from var(--warning) r g b / .14);box-shadow:inset 0 0 0 1px rgb(from var(--warning) r g b / .45);white-space:nowrap;user-select:none}
2
- `,v=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,y=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="1.8" y="5" width="20.4" height="14" rx="2"/><path d="M5.6 15.6V8.4l3.1 3.6 3.1-3.6v7.2"/><path d="M16.9 8.4v7.2m-2.6-2.9 2.6 2.9 2.6-2.9"/></svg>`,b=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>`;function x(e,t){let n=u.find(t=>t.value===e)?.label??e;return d(e)?.includes(`partial`)?t===`exclude`?`${n} (full only)`:t===`only`?`${n} (partial only)`:n:n}function S(e){return h.filter(t=>e.has(t)).map(e=>f[e]??e).join(`, `)}function C(e=s){let t=[];if(e.filterSeverities.size>0&&t.push({key:`severity`,label:`Severity`,value:S(e.filterSeverities),clear:{filterSeverities:new Set}}),e.filterColors.size>0&&t.push({key:`marks`,label:`Marks`,value:[...e.filterColors].map(e=>m[e]??e).join(`, `),clear:{filterColors:new Set}}),e.filterSources.size===1&&t.push({key:`source`,label:`Source`,value:e.filterSources.has(`own`)?`Sources only`:`Dependencies only`,clear:{filterSources:new Set}}),e.filterAnalyzer&&t.push({key:`analyzer`,label:`Analyzer`,value:e.filterAnalyzer===r?`(none)`:e.filterAnalyzer,clear:{filterAnalyzer:``}}),e.filterModel&&t.push({key:`model`,label:`Model`,value:e.filterModel===a?`(none)`:e.filterModel,clear:{filterModel:``}}),e.filterRepo&&t.push({key:`repo`,label:`Repository`,value:e.filterRepo===i?`(no repo)`:e.filterRepo,clear:{filterRepo:``}}),d(e.filterRevalidate)&&t.push({key:`revalidate`,label:`Revalidation`,value:x(e.filterRevalidate,e.filterPartial),clear:{filterRevalidate:``,filterPartial:``}}),!e.filterRevalidate&&(e.filterConfMin>0||e.filterConfMax<10)){let n;n=e.filterConfMin>0&&e.filterConfMax<10?`${e.filterConfMin}\u2013${e.filterConfMax}`:e.filterConfMin>0?`\u2265 ${e.filterConfMin}`:`\u2264 ${e.filterConfMax}`,t.push({key:`confidence`,label:`Confidence`,value:n,clear:{filterConfMin:0,filterConfMax:10}})}e.filterInclude&&t.push({key:`search`,label:e.filterIncludeNegate?`Excluding`:`Search`,value:`"${e.filterInclude}"`,clear:{filterInclude:``,filterIncludeNegate:!1}});for(let[n,r]of[[`filterComment`,`comment`],[`filterFix`,`fix`],[`filterFlagged`,`flag`]]){let i=e[n];i&&t.push({key:`annotation:${r}`,label:`Annotation`,value:`${i===`with`?`With`:`Without`} ${r}`,clear:{[n]:``}})}return!s.currentWorkspace&&e.filterDuplicates&&t.push({key:`duplicates`,label:`Duplicates`,value:e.filterDuplicates===`with`?`Only rows linked to other reports`:`Exclude rows linked to other reports`,clear:{filterDuplicates:``}}),e.filterCrossContext&&t.push({key:`cross-context`,label:`Context`,value:e.filterCrossContext===`with`?`Only rows across multiple repos or packages`:`Exclude rows across multiple repos or packages`,clear:{filterCrossContext:``}}),e.filterAppStacked&&t.push({key:`app-stacked`,label:`App stack`,value:e.filterAppStacked===`with`?`Only rows with multiple App findings`:`Exclude rows with multiple App findings`,clear:{filterAppStacked:``}}),e.filterSecurity&&t.push({key:`security`,label:`Security`,value:e.filterSecurity===`with`?`Only security-related rows`:`Exclude security-related rows`,clear:{filterSecurity:``}}),t}function w(){return n().filter(e=>t(e).commonTriage===s.shownTriage)}function T(){return s.shownTriage?p[s.shownTriage]??s.shownTriage:null}function E(t,n=o()){let r=w(),i=r.length;c(n);let a;try{a=e(r).length}finally{l()}return{included:a,total:i,excluded:i-a,fields:n,filters:C(n),bucketLabel:T(),focusedOnly:t===`print`&&s.viewMode===`focus`}}var D=`.managed-comment{container:managed-comment / inline-size;white-space:normal}.managed-comment-row{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr) auto;align-items:start;gap:.35rem .65rem;line-height:1.5}.managed-comment-author{grid-column:1;grid-row:1;display:flex;align-items:center;gap:.45rem;min-width:0;max-width:14rem;& strong{overflow:hidden;text-overflow:ellipsis;font-weight:600}}.managed-comment-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:1.3rem;height:1.3rem;overflow:hidden;border-radius:50%;background:rgb(from var(--muted) r g b / .15);color:var(--muted);font-size:.65rem;font-weight:600;& img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}& img[hidden]{display:none}}.managed-comment-body{grid-column:2;grid-row:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}& a.comment-self-ref{text-decoration:underline dotted;text-underline-offset:2px}& a.comment-self-ref:hover{text-decoration:underline solid}}.managed-comment-time{color:var(--muted);font-size:.7rem;font-weight:400;white-space:nowrap;text-align:right}.managed-comment-meta{grid-column:3;grid-row:1;justify-self:end;display:flex;align-items:center;gap:.5rem;min-height:1.3rem}.managed-comment-actions{display:flex;align-items:center;gap:.15rem}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr) auto;.managed-comment-body{grid-column:1}.managed-comment-meta{grid-column:2}}@container managed-comment (max-width: 28rem){.managed-comment-row:has(.managed-comment-meta){grid-template-columns:minmax(0,max-content) minmax(0,1fr);.managed-comment-meta{grid-column:1 / -1;grid-row:1}.managed-comment-author,.managed-comment-body{grid-row:2}}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr)}.managed-comment-author{max-width:9rem}}
1
+ import{Cb as e,Tb as t,Zb as n,rb as r,sb as i,tb as a,v as o,vb as s,wb as c,xb as l}from"./chunk-LE5ZWLG4.js";import{c as u,d}from"./chunk-MSION3G4.js";import{e as f,f as p,g as m,j as h}from"./chunk-SXV2T5C4.js";import{c as g}from"./chunk-2XUEZHIP.js";var _=`.token.comment,.token.prolog,.token.cdata{color:var(--code-comment);font-style:italic}.token.punctuation{color:var(--muted)}.token.string,.token.attr-value,.token.char,.token.regex{color:var(--code-string)}.token.number,.token.boolean,.token.constant,.token.symbol{color:var(--code-number)}.token.keyword,.token.builtin,.token.important,.token.atrule{color:var(--code-keyword)}.token.function,.token.class-name,.token.tag{color:var(--code-function)}.token.operator,.token.entity,.token.url,.token.attr-name,.token.selector{color:var(--code-operator)}.token.variable,.token.property,.token.parameter{color:var(--code-variable)}.token.annotation{color:var(--code-function)}.token.deleted{color:var(--code-deleted)}.token.inserted{color:var(--code-inserted)}.token.italic{font-style:italic}.token.bold{font-weight:700}.code-control{padding:0 .3em;margin:0 .1em;border-radius:3px;font-size:.8em;line-height:0;font-style:normal;font-weight:400;color:var(--warning);background:rgb(from var(--warning) r g b / .14);box-shadow:inset 0 0 0 1px rgb(from var(--warning) r g b / .45);white-space:nowrap;user-select:none}
2
+ `,v=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,y=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="1.8" y="5" width="20.4" height="14" rx="2"/><path d="M5.6 15.6V8.4l3.1 3.6 3.1-3.6v7.2"/><path d="M16.9 8.4v7.2m-2.6-2.9 2.6 2.9 2.6-2.9"/></svg>`,b=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>`;function x(e,t){let n=u.find(t=>t.value===e)?.label??e;return d(e)?.includes(`partial`)?t===`exclude`?`${n} (full only)`:t===`only`?`${n} (partial only)`:n:n}function S(e){return h.filter(t=>e.has(t)).map(e=>f[e]??e).join(`, `)}function C(e=o){let t=[];if(e.filterSeverities.size>0&&t.push({key:`severity`,label:`Severity`,value:S(e.filterSeverities),clear:{filterSeverities:new Set}}),e.filterColors.size>0&&t.push({key:`marks`,label:`Marks`,value:[...e.filterColors].map(e=>m[e]??e).join(`, `),clear:{filterColors:new Set}}),e.filterSources.size===1&&t.push({key:`source`,label:`Source`,value:e.filterSources.has(`own`)?`Sources only`:`Dependencies only`,clear:{filterSources:new Set}}),e.filterAnalyzer&&t.push({key:`analyzer`,label:`Analyzer`,value:e.filterAnalyzer===r?`(none)`:e.filterAnalyzer,clear:{filterAnalyzer:``}}),e.filterModel&&t.push({key:`model`,label:`Model`,value:e.filterModel===a?`(none)`:e.filterModel,clear:{filterModel:``}}),e.filterRepo&&t.push({key:`repo`,label:`Repository`,value:e.filterRepo===i?`(no repo)`:e.filterRepo,clear:{filterRepo:``}}),d(e.filterRevalidate)&&t.push({key:`revalidate`,label:`Revalidation`,value:x(e.filterRevalidate,e.filterPartial),clear:{filterRevalidate:``,filterPartial:``}}),!e.filterRevalidate&&(e.filterConfMin>0||e.filterConfMax<10)){let n;n=e.filterConfMin>0&&e.filterConfMax<10?`${e.filterConfMin}\u2013${e.filterConfMax}`:e.filterConfMin>0?`\u2265 ${e.filterConfMin}`:`\u2264 ${e.filterConfMax}`,t.push({key:`confidence`,label:`Confidence`,value:n,clear:{filterConfMin:0,filterConfMax:10}})}e.filterInclude&&t.push({key:`search`,label:e.filterIncludeNegate?`Excluding`:`Search`,value:`"${e.filterInclude}"`,clear:{filterInclude:``,filterIncludeNegate:!1}});for(let[n,r]of[[`filterComment`,`comment`],[`filterFix`,`fix`],[`filterFlagged`,`flag`]]){let i=e[n];i&&t.push({key:`annotation:${r}`,label:`Annotation`,value:`${i===`with`?`With`:`Without`} ${r}`,clear:{[n]:``}})}return!o.currentWorkspace&&e.filterDuplicates&&t.push({key:`duplicates`,label:`Duplicates`,value:e.filterDuplicates===`with`?`Only rows linked to other reports`:`Exclude rows linked to other reports`,clear:{filterDuplicates:``}}),e.filterCrossContext&&t.push({key:`cross-context`,label:`Context`,value:e.filterCrossContext===`with`?`Only rows across multiple repos or packages`:`Exclude rows across multiple repos or packages`,clear:{filterCrossContext:``}}),e.filterAppStacked&&t.push({key:`app-stacked`,label:`App stack`,value:e.filterAppStacked===`with`?`Only rows with multiple App findings`:`Exclude rows with multiple App findings`,clear:{filterAppStacked:``}}),e.filterSecurity&&t.push({key:`security`,label:`Security`,value:e.filterSecurity===`with`?`Only security-related rows`:`Exclude security-related rows`,clear:{filterSecurity:``}}),t}function w(){return n().filter(e=>t(e).commonTriage===o.shownTriage)}function T(){return o.shownTriage?p[o.shownTriage]??o.shownTriage:null}function E(t,n=s()){let r=w(),i=r.length;c(n);let a;try{a=e(r).length}finally{l()}return{included:a,total:i,excluded:i-a,fields:n,filters:C(n),bucketLabel:T(),focusedOnly:t===`print`&&o.viewMode===`focus`}}var D=`.managed-comment{container:managed-comment / inline-size;white-space:normal}.managed-comment-row{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr) auto;align-items:start;gap:.35rem .65rem;line-height:1.5}.managed-comment-author{grid-column:1;grid-row:1;display:flex;align-items:center;gap:.45rem;min-width:0;max-width:14rem;& strong{overflow:hidden;text-overflow:ellipsis;font-weight:600}}.managed-comment-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:1.3rem;height:1.3rem;overflow:hidden;border-radius:50%;background:rgb(from var(--muted) r g b / .15);color:var(--muted);font-size:.65rem;font-weight:600;& img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}& img[hidden]{display:none}}.managed-comment-body{grid-column:2;grid-row:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}& a.comment-self-ref{text-decoration:underline dotted;text-underline-offset:2px}& a.comment-self-ref:hover{text-decoration:underline solid}}.managed-comment-time{color:var(--muted);font-size:.7rem;font-weight:400;white-space:nowrap;text-align:right}.managed-comment-meta{grid-column:3;grid-row:1;justify-self:end;display:flex;align-items:center;gap:.5rem;min-height:1.3rem}.managed-comment-actions{display:flex;align-items:center;gap:.15rem}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr) auto;.managed-comment-body{grid-column:1}.managed-comment-meta{grid-column:2}}@container managed-comment (max-width: 28rem){.managed-comment-row:has(.managed-comment-meta){grid-template-columns:minmax(0,max-content) minmax(0,1fr);.managed-comment-meta{grid-column:1 / -1;grid-row:1}.managed-comment-author,.managed-comment-body{grid-row:2}}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr)}.managed-comment-author{max-width:9rem}}
3
3
  `;export{_ as a,v as b,y as c,b as d,C as e,w as f,T as g,E as h,D as i};
@@ -0,0 +1,2 @@
1
+ import{e,f as t,g as n,k as r}from"./chunk-4HI2MSAV.js";import{k as i}from"./chunk-JKGQ3O7O.js";function a(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}var o=(e,t)=>`${`../`.repeat(e.base.split(`/`).length-1)}${t}`;function s({root:e,paths:t},n,r){if(!e||n===`.`)return n;for(let e of r){let r=t.get(`${n}/${e}`);if(r?.endsWith(`/${e}`))return r.slice(0,-e.length-1)}let i=a(e,`${n}/`);return i===null?o(e,n):i.slice(0,-1)||`.`}function c(e,t){if(!e)return{prefix:t,from:null,to:null};let n=t.startsWith(e.other)?t:``;return{prefix:n,from:`./${e.base}${n.slice(e.other.length)}`,to:`./${n||e.other}`}}function l(...e){let t=new Set;for(let n of e){let e=i(n);for(let[r,i]of Object.entries(n?.bundle?.reason??{}))Array.isArray(i)&&i.some(t=>e.has(t))&&t.add(r)}let n=t=>e.some(e=>{if(e?.kind!==`stasis`)return!1;let n=i(e),r=e?.bundle?.reason?.[t];return new Set(Array.isArray(r)?r.filter(e=>n.has(e)):[]).size<n.size});return[...t].some(n)?[...t].toSorted().map(e=>({id:`reason:${e}`,label:e})):[]}function u(e,t=``){let n=i(e);if(!t||e?.kind!==`stasis`)return n;let r=e?.bundle?.reason?.[t.replace(/^reason:/u,``)],a=new Set(Array.isArray(r)?r:[]);return new Map([...n].filter(([e])=>a.has(e)))}function d(e,t,n,r){return JSON.stringify([e,t,n,r])}function f(e,t=``){let n=new Map;if(e?.kind!==`stasis`||!e.bundle)return n;let r=t?i(e):null,a=t?u(e,t):null;for(let[t,i]of e.bundle.imports)for(let[e,o]of i)for(let[i,s]of o){let o=typeof s==`string`?[[null,s]]:s;for(let[s,c]of o){if(a&&!a.has(e)&&(r.has(e)||!a.has(c)))continue;let o=d(e,i,t,s);n.set(o,{key:o,parent:e,specifier:i,conditions:t,platform:s,target:c})}}return n}var p=(e,{lo:t,start:n},r)=>e[n+(r-t)/2];function m(e,t,{low:n,high:r},i,a){return e===-t||e-1<n||e!==t&&e+1<=r&&p(i,a,e-1)<p(i,a,e+1)?e+1:e-1}function h(e,t,n,{first:r,n:i,m:a,d:o,...s}){e.a.fill(1,0,r).fill(1,i),e.b.fill(1,0,r).fill(1,a);let c=i,l=a;for(let r=o;r>0;r--){let i=c-l,a=m(i,r,s,t,n[r]),o=p(t,n[r],a);for(let t=a>i?o:o+1;t<c;t++)e.a[t]=e.b[t-i]=1;c=o,l=c-a}for(let t=r;t<c;t++)e.a[t]=e.b[t]=1}function g(e,t,n){let r=0,i=t.length,a=e.length,o=2*(a+i);for(;r<a&&r<i&&e[r]===t[r];)r++;for(;a>r&&i>r&&e[a-1]===t[i-1];)a--,i--;let s={high:a-r,low:r-i},c=[r],l=[{lo:1,start:0}];for(let u=0;u<=s.high-s.low;u++){let d=l[u],f=Math.min(u,s.high),g=Math.max(-u,s.low+(s.low+u&1));l.push({lo:g,start:c.length});for(let _=g;_<=f;_+=2){let f=m(_,u,s,c,d),g=p(c,d,f),v=f>_?g:g+1,y=v;for(;v<a&&v-_<i&&e[v]===t[v-_];)v++;if(o+=2+v-y,c.push(v),v>=a&&v-_>=i)return h(n,c,l,{first:r,n:a,m:i,d:u,...s}),o}}throw Error(`no edit script between two lines`)}var _=/[\p{L}\p{N}_$]+|\s+|[^\p{L}\p{N}_$\s]/gu,v=2e3,y=800,b=.6;function x(e,t){if(e.length>v)return null;let n=e.match(_)??[];return n.length>y?null:{line:e,tokens:n,words:n.map(e=>(t.has(e)||t.set(e,t.size),t.get(e)))}}function S({tokens:e,line:t},n){let r=[];for(let i=0,a=0;a<e.length;i+=e[a++].length){if(n[a])continue;let o=r.at(-1);o&&/^\s*$/u.test(t.slice(o[1],i))?o[1]=i+e[a].length:r.push([i,i+e[a].length])}return r}var C=(e,t)=>e.reduce((e,[t,n])=>e+n-t,0)/Math.max(1,t.length);function w(e,t){let n={a:e.words.map(()=>0),b:t.words.map(()=>0)},r=g(e.words,t.words,n),i={a:S(e,n.a),b:S(t,n.b)};return{ranges:i,share:n.a.includes(1)?Math.min(C(i.a,e.line),C(i.b,t.line)):1,steps:r}}function T(e,t){if(e===t)return{a:[],b:[]};let n=new Map,r=x(e,n),i=x(t,n);if(r===null||i===null)return null;let{ranges:a,share:o}=w(r,i);return o<=b?a:null}var E=200,D=5e6,O=6,k=60,A=3;function j(e){let t=new Map;for(let n of e?.tokens??[])t.set(n,(t.get(n)??0)+1);return t}function M(e,t){let n=new Map,r=[e,t].map(e=>e.map(e=>x(e,n))),i=r.map(e=>e.map(j)),a=0,o=(e,t,n)=>{let r=0;for(let[i,o]of e)if(a+=A,(r+=i.length*Math.max(0,o-(t.get(i)??0)))>b*n.length)return 1/0;return r/Math.max(1,n.length)},s=(n,a)=>r[0][n]===null||r[1][a]===null?1/0:Math.min(o(i[0][n],i[1][a],e[n]),o(i[1][a],i[0][n],t[a])),c=(e,t)=>{if(a+=k,s(e,t)===1/0)return 1/0;let{share:n,steps:i}=w(r[0][e],r[1][t]);return a+=i,n<=b?n:1/0},l=new Float64Array(e.length*t.length).fill(NaN);return{share:(n,r)=>{let i=n*t.length+r;return Number.isNaN(l[i])&&(l[i]=e[n]===t[r]?0:c(n,r)),l[i]},floor:s,spent:()=>a}}function N(e,t,{share:n,spent:r}){let i=Array.from({length:e+1},()=>new Float64Array(t+1)),a=(e,t)=>n(e,t)===1/0?-1/0:1e3-n(e,t)+i[e][t];for(let n=0;n<e;n++)for(let e=0;e<t;e++)if(i[n+1][e+1]=Math.max(i[n][e+1],i[n+1][e],a(n,e)),r()>D)return null;let o=[];for(let n=e,r=t;n>0&&r>0;)i[n][r]===i[n][r-1]?r--:i[n][r]===i[n-1][r]?n--:o.push([--n,--r]);return o.toReversed()}function P(e,t,{share:n,floor:r}){let i=[];for(let a=0,o=0;a<e&&o<t;a++){let e=null,s=1/0,c=Array.from({length:Math.min(t,o+O)-o},(e,t)=>[o+t,r(a,o+t)]);for(let[t,r]of c.toSorted((e,t)=>e[1]-t[1]||e[0]-t[0])){if(r>s)break;(n(a,t)<s||n(a,t)===s&&t<e)&&([e,s]=[t,n(a,t)])}e!==null&&(i.push([a,e]),o=e+1)}return i}function F(e,t){if(e.length>E||t.length>E)return[];let n=M(e,t);return N(e.length,t.length,n)??P(e.length,t.length,n)}var I=(e,n,r)=>t(e,n,{...r,discard:!1});function L(e){if(e===null)return``;let t=e.type===`symlink`?e.target:e.data;if(typeof t==`string`)return t.includes(`\0`)?void 0:t;if(!t.includes(0))try{return r(t)}catch{return}}var R=new Set([`none`,`all`,`change`,`trailing`]);function z({horizon:e=1/0,whitespace:t=`none`,ignoreCase:n=!1}={}){if(e!==1/0&&!(Number.isSafeInteger(e)&&e>=0))throw RangeError(`horizon must be a whole number or Infinity, not ${e}`);if(!R.has(t))throw RangeError(`whitespace must be 'none', 'all', 'change' or 'trailing', not ${t}`);if(typeof n!=`boolean`)throw TypeError(`ignoreCase must be a boolean, not ${typeof n}`);return{horizon:e,whitespace:t,ignoreCase:n}}var B=e=>e.reduce((e,{a0:t,a1:n,b0:r,b1:i})=>e+n-t+i-r,0),V=e=>e===``?[]:e.split(/(?<=\n)/u),H=e=>({...e,ignoreCase:!1,whitespace:`none`}),U=e=>(e.whitespace??`none`)!==`none`||!!e.ignoreCase;function W(t,r,i,a,o){let s=V(t),c=V(r),l=(e,t,n,r)=>({a0:e,a1:t,b0:n,b1:r,remove:s.slice(e,t),insert:c.slice(n,r)}),u=o.flatMap(({a0:e,a1:t,b0:n,b1:r})=>e===t||n===r?[l(e,t,n,r)]:I(s.slice(e,t).join(``),c.slice(n,r).join(``),i).map(t=>l(e+t.a0,e+t.a1,n+t.b0,n+t.b1))),d=B(u)<B(a)&&(a=>{try{return n(t,r,a,{format:`normal`,ignoreCase:i.ignoreCase,whitespace:i.whitespace}),!0}catch(t){if(t instanceof e)return!1;throw t}})(u)?u:a;return B(d)<B(o)?d:o}function G(e,t,n){let r=I(e,t,n);return U(n)?W(e,t,n,r,I(e,t,H(n))):r}function K(e,t,n){let r=L(e),i=L(t);if(r===void 0||i===void 0)return{binary:!0,blocks:[],insertions:null,deletions:null};let a=r===i?[]:G(r,i,n),o=(e,t)=>a.reduce((n,r)=>n+r[t]-r[e],0);return{binary:!1,blocks:a,insertions:o(`b0`,`b1`),deletions:o(`a0`,`a1`)}}function q(t,r,i,a){let{whitespace:o,ignoreCase:s}=z(a);try{return n(t,r,i,{format:`normal`,whitespace:o,ignoreCase:s}),!0}catch(t){if(t instanceof e)return!1;throw t}}var J=/[ \t\n\v\f\r]/u,Y=e=>{let t=e.split(`
2
+ `);return t.at(-1)===``&&t.pop(),t};function X(e,t){for(let n=0,r=0;;n++,r++){let i=``,a=``;for(;n<e.length&&J.test(e[n]);)i+=e[n++];for(;r<t.length&&J.test(t[r]);)a+=t[r++];if(i!==a&&new Set(i+a).size>1)return!0;if(n>=e.length||r>=t.length)return!1}}function Z(e,t,n){try{if(!q(e,t,n,{whitespace:`all`}))return!0}catch{return!0}let r=Y(e),i=Y(t),a=0,o=0;for(let e=0;e<=n.length;e++){let t=e<n.length?n[e].a0:r.length;for(;a<t;a++,o++)if(r[a]!==i[o]&&X(r[a],i[o]))return!0;e<n.length&&({a1:a,b1:o}=n[e])}return!1}function Q(e,t,{extension:n=!0}={}){let r=e.split(`/`),i=t.split(`/`),a=0;for(;a<r.length-1&&a<i.length-1&&r[a]===i[a];)a++;let o=0;for(;o<r.length-a-1&&o<i.length-a-1&&r.at(-1-o)===i.at(-1-o);)o++;let s={head:a?`${r.slice(0,a).join(`/`)}/`:``,from:r.slice(a,r.length-o).join(`/`),to:i.slice(a,i.length-o).join(`/`),tail:o?`/${r.slice(-o).join(`/`)}`:``},c=s.from.lastIndexOf(`.`);return n&&!s.from.includes(`/`)&&!s.to.includes(`/`)&&c>0&&s.to.lastIndexOf(`.`)===c&&s.from.slice(0,c)===s.to.slice(0,c)?{...s,head:s.head+s.from.slice(0,c),from:s.from.slice(c),to:s.to.slice(c)}:s}export{T as a,F as b,L as c,z as d,K as e,Z as f,Q as g,a as h,o as i,s as j,c as k,l,u as m,d as n,f as o};
@@ -3,4 +3,4 @@ import{a as e}from"./chunk-SXV2T5C4.js";import{b as t}from"./chunk-TUII34K2.js";
3
3
  `,t+1)?3:2,Qt=/\\(?:u\{([\da-f]+)\}|u([\da-f]{4})|x([\da-f]{2})|([0-3][0-7]{0,2}|[4-7][0-7]?)|(\r\n|[\n\r\u2028\u2029])|(.))/giu,$t={b:`\b`,f:`\f`,n:`
4
4
  `,r:`\r`,t:` `,v:`\v`};function en(e){return e.includes(`\\`)?e.replace(Qt,(e,t,n,r,i,a,o)=>{if(a!==void 0)return``;if(i!==void 0)return String.fromCodePoint(Number.parseInt(i,8));let s=Number.parseInt(t??n??r,16);return Number.isNaN(s)?$t[o]??o:String.fromCodePoint(Math.min(s,1114111))}):e}function tn(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n&&!Ht.includes(e[r]);)r+=e[r]===`\\`?Zt(e,r):1;return[e[r]===n?en(e.slice(t+1,r)):null,r+1]}function nn(e,t){let n=t+1,r=!1;for(;n<e.length&&!Ht.includes(e[n])&&(r||e[n]!==`/`);)e[n]===`\\`?n++:e[n]===`[`?r=!0:e[n]===`]`&&(r=!1),n++;return J.lastIndex=n+1,J.test(e)?J.lastIndex:n+1}function rn(e,t,n){for(let r=t;r<e.length;r++)if(e[r]===`\\`)r++;else{if(e[r]==="`")return r+1;if(e[r]===`$`&&e[r+1]===`{`)return n.push(`template`),r+2}return e.length}function an(e){let t=[],n=[],r=[],i=0,a=0;for(;i<e.length;){let o=t.length;if(K.lastIndex=i,K.test(e)&&(i=K.lastIndex),i>=e.length)break;let s=e[i],c=e[i+1];if(J.lastIndex=i,s===`/`&&c===`/`)q.lastIndex=i+2,i=q.test(e)?q.lastIndex-1:e.length;else if(s===`/`&&c===`*`){let t=e.indexOf(`*/`,i+2);i=t<0?e.length:t+2}else if(s===`"`||s===`'`){let[n,r]=tn(e,i);t.push({type:`string`,value:n}),i=r}else if(s==="`"||s===`}`&&n.at(-1)===`template`){s===`}`&&n.pop();let r=n.length,a=rn(e,i+1,n),o=s==="`"&&n.length===r&&e[a-1]==="`";t.push({type:`string`,value:o?en(e.slice(i+1,a-1)):null}),n.length>r&&t.push({type:`punctuator`,value:"${"}),i=a}else if(s===`/`&&Xt(t.at(-1)))i=nn(e,i),t.push({type:`regex`});else if(J.test(e)){let n=Kt.has(t.at(-1)?.value)&&!Ut.test(e.slice(a,i));t.push({type:`word`,value:e.slice(i,J.lastIndex),...n&&{label:n}}),i=J.lastIndex}else{s===`{`&&n.push(Jt(t.at(-1),Ut.test(e.slice(a,i)))?`object`:`block`);let o=s===`}`?n.pop():void 0;s===`(`&&r.push(Yt(t));let l=(s===`+`||s===`-`)&&c===s||s===`=`&&c===`>`?s+c:s;t.push({type:`punctuator`,value:l,...s===`)`&&{control:r.pop()===!0},...s===`}`&&{object:o===`object`}}),i+=l.length}t.length>o&&(a=i)}return t}var on=e=>e?.type===`string`&&e.value!==null,sn=new Set([`type`,`typeof`]),cn=(e,t)=>e[t+1]?.type===`word`&&(e[t+1].value!==`as`||e[t+2]?.type!==`word`||e[t+2].value===`as`);function ln(e,t){let n=!1;for(let r=t+1;r<e.length&&e[r].value!==`}`;r++)if(!(r>t+1&&e[r-1].value!==`,`)){if(!sn.has(e[r].value)||!cn(e,r))return!1;n=!0}return n}function un(e,t){for(let n=t;n<e.length;n++){let{value:r}=e[n];if(r===`;`||n>t&&(r===`import`||r===`export`))return null;if(r===`from`&&on(e[n+1]))return e[n+1].value}return null}function dn(e,t){let[n,r,i]=[e[t].value,e[t+1],e[t+2]],a=n===`import`?`import`:`export-from`;if(n===`import`&&on(r))return{kind:a,specifier:r.value};if(sn.has(r?.value)&&![`,`,`from`].includes(i?.value)||r?.value===`{`&&ln(e,t+1)||n===`export`&&![`{`,`*`].includes(r?.value)||n===`import`&&r?.type!==`word`&&![`{`,`*`].includes(r?.value))return null;let o=un(e,t+1);return o===null?null:{kind:a,specifier:o}}function fn(e,t){let[n,r]=[e[t+2],e[t+3]];if(n?.value!==`)`)return on(n)&&[`)`,`,`].includes(r?.value)?n.value:null}function pn(e,t=new Set){let n=an(e),r=[];for(let[e,i]of n.entries()){if(i.type!==`word`||[`.`,`#`,`function`].includes(n[e-1]?.value)||n[e-1]?.value===`=`&&n[e-3]?.value===`type`&&n[e-4]?.value===`import`)continue;let a=n[e+1]?.value===`(`,o=a?fn(n,e):void 0;if((i.value===`require`||t.has(i.value))&&o!==void 0)r.push({kind:`require`,specifier:o,...i.value!==`require`&&{callee:i.value}});else if(i.value===`import`&&a)o!==void 0&&r.push({kind:`dynamic-import`,specifier:o});else if(i.value===`import`||i.value===`export`){let t=dn(n,e);t&&r.push(t)}}return r}var mn=/^[\w$]*__d\(/gmu,hn=([e,t,n,...r])=>(typeof e==`number`||typeof e==`string`)&&(t===void 0||typeof t==`object`)&&(n===void 0||typeof n==`string`)&&r.length===0;function gn(e){let t=/\);?\s*$/u.exec(e)?.index,n=null,r=t===void 0?-1:e.lastIndexOf(`},`,t);for(;r>=0&&/[\d"]/u.test(e[r+2]);){let i;try{i=JSON.parse(`[${e.slice(r+2,t)}]`)}catch{break}if(!hn(i))break;n=i,r=r>0?e.lastIndexOf(`},`,r-1):-1}return n}function _n(e){let t=/^[^(]*\(\s*(?:function\s*[\w$]*\s*)?\(([^)]*)\)/u.exec(e)?.[1].split(`,`).slice(1,4).map(e=>e.trim().replaceAll(`$`,`\\$`));if(!t?.length)return[];let n=e.matchAll(RegExp(`(?<=[^\\w$.#]|\\.\\.\\.)(?:${t.join(`|`)})\\((\\d+|"(?:[^"\\\\]|\\\\.)*")[,)]`,`gu`));return[...new Set([...n].map(e=>JSON.parse(e[1])))]}function vn(e,t){if(Array.isArray(e))return e;let n=Object.entries(e??{}).filter(([e])=>/^\d+$/u.test(e)).map(([,e])=>e);return n.length>0?n:_n(t)}function yn(e,t){let n=new Map(t.files.map((e,t)=>[e,t])),r=e.flatMap((e,t)=>e.file?[{k:t,at:n.get(e.file)}]:[]);for(let n=0;n<(r[0]?.k??0);n++)e[n].file=t.files[r[0].at-r[0].k+n]??null;for(let[n,{k:i,at:a}]of r.entries()){let o=r[n+1];if(!(o&&o.at-a!==o.k-i))for(let n=i+1;n<(o?.k??e.length);n++)e[n].file=t.files[a+n-i]??null}}function bn(e,t){let n=[...e.matchAll(mn)].map(e=>e.index);if(n.length===0)return null;let r=Rt(e),i=t=>e.slice(r[t],r[t+1]),a=[];for(let[o,s]of n.entries()){let[c]=G(r,s),[l]=G(r,(n[o+1]??e.length)-1),u=gn(i(l));for(;!u&&l>c;)u=gn(i(--l));if(!u)throw Error(`bundleEdges: the Metro module at line ${c+1} ends in no define params`);let d=r[l+1]??e.length;a.push({id:u[0],file:Vt(t,r,s,d),dependencies:vn(u[1],e.slice(s,d))})}yn(a,t);let o=new Map(a.map(e=>[e.id,e])),{edges:s,link:c}=Ct();for(let{file:e,dependencies:t}of a)for(let n of t)c(e,o.get(n)?.file,`dependency`);return s}var xn=e=>e.path!==null&&![`json`,null].includes(lt(e.path)),Sn=e=>e.path!==null&&lt(e.path)===null;function Cn(e){let t=/^_([A-Za-z]+)\d+$/u.exec(e)?.[1];if(t)return[t,`interopRequireDefault`];let n=/^_(interopRequire(?:Default|Wildcard)|jsx(?:Dev)?Runtime|callSuper)$/u.exec(e)?.[1];return n===`callSuper`?[`getPrototypeOf`,`possibleConstructorReturn`,`interopRequireDefault`]:n?[n]:[]}var wn={jsxRuntime:`react/jsx-runtime`,jsxDevRuntime:`react/jsx-dev-runtime`};function Tn(e){let{sources:t,names:n,nameList:r}=jt(e),i=new Map,a=new Map,o=e.files.map(()=>new Set);for(let e=0;e<n.length;e++)n[e]<0||t[e]<0||(a.has(n[e])||a.set(n[e],Cn(r[n[e]]).length>0),a.get(n[e])&&o[t[e]].add(r[n[e]]));for(let[t,n]of o.entries()){if(n.size===0)continue;let r=e.files[t],a=new Set(Array.from((r.content??``).matchAll(/(?:function|var|let|const)\s+(_[A-Za-z]+\d*)\b/gu),e=>e[1])),o=[...n].filter(e=>!a.has(e)&&!a.has(e.replace(/\d+$/u,``))).flatMap(Cn);o.length>0&&i.set(r,o.map(e=>wn[e]??`@babel/runtime/helpers/${e}`))}return i}function En(e,t){let n=new Map;for(let[r,i]of e){let e=n.get(r)??n.set(r,new Map).get(r);for(let n of i)e.set(n,Et(t,r,n,()=>null))}let r=new Set([...n.values()].flatMap(e=>[...e.values()].map(e=>e.to))),i=(e,n)=>t.byRoot.get(n).find(e=>!r.has(e))??t.byRoot.get(n)[0];return(e,r)=>{let a=n.get(e)?.get(r);return a?.to?a:Et(t,e,r,i)}}var Dn=e=>/(?:^|\/)__prelude__$/u.test(e.source??``),On=e=>e?.package?.name===`metro-runtime`&&e.package.path===`src/polyfills/require.js`;function kn(e){if(!e.files.some(Dn)&&!On(e.files[0]))return null;if(!e.files.some(e=>e.content!==null&&!Dn(e)&&!On(e)))throw Error("bundleEdges: the Metro map carries no sourcesContent, which its edges are read from; pass the bundle as `code`");let t=yt(e.files),n=e.files[e.files.findIndex(Sn)+1],r=e.files.find(e=>e.package?.name===`metro-runtime`&&e.package.path===`src/modules/asyncRequire.js`),i=new Map(e.files.filter(e=>e.content!==null&&xn(e)).map(e=>[e,pn(e.content)])),a=Tn(e),o=En([...[...i].map(([e,t])=>[e,t.flatMap(({specifier:e})=>e===null?[]:[e])]),...a],t),{edges:s,add:c,link:l}=Ct();for(let t of e.files){Sn(t)&&l(t,n,`dependency`);for(let{kind:e,specifier:n}of i.get(t)??[]){let i=n===null?{to:null}:o(t,n);i.to!==t&&c(t,`${e}\0${JSON.stringify(n)}`,{from:t,kind:e,specifier:n,...i}),e===`dynamic-import`&&l(t,r,`dependency`)}for(let e of a.get(t)??[])l(t,o(t,e).to,`dependency`)}return s}var An=(e,t)=>t==null?kn(e):bn(t,e);function jn(e,t){let n=An(e,t);if(!n)throw Error(`bundleEdges: not a Metro ${t==null?`map`:`bundle`}; edges-lite.js reads only those, edges.js reads others`);return{edges:n}}function Mn(e){let t=JSON.parse(e.replace(/^\)\]\}'[^\n]*\n/u,``)),n=It(t),r=t.sections?t.sections.reduce((e,t)=>e+(t.map.names?.length??0),0):t.names?.length??null;return{json:{version:t.version,file:t.file,sourceRoot:t.sourceRoot},map:n,namesCount:r}}function Nn(e){if(e.map)return e.map.files.flatMap(e=>e.source===null?[]:[[e.source,e.content]]);let t=e.json?.sourcesContent??[];return(e.json?.sources??[]).map((e,n)=>[e,t[n]??null])}function Pn(e,t){let n=new Map;for(let{from:r,to:i,specifier:a}of t(e).edges){if(r.source===null||i?.source==null||i.source===r.source)continue;let e=typeof a==`string`?[r.source,i.source,a]:[r.source,i.source];n.set(e.join(`\0`),e)}return[...n.values()]}function Fn(e){try{return jn(e)}catch{return{edges:[]}}}var In=Object.freeze([]);function Ln(e){return e?.edges?e.edges:e?.map?(e.edges=Pn(e.map,Fn),e.edges):In}var Rn=new WeakMap,zn=new WeakMap;function Bn(e){let t=Ln(e);if(!Rn.has(t)){let e=new Map;for(let[n,r]of t)e.has(n)||e.set(n,new Set),e.get(n).add(r);Rn.set(t,e)}return Rn.get(t)}function Vn(e){let t=Ln(e);if(!zn.has(t)){let e=new Map;for(let[n,r,i]of t)i!==void 0&&(e.has(n)||e.set(n,new Map),e.get(n).set(i,r));zn.set(t,e)}return zn.get(t)}var Hn=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Kn=new WeakMap,Y=new WeakMap;function X(e){if(e?.metadataOnly)return new Map;let t=e?.bundle??e?.json;if(t&&Hn.has(t))return Hn.get(t);let n=new Map;if(!e)return n;if(e.kind===`stasis`){if(!e.bundle)return n;let t=e.bundle.formats;for(let[r,i]of e.bundle.sources)typeof i==`string`&&(M.isResourceFormat(t?.get(r))||n.set(r,i))}else if(e.kind===`sourcemap`)for(let[t,r]of Nn(e))typeof r==`string`&&n.set(t,r);return t&&Hn.set(t,n),n}function qn(e){let t=1;for(let n=e.indexOf(`
5
5
  `);n!==-1;n=e.indexOf(`
6
- `,n+1))t++;return t}var Jn=new WeakMap;function Yn(e){let t=Jn.get(e);if(!t){let n=[...e.keys()].toSorted();t={paths:n,numbers:new Map(n.map((e,t)=>[e,t+1]))},Jn.set(e,t)}return t}function Xn(e,t){let n=Array.isArray(t)?t:[];return{integrity:e.integrity,kind:`sourcemap`,size:e.size,json:{version:3,sources:n.map(([e])=>e),sourcesContent:n.map(([,,e])=>typeof e==`string`?e:null)},fileSizes:new Map(n.map(([e,t])=>[e,t])),npmBinaries:new Map(n.filter(([,,e,t])=>typeof e!=`string`&&typeof t==`string`).map(([e,t,,n])=>[e,{size:t,digest:n}]))}}function Zn(e){let t=e?.bundle??e?.json;if(t&&Un.has(t))return Un.get(t);let n=new Map(X(e));for(let[t,r]of e?.npmBinaries??[])n.set(t,{format:`digest`,...r});if(e?.kind===`stasis`&&e.bundle){let t=e.bundle.formats;for(let[r,i]of e.bundle.sources){if(typeof i!=`string`)continue;let e=t?.get(r);e===`resource`?n.set(r,i):e===`resource:base64`&&n.set(r,{format:`base64`,data:i})}}return t&&Un.set(t,n),n}var Qn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function $n(e){let t=e.endsWith(`=`);if(t?e.length%4!=0||e.at(-3)===`=`:e.length%4==1)return null;let n=t?e.slice(0,e.endsWith(`==`)?-2:-1):e;if(/[^A-Za-z0-9+/]/u.test(n))return null;let r=n.length%4;return r>1&&Qn.indexOf(n.at(-1))&(r===2?15:3)?null:Math.floor(n.length*3/4)}function er(e){return typeof e==`string`?t(e):e?.format===`digest`?e.size:e?.format===`base64`?$n(e.data):null}function Z(e){if(e?.fileSizes)return e.fileSizes;let t=e?.bundle??e?.json;if(t&&Wn.has(t))return Wn.get(t);let n=new Map,r=Zn(e),i=e?.kind===`stasis`?e.bundle?.sources.keys():e&&Nn(e).map(([e])=>e);for(let e of i??[])n.set(e,er(r.get(e)));return t&&Wn.set(t,n),n}function tr(e){if(e?.metadataOnly)return e.unsizedFiles??new Set;let t=Z(e);if(Y.has(t))return Y.get(t);let n=new Set;for(let r of Zn(e).keys())t.get(r)===null&&n.add(r);return Y.set(t,n),n}function nr(e){let t=Z(e);if(Kn.has(t))return Kn.get(t);let n=tr(e),r=e?.kind===`stasis`?e.bundle?.formats:null,i=new Map;for(let[a,o]of t)o===null&&!n.has(a)||i.set(a,M.isResourceFormat(r?.get(a))||e?.npmBinaries?.has(a)?`resource`:`source`);return Kn.set(t,i),i}function rr(e){let t=Z(e),n=e?.kind===`stasis`?e.bundle?.formats:null;if(!n||n.size===0)return t;if(Gn.has(t))return Gn.get(t);let r=new Map;for(let[e,i]of t)M.isResourceFormat(n.get(e))||r.set(e,i);return Gn.set(t,r),r}function ir(e){if(e?.kind!==`stasis`||!e.bundle?.modules)return null;let t=new Map;for(let[n,r]of e.bundle.modules)for(let e of Object.keys(r.files))t.set(n===`.`?e:`${n}/${e}`,n);return t}function ar(e,t=null,n=(e,t)=>t.name){let r=new Map;if(e?.kind!==`stasis`||!e.bundle?.modules)return r;let i=t===null?null:ir(e),a=t===null?null:new Set([...t].map(e=>i?.get(e)));for(let[t,i]of e.bundle.modules){if(a&&!a.has(t)||!t.includes(`node_modules`)||!i?.name||typeof i.version!=`string`||!i.version)continue;let e=n(t,i),o=r.get(e);o||(o=new Set,r.set(e,o)),o.add(i.version)}return r}var or=Object.freeze({javascript:`JavaScript`,jsx:`JSX`,typescript:`TypeScript`,tsx:`TSX`,json:`JSON`,css:`CSS`,markup:`HTML`,yaml:`YAML`,bash:`Shell`,markdown:`Markdown`,solidity:`Solidity`,php:`PHP`,rust:`Rust`,ruby:`Ruby`,java:`Java`,cpp:`C++`,c:`C`,objectivec:`Objective-C`,python:`Python`,go:`Go`,kotlin:`Kotlin`,swift:`Swift`,dart:`Dart`,sql:`SQL`,lua:`Lua`,csharp:`C#`,scala:`Scala`,vue:`Vue`,svelte:`Svelte`}),sr=Object.freeze({py:`python`,pyw:`python`,go:`go`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,dart:`dart`,sql:`sql`,lua:`lua`,cs:`csharp`,scala:`scala`,sc:`scala`,vue:`vue`,svelte:`svelte`});function cr(e){let t=typeof e==`string`?e.slice(e.lastIndexOf(`/`)+1):``,n=t.lastIndexOf(`.`),r=n>0?t.slice(n+1).trim().toLowerCase():``,i=a(e)??sr[r];return i?{key:i,label:or[i]??i}:r?{key:`extension:${r}`,label:`.${r}`}:{key:`other`,label:`Other`}}function lr(e,t){let n=new Map,r=0,i=0;for(let[a,o]of e){let e=cr(a),s=n.get(e.key)??{...e,files:0,lines:0,bytes:0};s.files++,s.lines+=o,s.bytes+=t.get(a)??0,n.set(e.key,s),i+=o,r+=t.get(a)??0}return{files:e.size,lines:i,bytes:r,languages:[...n.values()].toSorted((e,t)=>t.lines-e.lines||e.label.localeCompare(t.label))}}var ur=6,Q=new WeakMap,dr=new Set([`terminal`,`code`,`search`,`compare`]);function fr(e,t=null){return!!t||dr.has(e)}var pr=/^sha512-[A-Za-z0-9+/]{86}==$/u;function mr(t){if(t.fileHashes)return Promise.resolve(t.fileHashes);if(Q.has(t))return Q.get(t);let n=(async()=>{let n=[...X(t)],r=new Map;for(let t=0;t<n.length;t+=32){let i=await Promise.all(n.slice(t,t+32).map(async([t,n])=>[t,await e(n)]));for(let[e,t]of i)r.set(e,t)}return t.fileHashes=r,r})();return Q.set(t,n),n.catch(()=>Q.delete(t)),n}function hr(e){if(typeof e!=`string`)return 0;let t=/\S/gu,n=/[\r\n]/gu,r=0;for(;t.test(e)&&(r++,n.lastIndex=t.lastIndex,n.test(e));)t.lastIndex=n.lastIndex;return r}function gr(e){return e.lineCounts??=new Map([...X(e)].map(([e,t])=>[e,hr(t)]))}function $(e){return e instanceof Map?Object.fromEntries([...e].map(([e,t])=>[e,$(t)])):e}async function _r(e){let n=await mr(e),r=Z(e),i=gr(e),a={version:ur,integrity:e.integrity,kind:e.kind,size:e.size,codeStats:lr(i,r),files:[...r].map(([e,t])=>[e,t,n.get(e)??null,i.get(e)??null])},o=tr(e);if(o.size>0&&(a.unsized=[...o]),e.kind===`sourcemap`){let{version:n,file:r,sourceRoot:i,names:o}=e.json,s=Nn(e);a.json={version:n,file:r,sourceRoot:i,sources:s.map(([e])=>e)},a.sourceSizes=s.map(([,e])=>typeof e==`string`?t(e):null),a.namesCount=e.namesCount??o?.length??null;let c=new Map(a.files.map(([e],t)=>[e,t]));a.edges=Ln(e).map(([e,t,...n])=>[c.get(e),c.get(t),...n])}else{let t=e.bundle,n={version:t.version,config:t.config,repo:t.repo,package:t.package,formats:$(t.formats),imports:$(t.imports),reason:t.reason,executable:[...t.executable]};if(t.version===0)n.sources=Object.fromEntries([...r.keys()].map(e=>[e,null]));else{let e={},r={};for(let[n,i]of t.modules){let t=n.split(`/`).includes(`node_modules`)?e:r;Object.defineProperty(t,n,{enumerable:!0,value:{name:i.name,version:i.version,ecosystem:i.ecosystem,repo:i.repo,files:Object.fromEntries(Object.keys(i.files).map(e=>[e,null]))}})}n.modules=e,t.config.scope===`full`&&(n.sources=r,n.entries=[...t.entries])}a.bundle=n}return a}function vr(e,t){if(![1,2,3,4,5,ur].includes(e?.version)||e.integrity!==t||![`stasis`,`sourcemap`].includes(e.kind)||!Number.isSafeInteger(e.size)||e.size<0||!Array.isArray(e.files))throw Error(`Invalid bundle metadata`);let n=e.version!==ur,r=e.version===1,i=new Map,a=new Map,o=new Map;for(let t of e.files){if(!Array.isArray(t)||t.length!==4&&!(r&&t.length===3))throw Error(`Invalid bundle metadata file`);let[e,n,s,c]=t;if(typeof e!=`string`||a.has(e)||n!==null&&(!Number.isSafeInteger(n)||n<0)||s!==null&&(typeof s!=`string`||!pr.test(s))||n===null&&s!==null||r&&n!==null&&s===null||c!=null&&(!Number.isSafeInteger(c)||c<0))throw Error(`Invalid bundle metadata file`);a.set(e,n),s!==null&&i.set(e,s),c!=null&&o.set(e,c)}let s=new Set(e.unsized??[]);if(e.unsized!==void 0&&(r||!Array.isArray(e.unsized)||s.size!==e.unsized.length)||[...s].some(e=>typeof e!=`string`||!a.has(e)||a.get(e)!==null))throw Error(`Invalid bundle metadata`);let c={integrity:t,kind:e.kind,size:e.size,metadataOnly:!0,fileSizes:a,fileHashes:i,lineCounts:o,unsizedFiles:s,stale:n};if(e.kind===`stasis`){c.bundle=M.parse(JSON.stringify(e.bundle));let t=c.bundle.sources;if(t.size!==a.size||[...t.keys()].some(e=>!a.has(e)))throw Error(`Invalid bundle metadata inventory`);let n=c.bundle.formats;if(!r&&[...a].some(([e,t])=>i.has(e)!==(t!==null&&!M.isResourceFormat(n.get(e))))||[...s].some(e=>n.get(e)!==`resource:base64`))throw Error(`Invalid bundle metadata inventory`)}else{if(!e.json||typeof e.json!=`object`||![null,void 0].includes(e.namesCount)&&(!Number.isSafeInteger(e.namesCount)||e.namesCount<0))throw Error(`Invalid sourcemap metadata`);if(!Array.isArray(e.json.sources)||e.json.sources.some(e=>!a.has(e))||!Array.isArray(e.sourceSizes)||e.sourceSizes.length!==e.json.sources.length||e.sourceSizes.some(e=>e!==null&&(!Number.isSafeInteger(e)||e<0))||[...a].some(([e,t])=>i.has(e)!==(t!==null))||s.size>0)throw Error(`Invalid sourcemap inventory`);c.json=e.json,c.sourceSizes=e.sourceSizes,c.namesCount=e.namesCount,e.edges!==void 0&&(c.edges=yr(e.edges,e.files))}if(e.codeStats===void 0)c.codeStats=lr(o,a);else{let t=e.codeStats,n=e=>Number.isSafeInteger(e)&&e>=0;if(!t||![t.files,t.lines,t.bytes].every(n)||!Array.isArray(t.languages)||t.languages.some(e=>!e||typeof e.key!=`string`||typeof e.label!=`string`||![e.files,e.lines,e.bytes].every(n)))throw Error(`Invalid bundle code stats`);c.codeStats=t}return c}function yr(e,t){if(!Array.isArray(e))throw Error(`Invalid sourcemap edges`);return e.map(e=>{if(!Array.isArray(e)||![2,3].includes(e.length)||e[0]===e[1]||e.length===3&&typeof e[2]!=`string`||e.slice(0,2).some(e=>!Number.isSafeInteger(e)||e<0||e>=t.length))throw Error(`Invalid sourcemap edges`);return[t[e[0]][0],t[e[1]][0],...e.slice(2)]})}function br(e,{integrity:t,kind:n,size:r}){if(n===`stasis`)return{integrity:t,kind:n,size:r,bundle:M.parse(e)};if(n!==`sourcemap`)throw Error(`Unsupported bundle format`);return{integrity:t,kind:n,size:r,...Mn(e)}}export{a,lr as b,Ue as c,M as d,Bn as e,Vn as f,X as g,qn as h,Yn as i,Xn as j,Zn as k,er as l,Z as m,nr as n,rr as o,ir as p,ar as q,fr as r,mr as s,hr as t,gr as u,_r as v,vr as w,br as x};
6
+ `,n+1))t++;return t}var Jn=new WeakMap;function Yn(e){let t=Jn.get(e);if(!t){let n=[...e.keys()].toSorted();t={paths:n,numbers:new Map(n.map((e,t)=>[e,t+1]))},Jn.set(e,t)}return t}function Xn(e,t){let n=Array.isArray(t)?t:[];return{integrity:e.integrity,kind:`sourcemap`,size:e.size,json:{version:3,sources:n.map(([e])=>e),sourcesContent:n.map(([,,e])=>typeof e==`string`?e:null)},fileSizes:new Map(n.map(([e,t])=>[e,t])),npmBinaries:new Map(n.filter(([,,e,t])=>typeof e!=`string`&&typeof t==`string`).map(([e,t,,n])=>[e,{size:t,digest:n}]))}}function Zn(e){let t=e?.bundle??e?.json;if(t&&Un.has(t))return Un.get(t);let n=new Map(X(e));for(let[t,r]of e?.npmBinaries??[])n.set(t,{format:`digest`,...r});if(e?.kind===`stasis`&&e.bundle){let t=e.bundle.formats;for(let[r,i]of e.bundle.sources){if(typeof i!=`string`)continue;let e=t?.get(r);e===`resource`?n.set(r,i):e===`resource:base64`&&n.set(r,{format:`base64`,data:i})}}return t&&Un.set(t,n),n}var Qn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function $n(e){let t=e.endsWith(`=`);if(t?e.length%4!=0||e.at(-3)===`=`:e.length%4==1)return null;let n=t?e.slice(0,e.endsWith(`==`)?-2:-1):e;if(/[^A-Za-z0-9+/]/u.test(n))return null;let r=n.length%4;return r>1&&Qn.indexOf(n.at(-1))&(r===2?15:3)?null:Math.floor(n.length*3/4)}function er(e){return typeof e==`string`?t(e):e?.format===`digest`?e.size:e?.format===`base64`?$n(e.data):null}function Z(e){if(e?.fileSizes)return e.fileSizes;let t=e?.bundle??e?.json;if(t&&Wn.has(t))return Wn.get(t);let n=new Map,r=Zn(e),i=e?.kind===`stasis`?e.bundle?.sources.keys():e&&Nn(e).map(([e])=>e);for(let e of i??[])n.set(e,er(r.get(e)));return t&&Wn.set(t,n),n}function tr(e){if(e?.metadataOnly)return e.unsizedFiles??new Set;let t=Z(e);if(Y.has(t))return Y.get(t);let n=new Set;for(let r of Zn(e).keys())t.get(r)===null&&n.add(r);return Y.set(t,n),n}function nr(e){let t=Z(e);if(Kn.has(t))return Kn.get(t);let n=tr(e),r=e?.kind===`stasis`?e.bundle?.formats:null,i=new Map;for(let[a,o]of t)o===null&&!n.has(a)||i.set(a,M.isResourceFormat(r?.get(a))||e?.npmBinaries?.has(a)?`resource`:`source`);return Kn.set(t,i),i}function rr(e){let t=Z(e),n=e?.kind===`stasis`?e.bundle?.formats:null;if(!n||n.size===0)return t;if(Gn.has(t))return Gn.get(t);let r=new Map;for(let[e,i]of t)M.isResourceFormat(n.get(e))||r.set(e,i);return Gn.set(t,r),r}var ir=new WeakMap;function ar(e){if(e?.kind!==`stasis`||!e.bundle?.modules)return null;if(ir.has(e.bundle))return ir.get(e.bundle);let t=new Map;for(let[n,r]of e.bundle.modules)for(let e of Object.keys(r.files))t.set(n===`.`?e:`${n}/${e}`,n);return ir.set(e.bundle,t),t}function or(e,t=null,n=(e,t)=>t.name){let r=new Map;if(e?.kind!==`stasis`||!e.bundle?.modules)return r;let i=t===null?null:ar(e),a=t===null?null:new Set([...t].map(e=>i?.get(e)));for(let[t,i]of e.bundle.modules){if(a&&!a.has(t)||!t.includes(`node_modules`)||!i?.name||typeof i.version!=`string`||!i.version)continue;let e=n(t,i),o=r.get(e);o||(o=new Set,r.set(e,o)),o.add(i.version)}return r}var sr=Object.freeze({javascript:`JavaScript`,jsx:`JSX`,typescript:`TypeScript`,tsx:`TSX`,json:`JSON`,css:`CSS`,markup:`HTML`,yaml:`YAML`,bash:`Shell`,markdown:`Markdown`,solidity:`Solidity`,php:`PHP`,rust:`Rust`,ruby:`Ruby`,java:`Java`,cpp:`C++`,c:`C`,objectivec:`Objective-C`,python:`Python`,go:`Go`,kotlin:`Kotlin`,swift:`Swift`,dart:`Dart`,sql:`SQL`,lua:`Lua`,csharp:`C#`,scala:`Scala`,vue:`Vue`,svelte:`Svelte`}),cr=Object.freeze({py:`python`,pyw:`python`,go:`go`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,dart:`dart`,sql:`sql`,lua:`lua`,cs:`csharp`,scala:`scala`,sc:`scala`,vue:`vue`,svelte:`svelte`});function lr(e){let t=typeof e==`string`?e.slice(e.lastIndexOf(`/`)+1):``,n=t.lastIndexOf(`.`),r=n>0?t.slice(n+1).trim().toLowerCase():``,i=a(e)??cr[r];return i?{key:i,label:sr[i]??i}:r?{key:`extension:${r}`,label:`.${r}`}:{key:`other`,label:`Other`}}function ur(e,t){let n=new Map,r=0,i=0;for(let[a,o]of e){let e=lr(a),s=n.get(e.key)??{...e,files:0,lines:0,bytes:0};s.files++,s.lines+=o,s.bytes+=t.get(a)??0,n.set(e.key,s),i+=o,r+=t.get(a)??0}return{files:e.size,lines:i,bytes:r,languages:[...n.values()].toSorted((e,t)=>t.lines-e.lines||e.label.localeCompare(t.label))}}var dr=6,Q=new WeakMap,fr=new Set([`terminal`,`code`,`search`,`compare`]);function pr(e,t=null){return!!t||fr.has(e)}var mr=/^sha512-[A-Za-z0-9+/]{86}==$/u;function hr(t){if(t.fileHashes)return Promise.resolve(t.fileHashes);if(Q.has(t))return Q.get(t);let n=(async()=>{let n=[...X(t)],r=new Map;for(let t=0;t<n.length;t+=32){let i=await Promise.all(n.slice(t,t+32).map(async([t,n])=>[t,await e(n)]));for(let[e,t]of i)r.set(e,t)}return t.fileHashes=r,r})();return Q.set(t,n),n.catch(()=>Q.delete(t)),n}function gr(e){if(typeof e!=`string`)return 0;let t=/\S/gu,n=/[\r\n]/gu,r=0;for(;t.test(e)&&(r++,n.lastIndex=t.lastIndex,n.test(e));)t.lastIndex=n.lastIndex;return r}function _r(e){return e.lineCounts??=new Map([...X(e)].map(([e,t])=>[e,gr(t)]))}function $(e){return e instanceof Map?Object.fromEntries([...e].map(([e,t])=>[e,$(t)])):e}async function vr(e){let n=await hr(e),r=Z(e),i=_r(e),a={version:dr,integrity:e.integrity,kind:e.kind,size:e.size,codeStats:ur(i,r),files:[...r].map(([e,t])=>[e,t,n.get(e)??null,i.get(e)??null])},o=tr(e);if(o.size>0&&(a.unsized=[...o]),e.kind===`sourcemap`){let{version:n,file:r,sourceRoot:i,names:o}=e.json,s=Nn(e);a.json={version:n,file:r,sourceRoot:i,sources:s.map(([e])=>e)},a.sourceSizes=s.map(([,e])=>typeof e==`string`?t(e):null),a.namesCount=e.namesCount??o?.length??null;let c=new Map(a.files.map(([e],t)=>[e,t]));a.edges=Ln(e).map(([e,t,...n])=>[c.get(e),c.get(t),...n])}else{let t=e.bundle,n={version:t.version,config:t.config,repo:t.repo,package:t.package,formats:$(t.formats),imports:$(t.imports),reason:t.reason,executable:[...t.executable]};if(t.version===0)n.sources=Object.fromEntries([...r.keys()].map(e=>[e,null]));else{let e={},r={};for(let[n,i]of t.modules){let t=n.split(`/`).includes(`node_modules`)?e:r;Object.defineProperty(t,n,{enumerable:!0,value:{name:i.name,version:i.version,ecosystem:i.ecosystem,repo:i.repo,files:Object.fromEntries(Object.keys(i.files).map(e=>[e,null]))}})}n.modules=e,t.config.scope===`full`&&(n.sources=r,n.entries=[...t.entries])}a.bundle=n}return a}function yr(e,t){if(![1,2,3,4,5,dr].includes(e?.version)||e.integrity!==t||![`stasis`,`sourcemap`].includes(e.kind)||!Number.isSafeInteger(e.size)||e.size<0||!Array.isArray(e.files))throw Error(`Invalid bundle metadata`);let n=e.version!==dr,r=e.version===1,i=new Map,a=new Map,o=new Map;for(let t of e.files){if(!Array.isArray(t)||t.length!==4&&!(r&&t.length===3))throw Error(`Invalid bundle metadata file`);let[e,n,s,c]=t;if(typeof e!=`string`||a.has(e)||n!==null&&(!Number.isSafeInteger(n)||n<0)||s!==null&&(typeof s!=`string`||!mr.test(s))||n===null&&s!==null||r&&n!==null&&s===null||c!=null&&(!Number.isSafeInteger(c)||c<0))throw Error(`Invalid bundle metadata file`);a.set(e,n),s!==null&&i.set(e,s),c!=null&&o.set(e,c)}let s=new Set(e.unsized??[]);if(e.unsized!==void 0&&(r||!Array.isArray(e.unsized)||s.size!==e.unsized.length)||[...s].some(e=>typeof e!=`string`||!a.has(e)||a.get(e)!==null))throw Error(`Invalid bundle metadata`);let c={integrity:t,kind:e.kind,size:e.size,metadataOnly:!0,fileSizes:a,fileHashes:i,lineCounts:o,unsizedFiles:s,stale:n};if(e.kind===`stasis`){c.bundle=M.fromJSON(e.bundle);let t=c.bundle.sources;if(t.size!==a.size||[...t.keys()].some(e=>!a.has(e)))throw Error(`Invalid bundle metadata inventory`);let n=c.bundle.formats;if(!r&&[...a].some(([e,t])=>i.has(e)!==(t!==null&&!M.isResourceFormat(n.get(e))))||[...s].some(e=>n.get(e)!==`resource:base64`))throw Error(`Invalid bundle metadata inventory`)}else{if(!e.json||typeof e.json!=`object`||![null,void 0].includes(e.namesCount)&&(!Number.isSafeInteger(e.namesCount)||e.namesCount<0))throw Error(`Invalid sourcemap metadata`);if(!Array.isArray(e.json.sources)||e.json.sources.some(e=>!a.has(e))||!Array.isArray(e.sourceSizes)||e.sourceSizes.length!==e.json.sources.length||e.sourceSizes.some(e=>e!==null&&(!Number.isSafeInteger(e)||e<0))||[...a].some(([e,t])=>i.has(e)!==(t!==null))||s.size>0)throw Error(`Invalid sourcemap inventory`);c.json=e.json,c.sourceSizes=e.sourceSizes,c.namesCount=e.namesCount,e.edges!==void 0&&(c.edges=br(e.edges,e.files))}if(e.codeStats===void 0)c.codeStats=ur(o,a);else{let t=e.codeStats,n=e=>Number.isSafeInteger(e)&&e>=0;if(!t||![t.files,t.lines,t.bytes].every(n)||!Array.isArray(t.languages)||t.languages.some(e=>!e||typeof e.key!=`string`||typeof e.label!=`string`||![e.files,e.lines,e.bytes].every(n)))throw Error(`Invalid bundle code stats`);c.codeStats=t}return c}function br(e,t){if(!Array.isArray(e))throw Error(`Invalid sourcemap edges`);return e.map(e=>{if(!Array.isArray(e)||![2,3].includes(e.length)||e[0]===e[1]||e.length===3&&typeof e[2]!=`string`||e.slice(0,2).some(e=>!Number.isSafeInteger(e)||e<0||e>=t.length))throw Error(`Invalid sourcemap edges`);return[t[e[0]][0],t[e[1]][0],...e.slice(2)]})}function xr(e,{integrity:t,kind:n,size:r}){if(n===`stasis`)return{integrity:t,kind:n,size:r,bundle:M.parse(e)};if(n!==`sourcemap`)throw Error(`Unsupported bundle format`);return{integrity:t,kind:n,size:r,...Mn(e)}}export{a,ur as b,Ue as c,M as d,Bn as e,Vn as f,X as g,qn as h,Yn as i,Xn as j,Zn as k,er as l,Z as m,nr as n,rr as o,ar as p,or as q,pr as r,hr as s,gr as t,_r as u,vr as v,yr as w,xr as x};