@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
@@ -5,6 +5,7 @@
5
5
  //
6
6
  // Async throughout — the store (db.ts) is async so a future non-SQLite
7
7
  // backend slots in without touching these helpers.
8
+ import { AsyncLocalStorage } from 'node:async_hooks'
8
9
  import type { ManagedConfig } from './config.ts'
9
10
  import type { ManagedDb, ManagedSession, ManagedUser, StoredUser } from './db.ts'
10
11
  import { hashToken, randomToken } from './crypto.ts'
@@ -73,19 +74,32 @@ export async function createSession(
73
74
  return { setCookie, csrfToken, userId }
74
75
  }
75
76
 
77
+ // A request's sign-in, whose presence its first read to find it records.
78
+ // Every read after it in that request (the rechecks after its reads of
79
+ // storage, GitHub or npm among them) only reads: last_seen_at was written a
80
+ // moment before, by the read that let the request in.
81
+ const requests = new AsyncLocalStorage<{ seen: boolean }>()
82
+ export function runRequestPresence<T>(work: () => T): T {
83
+ return requests.run({ seen: false }, work)
84
+ }
85
+
76
86
  // Resolve the current session (+ user) from the request's cookies, or null.
77
87
  // A view cookie resolves only to that admin's view as another user: a view
78
88
  // that has ended never falls back to the admin's own session. `own` skips the
79
89
  // view and reads the signed-in session itself.
80
- export function readSession(
90
+ export async function readSession(
81
91
  config: ManagedConfig, db: ManagedDb, cookieHeader: string | undefined, now: number, { own = false } = {},
82
92
  ): Promise<{ session: ManagedSession; user: StoredUser } | null> {
83
93
  const cookies = parseCookies(cookieHeader)
84
94
  const token = cookies.get(config.sessionCookieName)
85
- if (token == null || token === '') return Promise.resolve(null)
95
+ if (token == null || token === '') return null
86
96
  const view = own ? undefined : cookies.get(cookieName(config, VIEW_COOKIE))
87
- if (view != null && view !== '') return db.viewSessionWithUser(hashToken(view), hashToken(token), now)
88
- return db.sessionWithUser(hashToken(token), now)
97
+ const request = requests.getStore(), seen = request?.seen === true
98
+ const s = view != null && view !== ''
99
+ ? await (seen ? db.getViewSessionWithUser : db.viewSessionWithUser)(hashToken(view), hashToken(token), now)
100
+ : await (seen ? db.getSessionWithUser : db.sessionWithUser)(hashToken(token), now)
101
+ if (s && request) request.seen = true
102
+ return s
89
103
  }
90
104
 
91
105
  // Drop the session named by the request's cookie (logout). The caller also
@@ -19,10 +19,13 @@ export interface ManagedSqlDriver extends ManagedSql {
19
19
  // These operations execute exactly one SQL statement. Postgres already gives
20
20
  // that statement an atomic snapshot; an explicit BEGIN/COMMIT adds only trips.
21
21
  // Lease and cache writes coordinate through their conditional UPSERT/UPDATE alone.
22
- const SINGLE_STATEMENTS = new Set(['getReport', 'getBundle', 'getStorageRow', 'getStorageEncryption',
22
+ const SINGLE_STATEMENTS = new Set(['getReport', 'getBundle', 'getStorageRow', 'getStorageEncryption', 'getTeam', 'getComment',
23
+ 'userCanReadReport', 'userCanReadRepo', 'userCanReadRepoPath', 'userCanReadBundle', 'reportPermissionsFor', 'listComments', 'listManagedIssues',
24
+ 'listTriageHistory', 'listUsers', 'listUserOptions', 'listActivityReports', 'getRepoFullName', 'getSessionWithUser', 'getViewSessionWithUser',
25
+ 'listTriageFixes',
23
26
  'listReports', 'listBundles', 'listReadableBundleIds', 'listAllRepos', 'listSelectedRepos', 'listRepoScopesForUser', 'listTriage',
24
27
  'getFeedState', 'getWorkspaceShareFeedState', 'claimMaintenanceLease', 'finishMaintenanceLease', 'cacheRepoDefaultBranch', 'releaseBundleBuildLease',
25
- 'getUpstreamCacheEntry', 'getUpstreamCacheEntries', 'setUpstreamCacheEntry', 'setUpstreamCacheEntries', 'ensureSessionUploadKey',
28
+ 'getUpstreamCacheEntry', 'getUpstreamCacheEntries', 'getFirstUpstreamCacheEntries', 'setUpstreamCacheEntry', 'setUpstreamCacheEntries', 'ensureSessionUploadKey',
26
29
  'listGithubCommits', 'listGithubCommitTags', 'setGithubCommits', 'getAvatarKey', 'listUsersByAccount'])
27
30
  // Session presence and upload keys change only their own rows.
28
31
  const UNLOCKED_WRITES = new Set(['sessionWithUser', 'viewSessionWithUser', 'ensureSessionUploadKey'])
@@ -15,8 +15,10 @@ import { migrateStorage, reapStorageUploads } from './storage-maintenance.ts'
15
15
  // Database-only callers (notably status) must not activate byte encryption.
16
16
  export async function openManagedStorageDb(config: ManagedConfig) {
17
17
  const options = { triageHistoryLimit: config.triageHistoryLimit, storageEncryptionKey: parseStorageKey(config.storageEncryptionKey) }
18
- return config.neonUrl ? openNeonManagedDb(config.neonUrl, options)
19
- : (await import('./db.ts')).openSqliteManagedDb(config.dbPath, options)
18
+ if (!config.neonUrl) return (await import('./db.ts')).openSqliteManagedDb(config.dbPath, options)
19
+ // Serverless instances hold pooled connections only while an invocation lasts.
20
+ const attachPool = config.serverless ? (await import('@vercel/functions')).attachDatabasePool : undefined
21
+ return openNeonManagedDb(config.neonUrl, options, attachPool)
20
22
  }
21
23
 
22
24
  export async function openManagedStorage(config: ManagedConfig) {
@@ -59,6 +59,13 @@ export class TeamReportsError extends Error {
59
59
  export function teamSnapshotKey(snapshot: TeamReportAccessSnapshot): string {
60
60
  return JSON.stringify([snapshot.user.id, snapshot.user.role, snapshot.teamId, snapshot.hiddenReportId ?? null, snapshot.reports, snapshot.repositories, snapshot.linkRevision])
61
61
  }
62
+ // What a built workspace is kept by: everything its build reads, and nothing
63
+ // of who asked. A user's role and grants decide which reports (and which
64
+ // hidden preview) their snapshot holds and each one's permissions, all of it
65
+ // in the key, so members whose snapshots agree share one build.
66
+ function workspaceKey(snapshot: TeamReportAccessSnapshot): string {
67
+ return JSON.stringify([snapshot.teamId, snapshot.hiddenReportId ?? null, snapshot.reports, snapshot.repositories, snapshot.linkRevision])
68
+ }
62
69
  export async function teamSnapshot(db: ManagedDb, sessionId: string, teamId: string, reportId: string | null = null): Promise<TeamReportAccessSnapshot> {
63
70
  const snapshot = await db.getTeamReportAccessSnapshot(sessionId, Date.now(), teamId, reportId)
64
71
  if (!snapshot) throw new TeamReportsError(401, 'unauthenticated')
@@ -145,15 +152,15 @@ async function buildTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Tea
145
152
  if (outputBytes + suffix.length > MAX_REPORT_QUERY_BYTES) throw new TeamReportsError(413, 'batch-too-large')
146
153
  parts.push(suffix)
147
154
  const body = Buffer.concat(parts)
148
- retainVisibility(db, teamSnapshotKey(snapshot), visible)
149
- retainReports(db, teamSnapshotKey(snapshot), body)
155
+ retainVisibility(db, workspaceKey(snapshot), visible)
156
+ retainReports(db, workspaceKey(snapshot), body)
150
157
  return { body, visible }
151
158
  }
152
159
  const pendingWorkspaces = new WeakMap<ManagedDb, Map<string, ReturnType<typeof buildTeamWorkspace>>>()
153
160
  async function loadTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot) {
154
161
  let pending = pendingWorkspaces.get(db)
155
162
  if (!pending) { pending = new Map(); pendingWorkspaces.set(db, pending) }
156
- const key = teamSnapshotKey(snapshot)
163
+ const key = workspaceKey(snapshot)
157
164
  const existing = pending.get(key)
158
165
  if (existing) return existing
159
166
  const job = buildTeamWorkspace(db, store, snapshot)
@@ -163,7 +170,7 @@ async function loadTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Team
163
170
  // Treat the encoded body as immutable and recheck access before sending it.
164
171
  // Warm HTTP reads need neither a parsed copy nor another serialization pass.
165
172
  export async function loadTeamReportsResponse(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot): Promise<Buffer> {
166
- const cached = reportCaches.get(db)?.get(teamSnapshotKey(snapshot))
173
+ const cached = reportCaches.get(db)?.get(workspaceKey(snapshot))
167
174
  return cached ?? (await loadTeamWorkspace(db, store, snapshot)).body
168
175
  }
169
176
  export async function loadTeamReports(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot): Promise<TeamReport[]> {
@@ -172,8 +179,7 @@ export async function loadTeamReports(db: ManagedDb, store: BlobStore, snapshot:
172
179
  return (JSON.parse(body.toString('utf8')) as { reports: TeamReport[] }).reports
173
180
  }
174
181
  async function teamVisibility(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot): Promise<Visibility> {
175
- const key = teamSnapshotKey(snapshot)
176
- let visible = caches.get(db)?.get(key)
182
+ let visible = caches.get(db)?.get(workspaceKey(snapshot))
177
183
  if (!visible) {
178
184
  // A large snapshot may deliberately remain uncached, or be evicted by
179
185
  // another request. Authorization uses this load's result in either case.
@@ -191,17 +197,23 @@ export async function teamReportVisibility(db: ManagedDb, store: BlobStore, snap
191
197
  const visible = await teamVisibility(db, store, snapshot)
192
198
  return visible.get(reportId)!
193
199
  }
194
- export async function teamFindingIds(db: ManagedDb, store: BlobStore, sessionId: string, teamId: string, reportId: string): Promise<Set<string>> {
200
+ // A report's visibility for the session's current snapshot. A workspace built
201
+ // (or waited for) here outlives that snapshot's read, so the team's access is
202
+ // read again after it; one kept is answered with no read in between, which
203
+ // leaves nothing for another snapshot read to guard.
204
+ async function sessionReportVisibility(db: ManagedDb, store: BlobStore, sessionId: string, teamId: string, reportId: string): Promise<ReportVisibility> {
195
205
  const snapshot = await teamSnapshot(db, sessionId, teamId, reportId)
206
+ const kept = caches.get(db)?.get(workspaceKey(snapshot))?.get(reportId)
207
+ if (kept) return kept
196
208
  const visible = await teamReportVisibility(db, store, snapshot, reportId)
197
209
  await recheckTeam(db, sessionId, snapshot)
198
- return visible.ids
210
+ return visible
211
+ }
212
+ export async function teamFindingIds(db: ManagedDb, store: BlobStore, sessionId: string, teamId: string, reportId: string): Promise<Set<string>> {
213
+ return (await sessionReportVisibility(db, store, sessionId, teamId, reportId)).ids
199
214
  }
200
215
  export async function teamSourcePaths(db: ManagedDb, store: BlobStore, sessionId: string, teamId: string, reportId: string): Promise<Set<string>> {
201
- const snapshot = await teamSnapshot(db, sessionId, teamId, reportId)
202
- const visible = await teamReportVisibility(db, store, snapshot, reportId)
203
- await recheckTeam(db, sessionId, snapshot)
204
- return visible.sourcePaths
216
+ return (await sessionReportVisibility(db, store, sessionId, teamId, reportId)).sourcePaths
205
217
  }
206
218
 
207
219
  // Serialize shared annotation bodies once. Reports carry only the annotated
@@ -26,6 +26,9 @@ export interface UpstreamCacheStore {
26
26
  getUpstreamCacheEntry(key: string): Promise<string | null>
27
27
  // Key → value for those of `keys` that are kept.
28
28
  getUpstreamCacheEntries(keys: string[]): Promise<Map<string, string>>
29
+ // Those of `first` that are kept; where none is, those of `then`, in the
30
+ // same statement (`first` whether they are `first`'s).
31
+ getFirstUpstreamCacheEntries(first: string[], then: string[]): Promise<{ first: boolean; entries: Map<string, string> }>
29
32
  setUpstreamCacheEntry(key: string, value: string, cachedAt: number): Promise<void>
30
33
  // Each of `entries` (key, value), as setUpstreamCacheEntry keeps one, in one
31
34
  // statement: the last of a key given twice.
@@ -38,6 +41,10 @@ export interface UpstreamCacheStore {
38
41
  export function upstreamCacheMethods(db: ManagedSql): UpstreamCacheStore {
39
42
  const get = db.prepare('SELECT value FROM managed_upstream_cache WHERE cache_key = ?')
40
43
  const getMany = db.prepare('SELECT cache_key, value FROM managed_upstream_cache WHERE cache_key IN (SELECT value FROM json_each(?))')
44
+ const getFirst = db.prepare(`WITH found AS (SELECT cache_key, value FROM managed_upstream_cache WHERE cache_key IN (SELECT value FROM json_each(?)))
45
+ SELECT cache_key, value, 1 AS in_first FROM found
46
+ UNION ALL SELECT cache_key, value, 0 AS in_first FROM managed_upstream_cache
47
+ WHERE cache_key IN (SELECT value FROM json_each(?)) AND NOT EXISTS (SELECT 1 FROM found)`)
41
48
  // A slower concurrent audit cannot replace a newer listing with an older one.
42
49
  const set = db.prepare(`INSERT INTO managed_upstream_cache (cache_key, value, cached_at) VALUES (?, ?, ?)
43
50
  ON CONFLICT (cache_key) DO UPDATE SET value = excluded.value, cached_at = excluded.cached_at
@@ -55,6 +62,11 @@ export function upstreamCacheMethods(db: ManagedSql): UpstreamCacheStore {
55
62
  const rows = await getMany.all(JSON.stringify(keys)) as { cache_key: string; value: string }[]
56
63
  return new Map(rows.map(row => [row.cache_key, row.value]))
57
64
  },
65
+ async getFirstUpstreamCacheEntries(first, then) {
66
+ if (first.length === 0 && then.length === 0) return { first: false, entries: new Map() }
67
+ const rows = await getFirst.all(JSON.stringify(first), JSON.stringify(then)) as { cache_key: string; value: string; in_first: number }[]
68
+ return { first: rows.some(row => Number(row.in_first) === 1), entries: new Map(rows.map(row => [row.cache_key, row.value])) }
69
+ },
58
70
  async setUpstreamCacheEntry(key, value, cachedAt) {
59
71
  await set.run(key, value, cachedAt)
60
72
  },
package/server.ts CHANGED
@@ -21,20 +21,29 @@ function parseMode(mode: string): ServerMode {
21
21
  throw new Error(`Unknown mode: ${mode}. Expected ${modes.join(', ')}.`)
22
22
  }
23
23
 
24
+ export type InitOptions = {
25
+ mode?: ServerMode
26
+ // False serves only the API: `out/` is never read, nor its UI served, for
27
+ // hosts that serve the UI themselves.
28
+ ui?: boolean
29
+ }
30
+
24
31
  // Assemble the selected server without binding a port. Hosts can reuse its
25
- // request/upgrade listeners or call listen() themselves.
26
- export async function init(mode: ServerMode = 'e2e'): Promise<Server> {
32
+ // request/upgrade listeners or call listen() themselves. `init(mode)` is
33
+ // `init({ mode })`.
34
+ export async function init(options: ServerMode | InitOptions = {}): Promise<Server> {
35
+ const { mode = 'e2e', ui = true }: InitOptions = typeof options === 'string' ? { mode: options } : options
27
36
  const selected = parseMode(mode)
28
37
  if (selected === 'e2e') {
29
38
  const { createE2eApp } = await import('./server-e2e/app.ts')
30
- return (await createE2eApp()).httpServer
39
+ return (await createE2eApp(undefined, { ui })).httpServer
31
40
  }
32
41
  if (selected === 'managed') {
33
42
  const managed = await import('./server-managed/index.ts')
34
- return managed.init()
43
+ return managed.init(undefined, { ui })
35
44
  }
36
45
  const combined = await import('./server-managed/combined.ts')
37
- return combined.init(selected === 'managed-e2e' ? 'managed+e2e' : 'e2e+managed')
46
+ return combined.init(selected === 'managed-e2e' ? 'managed+e2e' : 'e2e+managed', { ui })
38
47
  }
39
48
 
40
49
  export async function start(): Promise<void> {
@@ -1,2 +0,0 @@
1
- import{f as e,g as t,h as n,l as r}from"./chunk-NPW52BM2.js";import{k as i}from"./chunk-WI7Z5A2T.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};
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-NRPC74AM.js";import{a as t,d as n,f as r,h as i}from"./chunk-7C7DWL7I.js";import{d as a}from"./chunk-PNHBZGDD.js";import{a as o,b as s}from"./chunk-I2MDGSQX.js";import{c}from"./chunk-BC2UCLFJ.js";import{C as l,D as u,G as d,J as f,K as p,L as m,O as h,q as g}from"./chunk-SXV2T5C4.js";import{a as _}from"./chunk-TUII34K2.js";function v(e,t){let n=s([{groups:[e],tree:t.tree}]);for(let r of e)l(r,t),r.isApp??=g(r,r.source??t.source),r._depsDirectory=n}function y(e,t){return!(e.isApp??g(e,e._source??e.source))&&o(e.file,e._depsDirectory??t??s([{groups:[[e]]}]))}function b(e,n,r){let i=t(n);return i===`ignored`&&y(e,r)?void 0:i}function ee(e,n,a,o){let s=n.id??String(n._id),c=n._reportName??``;y(n,o)&&(a===`ignored`||a===`untriaged`)?(t(e.get(s))!==`ignored`&&r(e,s,{triage:void 0}),i(e,s,c,a===`ignored`,!0)):(r(e,s,{triage:a===`untriaged`?void 0:a}),a!==`ignored`&&a!==`untriaged`&&i(e,s,c,!1))}function x(e,a){if(![...e.values()].some(e=>e?.ignoredReports?.length))return!1;let o=!1;for(let c of a){let a=s([c]),l=(c.groups??[]).flat(),u=e=>({...e,_source:e._source??e.source??c.source}),d=new Set(l.filter(e=>y(u(e),a)).map(e=>e.id??String(e._id)));for(let s of l){let l=s.id??String(s._id),f=s._reportName??c.name??c.fileName??``,p=e.get(l);p?.ignoredReports?.includes(f)&&(n(p,f)||y(u(s),a)||(t(p)||(o=r(e,l,{triage:`ignored`})||o),d.has(l)||(o=i(e,l,f,!1)||o)))}for(let t of l){if(!y(u(t),a))continue;let n=t.id??String(t._id),r=t._reportName??c.name??c.fileName??``;e.get(n)?.ignoredReports?.includes(r)&&(o=i(e,n,r,!0,!0)||o)}}return o}async function S(e,t){let r=new Set(Object.values(e??{}).flatMap(e=>Array.isArray(e?.ignoredReports)?e.ignoredReports.filter(t=>typeof t==`string`&&!n(e,t)):[])),i=[];for(let e of r){let n;try{let r=await t(e);if(typeof r!=`string`)continue;n=await h(r)}catch{continue}n&&i.push({...n.data,name:e,groups:[n.findings]})}return i}async function C(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))return{entries:e,changed:!1};let n=new Map(Object.entries(e??{})),r=x(n,await S(e,t));return{entries:Object.fromEntries(n),changed:r}}var w=1,T=16,E=12,D=1+T+E+16,O=1+T+E;async function k(e,t){let n=await crypto.subtle.importKey(`raw`,_(e),`PBKDF2`,!1,[`deriveKey`]);return crypto.subtle.deriveKey({name:`PBKDF2`,hash:`SHA-256`,salt:t,iterations:3e6},n,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}function A(e){return!(e instanceof Uint8Array)||e.length<D?!1:e[0]===w}async function j(e,t){if(!(e instanceof Uint8Array))throw TypeError(`encryptWithPassword: plaintext Uint8Array required`);if(typeof t!=`string`||!t)throw TypeError(`encryptWithPassword: password required`);let n=new Uint8Array(O+e.length+16);n[0]=w,crypto.getRandomValues(n.subarray(1,1+T)),crypto.getRandomValues(n.subarray(1+T,O));let r=n.subarray(1,1+T),i=n.subarray(1+T,O),a=await k(t,r),o=new Uint8Array(await crypto.subtle.encrypt({name:`AES-GCM`,iv:i,additionalData:n.subarray(0,O)},a,e));return n.set(o,O),n}async function M(e,t){if(typeof t!=`string`||!t)throw TypeError(`tryDecryptWithPassword: password required`);if(!(e instanceof Uint8Array)||e.length<D||e[0]!==w)return{ok:!1,reason:`malformed`};let n=e.subarray(1,1+T),r=e.subarray(1+T,O),i=e.subarray(O),a=await k(t,n),o;try{o=new Uint8Array(await crypto.subtle.decrypt({name:`AES-GCM`,iv:r,additionalData:e.subarray(0,O)},a,i))}catch{return{ok:!1,reason:`wrong-password`}}return{ok:!0,plaintext:o}}async function N(e,t,n){if(!n||typeof n.malformedMsg!=`string`||typeof n.wrongPasswordMsg!=`string`)throw TypeError(`decryptWithPasswordOrThrow: { malformedMsg, wrongPasswordMsg } strings required`);let r=await M(e,t);if(r.ok)return r.plaintext;throw r.reason===`wrong-password`?Error(n.wrongPasswordMsg):Error(n.malformedMsg)}var P=A,F=j;function te(e,t){return N(e,t,{malformedMsg:`malformed encrypted bundle`,wrongPasswordMsg:`wrong password or corrupt bundle`})}var ne=1,I=1024,L=1024,R=200,z=104857600,B=Math.ceil(z*4/3)+16,V=512,H=64;function U(e){if(!e||typeof e!=`object`)return`payload is not an object`;if(e.version!==ne)return`unsupported export version: ${e.version}`;if(!e.workspace||typeof e.workspace!=`object`)return`workspace metadata missing`;if(typeof e.workspace.id!=`string`)return`workspace.id must be a string`;if(typeof e.workspace.name!=`string`)return`workspace.name must be a string`;if(typeof e.workspace.privateKey!=`string`)return`workspace.privateKey must be a string`;if(e.workspace.createdAt!==void 0&&!Number.isFinite(e.workspace.createdAt))return`workspace.createdAt must be a finite number or omitted`;if(!Array.isArray(e.reports))return`reports field must be an array`;if(e.reports.length>L)return`reports count (${e.reports.length}) exceeds cap (${L})`;if(e.bundles!==void 0){if(!Array.isArray(e.bundles))return`bundles field must be an array when present`;if(e.bundles.length>I)return`bundles count (${e.bundles.length}) exceeds cap (${I})`;for(let t of e.bundles){if(typeof t!=`string`)return`bundles entries must be strings`;if(t.length>R)return`bundle integrity exceeds per-entry length cap (${R})`}}if(e.bundleBlobs!==void 0){if(!Array.isArray(e.bundleBlobs))return`bundleBlobs field must be an array when present`;if(e.bundleBlobs.length>H)return`bundleBlobs count (${e.bundleBlobs.length}) exceeds cap (${H})`;for(let t of e.bundleBlobs){if(!t||typeof t!=`object`||Array.isArray(t))return`bundleBlobs entries must be objects`;if(typeof t.integrity!=`string`||t.integrity.length===0)return`bundleBlobs.integrity must be a non-empty string`;if(t.integrity.length>R)return`bundleBlobs.integrity exceeds per-entry length cap (${R})`;if(typeof t.name!=`string`||t.name.length===0)return`bundleBlobs.name must be a non-empty string`;if(t.name.length>V)return`bundleBlobs.name exceeds per-entry length cap (${V})`;if(t.name.includes(`\0`))return`bundleBlobs.name cannot contain NUL`;if(typeof t.data!=`string`)return`bundleBlobs.data must be a base64 string`;if(t.data.length>B)return`bundleBlobs.data exceeds per-blob size cap (${z} bytes raw)`}}return null}async function W(e){return new Uint8Array(await e.arrayBuffer())}async function G(e,t){if(P(e)){if(typeof t!=`string`||!t)throw TypeError(`parseWorkspaceBundleBytes: password required for encrypted bundle`);let n=await te(e,t);try{return K(await a(n))}catch(e){throw Error(`wrong password or corrupt bundle`,{cause:e})}}let n;try{n=await a(e)}catch(e){throw Error(`gzip decompression failed: ${e.message}`,{cause:e})}return K(n)}function K(e){let t;try{t=JSON.parse(e)}catch(e){throw Error(`payload is not JSON: ${e.message}`,{cause:e})}let n=U(t);if(n===null)return t;let r=n.includes(`exceeds cap`);throw Error(r?n:`not a deepview workspace export: ${n}`)}var q=`links`;function J(e){if(typeof e==`string`)return e.length>0?e:null;if(!e||typeof e!=`object`||Array.isArray(e))return null;let{id:t}=e;return typeof t==`string`&&t.length>0?t:null}function Y(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Array.isArray(t)||t.length===0)return null;let n=[],r=0;for(let e of t){if(!Array.isArray(e))return null;let t=new Set;for(let n of e){let e=J(n);if(e===null)return null;c(e)?t.add(e):r++}t.size>1&&n.push([...t])}return{groups:n,skipped:r}}function X(e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t.size}function re(e,t){for(let n of e)for(let e of n){let r=t.get(e);r||t.set(e,r=new Set);for(let t of n)t!==e&&r.add(t)}return t}function Z(e,t){let n=e.trimStart().startsWith(`[`)?Y(e):null;if(n)return{data:{source:`links`,findings:[],links:n.groups},format:`links`,reason:null};let r=m(e);if(r.data!=null||p(e,t)!==`codex`)return r;try{return{data:{type:`security`,source:`codex-security`,findings:d(e).flatMap(e=>e.data.findings)},format:`codex`,reason:null}}catch(e){return{data:null,format:null,reason:e instanceof Error?e.message:`Invalid Codex CSV`}}}function Q(e,t){let n=Z(e,t);return n.data==null?Promise.resolve(null):h(JSON.stringify(n.data))}function ie(e){let t=new Set;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.file==`string`&&e.file&&t.add(e.file);for(let n of Array.isArray(e.evidence)?e.evidence:[])typeof n?.file==`string`&&n.file&&t.add(n.file)}return t}function $(e){let t=(f(e)??[]).flat().filter(e=>typeof e==`object`&&!!e),n=s([{groups:[t],tree:e?.tree}]);return{directory:n,own:t.filter(e=>!o(e.file,n))}}function ae(e){let t=new Map;for(let n of $(e).own){let e=u(n);e&&t.set(e.toLowerCase(),e)}return t.size===1?[...t.values()][0]:null}function oe(t){let{directory:n,own:r}=$(t);return e([...ie(r)].filter(e=>!o(e,n)))}var se=[`inprogress`,`fixed`,`invalid`,`deleted`,`ignored`];function ce(e){return typeof e==`string`&&se.includes(e)}function le(e){if(e===null)return null;if(typeof e!=`object`||Array.isArray(e))return`invalid`;let t=e,n={},r=t.color;if(r!=null){if(typeof r!=`string`||r.length>50)return`invalid`;r!==``&&(n.color=r)}let i=t.triage;if(i!=null){if(!ce(i))return`invalid`;n.triage=i}for(let e of[`comment`,`fix`]){let r=t[e];if(r!=null){if(typeof r!=`string`||r.length>1e4)return`invalid`;r!==``&&(n[e]=r)}}let a=t.flagged;if(a!=null){if(typeof a!=`boolean`)return`invalid`;n.flagged=a}return n}export{v as a,y as b,b as c,ee as d,x as e,S as f,C as g,j as h,N as i,P as j,F as k,L as l,W as m,G as n,K as o,q as p,Y as q,X as r,re as s,Z as t,Q as u,ae as v,oe as w,le as x};
@@ -1,36 +0,0 @@
1
- import{b as e,h as t}from"./chunk-I2MDGSQX.js";import{a as n}from"./chunk-3PS4KWD2.js";import{a as r,b as i,e as a}from"./chunk-IYPY47MC.js";import{A as o,B as s,E as c,b as l,c as u,d,j as f,m as p,p as m,s as h,t as g,w as _,z as v}from"./chunk-SXV2T5C4.js";import{A as ee,b as y,c as b,i as te,w as x,y as S}from"./chunk-WFYLMF6Z.js";import{a as C,b as w,c as T}from"./chunk-C4Z6ZBXV.js";import{c as E,f as D,g as O,i as ne}from"./chunk-2XUEZHIP.js";function k(e){return e.id??String(e._id)}function re(e){let t=m(e);return t!==``&&t!==`revalidation`}var ie=[{value:`confirmed`,label:`Confirmed`,kinds:[`confirmed`,`partial`,`revalidation`]},{value:`unreachable`,label:`Unreachable`,kinds:[`unreachable`]},{value:`refuted`,label:`Refuted`,kinds:[`refuted`]}];function ae(e){return ie.find(t=>t.value===e)?.kinds??null}var oe=[``,`exclude`,`only`];function A(e,t){let n=ae(e);return n?.includes(`partial`)?t===`only`?[`partial`]:t===`exclude`?[`confirmed`]:n:n}function j(e){if(e.confidence!==void 0)return e.confidence;if(e.critical===!0||e._source)return 10}var se=e=>e.confidence!==void 0||e.critical===!0;function ce(e){return e.every(e=>e.every(e=>j(e)!==void 0))&&e.some(e=>e.some(se))}function le(e,t,n){return e.some(e=>{let r=[`refuted`,`unreachable`].includes(n(e))?0:j(e);return r===void 0?t===0:r>=t})}function ue(e,t){let n=e.map(t).filter(e=>e.length>0);if(!n.some(e=>e.some(e=>j(e)!==void 0)))return 0;let r=e=>n.reduce((t,n)=>t+ +!!n.some(t=>(j(t)??-1)>=e),0),i;for(i=r(6)<=25?6:r(7)<=25?7:8;i>0&&r(i-1)===r(i);)i--;return i}function de(e,t){return ce(e)?t:0}function fe(e,t,n){let r=new Set(e.ruledOutIds??[]);for(let t of e)for(let e of t)[`refuted`,`unreachable`].includes(n(e))&&r.add(k(e));for(let i of e){let e=t(i);if(e.length!==0&&e.some(e=>A(`confirmed`,``).includes(n(e)||(e._source&&!e._sourcePass?`revalidation`:``)))){for(let e of i)if(r.add(k(e)),e.isApp&&Array.isArray(e.revalidateInputs))for(let t of e.revalidateInputs)t&&r.add(t)}}return r}function pe(e,t,n,r){let i=de(e,t),a=e.filter(e=>le(e,i,r));if(a.length===0)return!1;let o=new Set(A(`confirmed`,``));return e.some(e=>e.some(e=>o.has(r(e))))?a.every(e=>e.every(e=>n.has(k(e)))):!1}function me(e,{tabs:t,kindOf:n,severityMode:r}){let i=e.map(t).filter(e=>e.length>0),a=fe(e,t,n);if(!pe(i,ue(e,t),a,n))return!1;let o=de(i,6);return i.every(e=>!le(e,o,n)||!e.some(e=>p(e,r)!==`low`)||e.every(e=>a.has(k(e))))}var M=!0;function he(e,t=!1){M=e!==!1&&!t}function ge(){return M}function N(e){return M?m(e):``}function _e(e){return m(e)!==``}function ve(e){return e.some(e=>(e.groups??[]).some(e=>e.some(re)))}function ye(e){let t=N(e);return t&&t!==`revalidation`?t:null}function be(e){return N(e)===`revalidation`}var xe=new Set([`refuted`,`unreachable`]);function Se(e){return xe.has(N(e))}function Ce(e){return xe.has(N(e))}function we(e){let t=new Set(e);return ie.filter(e=>e.kinds.some(e=>t.has(e)))}function P(e){return RegExp(`(^|/)${e}/`,`u`)}function Te(e){return RegExp(`^(?:.*/)?${e}/(?:@[^/]+/[^/]+|[^/]+)/(.*)$`,`u`)}var Ee=P(`node_modules`),De=P(`vendor`),F=`node_modules`,Oe=P(F),ke=Te(F);function Ae(e){e!==F&&(F=e,Oe=P(e),ke=Te(e))}function je(t){Ae(e(t))}function Me(){return F}function I(e){return Oe.test(e)}var L=new WeakSet;function Ne(e){let t=!1;for(let n of e??[])for(let e of n.groups??[])for(let n of e){if(n.isApp!==!1)continue;let e=L.has(n);`isUpstream`in n&&!e||(I(n.file)?(n.isUpstream!==!0&&(t=!0),n.isUpstream=!0,L.add(n)):e&&(t=!0,delete n.isUpstream,L.delete(n)))}return t}function Pe(e){let t=typeof e==`string`?e:``;return Ee.test(t)||De.test(t)||Oe.test(t)}var Fe=/^(.*(?:^|\/)node_modules\/(?:@[^/]+\/[^/]+|[^/]+))(?:\/|$)/u;function Ie(e){return Fe.exec(typeof e==`string`?e:``)?.[1]??null}function Le(e){return typeof e!=`number`||!Number.isFinite(e)?null:n(e)}function Re(e){if(e.length<=1)return{prefix:``,stripped:[...e]};let t=e.map(e=>e.split(`/`)),n=Math.min(...t.map(e=>e.length)),r=0;for(let e=0;e<n-1&&t.every(n=>n[e]===t[0][e]);e++)r=e+1;return r>0&&t[0][r-1].startsWith(`@`)&&r--,r>0&&t[0][r-1]===`node_modules`&&r--,r===0?{prefix:``,stripped:[...e]}:{prefix:`${t[0].slice(0,r).join(`/`)}/`,stripped:t.map(e=>e.slice(r).join(`/`))}}function ze(e){return e.match(ke)?.[1]??e}function Be(e){let t=M?[ye(e),e.revalidateVerdict,e.revalidateRecommendation]:[];return[e.file,e.title,e.description,e.impact,e.reproduction,xt(e),e.recommendation,e.confidenceReason,...t,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
2
- `).toLowerCase()}function Ve(e){return[typeof e?.category==`string`?e.category.trim():``,h(e,M)].filter(Boolean).join(` · `)}function He(e){if(e.length===0)return``;let t=e[0];for(let n=1;n<e.length;n++){for(;t&&!e[n].startsWith(t);)t=t.slice(0,-1);if(!t)return``}return t}function Ue(e){if(!e)return``;let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function We(e){if(!e)return null;let t=e.trim().replace(/\/$/u,``);return t?/^https?:\/\//iu.test(t)?t:/^github\.com\//iu.test(t)?`https://${t}`:`https://github.com/${t}`:null}var Ge=/^(?:@[\w.-]+\/)?[\w.-]+@[^/\s@]+$/u;function Ke(e){return Ge.test(e||``)}function qe(e){if(e==null||typeof e==`string`)return{id:e??``,prefix:``};let t=c(e);return{id:typeof e.github==`string`?e.github:``,prefix:t?`${t}/`:``}}function Je(e,t,n){if(Ke(e))return null;let r=qe(t);if(r.id)return`https://github.com/${r.id}/blob/HEAD/${r.prefix}${ze(e)}`;if(I(e))return null;let i=qe(n),a=We(i.id);return a?`${a}/blob/HEAD/${i.prefix}${e}`:null}function Ye(e,t){let n=e?.file??``,r=R(e,t);return r?E`<a href="${Xe(r)}" target="_blank" rel="noopener">${n}</a>`:n}function Xe(e){return e.replace(/#L\d+(?:-L?\d+)?$/u,``)}function R(e,t){if(!e)return null;if(s(e.location))return e.location;let n=Je(e.file,e.repo,t);if(!n)return null;let r=parseInt(e.line,10);return Number.isFinite(r)?`${n}#L${r}`:n}var Ze=/^https?:\/\/(?:www\.)?github\.com\/([^/\s]+\/[^/\s]+)\/(?:blob|tree|blame)\/[^/\s]+\/(\S+)$/u,Qe=/#L(\d+)(?:-L?(\d+))?$/u;function $e(e){let t=typeof e==`string`?Ze.exec(e):null;if(!t)return``;let n=t[2],r=Qe.exec(n);if(!r)return`${t[1]}/${n}`;n=n.slice(0,r.index);let i=r[2]?`${r[1]}-${r[2]}`:r[1];return`${t[1]}/${n}:${i}`}var et=/^(?:\s+\S|[-*+] |\d+[.)] |>|#{1,6}(?:[ \t]|$)|\||`{3}|~{3})/u;function tt(e){return e.split(/(\n{2,})/u).map(e=>{if(/^\n+$/u.test(e))return e;let t=e.split(`
3
- `);return t.some(e=>et.test(e)||B.test(e))?e:t.map(e=>e.trim()).filter(Boolean).join(` `)}).join(``)}function nt(e,t,n){let r=t?/^\n*/u.exec(e)[0]:``,i=e.slice(r.length),a=n?/\n*$/u.exec(i)[0]:``;return r+tt(i.slice(0,i.length-a.length))+a}function rt(e){if(!e)return e;let t=e.replaceAll(`\r
4
- `,`
5
- `),n=l(t);if(n.length===0)return tt(t);let r=[],i=0;for(let[e,a]of n)e>i&&r.push(nt(t.slice(i,e),i>0,!0)),r.push(t.slice(e,a)),i=a;return i<t.length&&r.push(nt(t.slice(i),!0,!1)),r.join(``)}var it=/^( *)(`{3,}|~{3,})(.*)$/u,at=/^[a-z0-9+#._-]{1,20}$/u;function ot(e,t){let n=0;for(;n<t&&e[n]===` `;)n++;return e.slice(n)}function st(e){let t=e.split(`
6
- `),n=it.exec(t[0]),r=(n?.[2]??"```").slice(0,3),i=(n?.[3]??``).trim().split(/\s+/u)[0].toLowerCase(),a=!!(t.length>1?it.exec(t.at(-1)):null)?.[2].startsWith(r),o=n?.[1].length??0,s=t.slice(1,a?-1:void 0);return{lang:at.test(i)?i:``,code:(o>0?s.map(e=>ot(e,o)):s).join(`
7
- `)}}function ct(e){let t=l(e||``);if(t.length===0)return[e];let n=[],r=0,i=(e,t)=>{let r=(t?e.replace(/^\n+/u,``):e).replace(/\n+$/u,``);r&&n.push(r)};for(let[a,o]of t)a>r&&i(e.slice(r,a),r>0),n.push(st(e.slice(a,o))),r=o;return r<e.length&&i(e.slice(r),!0),n}var z=/^( *)(?:[-*+]|(\d{1,9})[.)]) +(?=\S)/u,B=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u;function lt(e){return/^ */u.exec(e)[0].length}function ut(e){let t=e.length;for(;t>0&&!e[t-1].trim();)t--;return e.slice(0,t).join(`
8
- `)}function dt(e){let t=typeof e==`string`?e:``;if(!t)return[e];let n=l(t),r=t.split(`
9
- `),i=[],a=0;for(let e of r)i.push(a),a+=e.length+1;let o=e=>!u(n,i[e])&&!B.test(r[e])&&z.test(r[e]),s=[],c=0,d=0,f=e=>{let t=r.slice(c,e).join(`
10
- `).replace(/^\n+/u,``).replace(/\n+$/u,``);t.trim()&&s.push(t)};for(;d<r.length;){if(!o(d)){d++;continue}f(d);let e=z.exec(r[d]),t=!!e[2],a=[],l=null,p=!1;for(;d<r.length;){let e=r[d];if(!u(n,i[d])){if(!e.trim()){l.lines.push(``),p=!0,d++;continue}let n=lt(e),r=B.test(e)?null:z.exec(e);if(r&&(!l||n<l.column)){if(!!r[2]!==t)break;l&&a.push(ut(l.lines)),l={column:r[0].length,lines:[e.slice(r[0].length)]},p=!1,d++;continue}if(n<l.column&&(p||ft.test(e)||B.test(e)))break}l.lines.push(ot(e,l.column)),p=!1,d++}l&&a.push(ut(l.lines)),s.push({ordered:t,start:t?Number(e[2]):null,items:a}),c=d}return s.length===0?[e]:(f(r.length),s)}var ft=/^ {0,3}(#{1,6})[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/u,pt=/^ {0,3}-+[ \t]*$/u;function mt(e){let t=e.split(`
11
- `),n=[],r=0,i=e=>{let i=t.slice(r,e).join(`
12
- `).replaceAll(/^(?:[ \t]*\n)+|(?:\n[ \t]*)+$/gu,``);i.trim()&&n.push(i)};return t.forEach((e,a)=>{let o=ft.exec(e),s=B.test(e)&&(a===r||!t[a-1].trim()||!pt.test(e));!o&&!s||(i(a),n.push(o?{level:o[1].length,text:o[2]}:{rule:!0}),r=a+1)}),n.length===0?[e]:(i(t.length),n)}var ht=/^(\d+)(?:\s*-\s*(\d+))?$/u;function V(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=1?{start:Math.floor(e),end:Math.floor(e)}:null;let t=ht.exec(String(e??``).trim());if(!t)return null;let n=parseInt(t[1],10),r=t[2]===void 0?n:parseInt(t[2],10);return!Number.isFinite(n)||n<1||!Number.isFinite(r)||r<1?null:{start:Math.min(n,r),end:Math.max(n,r)}}function gt(e){return e?e.start===e.end?String(e.start):`${e.start}-${e.end}`:``}function _t(e){if(e&&typeof e==`object`){let t=V(e.start);if(!t)return null;let n=V(e.end)??t;return{start:t.start,end:Math.max(t.start,n.end)}}return V(e)}function vt(e,t,n=4){let r=typeof e==`string`&&e!==``?e.split(`
13
- `):[];if(r.length===0)return{text:``,startLine:1,lines:[]};let i=_t(t),a=i&&{start:Math.min(i.start,r.length),end:Math.min(i.end,r.length)},o=a?Math.max(1,a.start-n):1,s=a?Math.min(r.length,a.end+n):Math.min(r.length,n*2+1),c=r.slice(o-1,s);return{text:c.join(`
14
- `),startLine:o,lines:c}}function yt(e,t,n,r){if(s(e?.url))return e.url;let i=e?.file;if(typeof i!=`string`||i===``)return null;let a=t?.file??``,o=t?.repo?.github,c=()=>o?R({file:i,line:e?.line,repo:t.repo},null):null;if(r===0&&i===a)return c();let l=Ie(i);return l!==null&&l===Ie(a)?c():Pe(i)?null:o&&!Pe(a)?c():R({file:i,line:e?.line},n)}function bt(e,{spaced:t=!1}={}){let n=Array.isArray(e?.evidence)?e.evidence:[];return n.length===0?``:n.map((e,t)=>{let n=v(e),r=[`${t+1}. ${e.url?`[${n}](${e.url})`:n}`],i=o(e);if(i)for(let e of i.split(`
15
- `))r.push(` ${e}`);return r.join(`
16
- `)}).join(t?`
17
-
18
- `:`
19
- `)}function xt(e){let t=bt(e);return t?`**Evidence:**
20
- ${t}`:``}function St(e){let t=/^\[([^\]]+)\]\(([^)\s]+)\)$/u.exec(e);return!t||!s(t[2])?null:{label:d(t[1].trim())||t[2],url:t[2]}}function Ct(e,t){let n=parseInt(e?.line,10);if(!Number.isFinite(n))return O;let r=R(e,t),i=`line ${n}`;return r?E`<a href="${r}" target="_blank" rel="noopener">${i}</a>`:i}function wt(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,``):`https://github.com/${e}`}/commit/${t}`}var Tt=[[`Impact`,`impact`],[`Reproduction`,`reproduction`],[`Recommendation`,`recommendation`],[`Confidence reason`,`confidenceReason`],[`Revalidation verdict`,`revalidateVerdict`],[`Revalidation recommendation`,`revalidateRecommendation`]];function Et(e,t){let n=[];t&&n.push(`Repo: ${t}`);let r=v(e);r&&n.push(`Location: ${r}`),e?.confidence!=null&&n.push(`Confidence: ${e.confidence}/10`);let i=N(e);i&&n.push(`Revalidation: ${i}`);let a=[];n.length>0&&a.push(n.join(`
21
- `));let{title:o,body:s}=_(e);o&&a.push(`# ${o}`),s&&a.push(s.trim());let c=bt(e,{spaced:!0});c&&a.push(`# Evidence
22
-
23
- ${c}`);for(let[t,n]of Tt){if(!M&&n.startsWith(`revalidate`))continue;let r=g(e?.[n],e)?.trim();r&&a.push(`# ${t}
24
-
25
- ${r}`)}return a.join(`
26
-
27
- `)}function Dt(e,{title:t,body:n,labels:r=[]}={}){let i=We(e);if(!i)return null;let a;try{a=new URL(i).host.toLowerCase()}catch{return null}if(a!==`github.com`)return null;let o=new URLSearchParams;t&&o.set(`title`,t),n&&o.set(`body`,n),r.length>0&&o.set(`labels`,r.join(`,`));let s=o.toString();return s?`${i}/issues/new?${s}`:`${i}/issues/new`}var Ot=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,kt=/^[a-zA-Z\d._-]+$/u,At=/^[1-9]\d{0,9}$/u,jt=/^[a-fA-F\d]{7,40}$/u,Mt=/^#[\w-]+$/u,Nt=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function Pt(e){return e.length<=39&&Ot.test(e)}function Ft(e){return e.length<=100&&e!==`.`&&e!==`..`&&kt.test(e)}function It(e){let t;try{t=new URL(e)}catch{return null}if(t.href!==e||t.protocol!==`https:`||t.hostname.toLowerCase()!==`github.com`||t.port||t.username||t.password)return null;let n=t.pathname.split(`/`);if(n.at(-1)===``&&n.pop(),n.length===3&&n[1]===`advisories`){let e=n[2];return Nt.test(e)?{url:`https://github.com/advisories/${e}`,label:e}:null}if(n.length===6&&n[3]===`security`&&n[4]===`advisories`){let[,e,t,,,r]=n;return!Pt(e)||!Ft(t)||!Nt.test(r)?null:{url:`https://github.com/${e}/${t}/security/advisories/${r}`,label:r}}if(n.length!==5)return null;let[,r,i,a,o]=n;if(!Pt(r)||!Ft(i))return null;let s;if(a===`issues`||a===`pull`){if(!At.test(o))return null;s=`${r}/${i}#${o}`}else if(a===`commit`){if(!jt.test(o))return null;s=`${r}/${i}@${o.slice(0,7)}`}else return null;return{url:`https://github.com/${r}/${i}/${a}/${o}${Mt.test(t.hash)?t.hash:``}`,label:s}}var Lt=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u;function Rt(e){if(typeof e!=`string`)return null;let t=zt(e);return t!==e||Lt.test(e)?t.slice(0,8):null}function zt(e){let t=String(e);return t.startsWith(`https://chatgpt.com/codex/cloud/security/findings/`)?t.slice(50):t}function Bt(e,n){let r=t(e,{managed:n});if(!r)return null;let i=Rt(r.id);return{url:n?r.path:`#${r.fragment}`,label:i?`finding ${i}`:`finding`,self:!0}}var Vt=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,Ht=new Set([`)`,`.`,`,`,`!`,`?`,`;`,`:`,`'`,`"`,`*`,`]`,`}`,`>`]);function Ut(e){let t=e.length;for(;t>0&&Ht.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function Wt(e,{managed:t=!1}={}){if(typeof e!=`string`||e.length===0)return[];let n=[],r=0;Vt.lastIndex=0;let i;for(;(i=Vt.exec(e))!==null;){let a=Ut(i[0]),o=a?It(a)??Bt(a,t):null;o&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(o),r=i.index+a.length,Vt.lastIndex=r)}return r<e.length&&n.push(e.slice(r)),n}function Gt(e){if(!e)return null;let t=Me(),n=RegExp(`^(?:.*/)?${t}/(@[^/]+/[^/]+|[^/]+)`,`u`),r=e.match(n);return r?r[1]:`__own__`}function Kt(e){return new Set(e.filter(e=>!I(e)))}var qt=[`#4e9af1`,`#f28e2b`,`#59a14f`,`#e15759`,`#76b7b2`,`#edc948`,`#b07aa1`,`#ff9da7`,`#9c755f`,`#5cd1e5`,`#f1ce63`,`#d37295`,`#a0cbe8`,`#86bcb6`,`#8cd17d`,`#b6992d`,`#499894`,`#e15759`,`#e879c7`,`#d4a6c8`],Jt=[`#2f8aef`,`#d2691e`,`#2ea043`,`#e63946`,`#2e9a92`,`#b88817`,`#9560e8`,`#d24a9c`,`#8a5d40`,`#0891b2`,`#a07a14`,`#c14e8e`,`#1f7ad0`,`#549b94`,`#3fb95f`,`#a07a14`,`#2a8278`,`#cb2c40`,`#c026d3`,`#965f93`];function Yt(){if(typeof document>`u`)return!1;let e=document.body?.classList;return!!e&&(e.contains(`theme-light`)||e.contains(`theme-pink`)||e.contains(`theme-w95`)||e.contains(`theme-paper`))}var Xt=new Map;function Zt(e){let t=Yt()?Jt:qt;return t[e%t.length]}var Qt=()=>Yt()?`#8c959f`:`#6e7681`;function $t(e){let t=Yt(),n=t?Jt:qt,r=e??`__own__`,i=`${t?`l`:`d`}:${r}`;if(Xt.has(i))return Xt.get(i);let a=0;for(let e of r)a=a*37+e.codePointAt(0)|0;let o=n[((a%n.length+n.length)%n.length*7+3)%n.length];return Xt.set(i,o),o}var en=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),tn=e=>y(e)?e:en(b(String(e))),H=globalThis.trustedTypes?.createPolicy(`deepview`,{createHTML:tn,createScriptURL:e=>{let t=new URL(e,globalThis.location.href);if(t.origin!==globalThis.location.origin)throw TypeError(`Not a same-origin script: ${t.href}`);return t.href}}),U=e=>H?H.createHTML(e):tn(e),nn=e=>H?H.createScriptURL(String(e)):e,W={showAll:!1,packagesView:!1,dependencyPackagesView:!1,flowPackagesView:!1,bundleIssues:!1,bundleLayout:`graph`,lockfileLayout:`dependencies`,bundleReason:null,bundleReasonFor:null,selected:null,focusedPkg:null,topPkgsTab:`issues`,edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:``,hidden:new Set,solo:null,graphState:null,layoutCache:null,keptViewport:null};function rn({keepViewport:e=!1}={}){W.graphState?._cleanup?W.graphState._cleanup({keepViewport:e}):e||(W.keptViewport=null),W.graphState=null}var an=w(class extends T{constructor(e){if(super(e),e.type!==C.ATTRIBUTE||e.name!==`class`||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return` `+Object.keys(e).filter(t=>e[t]).join(` `)+` `}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(` `).split(/\s/).filter(e=>e!==``)));for(let e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}let n=e.element.classList;for(let e of this.st)e in t||(n.remove(e),this.st.delete(e));for(let e in t){let r=!!t[e];r===this.st.has(e)||this.nt?.has(e)||(r?(n.add(e),this.st.add(e)):(n.remove(e),this.st.delete(e)))}return D}}),on={commit:S},sn=8;function cn(e){let t;try{t=e?JSON.parse(e):null}catch{return null}let n=e=>typeof e==`string`&&e?e:null;return t&&{tags:Array.isArray(t.tags)?t.tags.filter(n):[],details:typeof t.title==`string`?{title:t.title,authorName:n(t.authorName),authorLogin:n(t.authorLogin),date:Number.isSafeInteger(t.date)?t.date:null}:null}}function ln({title:e,authorName:t,authorLogin:n,date:r}){let i=document.createElement(`div`);i.className=`tooltip-commit-details`;let a=document.createElement(`span`);a.className=`tooltip-commit-message`,a.textContent=e;let o=document.createElement(`span`);return o.className=`tooltip-commit-meta`,o.textContent=[t&&n&&t!==n?`${t} (@${n})`:t??(n&&`@${n}`),r===null?``:new Date(r).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})].filter(Boolean).join(` · `),i.append(...e?[a]:[],o),i}var G;function un(){return G||(G=document.createElement(`div`),G.id=`styled-tooltip`,G.setAttribute(`popover`,`manual`),document.body.append(G),G)}function dn(e){typeof e.showPopover==`function`&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}var K=null,fn=``,q=null,J=null,pn=0,mn=0,hn=!1;function Y(){if(!hn){hn=!0,document.addEventListener(`mousemove`,e=>{pn=e.clientX,mn=e.clientY},{passive:!0});for(let e of[`pointerdown`,`wheel`,`scroll`])document.addEventListener(e,()=>Z(),{capture:!0,passive:!0});document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Z()}),window.addEventListener(`blur`,()=>Z())}}var gn=100,_n=14,vn=8,X=8;function yn(e,{placement:t=`cursor`}={}){Y(),clearTimeout(q),q=null,J=null,e.prepareTooltip?.(e),t=e.dataset.tooltipPlacement??t;let n=un(),i=e.dataset.tooltip??``,a=Object.hasOwn(on,e.dataset.tooltipIcon??``)?e.dataset.tooltipIcon:``,o=e.dataset.tooltipRepo??``,s=r(e.dataset.tooltipCommit),c=cn(e.dataset.tooltipCommitInfo),l=[`stasis`,`sourcemap`].includes(e.dataset.tooltipBundle)?e.dataset.tooltipBundle:``,u=e.dataset.tooltipStats??``,d=e.dataset.tooltipBuilt===`true`,f=e.dataset.tooltipPackage??``,p=e.dataset.tooltipEcosystem??``,m=e.dataset.tooltipVersion??``,h=e.dataset.tooltipFiles??``,g=e.dataset.tooltipLoc??``,_=e.dataset.tooltipSize??``,v=e.tooltipContent??null,y=v??JSON.stringify([i,a,o,s,c,l,u,d,f,p,m,h,g,_]);if(!i){Z();return}if(K===e&&fn===y)return;if(n.textContent=a||v?``:i,v){let e=document.createElement(`div`);e.className=`tooltip-rich`,ne(v,e),n.append(e)}if(a){let e=document.createElement(`span`);e.className=`tooltip-text`,e.innerHTML=U(on[a]);let t=document.createElement(`span`);t.textContent=i,e.append(t),n.append(e)}if(f){let t=document.createElement(`div`);t.className=`tooltip-package`;let r=(e.querySelector(`[data-tooltip-package-icon] svg`)??e.querySelector(`svg`))?.cloneNode(!0);r&&t.append(r);let i=document.createElement(`span`);i.className=`tooltip-package-details`;let a=(e,t)=>/^\d+$/u.test(e)?`${Number(e).toLocaleString()} ${t}`:``;for(let e of[f,m,a(h,h===`1`?`file`:`files`),a(g,`LoC`),_].filter(Boolean)){let t=document.createElement(`span`);t.textContent=e,i.append(t)}t.append(i),n.append(t)}if(o||s){let e=document.createElement(`div`);if(e.className=`tooltip-repo`,o){e.innerHTML=U(x);let t=document.createElement(`span`);t.textContent=o,e.append(t)}if(s){let t=document.createElement(`span`);t.className=`tooltip-commit`,t.innerHTML=U(S);let n=document.createElement(`span`);n.textContent=s.slice(0,7),t.append(n),e.append(t)}if(n.append(e),s&&c?.tags.length){let e=document.createElement(`div`);e.className=`tooltip-tags`;for(let t of c.tags.slice(0,sn)){let n=document.createElement(`span`);n.className=`tooltip-tag`,n.innerHTML=U(ee);let r=document.createElement(`span`);r.textContent=t,n.append(r),e.append(n)}if(c.tags.length>sn){let t=document.createElement(`span`);t.className=`tooltip-tag-more`,t.textContent=`+${(c.tags.length-sn).toLocaleString()} more`,e.append(t)}n.append(e)}}if(c?.details&&n.append(ln(c.details)),l||u||d){let e=document.createElement(`div`);if(e.className=`tooltip-bundle`,l===`stasis`){let t=document.createElement(`img`);t.src=`./stasis.svg`,t.alt=``,e.append(t)}else e.innerHTML=U(te);let t=document.createElement(`span`);t.textContent=[l===`stasis`?`Stasis`:l===`sourcemap`?`Sourcemap`:``,d?`Built on server`:``,u].filter(Boolean).join(` · `),e.append(t),n.append(e)}dn(n),n.style.left=`0px`,n.style.top=`0px`,n.style.transform=`none`,n.classList.add(`visible`);let b=pn,C=mn+_n;if(t===`right`||t===`right-start`){let n=e.getBoundingClientRect();b=n.right+vn,C=n.top+(t===`right`?n.height/2:0)}let w=window.innerWidth-n.offsetWidth-X,T=Math.max(X,Math.min(b,w));n.style.left=`${Math.round(T)}px`;let E=n.offsetHeight,D=t===`right`?C-E/2:C,O=window.innerHeight-E-X,k=Math.max(X,Math.min(D,O));n.style.top=`${Math.round(k)}px`,K=e,fn=y}function Z(e){e&&!e.contains(K)&&!e.contains(J)||(clearTimeout(q),q=null,J=null,G&&(G.classList.remove(`visible`),typeof G.hidePopover==`function`&&G.matches(`:popover-open`)&&G.hidePopover()),K=null)}function bn(e,{gate:t,placement:n}={}){Y();let r=()=>e.isConnected!==!1&&(!Object.hasOwn(e.dataset,`tooltipTruncated`)||e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&(!t||t(e));if(!r()){Z();return}e===K||e===J||(Z(),J=e,q=setTimeout(()=>{q=null,J=null,r()&&yn(e,{placement:n})},gn))}var xn=new WeakSet;function Sn(e,t){for(let n of e.composedPath()){if(n===t)break;if(n.nodeType===1&&Object.hasOwn(n.dataset,`tooltip`))return n}return null}function Cn(e,t){!e||xn.has(e)||(xn.add(e),e.ownerDocument&&Y(),e.addEventListener(`mouseover`,n=>{if(n.buttons){Z();return}let r=Sn(n,e);if(!r){Z();return}r!==K&&bn(r,t)}),e.addEventListener(`mouseout`,t=>{let n=Sn(t,e),r=t.relatedTarget?.closest?.(`[data-tooltip]`)??null;n&&n===r||Z()}),e.addEventListener(`scroll`,()=>Z(e),{capture:!0,passive:!0}))}var wn=!1;function Tn(){wn||(wn=!0,Y(),document.addEventListener(`tooltip-root-connected`,e=>{Cn(e.composedPath()[0]?.shadowRoot)}),document.body.addEventListener(`mouseover`,e=>{if(e.target.closest(`[data-tooltip-managed]`))return;if(e.buttons){Z();return}let t=e.target.closest(`[data-tooltip]`);!t||t===K||bn(t)}),document.body.addEventListener(`mouseout`,e=>{e.target.closest(`[data-tooltip-managed]`)||e.relatedTarget?.closest?.(`[data-tooltip-managed]`)||!K&&!q||(K??J)?.contains(e.relatedTarget)||Z()}))}function En(e){return`tree-`+e.replaceAll(/[^\w-]+/gu,`_`)}var Dn=()=>Object.fromEntries(f.map(e=>[e,0]));function On(e,t){let n=new Map;for(let r of e)for(let e of r){n.has(e.file)||n.set(e.file,Dn());let r=n.get(e.file),i=p(e,t);r[i]!==void 0&&r[i]++}return n}function kn(e){let t=null;for(let n of e)if(n?.tree){t||={};for(let e of Object.keys(n.tree)){let r=n.tree[e];if(!t[e]){t[e]={...r,imports:[...r.imports??[]]};continue}let i=new Set(t[e].imports);for(let n of r.imports??[])i.has(n)||(i.add(n),t[e].imports.push(n));t[e].size==null&&r.size!=null&&(t[e].size=r.size)}}return t}function An(e,t){let n=Object.keys(e),r=new Map(n.map((e,t)=>[e,t])),i=n.map(()=>Dn()),a=n.map(()=>[]);for(let[t,i]of n.entries())for(let n of e[i].imports??[]){let e=r.get(n);e!==void 0&&a[e].push(t)}let o=new Uint32Array(n.length),s=0;for(let[e,n]of t){let t=r.get(e);if(t===void 0||!n)continue;let c=f.map(e=>[e,n[e]??0]).filter(([,e])=>e!==0);if(c.length===0)continue;let l=++s,u=[],d=e=>{o[e]!==l&&(o[e]=l,u.push(e))};for(let e of a[t])d(e);for(;u.length>0;){let e=u.pop();for(let[t,n]of c)i[e][t]+=n;for(let t of a[e])d(t)}}return new Map(n.map((e,t)=>[e,i[t]]))}function jn(e,t,n){let r=t.get(e),i=n.get(e);return Q(r)>0||Q(i)>0}function Q(e){if(!e)return 0;let t=0;for(let n of f)t+=e[n]??0;return t}var Mn={package:`@babel/core`,path:/^lib\/config\//u},Nn={package:`@babel/core`,path:/^lib\/config\/files\/(?:module-types|plugins)\.js$/u},Pn=Object.freeze([{id:`react-native-codegen-discovery`,reason:`Codegen discovers package metadata and React Native configuration.`,from:{package:`react-native`,path:/^scripts\/codegen\/generate-artifacts-executor\.js$/u},to:{path:/(?:^|\/)(?:package\.json|react-native\.config\.js)$/u}},{id:`react-native-release-version`,reason:`The CLI release checker reads the installed React Native version.`,from:{package:`@react-native-community/cli-tools`,path:/^build\/releaseChecker\/index\.js$/u},to:{package:`react-native`,path:/^package\.json$/u}},{id:`react-native-platform-config`,reason:`React Native configuration loads platform CLIs supplied by the host project.`,from:{package:`react-native`,path:/^react-native\.config\.js$/u},to:{package:/^@react-native-community\/cli-platform-(?:android|ios)$/u,path:/^build\/index\.js$/u}},{id:`babel-project-config`,reason:`Babel discovers project configuration.`,from:Mn,to:{path:/(?:^|\/)babel\.config\.js$/u}},{id:`babel-typescript-preset`,reason:`Babel configuration loads the TypeScript preset.`,from:Mn,to:{package:`@babel/preset-typescript`,path:/./u}},{id:`babel-react-native-preset`,reason:`Babel config loaders load the configured React Native preset.`,from:Nn,to:{package:`@react-native/babel-preset`,path:/^(?:src\/)?index\.js$/u}},{id:`babel-reanimated-plugin`,reason:`Babel config loaders load the configured Reanimated plugin, including scoped copies.`,from:Nn,to:{package:/^(?:@[^/]+\/)?react-native-reanimated$/u,path:/^plugin\/index\.js$/u}},{id:`babel-transform-plugin`,reason:`Babel config loaders load configured transform plugins.`,from:Nn,to:{package:/^@babel\/plugin-transform-[^/]+$/u,path:/^lib\/index\.js$/u}},{id:`cosmiconfig-config`,reason:`Cosmiconfig loads discovered configuration, including dependency configuration.`,from:{package:`cosmiconfig`,path:/^dist\/loaders\.js$/u},to:{path:/\.config\.js$/u}},{id:`import-fresh-own-config`,reason:`import-fresh loads host-project configuration.`,from:{package:`import-fresh`,path:/./u},to:{path:/\.config\.js$/u},ownSourceOnly:!0}].map(e=>Object.freeze({...e,from:Object.freeze(e.from),to:Object.freeze(e.to)})));function Fn(e){return typeof e==`string`&&!e.includes(`\\`)&&!e.includes(`:`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`node_modules`)}function In(e,t){let n=e.package;return n!==void 0&&t.ownSource===!0?!1:(n===void 0||(typeof n==`string`?n===t.package:n.test(t.package??``)))&&e.path.test(t.path)}function Ln(e,t){if(e?.ownSource!==!0&&Fn(e?.path)&&Fn(t?.path))return Pn.find(n=>(!n.ownSourceOnly||t.ownSource===!0)&&In(n.from,e)&&In(n.to,t))}function Rn(e,t){let n=e.split(/(?:^|\/)node_modules\//u).slice(1).at(-1)?.match(/^(@[^/]+\/[^/]+|[^/]+)\/(.+)$/u);return{package:n?.[1],path:n?.[2]??e.replace(/^\/+/u,``),ownSource:t??i(e)===`__own__`}}function zn(e,t,n,r){return!Ln(Rn(e,r),Rn(t,n))}function Bn(e,t=e=>e.file){let n=new Map(e.nodes.map(e=>[e.file,e])),r=new Map(e.nodes.map(e=>[t(e),new Set]));for(let[i,a]of e.importsOf){let o=n.get(i);if(o)for(let s of a){let a=n.get(s);a&&zn(o.origFile??i,a.origFile??s,e.ownSourceFiles?.has(s),e.ownSourceFiles?.has(i))&&r.get(t(o)).add(t(a))}}return r}var Vn=class{constructor(e){this.nodes=[...e];for(let[e,t]of this.nodes.entries())t.position=e;for(let e=(this.nodes.length>>1)-1;e>=0;e--)this.down(e)}before(e,t){return Math.abs(e.balance)>Math.abs(t.balance)||Math.abs(e.balance)===Math.abs(t.balance)&&(e.balance>t.balance||e.balance===t.balance&&e.tie<t.tie)}swap(e,t){let n=this.nodes,r=n[e];n[e]=n[t],n[t]=r,n[e].position=e,n[t].position=t}down(e){let t=this.nodes;for(;2*e+1<t.length;){let n=2*e+1;if(n+1<t.length&&this.before(t[n+1],t[n])&&n++,!this.before(t[n],t[e]))break;this.swap(e,n),e=n}}update(e){if(e.position<0)return;let t=e.position;for(;t>0;){let n=t-1>>1;if(!this.before(e,this.nodes[n]))break;this.swap(t,n),t=n}this.down(t)}take(){let e=this.nodes[0],t=this.nodes.pop();return e.position=-1,this.nodes.length>0&&(this.nodes[0]=t,t.position=0,this.down(0)),e}};function Hn(e,t){for(let n=0;n<8;n++){let r=!1;for(let i=0;i<e.length-1;i++){let a=n%2?e.length-2-i:i,o=e[a],s=e[a+1];(t.get(s)?.get(o)?.cycleCount??0)<=(t.get(o)?.get(s)?.cycleCount??0)||(e[a]=s,e[a+1]=o,r=!0)}if(!r)break}return e}function Un(e){let t=[],n=new Set;for(let t of e.values())t.outgoing.sort((e,t)=>t[1]-e[1]||e[0].tie-t[0].tie);for(let r of e.values()){if(n.has(r))continue;let e=[{node:r,next:0}];for(n.add(r);e.length>0;){let r=e.at(-1);if(r.next===r.node.outgoing.length){t.push(r.node.id),e.pop();continue}let i=r.node.outgoing[r.next++][0];n.has(i)||(n.add(i),e.push({node:i,next:0}))}}return t.toReversed()}function $(e,t){let n=new Map(e.map((e,t)=>[e,t])),r=0;for(let e of t.values())for(let[t,i]of e.outgoing)n.get(e.id)<n.get(t.id)&&(r+=i);return r}function Wn(e,t){let n=$(e,t),r=n,i=0;for(let a=0;a<e.length-1;a++)n-=t.get(e[a]).originalBalance,n>r&&(r=n,i=a+1);return[...e.slice(i),...e.slice(0,i)]}function Gn(e,t){if(e.length<2)return e;let n=new Map(e.map((e,t)=>[e,{id:e,tie:t,balance:0,incoming:[],outgoing:[]}]));for(let e of n.values())for(let r of t.get(e.id)?.values()??[]){let t=n.get(r.to);!t||t===e||!r.cycleCount||(e.outgoing.push([t,r.cycleCount]),t.incoming.push([e,r.cycleCount]),e.balance+=r.cycleCount,t.balance-=r.cycleCount)}for(let e of n.values())e.originalBalance=e.balance;let r=[],i=new Vn(n.values()),a=[];for(;i.nodes.length>0;){let e=i.take();e.balance>=0?r.push(e.id):a.push(e.id);for(let[t,n]of e.outgoing)t.position<0||(t.balance+=n,i.update(t));for(let[t,n]of e.incoming)t.position<0||(t.balance-=n,i.update(t))}let o=e,s=$(e,n);for(let i of[[...r,...a.toReversed()],Un(n),e,e.toReversed()]){let e=Hn(Wn(i,n),t),r=$(e,n);r>s&&(o=e,s=r)}return o}function Kn(e,t){let n=new Set(e),r=new Map(e.map(e=>[e,[]]));for(let[e,i]of t)for(let t of i)n.has(e)&&n.has(t)&&r.get(t).push(e);let i=[],a=new Set;for(let r of e){if(a.has(r))continue;a.add(r);let e=[[r,(t.get(r)??[])[Symbol.iterator]()]];for(;e.length>0;){let[r,o]=e.at(-1),s=o.next();if(s.done){i.push(r),e.pop();continue}n.has(s.value)&&!a.has(s.value)&&(a.add(s.value),e.push([s.value,(t.get(s.value)??[])[Symbol.iterator]()]))}}let o=new Map,s=[];for(let e of i.toReversed()){if(o.has(e))continue;let t=[],n=s.length,i=[e];for(o.set(e,n);i.length>0;){let e=i.pop();t.push(e);for(let t of r.get(e))o.has(t)||(o.set(t,n),i.push(t))}s.push(t.toSorted())}return{groups:s,componentOf:o}}function qn(e,{expanded:t=new Set,order:n=`structure`,query:r=``,neighborhood:i=null,cyclesOnly:o=!1}={}){let s=new Map,c=new Map,l=new Map;for(let n of e.nodes){let e=t.has(n.pkg),r=`${e?`f`:`p`}:${e?n.file:n.pkg}`;s.has(r)||s.set(r,{id:r,pkg:n.pkg,file:e?n.file:null,label:e?n.file:a(n.pkg),files:[],size:0,issues:0,incoming:0,outgoing:0,importers:0,dependencies:0});let i=s.get(r);i.files.push(n.file),i.size+=n.size??0,i.issues+=n.totalIssues??0,c.set(n.file,r),l.set(n.file,n.origFile??n.file)}let u=new Map,d=new Set,f=new Set,p=new Map([...s.keys()].map(e=>[e,new Set])),m=0;for(let[t,n]of e.importsOf){let r=c.get(t);if(r)for(let i of new Set(n)){let n=c.get(i);if(!n)continue;u.has(r)||u.set(r,new Map),u.get(r).has(n)||u.get(r).set(n,{from:r,to:n,count:0,cycleCount:0,examples:[]});let a=u.get(r).get(n);a.count++;let h=zn(l.get(t),l.get(i),e.ownSourceFiles?.has(i),e.ownSourceFiles?.has(t));a.examples.length<80&&(!o||h)&&a.examples.push([t,i]),m++,s.get(r).outgoing++,s.get(n).incoming++,r!==n&&(f.add(r),d.add(n)),h&&(a.cycleCount++,(r!==n||s.get(r).file)&&p.get(r).add(n))}}let h=[...s.keys()].toSorted(),{groups:g,componentOf:_}=Kn(h,p),v=new Set(g.flatMap(e=>e.length>1||p.get(e[0]).has(e[0])?e:[]));for(let e of s.values())e.cyclic=v.has(e.id),e.component=_.get(e.id);let ee=e.ownSourcePackages??new Set(e.layerRoots?.roots??[]),y=e=>e.pkg===`__own__`?0:ee.has(e.pkg)?1:2,b=e=>d.has(e.id)&&f.has(e.id)?0:1,te=new Map(g.map((e,t)=>[t,e.reduce((e,t)=>Math.min(e,y(s.get(t))),2)])),x=(e,t)=>e.pkg.localeCompare(t.pkg)||e.label.localeCompare(t.label),S=new Map;if(n===`structure`){for(let e of g)if(!(e.length<2))for(let t of Map.groupBy(e,e=>y(s.get(e))).values())Gn(t.toSorted((e,t)=>x(s.get(e),s.get(t))),u).forEach((e,t)=>S.set(e,t))}if(o){m=0,d.clear(),f.clear();for(let e of s.values())e.incoming=0,e.outgoing=0}for(let[e,t]of u){for(let n of t.values())if(n.cyclic=n.cycleCount>0&&v.has(e)&&_.get(e)===_.get(n.to)&&(e!==n.to||s.get(e).file!==null),o){if(!n.cyclic){t.delete(n.to);continue}n.count=n.cycleCount,m+=n.count,s.get(e).outgoing+=n.count,s.get(n.to).incoming+=n.count,e!==n.to&&(f.add(e),d.add(n.to))}t.size===0&&u.delete(e)}for(let[e,t]of u)for(let n of t.keys())e!==n&&(s.get(e).dependencies++,s.get(n).importers++);let C=r.trim().toLowerCase(),w=new Set(h.filter(e=>!C||s.get(e).files.some(e=>e.toLowerCase().includes(C))||s.get(e).label.toLowerCase().includes(C))),T=new Set(i?[i]:w);if(C||i)for(let[e,t]of u)for(let n of t.keys())(i?e===i:w.has(e))&&T.add(n),(i?n===i:w.has(n))&&T.add(e);let E=(e,t)=>{if(n===`structure`){let n=te.get(e.component)-te.get(t.component);if(n)return n;let r=b(e)-b(t);if(r)return r;let i=e.component-t.component;if(i)return i}let r=y(e)-y(t);if(r)return r;if(n===`importers`)return t.importers-e.importers||x(e,t);if(n===`imports`)return t.dependencies-e.dependencies||x(e,t);let i=b(e)-b(t);if(i)return i;if(n===`structure`&&e.component===t.component){let n=(S.get(e.id)??0)-(S.get(t.id)??0);if(n)return n}return x(e,t)},D=[...s.values()].filter(e=>T.has(e.id)&&(!o||e.cyclic)).toSorted(E),O=new Map(D.map((e,t)=>[e.id,t])),ne=[];for(let[e,t]of u)if(O.has(e))for(let n of t.values())O.has(n.to)&&ne.push({...n,row:O.get(e),col:O.get(n.to)});return{rows:D,byId:s,cells:u,visibleCells:ne,index:O,matches:w,importCount:m,totalRows:s.size,cycleCount:g.filter(e=>v.has(e[0])).length}}export{k as a,re as b,ie as c,ae as d,oe as e,A as f,j as g,ce as h,ue as i,fe as j,pe as k,me as l,he as m,ge as n,N as o,_e as p,ve as q,ye as r,be as s,Se as t,Ce as u,we as v,je as w,Me as x,I as y,Ne as z,Le as A,Re as B,Be as C,Ve as D,He as E,Ue as F,Ye as G,R as H,$e as I,rt as J,ct as K,dt as L,mt as M,V as N,gt as O,vt as P,yt as Q,xt as R,St as S,Ct as T,wt as U,Et as V,Dt as W,Rt as X,zt as Y,Wt as Z,Gt as _,Kt as $,Zt as aa,Qt as ba,$t as ca,U as da,nn as ea,W as fa,rn as ga,an as ha,yn as ia,Z as ja,bn as ka,Cn as la,Tn as ma,En as na,On as oa,kn as pa,An as qa,jn as ra,Q as sa,Gn as ta,zn as ua,Bn as va,Kn as wa,qn as xa};
28
- /*! Bundled license information:
29
-
30
- lit-html/directives/class-map.js:
31
- (**
32
- * @license
33
- * Copyright 2018 Google LLC
34
- * SPDX-License-Identifier: BSD-3-Clause
35
- *)
36
- */