@preventive/triage 1.0.0-alpha.55 → 1.0.0-alpha.56

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preventive/triage",
3
- "version": "1.0.0-alpha.55",
3
+ "version": "1.0.0-alpha.56",
4
4
  "description": "Client & relay server for triaging of automated reports",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": {
@@ -278,6 +278,8 @@
278
278
  "common/finding-id.js",
279
279
  "common/finding-duplicates.js",
280
280
  "common/finding-filters.js",
281
+ "common/finding-repo.d.ts",
282
+ "common/finding-repo.js",
281
283
  "common/github-pr.ts",
282
284
  "common/github-issue-labels.js",
283
285
  "common/github-issue-labels.d.ts",
@@ -313,6 +315,8 @@
313
315
  "common/managed/triage.ts",
314
316
  "common/managed/upload-seal.ts",
315
317
  "common/save-error-reason.ts",
318
+ "common/repo-commit.d.ts",
319
+ "common/repo-commit.js",
316
320
  "common/revalidation-conflicts.js",
317
321
  "common/revalidation-input-groups.js",
318
322
  "common/server-info.ts",
@@ -420,8 +424,8 @@
420
424
  "typescript": "^7.0.2"
421
425
  },
422
426
  "dependencies": {
423
- "@exodus/stasis": "1.0.0-beta.16",
424
- "@exodus/stasis-core": "1.0.0-beta.16",
427
+ "@exodus/stasis": "1.0.0-beta.17",
428
+ "@exodus/stasis-core": "1.0.0-beta.17",
425
429
  "@preventive/archive": "^1.4.0",
426
430
  "@preventive/compare": "^1.2.11",
427
431
  "@preventive/diff": "^1.1.0",
@@ -12,13 +12,27 @@ import { MAX_STASIS_CONFIG_BYTES, STASIS_CONFIG, namesLockfiles, parseStasisConf
12
12
  const regularFile = entry => entry.type === 'blob' && ['100644', '100755'].includes(entry.mode)
13
13
  const parentOf = path => posix.dirname(path).replace(/^\.$/u, '')
14
14
 
15
+ // The listing of `directory` at the commit, null where the commit has no
16
+ // directory there: one only the tree a lockfile lays out holds, as a package in
17
+ // node_modules a stasis.config.json lists entries of. A read that fails of one
18
+ // it has, as the listing above it tells, fails.
19
+ async function directoryListing(input, github, client, directory) {
20
+ try {
21
+ return await client.listRepoDir({ repo: github, sha: input.commit, directory: directory || undefined })
22
+ } catch (error) {
23
+ const above = directory ? await directoryListing(input, github, client, parentOf(directory)) : undefined
24
+ if (above === null || above?.some(entry => entry.path === posix.basename(directory) && entry.type === 'tree') === false) return null
25
+ throw error
26
+ }
27
+ }
28
+
15
29
  // The text of the stasis.config.json in a directory, null where there is none,
16
30
  // each read once a build.
17
31
  function configReader(input, github, client) {
18
32
  const read = new Map()
19
33
  const configText = async directory => {
20
- const listing = await client.listRepoDir({ repo: github, sha: input.commit, directory: directory || undefined })
21
- if (!listing.some(entry => entry.path === STASIS_CONFIG && regularFile(entry))) return null
34
+ const listing = await directoryListing(input, github, client, directory)
35
+ if (!listing?.some(entry => entry.path === STASIS_CONFIG && regularFile(entry))) return null
22
36
  return await client.getRepoFile({ repo: github, path: posix.join(directory, STASIS_CONFIG), ref: input.commit })
23
37
  }
24
38
  return directory => {
@@ -69,8 +83,8 @@ async function projectDirectory(input, github, client) {
69
83
  const manifests = input.entries[0].endsWith('.sol') ? ['foundry.toml', 'soldeer.toml', 'soldeer.lock'] : ['package.json']
70
84
  if (!input.directory) return ''
71
85
  for (let directory = input.directory; ; directory = posix.dirname(directory).replace(/^\.$/u, '')) {
72
- const entries = await client.listRepoDir({ repo: github, sha: input.commit, directory: directory || undefined })
73
- if (entries.some(entry => manifests.includes(entry.path) && regularFile(entry))) return directory
86
+ const entries = await directoryListing(input, github, client, directory)
87
+ if (entries?.some(entry => manifests.includes(entry.path) && regularFile(entry))) return directory
74
88
  if (!directory) return input.directory
75
89
  }
76
90
  }
@@ -6,6 +6,7 @@ import { randomToken } from './crypto.ts'
6
6
  import { githubIssueClosedReason } from '../common/github-pr.ts'
7
7
  import { reportEntries, reportRepoGithub } from '@preventive/report'
8
8
  import { newIssueLabels } from '../common/github-issue-labels.js'
9
+ import { ignoresOwnRepo } from '../common/finding-repo.js'
9
10
  import { appJwt, githubAppConfigured, installUrl, publicRepositoryName } from './github-app.ts'
10
11
  import { ISSUE_LOGIN_PATH, issueUserToken } from './github-issue-oauth.ts'
11
12
  import { TeamReportsError, loadTeamReports, recheckTeam, teamSnapshot } from './team-reports.ts'
@@ -75,8 +76,10 @@ export async function prepareGithubIssue(config: ManagedConfig, db: ManagedDb, s
75
76
  if (stored) return { ...referenceResult(stored, repoIds), labels, recheck }
76
77
  // The target comes from this finding's own source, or the report's managed
77
78
  // assignment. Team membership alone must not let a caller claim an unrelated
78
- // repository's issue as the permanent reference for this finding.
79
- const findingRepo = finding['repo'] as { github?: unknown } | null | undefined
79
+ // repository's issue as the permanent reference for this finding. One on an
80
+ // advisory naming the advised package's repository as its own is the
81
+ // report's (common/finding-repo.js).
82
+ const findingRepo = (ignoresOwnRepo(finding, report.repo.github) ? null : finding['repo']) as { github?: unknown } | null | undefined
80
83
  const targetRepository = publicRepositoryName(reportRepoGithub({ repo: { github: findingRepo?.github || report.repo.github } }))
81
84
  if (!targetRepository || targetRepository.toLowerCase() !== context.repository.toLowerCase()) throw new IssueError(400, 'bad-issue-repository')
82
85
  const repository = snapshot.repositories.find(repo => repo.github.toLowerCase() === targetRepository.toLowerCase())
@@ -173,6 +173,7 @@ import type { OriginGate } from '../server-common/origin.ts'
173
173
  import { isRole, roleAtLeast } from '../common/managed/roles.ts'
174
174
  import { VISIBILITY_PERMISSIONS, parseTeamUserPermissions } from '../common/managed/permissions.ts'
175
175
  import { filterReportData } from '../common/managed/report-filter.ts'
176
+ import { ourRepoSlugs, withoutStrayRepos } from '../common/finding-repo.js'
176
177
  import type { TriageEntryPatch } from '../common/managed/triage.ts'
177
178
  import { GITHUB_AGENTS } from '../common/managed/github-agents.ts'
178
179
  import { MAX_FINDING_ID, MAX_TRIAGE_BODY_BYTES, MAX_TRIAGE_ENTRIES, MAX_TRIAGE_HISTORY, parseTriageEntryPatch } from '../common/managed/triage.ts'
@@ -4128,7 +4129,9 @@ async function handleViewReport(req: IncomingMessage, res: ServerResponse, deps:
4128
4129
  const { data } = readManagedReport(bytes.toString('utf8'), access.filename)
4129
4130
  if (data == null) { sendJson(res, 422, { error: 'unreadable-report' }); return }
4130
4131
  const links = mergeLinkGroups(snapshot.linkRevision ? await deps.db.getEnabledLinkGroups(snapshot.linkRevision) : [], await reportIds(data))
4131
- envelope = { data, repo: access.repo, ...(links.length > 0 ? { links } : {}) }
4132
+ // Without a finding's `repo` none of ours (common/finding-repo.js isStrayRepo).
4133
+ const ours = ourRepoSlugs([...(await deps.db.listSelectedRepos()).map(repo => repo.fullName), access.repo.github])
4134
+ envelope = { data: withoutStrayRepos(data, ours), repo: access.repo, ...(links.length > 0 ? { links } : {}) }
4132
4135
  }
4133
4136
  // Link decryption and finding-ID backfill can outlast access or link changes.
4134
4137
  const current = await deps.db.getReportAccessSnapshot(s.session.id, Date.now(), [id])
@@ -4166,6 +4169,9 @@ async function handleQueryReports(req: IncomingMessage, res: ServerResponse, dep
4166
4169
  if (!snapshot || snapshot.user.id !== s.user.id) { sendJson(res, 401, { error: 'unauthenticated' }); return }
4167
4170
  if (!roleAtLeast(snapshot.user.role, 'manage')) { sendJson(res, 404, { error: 'no-report' }); return }
4168
4171
  const reports = new Map(snapshot.reports.map(report => [report.id, report]))
4172
+ // The repositories that are ours, for a finding's `repo` none of them
4173
+ // (common/finding-repo.js isStrayRepo), which every report sent leaves out.
4174
+ const selected = (await deps.db.listSelectedRepos()).map(repo => repo.fullName)
4169
4175
  if (reports.size !== ids.length) { sendJson(res, 404, { error: 'no-report' }); return }
4170
4176
  const storedBytes = snapshot.reports.reduce((total, report) => total + report.byteSize, 0)
4171
4177
  if (storedBytes > MAX_REPORT_QUERY_BYTES) { sendJson(res, 413, { error: 'batch-too-large' }); return }
@@ -4203,7 +4209,8 @@ async function handleQueryReports(req: IncomingMessage, res: ServerResponse, dep
4203
4209
  const { data } = readManagedReport(bytes.toString('utf8'), access.filename)
4204
4210
  if (!data) return fail(422, 'unreadable-report')
4205
4211
  for (const findingId of await reportIds(data)) findingIds.add(findingId)
4206
- const part = Buffer.from(`${index > 0 ? ',' : ''}${JSON.stringify({ id, data: filterReportData(data, access.permissions, access.repo), repo: access.repo })}`)
4212
+ const ours = ourRepoSlugs([...selected, access.repo.github])
4213
+ const part = Buffer.from(`${index > 0 ? ',' : ''}${JSON.stringify({ id, data: filterReportData(data, access.permissions, access.repo, undefined, ours), repo: access.repo })}`)
4207
4214
  outputBytes += part.length
4208
4215
  if (outputBytes > MAX_REPORT_QUERY_BYTES) return fail(413, 'batch-too-large')
4209
4216
  // Completion order may differ from the requested report order.
@@ -8,6 +8,7 @@ import { bundleSourceLinkImports } from '../common/bundle-source-links.js'
8
8
  import type { BundleDetails } from '../common/bundle-metadata.js'
9
9
  import { loadManagedFindings, managedFindingSourcePaths } from '../common/managed/report-content.ts'
10
10
  import { type ViewerPermissions, filterReportContent } from '../common/managed/report-filter.ts'
11
+ import { ourRepoSlugs } from '../common/finding-repo.js'
11
12
  import { CacheMissError, type CacheStorage } from './cache-storage.ts'
12
13
  import { readBundleDetails } from './bundle-cache.ts'
13
14
  import type { BlobStore } from './blob-store.ts'
@@ -84,6 +85,12 @@ async function lendSourcemapEdges(details: BundleDetails, bundle: ManagedBundle,
84
85
  // identity and visibility are part of the key: a broader viewer's sources must
85
86
  // never populate a restricted response. Group derivatives by hash and filename
86
87
  // format so each format's permissions can be removed after its last deletion.
88
+ // The repositories that are ours, so that a finding's `repo` none of them is
89
+ // left out (common/finding-repo.js isStrayRepo).
90
+ async function oursFor(db: ManagedDb, repo: { github: string | null }): Promise<Set<string>> {
91
+ return ourRepoSlugs([...(await db.listSelectedRepos()).map(selected => selected.fullName), repo.github])
92
+ }
93
+
87
94
  export function createReportSourcesCache(storage: CacheStorage, db: ManagedDb, reports: BlobStore, bundles: BundleStore, sourcemapEdges?: SourcemapEdges) {
88
95
  const pending = new Map<string, { reportId: string; job: Promise<boolean> }>()
89
96
  let queue = Promise.resolve()
@@ -102,7 +109,7 @@ export function createReportSourcesCache(storage: CacheStorage, db: ManagedDb, r
102
109
  if (!sourcePaths) {
103
110
  const bytes = await reports.get(report.id)
104
111
  if (!bytes) return false
105
- const parsed = await loadManagedFindings(filterReportContent(bytes.toString('utf8'), permissions, report.filename, repo), report.filename)
112
+ const parsed = await loadManagedFindings(filterReportContent(bytes.toString('utf8'), permissions, report.filename, repo, await oursFor(db, repo)), report.filename)
106
113
  if (!parsed) return false
107
114
  sourcePaths = managedFindingSourcePaths(parsed.findings)
108
115
  }
@@ -17,6 +17,7 @@ import type { TeamWorkspaceSummary } from './team-app.ts'
17
17
  import { triageWireEntry } from './triage-response.ts'
18
18
  import { visibleManagedIssues } from './managed-issues.ts'
19
19
  import { MAX_REPORT_QUERY_BYTES, MAX_REPORT_QUERY_COUNT } from './report-query.ts'
20
+ import { ourRepoSlugs } from '../common/finding-repo.js'
20
21
 
21
22
  type Finding = Record<string, unknown>
22
23
  type TeamReport = { id: string; filename: string; data: unknown; repo: { github: string | null; directory: string } }
@@ -167,7 +168,10 @@ async function buildTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Tea
167
168
  const allIds = new Set<string>(), visible: Visibility = new Map()
168
169
  for (let i = 0; i < reports.length; i++) {
169
170
  const access = snapshot.reports[i]!, report = reports[i]!
170
- report.data = filterReportData(report.data, access.permissions, access.repo, securityIds)
171
+ // A finding's `repo` none of the team's (common/finding-repo.js
172
+ // isStrayRepo) is removed before anything reads it.
173
+ const ours = ourRepoSlugs([...snapshot.repositories.map(repo => repo.github), access.repo.github])
174
+ report.data = filterReportData(report.data, access.permissions, access.repo, securityIds, ours)
171
175
  if (report.data && typeof report.data === 'object' && ('think' in report.data || 'reportRepo' in report.data)) {
172
176
  const { think: _think, reportRepo: _reportRepo, ...data } = report.data as Finding
173
177
  report.data = data
@@ -1,42 +0,0 @@
1
- import{b as e,h as t}from"./chunk-IZ6MYRYB.js";import{a as n}from"./chunk-WCPJDAYA.js";import{a as r,b as i,e as a}from"./chunk-IYPY47MC.js";import{A as o,B as s,D as c,E as l,b as u,c as d,d as f,j as p,m,p as h,s as g,t as _,w as v,z as y}from"./chunk-QRKFPLA4.js";import{B as b,b as x,c as S,i as C,x as w,z as T}from"./chunk-74AEKRES.js";import{a as E,b as D,c as O}from"./chunk-C4Z6ZBXV.js";import{c as k,f as A,g as j,i as ee}from"./chunk-2XUEZHIP.js";var te=D(class extends O{constructor(e){if(super(e),e.type!==E.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 A}});function ne(e){let t=typeof e==`string`?e.trim():``;return/^[0-9a-f]{7,64}$/iu.test(t)?t:``}function re(e){return ne(e?.commit)}function ie(e,t){return typeof e==`string`&&typeof t==`string`&&e!==``&&e.toLowerCase()===t.toLowerCase()}function ae(e,t){return ie(t,c(e))?re(e?.repo):``}var oe=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),se=e=>x(e)?e:oe(S(String(e))),M=globalThis.trustedTypes?.createPolicy(`deepview`,{createHTML:se,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}}),N=e=>M?M.createHTML(e):se(e),ce=e=>M?M.createScriptURL(String(e)):e,P={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 le({keepViewport:e=!1}={}){P.graphState?._cleanup?P.graphState._cleanup({keepViewport:e}):e||(P.keptViewport=null),P.graphState=null}function F(e){return e.id??String(e._id)}function ue(e){let t=h(e);return t!==``&&t!==`revalidation`}var de=[{value:`confirmed`,label:`Confirmed`,kinds:[`confirmed`,`partial`,`revalidation`]},{value:`unreachable`,label:`Unreachable`,kinds:[`unreachable`]},{value:`refuted`,label:`Refuted`,kinds:[`refuted`]}];function fe(e){return de.find(t=>t.value===e)?.kinds??null}var pe=[``,`exclude`,`only`];function me(e,t){let n=fe(e);return n?.includes(`partial`)?t===`only`?[`partial`]:t===`exclude`?[`confirmed`]:n:n}function I(e){if(e.confidence!==void 0)return e.confidence;if(e.critical===!0||e._source)return 10}var he=e=>e.confidence!==void 0||e.critical===!0;function ge(e){return e.every(e=>e.every(e=>I(e)!==void 0))&&e.some(e=>e.some(he))}function _e(e,t,n){return e.some(e=>{let r=[`refuted`,`unreachable`].includes(n(e))?0:I(e);return r===void 0?t===0:r>=t})}function ve(e,t){let n=e.map(t).filter(e=>e.length>0);if(!n.some(e=>e.some(e=>I(e)!==void 0)))return 0;let r=e=>n.reduce((t,n)=>t+ +!!n.some(t=>(I(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 ye(e,t){return ge(e)?t:0}function be(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(F(e));for(let i of e){let e=t(i);if(e.length!==0&&e.some(e=>me(`confirmed`,``).includes(n(e)||(e._source&&!e._sourcePass?`revalidation`:``)))){for(let e of i)if(r.add(F(e)),e.isApp&&Array.isArray(e.revalidateInputs))for(let t of e.revalidateInputs)t&&r.add(t)}}return r}function xe(e,t,n,r){let i=ye(e,t),a=e.filter(e=>_e(e,i,r));if(a.length===0)return!1;let o=new Set(me(`confirmed`,``));return e.some(e=>e.some(e=>o.has(r(e))))?a.every(e=>e.every(e=>n.has(F(e)))):!1}function Se(e,{tabs:t,kindOf:n,severityMode:r}){let i=e.map(t).filter(e=>e.length>0),a=be(e,t,n);if(!xe(i,ve(e,t),a,n))return!1;let o=ye(i,6);return i.every(e=>!_e(e,o,n)||!e.some(e=>m(e,r)!==`low`)||e.every(e=>a.has(F(e))))}var L=!0;function Ce(e,t=!1){L=e!==!1&&!t}function we(){return L}function R(e){return L?h(e):``}function Te(e){return h(e)!==``}function Ee(e){return e.some(e=>(e.groups??[]).some(e=>e.some(ue)))}function De(e){let t=R(e);return t&&t!==`revalidation`?t:null}function Oe(e){return R(e)===`revalidation`}var ke=new Set([`refuted`,`unreachable`]);function Ae(e){return ke.has(R(e))}function je(e){return ke.has(R(e))}function Me(e){let t=new Set(e);return de.filter(e=>e.kinds.some(e=>t.has(e)))}function z(e){return RegExp(`(^|/)${e}/`,`u`)}function Ne(e){return RegExp(`^(?:.*/)?${e}/(?:@[^/]+/[^/]+|[^/]+)/(.*)$`,`u`)}var Pe=z(`node_modules`),Fe=z(`vendor`),B=`node_modules`,Ie=z(B),Le=Ne(B);function Re(e){e!==B&&(B=e,Ie=z(e),Le=Ne(e))}var ze=null;function Be(t){ze?.length===t.length&&ze.every((e,n)=>e===t[n])||(ze=[...t],Re(e(t)))}function Ve(){return B}function V(e){return Ie.test(e)}var He=new WeakSet;function Ue(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=He.has(n);`isUpstream`in n&&!e||(V(n.file)?(n.isUpstream!==!0&&(t=!0),n.isUpstream=!0,He.add(n)):e&&(t=!0,delete n.isUpstream,He.delete(n)))}return t}function We(e){let t=typeof e==`string`?e:``;return Pe.test(t)||Fe.test(t)||Ie.test(t)}var Ge=/^(.*(?:^|\/)node_modules\/(?:@[^/]+\/[^/]+|[^/]+))(?:\/|$)/u;function Ke(e){return Ge.exec(typeof e==`string`?e:``)?.[1]??null}function qe(e){return typeof e!=`number`||!Number.isFinite(e)?null:n(e)}function Je(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 Ye(e){return e.match(Le)?.[1]??e}var H={on:new WeakMap,off:new WeakMap};function Xe(e){let t=L?H.on:H.off,n=t.get(e);if(n===void 0){let r=L?[De(e),e.revalidateVerdict,e.revalidateRecommendation]:[];n=[e.file,e.title,e.description,e.impact,e.reproduction,Gt(e),e.recommendation,e.confidenceReason,...r,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
2
- `).toLowerCase(),t.set(e,n)}return n}function Ze(e){H.on.delete(e),H.off.delete(e)}function Qe(e){return[typeof e?.category==`string`?e.category.trim():``,g(e,L)].filter(Boolean).join(` · `)}function $e(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 et(e){if(!e)return``;let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function tt(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 nt=/^(?:@[\w.-]+\/)?[\w.-]+@[^/\s@]+$/u;function rt(e){return nt.test(e||``)}function it(e){if(e==null||typeof e==`string`)return{id:e??``,prefix:``,commit:``};let t=l(e);return{id:typeof e.github==`string`?e.github:``,prefix:t?`${t}/`:``,commit:re(e)}}function at(e,t,n,r=``){if(rt(e))return null;let i=it(t),a=it(n),o=ne(r);if(i.id){let t=c({repo:{github:i.id}}),n=tt(t??i.id),r=ie(t,c({repo:{github:a.id}}));return`${n}/blob/${i.commit||(r?a.commit:``)||(r||!We(e)?o:``)||`HEAD`}/${i.prefix}${Ye(e)}`}if(V(e))return null;let s=tt(a.id);return s?`${s}/blob/${a.commit||o||`HEAD`}/${a.prefix}${e}`:null}function ot(e,t){let n=e?.file??``,r=U(e,t);return r?k`<a href="${st(r)}" target="_blank" rel="noopener">${n}</a>`:n}function st(e){return e.replace(/#L\d+(?:-L?\d+)?$/u,``)}function ct({start:e,end:t}){return t>e?`#L${e}-L${t}`:`#L${e}`}function U(e,t){if(!e)return null;if(s(e.location))return e.location;let n=at(e.file,e.repo,t,e.auditedCommit);if(!n)return null;let r=K(e.line);if(r)return`${n}${ct(r)}`;let i=parseInt(e.line,10);return Number.isFinite(i)?`${n}#L${i}`:n}var lt=/^https?:\/\/(?:www\.)?github\.com\/([^/\s]+\/[^/\s]+)\/(?:blob|tree|blame)\/[^/\s]+\/(\S+)$/u,ut=/#L(\d+)(?:-L?(\d+))?$/u;function dt(e){let t=typeof e==`string`?lt.exec(e):null;if(!t)return``;let n=t[2],r=ut.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 ft=/^(?:\s+\S|[-*+] |\d+[.)] |>|#{1,6}(?:[ \t]|$)|\||`{3}|~{3})/u;function pt(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=>ft.test(e)||G.test(e))?e:t.map(e=>e.trim()).filter(Boolean).join(` `)}).join(``)}function mt(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+pt(i.slice(0,i.length-a.length))+a}function ht(e){if(!e)return e;let t=e.replaceAll(`\r
4
- `,`
5
- `),n=u(t);if(n.length===0)return pt(t);let r=[],i=0;for(let[e,a]of n)e>i&&r.push(mt(t.slice(i,e),i>0,!0)),r.push(t.slice(e,a)),i=a;return i<t.length&&r.push(mt(t.slice(i),!0,!1)),r.join(``)}var gt=/^( *)(`{3,}|~{3,})(.*)$/u,_t=/^[a-z0-9+#._-]{1,20}$/u;function vt(e,t){let n=0;for(;n<t&&e[n]===` `;)n++;return e.slice(n)}function yt(e){let t=e.split(`
6
- `),n=gt.exec(t[0]),r=(n?.[2]??"```").slice(0,3),i=(n?.[3]??``).trim().split(/\s+/u)[0].toLowerCase(),a=!!(t.length>1?gt.exec(t.at(-1)):null)?.[2].startsWith(r),o=n?.[1].length??0,s=t.slice(1,a?-1:void 0);return{lang:_t.test(i)?i:``,code:(o>0?s.map(e=>vt(e,o)):s).join(`
7
- `)}}function bt(e){let t=u(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(yt(e.slice(a,o))),r=o;return r<e.length&&i(e.slice(r),!0),n}var W=/^( *)(?:[-*+]|(\d{1,9})[.)]) +(?=\S)/u,G=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u;function xt(e){return/^ */u.exec(e)[0].length}function St(e){let t=e.length;for(;t>0&&!e[t-1].trim();)t--;return e.slice(0,t).join(`
8
- `)}function Ct(e){let t=[],n=0;for(let r of e)t.push(n),n+=r.length+1;return t}function wt(e){let t=typeof e==`string`?e:``;if(!t)return[e];let n=u(t),r=t.split(`
9
- `),i=Ct(r),a=e=>!d(n,i[e])&&!G.test(r[e])&&W.test(r[e]),o=[],s=0,c=0,l=e=>{let t=r.slice(s,e).join(`
10
- `).replace(/^\n+/u,``).replace(/\n+$/u,``);t.trim()&&o.push(t)};for(;c<r.length;){if(!a(c)){c++;continue}l(c);let e=W.exec(r[c]),t=!!e[2],u=[],f=null,p=!1;for(;c<r.length;){let e=r[c];if(!d(n,i[c])){if(!e.trim()){f.lines.push(``),p=!0,c++;continue}let n=xt(e),r=G.test(e)?null:W.exec(e);if(r&&(!f||n<f.column)){if(!!r[2]!==t)break;f&&u.push(St(f.lines)),f={column:r[0].length,lines:[e.slice(r[0].length)]},p=!1,c++;continue}if(n<f.column&&(p||Tt.test(e)||G.test(e)||Ot.test(e)))break}f.lines.push(vt(e,f.column)),p=!1,c++}f&&u.push(St(f.lines)),o.push({ordered:t,start:t?Number(e[2]):null,items:u}),s=c}return o.length===0?[e]:(l(r.length),o)}var Tt=/^ {0,3}(#{1,6})[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/u,Et=/^ {0,3}-+[ \t]*$/u;function Dt(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=Tt.exec(e),s=G.test(e)&&(a===r||!t[a-1].trim()||!Et.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 Ot=/^ {0,3}>/u,kt=/^ {0,3}> ?/u,At=/^[ \t]*\[!(note|tip|important|warning|caution)\][ \t]*$/iu,jt=/^ {0,3}(?:`{3}|~{3})/u,Mt=/^(?: {0,3}> ?| *(?:[-*+]|\d{1,9}[.)])(?: +|$))*/u,Nt=16,Pt=e=>Tt.test(e)||G.test(e)||jt.test(e);function Ft(e,t){let n=gt.exec(t);return n?e?n[2][0]===e[0]&&n[2].length>=e.length&&!n[3].trim()?``:e:n[2][0]==="`"&&n[3].includes("`")?``:n[2]:e}function It(e){let t=0,n=e.length;for(;t<n&&!e[t].trim();)t++;for(;n>t&&!e[n-1].trim();)n--;return e.slice(t,n).join(`
13
- `)}function Lt(e,{alerts:t=!0}={}){let n=typeof e==`string`?e:``;if(!/^ {0,3}>/mu.test(n))return[e];let r=u(n),i=n.split(`
14
- `),a=Ct(i),o=e=>Ot.test(i[e])&&!d(r,a[e]),s=[],c=0,l=0;for(;l<i.length;){if(!o(l)){l++;continue}l>c&&s.push(i.slice(c,l).join(`
15
- `));let e=[],n=``,r=!1;for(;l<i.length;l++){let t=i[l];if(o(l)){let i=t.replace(kt,``),a=n!==``;n=Ft(n,i);let o=i.replace(Mt,``);r=!a&&!n&&o.trim()!==``&&!Pt(o),e.push(i)}else if(r&&t.trim()&&!Pt(t)&&!W.test(t))e.push(t);else break}let a=t?At.exec(e[0]):null,u=a?It(e.slice(1)):``;s.push({quote:!0,alert:u?a[1].toLowerCase():null,body:u||It(e)}),c=l}return c<i.length&&s.push(i.slice(c).join(`
16
- `)),s}function Rt(e,t=Nt){return t<=0?e:Lt(e).map(e=>typeof e==`string`?e:Rt(e.body,t-1)).join(`
17
- `)}var zt=/^(\d+)(?:\s*-\s*(\d+))?$/u;function K(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=1?{start:Math.floor(e),end:Math.floor(e)}:null;let t=zt.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 Bt(e){return e?e.start===e.end?String(e.start):`${e.start}-${e.end}`:``}function Vt(e){if(e&&typeof e==`object`){let t=K(e.start);if(!t)return null;let n=K(e.end)??t;return{start:t.start,end:Math.max(t.start,n.end)}}return K(e)}function Ht(e,t,n=4){let r=typeof e==`string`&&e!==``?e.split(`
18
- `):[];if(r.length===0)return{text:``,startLine:1,lines:[]};let i=Vt(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(`
19
- `),startLine:o,lines:c}}function Ut(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=t?.auditedCommit,l=()=>o?U({file:i,line:e?.line,repo:t.repo,auditedCommit:c},n):null;if(r===0&&i===a)return l();let u=Ke(i);return u!==null&&u===Ke(a)?l():We(i)?null:o&&!We(a)?l():U({file:i,line:e?.line,auditedCommit:c},n)}function Wt(e,{spaced:t=!1,link:n=e=>e.url,lineLinks:r=!1}={}){let i=Array.isArray(e?.evidence)?e.evidence:[];return i.length===0?``:i.map((e,t)=>{let i=y(e),a=n(e,t),s=[`${t+1}. ${a?`[${i}](${a})`:i}`],c=r?qt(o(e),a):o(e);if(c)for(let e of c.split(`
20
- `))s.push(` ${e}`);return s.join(`
21
- `)}).join(t?`
22
-
23
- `:`
24
- `)}function Gt(e,{repoFallback:t}={}){let n=t!==void 0,r=Wt(e,{link:n?(n,r)=>Ut(n,e,t,r):void 0,lineLinks:n});return r?`**Evidence:**
25
- ${r}`:``}var Kt=/\(\s*(?:lines?|L)\s*(\d+)(?:\s*(?:-|–|—|to)\s*L?(\d+))?\s*\)/giu;function qt(e,t){if(!e||!t||!lt.test(t)||!/\(\s*(?:lines?|L)\s*\d/iu.test(e))return e;let n=st(t),r=e=>{let t=Jt(e);return e.replace(Kt,(e,r,i,a)=>{let o=d(t,a)?null:K(i?`${r}-${i}`:r);return o?`([${e.slice(1,-1).trim()}](${n}${ct(o)}))`:e})},i=``,a=0;for(let[t,n]of u(e))i+=r(e.slice(a,t))+e.slice(t,n),a=n;return i+r(e.slice(a))}function Jt(e){let t=[],n=[...e.matchAll(/`+/gu)].map(e=>[e.index,e.index+e[0].length]),r=[],i=new Map;for(let e=n.length-1;e>=0;e--){let t=n[e][1]-n[e][0];r[e]=i.get(t),i.set(t,e)}for(let e=0;e<n.length;e++)r[e]!==void 0&&(t.push([n[e][0],n[r[e]][1]]),e=r[e]);let[a,o,s,c]=[`
26
- `,`]`,`)`,`>`].map(t=>{let n=Array.from({length:e.length+1},()=>1/0);for(let r=e.length-1;r>=0;r--)n[r]=e[r]===t?r:n[r+1];return n}),l=t.length,u=0;for(let n=0;n<e.length;n++){for(;u<l&&t[u][1]<=n;)u++;if(u<l&&t[u][0]<=n){n=t[u][1]-1;continue}let r=-1;if(e[n]===`[`&&o[n+1]<a[n]){r=o[n+1]+1;let t=e[r]===`(`?s[r]:e[r]===`[`?o[r+1]:1/0;t<a[r]&&(r=t+1)}else if(e[n]===`<`&&c[n+1]<a[n])r=c[n+1]+1;else if((e[n]===`h`||e[n]===`H`)&&/^https?:\/\//iu.test(e.slice(n,n+8))&&!/\w/u.test(e[n-1]??``))for(r=n;r<e.length&&!/\s/u.test(e[r]);)r++;r>n&&(t.push([n,r]),n=r-1)}t.sort((e,t)=>e[0]-t[0]);let d=[];for(let[e,n]of t){let t=d.at(-1);t&&e<t[1]?t[1]=Math.max(t[1],n):d.push([e,n])}return d}function Yt(e){let t=/^\[([^\]]+)\]\(([^)\s]+)\)$/u.exec(e);return!t||!s(t[2])?null:{label:f(t[1].trim())||t[2],url:t[2]}}function Xt(e,t){let n=parseInt(e?.line,10);if(!Number.isFinite(n))return j;let r=U(e,t),i=`line ${n}`;return r?k`<a href="${r}" target="_blank" rel="noopener">${i}</a>`:i}function Zt(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,``):`https://github.com/${e}`}/commit/${t}`}var Qt=[[`Impact`,`impact`],[`Reproduction`,`reproduction`],[`Recommendation`,`recommendation`],[`Confidence reason`,`confidenceReason`],[`Revalidation verdict`,`revalidateVerdict`],[`Revalidation recommendation`,`revalidateRecommendation`]];function $t(e,t){let n=[];t&&n.push(`Repo: ${t}`);let r=y(e);r&&n.push(`Location: ${r}`),e?.confidence!=null&&n.push(`Confidence: ${e.confidence}/10`);let i=R(e);i&&n.push(`Revalidation: ${i}`);let a=[];n.length>0&&a.push(n.join(`
27
- `));let{title:o,body:s}=v(e);o&&a.push(`# ${o}`),s&&a.push(s.trim());let c=Wt(e,{spaced:!0});c&&a.push(`# Evidence
28
-
29
- ${c}`);for(let[t,n]of Qt){if(!L&&n.startsWith(`revalidate`))continue;let r=_(e?.[n],e)?.trim();r&&a.push(`# ${t}
30
-
31
- ${r}`)}return a.join(`
32
-
33
- `)}function en(e,{title:t,body:n,labels:r=[]}={}){let i=tt(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 tn=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,nn=/^[a-zA-Z\d._-]+$/u,rn=/^[1-9]\d{0,9}$/u,an=/^[a-fA-F\d]{7,40}$/u,on=/^#[\w-]+$/u,sn=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function cn(e){return e.length<=39&&tn.test(e)}function ln(e){return e.length<=100&&e!==`.`&&e!==`..`&&nn.test(e)}function un(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 sn.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!cn(e)||!ln(t)||!sn.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(!cn(r)||!ln(i))return null;let s;if(a===`issues`||a===`pull`){if(!rn.test(o))return null;s=`${r}/${i}#${o}`}else if(a===`commit`){if(!an.test(o))return null;s=`${r}/${i}@${o.slice(0,7)}`}else return null;return{url:`https://github.com/${r}/${i}/${a}/${o}${on.test(t.hash)?t.hash:``}`,label:s}}var dn=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u;function fn(e){if(typeof e!=`string`)return null;let t=pn(e);return t!==e||dn.test(e)?t.slice(0,8):null}function pn(e){let t=String(e);return t.startsWith(`https://chatgpt.com/codex/cloud/security/findings/`)?t.slice(50):t}function mn(e,n){let r=t(e,{managed:n});if(!r)return null;let i=fn(r.id);return{url:n?r.path:`#${r.fragment}`,label:i?`finding ${i}`:`finding`,self:!0}}var hn=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,gn=new Set([`)`,`.`,`,`,`!`,`?`,`;`,`:`,`'`,`"`,`*`,`]`,`}`,`>`]);function _n(e){let t=e.length;for(;t>0&&gn.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function vn(e,{managed:t=!1}={}){if(typeof e!=`string`||e.length===0)return[];let n=[],r=0;hn.lastIndex=0;let i;for(;(i=hn.exec(e))!==null;){let a=_n(i[0]),o=a?un(a)??mn(a,t):null;o&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(o),r=i.index+a.length,hn.lastIndex=r)}return r<e.length&&n.push(e.slice(r)),n}var yn={commit:T},bn=8;function xn(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 Sn({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 q;function Cn(){return q||(q=document.createElement(`div`),q.id=`styled-tooltip`,q.setAttribute(`popover`,`manual`),document.body.append(q),q)}function wn(e){typeof e.showPopover==`function`&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}var J=null,Tn=``,Y=null,X=null,En=0,Dn=0,On=!1;function Z(){if(!On){On=!0,document.addEventListener(`mousemove`,e=>{En=e.clientX,Dn=e.clientY},{passive:!0});for(let e of[`pointerdown`,`wheel`,`scroll`])document.addEventListener(e,()=>$(),{capture:!0,passive:!0});document.addEventListener(`keydown`,e=>{e.key===`Escape`&&$()}),window.addEventListener(`blur`,()=>$())}}var kn=100,An=14,jn=8,Q=8;function Mn(e,{placement:t=`cursor`}={}){Z(),clearTimeout(Y),Y=null,X=null,e.prepareTooltip?.(e),t=e.dataset.tooltipPlacement??t;let n=Cn(),i=e.dataset.tooltip??``,a=Object.hasOwn(yn,e.dataset.tooltipIcon??``)?e.dataset.tooltipIcon:``,o=e.dataset.tooltipRepo??``,s=r(e.dataset.tooltipCommit),c=xn(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){$();return}if(J===e&&Tn===y)return;if(n.textContent=a||v?``:i,v){let e=document.createElement(`div`);e.className=`tooltip-rich`,ee(v,e),n.append(e)}if(a){let e=document.createElement(`span`);e.className=`tooltip-text`,e.innerHTML=N(yn[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=N(w);let t=document.createElement(`span`);t.textContent=o,e.append(t)}if(s){let t=document.createElement(`span`);t.className=`tooltip-commit`,t.innerHTML=N(T);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,bn)){let n=document.createElement(`span`);n.className=`tooltip-tag`,n.innerHTML=N(b);let r=document.createElement(`span`);r.textContent=t,n.append(r),e.append(n)}if(c.tags.length>bn){let t=document.createElement(`span`);t.className=`tooltip-tag-more`,t.textContent=`+${(c.tags.length-bn).toLocaleString()} more`,e.append(t)}n.append(e)}}if(c?.details&&n.append(Sn(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=N(C);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)}wn(n),n.style.left=`0px`,n.style.top=`0px`,n.style.transform=`none`,n.classList.add(`visible`);let x=En,S=Dn+An;if(t===`right`||t===`right-start`){let n=e.getBoundingClientRect();x=n.right+jn,S=n.top+(t===`right`?n.height/2:0)}let E=window.innerWidth-n.offsetWidth-Q,D=Math.max(Q,Math.min(x,E));n.style.left=`${Math.round(D)}px`;let O=n.offsetHeight,k=t===`right`?S-O/2:S,A=window.innerHeight-O-Q,j=Math.max(Q,Math.min(k,A));n.style.top=`${Math.round(j)}px`,J=e,Tn=y}function $(e){e&&!e.contains(J)&&!e.contains(X)||(clearTimeout(Y),Y=null,X=null,q&&(q.classList.remove(`visible`),typeof q.hidePopover==`function`&&q.matches(`:popover-open`)&&q.hidePopover()),J=null)}function Nn(e,{gate:t,placement:n}={}){Z();let r=()=>e.isConnected!==!1&&(!Object.hasOwn(e.dataset,`tooltipTruncated`)||e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&(!t||t(e));if(!r()){$();return}e===J||e===X||($(),X=e,Y=setTimeout(()=>{Y=null,X=null,r()&&Mn(e,{placement:n})},kn))}var Pn=new WeakSet;function Fn(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 In(e,t){!e||Pn.has(e)||(Pn.add(e),e.ownerDocument&&Z(),e.addEventListener(`mouseover`,n=>{if(n.buttons){$();return}let r=Fn(n,e);if(!r){$();return}r!==J&&Nn(r,t)}),e.addEventListener(`mouseout`,t=>{let n=Fn(t,e),r=t.relatedTarget?.closest?.(`[data-tooltip]`)??null;n&&n===r||$()}),e.addEventListener(`scroll`,()=>$(e),{capture:!0,passive:!0}))}var Ln=!1;function Rn(){Ln||(Ln=!0,Z(),document.addEventListener(`tooltip-root-connected`,e=>{In(e.composedPath()[0]?.shadowRoot)}),document.body.addEventListener(`mouseover`,e=>{if(e.target.closest(`[data-tooltip-managed]`))return;if(e.buttons){$();return}let t=e.target.closest(`[data-tooltip]`);!t||t===J||Nn(t)}),document.body.addEventListener(`mouseout`,e=>{e.target.closest(`[data-tooltip-managed]`)||e.relatedTarget?.closest?.(`[data-tooltip-managed]`)||!J&&!Y||(J??X)?.contains(e.relatedTarget)||$()}))}function zn(e){return`tree-`+e.replaceAll(/[^\w-]+/gu,`_`)}var Bn=()=>Object.fromEntries(p.map(e=>[e,0]));function Vn(e,t){let n=new Map;for(let r of e)for(let e of r){n.has(e.file)||n.set(e.file,Bn());let r=n.get(e.file),i=m(e,t);r[i]!==void 0&&r[i]++}return n}var Hn={trees:[],merged:null};function Un(e){let t=e.map(e=>e?.tree??null);return t.length===Hn.trees.length&&t.every((e,t)=>e===Hn.trees[t])||(Hn={trees:t,merged:Wn(e)}),Hn.merged}function Wn(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 Gn(e,t){let n=Object.keys(e),r=new Map(n.map((e,t)=>[e,t])),i=n.map(()=>Bn()),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=p.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 Kn(e,t,n){let r=t.get(e),i=n.get(e);return qn(r)>0||qn(i)>0}function qn(e){if(!e)return 0;let t=0;for(let n of p)t+=e[n]??0;return t}function Jn(e){if(!e)return null;let t=Ve(),n=RegExp(`^(?:.*/)?${t}/(@[^/]+/[^/]+|[^/]+)`,`u`),r=e.match(n);return r?r[1]:`__own__`}function Yn(e){return new Set(e.filter(e=>!V(e)))}var Xn=[`#4e9af1`,`#f28e2b`,`#59a14f`,`#e15759`,`#76b7b2`,`#edc948`,`#b07aa1`,`#ff9da7`,`#9c755f`,`#5cd1e5`,`#f1ce63`,`#d37295`,`#a0cbe8`,`#86bcb6`,`#8cd17d`,`#b6992d`,`#499894`,`#e15759`,`#e879c7`,`#d4a6c8`],Zn=[`#2f8aef`,`#d2691e`,`#2ea043`,`#e63946`,`#2e9a92`,`#b88817`,`#9560e8`,`#d24a9c`,`#8a5d40`,`#0891b2`,`#a07a14`,`#c14e8e`,`#1f7ad0`,`#549b94`,`#3fb95f`,`#a07a14`,`#2a8278`,`#cb2c40`,`#c026d3`,`#965f93`];function Qn(){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 $n=new Map;function er(e){let t=Qn()?Zn:Xn;return t[e%t.length]}var tr=()=>Qn()?`#8c959f`:`#6e7681`;function nr(e){let t=Qn(),n=t?Zn:Xn,r=e??`__own__`,i=`${t?`l`:`d`}:${r}`;if($n.has(i))return $n.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 $n.set(i,o),o}var rr={package:`@babel/core`,path:/^lib\/config\//u},ir={package:`@babel/core`,path:/^lib\/config\/files\/(?:module-types|plugins)\.js$/u},ar=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:rr,to:{path:/(?:^|\/)babel\.config\.js$/u}},{id:`babel-typescript-preset`,reason:`Babel configuration loads the TypeScript preset.`,from:rr,to:{package:`@babel/preset-typescript`,path:/./u}},{id:`babel-react-native-preset`,reason:`Babel config loaders load the configured React Native preset.`,from:ir,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:ir,to:{package:/^(?:@[^/]+\/)?react-native-reanimated$/u,path:/^plugin\/index\.js$/u}},{id:`babel-transform-plugin`,reason:`Babel config loaders load configured transform plugins.`,from:ir,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 or(e){return typeof e==`string`&&!e.includes(`\\`)&&!e.includes(`:`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`node_modules`)}function sr(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 cr(e,t){if(e?.ownSource!==!0&&or(e?.path)&&or(t?.path))return ar.find(n=>(!n.ownSourceOnly||t.ownSource===!0)&&sr(n.from,e)&&sr(n.to,t))}function lr(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 ur(e,t,n,r){return!cr(lr(e,r),lr(t,n))}function dr(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&&ur(o.origFile??i,a.origFile??s,e.ownSourceFiles?.has(s),e.ownSourceFiles?.has(i))&&r.get(t(o)).add(t(a))}}return r}var fr=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 pr(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 mr(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 hr(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 gr(e,t){let n=hr(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 _r(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 fr(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=hr(e,n);for(let i of[[...r,...a.toReversed()],mr(n),e,e.toReversed()]){let e=pr(gr(i,n),t),r=hr(e,n);r>s&&(o=e,s=r)}return o}function vr(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 yr(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=ur(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:_}=vr(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 y=e.ownSourcePackages??new Set(e.layerRoots?.roots??[]),b=e=>e.pkg===`__own__`?0:y.has(e.pkg)?1:2,x=e=>d.has(e.id)&&f.has(e.id)?0:1,S=new Map(g.map((e,t)=>[t,e.reduce((e,t)=>Math.min(e,b(s.get(t))),2)])),C=(e,t)=>e.pkg.localeCompare(t.pkg)||e.label.localeCompare(t.label),w=new Map;if(n===`structure`){for(let e of g)if(!(e.length<2))for(let t of Map.groupBy(e,e=>b(s.get(e))).values())_r(t.toSorted((e,t)=>C(s.get(e),s.get(t))),u).forEach((e,t)=>w.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 T=r.trim().toLowerCase(),E=new Set(h.filter(e=>!T||s.get(e).files.some(e=>e.toLowerCase().includes(T))||s.get(e).label.toLowerCase().includes(T))),D=new Set(i?[i]:E);if(T||i)for(let[e,t]of u)for(let n of t.keys())(i?e===i:E.has(e))&&D.add(n),(i?n===i:E.has(n))&&D.add(e);let O=(e,t)=>{if(n===`structure`){let n=S.get(e.component)-S.get(t.component);if(n)return n;let r=x(e)-x(t);if(r)return r;let i=e.component-t.component;if(i)return i}let r=b(e)-b(t);if(r)return r;if(n===`importers`)return t.importers-e.importers||C(e,t);if(n===`imports`)return t.dependencies-e.dependencies||C(e,t);let i=x(e)-x(t);if(i)return i;if(n===`structure`&&e.component===t.component){let n=(w.get(e.id)??0)-(w.get(t.id)??0);if(n)return n}return C(e,t)},k=[...s.values()].filter(e=>D.has(e.id)&&(!o||e.cyclic)).toSorted(O),A=new Map(k.map((e,t)=>[e.id,t])),j=[];for(let[e,t]of u)if(A.has(e))for(let n of t.values())A.has(n.to)&&j.push({...n,row:A.get(e),col:A.get(n.to)});return{rows:k,byId:s,cells:u,visibleCells:j,index:A,matches:E,importCount:m,totalRows:s.size,cycleCount:g.filter(e=>v.has(e[0])).length}}export{te as a,ae as b,N as c,ce as d,P as e,le as f,F as g,ue as h,de as i,fe as j,pe as k,me as l,I as m,ge as n,ve as o,be as p,xe as q,Se as r,Ce as s,we as t,R as u,Te as v,Ee as w,De as x,Oe as y,Ae as z,je as A,Me as B,Be as C,Ve as D,V as E,Ue as F,qe as G,Je as H,Xe as I,Ze as J,Qe as K,$e as L,et as M,ot as N,U as O,dt as P,ht as Q,bt as R,wt as S,Dt as T,Nt as U,Lt as V,Rt as W,K as X,Bt as Y,Ht as Z,Ut as _,Gt as $,Yt as aa,Xt as ba,Zt as ca,$t as da,en as ea,fn as fa,pn as ga,vn as ha,Mn as ia,$ as ja,Nn as ka,In as la,Rn as ma,zn as na,Vn as oa,Un as pa,Gn as qa,Kn as ra,qn as sa,Jn as ta,Yn as ua,er as va,tr as wa,nr as xa,_r as ya,ur as za,dr as Aa,vr as Ba,yr as Ca};
34
- /*! Bundled license information:
35
-
36
- lit-html/directives/class-map.js:
37
- (**
38
- * @license
39
- * Copyright 2018 Google LLC
40
- * SPDX-License-Identifier: BSD-3-Clause
41
- *)
42
- */