@preventive/triage 1.0.0-alpha.49 → 1.0.0-alpha.50
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/common/managed/finding-detail.d.ts +2 -0
- package/common/managed/finding-detail.js +32 -0
- package/common/managed/github-agents.ts +6 -3
- package/common/managed/routes.js +14 -2
- package/out/activity.js +4 -4
- package/out/{chunk-ULIF7A7N.js → chunk-2WDZPXVL.js} +1 -1
- package/out/chunk-4XMP7YVH.js +36 -0
- package/out/chunk-6S2U2UYG.js +232 -0
- package/out/{chunk-IO7JTZ6O.js → chunk-75YLHBCM.js} +1 -1
- package/out/chunk-FC65TPUB.js +1 -0
- package/out/{chunk-O6M574JI.js → chunk-FKBXNUW4.js} +1 -1
- package/out/{chunk-PBSOL2SL.js → chunk-HTBYHSPG.js} +1 -1
- package/out/{chunk-SZD5CW5R.js → chunk-UK7RGJT6.js} +2 -2
- package/out/client-managed-import.js +1 -1
- package/out/client-managed.js +2 -2
- package/out/compare.js +14 -14
- package/out/dialogs.js +34 -30
- package/out/graph.js +1 -1
- package/out/index.html +6 -6
- package/out/scan.js +2 -2
- package/out/view.css +1 -1
- package/out/view.js +15 -15
- package/package.json +4 -1
- package/server-managed/agent-merges.ts +31 -136
- package/server-managed/app-agents.ts +4 -0
- package/server-managed/commit-coauthors.ts +46 -24
- package/server-managed/http.ts +115 -37
- package/server-managed/npm-kept.ts +8 -0
- package/server-managed/public-workspace.ts +2 -2
- package/server-managed/repository-agents.ts +189 -57
- package/server-managed/repository-history.ts +51 -13
- package/server-managed/repository-pulls.ts +156 -0
- package/server-managed/repository-pulse.ts +3 -2
- package/server-managed/repository-squashes.ts +29 -6
- package/server-managed/team-reports.ts +33 -18
- package/out/chunk-BC2UCLFJ.js +0 -1
- package/out/chunk-C2AVODGZ.js +0 -36
- package/out/chunk-JEAUAJVF.js +0 -232
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
import { agentOperated, githubAgent } from '../common/managed/github-agents.ts'
|
|
16
16
|
import { GithubApiError, githubJson } from './github-app.ts'
|
|
17
17
|
import { shareGithubRead } from './github-requests.ts'
|
|
18
|
+
import { coauthorsOf } from './commit-coauthors.ts'
|
|
18
19
|
import { ACTOR, type GraphAccount, type HistoryCommit, type HistoryPages, accountOf, actorOf, githubGraphql, historyFrom } from './repository-history.ts'
|
|
19
20
|
|
|
20
21
|
export const PULSE_WEEKS = [1, 4, 13, 52]
|
|
21
22
|
// What a year counted from its commits holds, its version: kept years of
|
|
22
23
|
// another are counted again.
|
|
23
|
-
export const PULSE_YEAR_VERSION =
|
|
24
|
+
export const PULSE_YEAR_VERSION = 12
|
|
24
25
|
const WEEK_MS = 7 * 24 * 60 * 60_000
|
|
25
26
|
const DAY_MS = 24 * 60 * 60_000
|
|
26
27
|
const MAX_CONTRIBUTORS = 100
|
|
@@ -255,7 +256,7 @@ const bot = (login: string | null | undefined, name: string | null | undefined)
|
|
|
255
256
|
const withAgent = (commit: HistoryCommit, merges: ReadonlySet<string>, direct: ReadonlySet<string>) => merges.has(commit.sha)
|
|
256
257
|
|| (direct.has(commit.sha) && agentOperated(commit.authorLogin, commit.authorId ?? null))
|
|
257
258
|
|| githubAgent(commit.authorLogin, commit.authorId ?? null, commit.authorName) !== null || bot(commit.authorLogin, commit.authorName)
|
|
258
|
-
|| (commit
|
|
259
|
+
|| coauthorsOf(commit).some(coauthor => Boolean(coauthor.agent) || bot(coauthor.login, coauthor.name))
|
|
259
260
|
|
|
260
261
|
// The year from `first` (pulseSince(52, …)) of `commits`, as GitHub's
|
|
261
262
|
// statistics count them, merges left out: a week a row, its commits each day
|
|
@@ -21,6 +21,16 @@ export interface Squashes {
|
|
|
21
21
|
write(sha: string, pull: SquashedPull | null): Promise<void>
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// The pull requests merged as another read told them (http.ts pulseMerges,
|
|
25
|
+
// the Pulse's agent-merges.ts agentMerges): each's merge commit, its number
|
|
26
|
+
// where told (null where not), every one merged from `from` till `to` among
|
|
27
|
+
// them; a commit committed within, as a squash's or a rebase's is as it is
|
|
28
|
+
// merged, the merge commit of the one it names, or of none.
|
|
29
|
+
export interface KnownMerges { numbers: ReadonlyMap<string, number | null>; from: number; to: number }
|
|
30
|
+
// How far within `from` and `to` a commit is told by them, for the clocks
|
|
31
|
+
// of a merge and its commit.
|
|
32
|
+
const KNOWN_SKEW_MS = 5 * 60_000
|
|
33
|
+
|
|
24
34
|
const MAX_SQUASHED = 100
|
|
25
35
|
// Looked up of an answer's commits not yet kept, at most, the newest first;
|
|
26
36
|
// in queries of as many commits, or pull requests (their commits' lines
|
|
@@ -66,13 +76,16 @@ const within = (promise: Promise<unknown>, ms: number) => ms === Number.POSITIVE
|
|
|
66
76
|
// commit of one parent, not one rebased (its commits copied onto the branch,
|
|
67
77
|
// told by their subjects), kept by each commit (`squashes`), those not yet
|
|
68
78
|
// kept looked up with GraphQL, as many as MAX_SQUASH_LOOKUPS an answer, each
|
|
69
|
-
// kept as it is found (lookUpSquashes)
|
|
79
|
+
// kept as it is found (lookUpSquashes), of those merges another read told
|
|
80
|
+
// (`known`), the pull request each was merged by not looked up. Answered
|
|
81
|
+
// with those kept once the
|
|
70
82
|
// repository's lookup is done, or `waitMs` on, that lookup going on behind:
|
|
71
83
|
// `behind`, one this started, for the caller to keep alive, and `pending`
|
|
72
84
|
// while one does. Another's lookup done within it, but not of all of these,
|
|
73
85
|
// those it left are looked up as this one's, within what is left of it.
|
|
74
86
|
export async function squashedPulls(fullName: string, token: string, commits: HistoryCommit[], squashes: Squashes,
|
|
75
|
-
waitMs = Number.POSITIVE_INFINITY, fetchImpl: typeof fetch = globalThis.fetch
|
|
87
|
+
waitMs = Number.POSITIVE_INFINITY, fetchImpl: typeof fetch = globalThis.fetch, known: KnownMerges | null = null)
|
|
88
|
+
: Promise<{ pulls: SquashedPull[]; pending: boolean; behind: Promise<void> | null }> {
|
|
76
89
|
const single = commits.filter(commit => commit.parents.length === 1)
|
|
77
90
|
const kept = await squashes.read(single.map(commit => commit.sha))
|
|
78
91
|
let unknown = single.filter(commit => !kept.has(commit.sha))
|
|
@@ -90,7 +103,7 @@ export async function squashedPulls(fullName: string, token: string, commits: Hi
|
|
|
90
103
|
if (another) await settle(another)
|
|
91
104
|
let behind: Promise<void> | null = null
|
|
92
105
|
if (!another || (unknown.length > 0 && !lookingUp.has(fullName))) {
|
|
93
|
-
const lookup = lookUpSquashes(fullName, token, unknown.slice(0, MAX_SQUASH_LOOKUPS), listed, squashes, fetchImpl)
|
|
106
|
+
const lookup = lookUpSquashes(fullName, token, unknown.slice(0, MAX_SQUASH_LOOKUPS), listed, squashes, fetchImpl, known)
|
|
94
107
|
const done: Promise<void> = lookup.catch(() => {}).finally(() => { if (lookingUp.get(fullName) === done) lookingUp.delete(fullName) })
|
|
95
108
|
lookingUp.set(fullName, done)
|
|
96
109
|
behind = lookup
|
|
@@ -100,12 +113,22 @@ export async function squashedPulls(fullName: string, token: string, commits: Hi
|
|
|
100
113
|
}
|
|
101
114
|
|
|
102
115
|
// The pull requests squashed into `unknown`, of the commits `listed`, looked
|
|
103
|
-
// up, each kept as it is found (squashedPulls)
|
|
116
|
+
// up, each kept as it is found (squashedPulls); those committed when
|
|
117
|
+
// `known` tells every merge, by it: a merge commit's pull request, by its
|
|
118
|
+
// number, the rest none's.
|
|
104
119
|
async function lookUpSquashes(fullName: string, token: string, unknown: HistoryCommit[], listed: Map<string, HistoryCommit>, squashes: Squashes,
|
|
105
|
-
fetchImpl: typeof fetch) {
|
|
120
|
+
fetchImpl: typeof fetch, known: KnownMerges | null) {
|
|
106
121
|
const [owner, name] = fullName.split('/') as [string, string]
|
|
107
122
|
const merged: { commit: HistoryCommit; number: number }[] = []
|
|
108
|
-
|
|
123
|
+
const asked: HistoryCommit[] = []
|
|
124
|
+
for (const commit of unknown) {
|
|
125
|
+
const told = known !== null && commit.committedAt !== null && commit.committedAt >= known.from + KNOWN_SKEW_MS && commit.committedAt <= known.to - KNOWN_SKEW_MS
|
|
126
|
+
const number = told ? known.numbers.get(commit.sha) : null
|
|
127
|
+
if (number === null) asked.push(commit)
|
|
128
|
+
else if (number === undefined) await squashes.write(commit.sha, null)
|
|
129
|
+
else merged.push({ commit, number })
|
|
130
|
+
}
|
|
131
|
+
await inBatches(asked, SQUASH_COMMITS, SQUASH_PARALLEL, async batch => {
|
|
109
132
|
const data = await githubGraphql(mergedPullsQuery(batch.length), { owner, name, ...Object.fromEntries(batch.map((commit, at) => [`o${at}`, commit.sha])) },
|
|
110
133
|
token, fetchImpl, notFound) as MergedPulls
|
|
111
134
|
for (const [at, commit] of batch.entries()) {
|
|
@@ -8,6 +8,7 @@ import { managedFindingSourcePaths, readManagedReport } from '../common/managed/
|
|
|
8
8
|
import { filterReportData, projectFinding } from '../common/managed/report-filter.ts'
|
|
9
9
|
import { revalidationLinks, securityLinks } from '../common/security-links.js'
|
|
10
10
|
import { treeDependencyDirectory } from '../client/dependency-paths.js'
|
|
11
|
+
import { liteReportData } from '../common/managed/finding-detail.js'
|
|
11
12
|
import type { BlobStore } from './blob-store.ts'
|
|
12
13
|
import type { ManagedDb, TeamReportAccessSnapshot } from './db.ts'
|
|
13
14
|
import { triageWireEntry } from './triage-response.ts'
|
|
@@ -22,10 +23,15 @@ const VISIBILITY_CACHE_MAX_ITEMS = 250_000
|
|
|
22
23
|
const VISIBILITY_CACHE_MAX_SNAPSHOTS = 32
|
|
23
24
|
const caches = new WeakMap<ManagedDb, Map<string, Visibility>>()
|
|
24
25
|
const REPORT_CACHE_BYTES = 16 * 1024 * 1024
|
|
25
|
-
// A workspace's encoded reports,
|
|
26
|
-
|
|
26
|
+
// A workspace's encoded reports, the same without their findings' detail for
|
|
27
|
+
// the board (`lite`), and its reports' file trees apart.
|
|
28
|
+
type EncodedWorkspace = { reports: Buffer; lite: Buffer; trees: Buffer }
|
|
29
|
+
export type TeamResponsePart = keyof EncodedWorkspace
|
|
30
|
+
// The part a team's `reports` or `trees` route asks for.
|
|
31
|
+
export const teamResponsePart = (route: string, url: URL): TeamResponsePart =>
|
|
32
|
+
route === 'trees' ? 'trees' : url.searchParams.get('lite') === '1' ? 'lite' : 'reports'
|
|
27
33
|
const reportCaches = new WeakMap<ManagedDb, Map<string, EncodedWorkspace>>()
|
|
28
|
-
const encodedBytes = ({ reports, trees }: EncodedWorkspace) => reports.length + trees.length
|
|
34
|
+
const encodedBytes = ({ reports, lite, trees }: EncodedWorkspace) => reports.length + lite.length + trees.length
|
|
29
35
|
// A workspace's report reads at once. Its reports' sizes are bounded together
|
|
30
36
|
// before any is read, and each is held parsed till the build ends, so more at
|
|
31
37
|
// once costs only the raw bytes in flight: a cold build of a team's reports
|
|
@@ -157,6 +163,8 @@ async function buildTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Tea
|
|
|
157
163
|
// Preserve linked security classification for the UI lens, including a
|
|
158
164
|
// linked component that a dependency permission will hide from the UI.
|
|
159
165
|
finding['isSecurity'] = securityIds.has(String(finding['id']))
|
|
166
|
+
// The hash of its file's tree, which nothing a team view shows reads.
|
|
167
|
+
delete finding['treeHash']
|
|
160
168
|
if (typeof finding['id'] === 'string') { ids.add(finding['id']); allIds.add(finding['id']) }
|
|
161
169
|
}
|
|
162
170
|
visible.set(report.id, { ids, sourcePaths: managedFindingSourcePaths(groupsOf(report.data).flat()) })
|
|
@@ -168,8 +176,22 @@ async function buildTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Tea
|
|
|
168
176
|
if (links && !snapshot.hiddenReportId) report.data = { source: 'links', findings: [], links: links.map(ids => [...new Set(ids.filter(id => allIds.has(id)))]).filter(ids => ids.length >= 2) }
|
|
169
177
|
}
|
|
170
178
|
const trees = Buffer.from(`{"trees":{${reports.map(withoutTree).filter(tree => tree !== null).join(',')}}}`)
|
|
171
|
-
|
|
172
|
-
|
|
179
|
+
const links = mergeLinkGroups(globalLinks, allIds)
|
|
180
|
+
const encoded = {
|
|
181
|
+
// Bounded together, as when the trees were sent with their reports.
|
|
182
|
+
reports: encodeReports(reports, links, trees.length),
|
|
183
|
+
// The board's, its findings without their detail (common/managed/finding-detail.js).
|
|
184
|
+
lite: encodeReports(reports.map(report => ({ ...report, data: liteReportData(report.data) })), links, 0),
|
|
185
|
+
trees,
|
|
186
|
+
}
|
|
187
|
+
retainVisibility(db, workspaceKey(snapshot), visible)
|
|
188
|
+
retainReports(db, workspaceKey(snapshot), encoded)
|
|
189
|
+
return { ...encoded, visible }
|
|
190
|
+
}
|
|
191
|
+
// `{ reports, links }` as a response sends them, `spent` bytes already
|
|
192
|
+
// counted against the bound.
|
|
193
|
+
function encodeReports(reports: readonly TeamReport[], links: readonly string[][], spent: number): Buffer {
|
|
194
|
+
let outputBytes = spent + 14
|
|
173
195
|
const parts = [Buffer.from('{"reports":[')]
|
|
174
196
|
for (const [index, report] of reports.entries()) {
|
|
175
197
|
const bytes = Buffer.from(JSON.stringify(report))
|
|
@@ -178,14 +200,10 @@ async function buildTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Tea
|
|
|
178
200
|
if (index) parts.push(Buffer.from(','))
|
|
179
201
|
parts.push(bytes)
|
|
180
202
|
}
|
|
181
|
-
const links = mergeLinkGroups(globalLinks, allIds)
|
|
182
203
|
const suffix = Buffer.from(links.length > 0 ? `],"links":${JSON.stringify(links)}}` : ']}')
|
|
183
204
|
if (outputBytes + suffix.length > MAX_REPORT_QUERY_BYTES) throw new TeamReportsError(413, 'batch-too-large')
|
|
184
205
|
parts.push(suffix)
|
|
185
|
-
|
|
186
|
-
retainVisibility(db, workspaceKey(snapshot), visible)
|
|
187
|
-
retainReports(db, workspaceKey(snapshot), encoded)
|
|
188
|
-
return { ...encoded, visible }
|
|
206
|
+
return Buffer.concat(parts)
|
|
189
207
|
}
|
|
190
208
|
const pendingWorkspaces = new WeakMap<ManagedDb, Map<string, ReturnType<typeof buildTeamWorkspace>>>()
|
|
191
209
|
async function loadTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot) {
|
|
@@ -200,15 +218,12 @@ async function loadTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Team
|
|
|
200
218
|
}
|
|
201
219
|
// Treat the encoded body as immutable and recheck access before sending it.
|
|
202
220
|
// Warm HTTP reads need neither a parsed copy nor another serialization pass.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
// The workspace's reports' file trees, by report ID (withoutTree), for the
|
|
208
|
-
// same snapshot as its reports and with the same recheck before sending.
|
|
209
|
-
export async function loadTeamTreesResponse(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot): Promise<Buffer> {
|
|
221
|
+
// Its `lite` reports and its `trees`, by report ID (withoutTree), are of the
|
|
222
|
+
// same snapshot and take the same recheck.
|
|
223
|
+
export async function loadTeamReportsResponse(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot,
|
|
224
|
+
part: TeamResponsePart = 'reports'): Promise<Buffer> {
|
|
210
225
|
const cached = reportCaches.get(db)?.get(workspaceKey(snapshot))
|
|
211
|
-
return cached?.
|
|
226
|
+
return cached?.[part] ?? (await loadTeamWorkspace(db, store, snapshot))[part]
|
|
212
227
|
}
|
|
213
228
|
export async function loadTeamReports(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot): Promise<TeamReport[]> {
|
|
214
229
|
// Object consumers get their own copy, including when sharing a cold load.
|
package/out/chunk-BC2UCLFJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=new Set([`overview`,`graph`,`treemap`,`compare`,`advisories`,`issues`,`code`,`search`,`terminal`]),t=/^\d+$/u;function n(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n<32||n===127)return!0}return!1}var r=512;function i(e){return typeof e==`string`&&e.length>0&&e.length<=r&&!n(e)}function a(e){return i(e)&&!t.test(e)}var o=/^(?=.{1,214}$)(?:@[\w.-]+\/[\w-]|[\dA-Za-z])[\w.-]*$/u,s=/^(?=.{1,256}$)[\dA-Za-z][\w.+-]*$/u,c=/^@[\da-z~-][\w.~-]*$/u;function l(e){return typeof e==`string`&&o.test(e)}function u(e){return typeof e==`string`&&s.test(e)}function d(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase(),n=t.startsWith(`@`)?t:`@${t}`;return n.length<=214&&c.test(n)?n:null}var f=new Set([`code`,`diff`]),p=e=>f.has(e)?`code`:`overview`,m=e=>f.has(e)?{compareMode:`code`}:{},h=e=>f.has(e)?`/code`:``,g=Object.freeze({manage:`/manage`,"manage-bundles":`/manage/bundle`,"manage-scans":`/manage/scans`,"manage-reports":`/manage/report`,"manage-repos":`/manage/repositories`,"manage-repo-risk":`/manage/repositories/risk`,"admin-users":`/manage/users`,"manage-teams":`/manage/team`,"manage-import":`/manage/import`,"manage-links":`/manage/links`,"manage-deduplication":`/manage/deduplication`,"manage-history":`/manage/history`}),_=new Set([`workspace-reports`,`workspace-bundles`,`workspace-repositories`,`workspace-dependencies`]),v=new Set([`pulls`,`versions`,`branch`,`reviews`]),y=e=>e.view===`workspace-dependencies`&&e.dependencyTab!=null?{dependencyTab:e.dependencyTab}:{};function b(e){if(!a(e)||e===`.`||e===`..`)return null;try{return`/finding/${encodeURIComponent(e)}`}catch{return null}}function x(t){if(!t)return null;if(t.view===`home`)return`/`;if(t.view===`reviews`)return`/my/reviews`;if(t.view===`profile`)return`/my/profile`;if(t.view===`npm`)return C(t);if(t.view===`repository-code`)return j(t);if(_.has(t.view)){let e=y(t).dependencyTab??`pulls`;return!/^[A-Za-z0-9_-]+$/u.test(t.teamSlug??``)||!v.has(e)?null:`/team/${t.teamSlug}/${t.view.slice(10)}${e===`pulls`?``:`/${e}`}`}if(t.view===`bundles`){if(!/^[A-Za-z0-9_-]+$/u.test(t.bundleSlug??``)||[t.teamSlug,t.compareSlug].some(e=>e!=null&&!/^[A-Za-z0-9_-]+$/u.test(e)))return null;let n=t.bundleTab??`overview`;if(!e.has(n))return null;let r=t.teamSlug?`/team/${t.teamSlug}`:`/manage`,i=n===`code`&&N(t.file)?`/${t.file}`:``,a=i&&N(t.line)?`#L${t.line}${N(t.endLine)&&t.endLine>t.line?`-L${t.endLine}`:``}`:``,o=n===`compare`&&t.compareSlug!=null?`/${t.compareSlug}${h(t.compareMode)}`:``;return`${r}/bundle/${t.bundleSlug}${n===`overview`?``:`/${n}`}${i}${o}${a}`}if(Object.hasOwn(g,t.view)){let e=g[t.view];return t.view===`manage-deduplication`&&t.linkId?`${e}?report=${encodeURIComponent(t.linkId)}`:t.view===`manage-bundles`&&Number.isSafeInteger(t.createRepoId)&&t.createRepoId>0?`${e}?createRepo=${t.createRepoId}`:t.view===`manage-scans`&&t.scanMode===`link`?`${e}?mode=link`:t.view===`manage-scans`&&t.bundleId?`${e}?bundle=${encodeURIComponent(t.bundleId)}${t.scanMode===`dependencies`?`&mode=dependencies`:``}`:t.view===`manage-history`&&t.actor?`${e}?actor=${encodeURIComponent(t.actor)}`:e}if(![`findings`,`files`].includes(t.view)||!t.teamSlug||[t.teamSlug,t.reportSlug].some(e=>e!=null&&!/^[A-Za-z0-9_-]+$/u.test(e)))return null;let n=`/team/${encodeURIComponent(t.teamSlug)}`,r=t.reportSlug?`/report/${encodeURIComponent(t.reportSlug)}`:``;if(t.finding){let e=b(t.finding.id);return t.view===`findings`&&e?`${n}${r}${e}`:null}return`${n}${r}${t.view===`files`?`/files`:``}`}var S=new Set([`overview`,`code`,`search`,`compare`,`review`,`treemap`]);function C(e){if(e.packageName==null)return`/npm`;let t=e.bundleTab??`overview`;if(!l(e.packageName)||e.packageSpec!=null&&!u(e.packageSpec)||!S.has(t)||e.compareSpec!=null&&!u(e.compareSpec))return null;if(t===`review`){if(e.reviewPackage!=null&&!l(e.reviewPackage)||e.reviewSpec!=null&&!u(e.reviewSpec))return null;let t=e.reviewPackage==null?``:`/${e.reviewPackage}${e.reviewSpec==null?``:`@${e.reviewSpec}`}`;return`/npm/${e.packageName}${e.packageSpec==null?``:`@${e.packageSpec}`}/review${t}`}let n=t===`code`&&N(e.file)?`/${e.file}`:``,r=n&&N(e.line)?`#L${e.line}${N(e.endLine)&&e.endLine>e.line?`-L${e.endLine}`:``}`:``,i=t===`compare`&&e.compareSpec!=null?`/${e.compareSpec}${h(e.compareMode)}`:``;return`/npm/${e.packageName}${e.packageSpec==null?``:`@${e.packageSpec}`}${t===`overview`?``:`/${t}`}${n}${i}${r}`}function w(e,t){let n=/^\/npm\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?\/review(?:\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?)?$/u.exec(e);if(n){if(!l(n[1])||n[2]!=null&&!u(n[2])||n[3]!=null&&!l(n[3])||n[4]!=null&&!u(n[4]))return null;let e=n[3]&&/^\d+\.\d+\.\d+(?:[-+].*)?$/u.test(n[3])&&n[4]==null;return{view:`npm`,packageName:n[1],packageSpec:n[2]??null,bundleTab:`review`,...n[3]?{reviewPackage:e?n[1]:n[3],reviewSpec:e?n[3]:n[4]??null}:{}}}let r=/^\/npm(?:\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(code|search|compare|treemap)(?:\/([^/]+)(?:\/([a-z]+))?)?)?)?$/u.exec(e);if(!r)return;if(r[1]==null)return{view:`npm`};if(!l(r[1])||r[2]!=null&&!u(r[2]))return null;let i={view:`npm`,packageName:r[1],packageSpec:r[2]??null,bundleTab:r[3]??`overview`};if(r[4]==null)return i;if(i.bundleTab===`compare`)return u(r[4])&&(r[5]==null||f.has(r[5]))?{...i,compareSpec:r[4],...m(r[5])}:null;if(i.bundleTab!==`code`)return null;let a=Number(r[4]);return!r[5]&&/^[1-9]\d*$/u.test(r[4])&&Number.isSafeInteger(a)?{...i,file:a,...P(t)}:null}var T=new Set([`code`,`search`,`treemap`,`compare`,`commits`,`issues`,`pulls`,`agents`,`pulse`,`replay`]),E=new Set([`commits`,`issues`,`pulls`,`agents`,`pulse`,`replay`]),D=/^[a-f\d]{40}$/u,O=500,k=e=>Number.isSafeInteger(e)&&e>0;function A(e){return typeof e==`string`&&(e===``||e.length<=O&&!/[\p{Cc}\\]/u.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e===e.trim()))}function j(e){let t=e.bundleTab??`code`,n=e.path??``;if(!k(e.repoId)||e.commit!=null&&!D.test(e.commit)||!A(n)||!T.has(t)||e.compareCommit!=null&&!D.test(e.compareCommit))return null;let r=n?`?path=${n.split(`/`).map(encodeURIComponent).join(`/`)}`:``;if(e.commit==null)return`/repo/${e.repoId}${r}`;let i=t===`code`&&N(e.file)?`/code/${e.file}`:t===`code`?``:`/${t}`,a=t===`compare`&&e.compareCommit!=null?`/${e.compareCommit}${h(e.compareMode)}`:``,o=t===`code`&&N(e.file)&&N(e.line)?`#L${e.line}${N(e.endLine)&&e.endLine>e.line?`-L${e.endLine}`:``}`:``;return`/repo/${e.repoId}/${e.commit}${i}${a}${r}${o}`}function M(e){let t=/^\/(?:repo|manage\/code)\/([1-9]\d*)(?:\/([a-f\d]{40})(?:\/(code|search|treemap|compare|commits|history|issues|pulls|agents|pulse|replay)(?:\/([^/]+)(?:\/([a-z]+))?)?)?)?$/u.exec(e.pathname.replace(/\/$/u,``));if(!t)return;let n=Number(t[1]),r=e.searchParams.get(`path`)??``,i=t[3]===`history`?`commits`:t[3]??`code`;if(!k(n)||!A(r))return null;let a={view:`repository-code`,repoId:n,commit:t[2]??null,path:r,bundleTab:i};if(t[4]==null)return a;if(i===`compare`)return D.test(t[4])&&(t[5]==null||f.has(t[5]))?{...a,compareCommit:t[4],...m(t[5])}:null;let o=Number(t[4]);return i===`code`&&t[5]==null&&/^[1-9]\d*$/u.test(t[4])&&Number.isSafeInteger(o)?{...a,file:o,...P(e.hash)}:null}function N(e){return Number.isSafeInteger(e)&&e>0}function P(e){let t=/^#L([1-9]\d*)(?:-L([1-9]\d*))?$/u.exec(e),[n,r]=t?[Number(t[1]),Number(t[2]??t[1])]:[];return!N(n)||!N(r)?{}:n===r?{line:n}:{line:Math.min(n,r),endLine:Math.max(n,r)}}function F(t){let n=t.pathname.replace(/\/$/u,``)||`/`;if(n===`/`||n===`/index.html`)return{view:`home`};if(n===`/my/reviews`)return{view:`reviews`};if(n===`/my/profile`){let e=t.searchParams.get(`link-error`);return{view:`profile`,...e&&/^[a-z-]{1,64}$/u.test(e)?{linkError:e}:{}}}let i=Object.keys(g).find(e=>g[e]===n);if(i){let e=Number(t.searchParams.get(`createRepo`));return{view:i,...i===`manage-deduplication`&&t.searchParams.get(`report`)?{linkId:t.searchParams.get(`report`)}:{},...i===`manage-bundles`&&Number.isSafeInteger(e)&&e>0?{createRepoId:e}:{},...i===`manage-history`&&t.searchParams.get(`actor`)?{actor:t.searchParams.get(`actor`)}:{},...i===`manage-scans`?t.searchParams.get(`mode`)===`link`?{scanMode:`link`}:t.searchParams.get(`bundle`)?{bundleId:t.searchParams.get(`bundle`),...t.searchParams.get(`mode`)===`dependencies`?{scanMode:`dependencies`}:{}}:{}:{}}}let a=/^(?:\/team\/([A-Za-z0-9_-]+)|\/manage)\/bundle\/([A-Za-z0-9_-]+)(?:\/([a-z]+)(?:\/([A-Za-z0-9_-]+)(?:\/([a-z]+))?)?)?$/u.exec(n);if(a){let n=a[3]??`overview`;if(!e.has(n))return null;let r={view:`bundles`,teamSlug:a[1]??null,bundleSlug:a[2],bundleTab:n};if(a[4]==null)return r;if(n===`compare`)return a[5]==null||f.has(a[5])?{...r,compareSlug:a[4],...m(a[5])}:null;let i=Number(a[4]);return n!==`code`||a[5]||!/^[1-9]\d*$/u.test(a[4])||!Number.isSafeInteger(i)?null:{...r,file:i,...P(t.hash)}}let o=w(n,t.hash);if(o!==void 0)return o;let s=M(t);if(s!==void 0)return s;let c=/^\/team\/([A-Za-z0-9_-]+)\/(reports|bundles|repositories|dependencies)$/u.exec(n);if(c)return{view:`workspace-${c[2]}`,teamSlug:c[1]};let l=/^\/team\/([A-Za-z0-9_-]+)\/dependencies\/([a-z]+)$/u.exec(n);if(l)return v.has(l[2])?{view:`workspace-dependencies`,teamSlug:l[1],dependencyTab:l[2]}:null;let u=/^\/team\/([^/]+)(?:\/report\/([^/]+))?(?:\/(files)|\/finding\/([^/]+))?$/u.exec(n);if(!u)return null;try{let e=decodeURIComponent(u[1]),t=u[2]?decodeURIComponent(u[2]):null;if([e,t].some(e=>e!=null&&!/^[A-Za-z0-9_-]+$/u.test(e))||u[4]?.length>r*9)return null;let n=u[4]?decodeURIComponent(u[4]):null;return n!=null&&!b(n)?null:{view:u[3]?`files`:`findings`,teamSlug:e,reportSlug:t,...n==null?{}:{finding:{id:n}}}}catch{return null}}function I(e,t,n=[]){if(_.has(e.view)){let n=t.filter(t=>t.slug===e.teamSlug);return n.length===1?{view:e.view,teamId:n[0].id,...y(e)}:null}if(e.view===`bundles`){let{teamSlug:r,bundleSlug:i,compareSlug:a,compareMode:o,...s}=e,c=r==null?[]:t.filter(e=>e.slug===r);if(r!=null&&c.length!==1)return null;let l=c[0],u=r==null?n:t.flatMap(e=>e.bundles??[]),d=e=>new Set(u.filter(t=>t.slug===e).map(e=>e.id)),f=d(i),p=(l?.bundles??n).find(e=>e.slug===i);if(!i||!p||f.size!==1)return null;let h=a==null?null:d(a),g=h?.size===1?{compareId:[...h][0],...m(o)}:{};return{...s,teamId:l?.id??null,bundleId:p.id,...g}}if(![`findings`,`files`].includes(e.view))return e;let{teamSlug:r,reportSlug:i,...a}=e,o=t.filter(e=>e.slug===r);if(!r||o.length!==1)return null;let s=o[0];if(i==null)return{...a,teamId:s.id,reportId:null};let c=t.flatMap(e=>e.reports??[]).filter(e=>e.slug===i),l=new Set(c.map(e=>e.id)),u=(s.reports??[]).find(e=>e.slug===i);return u&&l.size===1?{...a,teamId:s.id,reportId:u.id}:null}function L(e,t,n=[]){if(_.has(e.view)){let n=t.find(t=>t.id===e.teamId),r={view:e.view,teamSlug:n?.slug,...y(e)};return n?.slug&&I(r,t)?r:null}if(e.view===`bundles`){let{teamId:r,bundleId:i,compareId:a,compareMode:o,...s}=e,c=t.find(e=>e.id===r);if(r!=null&&!c?.slug)return null;let l=(c?.bundles??n).find(e=>e.id===i);if(!l?.slug)return null;let u=a==null?null:(r==null?n:t.flatMap(e=>e.bundles??[])).find(e=>e.id===a),d={...s,teamSlug:c?.slug??null,bundleSlug:l.slug,...u?.slug?{compareSlug:u.slug,...m(o)}:{}},f=I(d,t,n);if(!f)return null;if(d.compareSlug!=null&&f.compareId!==a){let{compareSlug:e,compareMode:t,...n}=d;return n}return d}if(![`findings`,`files`].includes(e.view))return e;let{teamId:r,reportId:i,...a}=e,o=t.find(e=>e.id===r),s=i==null?null:o?.reports?.find(e=>e.id===i);if(!o?.slug||i!=null&&!s?.slug)return null;let c={...a,teamSlug:o.slug,reportSlug:s?.slug??null};return I(c,t)?c:null}export{e as a,r as b,a as c,l as d,u as e,d as f,p as g,m as h,g as i,v as j,x as k,S as l,T as m,E as n,F as o,I as p,L as q};
|
package/out/chunk-C2AVODGZ.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import{b as e,h as t}from"./chunk-IO7JTZ6O.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,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 k}from"./chunk-2XUEZHIP.js";var ne=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}}),re=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`),ie=e=>y(e)?e:re(b(String(e))),A=globalThis.trustedTypes?.createPolicy(`deepview`,{createHTML:ie,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}}),j=e=>A?A.createHTML(e):ie(e),ae=e=>A?A.createScriptURL(String(e)):e,M={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 oe({keepViewport:e=!1}={}){M.graphState?._cleanup?M.graphState._cleanup({keepViewport:e}):e||(M.keptViewport=null),M.graphState=null}function N(e){return e.id??String(e._id)}function se(e){let t=m(e);return t!==``&&t!==`revalidation`}var ce=[{value:`confirmed`,label:`Confirmed`,kinds:[`confirmed`,`partial`,`revalidation`]},{value:`unreachable`,label:`Unreachable`,kinds:[`unreachable`]},{value:`refuted`,label:`Refuted`,kinds:[`refuted`]}];function le(e){return ce.find(t=>t.value===e)?.kinds??null}var ue=[``,`exclude`,`only`];function de(e,t){let n=le(e);return n?.includes(`partial`)?t===`only`?[`partial`]:t===`exclude`?[`confirmed`]:n:n}function P(e){if(e.confidence!==void 0)return e.confidence;if(e.critical===!0||e._source)return 10}var fe=e=>e.confidence!==void 0||e.critical===!0;function pe(e){return e.every(e=>e.every(e=>P(e)!==void 0))&&e.some(e=>e.some(fe))}function me(e,t,n){return e.some(e=>{let r=[`refuted`,`unreachable`].includes(n(e))?0:P(e);return r===void 0?t===0:r>=t})}function he(e,t){let n=e.map(t).filter(e=>e.length>0);if(!n.some(e=>e.some(e=>P(e)!==void 0)))return 0;let r=e=>n.reduce((t,n)=>t+ +!!n.some(t=>(P(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 ge(e,t){return pe(e)?t:0}function _e(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(N(e));for(let i of e){let e=t(i);if(e.length!==0&&e.some(e=>de(`confirmed`,``).includes(n(e)||(e._source&&!e._sourcePass?`revalidation`:``)))){for(let e of i)if(r.add(N(e)),e.isApp&&Array.isArray(e.revalidateInputs))for(let t of e.revalidateInputs)t&&r.add(t)}}return r}function ve(e,t,n,r){let i=ge(e,t),a=e.filter(e=>me(e,i,r));if(a.length===0)return!1;let o=new Set(de(`confirmed`,``));return e.some(e=>e.some(e=>o.has(r(e))))?a.every(e=>e.every(e=>n.has(N(e)))):!1}function ye(e,{tabs:t,kindOf:n,severityMode:r}){let i=e.map(t).filter(e=>e.length>0),a=_e(e,t,n);if(!ve(i,he(e,t),a,n))return!1;let o=ge(i,6);return i.every(e=>!me(e,o,n)||!e.some(e=>p(e,r)!==`low`)||e.every(e=>a.has(N(e))))}var F=!0;function be(e,t=!1){F=e!==!1&&!t}function xe(){return F}function I(e){return F?m(e):``}function Se(e){return m(e)!==``}function Ce(e){return e.some(e=>(e.groups??[]).some(e=>e.some(se)))}function we(e){let t=I(e);return t&&t!==`revalidation`?t:null}function Te(e){return I(e)===`revalidation`}var Ee=new Set([`refuted`,`unreachable`]);function De(e){return Ee.has(I(e))}function Oe(e){return Ee.has(I(e))}function ke(e){let t=new Set(e);return ce.filter(e=>e.kinds.some(e=>t.has(e)))}function L(e){return RegExp(`(^|/)${e}/`,`u`)}function Ae(e){return RegExp(`^(?:.*/)?${e}/(?:@[^/]+/[^/]+|[^/]+)/(.*)$`,`u`)}var je=L(`node_modules`),Me=L(`vendor`),R=`node_modules`,z=L(R),Ne=Ae(R);function Pe(e){e!==R&&(R=e,z=L(e),Ne=Ae(e))}var B=null;function Fe(t){B?.length===t.length&&B.every((e,n)=>e===t[n])||(B=[...t],Pe(e(t)))}function Ie(){return R}function V(e){return z.test(e)}var Le=new WeakSet;function Re(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=Le.has(n);`isUpstream`in n&&!e||(V(n.file)?(n.isUpstream!==!0&&(t=!0),n.isUpstream=!0,Le.add(n)):e&&(t=!0,delete n.isUpstream,Le.delete(n)))}return t}function ze(e){let t=typeof e==`string`?e:``;return je.test(t)||Me.test(t)||z.test(t)}var Be=/^(.*(?:^|\/)node_modules\/(?:@[^/]+\/[^/]+|[^/]+))(?:\/|$)/u;function Ve(e){return Be.exec(typeof e==`string`?e:``)?.[1]??null}function He(e){return typeof e!=`number`||!Number.isFinite(e)?null:n(e)}function Ue(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 We(e){return e.match(Ne)?.[1]??e}var Ge={on:new WeakMap,off:new WeakMap};function Ke(e){let t=F?Ge.on:Ge.off,n=t.get(e);if(n===void 0){let r=F?[we(e),e.revalidateVerdict,e.revalidateRecommendation]:[];n=[e.file,e.title,e.description,e.impact,e.reproduction,Ot(e),e.recommendation,e.confidenceReason,...r,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase(),t.set(e,n)}return n}function qe(e){return[typeof e?.category==`string`?e.category.trim():``,h(e,F)].filter(Boolean).join(` · `)}function Je(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 Ye(e){if(!e)return``;let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function Xe(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 Ze=/^(?:@[\w.-]+\/)?[\w.-]+@[^/\s@]+$/u;function Qe(e){return Ze.test(e||``)}function $e(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 et(e,t,n){if(Qe(e))return null;let r=$e(t);if(r.id)return`https://github.com/${r.id}/blob/HEAD/${r.prefix}${We(e)}`;if(V(e))return null;let i=$e(n),a=Xe(i.id);return a?`${a}/blob/HEAD/${i.prefix}${e}`:null}function tt(e,t){let n=e?.file??``,r=H(e,t);return r?E`<a href="${nt(r)}" target="_blank" rel="noopener">${n}</a>`:n}function nt(e){return e.replace(/#L\d+(?:-L?\d+)?$/u,``)}function H(e,t){if(!e)return null;if(s(e.location))return e.location;let n=et(e.file,e.repo,t);if(!n)return null;let r=parseInt(e.line,10);return Number.isFinite(r)?`${n}#L${r}`:n}var rt=/^https?:\/\/(?:www\.)?github\.com\/([^/\s]+\/[^/\s]+)\/(?:blob|tree|blame)\/[^/\s]+\/(\S+)$/u,it=/#L(\d+)(?:-L?(\d+))?$/u;function at(e){let t=typeof e==`string`?rt.exec(e):null;if(!t)return``;let n=t[2],r=it.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 ot=/^(?:\s+\S|[-*+] |\d+[.)] |>|#{1,6}(?:[ \t]|$)|\||`{3}|~{3})/u;function st(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=>ot.test(e)||U.test(e))?e:t.map(e=>e.trim()).filter(Boolean).join(` `)}).join(``)}function ct(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+st(i.slice(0,i.length-a.length))+a}function lt(e){if(!e)return e;let t=e.replaceAll(`\r
|
|
4
|
-
`,`
|
|
5
|
-
`),n=l(t);if(n.length===0)return st(t);let r=[],i=0;for(let[e,a]of n)e>i&&r.push(ct(t.slice(i,e),i>0,!0)),r.push(t.slice(e,a)),i=a;return i<t.length&&r.push(ct(t.slice(i),!0,!1)),r.join(``)}var ut=/^( *)(`{3,}|~{3,})(.*)$/u,dt=/^[a-z0-9+#._-]{1,20}$/u;function ft(e,t){let n=0;for(;n<t&&e[n]===` `;)n++;return e.slice(n)}function pt(e){let t=e.split(`
|
|
6
|
-
`),n=ut.exec(t[0]),r=(n?.[2]??"```").slice(0,3),i=(n?.[3]??``).trim().split(/\s+/u)[0].toLowerCase(),a=!!(t.length>1?ut.exec(t.at(-1)):null)?.[2].startsWith(r),o=n?.[1].length??0,s=t.slice(1,a?-1:void 0);return{lang:dt.test(i)?i:``,code:(o>0?s.map(e=>ft(e,o)):s).join(`
|
|
7
|
-
`)}}function mt(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(pt(e.slice(a,o))),r=o;return r<e.length&&i(e.slice(r),!0),n}var ht=/^( *)(?:[-*+]|(\d{1,9})[.)]) +(?=\S)/u,U=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u;function gt(e){return/^ */u.exec(e)[0].length}function _t(e){let t=e.length;for(;t>0&&!e[t-1].trim();)t--;return e.slice(0,t).join(`
|
|
8
|
-
`)}function vt(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])&&!U.test(r[e])&&ht.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=ht.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=gt(e),r=U.test(e)?null:ht.exec(e);if(r&&(!l||n<l.column)){if(!!r[2]!==t)break;l&&a.push(_t(l.lines)),l={column:r[0].length,lines:[e.slice(r[0].length)]},p=!1,d++;continue}if(n<l.column&&(p||yt.test(e)||U.test(e)))break}l.lines.push(ft(e,l.column)),p=!1,d++}l&&a.push(_t(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 yt=/^ {0,3}(#{1,6})[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/u,bt=/^ {0,3}-+[ \t]*$/u;function xt(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=yt.exec(e),s=U.test(e)&&(a===r||!t[a-1].trim()||!bt.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 St=/^(\d+)(?:\s*-\s*(\d+))?$/u;function W(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=1?{start:Math.floor(e),end:Math.floor(e)}:null;let t=St.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 Ct(e){return e?e.start===e.end?String(e.start):`${e.start}-${e.end}`:``}function wt(e){if(e&&typeof e==`object`){let t=W(e.start);if(!t)return null;let n=W(e.end)??t;return{start:t.start,end:Math.max(t.start,n.end)}}return W(e)}function Tt(e,t,n=4){let r=typeof e==`string`&&e!==``?e.split(`
|
|
13
|
-
`):[];if(r.length===0)return{text:``,startLine:1,lines:[]};let i=wt(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 Et(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?H({file:i,line:e?.line,repo:t.repo},null):null;if(r===0&&i===a)return c();let l=Ve(i);return l!==null&&l===Ve(a)?c():ze(i)?null:o&&!ze(a)?c():H({file:i,line:e?.line},n)}function Dt(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 Ot(e){let t=Dt(e);return t?`**Evidence:**
|
|
20
|
-
${t}`:``}function kt(e){let t=/^\[([^\]]+)\]\(([^)\s]+)\)$/u.exec(e);return!t||!s(t[2])?null:{label:d(t[1].trim())||t[2],url:t[2]}}function At(e,t){let n=parseInt(e?.line,10);if(!Number.isFinite(n))return O;let r=H(e,t),i=`line ${n}`;return r?E`<a href="${r}" target="_blank" rel="noopener">${i}</a>`:i}function jt(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,``):`https://github.com/${e}`}/commit/${t}`}var Mt=[[`Impact`,`impact`],[`Reproduction`,`reproduction`],[`Recommendation`,`recommendation`],[`Confidence reason`,`confidenceReason`],[`Revalidation verdict`,`revalidateVerdict`],[`Revalidation recommendation`,`revalidateRecommendation`]];function Nt(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=I(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=Dt(e,{spaced:!0});c&&a.push(`# Evidence
|
|
22
|
-
|
|
23
|
-
${c}`);for(let[t,n]of Mt){if(!F&&n.startsWith(`revalidate`))continue;let r=g(e?.[n],e)?.trim();r&&a.push(`# ${t}
|
|
24
|
-
|
|
25
|
-
${r}`)}return a.join(`
|
|
26
|
-
|
|
27
|
-
`)}function Pt(e,{title:t,body:n,labels:r=[]}={}){let i=Xe(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 Ft=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,It=/^[a-zA-Z\d._-]+$/u,Lt=/^[1-9]\d{0,9}$/u,Rt=/^[a-fA-F\d]{7,40}$/u,zt=/^#[\w-]+$/u,Bt=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function Vt(e){return e.length<=39&&Ft.test(e)}function Ht(e){return e.length<=100&&e!==`.`&&e!==`..`&&It.test(e)}function Ut(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 Bt.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!Vt(e)||!Ht(t)||!Bt.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(!Vt(r)||!Ht(i))return null;let s;if(a===`issues`||a===`pull`){if(!Lt.test(o))return null;s=`${r}/${i}#${o}`}else if(a===`commit`){if(!Rt.test(o))return null;s=`${r}/${i}@${o.slice(0,7)}`}else return null;return{url:`https://github.com/${r}/${i}/${a}/${o}${zt.test(t.hash)?t.hash:``}`,label:s}}var Wt=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u;function Gt(e){if(typeof e!=`string`)return null;let t=Kt(e);return t!==e||Wt.test(e)?t.slice(0,8):null}function Kt(e){let t=String(e);return t.startsWith(`https://chatgpt.com/codex/cloud/security/findings/`)?t.slice(50):t}function qt(e,n){let r=t(e,{managed:n});if(!r)return null;let i=Gt(r.id);return{url:n?r.path:`#${r.fragment}`,label:i?`finding ${i}`:`finding`,self:!0}}var Jt=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,Yt=new Set([`)`,`.`,`,`,`!`,`?`,`;`,`:`,`'`,`"`,`*`,`]`,`}`,`>`]);function Xt(e){let t=e.length;for(;t>0&&Yt.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function Zt(e,{managed:t=!1}={}){if(typeof e!=`string`||e.length===0)return[];let n=[],r=0;Jt.lastIndex=0;let i;for(;(i=Jt.exec(e))!==null;){let a=Xt(i[0]),o=a?Ut(a)??qt(a,t):null;o&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(o),r=i.index+a.length,Jt.lastIndex=r)}return r<e.length&&n.push(e.slice(r)),n}var Qt={commit:S},$t=8;function en(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 tn({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 nn(){return G||(G=document.createElement(`div`),G.id=`styled-tooltip`,G.setAttribute(`popover`,`manual`),document.body.append(G),G)}function rn(e){typeof e.showPopover==`function`&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}var K=null,an=``,q=null,J=null,on=0,sn=0,cn=!1;function Y(){if(!cn){cn=!0,document.addEventListener(`mousemove`,e=>{on=e.clientX,sn=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 ln=100,un=14,dn=8,X=8;function fn(e,{placement:t=`cursor`}={}){Y(),clearTimeout(q),q=null,J=null,e.prepareTooltip?.(e),t=e.dataset.tooltipPlacement??t;let n=nn(),i=e.dataset.tooltip??``,a=Object.hasOwn(Qt,e.dataset.tooltipIcon??``)?e.dataset.tooltipIcon:``,o=e.dataset.tooltipRepo??``,s=r(e.dataset.tooltipCommit),c=en(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&&an===y)return;if(n.textContent=a||v?``:i,v){let e=document.createElement(`div`);e.className=`tooltip-rich`,k(v,e),n.append(e)}if(a){let e=document.createElement(`span`);e.className=`tooltip-text`,e.innerHTML=j(Qt[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=j(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=j(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,$t)){let n=document.createElement(`span`);n.className=`tooltip-tag`,n.innerHTML=j(ee);let r=document.createElement(`span`);r.textContent=t,n.append(r),e.append(n)}if(c.tags.length>$t){let t=document.createElement(`span`);t.className=`tooltip-tag-more`,t.textContent=`+${(c.tags.length-$t).toLocaleString()} more`,e.append(t)}n.append(e)}}if(c?.details&&n.append(tn(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=j(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)}rn(n),n.style.left=`0px`,n.style.top=`0px`,n.style.transform=`none`,n.classList.add(`visible`);let b=on,C=sn+un;if(t===`right`||t===`right-start`){let n=e.getBoundingClientRect();b=n.right+dn,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,ne=Math.max(X,Math.min(D,O));n.style.top=`${Math.round(ne)}px`,K=e,an=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 pn(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()&&fn(e,{placement:n})},ln))}var mn=new WeakSet;function hn(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 gn(e,t){!e||mn.has(e)||(mn.add(e),e.ownerDocument&&Y(),e.addEventListener(`mouseover`,n=>{if(n.buttons){Z();return}let r=hn(n,e);if(!r){Z();return}r!==K&&pn(r,t)}),e.addEventListener(`mouseout`,t=>{let n=hn(t,e),r=t.relatedTarget?.closest?.(`[data-tooltip]`)??null;n&&n===r||Z()}),e.addEventListener(`scroll`,()=>Z(e),{capture:!0,passive:!0}))}var _n=!1;function vn(){_n||(_n=!0,Y(),document.addEventListener(`tooltip-root-connected`,e=>{gn(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||pn(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 yn(e){return`tree-`+e.replaceAll(/[^\w-]+/gu,`_`)}var bn=()=>Object.fromEntries(f.map(e=>[e,0]));function xn(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=p(e,t);r[i]!==void 0&&r[i]++}return n}var Q={trees:[],merged:null};function Sn(e){let t=e.map(e=>e?.tree??null);return t.length===Q.trees.length&&t.every((e,t)=>e===Q.trees[t])||(Q={trees:t,merged:Cn(e)}),Q.merged}function Cn(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 wn(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=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 Tn(e,t,n){let r=t.get(e),i=n.get(e);return En(r)>0||En(i)>0}function En(e){if(!e)return 0;let t=0;for(let n of f)t+=e[n]??0;return t}function Dn(e){if(!e)return null;let t=Ie(),n=RegExp(`^(?:.*/)?${t}/(@[^/]+/[^/]+|[^/]+)`,`u`),r=e.match(n);return r?r[1]:`__own__`}function On(e){return new Set(e.filter(e=>!V(e)))}var kn=[`#4e9af1`,`#f28e2b`,`#59a14f`,`#e15759`,`#76b7b2`,`#edc948`,`#b07aa1`,`#ff9da7`,`#9c755f`,`#5cd1e5`,`#f1ce63`,`#d37295`,`#a0cbe8`,`#86bcb6`,`#8cd17d`,`#b6992d`,`#499894`,`#e15759`,`#e879c7`,`#d4a6c8`],An=[`#2f8aef`,`#d2691e`,`#2ea043`,`#e63946`,`#2e9a92`,`#b88817`,`#9560e8`,`#d24a9c`,`#8a5d40`,`#0891b2`,`#a07a14`,`#c14e8e`,`#1f7ad0`,`#549b94`,`#3fb95f`,`#a07a14`,`#2a8278`,`#cb2c40`,`#c026d3`,`#965f93`];function jn(){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 $=new Map;function Mn(e){let t=jn()?An:kn;return t[e%t.length]}var Nn=()=>jn()?`#8c959f`:`#6e7681`;function Pn(e){let t=jn(),n=t?An:kn,r=e??`__own__`,i=`${t?`l`:`d`}:${r}`;if($.has(i))return $.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 $.set(i,o),o}var Fn={package:`@babel/core`,path:/^lib\/config\//u},In={package:`@babel/core`,path:/^lib\/config\/files\/(?:module-types|plugins)\.js$/u},Ln=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:Fn,to:{path:/(?:^|\/)babel\.config\.js$/u}},{id:`babel-typescript-preset`,reason:`Babel configuration loads the TypeScript preset.`,from:Fn,to:{package:`@babel/preset-typescript`,path:/./u}},{id:`babel-react-native-preset`,reason:`Babel config loaders load the configured React Native preset.`,from:In,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:In,to:{package:/^(?:@[^/]+\/)?react-native-reanimated$/u,path:/^plugin\/index\.js$/u}},{id:`babel-transform-plugin`,reason:`Babel config loaders load configured transform plugins.`,from:In,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 Rn(e){return typeof e==`string`&&!e.includes(`\\`)&&!e.includes(`:`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`node_modules`)}function zn(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 Bn(e,t){if(e?.ownSource!==!0&&Rn(e?.path)&&Rn(t?.path))return Ln.find(n=>(!n.ownSourceOnly||t.ownSource===!0)&&zn(n.from,e)&&zn(n.to,t))}function Vn(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 Hn(e,t,n,r){return!Bn(Vn(e,r),Vn(t,n))}function Un(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&&Hn(o.origFile??i,a.origFile??s,e.ownSourceFiles?.has(s),e.ownSourceFiles?.has(i))&&r.get(t(o)).add(t(a))}}return r}var Wn=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 Gn(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 Kn(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 qn(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 Jn(e,t){let n=qn(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 Yn(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 Wn(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=qn(e,n);for(let i of[[...r,...a.toReversed()],Kn(n),e,e.toReversed()]){let e=Gn(Jn(i,n),t),r=qn(e,n);r>s&&(o=e,s=r)}return o}function Xn(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 Zn(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=Hn(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:_}=Xn(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())Yn(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])),k=[];for(let[e,t]of u)if(O.has(e))for(let n of t.values())O.has(n.to)&&k.push({...n,row:O.get(e),col:O.get(n.to)});return{rows:D,byId:s,cells:u,visibleCells:k,index:O,matches:w,importCount:m,totalRows:s.size,cycleCount:g.filter(e=>v.has(e[0])).length}}export{ne as a,j as b,ae as c,M as d,oe as e,N as f,se as g,ce as h,le as i,ue as j,de as k,P as l,pe as m,he as n,_e as o,ve as p,ye as q,be as r,xe as s,I as t,Se as u,Ce as v,we as w,Te as x,De as y,Oe as z,ke as A,Fe as B,Ie as C,V as D,Re as E,He as F,Ue as G,Ke as H,qe as I,Je as J,Ye as K,tt as L,H as M,at as N,lt as O,mt as P,vt as Q,xt as R,W as S,Ct as T,Tt as U,Et as V,Ot as W,kt as X,At as Y,jt as Z,Nt as _,Pt as $,Gt as aa,Kt as ba,Zt as ca,fn as da,Z as ea,pn as fa,gn as ga,vn as ha,yn as ia,xn as ja,Sn as ka,wn as la,Tn as ma,En as na,Dn as oa,On as pa,Mn as qa,Nn as ra,Pn as sa,Yn as ta,Hn as ua,Un as va,Xn as wa,Zn 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
|
-
*/
|