@preventive/triage 1.0.0-alpha.52 → 1.0.0-alpha.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/common/bundle-compare-diff.js +28 -9
  2. package/common/bundle-compare-inputs.d.ts +1 -0
  3. package/common/bundle-compare-inputs.js +91 -15
  4. package/common/bundle-comparison.js +14 -7
  5. package/common/default-scan-models.ts +3 -0
  6. package/common/dependency-reviews.d.ts +1 -1
  7. package/common/dependency-reviews.js +1 -1
  8. package/common/managed/finding-detail.d.ts +4 -2
  9. package/common/managed/finding-detail.js +27 -15
  10. package/common/managed/team-app.d.ts +9 -0
  11. package/common/managed/team-app.js +59 -6
  12. package/common/workspace-app.js +38 -6
  13. package/out/activity.js +4 -4
  14. package/out/chunk-4EMM6UCD.js +1 -0
  15. package/out/chunk-4ISO5F7Y.js +7 -0
  16. package/out/chunk-4XIH7YTX.js +1 -0
  17. package/out/chunk-6W5BMATD.js +1 -0
  18. package/out/{chunk-WFYLMF6Z.js → chunk-74AEKRES.js} +1 -1
  19. package/out/chunk-DEVAORP2.js +1 -0
  20. package/out/{chunk-KOGNQDSJ.js → chunk-DTM47KGS.js} +1 -1
  21. package/out/chunk-E3LFSUDJ.js +9 -0
  22. package/out/chunk-FHIVVVUA.js +6 -0
  23. package/out/chunk-G3LY2FV4.js +1 -0
  24. package/out/chunk-HAZKDK4M.js +4 -0
  25. package/out/chunk-HOB3YPS5.js +1 -0
  26. package/out/chunk-I47TYPXO.js +52 -0
  27. package/out/chunk-J7A5OSZE.js +244 -0
  28. package/out/chunk-JFL7WLRV.js +1 -0
  29. package/out/chunk-JMG5DXII.js +2 -0
  30. package/out/chunk-JOXLZXMI.js +1 -0
  31. package/out/chunk-L4CTEMRG.js +2 -0
  32. package/out/chunk-M37X4LCF.js +14 -0
  33. package/out/chunk-M3Y6SLC4.js +1 -0
  34. package/out/chunk-NXATZJQ2.js +1 -0
  35. package/out/{chunk-MYGJBYYJ.js → chunk-ORIP5INC.js} +1 -1
  36. package/out/chunk-PAD2JHZT.js +1 -0
  37. package/out/chunk-QMVOEBWC.js +13 -0
  38. package/out/{chunk-SXV2T5C4.js → chunk-QRKFPLA4.js} +1 -1
  39. package/out/chunk-RRBIJL2B.js +1 -0
  40. package/out/{chunk-GDPCLSOS.js → chunk-SYXT3SFP.js} +1 -1
  41. package/out/chunk-TOXMUOIW.js +5 -0
  42. package/out/chunk-UBOCLLF2.js +1 -0
  43. package/out/chunk-UCP3JRE2.js +1 -0
  44. package/out/{chunk-NCN3M5EP.js → chunk-VC72ZO3P.js} +2 -2
  45. package/out/chunk-VRX2APNA.js +9 -0
  46. package/out/{chunk-IMM274IW.js → chunk-VZMELPVL.js} +4 -3
  47. package/out/{chunk-CHRBUGVN.js → chunk-WHVXTJHK.js} +1 -1
  48. package/out/chunk-WMFDQS2L.js +11 -0
  49. package/out/chunk-WNSVBOSO.js +41 -0
  50. package/out/chunk-WREU7JAG.js +1 -0
  51. package/out/chunk-Y5ZHFNBD.js +2 -0
  52. package/out/chunk-YF4M5OCI.js +1 -0
  53. package/out/chunk-Z667U2UJ.js +1 -0
  54. package/out/chunk-ZQHLECTI.js +1 -0
  55. package/out/client-managed-import.js +1 -1
  56. package/out/client-managed.js +27 -26
  57. package/out/compare.js +14 -14
  58. package/out/dialogs.js +36 -51
  59. package/out/graph.js +17 -15
  60. package/out/index.html +26 -10
  61. package/out/prism.js +1 -1
  62. package/out/scan.js +2 -2
  63. package/out/terminal.js +232 -232
  64. package/out/view.css +1 -1
  65. package/out/view.js +15 -15
  66. package/package.json +12 -7
  67. package/risk/actions/resolve.js +36 -5
  68. package/risk/index.d.ts +20 -2
  69. package/risk/npm/malware.js +6 -4
  70. package/risk/npm/registry.js +8 -6
  71. package/server-managed/bundle-advisories.ts +56 -74
  72. package/server-managed/bundle-build-worker.js +61 -4
  73. package/server-managed/bundle-build.ts +13 -4
  74. package/server-managed/bundle-dependency-reviews.ts +74 -0
  75. package/server-managed/bundle-validation.ts +32 -0
  76. package/server-managed/db-methods.ts +51 -16
  77. package/server-managed/db-neon.ts +18 -2
  78. package/server-managed/db.ts +11 -2
  79. package/server-managed/github-issue-links.ts +151 -47
  80. package/server-managed/github-pulls.ts +34 -15
  81. package/server-managed/history-windows.ts +172 -0
  82. package/server-managed/http.ts +227 -12
  83. package/server-managed/index.ts +13 -1
  84. package/server-managed/managed-issues.ts +29 -15
  85. package/server-managed/npm-insights.ts +4 -3
  86. package/server-managed/npm-kept.ts +4 -0
  87. package/server-managed/package-entry-points.ts +37 -9
  88. package/server-managed/pretty-print.ts +7 -5
  89. package/server-managed/public-workspace.ts +2 -2
  90. package/server-managed/repository-actions.ts +7 -4
  91. package/server-managed/repository-browser.ts +11 -4
  92. package/server-managed/repository-history.ts +2 -2
  93. package/server-managed/repository-pulse.ts +11 -2
  94. package/server-managed/repository-risk-audit.ts +4 -5
  95. package/server-managed/repository-risk.ts +4 -4
  96. package/server-managed/sql.ts +2 -1
  97. package/server-managed/stasis-config.ts +46 -0
  98. package/server-managed/team-app-summaries.ts +54 -0
  99. package/server-managed/team-app.ts +52 -31
  100. package/server-managed/team-reports.ts +34 -13
  101. package/server-managed/upstream-cache.ts +41 -32
  102. package/server-managed/workspace-shares.ts +3 -1
  103. package/out/chunk-2ZDZWLFY.js +0 -1
  104. package/out/chunk-7VAWINQF.js +0 -6
  105. package/out/chunk-FMXWXDR4.js +0 -36
  106. package/out/chunk-IZ7POWI3.js +0 -18
  107. package/out/chunk-LJ7XRXFU.js +0 -52
  108. package/out/chunk-OGAYMEER.js +0 -232
  109. package/out/chunk-QB4CBOX2.js +0 -1
  110. package/out/chunk-TQJDYHVE.js +0 -2
  111. package/out/chunk-VH4XMZIW.js +0 -2
  112. package/out/chunk-WYLQWYLA.js +0 -1
@@ -15,13 +15,12 @@
15
15
  // reports stays expanded, and so does one whose reports each open as App but
16
16
  // whose combined workspace does not (contradicting verdicts, say): it has App
17
17
  // findings, and only expanded does it show that they fail to combine.
18
- import { reportEntries } from '@preventive/report'
19
- import { type TeamAppMetadata, managedTeamAppMetadata } from '../common/managed/team-app.js'
20
- import { expandFindingValues } from '../common/managed/finding-values.js'
18
+ import type { TeamAppMetadata } from '../common/managed/team-app.js'
21
19
  import type { BlobStore } from './blob-store.ts'
22
20
  import type { ManagedDb, TeamReportAccessSnapshot, UserTeam } from './db.ts'
23
21
  import type { WorkspaceShareSnapshot } from './workspace-shares.ts'
24
- import { TeamReportsError, loadTeamReportsResponse } from './team-reports.ts'
22
+ import { TeamReportsError, loadTeamSummary } from './team-reports.ts'
23
+ import { teamAppSummaryKey } from './team-app-summaries.ts'
25
24
 
26
25
  export type { TeamAppMetadata }
27
26
  export interface TeamWorkspaceSummary { app: TeamAppMetadata; empty: readonly string[] }
@@ -56,50 +55,68 @@ function remember(db: ManagedDb, key: string, summary: TeamWorkspaceSummary): Te
56
55
  return summary
57
56
  }
58
57
 
59
- function isLinks(data: unknown): boolean {
60
- const record = data as { source?: unknown; links?: unknown } | null
61
- return record?.source === 'links' && Array.isArray(record.links)
58
+ // Summaries kept in the database for every instance (team-app-summaries.ts),
59
+ // by key; a failed read is a miss, never a failed catalog, and an unreadable
60
+ // summary one to work out again.
61
+ async function storedSummaries(db: ManagedDb, keys: readonly string[]): Promise<Map<string, TeamWorkspaceSummary>> {
62
+ const hashed = new Map(keys.map(key => [teamAppSummaryKey(key), key]))
63
+ let rows: Map<string, string>
64
+ try { rows = await db.getTeamAppSummaries([...hashed.keys()]) } catch (error) {
65
+ console.warn('managed: stored team App classification read failed:', error)
66
+ return new Map()
67
+ }
68
+ const summaries = new Map<string, TeamWorkspaceSummary>()
69
+ for (const [hash, text] of rows) {
70
+ const key = hashed.get(hash), summary = readSummary(text)
71
+ if (summary && key !== undefined) summaries.set(key, summary)
72
+ }
73
+ return summaries
62
74
  }
63
75
 
64
- // A links document counts by its links, every other report by its findings.
65
- function hasContent(data: unknown): boolean {
66
- if (isLinks(data)) return (data as { links: unknown[] }).links.length > 0
67
- return (reportEntries(data) ?? []).some(entry => !Array.isArray(entry) || entry.length > 0)
76
+ function readSummary(text: string): TeamWorkspaceSummary | null {
77
+ try {
78
+ const summary = JSON.parse(text) as TeamWorkspaceSummary
79
+ return typeof summary?.app?.appMode === 'boolean' && Array.isArray(summary.empty) && summary.empty.every(id => typeof id === 'string') ? summary : null
80
+ } catch { return null }
81
+ }
82
+
83
+ // One worked out, remembered and stored for every instance.
84
+ async function settle(db: ManagedDb, key: string, summary: TeamWorkspaceSummary): Promise<TeamWorkspaceSummary> {
85
+ remember(db, key, summary)
86
+ try { await db.setTeamAppSummary(teamAppSummaryKey(key), JSON.stringify(summary), Date.now()) } catch (error) {
87
+ console.warn('managed: storing team App classification failed:', error)
88
+ }
89
+ return summary
68
90
  }
69
91
 
70
92
  // Null when the team cannot be classified right now: its catalog went stale,
71
93
  // the access snapshot is gone, or storage failed. The sidebar then keeps the
72
94
  // team expanded and lists every report, and a later catalog asks again.
73
95
  // Oversized and unreadable workspaces never have an App view, so they are
74
- // remembered as such, hiding nothing.
96
+ // remembered as such, hiding nothing. One kept in memory, or stored (`read`,
97
+ // where the caller has not asked already), is not worked out again.
75
98
  async function classify(db: ManagedDb, store: BlobStore, key: string, team: UserTeam,
76
- snapshot: () => Promise<TeamReportAccessSnapshot | null>): Promise<TeamWorkspaceSummary | null> {
99
+ snapshot: () => Promise<TeamReportAccessSnapshot | null>, read = true): Promise<TeamWorkspaceSummary | null> {
77
100
  const cached = caches.get(db)?.get(key)
78
101
  if (cached) return remember(db, key, cached)
79
- const ids = new Set(published(team).map(report => report.id))
80
- if (ids.size === 0) return remember(db, key, NO_APP)
102
+ const keys = new Map(published(team).map(report => [report.id, report.cacheKey]))
103
+ if (keys.size === 0) return remember(db, key, NO_APP)
104
+ const stored = read ? (await storedSummaries(db, [key])).get(key) : undefined
105
+ if (stored) return remember(db, key, stored)
81
106
  let jobs = pendingJobs.get(db)
82
107
  if (!jobs) { jobs = new Map(); pendingJobs.set(db, jobs) }
83
108
  const existing = jobs.get(key)
84
109
  if (existing) return existing
85
110
  const job = (async () => {
86
111
  const access = await snapshot()
87
- // A catalog read before a concurrent publication names another report set.
88
- if (!access?.teamId || access.reports.length !== ids.size || access.reports.some(report => !ids.has(report.id))) return null
89
- const body = JSON.parse((await loadTeamReportsResponse(db, store, access)).toString('utf8')) as {
90
- reports: { id: string; filename: string; data: unknown }[]; links?: string[][]; values?: unknown[]
91
- }
92
- for (const report of body.reports) expandFindingValues(report.data, body.values)
93
- const restricted = access.reports.some(report => !report.permissions.dependencies || !report.permissions.security)
94
- const empty = restricted ? body.reports.filter(report => !hasContent(report.data)).map(report => report.id) : []
95
- const links = body.links ?? []
96
- const app = managedTeamAppMetadata(Object.assign(body.reports, { links }), { countFindings: true })
97
- if (app.appMode) return remember(db, key, { app, empty })
98
- const appReports = body.reports.filter(report => !isLinks(report.data)
99
- && managedTeamAppMetadata(Object.assign([report], { links })).appMode).length
100
- return remember(db, key, { app: { ...app, appReports }, empty })
112
+ // A catalog read before a concurrent change names other reports, or
113
+ // other content or access of them: what is read now is no workspace of
114
+ // its key, so nothing is kept under it.
115
+ if (!access?.teamId || access.reports.length !== keys.size || access.reports.some(report => access.catalogKeys?.[report.id] !== keys.get(report.id))) return null
116
+ // Worked out as the workspace is built (team-reports.ts).
117
+ return settle(db, key, await loadTeamSummary(db, store, access))
101
118
  })().catch((error: unknown) => {
102
- if (error instanceof TeamReportsError && [413, 422].includes(error.status)) return remember(db, key, NO_APP)
119
+ if (error instanceof TeamReportsError && [413, 422].includes(error.status)) return settle(db, key, NO_APP)
103
120
  if (!(error instanceof TeamReportsError)) console.warn('managed: team App classification failed:', error)
104
121
  return null
105
122
  })
@@ -120,11 +137,15 @@ export async function teamAppStates(db: ManagedDb, store: BlobStore, sessionId:
120
137
  known: ReadonlyMap<string, TeamWorkspaceSummary | null> = new Map()): Promise<Map<string, TeamWorkspaceSummary | null>> {
121
138
  const states = new Map(known)
122
139
  const missing = [...new Map(teams.map(team => [teamAppKey(team), team])).entries()].filter(([key]) => !states.has(key))
140
+ // Those kept in no memory of this instance's are read of the database at
141
+ // once, in one statement.
142
+ const unknown = missing.filter(([key, team]) => !caches.get(db)?.has(key) && published(team).length > 0).map(([key]) => key)
143
+ for (const [key, summary] of unknown.length > 0 ? await storedSummaries(db, unknown) : []) remember(db, key, summary)
123
144
  let next = 0
124
145
  await Promise.all(Array.from({ length: Math.min(CLASSIFY_CONCURRENCY, missing.length) }, async () => {
125
146
  while (next < missing.length) {
126
147
  const [key, team] = missing[next++]!
127
- states.set(key, await classify(db, store, key, team, () => db.getTeamReportAccessSnapshot(sessionId, Date.now(), team.id)))
148
+ states.set(key, await classify(db, store, key, team, () => db.getTeamReportAccessSnapshot(sessionId, Date.now(), team.id), false))
128
149
  }
129
150
  }))
130
151
  return states
@@ -9,9 +9,11 @@ import { filterReportData, projectFinding } from '../common/managed/report-filte
9
9
  import { revalidationLinks, securityLinks } from '../common/security-links.js'
10
10
  import { treeDependencyDirectory } from '../client/dependency-paths.js'
11
11
  import { liteWorkspace } from '../common/managed/finding-detail.js'
12
+ import { managedTeamView } from '../common/managed/team-app.js'
12
13
  import { expandFindingValues, findingValueIndex } from '../common/managed/finding-values.js'
13
14
  import type { BlobStore } from './blob-store.ts'
14
15
  import type { ManagedDb, TeamReportAccessSnapshot } from './db.ts'
16
+ import type { TeamWorkspaceSummary } from './team-app.ts'
15
17
  import { triageWireEntry } from './triage-response.ts'
16
18
  import { visibleManagedIssues } from './managed-issues.ts'
17
19
  import { MAX_REPORT_QUERY_BYTES, MAX_REPORT_QUERY_COUNT } from './report-query.ts'
@@ -25,9 +27,10 @@ const VISIBILITY_CACHE_MAX_SNAPSHOTS = 32
25
27
  const caches = new WeakMap<ManagedDb, Map<string, Visibility>>()
26
28
  const REPORT_CACHE_BYTES = 16 * 1024 * 1024
27
29
  // A workspace's encoded reports, the same without their findings' detail for
28
- // the board (`lite`), and its reports' file trees apart.
29
- type EncodedWorkspace = { reports: Buffer; lite: Buffer; trees: Buffer }
30
- export type TeamResponsePart = keyof EncodedWorkspace
30
+ // the board (`lite`), its reports' file trees apart, and its team's catalog
31
+ // summary (team-app.ts).
32
+ type EncodedWorkspace = { reports: Buffer; lite: Buffer; trees: Buffer; summary: TeamWorkspaceSummary }
33
+ export type TeamResponsePart = 'reports' | 'lite' | 'trees'
31
34
  // The part a team's `reports` or `trees` route asks for.
32
35
  export const teamResponsePart = (route: string, url: URL): TeamResponsePart =>
33
36
  route === 'trees' ? 'trees' : url.searchParams.get('lite') === '1' ? 'lite' : 'reports'
@@ -98,6 +101,12 @@ function groupsOf(data: unknown): Finding[][] {
98
101
  (finding): finding is Finding => finding !== null && typeof finding === 'object' && !Array.isArray(finding),
99
102
  ))
100
103
  }
104
+ // A links document counts by its links, every other report by its findings.
105
+ function hasContent(data: unknown): boolean {
106
+ const links = linksOf(data)
107
+ if (links) return links.length > 0
108
+ return (reportEntries(data) ?? []).some(entry => !Array.isArray(entry) || entry.length > 0)
109
+ }
101
110
  function linksOf(data: unknown): string[][] | null {
102
111
  const record = data as { source?: string; links?: string[][] }
103
112
  if (record?.source !== 'links' || !Array.isArray(record.links)) return null
@@ -188,25 +197,33 @@ async function buildTeamWorkspace(db: ManagedDb, store: BlobStore, snapshot: Tea
188
197
  }
189
198
  const trees = Buffer.from(`{"trees":{${reports.map(withoutTree).filter(tree => tree !== null).join(',')}}}`)
190
199
  const links = mergeLinkGroups(globalLinks, allIds)
191
- // The board's: its findings without their detail, and in App mode its rows
192
- // as the App view shows them (common/managed/finding-detail.js).
193
- const lite = liteWorkspace(reports, links)
200
+ // Its rows read once (common/managed/team-app.js managedTeamView) for both
201
+ // what its catalog entry tells and the board's copy: its findings without
202
+ // their detail, and in App mode its rows as the App view shows them
203
+ // (common/managed/finding-detail.js).
204
+ const view = managedTeamView(Object.assign(reports.map(({ filename, data }) => ({ filename, data })), { links }))
205
+ const lite = liteWorkspace(reports, links, view)
206
+ const restricted = snapshot.reports.some(report => !report.permissions.dependencies || !report.permissions.security)
194
207
  const encoded = {
195
208
  // Bounded together, as when the trees were sent with their reports.
196
209
  reports: encodeReports(reports, links, trees.length),
197
- lite: encodeReports(lite.reports, links, 0, lite.folded),
210
+ lite: encodeReports(lite.reports, links, 0, { folded: lite.folded, lens: lite.lens }),
198
211
  trees,
212
+ // Its App classification, and the reports a restricted reader finds
213
+ // nothing in, which its catalog leaves out.
214
+ summary: { app: view.app, empty: restricted ? reports.filter(report => !hasContent(report.data)).map(report => report.id) : [] },
199
215
  }
200
216
  retainVisibility(db, workspaceKey(snapshot), visible)
201
217
  retainReports(db, workspaceKey(snapshot), encoded)
202
218
  return { ...encoded, visible }
203
219
  }
204
220
  // `{ reports, links }` as a response sends them, `spent` bytes already
205
- // counted against the bound; `folded` where the board's copy left out rows
206
- // App mode does not show (common/managed/finding-detail.js). Its findings'
207
- // packages and repositories are sent once each, in `values`
221
+ // counted against the bound; `folded` and its `lens` where the board's copy
222
+ // left out rows App mode does not show (common/managed/finding-detail.js).
223
+ // Its findings' packages and repositories are sent once each, in `values`
208
224
  // (common/managed/finding-values.js).
209
- function encodeReports(reports: readonly TeamReport[], links: readonly string[][], spent: number, folded = false): Buffer {
225
+ function encodeReports(reports: readonly TeamReport[], links: readonly string[][], spent: number,
226
+ { folded = false, lens = null }: { folded?: false | 'rows' | 'app'; lens?: unknown } = {}): Buffer {
210
227
  let outputBytes = spent + 14
211
228
  const parts = [Buffer.from('{"reports":[')]
212
229
  const values = findingValueIndex()
@@ -217,7 +234,7 @@ function encodeReports(reports: readonly TeamReport[], links: readonly string[][
217
234
  if (index) parts.push(Buffer.from(','))
218
235
  parts.push(bytes)
219
236
  }
220
- const tail = JSON.stringify({ ...links.length > 0 ? { links } : {}, ...folded ? { folded } : {}, ...values.values.length > 0 ? { values: values.values } : {} })
237
+ const tail = JSON.stringify({ ...links.length > 0 ? { links } : {}, ...folded ? { folded, lens } : {}, ...values.values.length > 0 ? { values: values.values } : {} })
221
238
  const suffix = Buffer.from(tail === '{}' ? ']}' : `],${tail.slice(1)}`)
222
239
  if (outputBytes + suffix.length > MAX_REPORT_QUERY_BYTES) throw new TeamReportsError(413, 'batch-too-large')
223
240
  parts.push(suffix)
@@ -243,6 +260,10 @@ export async function loadTeamReportsResponse(db: ManagedDb, store: BlobStore, s
243
260
  const cached = reportCaches.get(db)?.get(workspaceKey(snapshot))
244
261
  return cached?.[part] ?? (await loadTeamWorkspace(db, store, snapshot))[part]
245
262
  }
263
+ // A team's catalog summary (team-app.ts), as its workspace was built.
264
+ export async function loadTeamSummary(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot): Promise<TeamWorkspaceSummary> {
265
+ return reportCaches.get(db)?.get(workspaceKey(snapshot))?.summary ?? (await loadTeamWorkspace(db, store, snapshot)).summary
266
+ }
246
267
  export async function loadTeamReports(db: ManagedDb, store: BlobStore, snapshot: TeamReportAccessSnapshot): Promise<TeamReport[]> {
247
268
  // Object consumers get their own copy, including when sharing a cold load.
248
269
  const body = JSON.parse((await loadTeamReportsResponse(db, store, snapshot)).toString('utf8')) as { reports: TeamReport[]; values?: unknown[] }
@@ -318,7 +339,7 @@ export async function loadTeamAnnotations(db: ManagedDb, store: BlobStore, snaps
318
339
  const revision = await teamAnnotationRevision(db, snapshot, [...all])
319
340
  const { triage, comments, issues: savedIssues } = await db.getAnnotations([...ids])
320
341
  const issues = Object.fromEntries(visibleManagedIssues(savedIssues, snapshot)
321
- .map(issue => [issue.findingId, { url: issue.issueUrl!, autoFix: issue.autoFixUrl }]))
342
+ .map(issue => [issue.findingId, { url: issue.issueUrl!, autoFix: issue.autoFixUrl, duplicateOf: issue.duplicateOfUrl }]))
322
343
  const entries = Object.fromEntries(triage.map(row => [row.findingId, triageWireEntry(row)]))
323
344
  const annotated = new Set([...triage.map(row => row.findingId), ...comments.map(comment => comment.findingId), ...Object.keys(issues)])
324
345
  const reports = Object.fromEntries([...visible].map(([id, report]) => [id, [...report.ids].filter(finding => annotated.has(finding))]))
@@ -9,11 +9,13 @@ import type { ManagedSql } from './sql.ts'
9
9
 
10
10
  // Records @preventive/upstream would otherwise keep in its disk cache, shared
11
11
  // by every instance: each repository's published advisory listing, written by
12
- // dependency audits that ask repositories, keyed `github/advisories/owner/name`.
13
- // Upstream stamps, validates and expires each value (90 minutes for a listing);
14
- // a refresh replaces the row, and there is one row per repository, so rows are
15
- // not evicted. Only public repositories publish advisories: rows are shared
16
- // across viewers.
12
+ // dependency audits that ask repositories, keyed `github/advisories/owner/name`,
13
+ // and each npm package npm's registry serves anyone, written by audits that ask
14
+ // OSV, keyed `npm/public/name`. Upstream stamps, validates and expires each
15
+ // value (90 minutes for a listing, a month for a public name); a refresh
16
+ // replaces the row, and there is one row per repository or name, so rows are
17
+ // not evicted. Only public repositories publish advisories, and only names
18
+ // anyone may read are kept: rows are shared across viewers.
17
19
  export const UPSTREAM_CACHE_SCHEMA = `
18
20
  CREATE TABLE IF NOT EXISTS managed_upstream_cache (
19
21
  cache_key TEXT PRIMARY KEY,
@@ -88,35 +90,42 @@ export function upstreamCacheMethods(db: ManagedSql): UpstreamCacheStore {
88
90
  }
89
91
 
90
92
  // An audit's `cache`: where the server has an upstream disk cache (off Vercel,
91
- // set at startup), that keeps everything; else this store keeps listings.
92
- export function auditCache(cacheDir: string | null | undefined, db: UpstreamCacheStore, signal: AbortSignal, debug = false, repos: Iterable<string> = []): CacheStore | undefined {
93
- return cacheDir ? undefined : upstreamCache(db, signal, debug, repos)
93
+ // set at startup), that keeps everything; else this store keeps listings and
94
+ // public names, those of `keys` (auditedKeys) read at once.
95
+ export function auditCache(cacheDir: string | null | undefined, db: UpstreamCacheStore, signal: AbortSignal, debug = false, keys: Iterable<string> = []): CacheStore | undefined {
96
+ return cacheDir ? undefined : upstreamCache(db, signal, debug, keys)
94
97
  }
95
98
 
96
- // The repositories whose listings an audit of `packages` asks for, where they
97
- // are already known: each `github` package, each `soldeer` package's given
98
- // repository, and with `repoAdvisories`, every other package's. Upstream looks
99
- // up the rest itself.
100
- export function auditedRepos(packages: Iterable<Package>, repoAdvisories: boolean): string[] {
101
- const repos = [...packages].map(pkg => (pkg.ecosystem === 'github' ? pkg.name
102
- : pkg.ecosystem === 'soldeer' || repoAdvisories ? pkg.github : undefined))
103
- return [...new Set(repos.filter(repo => repo !== undefined))]
104
- }
99
+ // Only listings and public names are kept: upstream's other records (npm
100
+ // version documents, registries' repository lookups) read as misses and are
101
+ // not written.
102
+ const LISTINGS = 'github/advisories'
103
+ const PUBLIC_NAMES = 'npm/public'
104
+ const CACHED_TYPES = new Set([LISTINGS, PUBLIC_NAMES])
105
105
 
106
- // Only listings are kept: upstream's other records (npm version documents,
107
- // registries' repository lookups) read as misses and are not written.
108
- const CACHED_TYPE = 'github/advisories'
106
+ // What an audit of `packages` reads first, where it is already known: the
107
+ // listings of the repositories it knows, each `github` package, each `soldeer`
108
+ // package's given repository, and with `repoAdvisories`, every other
109
+ // package's, upstream looking up the rest itself; and whether each npm package
110
+ // is public, as upstream asks before it asks OSV of it. Each as upstream asks
111
+ // for it, a listing by its repository's lowercased name.
112
+ export function auditedKeys(packages: Iterable<Package>, repoAdvisories: boolean): string[] {
113
+ return [...new Set([...packages].flatMap(pkg => {
114
+ const repo = pkg.ecosystem === 'github' ? pkg.name : pkg.ecosystem === 'soldeer' || repoAdvisories ? pkg.github : undefined
115
+ return [...pkg.ecosystem === 'npm' ? [`${PUBLIC_NAMES}/${pkg.name}`] : [], ...repo === undefined ? [] : [`${LISTINGS}/${repo.toLowerCase()}`]]
116
+ }))]
117
+ }
109
118
 
110
119
  // The cache is an optimization: a database failure is a miss, never a failed
111
120
  // audit. Upstream keeps listing after an abandoned audit; once `signal` aborts,
112
121
  // the request's database work is over and the store is left alone.
113
- // Upstream reads one listing at a time per repository, and a request's queries
114
- // share one connection (Neon), so a recheck of hundreds of packages would wait
115
- // on as many round trips: the first read asks for every listing of `repos`
116
- // at once. Any other key, or all of them if that read fails, is read alone.
117
- export function upstreamCache(db: UpstreamCacheStore, signal: AbortSignal, debug = false, repos: Iterable<string> = []): CacheStore {
118
- // Upstream asks for a listing by its repository's lowercased name.
119
- const batched = new Set([...repos].map(repo => `${CACHED_TYPE}/${repo.toLowerCase()}`))
122
+ // Upstream reads one listing at a time per repository, and whether a name is
123
+ // public eight at a time, and a request's queries share one connection (Neon),
124
+ // so a recheck of hundreds of packages would wait on as many round trips: the
125
+ // first read asks for every one of `keys` at once. Any other key, or all of
126
+ // them if that read fails, is read alone.
127
+ export function upstreamCache(db: UpstreamCacheStore, signal: AbortSignal, debug = false, keys: Iterable<string> = []): CacheStore {
128
+ const batched = new Set(keys)
120
129
  let batch: Promise<Map<string, string> | null> | undefined
121
130
  const readBatch = () => batch ??= db.getUpstreamCacheEntries([...batched]).catch((error: unknown) => {
122
131
  if (debug) console.warn('managed: upstream cache read failed:', error)
@@ -124,7 +133,7 @@ export function upstreamCache(db: UpstreamCacheStore, signal: AbortSignal, debug
124
133
  })
125
134
  return {
126
135
  async read(type, key) {
127
- if (type !== CACHED_TYPE || signal.aborted) return null
136
+ if (!CACHED_TYPES.has(type) || signal.aborted) return null
128
137
  const cacheKey = `${type}/${key}`
129
138
  try {
130
139
  const found = batched.has(cacheKey) ? await readBatch() : null
@@ -136,7 +145,7 @@ export function upstreamCache(db: UpstreamCacheStore, signal: AbortSignal, debug
136
145
  }
137
146
  },
138
147
  async write(type, key, value) {
139
- if (type !== CACHED_TYPE || signal.aborted) return
148
+ if (!CACHED_TYPES.has(type) || signal.aborted) return
140
149
  try { await db.setUpstreamCacheEntry(`${type}/${key}`, JSON.stringify(value), Date.now()) } catch (error) {
141
150
  if (debug) console.warn('managed: upstream cache write failed:', error)
142
151
  }
@@ -224,10 +233,10 @@ export async function lastListing(cacheDir: string | null | undefined, db: Upstr
224
233
  let kept: { at?: unknown } | null
225
234
  try {
226
235
  if (cacheDir) {
227
- const bytes = await readKeptFile(upstreamCachePath(cacheDir, CACHED_TYPE, `${key}.json.gz`), LISTING_BYTES)
236
+ const bytes = await readKeptFile(upstreamCachePath(cacheDir, LISTINGS, `${key}.json.gz`), LISTING_BYTES)
228
237
  kept = bytes && JSON.parse((await gunzipAsync(bytes, { maxOutputLength: LISTING_BYTES })).toString('utf8'))
229
238
  } else {
230
- const value = await db.getUpstreamCacheEntry(`${CACHED_TYPE}/${key}`)
239
+ const value = await db.getUpstreamCacheEntry(`${LISTINGS}/${key}`)
231
240
  kept = value === null ? null : JSON.parse(value)
232
241
  }
233
242
  } catch (error) {
@@ -237,7 +246,7 @@ export async function lastListing(cacheDir: string | null | undefined, db: Upstr
237
246
  const at = kept?.at
238
247
  if (typeof at !== 'number') return null
239
248
  return { at, cache: {
240
- read: (type, name) => Promise.resolve(type === CACHED_TYPE && name === key ? { ...kept, at: Date.now() } : null),
249
+ read: (type, name) => Promise.resolve(type === LISTINGS && name === key ? { ...kept, at: Date.now() } : null),
241
250
  write: () => Promise.resolve(),
242
251
  } }
243
252
  }
@@ -146,6 +146,7 @@ export function workspaceShareMethods(db: ManagedSql): WorkspaceShareStore {
146
146
  const bundleRows = (await q.bundles.all(team.id) as (Omit<ManagedBundle, 'buildConditions'> & { buildConditions: string | null; repoFullName: string })[])
147
147
  .map(row => ({ ...row, buildConditions: row.buildConditions == null ? null : JSON.parse(row.buildConditions) as BundleBuildConditions }))
148
148
  const repositories = await q.repositories.all(team.id) as WorkspaceShareSnapshot['repositories']
149
+ const keyOf = (row: typeof rows[number]) => JSON.stringify([row.sha256, row.github, row.directory, row.filename, permissions, links])
149
150
  return {
150
151
  user: { id: `share:${tokenHash}`, login: 'public', name: 'Public workspace', avatarUrl: null, role: 'view' },
151
152
  teamId: team.id,
@@ -154,11 +155,12 @@ export function workspaceShareMethods(db: ManagedSql): WorkspaceShareStore {
154
155
  repositories,
155
156
  reports: rows.map(row => ({ id: row.id, filename: row.filename, byteSize: row.byteSize, sha256: row.sha256,
156
157
  repo: { github: row.github, directory: row.directory }, permissions })),
158
+ catalogKeys: Object.fromEntries(rows.map(row => [row.id, keyOf(row)])),
157
159
  team: { ...team, permissions, cacheKey: links,
158
160
  repos: repositories.map(repo => ({ repoId: repo.repoId, fullName: repo.github, path: repo.path || null }))
159
161
  .toSorted((a, b) => a.fullName.localeCompare(b.fullName) || (a.path ?? '').localeCompare(b.path ?? '')),
160
162
  reports: rows.map(row => ({ id: row.id, slug: row.slug, filename: row.filename, visible: true, analyzer: row.analyzer, repoFullName: row.github, repoDirectory: row.directory,
161
- cacheKey: JSON.stringify([row.sha256, row.github, row.directory, row.filename, permissions, links]) })),
163
+ cacheKey: keyOf(row) })),
162
164
  bundles: bundleRows.map(row => ({ id: row.id, slug: row.slug, integrity: row.integrity,
163
165
  filename: row.filename, visible: true, kind: row.kind, byteSize: row.byteSize, repoId: row.repoId!, repoDirectory: row.repoDirectory, repoFullName: row.repoFullName, provenance: row.provenance })),
164
166
  },
@@ -1 +0,0 @@
1
- import{b as e,c as t,d as n,e as r,f as i,g as a,h as o,i as s,j as c,k as l,m as u,n as d}from"./chunk-PXK7EU4V.js";import{b as f}from"./chunk-OOJM4CTU.js";var p=globalThis.atob,m=Uint8Array.prototype.toBase64,h=8192,g=m&&p;function _(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return``;if(g&&r>=256&&r<1e8&&e.toBase64===m&&e.BYTES_PER_ELEMENT===1)return p((t===0&&n===e.length?e:e.subarray(t,n)).toBase64());if(r>h){let r=``;for(let i=t;i<n;){let t=Math.min(n,i+h);r+=String.fromCharCode.apply(String,e.subarray(i,t)),i=t}return r}let i=t===0&&n===e.length?e:e.subarray(t,n);return String.fromCharCode.apply(String,i)}var v=t?e=>e.byteLength>=768&&!r?t.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):a.decode(e):o?e=>o.decode(e):e=>_(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),ee=t=>e(t,new Uint8Array(t.length)),y=n&&i?.encodeInto?(e,t)=>{let n=new Uint8Array(e.length+4),r=i.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw SyntaxError(t);return n.subarray(0,e.length)}:t?(e,n)=>{let r=t.from(e,`utf8`);if(r.length!==e.length)throw SyntaxError(n);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}:(e,t)=>{let n=i.encode(e);if(n.length!==e.length)throw SyntaxError(t);return n},b,x,S,C=12336,te=26214,ne=`0123456789ABCDEFabcdef`,w=`Input is not a hex string`;function re(e){b||=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));let t=e.length;if(a){if(!x){x=new Uint16Array(256);let e=new Uint8Array(x.buffer,x.byteOffset,x.byteLength);for(let t=0;t<256;t++){let n=b[t];e[2*t]=n.charCodeAt(0),e[2*t+1]=n.charCodeAt(1)}}let n=new Uint16Array(t),r=0;for(let t=e.length-3;!(r>=t);r+=4){let t=e[r],i=e[r+1],a=e[r+2],o=e[r+3];n[r]=x[t],n[r+1]=x[i],n[r+2]=x[a],n[r+3]=x[o]}for(;r<t;r++)n[r]=x[e[r]];return v(n)}return s(e,0,t,b)}function ie(e){if(typeof e!=`string`)throw TypeError(l);if(e.length%2!=0)throw SyntaxError(w);let t=e.length/2,n=new Uint8Array(t);if(i){if(!S){S=new Uint8Array(te+1);let e=new Uint8Array(2),t=new Uint16Array(e.buffer,e.byteOffset,1),n=[...ne].map(e=>[e.charCodeAt(0),parseInt(e,16)]);for(let[r,i]of n){e[0]=r;for(let[r,a]of n)e[1]=r,S[t[0]]=i<<4|a}}let r=y(e,w),i=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),a=0;for(let e=t-3;a<e;a+=4){let e=i[a],t=i[a+1],r=i[a+2],o=i[a+3],s=S[e],c=S[t],l=S[r],u=S[o];if(!s&&e!==C||!c&&t!==C||!l&&r!==C||!u&&o!==C)throw SyntaxError(w);n[a]=s,n[a+1]=c,n[a+2]=l,n[a+3]=u}for(;a<t;){let e=i[a],t=S[e];if(!t&&e!==C)throw SyntaxError(w);n[a++]=t}}else{if(!S){S=new Int8Array(128).fill(-1);for(let e=0;e<16;e++){let t=e.toString(16);S[t.charCodeAt(0)]=S[t.toUpperCase().charCodeAt(0)]=e}}let r=0;for(let i=0;i<t;i++){let t=e.charCodeAt(r++),a=e.charCodeAt(r++),o=S[t]<<4|S[a];if(o<0||(127|t|a)!=127)throw SyntaxError(w);n[i]=o}}return n}var{toHex:T}=Uint8Array.prototype;function ae(e){return c(e),e.length===0?``:T&&e.toHex===T?e.toHex():re(e)}var oe=Uint8Array.fromHex?(e,t=`uint8`)=>u(Uint8Array.fromHex(e),t):(e,t=`uint8`)=>u(ie(e),t);function E(e){if(Object.keys(e).length>0)throw TypeError(`Unexpected extra options`)}Object.getPrototypeOf(Uint8Array);var D={};f(D,{E_CHAR:()=>M,E_LAST:()=>F,E_LENGTH:()=>P,E_PADDING:()=>N,fromBase64:()=>L,toBase64:()=>I});var O=[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`],k=[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`],A={},j={},M=`Invalid character in base64 input`,N=`Invalid base64 padding`,P=`Invalid base64 length`,F=`Invalid last chunk`;function I(e,t,n){let r=e.length/3|0,i=r*3,o=``,s=0,c=t?k:O,l=t?j:A;if(!l.pairs){if(l.pairs=[],a){l.codepairs=new Uint16Array(4096);let e=l.codepairs,t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e<64;e++){let n=c[e].charCodeAt(0);for(let r=0;r<64;r++)t[e<<7|r<<1]=t[r<<7|(e<<1)+1]=n}}else{let e=l.pairs;for(let t=0;t<64;t++)for(let n=0;n<64;n++)e.push(`${c[t]}${c[n]}`)}}let{pairs:u,codepairs:d}=l;if(a){let t=new Uint16Array(r*2),n=0;for(let r=e.length-11;s<r;s+=12,n+=8){let r=e[s],i=e[s+1],a=e[s+2],o=e[s+3],c=e[s+4],l=e[s+5],u=e[s+6],f=e[s+7],p=e[s+8],m=e[s+9],h=e[s+10],g=e[s+11];t[n]=d[r<<4|i>>4],t[n+1]=d[(i&15)<<8|a],t[n+2]=d[o<<4|c>>4],t[n+3]=d[(c&15)<<8|l],t[n+4]=d[u<<4|f>>4],t[n+5]=d[(f&15)<<8|p],t[n+6]=d[m<<4|h>>4],t[n+7]=d[(h&15)<<8|g]}for(let r=e.length-2;s<r;s+=3,n+=2){let r=e[s],i=e[s+1],a=e[s+2];t[n]=d[r<<4|i>>4],t[n+1]=d[(i&15)<<8|a]}o=v(t)}else for(;s<i;s+=3){let t=e[s],n=e[s+1],r=e[s+2];o+=u[t<<4|n>>4],o+=u[(n&15)<<8|r]}let f=0,p=2,m=e.length;for(;s<m;s++){let t=e[s];o+=c[f|t>>p],p===6&&(p=0,o+=c[t&63]),f=t<<6-p&63,p+=2}return p!==2&&(o+=c[f]),n&&(o+=[``,`==`,`=`][m-i]),o}var se=i?128:65536;function L(e,t){let n=e.length;for(;e[n-1]===`=`;)n--;let r=e.length-n,a=n%4,o=n-a;if(a===1)throw SyntaxError(P);if(r>3||r!==0&&e.length%4!=0)throw SyntaxError(N);let s=t?k:O,c=t?j:A;c.fromMap||(c.fromMap=new Int8Array(se).fill(-1),s.forEach((e,t)=>c.fromMap[e.charCodeAt(0)]=t));let l=c.fromMap,u=new Uint8Array(Math.floor(n*3/4)),d=0,f=0;if(i){let t=y(e,M);for(;f<o;f+=4){let e=t[f],n=t[f+1],r=t[f+2],i=t[f+3],a=l[e]<<18|l[n]<<12|l[r]<<6|l[i];if(a<0)throw SyntaxError(M);u[d]=a>>16,u[d+1]=a>>8&255,u[d+2]=a&255,d+=3}}else for(;f<o;f+=4){let t=e.charCodeAt(f),n=e.charCodeAt(f+1),r=e.charCodeAt(f+2),i=e.charCodeAt(f+3),a=l[t]<<18|l[n]<<12|l[r]<<6|l[i];if(a<0)throw SyntaxError(M);u[d]=a>>16,u[d+1]=a>>8&255,u[d+2]=a&255,d+=3}if(a<2)return u;let p=l[e.charCodeAt(f++)]<<6|l[e.charCodeAt(f++)];if(p<0)throw SyntaxError(M);if(u[d++]=p>>4,a<3){if(p&15)throw SyntaxError(F);return u}let m=l[e.charCodeAt(f++)];if(m<0)throw SyntaxError(M);if(u[d++]=p<<4&255|m>>2,m&3)throw SyntaxError(F);return u}var{Buffer:R,atob:z,btoa:B}=globalThis,V=R&&!R.TYPED_ARRAY_SUPPORT,{toBase64:H}=Uint8Array.prototype,{E_CHAR:U,E_PADDING:W,E_LENGTH:ce,E_LAST:le}=D,ue=B&&n,de=z&&n,fe=e=>e.constructor===R&&R.isBuffer(e),pe=e=>fe(e)?e:R.from(e.buffer,e.byteOffset,e.byteLength);function G(e,t){if(t)return e;let n=e.indexOf(`=`,e.length-3);return n===-1?e:e.slice(0,n)}function K(e,t){return t&&e.length%4!=0?e+`=`.repeat(4-e.length%4):e}var me=e=>H&&e.toBase64===H;function q(e,{padding:t=!0}={}){return c(e),me(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):V?G(pe(e).base64Slice(0,e.byteLength),t):ue?G(B(_(e)),t):I(e,!1,t)}function he(e,t){if(typeof t==`string`&&(t={format:t}),!t)return J(e,!1,`both`,`uint8`,null);let{format:n=`uint8`,padding:r=`both`,...i}=t;return J(e,!1,r,n,i)}function J(e,t,n,r,i){if(typeof e!=`string`)throw TypeError(l);i!==null&&E(i);let a=n===`both`?e.endsWith(`=`):void 0;if(n===!0||a===!0){if(e.length%4!=0||e[e.length-3]===`=`)throw SyntaxError(W)}else if(n===!1||a===!1){if(e.length%4==1)throw SyntaxError(ce);if(n===!1&&e.endsWith(`=`))throw SyntaxError(`Did not expect padding in base64 input`)}else throw TypeError(`Invalid padding option`);return _e(e,t,n,r)}var ge=/[\t\n\f\r ]/;function Y(e,t){let n=e.indexOf(`=`,e.length-3),r=n>=0?e.length-n:0,i=e.length-r,a=i%4,o=t.length-(i-a)/4*3;return a===0&&o===0||a===2&&o===1||a===3&&o===2}var _e=Uint8Array.fromBase64?(e,t,n,r)=>{let i=t?`base64url`:`base64`,a;if(n===!0)a=Uint8Array.fromBase64(e,{alphabet:i,lastChunkHandling:`strict`});else try{let t=e.length%4>0?`${e}${`=`.repeat(4-e.length%4)}`:e;a=Uint8Array.fromBase64(t,{alphabet:i,lastChunkHandling:`strict`})}catch(t){throw ge.test(e)?SyntaxError(U):t}if(!Y(e,a))throw SyntaxError(U);return u(a,r)}:V?(e,t,n,r)=>{let i=R.byteLength(e,`base64`),a=R.allocUnsafeSlow(i);if(a.base64Write(e)!==i)throw SyntaxError(W);let o=t?a.base64urlSlice(0,a.length):a.base64Slice(0,a.length);if(e!==o&&(n===!t||K(e,!0)!==K(o,t)))throw SyntaxError(W);return d(a,r)}:de?(e,t,n,r)=>{let i;if(t){if(/[\t\n\f\r +/]/.test(e))throw SyntaxError(U);e=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`)}try{i=ee(z(e))}catch{throw SyntaxError(U)}if(!t&&!Y(e,i))throw SyntaxError(U);if(i.length%3!=0&&q(i.subarray(-(i.length%3)))!==(e.length%4==0?e.slice(-4):e.slice(-(e.length%4)).padEnd(4,`=`)))throw SyntaxError(le);return u(i,r)}:(e,t,n,r)=>u(L(e,t),r),X=[{},{},{}],Z=[[...`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`],[...`0123456789ABCDEFGHIJKLMNOPQRSTUV`],[...`0123456789ABCDEFGHJKMNPQRSTVWXYZ`]],Q=`Invalid character in base32 input`,ve=`Invalid base32 padding`,ye=`Invalid base32 length`,$=`Invalid last chunk`,be=n;function xe(e,t,n){c(e);let r=Math.floor(e.length/5),i=r*5,o=``,s=0,l=Z[t],u=X[t];if(!u.pairs){if(u.pairs=[],a){u.codepairs=new Uint16Array(1024);let e=u.codepairs,t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e<32;e++){let n=l[e].charCodeAt(0);for(let r=0;r<32;r++)t[e<<6|r<<1]=t[r<<6|(e<<1)+1]=n}}else{let e=u.pairs;for(let t=0;t<32;t++)for(let n=0;n<32;n++)e.push(`${l[t]}${l[n]}`)}}let{pairs:d,codepairs:f}=u;if(a){let t=new Uint16Array(r*4);for(let n=0;s<i;s+=5){let r=e[s],i=e[s+1],a=e[s+2],o=e[s+3],c=e[s+4],l=r<<2|i>>6,u=(i&63)<<4|a>>4,d=(a&15)<<6|o>>2,p=(o&3)<<8|c;t[n]=f[l],t[n+1]=f[u],t[n+2]=f[d],t[n+3]=f[p],n+=4}o=v(t)}else if(be)for(;s<i;s+=5){let t=e[s],n=e[s+1],r=e[s+2],i=e[s+3],a=e[s+4],c=t<<2|n>>6,l=(n&63)<<4|r>>4,u=(r&15)<<6|i>>2,f=(i&3)<<8|a;o+=`${d[c]}${d[l]}${d[u]}${d[f]}`}else for(;s<i;s+=5){let t=e[s],n=e[s+1],r=e[s+2],i=e[s+3],a=e[s+4],c=t<<2|n>>6,l=(n&63)<<4|r>>4,u=(r&15)<<6|i>>2,f=(i&3)<<8|a;o+=d[c],o+=d[l],o+=d[u],o+=d[f]}let p=0,m=3;for(;s<e.length;s++){let t=e[s];o+=l[p|t>>m],m>=5&&(m-=5,o+=l[t>>m&31]),p=t<<5-m&31,m+=3}return m!==3&&(o+=l[p]),n&&(o+=[``,`======`,`====`,`===`,`=`][e.length-i]),o}var Se=i?128:65536;function Ce(e,t){let n=e.length;for(;e[n-1]===`=`;)n--;let r=e.length-n,a=n%8,o=n-a;if(![0,2,4,5,7].includes(a))throw SyntaxError(ye);if(r>7||r!==0&&e.length%8!=0)throw SyntaxError(ve);let s=Z[t],c=X[t];if(!c.fromMap){c.fromMap=new Int8Array(Se).fill(-1);let e=c.fromMap;s.forEach((t,n)=>{e[t.charCodeAt(0)]=e[t.toLowerCase().charCodeAt(0)]=n}),t===2&&(e[73]=e[76]=e[105]=e[108]=e[49],e[79]=e[111]=e[48])}let l=c.fromMap,u=new Uint8Array(Math.floor(n*5/8)),d=0,f=0;if(i){let t=y(e,Q);for(;f<o;f+=8){let e=t[f],n=t[f+1],r=t[f+2],i=t[f+3],a=t[f+4],o=t[f+5],s=t[f+6],c=t[f+7],p=l[e]<<15|l[n]<<10|l[r]<<5|l[i],m=l[a]<<15|l[o]<<10|l[s]<<5|l[c];if(p<0||m<0)throw SyntaxError(Q);u[d]=p>>12,u[d+1]=p>>4&255,u[d+2]=p<<4&255|m>>16,u[d+3]=m>>8&255,u[d+4]=m&255,d+=5}}else for(;f<o;f+=8){let t=e.charCodeAt(f),n=e.charCodeAt(f+1),r=e.charCodeAt(f+2),i=e.charCodeAt(f+3),a=e.charCodeAt(f+4),o=e.charCodeAt(f+5),s=e.charCodeAt(f+6),c=e.charCodeAt(f+7),p=l[t]<<15|l[n]<<10|l[r]<<5|l[i],m=l[a]<<15|l[o]<<10|l[s]<<5|l[c];if(p<0||m<0)throw SyntaxError(Q);u[d]=p>>12,u[d+1]=p>>4&255,u[d+2]=p<<4&255|m>>16,u[d+3]=m>>8&255,u[d+4]=m&255,d+=5}if(a<2)return u;let p=l[e.charCodeAt(f++)]<<5|l[e.charCodeAt(f++)];if(p<0)throw SyntaxError(Q);if(u[d++]=p>>2,a<4){if(p&3)throw SyntaxError($);return u}let m=l[e.charCodeAt(f++)]<<5|l[e.charCodeAt(f++)];if(m<0)throw SyntaxError(Q);if(u[d++]=p<<6&255|m>>4,a<5){if(m&15)throw SyntaxError($);return u}let h=l[e.charCodeAt(f++)];if(h<0)throw SyntaxError(Q);if(u[d++]=m<<4&255|h>>1,a<7){if(h&1)throw SyntaxError($);return u}let g=l[e.charCodeAt(f++)]<<5|l[e.charCodeAt(f++)];if(g<0)throw SyntaxError(Q);if(u[d++]=h<<7&255|g>>3,g&7)throw SyntaxError($);return u}function we(e,t,n,r,i){if(typeof e!=`string`)throw TypeError(l);if(i!==null&&E(i),n===!0){if(e.length%8!=0)throw SyntaxError(ve)}else if(n===!1){if(e.endsWith(`=`))throw SyntaxError(`Did not expect padding in base32 input`)}else if(n!==`both`)throw TypeError(`Invalid padding option`);return u(Ce(e,t),r)}var Te=(e=>(t,n)=>{if(!n)return we(t,e,`both`,`uint8`,null);let{format:r=`uint8`,padding:i=`both`,...a}=n;return we(t,e,i,r,a)})(0),Ee=(e,{padding:t=!1}={})=>xe(e,0,t);export{q as a,he as b,ae as c,oe as d,Te as e,Ee as f};
@@ -1,6 +0,0 @@
1
- import{a as e}from"./chunk-SXV2T5C4.js";import{b as t}from"./chunk-TUII34K2.js";var n=new Set([`module`,`commonjs`,`json`,`module-typescript`,`commonjs-typescript`]),r=new Set([`solidity`,`php`,`shell`,`rust`]),i=new Set([`java`,`kotlin`,`gradle`,`objc`,`objcpp`,`swift`,`c`,`cpp`,`c-header`,`cpp-header`,`ruby`,`python`,`cmake`,`podspec`,`podfile`,`podfile-lock`,`template`,`xml`,`env`,`fastlane`,`pbxproj`]),a=new Set([`resource`,`resource:base64`]),o=new Set([`stat:file`,`stat:directory`]),s=new Set([...n,...r,...i,...a,`patch`,`directory`,...o]),c=e=>o.has(e),l=e=>e===`directory`||e===`stat:directory`?`directory`:`file`;function u(e,t,n){if(e===t)return e;let r=c(e);if(r!==c(t)&&l(e)===l(t))return r?t:e;throw Error(`format conflict for '${n}' ('${t}' vs '${e}')`)}function d(e,t){return t===``?e:e===`.`?t:`${e}/${t}`}var f=/^(?=[A-Za-z0-9-]{1,39}\/)[A-Za-z0-9](?:-?[A-Za-z0-9])*\/(?!\.\.?$)[\w.-]{1,100}$/u,p=/^(?!\.\.?(?:\/|$))[\w.~@+-]+(?:\/(?!\.\.?(?:\/|$))[\w.~@+-]+)*$/u,m=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u,h={github:e=>typeof e==`string`&&f.test(e),directory:e=>typeof e==`string`&&e.length<=1024&&(e===``||p.test(e)),commit:e=>typeof e==`string`&&m.test(e)},ee=(e,t)=>e?.toLowerCase()===t?.toLowerCase(),g=(e,t,n)=>{if(e===void 0)return;T(e)||S(!1,`${n} must be an object`);for(let r of Object.keys(e))Object.hasOwn(t,r)||S(!1,`unknown ${n} key '${r}'`);let r=Object.entries(t).map(([t,r])=>typeof r==`object`?[t,g(e[t],r,`${n}.${t}`)]:(e[t]!==void 0&&!r(e[t])&&S(!1,`invalid ${n}.${t}: ${JSON.stringify(e[t])}`),[t,e[t]])).filter(([,e])=>e!==void 0);return r.length===0?void 0:Object.freeze(E(r))},_=(e,t=`bundle repo`)=>g(e,h,t),te=(e,t)=>t??(j(e)?`npm`:void 0),ne=(e,{ecosystem:t,repo:n},r)=>{if(n===void 0)return;te(e,t)===void 0&&S(!1,`${r}: '${e}' is no dependency's bucket, and carries no repo`);let i=_(n,`${r} module '${e}' repo`);return i?.github===void 0&&S(!1,`${r} module '${e}' repo has no github`),i},re=e=>typeof e==`string`&&/^[\w.+@/~'!()*-]+$/u.test(e),v={name:re,version:re},ie=e=>typeof e==`string`&&e!==``&&!e.includes(`\\`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`node_modules`),ae=(e,t,n)=>typeof e==`string`&&ie(n)&&e===`${t}/${n}`,y={vendored:()=>!0,subpackages:(e,t,n)=>ae(e.name,t,n)},oe=(e,t)=>{for(let n=t.lastIndexOf(`/`);n>0;n=t.lastIndexOf(`/`,n-1))if(Object.hasOwn(e,t.slice(0,n)))return t.slice(0,n)};function se(e,t){if(e===void 0)return;let n=new Set;for(let r of Object.keys(t)){let t=oe(e,r);t!==void 0&&n.add(t)}return n.size===0?void 0:Object.freeze(E([...n].toSorted(C).map(t=>[t,e[t]])))}var b=(e,t,{name:n,ecosystem:r,files:i,[e]:a},o)=>{if(a===void 0)return;te(t,r)===void 0&&S(!1,`${o}: '${t}' is no dependency's bucket, and carries no ${e}`),T(a)||S(!1,`${o} module '${t}' ${e} must be an object`);let s=E(Object.entries(a).map(([r,i])=>{ie(r)||S(!1,`${o} module '${t}' ${e}: invalid directory ${JSON.stringify(r)}`);let a=g(i,v,`${o} module '${t}' ${e} '${r}'`);return a?.name===void 0&&S(!1,`${o} module '${t}' ${e} '${r}' has no name`),y[e](a,n,r)||S(!1,`${o} module '${t}' ${e} '${r}' is named '${a.name}', not '${n}/${r}'`),[r,a]})),c=se(s,i);for(let n of Object.keys(s))Object.hasOwn(c??{},n)||S(!1,`${o} module '${t}' ${e} '${n}' holds none of its files`);return c},x=({name:e,version:t,ecosystem:n,repo:r,vendored:i,subpackages:a,files:o})=>({name:e,version:t,...n===void 0?{}:{ecosystem:n},...r===void 0?{}:{repo:r},...i===void 0?{}:{vendored:i},...a===void 0?{}:{subpackages:a},files:o});function ce(e,t){let n=e.repo??t.repo,r=Object.keys(y).filter(n=>t[n]!==void 0&&Object.keys(t[n]).some(t=>!Object.hasOwn(e[n]??{},t)));if(n===e.repo&&r.length===0)return e;let i=E(r.map(n=>[n,Object.freeze(E([...Object.entries(t[n]),...Object.entries(e[n]??{})]))]));return x({...e,repo:n,...i})}var le=(e,t,n,r,i)=>E(Object.keys(y).map(a=>[a,i.includes(a)?b(a,e,{...t,files:n,[a]:se(t[a],n)},r):void 0]));function ue({name:e,version:t,ecosystem:n,repo:r,vendored:i,subpackages:a,files:o},s,c){return S(n===void 0||typeof n==`string`),o=E(Object.entries(o)),x({name:e,version:t??void 0,ecosystem:n,repo:ne(s,{ecosystem:n,repo:r},c),vendored:b(`vendored`,s,{name:e,ecosystem:n,files:o,vendored:i},c),subpackages:b(`subpackages`,s,{name:e,ecosystem:n,files:o,subpackages:a},c),files:o})}function de(e,{scope:t=`full`}={}){let n=new Set;for(let[r,{files:i}]of e)if(t===`full`||j(r))for(let e of Object.keys(i))n.add(d(r,e));return n}function fe(e,{what:t,files:n,formats:r,scope:i}){if(e.includes(`\\`))return`holds a '\\'`;if(D(e))return`escapes the root`;if(i!==`full`&&!j(e))return`is outside node_modules, which a '${i}'-scope ${t} does not record`;if(!n.has(e))return`names no file the ${t} records`;let a=r.get(e);return a===`directory`?`is a directory capture, not a file`:c(a)?`is a payload-free '${a}' record, not a file`:null}function pe(e,{what:t,files:n,formats:r,scope:i}){for(let a of e){let e=fe(a,{what:t,files:n,formats:r,scope:i});S(e===null,`${t}: executable entry '${a}' ${e}`)}}function me(e,{what:t,files:n,formats:r,scope:i=`full`}){if(e===void 0)return new Set;let a=`${t}: executable`;S(Array.isArray(e),`${a} must be an array of file paths`);let o=new Set;for(let t of e)S(typeof t==`string`&&t!==``,`${a} entry must be a non-empty string`),S(!o.has(t),`${a} entry '${t}' is listed twice`),o.add(t);return pe(o,{what:t,files:n,formats:r,scope:i}),o}function he(e,{what:t,modules:n,formats:r,scope:i}){if(e.size!==0)return pe(e,{what:t,files:de(n,{scope:i}),formats:r,scope:i}),ge(e)}function S(e,t){if(!e)throw Error(t)}function C(e,t){let[n,r]=[e.split(`/`),t.split(`/`)];for(;n.length>0&&n[0]===r[0];)n.shift(),r.shift();if(n.length===0&&r.length===0)return 0;if(n.length<2)return r.length<2&&n>r?1:-1;if(r.length<2)return 1;if(n[0]===`*`)return-1;if(r[0]===`*`||n[0]===`node_modules`)return 1;if(r[0]===`node_modules`)return-1;let[i,a]=[n,r].map(e=>e.join(String.fromCodePoint(0)));if(i<a)return-1;if(i>a)return 1;throw Error(`Unreachable`)}var w=(e,t)=>C(e[0],t[0]),T=e=>e&&[null,Object.prototype].includes(Object.getPrototypeOf(e)),E=e=>Object.setPrototypeOf(Object.fromEntries(e),null),ge=e=>[...e].toSorted(C),_e=(e,{sorted:t=!0}={})=>E((t?[...e].toSorted(w):[...e]).map(([e,n])=>[e,n instanceof Map?_e(n,{sorted:t}):n])),ve=(e,t)=>e.get(t)??e.set(t,new Map).get(t),ye=e=>new Map(Object.entries(e).map(([e,t])=>[e,T(t)?ye(t):t]));function D(e){if(e.startsWith(`/`))return!0;if(!e.includes(`..`))return!1;let t=0;for(let n of e.split(`/`))if(n!==`.`&&n!==``){if(n!==`..`)t++;else if(--t<0)return!0}return!1}var be=e=>e.includes(`\\`)||D(e),O=(e,t)=>S(!be(e),`${t}: path '${e}' escapes the root or holds a '\\'`),xe=(e,t)=>S(typeof e==`string`&&e!==``&&!be(e),`${t}: invalid entry ${JSON.stringify(e)}`);function Se(e,t){S(Array.isArray(e),`${t}: entries must be an array of file paths`);let n=new Set;for(let r of e)xe(r,t),S(!n.has(r),`${t}: entry '${r}' is listed twice`),n.add(r);return n}function Ce(e,t){for(let n of e)xe(n,t);return ge(e)}function we(e,t){O(e,`formats`),S(s.has(t),`unknown format '${t}' for ${e}`)}function Te(e){S(T(e));let t=new Map;for(let[n,r]of Object.entries(e)){we(n,r);let e=n===``?`.`:n;S(!t.has(e),`duplicate format key '${e}'`),t.set(e,r)}return t}function Ee(e){for(let[t,n]of e)we(t,n);return _e(e)}function De(e){for(let[,t]of e){S(t instanceof Map);for(let[e,n]of t){O(e,`imports`),S(n instanceof Map);for(let[,e]of n){if(typeof e==`string`){O(e,`imports`);continue}S(e instanceof Map&&e.size>0,`import target must be a file or a non-empty {platform: file} map`);for(let[t,n]of e)S(typeof t==`string`&&t.length>0&&!t.includes(`/`),`invalid platform key '${t}'`),S(typeof n==`string`),O(n,`imports`)}}}}function Oe(e){S(T(e));let t=ye(e);return De(t),t}function ke(e){return De(e),_e(e)}function Ae(e,{skipEmpty:t=!1,metadata:n=!0,what:r}={}){let i=n===!0?[`repo`,...Object.keys(y)]:n===!1?[]:n,a={modules:[],sources:[]};for(let[n,o]of e){if(t&&Object.keys(o.files).length===0)continue;let e=j(n);e&&S(o.name&&o.version&&o.files);let s=E(Object.entries(o.files).toSorted(w));a[e?`modules`:`sources`].push([n,x({...o,repo:i.includes(`repo`)?ne(n,o,r):void 0,...le(n,o,s,r,i),files:s})])}return{modules:E(a.modules.toSorted(w)),sources:E(a.sources.toSorted(w))}}function je(e,t){let n=e instanceof Map;if(n!==t instanceof Map)return!1;if(!n)return e===t;if(e.size!==t.size)return!1;for(let[n,r]of e)if(t.get(n)!==r)return!1;return!0}var Me=e=>e instanceof Map?`{${[...e].map(([e,t])=>`${e}: ${t}`).join(`, `)}}`:e;function Ne(e,t,n){let r=new Map,i=e=>{for(let[t,i]of e){let e=ve(r,t);for(let[t,r]of i){let i=ve(e,t);for(let[e,a]of r)i.has(e)?S(je(i.get(e),a),`${n}: import '${e}' from '${t}' resolves differently ('${Me(i.get(e))}' vs '${Me(a)}')`):i.set(e,a instanceof Map?new Map(a):a)}}};return i(e),i(t),r}function Pe(e,t,n){let r=new Map,i=e=>{for(let[t,i]of e){let e=r.get(t);if(e===void 0){r.set(t,i);continue}try{r.set(t,u(i,e,t))}catch(e){throw Error(`${n}: ${e.message}`,{cause:e})}}};return i(e),i(t),r}function Fe(e,t,n,r){if(e.size===0)return new Set(t);let i=de(n,{scope:r}),a=new Set(t);for(let t of e)i.has(t)||a.add(t);return a}var Ie=/(?:^|\/)\.{0,2}(?:\/|$)/u;function k(e,t,n){let r=d(e,t);return(r!==`.`||t!==``)&&Ie.test(r)&&S(!1,`${n}: non-canonical file key ${JSON.stringify(r)}`),r.includes(`\\`)&&S(!1,`${n}: file key '${r}' holds a '\\', which no path may`),r}function A(e,t,n){let r=new Map;for(let[i,{files:a}]of e){typeof i!=`string`&&S(!1,`${t}: bucket dir ${String(i)} is not a string`),O(i,t);for(let e of Object.keys(a)){let a=k(i,e,t),o=r.get(a);o!==void 0&&n(a,o,i),r.set(a,i)}}return r}var Le=(e,t)=>n=>S(!1,`duplicate file key '${n}' across ${e} buckets -- module bucketing changed between writes (a workspace package without a version now owns its own bucket); regenerate the ${t}`);function Re(e,t,n){let r=new Map,i=e=>{for(let[t,i]of e){let e=r.get(t);if(e===void 0){r.set(t,x({...i,files:Object.assign(Object.create(null),i.files)}));continue}S(e.name===i.name,`${n}: module '${t}' name mismatch ('${e.name}' vs '${i.name}')`),S(e.version===i.version,`${n}: module '${t}' version mismatch ('${e.version}' vs '${i.version}')`+(e.version==null==(i.version==null)?``:` -- an artifact from an older stasis may record a placeholder version for a workspace package without one; regenerate it (bundle=replace / lock=replace)`)),S(e.ecosystem===i.ecosystem,`${n}: module '${t}' ecosystem mismatch ('${e.ecosystem??`(none)`}' vs '${i.ecosystem??`(none)`}')`);let a=ce(e,i);a!==e&&r.set(t,a);for(let[r,a]of Object.entries(i.files))Object.hasOwn(e.files,r)?S(e.files[r]===a,`${n}: content mismatch for '${d(t,r)}'`):e.files[r]=a}};return i(e),i(t),A(r,n,(e,t,r)=>S(!1,`${n}: file '${e}' is bucketed under both '${t}' and '${r}' -- module bucketing changed between the artifacts (a workspace package without a version now owns its own bucket); regenerate the artifact (bundle=replace / lock=replace)`)),r}function j(e){return e.split(`/`).includes(`node_modules`)}function ze(e){let t=e.length;for(;(t=e.lastIndexOf(`node_modules/`,t-1))!==-1;)if(t===0||e[t-1]===`/`)return t;return-1}function Be(e){let t=ze(e);if(t===-1)return null;let n=t+13,r=e.slice(n).split(`/`),i=r[0].startsWith(`@`)?2:1;if(r.length<=i||r.slice(0,i).some(e=>!e))return null;let a=r.slice(0,i).join(`/`);return{dir:e.slice(0,n)+a,rel:r.slice(i).join(`/`),name:a}}var M=1,Ve=0,He=Le(`bundle`,`artifact (bundle=replace)`),Ue=e=>Be(e)??{dir:`.`,rel:e===`.`?``:e,name:null};function We(){throw Error(`bundle: file contents are not retained by this contents-free Bundle`)}var Ge=(e,{files:t,...n})=>{let r=Object.create(null);for(let[n,i]of Object.entries(t))typeof i!=`symbol`&&S(!1,`bundle: file '${d(e,n)}' is not a placeholder`),Object.defineProperty(r,n,{get:We,enumerable:!0});return{...n,files:Object.freeze(r)}},N=(e,t)=>{if(e===void 0&&t===void 0)return;let n=new Map;for(let r of[e,t])for(let[e,t]of Object.entries(r??{})){if(!Array.isArray(t))continue;let r=n.get(e);r===void 0&&n.set(e,r=new Set);for(let e of t)r.add(e)}return E([...n.keys()].toSorted().map(e=>[e,ge(n.get(e))]))},Ke=(e,t)=>Object.hasOwn(h,e)&&h[e](t),qe=(e,t)=>e?.github===void 0||!ee(e.github,t?.github)?void 0:E(Object.keys(h).filter(n=>e[n]!==void 0&&(n===`github`||e[n]===t[n])).map(t=>[t,e[t]])),Je=e=>{if(!T(e)||e.root!==!0||Object.hasOwn(e,`directory`))return e;let{root:t,...n}=e;return n},Ye={npm:v,composer:v,cargo:v},Xe=(e,t)=>E(Object.keys(Ye).map(n=>{let[r,i]=[e?.[n],t?.[n]];return[n,r?.name!==void 0&&r.name===i?.name?E(Object.entries(r).filter(([e,t])=>t===i[e])):void 0]})),P=class e{static VERSION=M;version=M;config;entries;modules;formats;imports;executable;reason;#e;get repo(){return this.#e}set repo(e){this.#e=_(e)}#t;get package(){return this.#t}set package(e){this.#t=g(e,Ye,`bundle package`)}constructor({config:e={scope:`full`},entries:t,modules:n,formats:r,imports:i,executable:a,reason:o,repo:s,package:c,version:l=M}={}){S([Ve,M].includes(l)),S([`node_modules`,`full`].includes(e.scope)),this.version=l,this.config=e,this.entries=t??new Set,this.modules=n??new Map,this.formats=r??new Map,this.imports=i??new Map,this.executable=a??new Set,this.reason=o,this.repo=_(s),this.package=c}get sources(){let e=new Map;for(let[t,{files:n}]of this.modules)for(let[r,i]of Object.entries(n))e.set(d(t,r),i);return e}static isResourceFormat(e){return e===`resource`||e===`resource:base64`||e===`directory`}get hasCode(){for(let[t,{files:n}]of this.modules)for(let r of Object.keys(n))if(!e.isResourceFormat(this.formats.get(d(t,r))))return!0;return!1}static parse(t){return e.fromJSON(JSON.parse(t))}static fileKeyAt(e){let[t,n,r,i]=e;if(typeof n==`string`){if(e.length===2&&t===`sources`){let e=Ue(n);return k(e.dir,e.rel,`bundle`)}if(e.length===4&&(t===`sources`||t===`modules`)&&r===`files`&&typeof i==`string`)return k(n,i,`bundle`)}}static fromJSON(t,{contents:n=!0}={}){S(t.version===M||t.version===Ve),S([`node_modules`,`full`].includes(t.config?.scope));let r=Te(t.formats),i=new Map,a=new Set;if(t.version===M){let e=t.config.scope===`full`;if(t.modules!==void 0){S(typeof t.modules==`object`&&t.modules!==null);for(let[e,n]of Object.entries(t.modules))S(j(e)),O(e,`bundle`),S(n?.name&&n.version&&n.files),i.set(e,ue(n,e,`bundle`))}if(e){S(t.sources&&typeof t.sources==`object`);for(let[e,n]of Object.entries(t.sources))S(!j(e)),O(e,`bundle`),S(n?.name&&n.files),i.set(e,ue(n,e,`bundle`));t.entries!==void 0&&(a=Se(t.entries,`bundle`))}else S(t.entries===void 0),S(t.sources===void 0)}else{S(t.sources);for(let[e,n]of Object.entries(t.sources)){O(e,`bundle`);let{dir:t,rel:r,name:a}=Ue(e);S(!D(t)&&!D(r)),i.has(t)||i.set(t,{name:a,version:null,files:Object.create(null)});let{files:o}=i.get(t);S(!Object.hasOwn(o,r),`bundle: duplicate file key '.' (v0 '' and '.')`),o[r]=n}}let o=A(i,`bundle`,He),s=Oe(t.imports);if(!n)for(let[e,t]of i)i.set(e,Ge(e,t));return new e({version:t.version,config:t.config,entries:a,modules:i,formats:r,imports:s,executable:t.version===M?me(t.executable,{what:`bundle`,files:o,formats:r,scope:t.config.scope}):new Set,reason:T(t.reason)?t.reason:void 0,repo:Je(t.repo),package:t.package})}serialize(){A(this.modules,`bundle`,He);let{modules:e,sources:t}=Ae(this.modules,{skipEmpty:!0,what:`bundle`}),n=this.config.scope===`full`,r={version:M,config:this.config};this.repo!==void 0&&(r.repo=this.repo),this.package!==void 0&&(r.package=this.package),n&&(r.entries=Ce(this.entries,`bundle`)),r.formats=Ee(this.formats),r.imports=ke(this.imports);let i=he(this.executable,{what:`bundle`,modules:this.modules,formats:this.formats,scope:this.config.scope});return i!==void 0&&(r.executable=i),this.reason!==void 0&&(r.reason=N(this.reason,void 0)),n&&(r.sources=t),r.modules=e,JSON.stringify(r,void 0,2)}withReason(t){let{version:n,config:r,entries:i,modules:a,formats:o,imports:s,executable:c,repo:l,package:u}=this,d=N(this.reason,{[t]:[...this.sources.keys()]});return new e({version:n,config:r,entries:i,modules:a,formats:o,imports:s,executable:c,reason:d,repo:l,package:u})}merge(t){return S(this.config.scope===t.config.scope,`bundle merge: scope mismatch ('${this.config.scope}' vs '${t.config.scope}')`),new e({config:{scope:this.config.scope},entries:new Set([...this.entries,...t.entries]),modules:Re(this.modules,t.modules,`bundle merge`),formats:Pe(this.formats,t.formats,`bundle merge`),imports:Ne(this.imports,t.imports,`bundle merge`),executable:Fe(this.executable,t.executable,t.modules,this.config.scope),reason:N(this.reason,t.reason),repo:qe(this.repo,t.repo),package:Xe(this.package,t.package)})}},Ze={__proto__:null,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,json:`json`,css:`css`,html:`markup`,htm:`markup`,xml:`markup`,svg:`markup`,yml:`yaml`,yaml:`yaml`,sh:`bash`,bash:`bash`,md:`markdown`,markdown:`markdown`,sol:`solidity`,php:`php`,phtml:`php`,rs:`rust`,rb:`ruby`,py:`python`,pyw:`python`,pyi:`python`,java:`java`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,"c++":`cpp`,hpp:`cpp`,hh:`cpp`,hxx:`cpp`,"h++":`cpp`,h:`cpp`,c:`c`,m:`objectivec`,mm:`objectivec`},Qe={__proto__:null,module:`javascript`,commonjs:`javascript`,"module-typescript":`typescript`,"commonjs-typescript":`typescript`,json:`json`,solidity:`solidity`,php:`php`,shell:`bash`,rust:`rust`,java:`java`,objc:`objectivec`,objcpp:`objectivec`,c:`c`,"c-header":`c`,cpp:`cpp`,"cpp-header":`cpp`,ruby:`ruby`,podspec:`ruby`,podfile:`ruby`,fastlane:`ruby`,"podfile-lock":`yaml`,xml:`markup`};function $e(e){if(typeof e!=`string`)return!1;let t=e.length-1,n=0;for(;n<t&&/\s/u.test(e[n]);)n++;for(;t>n&&/\s/u.test(e[t]);)t--;return n<t&&e[n]===`{`&&e[t]===`}`}function et(e,t,n){if(typeof t==`string`&&Qe[t])return Qe[t];if(typeof e!=`string`)return null;let r=e.slice(e.lastIndexOf(`/`)+1),i=r.lastIndexOf(`.`);if(i<=0)return null;let a=r.slice(i+1).toLowerCase();return a===`map`?$e(n)?`json`:null:Ze[a]??null}var tt=/^webpack(?:-internal)?:\/\/[^/]*\//u,nt=/^[a-z][\d+.a-z-]*:/iu,rt=/^file:/iu,it=/^(?:file|ftp|https?|wss?):/iu,at=/^(?:[a-z][\d+.a-z-]*:\/\/[^/]*\/?|\/\/[^/]+\/|[a-z]:\/|\/)?/iu,F=e=>at.exec(e)[0],I=e=>F(e).includes(`://`),L=e=>e.replace(I(e)?/[#?].*$/su:/\?.*$/su,``),ot=e=>e.slice(e.lastIndexOf(`/`)+1),R=(e,t)=>URL.parse(e,t)?.href??null;function z(e){let t=F(e),n=t.includes(`://`)&&R(e);if(n)return n;let r=[];for(let n of e.slice(t.length).split(`/`))n===``||n===`.`||(n===`..`?r.length>0&&r.at(-1)!==`..`?r.pop():t||r.push(`..`):r.push(n));let i=/^[a-z]:\/$/iu.test(t)?t.toUpperCase():t.startsWith(`//`)?t.toLowerCase():t;return i?i.replace(/\/?$/u,`/`)+r.join(`/`):r.join(`/`)||`.`}function st(e,t){let n=F(t);return I(e)&&!n.includes(`:`)?R(t,e)??z(`${e}/../${t}`):z(n===`/`?F(e).replace(/\/?$/u,``)+t:n?t:`${e}/../${t}`)}function ct(e){try{return decodeURIComponent(e)}catch{return e}}function B(e,t){let n=e.replaceAll(`\\`,`/`);if(tt.test(n))return z(n.replace(tt,``));let r=it.test(n)?R(n)??n:n,i=/^file:\/\/([^/#]*)([^#]*)/isu.exec(r);if(i){let[,e,t]=i;return z(ct(e&&e.toLowerCase()!==`localhost`?`//${e}${t}`:t).replace(/^\/(?=[a-z]:\/)/iu,``))}if(nt.test(r)&&!F(r).includes(`:`))return r;if(t===void 0)return z(r);if(rt.test(t)&&!F(r))return B(R(r,t)??r);let a=B(t);return F(r)&&!I(a)?z(r):st(a,r)}var lt=/^(?:@[\dA-Za-z~-][\w.~-]*\/)?[\dA-Za-z~-][\w.~-]*$/u;function V(e){let t=e.split(`/`).slice(0,e.startsWith(`@`)?2:1).join(`/`);return lt.test(t)?t:null}var ut=new Set([`.pnpm`,`.bun`,`.deno`]),dt=/^\d+\.\d+\.\d+(?:-[\d.a-z-]+)?(?:\+[\d.a-z-]+)?$/iu;function ft(e,t){let n=`${t.replace(`/`,`+`)}@`,r=e.startsWith(n)?e.slice(n.length).split(/[(_]/u)[0]:null;return dt.test(r)?r:null}function pt(e){let t=L(e).split(`/`),n=t.lastIndexOf(`node_modules`),r=n<0?null:V(t.slice(n+1).join(`/`));if(r===null)return null;let i=n+1+r.split(`/`).length;if(i>=t.length||t.slice(i).includes(``))return null;let a=t.slice(0,i).join(`/`);return{name:r,version:ut.has(t[n-2])?ft(t[n-1],r):null,root:a,path:e.slice(a.length+1)}}var mt=new Map([[`js`,`jsx`],[`mjs`,`jsx`],[`cjs`,`jsx`],[`jsx`,`jsx`],[`es`,`jsx`],[`es6`,`jsx`],[`ts`,`ts`],[`mts`,`ts`],[`cts`,`ts`],[`tsx`,`tsx`],[`json`,`json`]]);function ht(e){let t=ot(L(e));return/^[\w-]+$/u.test(t)?`jsx`:mt.get(/\.([\da-z]+)$/iu.exec(t)?.[1].toLowerCase())??null}var gt=[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.tsx`,`.mts`,`.cts`,`.json`],_t=[`.ios`,`.android`,`.web`];function vt(e){let t=e.map(e=>/\.[a-z]+(?=\.\w+$)/u.exec(ot(L(e.path??``)))?.[0]),[[n,r],[,i]]=_t.map(e=>[e,t.filter(t=>t===e).length]).toSorted((e,t)=>t[1]-e[1]);return[...r===i?[]:[n],`.native`,``,`.browser`,`.node`]}var yt=new Map([[`.js`,[`.ts`,`.tsx`]],[`.jsx`,[`.tsx`]],[`.mjs`,[`.mts`]],[`.cjs`,[`.cts`]]]),bt=[`index`,`main`,`browser`,`node`],xt=[``,`src/`,`lib/`,`dist/`,`build/`],St=new Set([`lib`,`dist`,`build`,`out`,`esm`,`cjs`]);function*Ct(e,t){yield e;let n=/\.[^./]+$/u.exec(e)?.[0];for(let t of yt.get(n)??[])yield e.slice(0,-n.length)+t;for(let n of e.endsWith(`/`)?[`${e}index`]:[e,`${e}/index`])for(let e of gt)for(let r of t)yield n+r+e;if(n)for(let r of t.filter(Boolean))yield e.slice(0,-n.length)+r+n}function*wt(e){let t=e;for(;;){t.startsWith(`src/`)||(yield`src/${t}`),t!==e&&(yield t);let n=t.indexOf(`/`);if(n<0||!St.has(t.slice(0,n)))return;t=t.slice(n+1)}}function Tt(e){let t=new Map,n=new Map,r=new Map;for(let i of e)i.path!==null&&t.set(i.path,i),i.package&&(n.set(i.package.name,(n.get(i.package.name)??new Set).add(i.package.root)),(r.get(i.package.root)??r.set(i.package.root,[]).get(i.package.root)).push(i));return{byPath:t,roots:n,byRoot:r,platforms:vt(e),found:new Map}}function H(e,t){if(!e.found.has(t)){let n=L(t),r=Ct(n,e.platforms).map(e=>e+t.slice(n.length));e.found.set(t,e.byPath.get(r.find(t=>e.byPath.has(t)))??null)}return e.found.get(t)}function Et(e,t,n){let r=e.roots.get(n);if(!r)return null;let i=t.path.split(`/`);for(let e=i.length-1;e>=0;e--){let t=[...i.slice(0,e),`node_modules`,n].join(`/`);if(r.has(t))return t}return r.size===1?[...r][0]:null}var Dt=new Set(`assert.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.domain.events.fs.http.http2.https.inspector.module.net.os.path.perf_hooks.process.punycode.querystring.readline.repl.stream.string_decoder.sys.timers.tls.trace_events.tty.url.util.v8.vm.wasi.worker_threads.zlib._http_agent._http_client._http_common._http_incoming._http_outgoing._http_server._stream_duplex._stream_passthrough._stream_readable._stream_transform._stream_wrap._stream_writable._tls_common._tls_wrap.assert/strict.dns/promises.fs/promises.inspector/promises.path/posix.path/win32.readline/promises.stream/consumers.stream/promises.stream/web.timers/promises.util/types`.split(`.`));function Ot(e){if(e.startsWith(`node:`)||Dt.has(e))return{builtin:!0};let t=V(L(e));return t===null?{}:{package:t}}function kt(){let e=[],t=new Map,n=(n,r,i)=>{let a=t.get(n)??t.set(n,new Set).get(n);a.has(r)||(a.add(r),e.push(i))};return{edges:e,add:n,link:(e,t,r)=>{e&&t&&t!==e&&n(e,t,{from:e,to:t,kind:r})}}}function At(e,t){for(let n of bt)for(let r of xt){let i=H(e,`${t}/${r}${n}`);if(i)return i}let n=e.byRoot.get(t);return n?.length===1?n[0]:null}function jt(e,t,n,r){return/^\/[^?]/u.test(n)?H(e,t+n)??wt(n.slice(1)).map(n=>H(e,`${t}/${n}`)).find(Boolean):H(e,t+n)??r(e,t)}function Mt(e,t,n,r=At){let i=/^(?:\.{1,2}|[a-z]:)?\\/iu.test(n)?n.replaceAll(`\\`,`/`):n,a=it.test(i);if(a||/^(?:\.{1,2}(?:\/|$)|\/|[a-z]:\/)/iu.test(i)||I(i)){let n=a?B(i):st(t.path,i),r=H(e,n);return r?{to:r}:{to:null,path:n}}if(nt.test(i)&&e.byPath.has(i))return{to:e.byPath.get(i)};let o=V(L(n)),s=o===null?null:Et(e,t,o);if(s===null)return{to:null,...Ot(n)};let c=jt(e,s,n.slice(o.length),r);return c?{to:c}:{to:null,package:o}}var U=class extends Error{name=`SourceMapError`},Nt=new Uint8Array(128).fill(255);for(let[e,t]of[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/,;`].entries())Nt[t.codePointAt(0)]=e;function W(e){let t=new Int32Array(e.length*2);return t.set(e),t}function Pt(e){let{starts:t,columns:n,sources:r,names:i}=e;for(let e=0;e+1<t.length;e++){let[a,o]=[t[e],t[e+1]],s=a+1;for(;s<o&&n[s-1]<=n[s];)s++;if(s>=o)continue;let c=Array.from(n.subarray(a,o),(e,t)=>[e,r[a+t],i[a+t]]).sort((e,t)=>e[0]-t[0]);for(let[e,[t,o,s]]of c.entries())[n[a+e],r[a+e],i[a+e]]=[t,o,s]}return e}function Ft(e){let t=[0],n=new Int32Array(1024),r=new Int32Array(1024),i=new Int32Array(1024),a=0;for(let{mappings:o,files:s,line:c,column:l,names:u,nameCount:d}of e){if(typeof o!=`string`)throw new U(`mappings is not a string`);for(;t.length<=c;)t.push(a);let e=[0,0,0,0,0],f=0,p=0,m=1,h=l;for(let c=0;c<=o.length;c++){let l=c<o.length?Nt[o.codePointAt(c)]??255:64;if(l<32){if(p+=l*m,f===5)throw new U(`mappings: a segment of more than 5 fields at ${c}`);e[f++]+=p%2?(1-p)/2:p/2,p=0,m=1;continue}if(l<64){if(p+=(l-32)*m,m*=32,m>2**30)throw new U(`mappings: a value at ${c} runs past 32 bits`);continue}if(l===255)throw new U(`mappings: ${JSON.stringify(o[c])} at ${c} is not a base64 digit`);if(m!==1)throw new U(`mappings: the value before ${c} is cut off`);if(f>0){if(f===2||f===3)throw new U(`mappings: a segment of ${f} fields before ${c}`);let t=f===1?-1:s[e[1]];if(t===void 0)throw new U(`mappings: source ${e[1]} before ${c} is not in sources`);if(e[0]<0)throw new U(`mappings: a negative generated column before ${c}`);a===n.length&&([n,r,i]=[W(n),W(r),W(i)]),n[a]=e[0]+h,r[a]=t,i[a++]=f===5&&e[4]>=0&&e[4]<d?u+e[4]:-1,f=0}l===65&&(t.push(a),e[0]=0,h=0)}}return t.push(a),Pt({starts:Int32Array.from(t),columns:n.slice(0,a),sources:r.slice(0,a),names:i.slice(0,a)})}var It=new WeakMap,Lt=e=>It.get(e),G=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function K(e,t){if(!e)throw new U(t)}function Rt(e,t){if(e===void 0)return[];K(Array.isArray(e),`${t} is not an array`);for(let n of e)K(typeof n==`string`||n===null,`${t} holds ${JSON.stringify(n)}`);return e}function zt(e,t,n,r){let i=e.bySource.get(t);if(i!==void 0)return e.files[i].content??=n,e.files[i].ignored||=r,i;let a=t===null?null:B(t,e.mapPath);return e.files.push({source:t,path:a,package:a===null?null:pt(a),content:n,ignored:r}),t!==null&&e.bySource.set(t,e.files.length-1),e.files.length-1}function Bt(e,t,n,r){K(e.version===3,`version ${JSON.stringify(e.version)} is not 3`),K(e.sourceRoot===void 0||typeof e.sourceRoot==`string`,`sourceRoot is not a string`);let i=Rt(e.sources,`sources`),a=Rt(e.sourcesContent,`sourcesContent`),o=e.ignoreList??e.x_google_ignoreList??[];K(Array.isArray(o)&&o.every(e=>Number.isInteger(e)&&e>=0&&e<i.length),`ignoreList is not a list of indices into sources`);let s=new Set(o),c=e.sourceRoot?e.sourceRoot.replace(/\/?$/u,`/`):``,l=i.map((e,n)=>zt(t,e===null?null:c+e,a[n]??null,s.has(n))),u=Array.isArray(e.names)?e.names:[];t.parts.push({mappings:e.mappings,files:l,line:n,column:r,names:t.names.length,nameCount:u.length}),t.names.push(...u)}function Vt(e,t){K(e.version===3,`version ${JSON.stringify(e.version)} is not 3`),K(Array.isArray(e.sections),`sections is not an array`);for(let[n,r]of e.sections.entries()){let{offset:i,map:a}=G(r)?r:{};K(G(i)&&[i.line,i.column].every(e=>Number.isInteger(e)&&e>=0),`sections[${n}].offset is not a line and a column`),K(G(a)&&a.sections===void 0,`sections[${n}].map is not a plain source map`);let o=e.sections[n-1]?.offset;K(!o||o.line<i.line||o.line===i.line&&o.column<=i.column,`sections[${n}] starts before sections[${n-1}]`),Bt(a,t,i.line,i.column)}}function Ht(e,t={}){if(!G(t))throw TypeError(`readSourceMap: options is not an object`);if(t.path!==void 0&&typeof t.path!=`string`)throw TypeError(`readSourceMap: options.path is not a string`);let n=e;if(typeof e==`string`||e instanceof Uint8Array)try{let t=typeof e==`string`?e:new TextDecoder(`utf-8`,{fatal:!0}).decode(e);n=JSON.parse(t.replace(/^\)\]\}'[^\n]*\n/u,``))}catch(e){throw new U(`not JSON: ${e.message}`,{cause:e})}K(G(n),`not a JSON object`);let r={files:[],bySource:new Map,mapPath:t.path,parts:[],names:[]};n.sections===void 0?Bt(n,r,0,0):Vt(n,r);let i={files:r.files};return It.set(i,{...Ft(r.parts),nameList:r.names}),i}var Ut=/\r\n?|[\n\u2028\u2029]/gu;function Wt(e){let t=[0];for(let n of e.matchAll(Ut))t.push(n.index+n[0].length);return t}function Gt(e,t,n,r){let[i,a]=[t,n];for(;i<a;){let t=i+a>>1;e[t]<=r?i=t+1:a=t}return i-1}function q(e,t){let n=Gt(e,0,e.length,t);return[n,t-e[n]]}function Kt(e,[t,n]){if(t>=e.starts.length-1)return-1;let r=e.starts[t],i=Gt(e.columns,r,e.starts[t+1],n);return i<r?-1:i}function qt(e,t,n,r){let i=Lt(e),a=q(t,n),[o,s]=q(t,r),c=new Map,l=Kt(i,a);for(let e=a[0];e<=o&&e<i.starts.length-1;e++){let t=e===a[0]&&l>=0?l:i.starts[e];for(let n=t;n<i.starts[e+1];n++){let t=i.sources[n];if(e===o&&i.columns[n]>=s)break;t>=0&&c.set(t,(c.get(t)??0)+1)}}let[u]=[...c].reduce((e,t)=>t[1]>e[1]?t:e,[-1,0]);return u<0?null:e.files[u]}var Jt=/\s+/uy,Yt=`
2
- \r\u2028\u2029`,Xt=/[\n\r\u2028\u2029]/gu,Zt=/[\n\r\u2028\u2029]/u,J=/[\w$\u0080-￿]+/uy,Qt=new Set([`return`,`typeof`,`instanceof`,`in`,`of`,`new`,`delete`,`void`,`throw`,`case`,`default`,`extends`,`do`,`else`,`yield`,`await`]),$t=new Set([`if`,`while`,`for`,`with`]),en=new Set([`break`,`continue`,`debugger`]),tn=new Set([`(`,`[`,"${",`,`,`=`,`:`,`?`,`!`,`~`,`+`,`-`,`*`,`/`,`%`,`&`,`|`,`^`,`<`,`>`]);function nn(e,t){return e?.type===`word`?t&&[`return`,`yield`].includes(e.value)?!1:Qt.has(e.value)&&![`do`,`else`].includes(e.value):tn.has(e?.value)}function rn(e){let t=e.at(-1);return t?.type===`word`&&($t.has(t.value)||t.value===`await`&&e.at(-2)?.value===`for`)}function an(e){return e?e.type===`word`?Qt.has(e.value)||en.has(e.value)||e.label===!0:e.value===`)`?e.control:e.value===`}`?!e.object:e.type===`punctuator`&&![`++`,`--`,`]`].includes(e.value):!0}var on=(e,t)=>e.startsWith(`\r
3
- `,t+1)?3:2,sn=/\\(?:u\{([\da-f]+)\}|u([\da-f]{4})|x([\da-f]{2})|([0-3][0-7]{0,2}|[4-7][0-7]?)|(\r\n|[\n\r\u2028\u2029])|(.))/giu,cn={b:`\b`,f:`\f`,n:`
4
- `,r:`\r`,t:` `,v:`\v`};function ln(e){return e.includes(`\\`)?e.replace(sn,(e,t,n,r,i,a,o)=>{if(a!==void 0)return``;if(i!==void 0)return String.fromCodePoint(Number.parseInt(i,8));let s=Number.parseInt(t??n??r,16);return Number.isNaN(s)?cn[o]??o:String.fromCodePoint(Math.min(s,1114111))}):e}function un(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n&&!Yt.includes(e[r]);)r+=e[r]===`\\`?on(e,r):1;return[e[r]===n?ln(e.slice(t+1,r)):null,r+1]}function dn(e,t){let n=t+1,r=!1;for(;n<e.length&&!Yt.includes(e[n])&&(r||e[n]!==`/`);)e[n]===`\\`?n++:e[n]===`[`?r=!0:e[n]===`]`&&(r=!1),n++;return J.lastIndex=n+1,J.test(e)?J.lastIndex:n+1}function fn(e,t,n){for(let r=t;r<e.length;r++)if(e[r]===`\\`)r++;else{if(e[r]==="`")return r+1;if(e[r]===`$`&&e[r+1]===`{`)return n.push(`template`),r+2}return e.length}function pn(e){let t=[],n=[],r=[],i=0,a=0;for(;i<e.length;){let o=t.length;if(Jt.lastIndex=i,Jt.test(e)&&(i=Jt.lastIndex),i>=e.length)break;let s=e[i],c=e[i+1];if(J.lastIndex=i,s===`/`&&c===`/`)Xt.lastIndex=i+2,i=Xt.test(e)?Xt.lastIndex-1:e.length;else if(s===`/`&&c===`*`){let t=e.indexOf(`*/`,i+2);i=t<0?e.length:t+2}else if(s===`"`||s===`'`){let[n,r]=un(e,i);t.push({type:`string`,value:n}),i=r}else if(s==="`"||s===`}`&&n.at(-1)===`template`){s===`}`&&n.pop();let r=n.length,a=fn(e,i+1,n),o=s==="`"&&n.length===r&&e[a-1]==="`";t.push({type:`string`,value:o?ln(e.slice(i+1,a-1)):null}),n.length>r&&t.push({type:`punctuator`,value:"${"}),i=a}else if(s===`/`&&an(t.at(-1)))i=dn(e,i),t.push({type:`regex`});else if(J.test(e)){let n=en.has(t.at(-1)?.value)&&!Zt.test(e.slice(a,i));t.push({type:`word`,value:e.slice(i,J.lastIndex),...n&&{label:n}}),i=J.lastIndex}else{s===`{`&&n.push(nn(t.at(-1),Zt.test(e.slice(a,i)))?`object`:`block`);let o=s===`}`?n.pop():void 0;s===`(`&&r.push(rn(t));let l=(s===`+`||s===`-`)&&c===s||s===`=`&&c===`>`?s+c:s;t.push({type:`punctuator`,value:l,...s===`)`&&{control:r.pop()===!0},...s===`}`&&{object:o===`object`}}),i+=l.length}t.length>o&&(a=i)}return t}var mn=e=>e?.type===`string`&&e.value!==null,hn=new Set([`type`,`typeof`]),gn=(e,t)=>e[t+1]?.type===`word`&&(e[t+1].value!==`as`||e[t+2]?.type!==`word`||e[t+2].value===`as`);function _n(e,t){let n=!1;for(let r=t+1;r<e.length&&e[r].value!==`}`;r++)if(!(r>t+1&&e[r-1].value!==`,`)){if(!hn.has(e[r].value)||!gn(e,r))return!1;n=!0}return n}function vn(e,t){for(let n=t;n<e.length;n++){let{value:r}=e[n];if(r===`;`||n>t&&(r===`import`||r===`export`))return null;if(r===`from`&&mn(e[n+1]))return e[n+1].value}return null}function yn(e,t){let[n,r,i]=[e[t].value,e[t+1],e[t+2]],a=n===`import`?`import`:`export-from`;if(n===`import`&&mn(r))return{kind:a,specifier:r.value};if(hn.has(r?.value)&&![`,`,`from`].includes(i?.value)||r?.value===`{`&&_n(e,t+1)||n===`export`&&![`{`,`*`].includes(r?.value)||n===`import`&&r?.type!==`word`&&![`{`,`*`].includes(r?.value))return null;let o=vn(e,t+1);return o===null?null:{kind:a,specifier:o}}function bn(e,t){let[n,r]=[e[t+2],e[t+3]];if(n?.value!==`)`)return mn(n)&&[`)`,`,`].includes(r?.value)?n.value:null}function xn(e,t=new Set){let n=pn(e),r=[];for(let[e,i]of n.entries()){if(i.type!==`word`||[`.`,`#`,`function`].includes(n[e-1]?.value)||n[e-1]?.value===`=`&&n[e-3]?.value===`type`&&n[e-4]?.value===`import`)continue;let a=n[e+1]?.value===`(`,o=a?bn(n,e):void 0;if((i.value===`require`||t.has(i.value))&&o!==void 0)r.push({kind:`require`,specifier:o,...i.value!==`require`&&{callee:i.value}});else if(i.value===`import`&&a)o!==void 0&&r.push({kind:`dynamic-import`,specifier:o});else if(i.value===`import`||i.value===`export`){let t=yn(n,e);t&&r.push(t)}}return r}var Sn=/^[\w$]*__d\(/gmu,Cn=([e,t,n,...r])=>(typeof e==`number`||typeof e==`string`)&&(t===void 0||typeof t==`object`)&&(n===void 0||typeof n==`string`)&&r.length===0;function wn(e){let t=/\);?\s*$/u.exec(e)?.index,n=null,r=t===void 0?-1:e.lastIndexOf(`},`,t);for(;r>=0&&/[\d"]/u.test(e[r+2]);){let i;try{i=JSON.parse(`[${e.slice(r+2,t)}]`)}catch{break}if(!Cn(i))break;n=i,r=r>0?e.lastIndexOf(`},`,r-1):-1}return n}function Tn(e){let t=/^[^(]*\(\s*(?:function\s*[\w$]*\s*)?\(([^)]*)\)/u.exec(e)?.[1].split(`,`).slice(1,4).map(e=>e.trim().replaceAll(`$`,`\\$`));if(!t?.length)return[];let n=e.matchAll(RegExp(`(?<=[^\\w$.#]|\\.\\.\\.)(?:${t.join(`|`)})\\((\\d+|"(?:[^"\\\\]|\\\\.)*")[,)]`,`gu`));return[...new Set([...n].map(e=>JSON.parse(e[1])))]}function En(e,t){if(Array.isArray(e))return e;let n=Object.entries(e??{}).filter(([e])=>/^\d+$/u.test(e)).map(([,e])=>e);return n.length>0?n:Tn(t)}function Dn(e,t){let n=new Map(t.files.map((e,t)=>[e,t])),r=e.flatMap((e,t)=>e.file?[{k:t,at:n.get(e.file)}]:[]);for(let n=0;n<(r[0]?.k??0);n++)e[n].file=t.files[r[0].at-r[0].k+n]??null;for(let[n,{k:i,at:a}]of r.entries()){let o=r[n+1];if(!(o&&o.at-a!==o.k-i))for(let n=i+1;n<(o?.k??e.length);n++)e[n].file=t.files[a+n-i]??null}}function On(e,t){let n=[...e.matchAll(Sn)].map(e=>e.index);if(n.length===0)return null;let r=Wt(e),i=t=>e.slice(r[t],r[t+1]),a=[];for(let[o,s]of n.entries()){let[c]=q(r,s),[l]=q(r,(n[o+1]??e.length)-1),u=wn(i(l));for(;!u&&l>c;)u=wn(i(--l));if(!u)throw Error(`bundleEdges: the Metro module at line ${c+1} ends in no define params`);let d=r[l+1]??e.length;a.push({id:u[0],file:qt(t,r,s,d),dependencies:En(u[1],e.slice(s,d))})}Dn(a,t);let o=new Map(a.map(e=>[e.id,e])),{edges:s,link:c}=kt();for(let{file:e,dependencies:t}of a)for(let n of t)c(e,o.get(n)?.file,`dependency`);return s}var kn=e=>e.path!==null&&![`json`,null].includes(ht(e.path)),An=e=>e.path!==null&&ht(e.path)===null;function jn(e){let t=/^_([A-Za-z]+)\d+$/u.exec(e)?.[1];if(t)return[t,`interopRequireDefault`];let n=/^_(interopRequire(?:Default|Wildcard)|jsx(?:Dev)?Runtime|callSuper)$/u.exec(e)?.[1];return n===`callSuper`?[`getPrototypeOf`,`possibleConstructorReturn`,`interopRequireDefault`]:n?[n]:[]}var Mn={jsxRuntime:`react/jsx-runtime`,jsxDevRuntime:`react/jsx-dev-runtime`};function Nn(e){let{sources:t,names:n,nameList:r}=Lt(e),i=new Map,a=new Map,o=e.files.map(()=>new Set);for(let e=0;e<n.length;e++)n[e]<0||t[e]<0||(a.has(n[e])||a.set(n[e],jn(r[n[e]]).length>0),a.get(n[e])&&o[t[e]].add(r[n[e]]));for(let[t,n]of o.entries()){if(n.size===0)continue;let r=e.files[t],a=new Set(Array.from((r.content??``).matchAll(/(?:function|var|let|const)\s+(_[A-Za-z]+\d*)\b/gu),e=>e[1])),o=[...n].filter(e=>!a.has(e)&&!a.has(e.replace(/\d+$/u,``))).flatMap(jn);o.length>0&&i.set(r,o.map(e=>Mn[e]??`@babel/runtime/helpers/${e}`))}return i}function Pn(e,t){let n=new Map;for(let[r,i]of e){let e=n.get(r)??n.set(r,new Map).get(r);for(let n of i)e.set(n,Mt(t,r,n,()=>null))}let r=new Set([...n.values()].flatMap(e=>[...e.values()].map(e=>e.to))),i=(e,n)=>t.byRoot.get(n).find(e=>!r.has(e))??t.byRoot.get(n)[0];return(e,r)=>{let a=n.get(e)?.get(r);return a?.to?a:Mt(t,e,r,i)}}var Fn=e=>/(?:^|\/)__prelude__$/u.test(e.source??``),In=e=>e?.package?.name===`metro-runtime`&&e.package.path===`src/polyfills/require.js`;function Ln(e){if(!e.files.some(Fn)&&!In(e.files[0]))return null;if(!e.files.some(e=>e.content!==null&&!Fn(e)&&!In(e)))throw Error("bundleEdges: the Metro map carries no sourcesContent, which its edges are read from; pass the bundle as `code`");let t=Tt(e.files),n=e.files[e.files.findIndex(An)+1],r=e.files.find(e=>e.package?.name===`metro-runtime`&&e.package.path===`src/modules/asyncRequire.js`),i=new Map(e.files.filter(e=>e.content!==null&&kn(e)).map(e=>[e,xn(e.content)])),a=Nn(e),o=Pn([...[...i].map(([e,t])=>[e,t.flatMap(({specifier:e})=>e===null?[]:[e])]),...a],t),{edges:s,add:c,link:l}=kt();for(let t of e.files){An(t)&&l(t,n,`dependency`);for(let{kind:e,specifier:n}of i.get(t)??[]){let i=n===null?{to:null}:o(t,n);i.to!==t&&c(t,`${e}\0${JSON.stringify(n)}`,{from:t,kind:e,specifier:n,...i}),e===`dynamic-import`&&l(t,r,`dependency`)}for(let e of a.get(t)??[])l(t,o(t,e).to,`dependency`)}return s}var Rn=(e,t)=>t==null?Ln(e):On(t,e);function zn(e,t){let n=Rn(e,t);if(!n)throw Error(`bundleEdges: not a Metro ${t==null?`map`:`bundle`}; edges-lite.js reads only those, edges.js reads others`);return{edges:n}}function Bn(e){let t=JSON.parse(e.replace(/^\)\]\}'[^\n]*\n/u,``)),n=Ht(t),r=t.sections?t.sections.reduce((e,t)=>e+(t.map.names?.length??0),0):t.names?.length??null;return{json:{version:t.version,file:t.file,sourceRoot:t.sourceRoot},map:n,namesCount:r}}function Vn(e){if(e.map)return e.map.files.flatMap(e=>e.source===null?[]:[[e.source,e.content]]);let t=e.json?.sourcesContent??[];return(e.json?.sources??[]).map((e,n)=>[e,t[n]??null])}function Hn(e,t){let n=new Map;for(let{from:r,to:i,specifier:a}of t(e).edges){if(r.source===null||i?.source==null||i.source===r.source)continue;let e=typeof a==`string`?[r.source,i.source,a]:[r.source,i.source];n.set(e.join(`\0`),e)}return[...n.values()]}function Un(e){try{return zn(e)}catch{return{edges:[]}}}var Wn=Object.freeze([]);function Gn(e){return e?.edges?e.edges:e?.map?(e.edges=Hn(e.map,Un),e.edges):Wn}var Kn=new WeakMap,qn=new WeakMap;function Jn(e){let t=Gn(e);if(!Kn.has(t)){let e=new Map;for(let[n,r]of t)e.has(n)||e.set(n,new Set),e.get(n).add(r);Kn.set(t,e)}return Kn.get(t)}function Yn(e){let t=Gn(e);if(!qn.has(t)){let e=new Map;for(let[n,r,i]of t)i!==void 0&&(e.has(n)||e.set(n,new Map),e.get(n).set(i,r));qn.set(t,e)}return qn.get(t)}var Xn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,$n=new WeakMap,Y=new WeakMap,er=new WeakMap;function X(e){if(e?.metadataOnly)return new Map;let t=e?.bundle??e?.json;if(t&&Xn.has(t))return Xn.get(t);let n=new Map;if(!e)return n;if(e.kind===`stasis`){if(!e.bundle)return n;let t=e.bundle.formats;for(let[r,i]of e.bundle.sources)typeof i==`string`&&(P.isResourceFormat(t?.get(r))||n.set(r,i))}else if(e.kind===`sourcemap`)for(let[t,r]of Vn(e))typeof r==`string`&&n.set(t,r);return t&&Xn.set(t,n),n}function tr(e){let t=1;for(let n=e.indexOf(`
5
- `);n!==-1;n=e.indexOf(`
6
- `,n+1))t++;return t}var nr=new WeakMap;function rr(e){let t=nr.get(e);if(!t){let n=[...e.keys()].toSorted();t={paths:n,numbers:new Map(n.map((e,t)=>[e,t+1]))},nr.set(e,t)}return t}function ir(e,t){let n=Array.isArray(t)?t:[];return{integrity:e.integrity,kind:`sourcemap`,size:e.size,json:{version:3,sources:n.map(([e])=>e),sourcesContent:n.map(([,,e])=>typeof e==`string`?e:null)},fileSizes:new Map(n.map(([e,t])=>[e,t])),npmBinaries:new Map(n.filter(([,,e,t])=>typeof e!=`string`&&typeof t==`string`).map(([e,t,,n])=>[e,{size:t,digest:n}]))}}function ar(e){let t=e?.bundle??e?.json;if(t&&Zn.has(t))return Zn.get(t);let n=new Map(X(e));for(let[t,r]of e?.npmBinaries??[])n.set(t,{format:`digest`,...r});if(e?.kind===`stasis`&&e.bundle){let t=e.bundle.formats;for(let[r,i]of e.bundle.sources){if(typeof i!=`string`)continue;let e=t?.get(r);e===`resource`?n.set(r,i):e===`resource:base64`&&n.set(r,{format:`base64`,data:i})}}return t&&Zn.set(t,n),n}var or=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function sr(e){let t=e.endsWith(`=`);if(t?e.length%4!=0||e.at(-3)===`=`:e.length%4==1)return null;let n=t?e.slice(0,e.endsWith(`==`)?-2:-1):e;if(/[^A-Za-z0-9+/]/u.test(n))return null;let r=n.length%4;return r>1&&or.indexOf(n.at(-1))&(r===2?15:3)?null:Math.floor(n.length*3/4)}function cr(e){return typeof e==`string`?t(e):e?.format===`digest`?e.size:e?.format===`base64`?sr(e.data):null}function Z(e){if(e?.fileSizes)return e.fileSizes;let t=e?.bundle??e?.json;if(t&&Qn.has(t))return Qn.get(t);let n=new Map,r=ar(e),i=e?.kind===`stasis`?e.bundle?.sources.keys():e&&Vn(e).map(([e])=>e);for(let e of i??[])n.set(e,cr(r.get(e)));return t&&Qn.set(t,n),n}function lr(e){if(e?.metadataOnly)return e.unsizedFiles??new Set;let t=Z(e);if(er.has(t))return er.get(t);let n=new Set;for(let r of ar(e).keys())t.get(r)===null&&n.add(r);return er.set(t,n),n}function ur(e){let t=Z(e);if(Y.has(t))return Y.get(t);let n=lr(e),r=e?.kind===`stasis`?e.bundle?.formats:null,i=new Map;for(let[a,o]of t)o===null&&!n.has(a)||i.set(a,P.isResourceFormat(r?.get(a))||e?.npmBinaries?.has(a)?`resource`:`source`);return Y.set(t,i),i}function dr(e){let t=Z(e),n=e?.kind===`stasis`?e.bundle?.formats:null;if(!n||n.size===0)return t;if($n.has(t))return $n.get(t);let r=new Map;for(let[e,i]of t)P.isResourceFormat(n.get(e))||r.set(e,i);return $n.set(t,r),r}var fr=new WeakMap;function pr(e){if(e?.kind!==`stasis`||!e.bundle?.modules)return null;if(fr.has(e.bundle))return fr.get(e.bundle);let t=new Map;for(let[n,r]of e.bundle.modules)for(let e of Object.keys(r.files))t.set(n===`.`?e:`${n}/${e}`,n);return fr.set(e.bundle,t),t}function mr(e,t=null,n=(e,t)=>t.name){let r=new Map;if(e?.kind!==`stasis`||!e.bundle?.modules)return r;let i=t===null?null:pr(e),a=t===null?null:new Set([...t].map(e=>i?.get(e)));for(let[t,i]of e.bundle.modules){if(a&&!a.has(t)||!t.includes(`node_modules`)||!i?.name||typeof i.version!=`string`||!i.version)continue;let e=n(t,i),o=r.get(e);o||(o=new Set,r.set(e,o)),o.add(i.version)}return r}var hr=Object.freeze({javascript:`JavaScript`,jsx:`JSX`,typescript:`TypeScript`,tsx:`TSX`,json:`JSON`,css:`CSS`,markup:`HTML`,yaml:`YAML`,bash:`Shell`,markdown:`Markdown`,solidity:`Solidity`,php:`PHP`,rust:`Rust`,ruby:`Ruby`,java:`Java`,cpp:`C++`,c:`C`,objectivec:`Objective-C`,python:`Python`,go:`Go`,kotlin:`Kotlin`,swift:`Swift`,dart:`Dart`,sql:`SQL`,lua:`Lua`,csharp:`C#`,scala:`Scala`,vue:`Vue`,svelte:`Svelte`}),gr=Object.freeze({py:`python`,pyw:`python`,go:`go`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,dart:`dart`,sql:`sql`,lua:`lua`,cs:`csharp`,scala:`scala`,sc:`scala`,vue:`vue`,svelte:`svelte`});function _r(e){let t=typeof e==`string`?e.slice(e.lastIndexOf(`/`)+1):``,n=t.lastIndexOf(`.`),r=n>0?t.slice(n+1).trim().toLowerCase():``,i=et(e)??gr[r];return i?{key:i,label:hr[i]??i}:r?{key:`extension:${r}`,label:`.${r}`}:{key:`other`,label:`Other`}}function vr(e,t){let n=new Map,r=0,i=0;for(let[a,o]of e){let e=_r(a),s=n.get(e.key)??{...e,files:0,lines:0,bytes:0};s.files++,s.lines+=o,s.bytes+=t.get(a)??0,n.set(e.key,s),i+=o,r+=t.get(a)??0}return{files:e.size,lines:i,bytes:r,languages:[...n.values()].toSorted((e,t)=>t.lines-e.lines||e.label.localeCompare(t.label))}}var yr=6,Q=new WeakMap,br=new Set([`terminal`,`code`,`search`,`compare`]);function xr(e,t=null){return!!t||br.has(e)}var Sr=/^sha512-[A-Za-z0-9+/]{86}==$/u;function Cr(t){if(t.fileHashes)return Promise.resolve(t.fileHashes);if(Q.has(t))return Q.get(t);let n=(async()=>{let n=[...X(t)],r=new Map;for(let t=0;t<n.length;t+=32){let i=await Promise.all(n.slice(t,t+32).map(async([t,n])=>[t,await e(n)]));for(let[e,t]of i)r.set(e,t)}return t.fileHashes=r,r})();return Q.set(t,n),n.catch(()=>Q.delete(t)),n}function wr(e){if(typeof e!=`string`)return 0;let t=/\S/gu,n=/[\r\n]/gu,r=0;for(;t.test(e)&&(r++,n.lastIndex=t.lastIndex,n.test(e));)t.lastIndex=n.lastIndex;return r}function Tr(e){return e.lineCounts??=new Map([...X(e)].map(([e,t])=>[e,wr(t)]))}function $(e){return e instanceof Map?Object.fromEntries([...e].map(([e,t])=>[e,$(t)])):e}async function Er(e){let n=await Cr(e),r=Z(e),i=Tr(e),a={version:yr,integrity:e.integrity,kind:e.kind,size:e.size,codeStats:vr(i,r),files:[...r].map(([e,t])=>[e,t,n.get(e)??null,i.get(e)??null])},o=lr(e);if(o.size>0&&(a.unsized=[...o]),e.kind===`sourcemap`){let{version:n,file:r,sourceRoot:i,names:o}=e.json,s=Vn(e);a.json={version:n,file:r,sourceRoot:i,sources:s.map(([e])=>e)},a.sourceSizes=s.map(([,e])=>typeof e==`string`?t(e):null),a.namesCount=e.namesCount??o?.length??null;let c=new Map(a.files.map(([e],t)=>[e,t]));a.edges=Gn(e).map(([e,t,...n])=>[c.get(e),c.get(t),...n])}else{let t=e.bundle,n={version:t.version,config:t.config,repo:t.repo,package:t.package,formats:$(t.formats),imports:$(t.imports),reason:t.reason,executable:[...t.executable]};if(t.version===0)n.sources=Object.fromEntries([...r.keys()].map(e=>[e,null]));else{let e={},r={};for(let[n,i]of t.modules){let t=n.split(`/`).includes(`node_modules`)?e:r;Object.defineProperty(t,n,{enumerable:!0,value:{name:i.name,version:i.version,ecosystem:i.ecosystem,repo:i.repo,files:Object.fromEntries(Object.keys(i.files).map(e=>[e,null]))}})}n.modules=e,t.config.scope===`full`&&(n.sources=r,n.entries=[...t.entries])}a.bundle=n}return a}function Dr(e,t){if(![1,2,3,4,5,yr].includes(e?.version)||e.integrity!==t||![`stasis`,`sourcemap`].includes(e.kind)||!Number.isSafeInteger(e.size)||e.size<0||!Array.isArray(e.files))throw Error(`Invalid bundle metadata`);let n=e.version!==yr,r=e.version===1,i=new Map,a=new Map,o=new Map;for(let t of e.files){if(!Array.isArray(t)||t.length!==4&&!(r&&t.length===3))throw Error(`Invalid bundle metadata file`);let[e,n,s,c]=t;if(typeof e!=`string`||a.has(e)||n!==null&&(!Number.isSafeInteger(n)||n<0)||s!==null&&(typeof s!=`string`||!Sr.test(s))||n===null&&s!==null||r&&n!==null&&s===null||c!=null&&(!Number.isSafeInteger(c)||c<0))throw Error(`Invalid bundle metadata file`);a.set(e,n),s!==null&&i.set(e,s),c!=null&&o.set(e,c)}let s=new Set(e.unsized??[]);if(e.unsized!==void 0&&(r||!Array.isArray(e.unsized)||s.size!==e.unsized.length)||[...s].some(e=>typeof e!=`string`||!a.has(e)||a.get(e)!==null))throw Error(`Invalid bundle metadata`);let c={integrity:t,kind:e.kind,size:e.size,metadataOnly:!0,fileSizes:a,fileHashes:i,lineCounts:o,unsizedFiles:s,stale:n};if(e.kind===`stasis`){c.bundle=P.fromJSON(e.bundle);let t=c.bundle.sources;if(t.size!==a.size||[...t.keys()].some(e=>!a.has(e)))throw Error(`Invalid bundle metadata inventory`);let n=c.bundle.formats;if(!r&&[...a].some(([e,t])=>i.has(e)!==(t!==null&&!P.isResourceFormat(n.get(e))))||[...s].some(e=>n.get(e)!==`resource:base64`))throw Error(`Invalid bundle metadata inventory`)}else{if(!e.json||typeof e.json!=`object`||![null,void 0].includes(e.namesCount)&&(!Number.isSafeInteger(e.namesCount)||e.namesCount<0))throw Error(`Invalid sourcemap metadata`);if(!Array.isArray(e.json.sources)||e.json.sources.some(e=>!a.has(e))||!Array.isArray(e.sourceSizes)||e.sourceSizes.length!==e.json.sources.length||e.sourceSizes.some(e=>e!==null&&(!Number.isSafeInteger(e)||e<0))||[...a].some(([e,t])=>i.has(e)!==(t!==null))||s.size>0)throw Error(`Invalid sourcemap inventory`);c.json=e.json,c.sourceSizes=e.sourceSizes,c.namesCount=e.namesCount,e.edges!==void 0&&(c.edges=Or(e.edges,e.files))}if(e.codeStats===void 0)c.codeStats=vr(o,a);else{let t=e.codeStats,n=e=>Number.isSafeInteger(e)&&e>=0;if(!t||![t.files,t.lines,t.bytes].every(n)||!Array.isArray(t.languages)||t.languages.some(e=>!e||typeof e.key!=`string`||typeof e.label!=`string`||![e.files,e.lines,e.bytes].every(n)))throw Error(`Invalid bundle code stats`);c.codeStats=t}return c}function Or(e,t){if(!Array.isArray(e))throw Error(`Invalid sourcemap edges`);return e.map(e=>{if(!Array.isArray(e)||![2,3].includes(e.length)||e[0]===e[1]||e.length===3&&typeof e[2]!=`string`||e.slice(0,2).some(e=>!Number.isSafeInteger(e)||e<0||e>=t.length))throw Error(`Invalid sourcemap edges`);return[t[e[0]][0],t[e[1]][0],...e.slice(2)]})}function kr(e,{integrity:t,kind:n,size:r}){if(n===`stasis`)return{integrity:t,kind:n,size:r,bundle:P.parse(e)};if(n!==`sourcemap`)throw Error(`Unsupported bundle format`);return{integrity:t,kind:n,size:r,...Bn(e)}}export{Ke as a,P as b,et as c,Jn as d,Yn as e,X as f,tr as g,rr as h,ir as i,ar as j,cr as k,Z as l,ur as m,dr as n,pr as o,mr as p,vr as q,xr as r,Cr as s,wr as t,Tr as u,Er as v,Dr as w,kr as x};