@preventive/triage 1.0.0-alpha.74 → 1.0.0-alpha.76

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 (58) hide show
  1. package/common/finding-duplicates.js +4 -4
  2. package/common/finding-filters.js +11 -13
  3. package/common/managed/roles.ts +6 -0
  4. package/common/managed/routes.js +4 -3
  5. package/common/managed/team-app.d.ts +2 -0
  6. package/common/managed/team-app.js +31 -14
  7. package/out/activity.js +1 -1
  8. package/out/{chunk-C6OPCPCA.js → chunk-24LZZYAP.js} +1 -1
  9. package/out/{chunk-VRAJCPV5.js → chunk-EYTPAODY.js} +2 -2
  10. package/out/chunk-ITUKKCCK.js +10 -0
  11. package/out/{chunk-BLPHP4U3.js → chunk-IVDE66N5.js} +1 -1
  12. package/out/{chunk-VS7RV24Z.js → chunk-MFAB7P3T.js} +2 -2
  13. package/out/chunk-O6FA2R5G.js +53 -0
  14. package/out/chunk-OCE6KQGJ.js +40 -0
  15. package/out/{chunk-YI4D6XVX.js → chunk-RHOQDAU4.js} +1 -1
  16. package/out/{chunk-2IHCVA3Y.js → chunk-T6EXDRB7.js} +1 -1
  17. package/out/chunk-UZC7POI4.js +255 -0
  18. package/out/chunk-WGQ7D5DB.js +1 -0
  19. package/out/client-managed-import.js +1 -1
  20. package/out/client-managed.js +30 -30
  21. package/out/compare.js +4 -4
  22. package/out/dialogs.js +1 -1
  23. package/out/graph.js +6 -6
  24. package/out/index.html +8 -8
  25. package/out/prism.js +1 -1
  26. package/out/scan.js +1 -1
  27. package/out/view.css +1 -1
  28. package/out/view.js +4 -4
  29. package/package.json +5 -2
  30. package/risk/files/characters.js +142 -8
  31. package/risk/files/hosts.js +4 -3
  32. package/risk/files/readability.js +18 -13
  33. package/risk/files/runs-code.js +41 -80
  34. package/risk/files/script.js +210 -48
  35. package/risk/index.d.ts +4 -2
  36. package/risk/npm/assess.js +1 -1
  37. package/risk/npm/tarball.js +35 -19
  38. package/server-managed/dependency-review-comments.ts +22 -10
  39. package/server-managed/http.ts +74 -25
  40. package/server-managed/locked-packages.ts +62 -5
  41. package/server-managed/npm-packages.ts +7 -5
  42. package/server-managed/queue.ts +8 -7
  43. package/server-managed/repository-browser.ts +6 -3
  44. package/server-managed/repository-code.ts +3 -2
  45. package/server-managed/repository-risk-caches.ts +37 -0
  46. package/server-managed/repository-risk-read.ts +41 -18
  47. package/server-managed/repository-risk-stasis.ts +61 -0
  48. package/server-managed/repository-risk-turn.ts +97 -0
  49. package/server-managed/repository-risk.ts +128 -102
  50. package/server-managed/scan-downloads.ts +44 -10
  51. package/server-managed/team-app-summaries.ts +3 -1
  52. package/server-managed/team-app.ts +4 -2
  53. package/server-managed/team-reports.ts +8 -3
  54. package/out/chunk-5YP7P5KA.js +0 -1
  55. package/out/chunk-74AEKRES.js +0 -10
  56. package/out/chunk-DQJEVHRE.js +0 -52
  57. package/out/chunk-ESJZZF2Y.js +0 -255
  58. package/out/chunk-GV5U7OLP.js +0 -40
@@ -44,12 +44,12 @@ export function mergeDuplicateFields(survivor, dup) {
44
44
  // run for every duplicate, including agreeing copies and missing-field fills,
45
45
  // so the eventual dialog can name the reports that actually supplied a value.
46
46
  //
47
- // The derived copy is switched to open on Confirmed only where every copy is
48
- // (finding-filters.js confirmedCoverage): a copy from a report nobody
49
- // switched is still that report's to lose.
47
+ // The derived copy is of a report that opens as an App view on its own where
48
+ // any copy is (finding-filters.js confirmedCoverage): that report's view has
49
+ // it already, and another report carrying it adds nothing.
50
50
  export function mergeReportDuplicateFields(survivor, dup, reportName, conflicts) {
51
51
  if (!survivor || !dup || survivor === dup) return
52
- if (survivor._confirmedDefault === true && dup._confirmedDefault !== true) survivor._confirmedDefault = false
52
+ if (dup._opensAsApp === true) survivor._opensAsApp = true
53
53
  if (survivor.correctedSeverity || dup.correctedSeverity) {
54
54
  survivor._correctedByReport ??= {
55
55
  [survivor._reportName ?? '']: { severity: effectiveSeverity(survivor), reason: survivor.correctedSeverityReason },
@@ -238,17 +238,18 @@ function effectiveFloor(groups, confMin) {
238
238
 
239
239
  // Both the opening default and the dropdown lock use the same coverage:
240
240
  // findings represented by Confirmed rows, plus findings explicitly ruled out,
241
- // plus those a manager let Confirmed hide (`_confirmedDefault`).
241
+ // plus those of a report that opens as an App view on its own (`_opensAsApp`).
242
242
  // Read the original groups before `tabs` folds away their source members.
243
243
  //
244
- // A managed report switched to Confirmed by default (Manage → Reports) has
245
- // each of its findings stamped `_confirmedDefault` as it is read, its own
246
- // value whatever the report wrote (ingest.js, common/managed/team-app.js).
247
- // A finding Confirmed would hide is then a cost its manager accepted, and
248
- // counts as covered here, so both the opening outcome and the App lock (a
249
- // team's App mode) look past it. Only where EVERY copy of it is so stamped:
250
- // the same finding in a report nobody switched is still that report's to
251
- // lose, and keeps the view on Confidence.
244
+ // A managed team's reports are told beside each whether it opens as an App
245
+ // view alone: by its rows, or as a manager switched it to open on Confirmed
246
+ // (Manage → Reports). Each of its findings is stamped `_opensAsApp` as it is
247
+ // read, never from what the report wrote (ingest.js,
248
+ // common/managed/team-app.js). Confirmed hiding such a finding hides nothing
249
+ // that report's own view shows, so it counts as covered here, and both the
250
+ // opening outcome and the App lock (a team's App mode) look past it, whatever
251
+ // floor or range the team's other rows give the set. Where ANY copy of it is
252
+ // so stamped: another report carrying the same finding adds nothing to it.
252
253
  export function confirmedCoverage(groups, tabs, kindOf) {
253
254
  // A workspace may carry an un-stamped source copy from report A while
254
255
  // report B explicitly ruled out the same id. The ruled-out copy is
@@ -258,14 +259,11 @@ export function confirmedCoverage(groups, tabs, kindOf) {
258
259
  // even when the App finding that caused the ruling has no
259
260
  // `revalidateInputs` list of its own.
260
261
  const covered = new Set(groups.ruledOutIds ?? [])
261
- const waived = new Map()
262
262
  for (const raw of groups) {
263
263
  for (const f of raw) {
264
- if (['refuted', 'unreachable'].includes(kindOf(f))) covered.add(tabKey(f))
265
- waived.set(tabKey(f), waived.get(tabKey(f)) !== false && f._confirmedDefault === true)
264
+ if (['refuted', 'unreachable'].includes(kindOf(f)) || f._opensAsApp === true) covered.add(tabKey(f))
266
265
  }
267
266
  }
268
- for (const [key, all] of waived) if (all) covered.add(key)
269
267
  for (const raw of groups) {
270
268
  const g = tabs(raw)
271
269
  if (g.length === 0) continue
@@ -33,3 +33,9 @@ export function roleAtLeast(role: Role, min: Role): boolean {
33
33
  export function canReadRepositoryCode(session: { role: Role; publicShare?: boolean } | null | undefined): boolean {
34
34
  return session != null && !session.publicShare && roleAtLeast(session.role, 'view')
35
35
  }
36
+
37
+ // Who scans a team's risk, on its Risk tab (ui/managed/repository-risk.js):
38
+ // its managers and admins, signed in. A public link scans none.
39
+ export function canScanTeamRisk(session: { role: Role; publicShare?: boolean } | null | undefined): boolean {
40
+ return session != null && !session.publicShare && roleAtLeast(session.role, 'manage')
41
+ }
@@ -33,8 +33,9 @@ export const MANAGED_PAGES = Object.freeze({
33
33
  })
34
34
 
35
35
  // A team's lists, each at /team/<slug>/<what it lists>; its dependencies'
36
- // sub-tabs past the first at /team/<slug>/dependencies/<tab>.
37
- const WORKSPACE_CONTENT_VIEWS = new Set(['workspace-reports', 'workspace-bundles', 'workspace-repositories', 'workspace-dependencies'])
36
+ // sub-tabs past the first at /team/<slug>/dependencies/<tab>; and its risk,
37
+ // scanned at /team/<slug>/risk.
38
+ const WORKSPACE_CONTENT_VIEWS = new Set(['workspace-reports', 'workspace-bundles', 'workspace-repositories', 'workspace-dependencies', 'workspace-risk'])
38
39
  export const DEPENDENCY_TABS = new Set(['pulls', 'versions', 'branch', 'reviews'])
39
40
  // A route's `dependencyTab` field, where it names one.
40
41
  const dependencyTabField = route => route.view === 'workspace-dependencies' && route.dependencyTab != null ? { dependencyTab: route.dependencyTab } : {}
@@ -288,7 +289,7 @@ export function parseManagedRoute(url) {
288
289
  if (npm !== undefined) return npm
289
290
  const code = parseRepositoryCodeRoute(url)
290
291
  if (code !== undefined) return code
291
- const contentList = /^\/team\/([A-Za-z0-9_-]+)\/(reports|bundles|repositories|dependencies)$/u.exec(path)
292
+ const contentList = /^\/team\/([A-Za-z0-9_-]+)\/(reports|bundles|repositories|dependencies|risk)$/u.exec(path)
292
293
  if (contentList) return { view: `workspace-${contentList[2]}`, teamSlug: contentList[1] }
293
294
  const dependencies = /^\/team\/([A-Za-z0-9_-]+)\/dependencies\/([a-z]+)$/u.exec(path)
294
295
  if (dependencies) return DEPENDENCY_TABS.has(dependencies[2]) ? { view: 'workspace-dependencies', teamSlug: dependencies[1], dependencyTab: dependencies[2] } : null
@@ -11,6 +11,8 @@ export function managedReportConfirmedDefaultOffered(filename: string, data: unk
11
11
  export interface ManagedTeamView {
12
12
  app: TeamAppMetadata
13
13
  rows: Set<string> | null
14
+ // By the workspace's index, whether each report opens as an App view on its own.
15
+ opensAsApp: boolean[]
14
16
  conflicted(): boolean
15
17
  lens(): { drop: boolean; detail: boolean; upstream: boolean }
16
18
  }
@@ -46,16 +46,16 @@ export function managedTeamLens(workspace) {
46
46
  // their own), the rows its App view shows (managedTeamAppRows), and, asked
47
47
  // only where wanted, whether copies contradict the pass
48
48
  // (managedTeamRevalidationConflicted) and what its rows offer the toolbar
49
- // (managedTeamLens).
49
+ // (managedTeamLens). With it, which of the workspace's reports open as App
50
+ // views on their own (`opensAsApp`, by its index), which its view is told
51
+ // beside each report (server-managed/team-reports.ts).
50
52
  export function managedTeamView(workspace) {
51
- const { reports, duplicates, linked } = viewReports(workspace)
53
+ const { reports, duplicates, opensAsApp } = viewReports(workspace)
52
54
  const { metadata, rows } = workspaceApp(reports, id => [...duplicates.get(id) ?? []], { countFindings: true })
53
- // Each report alone, with the links the workspace has, not its link reports'.
54
- const alone = id => [...linked.get(id) ?? []]
55
- const app = metadata.appMode ? metadata : { ...metadata, appReports: reports.filter(report => workspaceAppMetadata([report], alone).appMode).length }
55
+ const app = metadata.appMode ? metadata : { ...metadata, appReports: opensAsApp.filter(Boolean).length }
56
56
  let merged = null
57
57
  const plain = () => merged ??= mergeReportGroups(reports)
58
- return { app, rows, conflicted: () => plain().conflicts.size > 0, lens: () => lensOf(reports, plain().groups) }
58
+ return { app, rows, opensAsApp, conflicted: () => plain().conflicts.size > 0, lens: () => lensOf(reports, plain().groups) }
59
59
  }
60
60
 
61
61
  const RULED_OUT = new Set(['refuted', 'unreachable'])
@@ -84,15 +84,23 @@ export function managedReportConfirmedDefaultOffered(filename, data) {
84
84
  }
85
85
 
86
86
  // The workspace's reports as a view holds them (ui/view/ingest.js), with the
87
- // duplicates its links name, and those its own `links` name alone (`linked`).
88
- // A report switched to open on Confirmed (`confirmedDefault`) stamps each of
89
- // its findings so, and no other finding is, whatever its report wrote
90
- // (common/finding-filters.js confirmedCoverage).
87
+ // duplicates its links name.
88
+ //
89
+ // A report that opens as an App view on its own stamps each of its findings
90
+ // `_opensAsApp`, and no other finding is, whatever its report wrote: one a
91
+ // manager switched to open on Confirmed (`confirmedDefault`), and one whose
92
+ // rows make it one, asked of it alone with the links the workspace has, not
93
+ // its link reports' (common/workspace-app.js workspaceAppMetadata). Its team
94
+ // counts none of them as holding it off Confirmed
95
+ // (common/finding-filters.js confirmedCoverage): a report that opens on
96
+ // Confirmed alone does so in its team too, whatever floor or range the
97
+ // team's other rows give it. `opensAsApp` tells which, by the workspace's
98
+ // index; a links document is none.
91
99
  function viewReports(workspace) {
92
- const duplicates = new Map(), linked = new Map(), reports = []
100
+ const duplicates = new Map(), indices = [], linked = new Map(), reports = []
93
101
  collectDuplicates(workspace.links ?? [], duplicates)
94
102
  collectDuplicates(workspace.links ?? [], linked)
95
- for (const { filename, data, confirmedDefault } of workspace) {
103
+ for (const [index, { filename, data, confirmedDefault }] of workspace.entries()) {
96
104
  if (data.source === 'links' && Array.isArray(data.links)) {
97
105
  collectDuplicates(data.links, duplicates)
98
106
  continue
@@ -100,13 +108,22 @@ function viewReports(workspace) {
100
108
  const entries = (reportEntries(data) ?? []).map(entry => Array.isArray(entry) ? entry : [entry])
101
109
  const judged = new Set(entries.flat().filter(hasRevalidateStamp).map(f => f.source ?? data.source ?? null))
102
110
  const groups = entries.map(group => group.map(f => {
103
- const finding = { ...f, _source: f.source ?? data.source ?? null, _confirmedDefault: confirmedDefault === true }
111
+ const finding = { ...f, _source: f.source ?? data.source ?? null, _opensAsApp: confirmedDefault === true }
104
112
  inheritReportMeta(finding, data)
105
113
  if (!('isApp' in finding)) finding.isApp = isAppFinding(finding, finding._source)
106
114
  finding._sourcePass = judged.has(finding._source)
107
115
  return finding
108
116
  }))
109
117
  reports.push({ fileName: filename, groups, treeDependencies: data.treeDependencies ?? null })
118
+ indices.push(index)
119
+ }
120
+ const alone = id => [...linked.get(id) ?? []]
121
+ const opensAsApp = workspace.map(() => false)
122
+ for (const [at, report] of reports.entries()) {
123
+ const findings = report.groups.flat()
124
+ if (!findings.some(f => f._opensAsApp) && !workspaceAppMetadata([report], alone).appMode) continue
125
+ for (const f of findings) f._opensAsApp = true
126
+ opensAsApp[indices[at]] = true
110
127
  }
111
- return { reports, duplicates, linked }
128
+ return { reports, duplicates, opensAsApp }
112
129
  }
package/out/activity.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,d as n,e as r,f as i,h as a,i as o}from"./chunk-C6OPCPCA.js";import{Aa as s,Ba as c,Ca as l,Cf as u,Da as d,Df as f,Fa as p,Fe as m,Ga as h,Ge as g,Gf as _,He as v,Hf as y,Ie as b,If as x,Je as S,Jf as ee,Ke as C,Kf as te,Lf as ne,Lg as re,Mf as ie,Mg as ae,Nf as oe,Of as se,Pf as ce,Qf as le,Rf as ue,Sf as de,Tf as fe,Uf as pe,Vf as me,Wf as he,Xf as ge,Yf as _e,ag as ve,la as ye,le as be,me as xe,ne as w,oa as Se,pa as Ce,pe as T,qa as we,qe as Te,re as Ee,sa as De,se as Oe,ta as ke,tc as Ae,te as E,ua as je,uc as Me,ue as Ne,va as Pe,ve as D,we as Fe,xe as O,ye as Ie,za as Le,ze as Re}from"./chunk-ESJZZF2Y.js";import"./chunk-A4BBBHQU.js";import"./chunk-JCIIBLKR.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import"./chunk-PQPKHAI5.js";import"./chunk-2IHCVA3Y.js";import"./chunk-DQJEVHRE.js";import"./chunk-62QT2RXR.js";import"./chunk-S5HSDGTP.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as ze}from"./chunk-GV5U7OLP.js";import"./chunk-BLPHP4U3.js";import{e as Be}from"./chunk-74JZTGTO.js";import"./chunk-IYPY47MC.js";import{A as Ve,B as He,d as Ue,e as We,f as Ge,g as Ke}from"./chunk-74AEKRES.js";import{a as k}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import"./chunk-5YP7P5KA.js";import"./chunk-QRKFPLA4.js";import{c as A,d as j,g as M,j as qe}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Je=e=>e.committedAt??-1/0;function Ye(e){let t=new Map(e.map((e,t)=>[e.sha,t])),n=new Map(e.map(e=>[e.sha,0]));for(let r of e)for(let e of new Set(r.parents))t.has(e)&&n.set(e,n.get(e)+1);let r=(e,n)=>Je(e)-Je(n)||t.get(n.sha)-t.get(e.sha),i=e.filter(e=>n.get(e.sha)===0).toSorted(r),a=[];for(;i.length>0;){let o=i.pop();a.push(o);for(let a of new Set(o.parents)){if(!t.has(a))continue;let o=n.get(a)-1;if(n.set(a,o),o>0)continue;let s=e[t.get(a)],c=i.length,l=0;for(;l<c;){let e=l+c>>1;r(i[e],s)<0?l=e+1:c=e}i.splice(l,0,s)}}return a}function Xe(e,t){let n=new Map(e.map(e=>[e.sha,e])),r=new Set;for(let e=n.get(t);e&&!r.has(e.sha);e=n.get(e.parents[0]))r.add(e.sha);return r}function Ze(e,{linear:t=!1,trunk:n=null,colors:r=8}={}){let i=new Set(e.map(e=>e.sha)),a=+(n?.size>0),o=[],s=[],c=[],l=[],u=[],d=0,f=0,p=()=>{let e=o.indexOf(null,a);return e===-1?Math.max(o.length,a):e},m=e=>{if(n?.has(e))return 0;let t=o.indexOf(e);return t===-1?null:t},h=e=>{let t=Math.max(1,r-a),n=new Set([e-1,e+1].filter(e=>o[e]!=null).map(e=>s[e])),i=Array.from({length:t},(e,t)=>t).find(e=>!n.has(a+(f+e)%t))??0,c=a+(f+i)%t;return f=(f+i+1)%t,c};for(let[r,a]of e.entries()){let f=e[r+1],g=t?f?[f.sha]:a.parents.slice(0,1):[...new Set(a.parents)],_=g.filter(e=>i.has(e)),v=m(a.sha),y=v??p(),b=n?.has(a.sha)?0:v===null?h(y):s[y];for(let[e,t]of o.entries())t===a.sha&&(o[e]=null);c.push({commit:a,col:y,color:b});let x=new Set;o[y]=_[0]??null,s[y]=b,_.length>0&&x.add(y);let S=[];for(let e of _.slice(1)){let t=n?.has(e)?0:o.indexOf(e);if(t===-1||o[t]!==e){let t=p();s[t]=h(t),o[t]=e,x.add(t)}else S.push(t)}let ee=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:ee,color:b}),ee=!1;for(let e=0;e<o.length;e++)o[e]??=null;if(d=Math.max(d,o.length),f){let e=m(f.sha);for(let[t,n]of o.entries())n!==null&&l.push({row:r,from:x.has(t)?y:t,to:n===f.sha?e:t,color:s[t]});for(let t of S)l.push({row:r,from:y,to:o[t]===f.sha?e:t,color:s[t]})}for(;o.length>0&&o.at(-1)===null;)o.pop()}return{rows:c,segments:l,stubs:u,width:Math.max(d,+(c.length>0))}}var Qe=12,N=24,$e=9,et=8,tt=3,nt=`a[href], .history-commit`,rt=15e3,it=3e3,at=10,ot=25,st=`all`,ct=new Set,P=T(new Map,ct),{Shown:lt,shown:ut,repaint:F}=D(qe);function dt(e,t,n=new Set){let r={status:`ready`,until:Date.now()+be,page:1,commits:e.commits,more:e.more===!0,branches:e.branches??[],tags:e.tags??[],defaultBranch:e.defaultBranch??null,unread:e.unread,cut:e.cut===!0,pulls:e.pulls,pullsPending:e.pullsPending===!0,openPulls:e.openPulls,loadingMore:!1,moreError:null,sought:n};return t?.(r),r}function ft(e,t){let n=E(e.pulls,t,e=>e.merge);n.length>e.pulls.length&&(e.pulls=n)}function pt(e,t,n,r,i,a=1){setTimeout(()=>{P().get(e)===t&&n(r,i).then(o=>(P().get(e)!==t||(ft(t,o.pulls),o.pullsPending&&a<at&&pt(e,t,n,r,i,a+1)),null),()=>null).finally(F)},it)}function mt(e,t,n){return Ee(P(),e,()=>t(1),{ready:e=>dt(e,n),settled:n=>{n.pullsPending&&pt(e,n,t,1,null)},failed:e=>{let t=Te(e,`The history could not be read.`);return t&&{...t,code:e?.code??null}},repaint:F})}function ht(e,t,n,r,i){let a=t.sought;t.sought=new Set(a).add(i),t.refreshing=!0,n(1,null,!0).then(o=>{if(P().get(e)!==t)return null;let s=t.retried===i?0:Math.min(Number(o.retryIn)||0,rt),c=dt(o,r,s>0?a:t.sought);return s>0&&(Object.assign(c,{retried:i,retryAt:Date.now()+s}),setTimeout(F,s)),P().set(e,c),c.pullsPending&&pt(e,c,n,1,null),null},()=>null).finally(()=>{t.refreshing=!1,F()})}function gt(e){let t=new Set(e.commits.map(e=>e.sha));e.branches=[...e.branches,...e.unread.flatMap(({name:e,sha:n})=>t.has(n)?[{name:e,sha:n}]:[])],e.unread=e.unread.filter(e=>!t.has(e.sha)),e.asked??=new Set;let n=new Map,r=(t,r)=>{e.asked.has(t)||n.set(t,Math.max(n.get(t)??-1/0,r??0))};for(let n of e.commits)for(let e of n.parents)t.has(e)||r(e,n.committedAt);for(let t of e.unread)r(t.sha,t.at);e.next=[...n].toSorted((e,t)=>t[1]-e[1]).slice(0,ot).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function _t(e,t,n,r){let i={next:t.next};Fe(t,{held:()=>P().get(e)===t,ask:()=>n(t.page+1,i),merge:a=>{t.commits=E(t.commits,a.commits,e=>e.sha),ft(t,a.pulls),t.page+=1,t.more=a.more===!0,r?.(t),a.pullsPending&&pt(e,t,n,t.page,i)},error:`More commits could not be read.`,repaint:F})}var vt=e=>typeof e==`string`&&/^[a-f\d]{40}$/u.test(e),yt=e=>vt(e?.sha)&&Array.isArray(e.parents);function bt(e){if(!Array.isArray(e?.commits))throw TypeError(`The server answered with no history.`);let t=e.commits.filter(yt),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&vt(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>vt(e?.merge)&&Number.isSafeInteger(e.number)&&vt(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(yt)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&vt(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function xt(e,t,n){let r=St(e,t),i=new Map(r.map(e=>[e.sha,e]));if(!i.has(n))return r;let a=new Set;for(let e=[n];e.length>0;){let t=e.pop();a.has(t)||!i.has(t)||(a.add(t),e.push(...i.get(t).parents))}let o=i.get(n);for(let e=new Set;i.has(o.parents[0])&&!e.has(o.sha);o=i.get(o.parents[0]))e.add(o.sha);let s=o.parents.length>0?o.committedAt??1/0:-1/0;return r.filter(e=>!a.has(e.sha)&&(e.committedAt??-1/0)>s)}function St(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.merge,e])),r=new Set(e.map(e=>e.sha)),i=new Map;for(let e of t)for(let t of e.commits)!r.has(t.sha)&&!i.has(t.sha)&&i.set(t.sha,{...t,pull:e.number});return[...e.map(e=>{let t=n.get(e.sha);return t&&e.parents.length===1&&t.head!==e.parents[0]?{...e,parents:[e.parents[0],t.head]}:e}),...i.values()]}var Ct=6e4,wt=60*Ct,Tt=24*wt;function Et(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-Ct&&n<Ct)return`now`;if(n>0&&n<wt)return`${Math.floor(n/Ct)}m`;if(n>0&&n<Tt)return`${Math.floor(n/wt)}h`;if(n>0&&n<7*Tt)return`${Math.floor(n/Tt)}d`;let r=new Date(e);return r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`}})}function Dt({branches:e=[],tags:t=[],pulls:n=[],openPulls:r=[]},i){let a=new Map,o=(e,t)=>a.set(e,[...a.get(e)??[],t]);for(let t of e.toSorted((e,t)=>+(t.name===i)-(e.name===i)))o(t.sha,{kind:`branch`,name:t.name,main:t.name===i});let s=new Set;for(let{number:e,sha:t}of[...n.map(e=>({number:e.number,sha:e.head})),...r])s.has(e)||(s.add(e),o(t,{kind:`pull`,name:`#${e}`,number:e}));for(let e of t)o(e.sha,{kind:`tag`,name:e.name});return a}var Ot=e=>e?`https://github.com/${e.split(`/`).map(encodeURIComponent).join(`/`)}`:null;function kt(e,t){if(!t)return e;let n=[],r=0;for(let i of e.matchAll(/(?<=^|[\s([])#(\d+)\b/gu))n.push(e.slice(r,i.index),A`<a href="${`${t}/issues/${i[1]}`}" target="_blank" rel="noopener noreferrer" tabindex="-1">${i[0]}</a>`),r=i.index+i[0].length;return r===0?e:[...n,e.slice(r)]}var I=e=>$e+e*Qe,At=e=>e*N+N/2,jt=e=>$e*2+(e.width-1)*Qe;function Mt({row:e,from:t,to:n}){let[r,i,a,o]=[I(t),I(n),At(e),At(e+1)];if(r===i)return`M${r} ${a}V${o}`;let s=(a+o)/2;return`M${r} ${a}C${r} ${s} ${i} ${s} ${i} ${o}`}var Nt=({row:e,col:t,straight:n})=>n?`M${I(t)} ${At(e)+6}v${N*.55}`:`M${I(t)+4} ${At(e)+5}l${Qe*.6} ${N*.5}`;function Pt(e,t){let n=(e,t,n=``)=>{let r=Array.from({length:et},()=>[]);for(let n of e)r[n.color].push(t(n));return r.map((e,t)=>e.length>0?j`<path class=${`${n}lane-${t}`} d=${e.join(``)}/>`:M)};return A`<svg class="history-graph" width="${jt(e)}" height="${e.rows.length*N}" aria-hidden="true">${n(e.segments,Mt)} ${n(e.stubs,Nt,`history-stub `)} ${e.rows.map(({commit:e,col:n,color:r},i)=>j`<circle class=${`lane-${r}${e.sha===t?` is-shown`:``}`} cx=${I(n)} cy=${At(i)}
1
+ import{a as e,c as t,d as n,e as r,f as i,h as a,i as o}from"./chunk-24LZZYAP.js";import{Aa as s,Ba as c,Ca as l,Cf as u,Da as d,Df as f,Fa as p,Fe as m,Ga as h,Ge as g,Gf as _,He as v,Hf as y,Ie as b,If as x,Je as S,Jf as ee,Ke as C,Kf as te,Lf as ne,Lg as re,Mf as ie,Mg as ae,Nf as oe,Of as se,Pf as ce,Qf as le,Rf as ue,Sf as de,Tf as fe,Uf as pe,Vf as me,Wf as he,Xf as ge,Yf as _e,ag as ve,la as ye,le as be,me as xe,ne as w,oa as Se,pa as Ce,pe as T,qa as we,qe as Te,re as Ee,sa as De,se as Oe,ta as ke,tc as Ae,te as E,ua as je,uc as Me,ue as Ne,va as Pe,ve as D,we as Fe,xe as O,ye as Ie,za as Le,ze as Re}from"./chunk-UZC7POI4.js";import"./chunk-A4BBBHQU.js";import"./chunk-JCIIBLKR.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import"./chunk-PQPKHAI5.js";import"./chunk-T6EXDRB7.js";import"./chunk-O6FA2R5G.js";import"./chunk-62QT2RXR.js";import"./chunk-S5HSDGTP.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as ze}from"./chunk-OCE6KQGJ.js";import"./chunk-IVDE66N5.js";import{e as Be}from"./chunk-74JZTGTO.js";import"./chunk-IYPY47MC.js";import{A as Ve,B as He,d as Ue,e as We,f as Ge,g as Ke}from"./chunk-ITUKKCCK.js";import{a as k}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import"./chunk-WGQ7D5DB.js";import"./chunk-QRKFPLA4.js";import{c as A,d as j,g as M,j as qe}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Je=e=>e.committedAt??-1/0;function Ye(e){let t=new Map(e.map((e,t)=>[e.sha,t])),n=new Map(e.map(e=>[e.sha,0]));for(let r of e)for(let e of new Set(r.parents))t.has(e)&&n.set(e,n.get(e)+1);let r=(e,n)=>Je(e)-Je(n)||t.get(n.sha)-t.get(e.sha),i=e.filter(e=>n.get(e.sha)===0).toSorted(r),a=[];for(;i.length>0;){let o=i.pop();a.push(o);for(let a of new Set(o.parents)){if(!t.has(a))continue;let o=n.get(a)-1;if(n.set(a,o),o>0)continue;let s=e[t.get(a)],c=i.length,l=0;for(;l<c;){let e=l+c>>1;r(i[e],s)<0?l=e+1:c=e}i.splice(l,0,s)}}return a}function Xe(e,t){let n=new Map(e.map(e=>[e.sha,e])),r=new Set;for(let e=n.get(t);e&&!r.has(e.sha);e=n.get(e.parents[0]))r.add(e.sha);return r}function Ze(e,{linear:t=!1,trunk:n=null,colors:r=8}={}){let i=new Set(e.map(e=>e.sha)),a=+(n?.size>0),o=[],s=[],c=[],l=[],u=[],d=0,f=0,p=()=>{let e=o.indexOf(null,a);return e===-1?Math.max(o.length,a):e},m=e=>{if(n?.has(e))return 0;let t=o.indexOf(e);return t===-1?null:t},h=e=>{let t=Math.max(1,r-a),n=new Set([e-1,e+1].filter(e=>o[e]!=null).map(e=>s[e])),i=Array.from({length:t},(e,t)=>t).find(e=>!n.has(a+(f+e)%t))??0,c=a+(f+i)%t;return f=(f+i+1)%t,c};for(let[r,a]of e.entries()){let f=e[r+1],g=t?f?[f.sha]:a.parents.slice(0,1):[...new Set(a.parents)],_=g.filter(e=>i.has(e)),v=m(a.sha),y=v??p(),b=n?.has(a.sha)?0:v===null?h(y):s[y];for(let[e,t]of o.entries())t===a.sha&&(o[e]=null);c.push({commit:a,col:y,color:b});let x=new Set;o[y]=_[0]??null,s[y]=b,_.length>0&&x.add(y);let S=[];for(let e of _.slice(1)){let t=n?.has(e)?0:o.indexOf(e);if(t===-1||o[t]!==e){let t=p();s[t]=h(t),o[t]=e,x.add(t)}else S.push(t)}let ee=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:ee,color:b}),ee=!1;for(let e=0;e<o.length;e++)o[e]??=null;if(d=Math.max(d,o.length),f){let e=m(f.sha);for(let[t,n]of o.entries())n!==null&&l.push({row:r,from:x.has(t)?y:t,to:n===f.sha?e:t,color:s[t]});for(let t of S)l.push({row:r,from:y,to:o[t]===f.sha?e:t,color:s[t]})}for(;o.length>0&&o.at(-1)===null;)o.pop()}return{rows:c,segments:l,stubs:u,width:Math.max(d,+(c.length>0))}}var Qe=12,N=24,$e=9,et=8,tt=3,nt=`a[href], .history-commit`,rt=15e3,it=3e3,at=10,ot=25,st=`all`,ct=new Set,P=T(new Map,ct),{Shown:lt,shown:ut,repaint:F}=D(qe);function dt(e,t,n=new Set){let r={status:`ready`,until:Date.now()+be,page:1,commits:e.commits,more:e.more===!0,branches:e.branches??[],tags:e.tags??[],defaultBranch:e.defaultBranch??null,unread:e.unread,cut:e.cut===!0,pulls:e.pulls,pullsPending:e.pullsPending===!0,openPulls:e.openPulls,loadingMore:!1,moreError:null,sought:n};return t?.(r),r}function ft(e,t){let n=E(e.pulls,t,e=>e.merge);n.length>e.pulls.length&&(e.pulls=n)}function pt(e,t,n,r,i,a=1){setTimeout(()=>{P().get(e)===t&&n(r,i).then(o=>(P().get(e)!==t||(ft(t,o.pulls),o.pullsPending&&a<at&&pt(e,t,n,r,i,a+1)),null),()=>null).finally(F)},it)}function mt(e,t,n){return Ee(P(),e,()=>t(1),{ready:e=>dt(e,n),settled:n=>{n.pullsPending&&pt(e,n,t,1,null)},failed:e=>{let t=Te(e,`The history could not be read.`);return t&&{...t,code:e?.code??null}},repaint:F})}function ht(e,t,n,r,i){let a=t.sought;t.sought=new Set(a).add(i),t.refreshing=!0,n(1,null,!0).then(o=>{if(P().get(e)!==t)return null;let s=t.retried===i?0:Math.min(Number(o.retryIn)||0,rt),c=dt(o,r,s>0?a:t.sought);return s>0&&(Object.assign(c,{retried:i,retryAt:Date.now()+s}),setTimeout(F,s)),P().set(e,c),c.pullsPending&&pt(e,c,n,1,null),null},()=>null).finally(()=>{t.refreshing=!1,F()})}function gt(e){let t=new Set(e.commits.map(e=>e.sha));e.branches=[...e.branches,...e.unread.flatMap(({name:e,sha:n})=>t.has(n)?[{name:e,sha:n}]:[])],e.unread=e.unread.filter(e=>!t.has(e.sha)),e.asked??=new Set;let n=new Map,r=(t,r)=>{e.asked.has(t)||n.set(t,Math.max(n.get(t)??-1/0,r??0))};for(let n of e.commits)for(let e of n.parents)t.has(e)||r(e,n.committedAt);for(let t of e.unread)r(t.sha,t.at);e.next=[...n].toSorted((e,t)=>t[1]-e[1]).slice(0,ot).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function _t(e,t,n,r){let i={next:t.next};Fe(t,{held:()=>P().get(e)===t,ask:()=>n(t.page+1,i),merge:a=>{t.commits=E(t.commits,a.commits,e=>e.sha),ft(t,a.pulls),t.page+=1,t.more=a.more===!0,r?.(t),a.pullsPending&&pt(e,t,n,t.page,i)},error:`More commits could not be read.`,repaint:F})}var vt=e=>typeof e==`string`&&/^[a-f\d]{40}$/u.test(e),yt=e=>vt(e?.sha)&&Array.isArray(e.parents);function bt(e){if(!Array.isArray(e?.commits))throw TypeError(`The server answered with no history.`);let t=e.commits.filter(yt),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&vt(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>vt(e?.merge)&&Number.isSafeInteger(e.number)&&vt(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(yt)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&vt(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function xt(e,t,n){let r=St(e,t),i=new Map(r.map(e=>[e.sha,e]));if(!i.has(n))return r;let a=new Set;for(let e=[n];e.length>0;){let t=e.pop();a.has(t)||!i.has(t)||(a.add(t),e.push(...i.get(t).parents))}let o=i.get(n);for(let e=new Set;i.has(o.parents[0])&&!e.has(o.sha);o=i.get(o.parents[0]))e.add(o.sha);let s=o.parents.length>0?o.committedAt??1/0:-1/0;return r.filter(e=>!a.has(e.sha)&&(e.committedAt??-1/0)>s)}function St(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.merge,e])),r=new Set(e.map(e=>e.sha)),i=new Map;for(let e of t)for(let t of e.commits)!r.has(t.sha)&&!i.has(t.sha)&&i.set(t.sha,{...t,pull:e.number});return[...e.map(e=>{let t=n.get(e.sha);return t&&e.parents.length===1&&t.head!==e.parents[0]?{...e,parents:[e.parents[0],t.head]}:e}),...i.values()]}var Ct=6e4,wt=60*Ct,Tt=24*wt;function Et(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-Ct&&n<Ct)return`now`;if(n>0&&n<wt)return`${Math.floor(n/Ct)}m`;if(n>0&&n<Tt)return`${Math.floor(n/wt)}h`;if(n>0&&n<7*Tt)return`${Math.floor(n/Tt)}d`;let r=new Date(e);return r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`}})}function Dt({branches:e=[],tags:t=[],pulls:n=[],openPulls:r=[]},i){let a=new Map,o=(e,t)=>a.set(e,[...a.get(e)??[],t]);for(let t of e.toSorted((e,t)=>+(t.name===i)-(e.name===i)))o(t.sha,{kind:`branch`,name:t.name,main:t.name===i});let s=new Set;for(let{number:e,sha:t}of[...n.map(e=>({number:e.number,sha:e.head})),...r])s.has(e)||(s.add(e),o(t,{kind:`pull`,name:`#${e}`,number:e}));for(let e of t)o(e.sha,{kind:`tag`,name:e.name});return a}var Ot=e=>e?`https://github.com/${e.split(`/`).map(encodeURIComponent).join(`/`)}`:null;function kt(e,t){if(!t)return e;let n=[],r=0;for(let i of e.matchAll(/(?<=^|[\s([])#(\d+)\b/gu))n.push(e.slice(r,i.index),A`<a href="${`${t}/issues/${i[1]}`}" target="_blank" rel="noopener noreferrer" tabindex="-1">${i[0]}</a>`),r=i.index+i[0].length;return r===0?e:[...n,e.slice(r)]}var I=e=>$e+e*Qe,At=e=>e*N+N/2,jt=e=>$e*2+(e.width-1)*Qe;function Mt({row:e,from:t,to:n}){let[r,i,a,o]=[I(t),I(n),At(e),At(e+1)];if(r===i)return`M${r} ${a}V${o}`;let s=(a+o)/2;return`M${r} ${a}C${r} ${s} ${i} ${s} ${i} ${o}`}var Nt=({row:e,col:t,straight:n})=>n?`M${I(t)} ${At(e)+6}v${N*.55}`:`M${I(t)+4} ${At(e)+5}l${Qe*.6} ${N*.5}`;function Pt(e,t){let n=(e,t,n=``)=>{let r=Array.from({length:et},()=>[]);for(let n of e)r[n.color].push(t(n));return r.map((e,t)=>e.length>0?j`<path class=${`${n}lane-${t}`} d=${e.join(``)}/>`:M)};return A`<svg class="history-graph" width="${jt(e)}" height="${e.rows.length*N}" aria-hidden="true">${n(e.segments,Mt)} ${n(e.stubs,Nt,`history-stub `)} ${e.rows.map(({commit:e,col:n,color:r},i)=>j`<circle class=${`lane-${r}${e.sha===t?` is-shown`:``}`} cx=${I(n)} cy=${At(i)}
2
2
  r=${e.sha===t?4.5:e.parents.length>1?3:3.5}/>`)}</svg>`}function Ft(e,t,n,r){if(!e?.length)return M;let i=e=>{let t=ze({"history-ref":!0,[`is-${e.kind}`]:!0,"is-default":e.main===!0,"is-shown":e.kind===n.kind&&e.name===n.name}),i=A`${e.kind===`tag`?Ue(He):e.kind===`pull`?Ue(Ve):M}<span>${e.name}</span>`;return e.kind===`pull`&&r?A`<a class="${t}" href="${`${r}/pull/${e.number}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Pull request ${e.name} on GitHub`}">${i}</a>`:A`<span class="${t}">${i}</span>`},a=e.slice(tt);return A`<span class="history-refs" style="${k({"--ref":`var(--lane-${t})`})}">${e.slice(0,tt).map(i)}${a.length>0?A`<span class="history-ref is-more" data-tooltip="${a.map(e=>e.name).join(`, `)}">+${a.length}</span>`:M}</span>`}function It(e,t){let{repoId:n,commit:r,path:i}=e,a=t===`all`||t===`unmerged`,o=a?`all\0${n}`:`${n}\0${r}\0${i}`,s=(e,o,s=!1)=>Le(n,a?``:r,i,{page:e,all:a,...s?{fresh:!0}:{},...t!==`path`&&e>1?{from:o.next}:{}}).then(e=>{if(!a&&e?.commit!==r)throw Error(`The server answered with another revision's history.`);return bt(e)}),c=t===`path`?null:gt,l=mt(o,s,c);return!a||l.status!==`ready`||l.refreshing||l.sought.has(r)||l.retryAt>Date.now()||St(l.commits,l.pulls??[]).some(e=>e.sha===r)||ht(o,l,s,c,r),a&&l.status===`error`&&l.code===`github-token-required`?(ct.add(n),It(e,`revision`)):{mode:t,key:o,entry:l,more:()=>_t(o,l,s,c)}}var Lt=e=>It(e,e.path?`path`:`revision`),Rt=e=>{ut.add(e)},zt=e=>{ut.delete(e)};function Bt(e){P().delete(e),F()}var Vt=class extends lt{static properties={refs:{attribute:!1}};constructor(){super(),this.refs=null,this._drawn=null,this._mode=null}updated(){this.watchMore(()=>this._mode!==`unmerged`)}mode(){let{repoId:e,path:t}=this.repository;return t?`path`:(P(),ct.has(e)?`revision`:st)}history(e){return It(this.repository,e)}layout(e,t,n){let r=this._drawn;if(r?.commits===t.commits&&r.pulls===t.pulls&&r.mode===e&&r.defaultBranch===n)return r.layout;let i=e===`path`,a=t.branches.find(e=>e.name===n)?.sha,o=i?t.commits:Ye(e===`unmerged`?xt(t.commits,t.pulls??[],a):St(t.commits,t.pulls??[])),s=e===`all`?a:e===`revision`?o[0]?.sha:null,c=Ze(o,{linear:i,trunk:s&&!i?Xe(o,s):null,colors:et});return this._drawn={commits:t.commits,pulls:t.pulls,mode:e,defaultBranch:n,layout:c},c}pick(e){st=e,F()}open(e,t){let{repoId:n,repo:r,path:i}=this.repository,a=t?.find(e=>e.kind===`branch`)??t?.find(e=>e.kind===`tag`);re({repoId:n,repo:r,path:i,commit:e.sha,bundleTab:`commits`,...a?{revision:{kind:a.kind,name:a.name}}:{}})}keydown(e){let t=[...this.querySelectorAll(`.history-row`)],n=e.target.closest(`.history-row`),r=n?[...n.querySelectorAll(nt)]:[],i=r.indexOf(e.target);if(i===-1)return;let a={ArrowLeft:-1,ArrowRight:1}[e.key],o={ArrowUp:-1,ArrowDown:1}[e.key],s=a?r[i+a]:(o?t[t.indexOf(n)+o]:{Home:t[0],End:t.at(-1)}[e.key])?.querySelector(`.history-commit`);if(s){e.preventDefault();for(let e of this.querySelectorAll(`.history-row :is(${nt})`))e.tabIndex=e===s?0:-1;s.focus()}}render(){if(!this.repository)return M;let{mode:e,key:t,entry:n,more:r}=this.history(this.mode());this._mode=e;let i=n.status===`ready`,a=e===`all`||e===`unmerged`?n.defaultBranch:this.refs?.status===`ready`?this.refs.value.defaultBranch??null:null,o=i?this.layout(e,n,a):null,s=e===`unmerged`?o?.rows.length??0:n.commits?.length??0,c=e===`unmerged`&&o?new Set(o.rows.map(e=>e.commit.sha)):null,l=i&&e===`all`?n.branches.length:c?n.branches.filter(e=>c.has(e.sha)).length:0,u=i?`${s}${n.more||n.cut?`+`:``} commit${s===1?``:`s`}`:``,d=ct.has(this.repository.repoId);return A`<div class="history-bar">${C(`commits`)} ${e===`path`?A`<span class="history-scope">Commits touching <code>${this.repository.path}</code></span>`:d?A`<span class="history-scope">Every branch needs your GitHub sign-in.</span>`:O(`Branches`,[[`all`,`All branches`],[`unmerged`,`Unmerged`]],e,e=>()=>this.pick(e),{spaced:!0})} ${i?A`<span class="history-summary">${u}${l>0?` on ${l} branch${l===1?``:`es`}`:``}</span>`:M}</div>${i?this.renderCommits(e,n,r,o,a):Re(n,`Reading the history…`,()=>Bt(t))}`}renderCommits(e,t,n,r,i){if(r.rows.length===0&&(e!==`unmerged`||!t.more&&!t.moreError))return A`<div class="bundles-slide-placeholder">${e===`unmerged`?`Every branch read is merged.`:`No commits.`}</div>`;let a=this.repository.commit,o=ae(this.repository,this.refs),s=Dt(t,i),c=Math.max(0,r.rows.findIndex(e=>e.commit.sha===a)),l=Ot(this.repo??this.repository.repo);return A`<div class="history-scroll">${e===`all`&&!t.refreshing&&!(t.retryAt>Date.now())&&!r.rows.some(e=>e.commit.sha===a)?A`<p class="history-note"><code>${a.slice(0,7)}</code> isn’t among these commits.</p>`:M}<div class="history-lines" style="${k({"--history-graph":`${jt(r)}px`})}">${Pt(r,a)}<ol class="history-list" aria-label="Commits" @keydown="${this.keydown}">${r.rows.map(({commit:e,color:t},n)=>{let r=s.get(e.sha),i=e.committedAt==null?null:new Date(e.committedAt),u=e.sha.slice(0,7);return A`<li class="${ze({"history-row":!0,"is-shown":e.sha===a})}">${l?A`<a class="history-sha" href="${`${l}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Commit ${u} on GitHub`}">${u}</a>`:A`<code class="history-sha">${u}</code>`} ${Ft(r,t,o,l)} <span class="history-subject" id="${`history-subject-${e.sha}`}">${kt(e.subject||`(no message)`,l)}</span> <button type="button" class="history-commit" id="${`history-commit-${e.sha}`}" tabindex="${n===c?0:-1}" aria-labelledby="${`history-subject-${e.sha} history-commit-${e.sha}`}" aria-current="${e.sha===a?`true`:M}" @click="${()=>this.open(e,r)}"><span class="history-author">${Pe(e.authorLogin,e.authorName,e.coauthors)}</span> ${i?A`<time class="history-time" datetime="${i.toISOString()}">${Et(e.committedAt)}</time>`:A`<span class="history-time"></span>`}</button></li>`})}</ol></div>${t.cut?A`<p class="history-note">Only the first 5,000 branches by name are read.</p>`:M} ${Ie(t,n,`Older commits`)}</div>`}};customElements.get(`repository-history`)||customElements.define(`repository-history`,Vt);function Ht(e){let t=e?.startsWith(`claude/`)?`claude`:e?.startsWith(`codex/`)?`codex`:null,n=t===`claude`?/^claude\/(issue|pr)-([1-9]\d{0,9})-/u.exec(e):null;return{agent:t,issue:n?.[1]===`issue`?Number(n[2]):null,pull:n?.[1]===`pr`?Number(n[2]):null}}var Ut=e=>e.head&&e.fork?`${e.fork}:${e.head}`:e.head,Wt=e=>[...e.agents,...e.sessions.length>0||e.claude?[`claude`]:[],...e.tasks.length>0||e.codex?[`codex`]:[]],Gt=new Set([`claude`,`codex`]);function Kt({pulls:e=[],commits:t=[],branches:n=[]}){let r=new Map,i=e=>{let t=e;for(;r.has(t)&&r.get(t)!==t;)t=r.get(t);return r.set(e,t),t},a=(e,t)=>{let[n,a]=[i(e),i(t)];n!==a&&r.set(a,n)},o=new Map,s=(e,t)=>{for(let n of t)o.set(e,new Set([...o.get(e)??[],n]))},c=(e,t)=>{if(i(e),t.agents.length===0)for(let n of t.sessions)a(e,`session:${n}`);if(t.agents.length===0)for(let n of t.tasks)a(e,`task:${n}`);s(e,Wt(t))},l=new Set(n.map(e=>e.name));for(let e of n){let t=`branch:${e.name}`;c(t,e.signals);let{agent:n}=Ht(e.name);n&&s(t,[n])}let u=new Map;for(let t of e){let e=Ut(t);e!==null&&t.number>(u.get(e)??0)&&u.set(e,t.number)}for(let t of e){let e=`pull:${t.number}`;c(e,t.signals);let{agent:n,pull:r}=Ht(t.head);n&&s(e,[n]);let i=Ut(t);t.signals.agents.length>0?i!==null&&u.get(i)===t.number&&a(e,`branch:${i}`):(i&&(n||Wt(t.signals).length>0||l.has(i))&&a(e,`branch:${i}`),r&&a(e,`pull:${r}`))}for(let e of t)c(`commit:${e.oid}`,e.signals);let d=new Map;for(let e of r.keys()){let t=i(e),n=d.get(t)??{agents:new Set,keys:[]};n.keys.push(e);for(let t of o.get(e)??[])n.agents.add(t);d.set(t,n)}return[...d.values()]}var qt=e=>(t,n)=>(e(t)??0)-(e(n)??0);function Jt({agents:e,keys:t},{pulls:n,commits:r,issues:i,branches:a}){if(e.size===0)return null;let o=e=>t.filter(t=>t.startsWith(e)).map(t=>t.slice(e.length)),s=o(`pull:`).flatMap(e=>n.get(Number(e))??[]).toSorted(qt(e=>e.createdAt)),c=o(`commit:`).flatMap(e=>r.get(e)??[]).toSorted(qt(e=>e.at)),l=[...new Set([...o(`branch:`),...s.flatMap(e=>Ut(e)??[])])],u=[...new Set([...s.flatMap(e=>e.closes),...s.flatMap(e=>Ht(e.head).issue??[]),...o(`branch:`).flatMap(e=>Ht(e).issue??[])])].flatMap(e=>i.get(e)??[]).toSorted(qt(e=>e.createdAt)),d=l.flatMap(e=>a.get(e)??[]),f=[...s,...c,...u,...d];if(f.length===0)return null;let[p,m]=[o(`task:`),o(`session:`)],h=f.flatMap(e=>(`createdAt`in e?e.createdAt:e.at)??[]),g=f.flatMap(e=>(`updatedAt`in e?e.updatedAt:e.at)??[]),_=new Set(s.map(e=>e.state)),v=[...s.map(e=>({at:e.createdAt,title:e.title})),...c.map(e=>({at:e.at,title:e.title}))].toSorted(qt(e=>e.at))[0],y=[...s,...c];return{id:m[0]??p[0]??(s[0]?`pull-${s[0].number}`:c[0]?.oid??l[0]??``),agents:[...[...e].filter(e=>!Gt.has(e)),...[`claude`,`codex`].filter(t=>e.has(t))],sessions:m,tasks:p,title:v?.title??u[0]?.title??l[0]??``,authors:[...new Set(f.flatMap(e=>e.author??[]))],startedAt:h.length>0?Math.min(...h):null,updatedAt:g.length>0?Math.max(...g):null,state:_.has(`open`)?`open`:_.has(`merged`)||c.length>0?`merged`:_.has(`closed`)?`closed`:`branch`,pulls:s.map(({number:e,title:t,state:n,draft:r})=>({number:e,title:t,state:n,draft:r})).toReversed(),commits:c.map(({oid:e,title:t})=>({oid:e,title:t})).toReversed(),issues:u.map(({number:e,title:t,state:n})=>({number:e,title:t,state:n})),branches:l,commitCount:s.reduce((e,t)=>e+t.commits,0)+c.length,additions:y.reduce((e,t)=>e+t.additions,0),deletions:y.reduce((e,t)=>e+t.deletions,0)}}function Yt(e,{branchesSince:t=null}={}){let n={pulls:new Map((e.pulls??[]).map(e=>[e.number,e])),commits:new Map((e.commits??[]).map(e=>[e.oid,e])),issues:new Map((e.issues??[]).map(e=>[e.number,e])),branches:new Map((e.branches??[]).map(e=>[e.name,e]))},r=e=>t!==null&&e.pulls.length===0&&e.commits.length===0&&(e.updatedAt??0)<t;return Kt(e).flatMap(e=>Jt(e,n)??[]).filter(e=>!r(e)).toSorted(qt(e=>e.updatedAt)).toReversed()}var Xt=/^[a-z][a-z\d-]{0,31}$/u,Zt=/^(?:app|user)-[1-9]\d{0,11}$/u,Qt=12,$t=T(new Map),{Shown:en,repaint:tn}=D(qe);g(e=>{e===`agents`&&tn()});function nn(e){if(!Array.isArray(e?.pulls)||!Array.isArray(e.commits))throw TypeError(`The server answered with no pull requests or commits.`);let t=e=>typeof e==`string`&&Xt.test(e)&&![`claude`,`codex`,`all`].includes(e),n=(Array.isArray(e.agents)?e.agents:[]).filter(e=>t(e?.id)&&typeof e.name==`string`&&e.name.trim()&&(e.avatar===void 0||typeof e.avatar==`string`&&Zt.test(e.avatar))).map(({id:e,name:t,avatar:n})=>[e,{id:e,name:t.trim().slice(0,64),avatar:n??null}]),r=e=>Array.isArray(e?.signals?.sessions)&&Array.isArray(e.signals.tasks),i=e=>({...e,signals:{...e.signals,agents:Array.isArray(e.signals.agents)?e.signals.agents.filter(t):[]}});return{pulls:e.pulls.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`&&Array.isArray(e.closes)&&r(e)).map(i),commits:e.commits.filter(e=>typeof e?.oid==`string`&&/^[a-f\d]{40}$/u.test(e.oid)&&r(e)).map(i),issues:Array.isArray(e.issues)?e.issues.filter(e=>Number.isSafeInteger(e?.number)):[],branches:Array.isArray(e.branches)?e.branches.filter(e=>typeof e?.name==`string`&&r(e)).map(i):[],agents:[...new Map(n).values()],more:e.more===!0,after:e.more===!0?{pulls:e.after?.pulls??null,commits:e.after?.commits??null}:null}}var rn=e=>Object.assign(e,{sessions:Yt(e,{branchesSince:e.after?.pulls?Math.min(...e.pulls.map(e=>e.updatedAt??1/0)):null})}),an=(e,t,n)=>Ne(e.filter(e=>t===`all`||e.agents.includes(t)),n,e=>[e.title,...e.authors,...e.authors.map(Ce),...e.branches,...e.sessions,...e.tasks,...e.pulls.flatMap(e=>[`#${e.number}`,e.title]),...e.commits.flatMap(e=>[e.oid.slice(0,7),e.title]),...e.issues.flatMap(e=>[`#${e.number}`,e.title])]),on={open:`open`,merged:`merged`,closed:`closed`,branch:`draft`},sn=e=>(e.agents??[]).map(e=>e.id).filter(t=>(e.sessions??[]).some(e=>e.agents.includes(t))),cn=e=>[`claude`,`codex`,...sn(e)],ln=[[`pulls`,ue,`pull request`,`pull requests`],[`branches`,de,`branch`,`branches`],[`commits`,fe,`commit to the default branch without a pull request`,`commits to the default branch without a pull request`]];function un(e){if(!e.after?.pulls)return 100;let t=Math.max(e.pulls.length,...e.pulls.map(e=>e.number),...(e.issues??[]).map(e=>e.number));return t>0?Math.min(99,Math.floor(100*e.pulls.length/t)):0}function dn(e,t,n){let r=2*Math.PI*9;return A`<span class="${`history-summary read-gauge${n?` is-reading`:``}`}" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${e}" aria-label="${t}" data-tooltip="${t}"><svg class="read-gauge-ring" viewBox="0 0 22 22" aria-hidden="true"><circle class="read-gauge-track" cx="11" cy="11" r="9"/>${e>0?j`<circle class="read-gauge-arc" cx="11" cy="11" r="9" transform="rotate(-90 11 11)" stroke-dasharray=${`${r*e/100} ${r}`}/>`:M}</svg> ${e===100?A`<svg class="read-gauge-check" viewBox="0 0 16 16" aria-hidden="true"><path d="m4.25 8.5 2.5 2.5 5-5.5"/></svg>`:A`<span class="read-gauge-value" aria-hidden="true">${e}%</span>`}</span>`}function fn(e,t){let n=e.filter(e=>e.agents.includes(t));return{pulls:n.reduce((e,t)=>e+t.pulls.length,0),branches:new Set(n.flatMap(e=>e.branches)).size,commits:n.reduce((e,t)=>e+t.commits.length,0)}}var pn=class extends en{static properties={_filter:{state:!0}};constructor(){super(),this._filter=``}updated(){this.watchMore(()=>!this._filter.trim()&&!this.list().entry.stalled)}list(){let{repoId:e}=this.repository,t=t=>l(e,t??{}).then(nn);return Oe($t,`${e}`,{first:()=>t(null).then(e=>(he(e.agents),e)),next:t,message:`The agents' work could not be read.`,repaint:tn,ready:rn,merge:(e,t)=>{e.pulls=E(e.pulls,t.pulls,e=>e.number),e.commits=E(e.commits,t.commits,e=>e.oid);let n=e.sessions.length;rn(e),e.stalled=e.sessions.length<=n}})}pick(e){S(this.repository,`agents`,e)}render(){if(!this.repository)return M;let{key:e,entry:t,more:n}=this.list(),r=t.status===`ready`,i=r?t.sessions:[],a=e=>r?A`<span class="n">${(e===`all`?i:i.filter(t=>t.agents.includes(e))).length}${t.more?`+`:``}</span>`:M,o=m(`agents`),s=cn(t).includes(o)?o:`all`,c=an(i,s,this._filter);return A`<div class="history-bar issues-bar">${C(`agents`)}${O(`Agents`,[[`all`,A`All${a(`all`)}`],...cn(t).map(e=>[e,A`${_e(e)}${ge(e)}${a(e)}`])],s,e=>()=>this.pick(e),{kindOf:e=>e===`all`?M:`agent-pick is-${e}`,spaced:!0})}<input class="issues-filter" type="search" placeholder="Filter" aria-label="Filter the sessions read" .value="${this._filter}" @input="${e=>{this._filter=e.target.value}}"> ${r?this.renderStats(t):M} ${r?dn(un(t),`${t.pulls.length} pull request${t.pulls.length===1?``:`s`} read`,t.loadingMore):M}</div>${r?this.renderSessions(t,c,n,s):Re(t,`Reading what the agents did…`,()=>{$t().delete(e),tn()})}`}renderStats(e){let t={pulls:!!e.after?.pulls,branches:!!e.after?.pulls,commits:!!e.after?.commits},n=t=>e.sessions.some(e=>e.agents.includes(t));return A`<span class="agent-totals">${[...sn(e),`claude`,`codex`].filter(n).map(n=>{let r=fn(e.sessions,n);return A`<span class="agent-stats" role="group" aria-label="${ge(n)}"><span class="${`agent-mark is-${n}`}">${_e(n)}</span> ${ln.filter(([e])=>r[e]>0).map(([e,n,i,a])=>{let o=`${w(r[e])}${t[e]?`+`:``}`,s=`${o} ${r[e]===1&&!t[e]?i:a}`;return A`<span class="agent-stat" role="img" aria-label="${s}" data-tooltip="${s}">${n}${o}</span>`})}</span>`})}</span>`}renderSessions(e,t,n,r){let i=r===`all`?`agents' sessions`:`${ge(r)} sessions`;return A`<div class="issues-scroll">${t.length>0?A`<ol class="issues-grid" aria-label="Sessions">${t.map(e=>this.renderSession(e))}</ol>`:A`<p class="history-note">${e.sessions.length>0&&this._filter.trim()?`None of the ${i} read match.`:`No ${i} among those read.`}</p>`} ${Ie(e,()=>{e.stalled=!1,n()},`More`,`history-more issues-more`)}</div>`}openSession(e,t){e.target?.closest?.(`.agent-chip.is-commit`)||this.openPopup(e,{session:t})}openItem(e,t,n){this.openPopup(e,{number:t,preview:n})&&e.stopPropagation()}renderSession(e){let t=this.repo??this.repository.repo,n=ve(e,t),r=e.updatedAt==null?null:new Date(e.updatedAt),i=e.authors.find(e=>!De(e)),a=e.pulls.length+e.commits.length,o=r?A`<time datetime="${r.toISOString()}">${Et(e.updatedAt)}</time>`:M,s=e.additions||e.deletions?A`<span class="issue-diff"><span class="is-added">+${w(e.additions)}</span> <span class="is-deleted">−${w(e.deletions)}</span></span>`:M,c=a===1,l=[i?A`<span class="issue-author">${we(i)}</span>`:M,c?M:o,a===0?A`<span>no pull request</span>`:M,c?M:s].filter(e=>e!==M),u=[...e.pulls.map(e=>[`is-${e.draft&&e.state===`open`?`draft`:e.state}`,`pull/${e.number}`,`#${e.number}`,{kind:`pulls`,...e}]),...e.commits.map(e=>[`is-commit`,`commit/${e.oid}`,A`<code>${e.oid.slice(0,7)}</code>`,null]),...e.issues.map(e=>[`is-issue is-${e.state===`open`?`open`:`merged`}`,`issues/${e.number}`,A`<span class="sr-only">Issue </span>#${e.number}`,{kind:`issues`,reason:null,...e}])];return A`<li class="${`issue-tile agent-tile is-${on[e.state]}`}"><div class="issue-body" @click="${t=>this.openSession(t,e)}"><span class="issue-rail">${e.agents.map(e=>A`<span class="${`agent-mark is-${e}`}" role="img" aria-label="${ge(e)}">${_e(e)}</span>`)}</span> <span class="issue-lines">${n?A`<a class="issue-name" href="${n}" target="_blank" rel="noopener noreferrer">${e.title||`(no title)`}</a>`:A`<button type="button" class="issue-name">${e.title||`(no title)`}</button>`} ${l.length>0?A`<span class="issue-meta">${l}</span>`:M} ${u.length>0?A`<span class="agent-task-row"><span class="agent-chips">${u.slice(0,Qt).map(([e,n,r,i],a)=>A`<a class="${`agent-chip ${e}`}" href="${t?`https://github.com/${t}/${n}`:M}" target="_blank" rel="noopener noreferrer" @click="${i?e=>this.openItem(e,i.number,i):M}" data-rest="${a<u.length-1?u.length-1-a:M}">${r}</a>`)}</span>${c&&(o!==M||s!==M)?A`<span class="issue-meta">${o}${s}</span>`:M}</span>`:M} ${e.branches[0]?A`<span class="issue-branch"><code>${e.branches[0]}</code>${e.branches.length>1?A`<span>+${e.branches.length-1}</span>`:M}</span>`:M}</span></div></li>`}};customElements.get(`repository-agents`)||customElements.define(`repository-agents`,pn);var mn=1e3,hn=5,gn=60,_n=5e3,vn=12,L=864e5,R=7*L,z=e=>Math.floor(e/L)*L,yn=()=>Array.from({length:7},()=>0),bn=8,xn=3,Sn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Cn=[1,2,3,4,5,6,0],wn=6,Tn=new Map,En=new Map,Dn=new Map,B=T(new Map,Tn,En,Dn),{Shown:On,shown:kn,repaint:V}=D(qe),An={pulls:`merged`,issues:`closed`},jn={pulls:[`Pull requests`,[[`merged`,`Merged`,`is:pr is:merged merged:`],[`opened`,`Opened`,`is:pr created:`]]],issues:[`Issues`,[[`closed`,`Closed`,`is:issue is:closed closed:`],[`created`,`Opened`,`is:issue created:`]]]},Mn=[`merged`,`opened`,`closed`,`created`],Nn=ie(j`<circle cx="8" cy="8" r="2.75"/><path d="M8 1v4.25M8 10.75V15"/>`),Pn={agent:`Commit with agents`,without:`Commit without agents`,release:`Release`},Fn=10,In=10;g(e=>{if(e===`pulse`)for(let e of kn)e.periodShown()});var H=e=>Number.isSafeInteger(e)&&e>=0?e:0,U=e=>Number.isSafeInteger(e)?e:null,W=e=>typeof e==`string`?e:null,Ln=e=>Object.fromEntries(Mn.map(t=>[t,{count:H(e?.[t]?.count),previous:U(e?.[t]?.previous),items:Array.isArray(e?.[t]?.items)?e[t].items.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`):[]}]));function Rn(e){if(!Number.isSafeInteger(e?.since)||!v.some(([t])=>t===e.weeks))throw Error(`The server answered with no period.`);let t=e=>Array.isArray(e)&&e.length===7&&e.every(Array.isArray)?e.map(([e,t])=>[H(e),H(t)]):null,n=e=>Array.isArray(e)&&e.length===7?e.map(H):null,r=Array.isArray(e.stats?.weeks)?e.stats.weeks.filter(e=>Number.isSafeInteger(e?.week)&&Array.isArray(e.days)).map(e=>({...e,dayLines:t(e.dayLines),agentDays:n(e.agentDays),releaseDays:n(e.releaseDays),directDays:n(e.directDays)})):[],i=e=>r.length>0&&r.every(t=>t[e]!==null),a=e.stats&&Array.isArray(e.stats.weeks)&&Array.isArray(e.stats.contributors)&&Array.isArray(e.stats.punch)?{weeks:r,contributors:e.stats.contributors.filter(e=>(typeof e?.login==`string`||typeof e?.name==`string`)&&Array.isArray(e.weeks)).map(e=>({login:W(e.login),id:U(e.id),name:W(e.name),weeks:e.weeks,days:Array.isArray(e.days)?e.days:null})),punch:Cn.map(t=>Array.from({length:24},(n,r)=>H(e.stats.punch[t]?.[r]))),periodPunch:e.stats.periodPunch===!0,from:U(e.stats.from),lines:typeof e.stats.lines==`boolean`?e.stats.lines:null,agents:i(`agentDays`),releases:i(`releaseDays`),direct:i(`directDays`)&&Array.isArray(e.stats.directCommits),directCommits:Array.isArray(e.stats.directCommits)?e.stats.directCommits.filter(e=>typeof e?.sha==`string`&&Number.isSafeInteger(e.at)).map(e=>({sha:e.sha,at:e.at,subject:W(e.subject)??``,login:W(e.login),id:U(e.id),name:W(e.name),kind:typeof e.kind==`string`&&Object.hasOwn(Pn,e.kind)?e.kind:null})):[]}:null;return{weeks:e.weeks,since:e.since,...Ln(e),stats:a,reading:U(e.reading),pulls:U(e.pulls),pending:e.pending===!0,behind:e.behind===!0}}function zn(e,t){En.set(e,t),t.answer.stats&&Dn.set(e,t.answer)}var G=e=>e.reading??e.pulls,Bn=e=>G(e)===null?e.pending?[_n,vn]:null:[mn,hn];function Vn(e,t){let n=`${e}\0${t}`;return Ee(B(),n,()=>p(e,t).then(Rn),{ready:e=>({answer:e,tries:0,asking:!1}),settled:r=>{zn(e,r),Bn(r.answer)&&Hn(n,r,e,t,Bn(r.answer)[0])},message:`The repository’s pulse could not be read.`,repaint:V})}function Hn(e,t,n,r,i){t.asking=!0,setTimeout(()=>{B().get(e)===t&&p(n,r).then(Rn).then(i=>{if(B().get(e)!==t)return null;t.behind=i.behind?(t.behind??0)+1:0;let a=G(i)!==null&&G(t.answer)!==null&&G(i)>G(t.answer)||t.behind>0&&t.behind<=gn;t.answer=i,t.until=Date.now()+be,t.tries=a?0:t.tries+1;let o=Bn(i);return o&&t.tries<o[1]?Hn(e,t,n,r,o[0]):t.asking=!1,null},()=>(t.asking=!1,null)).finally(V)},i)}function Un(e,t,n){B();let r=[e,t,n.from,n.to??``,n.authors.join(`,`)].join(`\0`);return Ee(Tn,r,()=>h(e,t,n),{ready:e=>({answer:Ln(e)}),failed:e=>({status:`error`,until:Date.now()+xe,error:e?.message||`These couldn’t be read.`}),repaint:V})}var Wn=(e,t)=>e[t]===!0&&e.weeks.some(e=>e[t===`agents`?`agentDays`:`releaseDays`].some(e=>e>0)),Gn=(e,t,n,r=`days`)=>e.reduce((e,i)=>e+i[r].reduce((e,r,a)=>{let o=i.week+a*L;return o>=t&&o<=n?e+H(r):e},0),0);function Kn(e,t){let n=z(t);return n-new Date(n).getUTCDay()*L-(e-1)*R}var qn=(e,t)=>e.from===null||e.from===void 0||e.from<t;function Jn(e,t,n,r){return{weeks:n,since:e?.since??Kn(n,r),...Object.fromEntries(Mn.map(t=>[t,e?.[t]??null])),stats:{...t.stats,otherPunch:t.weeks!==n},reading:e?.reading??null,pulls:e?.pulls??null,pending:e?.pending??!1}}function Yn(e,t=Date.now()){let{stats:n,since:r}=e;if(!n)return{commits:null,previous:null,agents:null,previousAgents:null,releases:null,previousReleases:null,additions:null,deletions:null,authors:null};let i=z(t),a=e.weeks*R,o=n.weeks.filter(e=>e.week>=r),s=n.weeks.length>0&&n.weeks[0].week<=r-a&&qn(n,r-a),c=(e,t=0)=>Gn(n.weeks,r-t,i-t,e),l=e=>n.lines===!0?o.reduce((t,n)=>t+H(n[e]),0):null;return{commits:c(`days`),previous:s?c(`days`,a):null,agents:n.agents?c(`agentDays`):null,previousAgents:n.agents&&s?c(`agentDays`,a):null,releases:n.releases?c(`releaseDays`):null,previousReleases:n.releases&&s?c(`releaseDays`,a):null,additions:l(`additions`),deletions:l(`deletions`),authors:Zn(n.contributors,r).length}}function Xn({id:e=null,login:t,name:n}){let r=De(t,n);if(r)return`agent:${r}`;let i=Se(t)?.id;return i==null?e===null?t?`@${t.toLowerCase()}`:`=${n}`:`#${e}`:`user:${i}`}function Zn(e,t,n=1/0){let r=new Map;for(let i of e){let{login:e,name:a}=i,o=Xn(i);r.set(o,(i.days??i.weeks).reduce((e,[r,i,a,o])=>r>=t&&r<n?{...e,commits:e.commits+H(i),additions:e.additions+H(a),deletions:e.deletions+H(o)}:e,r.get(o)??{key:o,login:e,name:a,commits:0,additions:0,deletions:0}))}return[...r.values()].filter(e=>e.commits>0).toSorted((e,t)=>t.commits-e.commits||(e.login??e.name).localeCompare(t.login??t.name))}function Qn(e,t){let n=e.contributors.filter(e=>Xn(e)===t),r=n.length>0&&n.every(e=>e.days),i=e.weeks.map(({week:e})=>({week:e,days:yn(),dayLines:Array.from({length:7},()=>[0,0]),agentDays:yn(),releaseDays:yn(),directDays:yn(),commits:0,additions:0,deletions:0}));for(let[e,t,a,o,s,c,l]of n.flatMap(e=>r?e.days:e.weeks)){let n=i[Math.floor((e-(i[0]?.week??0))/R)];if(!n||(n.commits+=H(t),n.additions+=H(a),n.deletions+=H(o),!r))continue;let u=Math.floor((e-n.week)/L);n.dayLines[u]=[n.dayLines[u][0]+H(a),n.dayLines[u][1]+H(o)];for(let[e,r]of[[`days`,t],[`agentDays`,s],[`releaseDays`,c],[`directDays`,l]])n[e][u]+=H(r)}let a=(t,i)=>e[t]===!0&&r&&n.every(e=>e.days.every(e=>e.length>i));return{...e,weeks:i,agents:a(`agents`,4),releases:a(`releases`,5),direct:a(`direct`,6),byDays:r}}function $n(e,t,n,r,i){let a=r===null?e:Qn(e,r);if(!e?.direct||!a.direct)return null;let o=Math.min(n-L,z(i)),s=e.directCommits.filter(e=>e.at>=t&&e.at<o+L&&(r===null||Xn(e)===r));return{count:Gn(a.weeks,t,o,`directDays`),items:s}}function er(e,t=Date.now()){let{stats:n,since:r,weeks:i}=e,a=n.lines===!0,o=e=>e.reduce((e,t)=>e+t,0);if(i>4)return n.weeks.filter(e=>e.week>=r).map(e=>({from:e.week,to:e.week+R,day:!1,commits:H(e.commits),agents:n.agents?o(e.agentDays):null,releases:n.releases?o(e.releaseDays):null,additions:a?H(e.additions):null,deletions:a?H(e.deletions):null,future:!1}));let s=z(t);return Array.from({length:i*7},(e,t)=>{let i=r+t*L,o=n.weeks.find(e=>i>=e.week&&i<e.week+R),c=o?Math.floor((i-o.week)/L):0,l=a?o?.dayLines?.[c]??null:null;return{from:i,to:i+L,day:!0,commits:H(o?.days[c]),agents:n.agents?H(o?.agentDays[c]):null,releases:n.releases?H(o?.releaseDays[c]):null,additions:l?.[0]??null,deletions:l?.[1]??null,future:i>s}})}function tr(e,t){if(!e.day||t.every(e=>e.days))return[e.from,e.to,!1];let n=e.from-new Date(e.from).getUTCDay()*L;return[n,n+R,!0]}function nr(e){if(!(e>0))return{top:1,ticks:[0,1]};let t=e/3,n=10**Math.floor(Math.log10(t)),r=Math.max(1,[1,2,5,10].map(e=>e*n).find(e=>e>=t)),i=Math.ceil(e/r)*r;return{top:i,ticks:Array.from({length:i/r+1},(e,t)=>t*r)}}var rr=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),K=e=>rr.format(e),q=(e,t,n=`${t}s`)=>`${w(e)} ${e===1?t:n}`,J=(e,t=!1,n=!1)=>new Date(e).toLocaleDateString(`en-US`,{...n?{weekday:`short`}:{},month:`short`,day:`numeric`,...t?{year:`numeric`}:{},timeZone:`UTC`}),ir=e=>new Date(e).toISOString().slice(0,10),ar=(e,t)=>new Date(e).getUTCFullYear()!==new Date(t).getUTCFullYear(),or=(e,t)=>{let n=z(t),r=ar(e,n);return e>=n?J(n,r):`${J(e,r)} \u2013 ${J(n,r)}`},sr=(e,t)=>`${e.day?``:`Week of `}${J(e.from,ar(e.from,t),e.day)}`,cr=(e,t,n={})=>`${sr(e,t)}: ${q(e.commits,`commit`)}${n.agents?`, ${w(e.agents)} with agents`:``}${n.releases?`, ${q(e.releases,`release`)}`:``}${e.additions===null?``:`, +${w(e.additions)} \u2212${w(e.deletions)} lines`}`;function lr(e,t,n){let r=new Date(e[t].from);if(n===1)return`${r.toLocaleDateString(`en-US`,{weekday:`short`,timeZone:`UTC`})} ${r.getUTCDate()}`;if(n===4)return r.getUTCDay()===0?J(e[t].from):``;if(n===13)return t%2==0?J(e[t].from):``;let i=r.getUTCMonth();return(t===0?e.length>3&&new Date(e[3].from).getUTCMonth()===i:new Date(e[t-1].from).getUTCMonth()!==i)?i===0?String(r.getUTCFullYear()):r.toLocaleDateString(`en-US`,{month:`short`,timeZone:`UTC`}):``}var ur=(e,t,n)=>t===null||e===null?null:e===t?`Same as ${n}`:`${e>t?`↑`:`↓`}${t>0?` ${Math.max(1,Math.round(Math.abs(e-t)/t*100))}%`:``} from ${w(t)} ${n}`,dr=(e,t)=>e===0?0:e===t?100:Math.min(99,Math.max(1,Math.round(e/t*100)));function fr(e,t=!1){let[n,r]=t?[`latest `,`: the year shown is as it was before.`]:[``,`.`],i=e.weeks===52?` of the last year`:``;return e.reading===null?e.pulls===null?[`GitHub is still counting this repository\u2019s ${n}commits\u2026`,`GitHub hasn\u2019t counted this repository\u2019s ${n}commits yet.`,`Ask again`]:[`Reading this repository\u2019s pull requests\u2026 ${w(e.pulls)} so far`,`${w(e.pulls)} of this repository\u2019s pull requests read so far${r}`,`Read on`]:[`Reading this repository\u2019s ${n}commits\u2026 ${w(e.reading)}${i} so far`,`${w(e.reading)} of this repository\u2019s commits${i} read so far${r}`,`Read on`]}var pr=(e,t,n)=>e===t?`Same as ${n}`:`${e>t?`↑`:`↓`} from ${t}% ${n}`,mr=A`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 13 13 3M5 3h8v8"/></svg>`,hr=e=>e.endsWith(`[bot]`)?`https://github.com/apps/${encodeURIComponent(e.slice(0,-5))}`:`https://github.com/${encodeURIComponent(e)}`,gr=e=>e.login?ke(e.login,e.name,e.login):ke(null,e.name);function _r(e){let t=e?.who?je(e.who.login,e.who.name):null,n=t&&`by ${t}`;return{who:t,to:e?[n,e.when].filter(Boolean).join(` `):``,scope:e?[n,e.when??`in the period`].filter(Boolean).join(` `):`in the period`}}var vr=(e,t,n)=>e>0?A`<button type="button" class="history-link pulse-more" @click="${n}">${t?`Fewer`:`and ${q(e,`more`,`more`)}`}</button>`:M,yr=class extends On{static properties={_column:{state:!0},_typed:{state:!0},_picked:{state:!0},_everyone:{state:!0},_person:{state:!0},_allDirect:{state:!0}};constructor(){super(),this._column=null,this._typed=!1,this._picked=null,this._everyone=!1,this._person=null,this._allDirect=!1}willUpdate(e){!e.has(`repository`)||e.get(`repository`)?.repoId===this.repository?.repoId||Object.assign(this,{_column:null,_picked:null,_everyone:!1,_person:null,_allDirect:!1})}pick(e){S(this.repository,`pulse`,v.find(([t])=>t===e)[1].toLowerCase()),this.periodShown()}periodShown(){Object.assign(this,{_column:null,_picked:null,_everyone:!1,_allDirect:!1}),this.requestUpdate()}showList(e,t){An[e]=t,V()}askAgain(){let{repoId:e}=this.repository,t=b(),n=`${e}\0${t}`,r=B().get(n);r?.status!==`ready`||r.asking||(r.tries=0,Hn(n,r,e,t,0),V())}render(){if(!this.repository)return M;let{repoId:e}=this.repository,t=b(),n=Vn(e,t);n.status===`ready`&&zn(e,n);let r=Date.now(),i=n.status===`ready`?n.answer:null,a=Dn.get(e),o=i?.stats&&qn(i.stats,i.since)?i:a&&n.status!==`error`&&qn(a.stats,Kn(t,r))?Jn(i,a,t,r):i&&{...i,stats:null},s=!o&&n.status===`loading`?En.get(e)??null:null,c=o?{answer:o,asking:n.asking===!0}:s,l=c?.answer.stats&&(G(c.answer)!==null||c.answer.pending);return A`<div class="history-bar">${C(`pulse`)}${O(`Period`,v,t,e=>()=>this.pick(e))}${c?A`<span class="pulse-range">${or(c.answer.since,r)}</span>`:M} ${l?A`<span class="pulse-updating" role="status">${this.renderWaiting(c,fr(c.answer,!0))}</span>`:M}</div>${c?A`<div class="${`pulse-scroll${s?` is-reading`:``}`}" aria-busy="${String(n.status!==`ready`)}">${this.renderPulse(c,r)}</div>`:Re(n,`Reading the repository’s pulse…`,()=>{B().delete(`${e}\0${t}`),V()})}`}renderPulse(e,t){let{answer:n}=e,r=v.find(([e])=>e===n.weeks)[2],i=Yn(n,t),a=this.narrowing(n,t),o=n.stats?null:n.reading===null?n.pulls===null?`Counting…`:`Reading pull requests…`:`Reading commits…`,s=o??(n.stats?.lines===null?`Counting…`:null),c=(e,t,i)=>n[t]?this.renderTile(e,w(n[t].count),ur(n[t].count,n[t].previous,r),`${w(n[i].count)} opened`):this.renderTile(e,`–`,`Reading…`,``),l=this.renderLists(n,a,t);return A`<section class="pulse-tiles" aria-label="Figures">${this.renderTile(`Commits`,i.commits===null?`–`:w(i.commits),o??ur(i.commits,i.previous,r),`to the default branch`)} ${this.renderTile(`Contributors`,i.authors===null?`–`:w(i.authors),o,`who made them`)} ${c(`Pull requests merged`,`merged`,`opened`)} ${c(`Issues closed`,`closed`,`created`)} ${n.stats?.lines===!1?M:this.renderTile(`Lines`,i.additions===null?`–`:A`<span class="is-added">+${w(i.additions)}</span> <span class="is-removed">−${w(i.deletions)}</span>`,s,`added and removed`,i.additions===null?M:this.renderRatio(i.additions,i.deletions))} ${i.agents===null||!Wn(n.stats,`agents`)?M:this.renderAgentsTile(i,r)}</section><div class="${`pulse-grid${l.length>2?` is-lists`:``}`}">${n.stats?A`${this.renderActivity(e,t)}${this.renderContributors(n,t)}`:A`<div class="pulse-pending pulse-wide" role="status">${this.renderWaiting(e,fr(n))}</div>`} ${l} ${n.stats?this.renderPunch(n.stats):M}</div>`}renderAgentsTile(e,t){let n=e.commits-(e.releases??0),r=e.previous===null?null:e.previous-(e.previousReleases??0),i=e.releases>0?`, ${q(e.releases,`release`)} apart`:``;return this.renderTile(A`<span data-tooltip="${`Commits an agent made or co-authored, or merged from an agent’s branch or a pull request labelled for one; releases, tagged commits changing only package.json, lockfiles and changelogs, counted in neither`}">With agents</span>`,n===0?`–`:`${dr(e.agents,n)}%`,e.previousAgents===null||n===0||!r?null:pr(dr(e.agents,n),dr(e.previousAgents,r),t),n===0?`no commits${i}`:`${w(e.agents)} of ${q(n,`commit`)}${i}`)}renderWaiting(e,[t,n,r]){return e.asking?t:A`${n} <button type="button" class="history-link" @click="${()=>this.askAgain()}">${r}</button>`}renderTile(e,t,n,r,i=M){return A`<div class="pulse-tile"><span class="pulse-tile-label">${e}</span> <span class="pulse-tile-value">${t}</span> ${i} <span class="pulse-tile-note">${n??r}</span> ${n?A`<span class="pulse-tile-note">${r}</span>`:M}</div>`}renderRatio(e,t){return e+t===0?M:A`<span class="pulse-ratio" aria-hidden="true">${[[`is-added`,e],[`is-removed`,t]].map(([n,r])=>r>0?A`<span class="${n}" style="${k({"--share":`${r/(e+t)}`})}"></span>`:M)}</span>`}renderActivity(e,t){let{answer:n}=e,r=this._person===null?null:n.stats.contributors.find(e=>Xn(e)===this._person)??null,i=r?Qn(n.stats,this._person):n.stats,a=er({...n,stats:i},t),o=a[0]?.day?`day`:`week`,s=r?je(r.login,r.name):null,c=r?A`<span>a ${o} by</span><button type="button" class="pulse-picked is-person" aria-label="${`${s}\u2019s: show everyone\u2019s`}" @click="${()=>this.showPerson(null)}">${gr(r)}<span aria-hidden="true">×</span></button>`:A`<span>a ${o}</span>`,l=r&&!i.byDays&&o===`day`?`GitHub counts each contributor’s commits a week, not a day, in a repository this large: the quarter and the year show theirs.`:a.some(e=>e.commits>0)?null:`No commits${r?` by ${s}`:``} in the period.`;if(l)return A`<figure class="pulse-panel pulse-activity"><figcaption class="pulse-head"><h3>Commits</h3>${c}</figcaption><p class="pulse-note">${l}</p></figure>`;let u=nr(Math.max(...a.map(e=>e.commits))),d=i.lines===!0&&a.every(e=>e.additions!==null)?nr(Math.max(...a.flatMap(e=>[e.additions,e.deletions]))):null,f={agents:Wn(n.stats,`agents`)&&a.some(e=>e.agents!==null),releases:Wn(n.stats,`releases`)&&a.some(e=>e.releases!==null)},p=f.agents||f.releases,m=n.weeks===1,h=z(t),g=a[this._column]&&!a[this._column].future?this._column:null,_=a.findIndex(e=>e.from===this._picked),v=(e,r,i,o)=>A`<span class="${`pulse-column${r===g?` is-at`:``}${r===_?` is-picked`:``}${e.future?` is-future`:``}${e.day&&n.weeks===4&&[0,6].includes(new Date(e.from).getUTCDay())?` is-weekend`:``}`}" role="${i?`img`:M}" aria-label="${i?cr(e,t,f):M}" aria-hidden="${i?M:`true`}" @pointerenter="${()=>this.point(e.future?null:r)}" @click="${()=>this.pickColumn(a,r)}">${o}</span>`,y=(e,t)=>m&&!e.future?A`<span class="pulse-figure">${t}</span>`:M,b=(e,t,n=M)=>A`<span class="${`pulse-bar${e}`}" style="${k({"--value":`${t}`})}">${n}</span>`,x=e=>{let t=f.releases?e.releases:0,n=e.commits-t;return[...f.agents?[[``,e.agents],[` is-without`,n-e.agents]]:[[``,n]],[` is-release`,t]].map(([e,t])=>t>0?A`<span class="${`pulse-part${e}`}" style="${k({"--part":`${t}`})}"></span>`:M)};return A`<figure class="${`pulse-panel pulse-activity${m?` is-written`:``}`}" tabindex="0" aria-label="${`Commits${d?` and lines`:``} a ${o}${r?` by ${s}`:``}: the arrow keys read each ${o}, Enter picks it for its contributors`}" @keydown="${e=>this.readColumns(e,a)}" @focus="${e=>this.focusColumns(e,a)}" @blur="${()=>this.point(null)}"><figcaption class="pulse-head"><h3>Commits</h3>${c}${p?A`<span class="pulse-legend">${f.agents?A`<span class="pulse-key"></span>With agents<span class="pulse-key is-without"></span>Without`:M}${f.releases?A`<span class="pulse-key is-release"></span>Releases`:M}</span>`:M}</figcaption><div class="pulse-plots" @pointerleave="${()=>this.point(null)}"><div class="pulse-plot">${this.renderTicks(u.ticks.map(e=>[e/u.top,K(e),e===0]))}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!0,A`${y(e,w(e.commits))}${p?b(` is-split`,e.commits/u.top,x(e)):b(``,e.commits/u.top)}`))}</div></div>${d?A`<div class="pulse-head is-sub"><h3>Lines</h3><span>added and removed a ${o}</span> <span class="pulse-legend"><span class="pulse-key is-added"></span>Added<span class="pulse-key is-removed"></span>Removed</span></div><div class="pulse-plot is-diverging">${this.renderTicks([[1,`+${K(d.top)}`],[.5,`0`,!0],[0,`\u2212${K(d.top)}`]])}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!1,A`<span class="pulse-half">${y(e,`+${K(e.additions)}`)}${b(` is-added`,e.additions/d.top)}</span> <span class="pulse-half is-below">${b(` is-removed`,e.deletions/d.top)}${y(e,`\u2212${K(e.deletions)}`)}</span>`))}</div></div>`:i.lines===!1?A`<p class="pulse-note">GitHub doesn’t count lines added and removed in a repository of 10,000 commits or more.</p>`:i.lines===!0?A`<p class="pulse-note">GitHub counts this repository’s lines a week, not a day: the quarter and the year show them.</p>`:A`<p class="pulse-note" role="status">${this.renderWaiting(e,[`GitHub is still counting lines added and removed…`,`GitHub hasn’t counted lines added and removed yet.`,`Ask again`])}</p>`}<div class="${`pulse-axis${m?` is-each`:``}`}" aria-hidden="true">${a.map((e,t)=>A`<span class="${e.future?`is-future`:e.day&&e.from===h?`is-today`:``}">${lr(a,t,n.weeks)}</span>`)}</div>${g===null?M:this.renderTip(n,a,g,t,f,!r)}</div><span class="sr-only" aria-live="polite">${this._typed&&g!==null?cr(a[g],t,f):``}</span></figure>`}renderTip(e,t,n,r,i,a){let o=t[n],s=z(r),[c,l,u]=tr(o,e.stats.contributors),d=a?Zn(e.stats.contributors,c,l).slice(0,xn):[],f=(n+.5)/t.length;return A`<div class="${`pulse-tip${f>.6?` is-left`:``}`}" style="${k({"--x":`${f}`})}" aria-hidden="true"><span class="pulse-tip-when">${sr(o,r)}${o.day?o.from===s?A`<span>today</span>`:M:r<o.to?A`<span>so far</span>`:M}</span> <span class="pulse-tip-row"><span class="${`pulse-tip-key${i.agents||i.releases?` is-none`:``}`}"></span><strong>${w(o.commits)}</strong> ${o.commits===1?`commit`:`commits`}</span> ${i.agents?A`<span class="pulse-tip-row"><span class="pulse-tip-key"></span><strong>${w(o.agents)}</strong> with agents</span>`:M} ${i.releases?A`<span class="pulse-tip-row"><span class="pulse-tip-key is-release"></span><strong>${w(o.releases)}</strong> ${o.releases===1?`release`:`releases`}</span>`:M} ${o.additions===null?M:A`<span class="pulse-tip-row"><span class="pulse-tip-key is-added"></span><strong>+${w(o.additions)}</strong> added</span> <span class="pulse-tip-row"><span class="pulse-tip-key is-removed"></span><strong>−${w(o.deletions)}</strong> removed</span>`} ${d.length>0?A`<span class="pulse-tip-people">${u?A`<span class="pulse-tip-note">Its week’s</span>`:M} ${d.map(e=>A`<span class="pulse-tip-person">${gr(e)}<strong>${w(e.commits)}</strong></span>`)}</span>`:M}</div>`}point(e){this._column=e,this._typed=!1}showPerson(e){this._person=e===this._person?null:e,this._column=null,this._allDirect=!1}pickColumn(e,t){let n=e[t];!n||n.future||(this._picked=this._picked===n.from?null:n.from,this._everyone=!1,this._allDirect=!1)}focusColumns(e,t){if(!e.target.matches?.(`:focus-visible`))return;let n=t.findIndex(e=>e.from===this._picked);this._column=n>=0?n:t.findLastIndex(e=>!e.future),this._typed=!0}readColumns(e,t){let n=t.flatMap((e,t)=>e.future?[]:[t]);if(n.length===0)return;let r=t.findIndex(e=>e.from===this._picked),i=n.indexOf(n.includes(this._column)?this._column:n.includes(r)?r:n.at(-1)),a={ArrowLeft:i-1,ArrowRight:i+1,Home:0,End:n.length-1}[e.key];if(a!==void 0)this._column=n[Math.min(Math.max(a,0),n.length-1)];else if(e.key===`Enter`||e.key===` `)this._column=n[i],this.pickColumn(t,n[i]);else if(e.key===`Escape`&&(this._picked!==null||this._column!==null))this._picked=null,this._column=null;else return;this._typed=!0,e.preventDefault()}renderTicks(e){return A`<div class="pulse-ticks" aria-hidden="true">${e.map(([e,t,n])=>A`<span class="${n?`is-zero`:M}" style="${k({"--at":`${e}`})}"><span>${t}</span></span>`)}</div>`}renderContributors(e,t){let{contributors:n}=e.stats,r=er(e,t).find(e=>e.from===this._picked)??null,[i,a,o]=r?tr(r,n):[e.since,1/0,!1],s=Zn(n,i,a),c=s[0]?.commits??1,l=e.stats.lines===!0,u=r?o?`Week of ${J(i,ar(i,t))}`:sr(r,t):null;return A`<figure class="pulse-panel pulse-people"><figcaption class="pulse-head"><h3>Contributors</h3>${u?A`<button type="button" class="pulse-picked" aria-label="${`${u}: show the whole period\u2019s`}" @click="${()=>{this._picked=null,this._everyone=!1}}">${u}<span aria-hidden="true">×</span></button>`:A`<span>by their commits in the period</span>`}</figcaption>${s.length===0?A`<p class="pulse-note">No commits ${r?o||!r.day?`that week`:`that day`:`in the period`}.</p>`:A`<ol class="${`pulse-ranks${this._person===null?``:` is-picking`}`}">${(this._everyone?s:s.slice(0,bn)).map(e=>A`<li class="${e.key===this._person?`is-person`:M}"><span class="pulse-rank-who"><button type="button" class="pulse-rank-name" aria-pressed="${String(e.key===this._person)}" @click="${()=>this.showPerson(e.key)}">${gr(e)}</button> ${e.login?A`<a class="pulse-rank-profile" href="${hr(e.login)}" target="_blank" rel="noopener noreferrer" aria-label="${`${je(e.login,e.name)} on GitHub`}">${mr}</a>`:M}</span> <span class="pulse-rank-bar"><span style="${k({"--value":`${e.commits/c}`})}"></span><span class="pulse-rank-value">${w(e.commits)}</span></span> ${l?A`<span class="pulse-rank-lines"><span class="is-added">+${K(e.additions)}</span> <span class="is-removed">−${K(e.deletions)}</span></span>`:M}</li>`)}</ol>${vr(s.length-bn,this._everyone,()=>{this._everyone=!this._everyone})}`}</figure>`}renderPunch(e){let{punch:t}=e,n=Math.max(1,...t.flat());return A`<figure class="${`pulse-panel${e.otherPunch?` is-reading`:``}`}" aria-busy="${String(e.otherPunch===!0)}"><figcaption class="pulse-head"><h3>When commits are made</h3><span>by day and hour, in each author’s own time zone${e.periodPunch?``:`, not only the period’s`}</span></figcaption><div class="pulse-punch">${t.map((e,t)=>A`<span class="pulse-punch-day">${Sn[Cn[t]].slice(0,3)}</span>${e.map((e,r)=>{let i=`${Sn[Cn[t]]}s, ${String(r).padStart(2,`0`)}:00\u2013${String(r+1).padStart(2,`0`)}:00: ${q(e,`commit`)}`;return A`<span class="${`pulse-cell is-${e===0?0:Math.ceil(e/n*wn)}`}" role="img" aria-label="${i}" data-tooltip="${i}"></span>`})}`)} <span></span>${Array.from({length:24},(e,t)=>A`<span class="pulse-punch-hour">${t%6==0?`${t}h`:``}</span>`)}</div><div class="pulse-scale" aria-hidden="true">Fewer${Array.from({length:wn},(e,t)=>A`<span class="${`pulse-cell is-${t+1}`}"></span>`)}More</div></figure>`}renderLists(e,t,n){let r=e.stats?$n(e.stats,e.since,1/0,null,n):null,i=r!==null&&r.count>0,a=e.closed&&e.created?e.closed.count+e.created.count:null,o=i&&t?$n(e.stats,t.since??e.since,t.until??1/0,t.person??null,n)??{count:0,items:[]}:r;return[this.renderList(e,`pulls`,t),...i?[this.renderDirect(o,t)]:[],...i&&a===0?[]:[this.renderList(e,`issues`,t)]]}renderDirect(e,t){let n=this.repo??this.repository.repo,{to:r,scope:i}=_r(t),a=this._allDirect?e.items:e.items.slice(0,Fn),o=Math.max(0,e.count-e.items.length);return A`<section class="pulse-panel pulse-list" aria-label="Direct commits"><div class="pulse-head"><h3 data-tooltip="Commits pushed to the default branch, not merged from a pull request">Direct commits</h3>${t?A`<span class="pulse-narrowed">${r}</span>`:M}<span class="pulse-count">${w(e.count)}</span></div>${e.count===0?A`<p class="pulse-note">None ${i}.</p>`:A`<ol>${a.map(e=>A`<li><a class="${`pulse-item is-commit${e.kind?` is-${e.kind}`:``}`}" href="${n?`https://github.com/${n}/commit/${e.sha}`:M}" target="_blank" rel="noopener noreferrer"><span class="issue-state" role="img" aria-label="${e.kind?Pn[e.kind]:`Commit`}">${Nn}</span> <span class="pulse-item-title">${e.subject||`(no message)`}</span> <span class="pulse-item-meta"><span>${e.sha.slice(0,7)}</span><span>${gr(e)}</span><time datetime="${new Date(e.at).toISOString()}">${Et(e.at)}</time></span></a></li>`)}</ol>`} ${vr(e.items.length-Fn,this._allDirect,()=>{this._allDirect=!this._allDirect})} ${o>0?A`<p class="pulse-note">${e.items.length>0?q(o,`older commit`,`older commits`):q(o,`commit`)} not listed.</p>`:M}</section>`}narrowing(e,t){let n=this._picked===null||!e.stats?null:er(e,t).find(e=>e.from===this._picked)??null,r=this._person===null||!e.stats?null:e.stats.contributors.filter(e=>Xn(e)===this._person);if(!n&&!r)return null;let i=[...new Set((r??[]).flatMap(e=>e.login?[e.login]:[]))].slice(0,In);return{from:ir(n?.from??e.since),to:n?ir(n.to-L):null,authors:i,nobody:r!==null&&i.length===0,who:r?.[0]??null,when:n?n.day?`on ${sr(n,t)}`:`in the w${sr(n,t).slice(1)}`:null,since:n?.from??e.since,until:n?.to??1/0,person:r?this._person:null}}renderList(e,t,n=null){let[r,i]=jn[t],[a,,o]=i.find(([e])=>e===An[t]),s=n&&!n.nobody?Un(this.repository.repoId,e.weeks,n):null,c=n?s?.status===`ready`?s.answer:null:e,{count:l,items:u}=c?.[a]??{count:null,items:null},d=this.repo??this.repository.repo,f=n?n.to===null?`>=${n.from}`:`${n.from}..${n.to}`:`>=${ir(e.since)}`,p=(n?.authors??[]).map(e=>` author:${e.endsWith(`[bot]`)?`app/${e.slice(0,-5)}`:e}`).join(``),m=d?`https://github.com/${d}/${t===`pulls`?`pulls`:`issues`}?q=${encodeURIComponent(`${o}${f}${p}`)}`:null,{who:h,to:g,scope:_}=_r(n);return A`<section class="pulse-panel pulse-list" aria-label="${r}"><div class="pulse-head"><h3>${r}</h3>${n?A`<span class="pulse-narrowed">${g}</span>`:M}${O(`${r} shown`,i.map(([e,t])=>[e,A`${t}<span class="n">${c?.[e]?w(c[e].count):`–`}</span>`]),a,e=>()=>this.showList(t,e))}</div>${n?.nobody?A`<p class="pulse-note">${h}’s commits name no GitHub account to find their ${r.toLowerCase()} by.</p>`:s?.status===`error`?A`<p class="pulse-note" role="alert">${s.error}</p>`:u===null?A`<p class="pulse-note" role="status">Reading…</p>`:u.length===0?A`<p class="pulse-note">None ${_}.</p>`:A`<ol>${u.map(e=>{let[n,r]=me(t,e);return A`<li><a class="${`pulse-item is-${n}`}" href="${d?`https://github.com/${d}/${t===`pulls`?`pull`:`issues`}/${e.number}`:M}" target="_blank" rel="noopener noreferrer" @click="${n=>this.openItem(n,t,e)}"><span class="issue-state" role="img" aria-label="${r}">${oe[t][n]}</span> <span class="pulse-item-title">${e.title||`(no title)`}</span> <span class="pulse-item-meta"><span>#${e.number}</span>${e.author?A`<span>${we(e.author)}</span>`:M} ${e.at==null?M:A`<time datetime="${new Date(e.at).toISOString()}">${Et(e.at)}</time>`}</span></a></li>`})}</ol>`} ${m&&u!==null&&l>u.length?A`<a class="pulse-all" href="${m}" target="_blank" rel="noopener noreferrer">All ${w(l)} on GitHub</a>`:M}</section>`}openItem(e,t,n){this.openPopup(e,{number:n.number,preview:{...n,kind:t,labels:[],comments:0}})}};customElements.get(`repository-pulse`)||customElements.define(`repository-pulse`,yr);var br=864e5,xr=[100,300,1e3],Sr=e=>e.parents.length<=1&&Number.isFinite(e.committedAt),Cr=(e,t)=>Ye(e).filter(Sr).slice(0,t).toReversed(),wr=1,Tr=.08,Er=.6;function Dr(e){let t=[];for(let[n,r]of e.entries()){let i=n===0?0:(r.committedAt-e[n-1].committedAt)/br;t.push(n===0?0:t[n-1]+Math.min(Er,Math.max(Tr,i*wr)))}return t}function Or(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function kr(e,t,n){let r=new Set(e.values()),i=Array.from({length:n},(e,t)=>t).filter(e=>!r.has(e)),a=[...t].filter(([t])=>t!==``&&!e.has(t)).toSorted((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]));for(let[t]of a.slice(0,i.length))e.set(t,i.shift());return e}var Ar=.9,jr=2,Mr=1,Nr=5,Pr=1,Fr=.06;function Ir(){let e=Lr(``,null);return{root:e,dirs:new Map([[``,e]]),files:new Map,going:new Set,users:new Map,beams:[],due:[],layout:!0}}function Lr(e,t){return{path:e,name:e.slice(e.lastIndexOf(`/`)+1),parent:t,dirs:[],files:[],depth:t?t.depth+1:0,x:t?.x??0,y:t?.y??0,tx:t?.tx??0,ty:t?.ty??0,cluster:0,radius:0,node:[0,0],at:[0,0],lx:void 0,ly:void 0,packed:!1,dirty:!0,touched:-1/0}}var Rr=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`)));function zr(e,t){let n=e.dirs.get(t);if(n)return n;let r=zr(e,Rr(t)),i=Lr(t,r),[a,o]=[0,r.dirs.length];for(;a<o;){let e=a+o>>1;r.dirs[e].name<i.name?a=e+1:o=e}return r.dirs.splice(a,0,i),e.dirs.set(t,i),ni(r),e.layout=!0,i}function Br(e,t,n,r){let i=e.files.get(t);if(n===`D`&&!i)return null;if(!i){let a=zr(e,Rr(t));i={path:t,name:t.slice(t.lastIndexOf(`/`)+1),extension:Or(t),dir:a,ox:0,oy:0,touched:r,kind:n,removed:null},a.files.push(i),e.files.set(t,i),ni(a),e.layout=!0}i.touched=r,i.kind=n,i.removed=n===`D`?i.removed??r:null,n===`D`?e.going.add(i):e.going.delete(i);for(let e=i.dir;e;e=e.parent)e.touched=r;return i}function Vr(e,t){let{dir:n}=t;n.files.splice(n.files.indexOf(t),1),e.files.delete(t.path),e.going.delete(t);let r=n;for(;r.parent&&r.files.length===0&&r.dirs.length===0;r=r.parent)r.parent.dirs.splice(r.parent.dirs.indexOf(r),1),e.dirs.delete(r.path);ni(r),e.layout=!0}var Hr=e=>e.flatMap(([e,t,n])=>t===`R`?[[n,`D`],[e,`A`]]:[[e,t]]);function Ur(e,t,n,r,i){let a=t.map(t=>{let n=e.users.get(t.key)??{...t,x:NaN,y:NaN,active:r};return e.users.set(t.key,n),n.active=r,n}),o=Hr(n),s=o.length>1?Math.min(Fr,i/o.length):0;for(let[t,[n,i]]of o.entries())e.due.push({at:r+t*s,path:n,kind:i,users:a});e.due.sort((e,t)=>e.at-t.at)}function Wr(e,t){for(let[n,r]of Hr(t)){let t=Br(e,n,r,-1/0);t&&r===`D`&&Vr(e,t)}}function Gr(e,t,n,r=[]){let i=new Set([...e.files.values()].filter(e=>e.removed===null).map(e=>e.path));for(let[t,n]of[...e.due.map(e=>[e.path,e.kind]),...r])n===`D`?i.delete(t):i.add(t);let a=new Set(t);return[...t.filter(e=>!i.has(e)).map(e=>[e,`A`]),...n?[]:[...i].filter(e=>!a.has(e)).map(e=>[e,`D`])]}function Kr(e,t){let n=0;for(;n<e.due.length&&e.due[n].at<=t;n++){let{at:t,path:r,kind:i,users:a}=e.due[n],o=Br(e,r,i,t);if(o)for(let n of a)e.beams.push({user:n,file:o,kind:i,at:t})}n>0&&e.due.splice(0,n),e.beams=e.beams.filter(e=>t-e.at<Ar);for(let n of[...e.going])t-n.removed>=Mr&&Vr(e,n);for(let[n,r]of e.users)t-r.active>Nr+Pr&&e.users.delete(n)}var qr=6,Jr=2.2,Yr=12,Xr=Math.PI*(3-Math.sqrt(5)),Zr=46,Qr=34,$r=e=>e===0?0:qr*.62*Math.sqrt(e)+Jr;function ei(e){let t=qr*.62*Math.sqrt(e+.5);return[t*Math.cos(e*Xr),t*Math.sin(e*Xr)]}function ti(e){ri(e.root),ii(e.root,-e.root.node[0],-e.root.node[1],0),e.layout=!1}function ni(e){for(let t=e;t&&!t.dirty;t=t.parent)t.dirty=!0}function ri(e){if(!e.dirty)return;for(let t of e.dirs)ri(t);e.cluster=Math.max($r(e.files.length),Jr)+Yr/2;let t={x:0,y:0,r:e.cluster},n=e.dirs.map(e=>({child:e,x:e.lx,y:e.ly,r:e.radius}));if(e.packed)_i(t,n);else{ai([t,...n.toSorted((e,t)=>t.r-e.r||(e.child.name<t.child.name?-1:1))]);for(let e of n)[e.x,e.y]=[e.x-t.x,e.y-t.y];[t.x,t.y]=[0,0]}let r=ui([t,...n]);e.radius=r.r,e.node=[-r.x,-r.y];for(let e of n)[e.child.lx,e.child.ly]=[e.x,e.y],e.child.at=[e.x-r.x,e.y-r.y];e.packed=!0,e.dirty=!1}function ii(e,t,n,r){let[i,a]=[Math.cos(r),Math.sin(r)],o=([e,r])=>[t+e*i-r*a,n+e*a+r*i];[e.tx,e.ty]=o(e.node);for(let t of e.dirs){let[n,r]=o(t.at);ii(t,n,r,Math.atan2(r-e.ty,n-e.tx))}}function ai(e){let[t,n,r]=e;if(!t||([t.x,t.y]=[0,0],!n)||([t.x,n.x,n.y]=[-n.r,t.r,0],!r))return;oi(n,t,r);let i={c:t},a={c:n},o={c:r};i.next=o.previous=a,a.next=i.previous=o,o.next=a.previous=i;t:for(let t=3;t<e.length;t++){let n=e[t];oi(i.c,a.c,n);let r=a.next,o=a.c.r,s=i.previous,c=i.c.r;do{let e=o<=c,l=e?r:s;if(si(l.c,n)){e?a=l:i=l,i.next=a,a.previous=i,t--;continue t}e?[o,r]=[o+r.c.r,r.next]:[c,s]=[c+s.c.r,s.previous]}while(r!==s.next);let l={c:n,previous:i,next:a};i.next=a.previous=a=l;let u=ci(i);for(let e=l.next;e!==a;e=e.next){let t=ci(e);t<u&&([i,u]=[e,t])}a=i.next}}function oi(e,t,n){let[r,i]=[e.x-t.x,e.y-t.y],a=r*r+i*i;if(!a){[n.x,n.y]=[t.x+n.r,t.y];return}let o=(t.r+n.r)**2,s=(e.r+n.r)**2,[c,l,u,d]=o>s?[e,-1,s,o]:[t,1,o,s],f=(a+u-d)/(2*a),p=Math.sqrt(Math.max(0,u/a-f*f));[n.x,n.y]=[c.x+l*f*r-p*i,c.y+l*f*i+p*r]}var si=(e,t)=>{let n=e.r+t.r-1e-6;return n>0&&n*n>(t.x-e.x)**2+(t.y-e.y)**2};function ci(e){let[t,n]=[e.c,e.next.c],r=t.r+n.r;return((t.x*n.r+n.x*t.r)/r)**2+((t.y*n.r+n.y*t.r)/r)**2}var li=64;function ui(e){let t=e.toSorted((e,t)=>X(`${e.x},${e.y}`)-X(`${t.x},${t.y}`)),n=[],r=null,i=0;for(let a=0;a<t.length;a++)if(!(r&&mi(r,t[a]))){if(n=fi(n,t[a]),r=Y(n),!Number.isFinite(r.x+r.y+r.r)||++i>li*t.length)return di(e);a=-1}return r}function di(e){let[t,n]=[0,1].map(t=>{let n=e.flatMap(e=>t===0?[e.x-e.r,e.x+e.r]:[e.y-e.r,e.y+e.r]);return(Math.min(...n)+Math.max(...n))/2});return{x:t,y:n,r:Math.max(...e.map(e=>Math.hypot(e.x-t,e.y-n)+e.r))}}function fi(e,t){if(e.every(e=>mi(t,e)))return[t];for(let n of e)if(!pi(t,n)&&e.every(e=>mi(Y([n,t]),e)))return[n,t];for(let[n,r]of e.entries())for(let i of e.slice(n+1))if(!pi(Y([r,i]),t)&&!pi(Y([r,t]),i)&&!pi(Y([i,t]),r)&&e.every(e=>mi(Y([r,i,t]),e)))return[r,i,t];return[...e,t].length<=3?[...e,t]:[t]}var pi=(e,t)=>e.r-t.r>=0&&(e.r-t.r)**2>=(t.x-e.x)**2+(t.y-e.y)**2;function mi(e,t){let n=e.r-t.r+Math.max(e.r,t.r,1)*1e-9;return n>0&&n*n>(t.x-e.x)**2+(t.y-e.y)**2}function Y([e,t,n]){if(!t)return{x:e.x,y:e.y,r:e.r};if(!n){let[n,r,i]=[t.x-e.x,t.y-e.y,t.r-e.r],a=Math.hypot(n,r)||1e-12;return{x:(e.x+t.x+n/a*i)/2,y:(e.y+t.y+r/a*i)/2,r:(a+e.r+t.r)/2}}let[r,i,a,o,s,c]=[e.x-t.x,e.x-n.x,e.y-t.y,e.y-n.y,t.r-e.r,n.r-e.r],l=e.x**2+e.y**2-e.r**2,[u,d]=[l-t.x**2-t.y**2+t.r**2,l-n.x**2-n.y**2+n.r**2],f=i*a-r*o,[p,m,h,g]=[(a*d-o*u)/(f*2)-e.x,(o*s-a*c)/f,(i*u-r*d)/(f*2)-e.y,(r*c-i*s)/f],[_,v,y]=[m**2+g**2-1,2*(e.r+p*m+h*g),p**2+h**2-e.r**2],b=-(Math.abs(_)>1e-6?(v+Math.sqrt(v*v-4*_*y))/(2*_):y/v);return{x:e.x+p+m*b,y:e.y+h+g*b,r:b}}var hi=60,gi=.5;function _i(e,t){let n=t.filter(e=>e.x!==void 0);for(let r of t.filter(e=>e.x===void 0))vi(r,e,n),n.push(r);for(let n=0;n<hi;n++){let n=!1;for(let r of t){let t=Math.hypot(r.x,r.y),i=e.r+r.r;if(t>=i-gi)continue;let a=t>1e-6?Math.atan2(r.y,r.x):X(r.child.name);[r.x,r.y]=[Math.cos(a)*i,Math.sin(a)*i],n=!0}if(yi(t,0,(e,t)=>{let r=e.r+t.r,[i,a]=[t.x-e.x,t.y-e.y];if(Math.abs(a)>=r-gi)return;let o=Math.hypot(i,a);if(o>=r-gi)return;let s=o>1e-6?Math.atan2(a,i):X(t.child.name),[c,l]=[t.r**2,e.r**2].map(n=>n/(e.r**2+t.r**2)*(r-o));[e.x,e.y]=[e.x-Math.cos(s)*c,e.y-Math.sin(s)*c],[t.x,t.y]=[t.x+Math.cos(s)*l,t.y+Math.sin(s)*l],n=!0}),!n)return}}function vi(e,t,n){let r=r=>Math.hypot(r.x,r.y)>=t.r+e.r-gi&&n.every(t=>Math.hypot(t.x-r.x,t.y-r.y)>=t.r+e.r-gi),i=[],a=(t,n)=>{for(let[r,a]of[[t,n],[n,t]]){let t={r:e.r};oi(r,a,t),i.push(t)}};for(let e of n)a(t,e);yi(n,2*e.r,(t,n)=>{Math.hypot(n.x-t.x,n.y-t.y)<t.r+n.r+2*e.r&&a(t,n)});let o=X(e.child.name);n.length===0&&i.push({x:Math.cos(o)*(t.r+e.r),y:Math.sin(o)*(t.r+e.r)});let s=null;for(let e of i)r(e)&&(!s||Math.hypot(e.x,e.y)<Math.hypot(s.x,s.y))&&(s=e);let c=Math.max(t.r,...n.map(e=>Math.hypot(e.x,e.y)+e.r))+e.r;[e.x,e.y]=s?[s.x,s.y]:[Math.cos(o)*c,Math.sin(o)*c]}function yi(e,t,n){let r=e.toSorted((e,t)=>e.x-e.r-(t.x-t.r));for(let[e,i]of r.entries())for(let a=e+1;a<r.length&&r[a].x-r[a].r<i.x+i.r+t;a++)n(i,r[a])}function bi(e,t,n=Qr){let r=e=>1-Math.exp(-t*e),i=r(3),a=r(6),o=r(2.5);for(let t of e.dirs.values()){t.x+=(t.tx-t.x)*i,t.y+=(t.ty-t.y)*i;for(let[e,n]of t.files.entries()){let[t,r]=ei(e);n.ox+=(t-n.ox)*a,n.oy+=(r-n.oy)*a}}let s=new Map;for(let{user:t,file:n}of e.beams){let e=s.get(t)??s.set(t,{x:0,y:0,count:0}).get(t);e.x+=n.dir.x+n.ox,e.y+=n.dir.y+n.oy,e.count++}for(let[e,t]of s){let[n,r]=[t.x/t.count,t.y/t.count];if(Number.isNaN(e.x)){let t=X(e.key);[e.x,e.y]=[n+Math.cos(t)*Zr*3,r+Math.sin(t)*Zr*3]}let i=Math.hypot(e.x-n,e.y-r)||1,[a,s]=[n+(e.x-n)/i*Zr,r+(e.y-r)/i*Zr];e.x+=(a-e.x)*o,e.y+=(s-e.y)*o}let c=[...e.users.values()].filter(e=>!Number.isNaN(e.x));for(let[e,t]of c.entries())for(let r of c.slice(e+1)){let[e,i]=[r.x-t.x,r.y-t.y],a=Math.hypot(e,i);if(a>=n)continue;let[s,c]=a>0?[e/a,i/a]:[Math.cos(X(r.key)),Math.sin(X(r.key))],l=(n-a)/2*o;[t.x,t.y,r.x,r.y]=[t.x-s*l,t.y-c*l,r.x+s*l,r.y+c*l]}}function X(e){let t=0;for(let n of e)t=t*31+n.codePointAt(0)|0;return(t>>>0)/2**32*2*Math.PI}function xi(e){e.layout&&ti(e);for(let t of e.dirs.values()){t.x=t.tx,t.y=t.ty;for(let[e,n]of t.files.entries())[n.ox,n.oy]=ei(e)}}function Si(e){let t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},n=(e,n,r)=>{t.minX=Math.min(t.minX,e-r),t.minY=Math.min(t.minY,n-r),t.maxX=Math.max(t.maxX,e+r),t.maxY=Math.max(t.maxY,n+r)};for(let t of e.dirs.values())n(t.x,t.y,$r(t.files.length)+Jr);for(let t of e.users.values())Number.isNaN(t.x)||n(t.x,t.y,14);return t}var Ci=[.5,1,2,4,8],wi=20,Ti=50,Ei=8,Di=[`background`,`text`,`muted`,`surface`,`added`,`modified`,`removed`],Oi={side:40,top:64,bottom:40},ki=3,Ai=10,Z=11,ji=72,Mi=250,Ni=1.8,Pi=2,Fi=new Set([`A`,`M`,`D`,`R`]),Ii=2,Li=new Map,Ri=new Map,zi=new Set,Bi=new Map,Vi=new Map,Hi=T(Li,Ri,zi,Bi),{Shown:Ui,shown:Wi,repaint:Gi}=D(qe),Ki=()=>Number(m(`replay`)??300),qi=1;g(e=>{e===`replay`&&Gi()});var Ji=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;function Yi(e,t){let{repoId:n,commit:r,path:i}=e,a=`${n}\0${r}\0${i}\0${t}`,o=Ae(Hi(),a);if(o)return o;let s={key:a,repoId:n,path:i,count:t,commits:null,times:[],reading:!1,treeReading:!1,error:null,counted:``,counts:new Map,colors:new Map,people:null,scene:Ir(),clock:0,next:0,playing:!1,waiting:!1,ended:!1,started:!1};return Hi().set(a,s),Me(Li,Ii,e=>[...Wi].some(t=>t.replay===e),Xi),s}function Xi(e,t){if(Li.delete(e),[...Li.values()].some(e=>e.repoId===t.repoId&&e.path===t.path))return;let n=`${t.repoId}\0${t.path}\0`;for(let e of[Ri,Bi,zi])for(let t of[...e.keys()])t.startsWith(n)&&e.delete(t)}var Zi={files:[],cut:!1},Qi=e=>e.commits[0]?.parents[0]??null,Q=e=>Qi(e)?ta(e,Qi(e)):Zi,$=(e,t)=>`${e.repoId}\0${e.path}\0${t}`,$i=(e,t)=>Ri.get($(e,t)),ea=(e,t)=>zi.has($(e,t)),ta=(e,t)=>Bi.get($(e,t)),na=(e,t)=>!(!$i(e,t.sha)||ea(e,t.sha)&&!ta(e,t.sha));function ra(e){let t=0;for(;t<(e.commits?.length??0)&&na(e,e.commits[t]);)t++;return t}function ia(e,t){if(!Array.isArray(e)||!Fi.has(e[1]))return null;let n=e=>typeof e==`string`&&(t===``||e.startsWith(`${t}/`))?e.slice(t===``?0:t.length+1):null,[r,i,a]=[n(e[0]),e[1],n(e[2])];return!r||i===`R`&&!a?null:i===`R`?[r,i,a]:[r,i]}function aa(e){let t=Q(e),n=e.commits.filter(t=>$i(e,t.sha)),r=`${t?t.files.length:`-`}\0${n.length}`;if(r===e.counted)return;e.counted=r,e.counts=new Map;let i=t=>e.counts.set(Or(t),(e.counts.get(Or(t))??0)+1);for(let e of t?.files??[])i(e);for(let t of n)for(let[n,r]of Hr($i(e,t.sha)))r!==`D`&&i(n);kr(e.colors,e.counts,Ei)}var oa=e=>[...e.commits.slice(e.next),...e.commits.slice(0,e.next)];function sa(e,t,n,r,i){e[t]=!0,n().then(t=>(Hi().get(e.key)===e&&r(t),null),t=>(t?.name!==`AbortError`&&(e.error=t?.message||i),null)).finally(()=>{e[t]=!1,Gi()})}function ca(e){if(e.treeReading||e.error)return;let t=Qi(e)&&!Q(e),n=t?Qi(e):oa(e).find(t=>ea(e,t.sha)&&!ta(e,t.sha))?.sha;n&&sa(e,`treeReading`,()=>c(e.repoId,e.path,n),r=>{let i=Array.isArray(r?.files)?r.files.map(t=>ia([t,`A`],e.path)?.[0]).filter(Boolean):[];Bi.set($(e,n),{files:i,cut:r?.cut===!0||!t&&!Array.isArray(r?.files)})},t?`The files the commits start from could not be read.`:`The files a commit leaves could not be read.`)}function la(e,t,n){let r=$i(e,n.sha),i=ea(e,n.sha)?ta(e,n.sha):null;return i?[...r,...Gr(t,i.files,i.cut,Hr(r))]:r}function ua(e,t){let n=Ir();n.start=Q(e),Wr(n,n.start.files.map(e=>[e,`A`]));for(let r of e.commits.slice(0,t))Wr(n,la(e,n,r));return xi(n),n}function da(e){if(e.reading||e.error||!e.commits)return;let t=ra(e)===0?wi:Ti,n=oa(e).filter(t=>!$i(e,t.sha)).slice(0,t).map(e=>e.sha);n.length!==0&&sa(e,`reading`,()=>s(e.repoId,e.path,n),t=>{let r=new Map((Array.isArray(t?.changes)?t.changes:[]).filter(e=>typeof e?.sha==`string`).map(e=>[e.sha,e]));for(let t of n)Ri.set($(e,t),Array.isArray(r.get(t)?.files)?r.get(t).files.map(t=>ia(t,e.path)).filter(Boolean):[]),r.get(t)?.more===!0&&zi.add($(e,t))},`What the commits changed could not be read.`)}function fa(e){let t=new Map;for(let{login:n=null,name:r=null,agent:i=null}of[{login:e.authorLogin,name:e.authorName},...e.coauthors??[]]){if(typeof n!=`string`&&typeof r!=`string`)continue;let e=typeof i==`string`&&Object.hasOwn(ye,i)?i:De(n,r),a=e?null:Se(n),o=e?`agent:${e}`:a?`user:${a.id}`:typeof n==`string`?`login:${n.toLowerCase()}`:`name:${r.toLowerCase()}`;if(t.has(o))continue;let s=e?ye[e].name:a?a.name??a.login:r??n,c=e?ye[e].mark??null:null,l=e?!c&&ye[e].avatar?`/api/avatar/${ye[e].avatar}`:null:a?`/api/avatar/${encodeURIComponent(a.id)}`:null;t.set(o,{key:o,label:s,letter:s.trim()[0]?.toUpperCase()??`?`,agent:e,mark:c,image:l})}return[...t.values()]}var pa={anthropic:[We,4,5,8],openai:[Ge,4,5,8],"github-copilot":[Ke,0,0,24]},ma={claude:[`#d97757`,`#fff`],codex:[`#fff`,`#000`],copilot:[`#0d1117`,`#fff`]},ha=new Map,ga=e=>ha.get(e)??ha.set(e,new Path2D(pa[e][0])).get(e);function _a(e){let t=Vi.get(e);return t||(t=new Image,t.decoding=`async`,t.src=e,Vi.set(e,t)),t.complete&&t.naturalWidth>0?t:null}var va=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ya=e=>e===.5?`½×`:`${e}\xD7`,ba=j`<path d="M5 3.25v9.5L12.75 8z" fill="currentColor"/>`,xa=j`<path d="M5.25 3.5v9M10.75 3.5v9"/>`,Sa=j`<path d="M3.25 8a4.75 4.75 0 1 0 1.4-3.36M3.25 2.5v2.75H6"/>`,Ca=class extends Ui{constructor(){super(),this.replay=null,this._frame=null,this._last=0,this._camera=null,this._colors=null,this._themes=null,this._resize=null,this._restless=0,this._laidOut=-1/0,this._pointer=null,this._hovered=null,this._shownNext=-1}connectedCallback(){super.connectedCallback(),Rt(this),this._themes=new AbortController,globalThis.addEventListener(`deepview-theme-changed`,()=>this.themeChanged(),{signal:this._themes.signal}),this._resize=globalThis.ResizeObserver?new ResizeObserver(()=>{this.restless()}):null,this._resize?.observe(this),this._last=performance.now(),this._frame=requestAnimationFrame(e=>this.frame(e))}disconnectedCallback(){super.disconnectedCallback(),zt(this),this._themes?.abort(),this._resize?.disconnect(),cancelAnimationFrame(this._frame),this._frame=null,this.replay&&![...Wi].some(e=>e.replay===this.replay)&&(this.replay.playing=!1)}updated(){let e=this.replay;if(!e)return;if(this.restless(),!e.commits){let{entry:t,more:n}=Lt(this.repository);if(t.status!==`ready`)return;if(t.commits.filter(Sr).length<e.count&&t.more){!t.loadingMore&&!t.moreError&&n();return}e.commits=Cr(t.commits,e.count),e.times=Dr(e.commits)}ca(e),da(e);let t=Q(e);t&&(aa(e),e.scene.start!==t&&this.seek(e.next),!e.started&&ra(e)>0&&(e.started=!0,e.playing=!Ji(),this.requestUpdate()))}pickCount(e){S(this.repository,`replay`,String(e))}pickSpeed(e){qi=e,Gi()}toggle(){let e=this.replay;e?.commits?.length&&(e.ended?(this.seek(0),e.playing=!0):e.playing=!e.playing,e.started=!0,this.requestUpdate())}seek(e){let t=this.replay;if(!t?.commits||!Q(t))return;let n=Math.max(0,Math.min(e,ra(t)));Object.assign(t,{scene:ua(t,n),next:n,clock:n>0?t.times[n-1]:-.001,ended:!1,waiting:!1}),this._camera=null,this.requestUpdate()}restless(){this._restless=performance.now()+3e3}themeChanged(){this.readColors(),this.restless(),this.replay&&this.draw(this.replay,0)}frame(e){this._frame=requestAnimationFrame(e=>this.frame(e));let t=Math.min(.1,Math.max(0,(e-this._last)/1e3));this._last=e;let n=this.replay;n&&(n.playing&&n.commits&&this.play(n,t),n.next!==this._shownNext&&(this._shownNext=n.next,this.requestUpdate()),this._colors||this.readColors(),(n.playing||e<this._restless)&&(Kr(n.scene,n.clock),n.scene.layout&&e-this._laidOut>=Mi&&(ti(n.scene),this._laidOut=e),bi(n.scene,t,Math.max(Qr,ji/(this._camera?.zoom??1))),this.draw(n,t)))}play(e,t){let n=e.clock+t*qi,r=e.waiting;for(e.waiting=!1;e.next<e.commits.length&&e.times[e.next]<=n;){let t=e.commits[e.next];if(!na(e,t)){n=e.times[e.next],e.waiting=!0;break}let r=e.times[e.next],i=(e.times[e.next+1]??r+Er)-r;Ur(e.scene,fa(t),la(e,e.scene,t),r,i*.8),e.next++}e.clock=n,e.next>=e.commits.length&&n>(e.times.at(-1)??0)+Pi&&(e.playing=!1,e.ended=!0),(r!==e.waiting||e.ended)&&this.requestUpdate()}readColors(){let e=this.querySelector(`.replay-swatches`);if(!e)return;let t=t=>getComputedStyle(e.querySelector(`.is-${t}`)).color,n={...Object.fromEntries(Di.map(e=>[e,t(e)])),kinds:Array.from({length:Ei},(e,n)=>t(`kind-${n}`)),font:getComputedStyle(this).fontFamily},r=Object.assign(document.createElement(`canvas`),{width:1,height:1}).getContext(`2d`,{willReadFrequently:!0});n.pixels=new Map([n.muted,...n.kinds].map(e=>(r.clearRect(0,0,1,1),r.fillStyle=e,r.fillRect(0,0,1,1),[e,[...r.getImageData(0,0,1,1).data]]))),this._colors=n}draw(e,t){let n=this.querySelector(`canvas`),r=this._colors;if(!n||!r)return;let{clientHeight:i,clientWidth:a}=n;if(a===0||i===0)return;let o=globalThis.devicePixelRatio||1;(n.width!==Math.round(a*o)||n.height!==Math.round(i*o))&&(n.width=Math.round(a*o),n.height=Math.round(i*o));let s=n.getContext(`2d`);if(!s)return;s.setTransform(o,0,0,o,0,0),s.clearRect(0,0,a,i);let{scene:c,clock:l}=e,u=this.aim(c,a,i,t),d=e=>(e-u.x)*u.zoom+a/2,f=e=>(e-u.y)*u.zoom+i/2,p=e=>d(e.dir.x+e.ox),m=e=>f(e.dir.y+e.oy);s.lineCap=`round`,s.strokeStyle=r.muted,s.globalAlpha=.35,s.lineWidth=Math.max(1,Math.min(2.5,1.5*u.zoom)),s.beginPath();for(let e of c.dirs.values())e.parent&&(s.moveTo(d(e.parent.x),f(e.parent.y)),s.lineTo(d(e.x),f(e.y)));s.stroke();let h=Math.max(1.2,Jr*u.zoom),g=h<Ni,_=t=>e.colors.has(t.extension)?r.kinds[e.colors.get(t.extension)]:r.muted,v=[],y=new Map;for(let e of c.files.values()){if(e.removed!==null||l-e.touched<jr){v.push(e);continue}let[t,n]=[p(e),m(e)];if(t<-h||n<-h||t>a+h||n>i+h)continue;let r=_(e);(y.get(r)??y.set(r,[]).get(r)).push(t,n)}if(g)s.globalAlpha=1,s.drawImage(this.dotLayer(n,y,o,h*o,.85),0,0,a,i);else{s.globalAlpha=.85;for(let[e,t]of y){s.fillStyle=e,s.beginPath();for(let e=0;e<t.length;e+=2)s.moveTo(t[e]+h,t[e+1]),s.arc(t[e],t[e+1],h,0,2*Math.PI);s.fill()}}for(let e of v){let t=Math.max(0,1-(l-e.touched)/jr),n=e.removed===null?1:Math.max(0,1-(l-e.removed)/Mr);s.globalAlpha=.85*n+.15*t,s.fillStyle=_(e),s.beginPath(),s.arc(p(e),m(e),h*(1+t)*n,0,2*Math.PI),s.fill()}s.lineWidth=1.5;for(let e of c.beams)Number.isNaN(e.user.x)||(s.globalAlpha=Math.max(0,1-(l-e.at)/Ar)*.85,s.strokeStyle=e.kind===`A`?r.added:e.kind===`D`?r.removed:r.modified,s.beginPath(),s.moveTo(d(e.user.x),f(e.user.y)),s.lineTo(p(e.file),m(e.file)),s.stroke());let b=(e,t,n)=>{s.strokeText(e,t,n),s.fillText(e,t,n)};s.lineJoin=`round`,s.globalAlpha=1,s.textBaseline=`middle`,s.font=`11px ${r.font}`,s.fillStyle=r.muted,s.strokeStyle=r.background,s.lineWidth=3;for(let e of c.dirs.values())!e.parent||e.depth>1&&l-e.touched>jr||b(e.name,d(e.x)+Math.max(6,($r(e.files.length)+3)*u.zoom),f(e.y));let x=v.filter(e=>e.removed===null);if(x.length<=Ai){s.fillStyle=r.text;for(let e of x)s.globalAlpha=Math.max(0,1-(l-e.touched)/jr),b(e.name,p(e)+h*2+3,m(e))}s.textAlign=`center`;for(let e of c.users.values()){if(Number.isNaN(e.x))continue;let[t,n]=[d(e.x),f(e.y)];s.globalAlpha=Math.max(0,Math.min(1,1-(l-e.active-Nr)/Pr));let[i,a]=Object.hasOwn(ma,e.agent)?ma[e.agent]:[r.surface,r.text];s.fillStyle=i,s.beginPath(),s.arc(t,n,Z,0,2*Math.PI),s.fill();let o=e.image?_a(e.image):null;if(e.mark&&Object.hasOwn(pa,e.mark)){let[,r,i,o]=pa[e.mark],c=Z*2*.62;s.save(),s.translate(t-c/2,n-c/2),s.scale(c/o,c/o),s.translate(-r,-i),s.fillStyle=a,s.fill(ga(e.mark)),s.restore(),s.beginPath(),s.arc(t,n,Z,0,2*Math.PI)}else o?(s.save(),s.clip(),s.drawImage(o,t-Z,n-Z,Z*2,Z*2),s.restore()):(s.fillStyle=r.text,s.font=`600 11px ${r.font}`,s.fillText(e.letter,t,n+.5));s.strokeStyle=r.muted,s.lineWidth=1,s.stroke(),s.fillStyle=r.text,s.strokeStyle=r.background,s.lineWidth=3,s.font=`11px ${r.font}`,b(e.label,t,n+Z+9)}s.textAlign=`start`,s.globalAlpha=1,this.hover(c,d,f,p,m,h)}dotLayer(e,t,n,r,i){let[a,o]=[e.width,e.height];if(this._dots?.wide!==a||this._dots?.high!==o){let e=new ImageData(a,o);this._dots={wide:a,high:o,image:e,pixels:new Uint32Array(e.data.buffer),layer:Object.assign(document.createElement(`canvas`),{width:a,height:o})}}let{image:s,pixels:c,layer:l}=this._dots;c.fill(0);for(let[e,s]of t){let[t,l,u,d]=this._colors.pixels.get(e)??[128,128,128,255],f=(Math.round(d*i)<<24|u<<16|l<<8|t)>>>0;for(let e=0;e<s.length;e+=2){let t=s[e]*n,i=s[e+1]*n,l=Math.max(0,Math.round(t-r)),u=Math.min(a,Math.round(t+r)),d=Math.min(o,Math.round(i+r));for(let e=Math.max(0,Math.round(i-r));e<d;e++)for(let t=e*a+l,n=e*a+u;t<n;t++)c[t]=f}}return l.getContext(`2d`).putImageData(s,0,0),l}aim(e,t,n,r){let i=Si(e),a=Number.isFinite(i.minX),o=a?Math.max(.02,Math.min(ki,(t-2*Oi.side)/Math.max(1,i.maxX-i.minX),(n-Oi.top-Oi.bottom)/Math.max(1,i.maxY-i.minY))):1,s={x:a?(i.minX+i.maxX)/2:0,y:a?(i.minY+i.maxY)/2-(Oi.top-Oi.bottom)/2/o:0,zoom:o};if(this._camera){let e=1-Math.exp(-r*1.8);this._camera.x+=(s.x-this._camera.x)*e,this._camera.y+=(s.y-this._camera.y)*e,this._camera.zoom=Math.exp(Math.log(this._camera.zoom)+(Math.log(s.zoom)-Math.log(this._camera.zoom))*e)}else this._camera=s;return this._camera}hover(e,t,n,r,i,a){let o=this._pointer,s=null;if(o){let c=(e,t)=>Math.hypot(e-o.x,t-o.y),l=[...e.users.values()].find(e=>!Number.isNaN(e.x)&&c(t(e.x),n(e.y))<=Z+2),u=a+4,d=null;if(!l)for(let t of e.files.values()){let e=c(r(t),i(t));e<=u&&([u,d]=[e,t])}let f=l||d?null:[...e.dirs.values()].find(e=>e.parent&&c(t(e.x),n(e.y))<=6);s=l?l.label:d?this.pathName(d.path):f?`${this.pathName(f.path)}/`:null}let c=s?{text:s,x:o.x,y:o.y}:null;(c?.text!==this._hovered?.text||c?.x!==this._hovered?.x||c?.y!==this._hovered?.y)&&(this._hovered=c,this.requestUpdate())}pathName(e){return this.repository.path?`${this.repository.path}/${e}`:e}pointer(e){let t=e.currentTarget.getBoundingClientRect();this._pointer=e.type===`pointerleave`?null:{x:e.clientX-t.left,y:e.clientY-t.top},this.restless()}render(){if(!this.repository)return M;let e=Yi(this.repository,Ki());this.replay&&this.replay!==e&&(this.replay.playing=!1),this.replay=e;let t=e.commits?null:Lt(this.repository),n=e.commits?.length??0,r=ra(e),i=e.next>0?e.commits[e.next-1]:null,a=e.commits?e.people??=new Set(e.commits.flatMap(e=>fa(e).map(e=>e.key))).size:0,o=(e.commits?Q(e):null)?.cut||e.commits?.some(t=>ea(e,t.sha)&&ta(e,t.sha)?.cut),s=e.commits&&n>0?`${w(n)} commit${n===1?``:`s`} by ${w(a)}, ${va(e.commits[0].committedAt)} \u2013 ${va(e.commits.at(-1).committedAt)}${o?`, drawn in part: more files than are read`:``}`:``;return A`<div class="history-bar">${C(`replay`)}${O(`Commits played`,xr.map(e=>[e,A`Last ${w(e)}`]),e.count,e=>()=>this.pickCount(e))}${s?A`<span class="history-summary">${s}</span>`:M}</div><div class="replay-stage"><canvas class="replay-canvas" role="img" aria-label="${i?`The repository\u2019s files as of ${va(i.committedAt)}, ${w(e.next)} of ${w(n)} commits played`:`The repository’s files, as its commits change them`}" @pointermove="${this.pointer}" @pointerleave="${this.pointer}"></canvas>${i?A`<div class="replay-day"><time datetime="${new Date(i.committedAt).toISOString()}">${va(i.committedAt)}</time> <span>${w(e.next)} of ${w(n)}</span></div>${this.renderCommit(i)}`:M} ${this.renderKey(e)} ${this.renderStatus(e,t,r)} ${this._hovered?A`<div class="replay-tip" style="${k({left:`${this._hovered.x}px`,top:`${this._hovered.y}px`})}">${this._hovered.text}</div>`:M}<div class="replay-swatches" aria-hidden="true">${[...Di,...Array.from({length:Ei},(e,t)=>`kind-${t}`)].map(e=>A`<span class="${`is-${e}`}"></span>`)}</div></div>${this.renderControls(e,n,r)}`}renderCommit(e){let t=Ot(this.repo??this.repository.repo),n=e.sha.slice(0,7);return A`<p class="replay-commit">${t?A`<a class="replay-sha" href="${`${t}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" aria-label="${`Commit ${n} on GitHub`}">${n}</a>`:A`<code class="replay-sha">${n}</code>`} <span class="replay-commit-subject">${kt(e.subject||`(no message)`,t)}</span> <span class="replay-commit-author">${Pe(e.authorLogin,e.authorName,e.coauthors)}</span></p>`}renderKey(e){if(e.colors.size===0)return M;let t=[...e.colors].toSorted((t,n)=>(e.counts.get(n[0])??0)-(e.counts.get(t[0])??0));return A`<ul class="replay-key" aria-label="Kinds of files">${t.map(([e,t])=>A`<li><span class="${`replay-dot is-kind-${t}`}"></span>.${e}</li>`)}<li><span class="replay-dot is-muted"></span>Other</li><li class="replay-beams"><span class="replay-beam is-added"></span>Added</li><li><span class="replay-beam is-modified"></span>Modified</li><li><span class="replay-beam is-removed"></span>Removed</li></ul>`}renderStatus(e,t,n){let[r,i,a]=t?.entry.status===`error`?[`history`,t.entry.error,()=>Bt(t.key)]:e.error?[`replay`,e.error,()=>{e.error=null,Gi()}]:t?.entry.status===`ready`&&t.entry.moreError?[`more`,t.entry.moreError,()=>t.more()]:[];if(a)return Be(r,A`<div class="replay-status is-error"><p role="alert">${i}</p><button type="button" @click="${a}">Retry</button></div>`);if(t){let e=t.entry.status===`ready`?t.entry.commits.length:0;return A`<div class="replay-status" role="status">${e>0?`Reading commits\u2026 ${w(e)} so far`:`Reading the history…`}</div>`}return e.commits.length===0?A`<div class="replay-status">No commits to play.</div>`:Q(e)?n===0?A`<div class="replay-status" role="status">Reading what the commits changed…</div>`:e.waiting?A`<div class="replay-status is-waiting" role="status">Reading what the next commits changed…</div>`:M:A`<div class="replay-status" role="status">Reading the files as they were before ${va(e.commits[0].committedAt)}…</div>`}renderControls(e,t,n){let r=e.ended?`Play again`:e.playing?`Pause`:`Play`,i=n>0&&!!(e.commits&&Q(e)),a=e=>`${t>0?e/t*100:0}%`;return A`<div class="replay-controls"><button type="button" class="replay-play" aria-label="${r}" ?disabled="${!i}" @click="${()=>this.toggle()}"><svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e.ended?Sa:e.playing?xa:ba}</svg></button><div class="replay-track" style="${k({"--buffered":a(n),"--played":a(e.next)})}"><input type="range" min="0" max="${t}" step="1" .value="${String(e.next)}" aria-label="Commits played" ?disabled="${!i}" aria-valuetext="${`${w(e.next)} of ${w(t)} commits`}" @input="${e=>this.seek(Number(e.target.value))}"></div>${O(`Speed`,Ci.map(e=>[e,ya(e)]),qi,e=>()=>this.pickSpeed(e))}</div>`}};customElements.get(`repository-replay`)||customElements.define(`repository-replay`,Ca);var wa=8,Ta=20,Ea=T(new Map),{Shown:Da,shown:Oa,repaint:ka}=D(ne);g(e=>{(e===`issues`||e===`pulls`)&&ka()}),u(e=>{for(let t of Oa)e&&t.repository?.repoId!==e.repoId||t.requestUpdate()});function Aa(e){if(!Array.isArray(e?.items))throw TypeError(`The server answered with no list.`);return{items:e.items.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`&&Array.isArray(e.labels)),counts:{open:e.counts?.open??0,closed:e.counts?.closed??0},more:e.more===!0,after:e.more===!0?e.after:null,readAt:t(e)}}function ja(e,t,n,s){let c=e=>e.state===`open`==(n===`open`),l=s.items.map(t=>r(e,t.number)??{item:t,readAt:s.readAt}),u=l.map(({item:e})=>e),d=new Set(u.map(e=>e.number)),f=s.more?s.items.at(-1)?.updatedAt??0:null,p=i(e,t).filter(({item:e,readAt:t})=>t>s.readAt&&!d.has(e.number)&&c(e)&&(f===null||(e.updatedAt??0)>=f)).toSorted((e,t)=>(t.item.updatedAt??0)-(e.item.updatedAt??0));for(let{item:e}of p){let t=u.findIndex(t=>(t.updatedAt??0)<(e.updatedAt??0));u.splice(t===-1?u.length:t,0,e)}let m=s.countsAt??s.readAt,h=e=>{let t=a(e.item),n=e.item.closedAt??e.item.mergedAt??null;return(t===`closed`?n!==null&&n<=m:(e.item.updatedAt??1/0)<=m)?t:s.counted?.get(e.item.number)??o(e,m)},g=new Map(i(e,t).map(e=>[e.item.number,e]));for(let e of l)g.has(e.item.number)||g.set(e.item.number,e);let _=0;for(let e of g.values()){let t=h(e);t!==a(e.item)&&(_+=t===n?1:-1)}let v=n===`open`?`closed`:`open`;return{items:u,counts:{[n]:Math.max(0,s.counts[n]-_),[v]:Math.max(0,s.counts[v]+_)}}}function Ma(e,t,n){let r=new Map(i(e,t).map(e=>[e.item.number,o(e,n.countsAt)]));for(let e of n.items)r.has(e.number)||r.set(e.number,a(e));return n.counted=r,n}var Na=(e,t)=>Ne(e,t,e=>[`#${e.number}`,e.title,e.author??``,Ce(e.author)??``,e.head??``,...e.labels.map(e=>e.name)]),Pa=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumSignificantDigits:2}),Fa=e=>e<1e3?String(e):Pa.format(e);function Ia(e){let t=e.labels.length+(e.moreLabels??0),n=e.labels.slice(0,t>wa?wa-1:wa),r=e=>A`<span class="issue-label" style="${k(e.color?{"--label":`#${e.color}`}:{})}" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span>`,i=e=>A`${r(e[0])}${e.length>1?A`<span class="issue-labels-rest" style="${k({"--labels":String(e.length-1)})}">${i(e.slice(1))}</span>`:M}`;return A`${n.length>0?i(n):M}${t>n.length?A`<span class="issue-label is-more">+${t-n.length}</span>`:M}`}var La={git:`from git`,tarball:`a tarball not npm’s registry’s`,integrity:`locked with no integrity`,unlocked:`locked by no lockfile read`};function Ra({versions:e,count:t,unread:n,unchecked:r,cut:i}){let a=t-Math.min(e.length,Ta);return[t>0?`${e.slice(0,Ta).map(e=>`${e.name}${e.version?`@${e.version}`:``} (${La[e.unsupported]})`).join(`, `)}${a>0?` and ${w(a)} more`:``} can\u2019t be reviewed`:null,n.length>0||r>0||i?`not every lockfile it changes was read`:null].filter(Boolean).join(`; `)}function za(e){if(e.status!==`ready`)return M;let{versions:t,fresh:n,updated:r,more:i,toReview:a}=y(e),o=e.review?ee(e).count:0,s=te(e);if(t.length===0&&o===0&&!s&&!e.pending)return M;let c=i?`+`:``,l=t=>{let n=x(t,e.review);return n===`unsupported`?`, can\u2019t be reviewed: ${La[t.unsupported]}`:n===`baseline`?`, needs no review`:t.reviewed?`, reviewed`:t.rejected?`, rejected`:n?`, ${t.reviews}/${e.review.required} reviews`:``},u=e=>`${e.name}@${e.version??`?`}${e.patch?`, patched`:``}${e.was?` (was ${e.was.join(`, `)}${l(e)})`:` (new${l(e)})`}`,d=t.length-Ta,f=[t.length>0?`New in its lockfiles: ${t.slice(0,Ta).map(u).join(`, `)}${d>0?` and ${w(d)}${c} more`:i?` and more`:``}`:null,o>0?`${w(o)} on the base branch unreviewed`:null,s?`Its review fails: ${Ra(s)}`:null,e.pending?`Stasis is still working out what its stasis.config.json’s entries reach`:null].filter(Boolean).join(`. `),p=[n?`${w(n)} new`:null,r?`${w(r)} updated`:null].filter(Boolean).join(`, `),m=a&&o?`${w(a)} + ${w(o)} to review`:a?`${w(a)} to review`:o?`${w(o)} unreviewed`:``;return A`<span class="issue-deps" data-tooltip="${f}">${pe}<span class="issue-deps-names">${[...new Set(t.map(e=>e.name))].join(`, `)}</span> ${p?A`<span class="issue-deps-count">${p}${c}</span>`:M} ${s?A`<span class="issue-deps-review is-failed">${s.count>0?`${w(s.count)} can\u2019t be reviewed`:`lockfiles unread`}</span>`:e.pending?A`<span class="issue-deps-review is-pending" role="status">${m?`${m}, `:``}Stasis building…</span>`:e.review?m?A`<span class="issue-deps-review is-wanted">${m}</span>`:A`<span class="issue-deps-review is-passed" role="img" aria-label="Every version reviewed">${ce.success[1]}</span>`:M}</span>`}var Ba=class extends Da{static properties={kind:{},_filter:{state:!0}};constructor(){super(),this.kind=`issues`,this._filter=``}updated(){this.watchMore(()=>!this._filter.trim())}list(e){let{repoId:t}=this.repository,r=this.kind,i=i=>d(t,r,{state:e,after:i}).then(Aa).then(e=>(n(t,e.items,e.readAt,r),e));return Oe(Ea,`${t}\0${r}\0${e}`,{first:()=>i(null),next:i,message:`The list could not be read.`,repaint:ka,ready:e=>Ma(t,r,{...e,countsAt:e.readAt}),merge:(e,n)=>{e.items=E(e.items,n.items,e=>e.number),n.readAt>=e.countsAt&&(e.counts=n.counts,e.countsAt=n.readAt,Ma(t,r,e))}})}pick(e){S(this.repository,this.kind,e)}render(){if(!this.repository)return M;let e=m(this.kind)??`open`,{key:t,entry:n,more:r}=this.list(e),i=n.status===`ready`,a=this.kind===`pulls`?`pull requests`:`issues`,o=e===`open`?`closed`:`open`,s=Ea().get(`${this.repository.repoId}\0${this.kind}\0${o}`),c=i?ja(this.repository.repoId,this.kind,e,n):null,l=c?c.counts:s?.status===`ready`?ja(this.repository.repoId,this.kind,o,s).counts:null,u=e=>l?A`<span class="n">${w(l[e])}</span>`:M,d=c?Na(c.items,this._filter):[];return A`<div class="history-bar issues-bar">${C(this.kind)}${O(this.kind===`pulls`?`Pull requests`:`Issues`,[[`open`,A`Open${u(`open`)}`],[`closed`,A`Closed${u(`closed`)}`]],e,e=>()=>this.pick(e),{spaced:!0})}<input class="issues-filter" type="search" placeholder="Filter" aria-label="${`Filter the ${a} read`}" .value="${this._filter}" @input="${e=>{this._filter=e.target.value}}"> ${c&&this._filter.trim()?A`<span class="history-summary">${d.length} of ${c.items.length} read</span>`:M}</div>${c?this.renderTiles(n,c.items,d,r,`${e} ${a}`):Re(n,`Reading the ${a}\u2026`,()=>{Ea().delete(t),ka()})}`}renderTiles(e,t,n,r,i){if(t.length===0)return A`<div class="bundles-slide-placeholder">No ${i}.</div>`;let a=this.repo??this.repository.repo,o=this.kind===`pulls`?`pull`:`issues`;return A`<div class="issues-scroll">${n.length===0?A`<p class="history-note">None of the ${i} read match.</p>`:A`<ol class="issues-grid" aria-label="${i}">${n.map(e=>{let[t,n]=me(this.kind,e),r=this.renderTile(e,t,n);return A`<li class="${ze({"issue-tile":!0,[`is-${t}`]:!0})}">${a?A`<a class="issue-body" href="${`https://github.com/${a}/${o}/${e.number}`}" target="_blank" rel="noopener noreferrer" @click="${t=>this.openTile(t,e)}">${r}</a>`:A`<div class="issue-body" @click="${t=>this.openTile(t,e)}">${r}</div>`}</li>`})}</ol>`} ${Ie(e,r,`More`,`history-more issues-more`)}</div>`}openTile(e,t){this.openPopup(e,{number:t.number,preview:{...t,kind:this.kind}})}renderTile(t,n,r){let i=this.kind===`pulls`,a=i&&t.state===`open`&&f(t)?_(this.repository.repoId,t.number,!0,{listed:!0}):null,o=t.updatedAt==null?null:new Date(t.updatedAt),s=i&&t.checks?ce[t.checks]:null,c=i&&t.state===`open`&&t.review?le[t.review]:null,l=t.comments>0?`${w(t.comments)} comment${t.comments===1?``:`s`}`:null,u=(e,[n,r])=>A`<span class="${`issue-${e} is-${t[e]}`}" role="img" aria-label="${n}" data-tooltip="${n}">${r}</span>`;return A`<span class="issue-rail"><span class="issue-state" role="img" aria-label="${r}">${oe[this.kind][n]}</span> ${i?A`<span class="issue-marks">${c?u(`review`,c):M}${s?u(`checks`,s):M}</span>`:M} ${l?A`<span class="issue-comments" role="img" aria-label="${l}" data-tooltip="${l}">${se}<span>${Fa(t.comments)}</span></span>`:M} </span><span class="issue-lines"><span class="issue-name">${t.title||`(no title)`}</span> <span class="issue-meta"><span class="issue-number">#${t.number}</span> <span class="issue-author">${we(t.author,t.author??`ghost`)}</span> ${o?A`<time datetime="${o.toISOString()}">${Et(t.updatedAt)}</time>`:M} </span>${t.labels.length>0||t.moreLabels>0?A`<span class="issue-labels">${Ia(t)}</span>`:M} ${i&&t.head?A`<span class="issue-branch"><code>${t.head}</code>${t.base?A`<span aria-hidden="true">→</span><code>${t.base}</code>`:M} <span class="issue-diff"><span class="is-added">+${w(t.additions)}</span> <span class="is-deleted">−${w(t.deletions)}</span></span></span>`:M} ${i&&t.state===`open`?e(t.reviews):M} ${a?za(a):M}</span>`}};customElements.get(`repository-issues`)||customElements.define(`repository-issues`,Ba);
@@ -1 +1 @@
1
- import{Mf as e,Of as t,Qf as n,oe as r,pe as i,qa as a}from"./chunk-ESJZZF2Y.js";import{a as o}from"./chunk-DQJEVHRE.js";import{c as s,d as c,g as l}from"./chunk-2XUEZHIP.js";var u=e(c`<path d="M3.5 8.4l2.9 2.9 6.1-6.6"/>`),d=e(c`<circle class="fill" cx="8" cy="8" r="3"/>`),f=e(c`<path d="M4.2 4.2l7.6 7.6M11.8 4.2l-7.6 7.6"/>`),p=e(c`<circle class="dotted" cx="8" cy="8" r="5.5"/>`),m=e(c`<path d="M2.6 3.2h7.6v5.3H6.3L4 10.4V8.5H2.6z"/><path d="M12.2 6.2h1.2v5.3H12v1.9l-2.3-1.9H7"/>`),h={approved:[`approved`,n.approved[1],`Approved`],changes:[`changes`,n.changes[1],`Changes requested`],commented:[`commented`,t,`Commented`],dismissed:[`dismissed`,t,`Review dismissed`]},g={done:[`reviewed`,u,`Reviewed`],running:[`running`,d,`Reviewing`],failed:[`failed`,f,`Review failed`],requested:[`requested`,p,`Asked to review again`]},_=[`requested`,p,`Review requested`],v=e=>e.slice(0,7),y=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),b=(e,t,n=!1)=>`${e.toLocaleString(`en-US`)}${n?`+`:``} ${t}${e===1&&!n?``:`s`}`;function x(e){return e?e.failed?g.failed:e.requested?g.requested:g[e.code?.status]??null:null}function S(e){let t=x(e.codex),n=e.codex?.code?.commit??null;return[...t?[{who:a(e.codex.login,`Codex`),standing:t,commit:n,stale:n!==null&&n!==e.head}]:[],...e.reviewers.map(t=>({who:a(t.login,t.login??`someone`),standing:h[t.state]??_,requested:t.requested&&!!h[t.state],workflow:t.workflow??null,commit:t.commit,at:t.at,stale:t.commit!==null&&t.commit!==e.head}))]}var C=e=>(e.moreReviews??0)+(e.moreRequests??0),w=e=>[e.moreReviews>0?b(e.moreReviews,`more review`):null,e.moreRequests>0?b(e.moreRequests,`more review request`):null].filter(Boolean).join(` and `);function T(e){if(!e.head)return!0;let t=e.codex?.code;return t?.status===`done`&&t.commit===e.head||e.reviewers.some(t=>h[t.state]&&t.state!==`dismissed`&&t.commit===e.head)?!0:e.moreReviews>0&&null}var E=e=>e?s`<span class="${`review-severity is-${e}`}">${e.toUpperCase()}</span>`:l;function D(e){if(!e)return l;let t=S(e),{open:n,more:r,severity:i}=e.threads,a=n>0?`${b(n,`open review thread`,r)}${i?`, the gravest ${i.toUpperCase()}`:``}`:r?`No open review thread among those read; more on GitHub`:null,o=T(e);return s`<span class="issue-reviews">${t.map(({who:e,standing:[t,n,r],commit:i,stale:a,requested:o})=>{let c=`${r}${o?`, and requested again`:``}${a?`, on an earlier commit (${v(i)})`:i?`, on the latest commit`:``}`;return s`<span class="${`review-mark is-${t}${a?` is-stale`:``}`}"><span class="review-glyph" role="img" aria-label="${c}" data-tooltip="${c}">${n}</span><span class="review-who">${e}</span></span>`})} ${C(e)>0?s`<span class="review-more" data-tooltip="${`${w(e)}, on GitHub`}">+${C(e)}</span>`:l} ${a?s`<span class="review-threads" role="img" aria-label="${a}" data-tooltip="${a}">${m}<span>${n}${r?`+`:``}</span>${E(i)}</span>`:l} ${o===!1?s`<span class="review-unreviewed" data-tooltip="${t.length>0?`No review is on the latest commit`:`No reviews yet`}">Unreviewed</span>`:o===null?s`<span class="review-unreviewed" data-tooltip="No review read is on the latest commit; more on GitHub">Unreviewed?</span>`:l}</span>`}function O(e,t,n){if(!e)return l;let r=s`<code>${v(e)}</code>`;return s`<span class="review-on">on ${n?s`<a href="${`https://github.com/${n}/commit/${e}`}" target="_blank" rel="noopener noreferrer">${r}</a>`:r}${e===t?`, the latest commit`:`, an earlier commit`}</span>`}function k(e,t){if(!e)return l;let{head:n,codex:r}=e,i=(e,[i,o,c],l)=>s`<li class="review-row">${a(r.login,`Codex`)} <span class="${`review-state is-${i}`}">${o}${l}: ${c.toLowerCase()}</span>${O(e.commit,n,t)}</li>`,o=[...r?.code?[i(r.code,x(r)??g.done,`Code review`)]:[],...r?.security?[i(r.security,g[r.security.status]??g.done,`Security review`)]:[],...S({...e,codex:null}).map(({who:e,standing:[r,i,a],commit:o,at:c,requested:u,workflow:d})=>s`<li class="review-row">${e} <span class="${`review-state is-${r}`}">${i}${a}${u?`, requested again`:``}</span>${d?s`<span class="review-on">by the workflow <code>${d}</code></span>`:l}${O(o,n,t)}${c?s`<time datetime="${new Date(c).toISOString()}">${y(c)}</time>`:l}</li>`)],{open:c,resolved:u,more:d,list:f=[]}=e.threads;return s`<section class="repo-item-section"><h4>Reviews</h4>${o.length>0?s`<ul>${o}</ul>`:s`<p class="repo-item-quiet">No reviews yet.</p>`} ${C(e)>0?s`<p class="repo-item-quiet">And ${w(e)}, on GitHub.</p>`:l} ${T(e)===null?s`<p class="repo-item-quiet">No review read is on the latest commit, <code>${v(n)}</code>; one of those on GitHub may be.</p>`:o.length>0&&!T(e)?s`<p class="repo-item-quiet">No review is on the latest commit, <code>${v(n)}</code>.</p>`:l}</section>${c>0||u>0?s`<section class="repo-item-section"><h4>Open threads</h4>${f.length>0?s`<ul>${f.map(e=>s`<li><a class="repo-item-row review-thread" href="${e.url??l}" target="_blank" rel="noopener noreferrer">${E(e.severity)}<span class="repo-item-title">${e.title||`(no comment)`}</span> ${e.path?s`<code class="review-path">${e.path}${e.line?`:${e.line}`:``}</code>`:l} ${e.outdated?s`<span class="repo-item-quiet">outdated</span>`:l}</a></li>`)}</ul>`:s`<p class="repo-item-quiet">${d?`None open among those read.`:`None open.`}</p>`} ${u>0||d?s`<p class="repo-item-quiet">${u>0?`${b(u,`thread`)} resolved`:``}${d?`${u>0?`; `:``}more on GitHub`:``}.</p>`:l}</section>`:l}`}var A=o({items:new Map,changes:0}),j=i(A.items),M=(e,t,n)=>`${e}\0${t}\0${n}`,N=e=>Number.isSafeInteger(e?.readAt)&&e.readAt>0?e.readAt:Date.now();function P(e,t,n,i=null){j();let a=r(),o=!1;for(let r of t){let t=M(a,e,r.number),s=A.items.get(t);if(s&&s.readAt>n)continue;let c=s&&R(s.item),l=!c||c===R(r)?s?.moved??null:{from:c,before:s.readAt};A.items.set(t,{item:{...r,kind:r.kind??i??s?.item.kind??null},readAt:n,moved:l}),o=!0}o&&A.changes++}var F=(e,t)=>A.items.get(M(r(),e,t))??null;function I(e,t){let n=M(r(),e,``);return A.changes,[...A.items].flatMap(([e,r])=>e.startsWith(n)&&r.item.kind===t?[r]:[])}var L=()=>A.changes,R=e=>e.state===`open`?`open`:`closed`;function z(e,t){let n=R(e.item);if(e.readAt<=t||!e.moved)return n;if(e.moved.before>=t)return e.moved.from;let r=e.item.closedAt??e.item.mergedAt??null;return n===`closed`&&r!==null&&r>t?e.moved.from:n}export{D as a,k as b,N as c,P as d,F as e,I as f,L as g,R as h,z as i};
1
+ import{Mf as e,Of as t,Qf as n,oe as r,pe as i,qa as a}from"./chunk-UZC7POI4.js";import{a as o}from"./chunk-O6FA2R5G.js";import{c as s,d as c,g as l}from"./chunk-2XUEZHIP.js";var u=e(c`<path d="M3.5 8.4l2.9 2.9 6.1-6.6"/>`),d=e(c`<circle class="fill" cx="8" cy="8" r="3"/>`),f=e(c`<path d="M4.2 4.2l7.6 7.6M11.8 4.2l-7.6 7.6"/>`),p=e(c`<circle class="dotted" cx="8" cy="8" r="5.5"/>`),m=e(c`<path d="M2.6 3.2h7.6v5.3H6.3L4 10.4V8.5H2.6z"/><path d="M12.2 6.2h1.2v5.3H12v1.9l-2.3-1.9H7"/>`),h={approved:[`approved`,n.approved[1],`Approved`],changes:[`changes`,n.changes[1],`Changes requested`],commented:[`commented`,t,`Commented`],dismissed:[`dismissed`,t,`Review dismissed`]},g={done:[`reviewed`,u,`Reviewed`],running:[`running`,d,`Reviewing`],failed:[`failed`,f,`Review failed`],requested:[`requested`,p,`Asked to review again`]},_=[`requested`,p,`Review requested`],v=e=>e.slice(0,7),y=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),b=(e,t,n=!1)=>`${e.toLocaleString(`en-US`)}${n?`+`:``} ${t}${e===1&&!n?``:`s`}`;function x(e){return e?e.failed?g.failed:e.requested?g.requested:g[e.code?.status]??null:null}function S(e){let t=x(e.codex),n=e.codex?.code?.commit??null;return[...t?[{who:a(e.codex.login,`Codex`),standing:t,commit:n,stale:n!==null&&n!==e.head}]:[],...e.reviewers.map(t=>({who:a(t.login,t.login??`someone`),standing:h[t.state]??_,requested:t.requested&&!!h[t.state],workflow:t.workflow??null,commit:t.commit,at:t.at,stale:t.commit!==null&&t.commit!==e.head}))]}var C=e=>(e.moreReviews??0)+(e.moreRequests??0),w=e=>[e.moreReviews>0?b(e.moreReviews,`more review`):null,e.moreRequests>0?b(e.moreRequests,`more review request`):null].filter(Boolean).join(` and `);function T(e){if(!e.head)return!0;let t=e.codex?.code;return t?.status===`done`&&t.commit===e.head||e.reviewers.some(t=>h[t.state]&&t.state!==`dismissed`&&t.commit===e.head)?!0:e.moreReviews>0&&null}var E=e=>e?s`<span class="${`review-severity is-${e}`}">${e.toUpperCase()}</span>`:l;function D(e){if(!e)return l;let t=S(e),{open:n,more:r,severity:i}=e.threads,a=n>0?`${b(n,`open review thread`,r)}${i?`, the gravest ${i.toUpperCase()}`:``}`:r?`No open review thread among those read; more on GitHub`:null,o=T(e);return s`<span class="issue-reviews">${t.map(({who:e,standing:[t,n,r],commit:i,stale:a,requested:o})=>{let c=`${r}${o?`, and requested again`:``}${a?`, on an earlier commit (${v(i)})`:i?`, on the latest commit`:``}`;return s`<span class="${`review-mark is-${t}${a?` is-stale`:``}`}"><span class="review-glyph" role="img" aria-label="${c}" data-tooltip="${c}">${n}</span><span class="review-who">${e}</span></span>`})} ${C(e)>0?s`<span class="review-more" data-tooltip="${`${w(e)}, on GitHub`}">+${C(e)}</span>`:l} ${a?s`<span class="review-threads" role="img" aria-label="${a}" data-tooltip="${a}">${m}<span>${n}${r?`+`:``}</span>${E(i)}</span>`:l} ${o===!1?s`<span class="review-unreviewed" data-tooltip="${t.length>0?`No review is on the latest commit`:`No reviews yet`}">Unreviewed</span>`:o===null?s`<span class="review-unreviewed" data-tooltip="No review read is on the latest commit; more on GitHub">Unreviewed?</span>`:l}</span>`}function O(e,t,n){if(!e)return l;let r=s`<code>${v(e)}</code>`;return s`<span class="review-on">on ${n?s`<a href="${`https://github.com/${n}/commit/${e}`}" target="_blank" rel="noopener noreferrer">${r}</a>`:r}${e===t?`, the latest commit`:`, an earlier commit`}</span>`}function k(e,t){if(!e)return l;let{head:n,codex:r}=e,i=(e,[i,o,c],l)=>s`<li class="review-row">${a(r.login,`Codex`)} <span class="${`review-state is-${i}`}">${o}${l}: ${c.toLowerCase()}</span>${O(e.commit,n,t)}</li>`,o=[...r?.code?[i(r.code,x(r)??g.done,`Code review`)]:[],...r?.security?[i(r.security,g[r.security.status]??g.done,`Security review`)]:[],...S({...e,codex:null}).map(({who:e,standing:[r,i,a],commit:o,at:c,requested:u,workflow:d})=>s`<li class="review-row">${e} <span class="${`review-state is-${r}`}">${i}${a}${u?`, requested again`:``}</span>${d?s`<span class="review-on">by the workflow <code>${d}</code></span>`:l}${O(o,n,t)}${c?s`<time datetime="${new Date(c).toISOString()}">${y(c)}</time>`:l}</li>`)],{open:c,resolved:u,more:d,list:f=[]}=e.threads;return s`<section class="repo-item-section"><h4>Reviews</h4>${o.length>0?s`<ul>${o}</ul>`:s`<p class="repo-item-quiet">No reviews yet.</p>`} ${C(e)>0?s`<p class="repo-item-quiet">And ${w(e)}, on GitHub.</p>`:l} ${T(e)===null?s`<p class="repo-item-quiet">No review read is on the latest commit, <code>${v(n)}</code>; one of those on GitHub may be.</p>`:o.length>0&&!T(e)?s`<p class="repo-item-quiet">No review is on the latest commit, <code>${v(n)}</code>.</p>`:l}</section>${c>0||u>0?s`<section class="repo-item-section"><h4>Open threads</h4>${f.length>0?s`<ul>${f.map(e=>s`<li><a class="repo-item-row review-thread" href="${e.url??l}" target="_blank" rel="noopener noreferrer">${E(e.severity)}<span class="repo-item-title">${e.title||`(no comment)`}</span> ${e.path?s`<code class="review-path">${e.path}${e.line?`:${e.line}`:``}</code>`:l} ${e.outdated?s`<span class="repo-item-quiet">outdated</span>`:l}</a></li>`)}</ul>`:s`<p class="repo-item-quiet">${d?`None open among those read.`:`None open.`}</p>`} ${u>0||d?s`<p class="repo-item-quiet">${u>0?`${b(u,`thread`)} resolved`:``}${d?`${u>0?`; `:``}more on GitHub`:``}.</p>`:l}</section>`:l}`}var A=o({items:new Map,changes:0}),j=i(A.items),M=(e,t,n)=>`${e}\0${t}\0${n}`,N=e=>Number.isSafeInteger(e?.readAt)&&e.readAt>0?e.readAt:Date.now();function P(e,t,n,i=null){j();let a=r(),o=!1;for(let r of t){let t=M(a,e,r.number),s=A.items.get(t);if(s&&s.readAt>n)continue;let c=s&&R(s.item),l=!c||c===R(r)?s?.moved??null:{from:c,before:s.readAt};A.items.set(t,{item:{...r,kind:r.kind??i??s?.item.kind??null},readAt:n,moved:l}),o=!0}o&&A.changes++}var F=(e,t)=>A.items.get(M(r(),e,t))??null;function I(e,t){let n=M(r(),e,``);return A.changes,[...A.items].flatMap(([e,r])=>e.startsWith(n)&&r.item.kind===t?[r]:[])}var L=()=>A.changes,R=e=>e.state===`open`?`open`:`closed`;function z(e,t){let n=R(e.item);if(e.readAt<=t||!e.moved)return n;if(e.moved.before>=t)return e.moved.from;let r=e.item.closedAt??e.item.mergedAt??null;return n===`closed`&&r!==null&&r>t?e.moved.from:n}export{D as a,k as b,N as c,P as d,F as e,I as f,L as g,R as h,z as i};