@preventive/triage 1.0.0-alpha.46 → 1.0.0-alpha.47

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 (71) hide show
  1. package/common/managed/agent-tasks.ts +5 -3
  2. package/common/managed/github-agents.ts +28 -10
  3. package/out/activity.js +4 -0
  4. package/out/chunk-5AHIQFFG.js +36 -0
  5. package/out/chunk-6ANSHRFQ.js +6 -0
  6. package/out/chunk-6WF3KNTL.js +3 -0
  7. package/out/chunk-7BKKYVWR.js +7 -0
  8. package/out/{chunk-7XRR4OFU.js → chunk-FH24VHSJ.js} +1 -1
  9. package/out/chunk-NOZJULWS.js +52 -0
  10. package/out/{chunk-OKRLLE5I.js → chunk-PWFUOLZK.js} +1 -1
  11. package/out/chunk-S6U2J62U.js +232 -0
  12. package/out/{chunk-G24A42V6.js → chunk-SPEFPML6.js} +1 -1
  13. package/out/chunk-UENXT2HK.js +3 -0
  14. package/out/chunk-VL43BTSO.js +1 -0
  15. package/out/{chunk-3PS4KWD2.js → chunk-WCPJDAYA.js} +1 -1
  16. package/out/chunk-ZCS4UYHI.js +1 -0
  17. package/out/chunk-ZGNMDGSB.js +1 -0
  18. package/out/client-managed-import.js +1 -1
  19. package/out/client-managed.js +22 -22
  20. package/out/client-sync.js +2 -2
  21. package/out/compare.js +14 -14
  22. package/out/dialogs.js +40 -40
  23. package/out/graph.js +11 -11
  24. package/out/index.html +11 -11
  25. package/out/scan.js +2 -2
  26. package/out/terminal.js +6 -6
  27. package/out/view.css +1 -1
  28. package/out/view.js +15 -15
  29. package/package.json +2 -1
  30. package/risk/index.d.ts +4 -2
  31. package/risk/npm/assess.js +15 -4
  32. package/risk/npm/registry.js +6 -1
  33. package/server-managed/activity.ts +24 -11
  34. package/server-managed/app-agents.ts +10 -21
  35. package/server-managed/bundle-build-worker.js +7 -3
  36. package/server-managed/bundle-build.ts +5 -3
  37. package/server-managed/bundle-cache.ts +9 -3
  38. package/server-managed/bundle.ts +3 -4
  39. package/server-managed/commit-coauthors.ts +5 -9
  40. package/server-managed/db-methods.ts +286 -149
  41. package/server-managed/db-neon.ts +11 -4
  42. package/server-managed/http.ts +75 -33
  43. package/server-managed/link-reports.ts +5 -1
  44. package/server-managed/npm-kept.ts +19 -5
  45. package/server-managed/npm-loads.ts +27 -15
  46. package/server-managed/npm-packages.ts +18 -11
  47. package/server-managed/npm-risk.ts +64 -17
  48. package/server-managed/pretty-print.ts +45 -12
  49. package/server-managed/report-store.ts +16 -11
  50. package/server-managed/repository-agents.ts +1 -1
  51. package/server-managed/repository-browser.ts +4 -2
  52. package/server-managed/repository-code.ts +28 -11
  53. package/server-managed/repository-pulse.ts +1 -1
  54. package/server-managed/solidity-entry-points.ts +5 -3
  55. package/server-managed/sql-postgres.ts +3 -0
  56. package/server-managed/sql.ts +2 -1
  57. package/server-managed/storage-db.ts +11 -3
  58. package/server-managed/storage-encryption.ts +7 -4
  59. package/server-managed/storage.ts +4 -2
  60. package/server-managed/team-feed.ts +3 -1
  61. package/server-managed/team-reports.ts +6 -1
  62. package/server-managed/uploads.ts +29 -9
  63. package/out/chunk-4UFAMJAX.js +0 -1
  64. package/out/chunk-BOIXMUU5.js +0 -3
  65. package/out/chunk-CC4OM6TZ.js +0 -3
  66. package/out/chunk-JKGQ3O7O.js +0 -6
  67. package/out/chunk-LE5ZWLG4.js +0 -235
  68. package/out/chunk-MSION3G4.js +0 -36
  69. package/out/chunk-S6GIXWQW.js +0 -52
  70. package/out/chunk-V3KWNNMY.js +0 -1
  71. package/out/chunk-WQ74ZBZF.js +0 -7
@@ -32,7 +32,8 @@ export type Agent = string
32
32
  export interface AppAgent { id: string; name: string; avatar?: string }
33
33
  // How the server tells one: its fingerprint, a line of an artifact's texts
34
34
  // starting with it; the GitHub account its work is authored by, its id and
35
- // the logins GitHub names it by; its branches' prefix.
35
+ // the logins GitHub names it by, none for one known by its id alone; its
36
+ // branches' prefix.
36
37
  export interface AppAgentMarks { id: string; fingerprint?: string; account?: { id: number; logins: readonly string[] }; prefix: string }
37
38
  // An artifact's author, as GitHub names its account: its login and id.
38
39
  export interface AgentAuthor { login: string; id: number }
@@ -120,7 +121,8 @@ export function labelAgents(labels: unknown[], ids: readonly string[]): Agent[]
120
121
  // The sessions and tasks `texts` link, whether they carry Claude's marks and
121
122
  // Codex's, and the agents of `apps` whose fingerprints start a line of them
122
123
  // (not one a text quotes, as one describing it may), whose account `author`
123
- // is, by its id and login both, or whose prefix the branch `branch` is under;
124
+ // is, by its id and login both (its id alone where it names no login), or
125
+ // whose prefix the branch `branch` is under;
124
126
  // Claude, Codex or the agents of `apps` its `labels` name (labelAgents).
125
127
  export function agentSignals(texts: unknown[], apps: readonly AppAgentMarks[] = [], branch: string | null = null,
126
128
  author: AgentAuthor | null = null, labels: unknown[] = []): AgentSignals {
@@ -129,7 +131,7 @@ export function agentSignals(texts: unknown[], apps: readonly AppAgentMarks[] =
129
131
  const lines = strings.flatMap(text => text.split('\n').map(line => line.trimStart()))
130
132
  const login = author?.login.toLowerCase()
131
133
  const authored = ({ account }: AppAgentMarks) => author !== null && account !== undefined && account.id === author.id
132
- && account.logins.some(name => name.toLowerCase() === login)
134
+ && (account.logins.length === 0 || account.logins.some(name => name.toLowerCase() === login))
133
135
  const labelled = labelAgents(labels, ['claude', 'codex', ...apps.map(app => app.id)])
134
136
  return { sessions: found(SESSION), tasks: found(CODEX_TASK), claude: labelled.includes('claude') || strings.some(text => CLAUDE_MARK.test(text)),
135
137
  codex: labelled.includes('codex') || strings.some(text => CODEX_MARK.test(trailerBlock(text))),
@@ -1,8 +1,7 @@
1
1
  // Agents by their own GitHub accounts, where a repository's activity names
2
2
  // them: each its name, and how the app draws it, by its mark, as the Agents
3
3
  // tab does (ui/view/provider-icons.js), or by its avatar, which
4
- // /api/avatar/<avatar> serves (server-managed/repository-agents.ts
5
- // APP_AGENTS, the Agents tab's marks); its accounts, each by the logins GitHub's REST and GraphQL APIs
4
+ // /api/avatar/<avatar> serves; its accounts, each by the logins GitHub's REST and GraphQL APIs
6
5
  // name it by and its numeric id where known, which GitHub never gives
7
6
  // another; and the names its commits carry where GitHub names no account for
8
7
  // them. Claude Code's commits are authored as Claude <noreply@anthropic.com>,
@@ -21,21 +20,36 @@
21
20
  // in its address. GitHub's Agentic Workflows (gh-aw) post, and approve or
22
21
  // review pull requests, as GitHub Actions' bot, `github-actions` (41898282,
23
22
  // `[bot]` to the REST API), its mark the GitHub Actions App's avatar; other
24
- // workflows the bot runs are as much its own. Cursor's agents commit as whoever ran them, with a
23
+ // workflows the bot runs are as much its own. Neo, its GitHub App (3115942),
24
+ // as its account (274065190), known by its id alone, whatever GitHub names
25
+ // it, and drawn by its App's avatar, wherever its account or its fingerprint
26
+ // names it. Cursor's agents commit as whoever ran them, with a
25
27
  // `Co-authored-by: Cursor Agent <cursoragent@cursor.com>` trailer; the app
26
28
  // has no mark of Cursor's, and draws it by its name's letter. Each by the
27
29
  // addresses (`emails`) its commits name it by, as author or co-author.
30
+ //
31
+ // Those the Agents tab tells beside Claude and Codex (whose sessions and
32
+ // tasks it tells them by, common/managed/agent-tasks.ts), the server's app
33
+ // agents (server-managed/app-agents.ts APP_AGENTS), by their branches'
34
+ // prefix (`prefix`), their first account, the one their work is authored by,
35
+ // and the fingerprint (`fingerprint`) they leave as a line of their pull
36
+ // requests' bodies and their commits' messages, where they leave one:
37
+ // Neo's, on `neo/` branches; Copilot's coding agent's, on `copilot/`;
38
+ // Dependabot's, on `dependabot/<ecosystem>/…`. Their work may carry
39
+ // Claude's or Codex's marks too, those its tools.
28
40
  export interface GithubAgentAccount { id?: number; logins: readonly string[] }
29
41
  export interface GithubAgent { name: string; mark?: 'anthropic' | 'openai' | 'github-copilot'; avatar?: string; accounts: readonly GithubAgentAccount[]; names: readonly string[]
30
- emails?: readonly string[] }
42
+ emails?: readonly string[]; prefix?: string; fingerprint?: string }
31
43
 
32
44
  export const GITHUB_AGENTS = {
33
45
  claude: { name: 'Claude', mark: 'anthropic', accounts: [{ id: 81847, logins: ['claude'] }, { logins: ['claude[bot]'] }], names: ['Claude'], emails: ['noreply@anthropic.com'] },
34
46
  codex: { name: 'Codex', mark: 'openai', accounts: [{ id: 199175422, logins: ['chatgpt-codex-connector', 'chatgpt-codex-connector[bot]'] }], names: ['Codex'],
35
47
  emails: ['codex@openai.com'] },
48
+ neo: { name: 'Neo', avatar: 'app-3115942', accounts: [{ id: 274065190, logins: [] }], names: [], prefix: 'neo/', fingerprint: '🤖 Generated with [Neo](' },
36
49
  copilot: { name: 'Copilot', mark: 'github-copilot', accounts: [{ id: 198982749, logins: ['Copilot', 'copilot-swe-agent'] },
37
- { id: 175728472, logins: ['Copilot', 'copilot-pull-request-reviewer', 'copilot-pull-request-reviewer[bot]'] }], names: ['Copilot'] },
38
- dependabot: { name: 'Dependabot', avatar: 'app-29110', accounts: [{ id: 49699333, logins: ['dependabot', 'dependabot[bot]'] }], names: ['dependabot[bot]'] },
50
+ { id: 175728472, logins: ['Copilot', 'copilot-pull-request-reviewer', 'copilot-pull-request-reviewer[bot]'] }], names: ['Copilot'], prefix: 'copilot/' },
51
+ dependabot: { name: 'Dependabot', avatar: 'app-29110', accounts: [{ id: 49699333, logins: ['dependabot', 'dependabot[bot]'] }], names: ['dependabot[bot]'],
52
+ prefix: 'dependabot/' },
39
53
  actions: { name: 'GitHub Actions', avatar: 'app-15368', accounts: [{ id: 41898282, logins: ['github-actions', 'github-actions[bot]'] }], names: ['github-actions[bot]'] },
40
54
  cursor: { name: 'Cursor', accounts: [], names: ['Cursor Agent'], emails: ['cursoragent@cursor.com'] },
41
55
  } as const satisfies Record<string, GithubAgent>
@@ -50,6 +64,8 @@ for (const [agent, { accounts }] of agents) {
50
64
  for (const login of logins) byLogin.set(login.toLowerCase(), { agent, ids: [...byLogin.get(login.toLowerCase())?.ids ?? [], id] })
51
65
  }
52
66
  }
67
+ // The accounts known by their ids alone, no login of theirs: each its agent.
68
+ const byId = new Map(agents.flatMap(([agent, { accounts }]) => accounts.flatMap(({ id, logins }) => id !== undefined && logins.length === 0 ? [[id, agent] as const] : [])))
53
69
  const byName = new Map(agents.flatMap(([agent, { names }]) => names.map(name => [name.toLowerCase(), agent] as const)))
54
70
  const byEmail = new Map(agents.flatMap(([agent, { emails = [] }]) => emails.map(email => [email, agent] as const)))
55
71
 
@@ -60,13 +76,15 @@ export const emailAgent = (email: unknown): GithubAgentId | null => typeof email
60
76
  // The agent an author is: by their login, GitHub matching logins regardless
61
77
  // of case, their account's id the agent's where both are known, so another
62
78
  // account GitHub names by the same login (a user's, the bot's GraphQL login
63
- // may be) is not; for an author GitHub names no account for, by the name
64
- // they carry. Null for anyone else: a human's account is theirs, whatever
65
- // their commits name them.
79
+ // may be) is not; an account known by its id alone, by that, whatever its
80
+ // login; for an author GitHub names no account for, by the name they carry.
81
+ // Null for anyone else: a human's account is theirs, whatever their commits
82
+ // name them.
66
83
  export function githubAgent(login: string | null, account: number | null = null, name: string | null = null): GithubAgentId | null {
67
84
  if (typeof login !== 'string') return typeof name === 'string' ? byName.get(name.trim().toLowerCase()) ?? null : null
68
85
  const known = byLogin.get(login.toLowerCase())
69
- return known && (account === null || known.ids.includes(undefined) || known.ids.includes(account)) ? known.agent : null
86
+ if (known && (account === null || known.ids.includes(undefined) || known.ids.includes(account))) return known.agent
87
+ return account === null ? null : byId.get(account) ?? null
70
88
  }
71
89
 
72
90
  // Whether the accounts `ids` a login is named by are all one agent's, as
@@ -0,0 +1,4 @@
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-VL43BTSO.js";import{$e as s,Da as c,Ea as l,Fa as u,Ga as d,Ha as f,Ie as p,Ja as m,Je as h,Ka as g,Ke as _,Le as v,Me as y,Ne as b,Od as x,Oe as ee,Pe as te,Qe as ne,Re as re,Se as ie,Te as ae,Ue as oe,Ve as se,We as ce,Xe as le,Ye as ue,Ze as de,_e as fe,af as pe,bb as me,cb as S,ef as he,pa as C,sa as ge,sc as _e,sf as ve,ta as ye,tf as be,ua as xe,w,wa as Se,xa as Ce,ya as we,za as Te}from"./chunk-S6U2J62U.js";import"./chunk-JCIIBLKR.js";import"./chunk-VH4XMZIW.js";import"./chunk-ZGNMDGSB.js";import{M as Ee}from"./chunk-NOZJULWS.js";import"./chunk-6ANSHRFQ.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as De}from"./chunk-5AHIQFFG.js";import"./chunk-I2MDGSQX.js";import"./chunk-WCPJDAYA.js";import"./chunk-IYPY47MC.js";import{a as T}from"./chunk-PWFUOLZK.js";import"./chunk-BC2UCLFJ.js";import"./chunk-SXV2T5C4.js";import{A as Oe,d as ke,e as Ae,f as je,g as Me,z as Ne}from"./chunk-WFYLMF6Z.js";import"./chunk-C4Z6ZBXV.js";import{c as E,d as D,g as O,j as Pe}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Fe=e=>e.committedAt??-1/0;function Ie(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)=>Fe(e)-Fe(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 Le(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 Re(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 ee=[];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 ee.push(t)}let te=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:te,color:b}),te=!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 ee)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))}}function ze(e,t,n,{ready:r,failed:i,settled:a=()=>{},retryMs:o,repaint:s}){let c=e.get(t);if(c&&Date.now()<c.until)return c;let l=c?.status===`ready`?c:null;if(l?.rereading)return l;let u=l??{status:`loading`,until:1/0};return l?l.rereading=!0:e.set(t,u),n().then(n=>{if(e.get(t)!==u||l&&Date.now()<l.until)return null;let i=r(n);return e.set(t,i),a(i),null},n=>{if(e.get(t)!==u)return null;if(l)return n?.name!==`AbortError`&&(l.until=Date.now()+o),null;let r=i(n);return r?e.set(t,r):e.delete(t),null}).finally(()=>{l&&(l.rereading=!1),s()}),u}var Be=12,k=24,Ve=9,He=8,Ue=3,We=`a[href], .history-commit`,Ge=3e5,Ke=15e3,qe=3e4,Je=25,Ye=new Map,Xe=new Set,Ze=null,Qe=`all`,$e=new Set;function A(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Ze&&(Ye.clear(),$e.clear(),Ze=e),Ye}var j=()=>{for(let e of Xe)e.requestUpdate()};function et(e,t,n=new Set){let r={status:`ready`,until:Date.now()+Ge,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,openPulls:e.openPulls,loadingMore:!1,moreError:null,sought:n};return t?.(r),r}function tt(e,t,n){return ze(A(),e,()=>t(1),{ready:e=>et(e,n),failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+qe,error:e?.message||`The history could not be read.`,code:e?.code??null},retryMs:qe,repaint:j})}function nt(e,t,n,r,i){let a=t.sought;t.sought=new Set(a).add(i),t.refreshing=!0,n(1,null,!0).then(n=>{if(A().get(e)!==t)return null;let o=t.retried===i?0:Math.min(Number(n.retryIn)||0,Ke),s=et(n,r,o>0?a:t.sought);return o>0&&(Object.assign(s,{retried:i,retryAt:Date.now()+o}),setTimeout(j,o)),A().set(e,s),null},()=>null).finally(()=>{t.refreshing=!1,j()})}function rt(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,Je).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function it(e,t,n,r){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+Ge,j(),n(t.page+1,t).then(n=>{if(A().get(e)!==t)return null;let i=new Set(t.commits.map(e=>e.sha));t.commits=[...t.commits,...n.commits.filter(e=>!i.has(e.sha))];let a=new Set(t.pulls.map(e=>e.merge));return t.pulls=[...t.pulls,...n.pulls.filter(e=>!a.has(e.merge))],t.page+=1,t.more=n.more===!0,r?.(t),t.until=Date.now()+Ge,null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More commits could not be read.`),null)).finally(()=>{t.loadingMore=!1,j()}))}var at=/^[a-f\d]{40}$/u,ot=e=>typeof e?.sha==`string`&&at.test(e.sha)&&Array.isArray(e.parents);function st(e){if(!Array.isArray(e?.commits))throw Error(`The server answered with no history.`);let t=e.commits.filter(ot),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&typeof e.sha==`string`&&at.test(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>typeof e?.merge==`string`&&at.test(e.merge)&&Number.isSafeInteger(e.number)&&typeof e.head==`string`&&at.test(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(ot)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.sha==`string`&&at.test(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function ct(e,t,n){let r=lt(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 lt(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 ut=6e4,dt=60*ut,ft=24*dt;function M(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-ut&&n<ut)return`now`;if(n>0&&n<dt)return`${Math.floor(n/ut)}m`;if(n>0&&n<ft)return`${Math.floor(n/dt)}h`;if(n>0&&n<7*ft)return`${Math.floor(n/ft)}d`;let r=new Date(e);return r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`}})}function pt({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}function mt(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),E`<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 N=e=>Ve+e*Be,ht=e=>e*k+k/2;function gt({row:e,from:t,to:n}){let[r,i,a,o]=[N(t),N(n),ht(e),ht(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 _t=({row:e,col:t,straight:n})=>n?`M${N(t)} ${ht(e)+6}v${k*.55}`:`M${N(t)+4} ${ht(e)+5}l${Be*.6} ${k*.5}`;function vt(e,t){let n=Array.from({length:He},()=>[]);for(let t of e.segments)n[t.color].push(gt(t));let r=Array.from({length:He},()=>[]);for(let t of e.stubs)r[t.color].push(_t(t));let i=Ve*2+(e.width-1)*Be;return E`<svg class="history-graph" width="${i}" height="${e.rows.length*k}" aria-hidden="true">${n.map((e,t)=>e.length>0?D`<path class=${`lane-${t}`} d=${e.join(``)}/>`:O)} ${r.map((e,t)=>e.length>0?D`<path class=${`history-stub lane-${t}`} d=${e.join(``)}/>`:O)} ${e.rows.map(({commit:e,col:n,color:r},i)=>D`<circle class=${`lane-${r}${e.sha===t?` is-shown`:``}`} cx=${N(n)} cy=${ht(i)}
2
+ r=${e.sha===t?4.5:e.parents.length>1?3:3.5}/>`)}</svg>`}function yt(e,t,n,r){if(!e?.length)return O;let i=e=>{let t=De({"history-ref":!0,[`is-${e.kind}`]:!0,"is-default":e.main===!0,"is-shown":e.kind===n.kind&&e.name===n.name}),i=E`${e.kind===`tag`?ke(Oe):e.kind===`pull`?ke(Ne):O}<span>${e.name}</span>`;return e.kind===`pull`&&r?E`<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>`:E`<span class="${t}">${i}</span>`},a=e.slice(Ue);return E`<span class="history-refs" style="${T({"--ref":`var(--lane-${t})`})}">${e.slice(0,Ue).map(i)}${a.length>0?E`<span class="history-ref is-more" data-tooltip="${a.map(e=>e.name).join(`, `)}">+${a.length}</span>`:O}</span>`}function bt(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)=>c(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 st(e)}),l=t===`path`?null:rt,u=tt(o,s,l);return a&&u.status===`ready`&&!u.refreshing&&!u.sought.has(r)&&!(u.retryAt>Date.now())&&!lt(u.commits,u.pulls??[]).some(e=>e.sha===r)&&nt(o,u,s,l,r),a&&u.status===`error`&&u.code===`github-token-required`?($e.add(n),bt(e,`revision`)):{mode:t,key:o,entry:u,more:()=>it(o,u,s,l)}}var xt=e=>bt(e,e.path?`path`:`revision`),St=e=>{Xe.add(e)},Ct=e=>{Xe.delete(e)};function wt(e){A().delete(e),j()}var Tt=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1},refs:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this.refs=null,this._drawn=null,this._moreButton=null,this._mode=null}connectedCallback(){super.connectedCallback(),Xe.add(this)}disconnectedCallback(){super.disconnectedCallback(),Xe.delete(this),this._moreButton&&S(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.history-more > button`);this._moreButton&&this._moreButton!==e&&S(this._moreButton),this._moreButton=e,e&&me(e,t=>{t&&this.readNear(e)})}readNear(e){e===this._moreButton&&e.isConnected&&!e.disabled&&!e.parentElement.querySelector(`[role=alert]`)&&this._mode!==`unmerged`&&e.click()}mode(){let{repoId:e,path:t}=this.repository;return t?`path`:(A(),$e.has(e)?`revision`:Qe)}history(e){return bt(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:Ie(e===`unmerged`?ct(t.commits,t.pulls??[],a):lt(t.commits,t.pulls??[])),s=e===`all`?a:e===`revision`?o[0]?.sha:null,c=Re(o,{linear:i,trunk:s&&!i?Le(o,s):null,colors:He});return this._drawn={commits:t.commits,pulls:t.pulls,mode:e,defaultBranch:n,layout:c},c}pick(e){Qe=e,j()}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`);ve({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(We)]:[],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(${We})`))e.tabIndex=e===s?0:-1;s.focus()}}render(){if(!this.repository)return O;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=$e.has(this.repository.repoId);return E`<div class="history-bar">${x(`commits`)} ${e===`path`?E`<span class="history-scope">Commits touching <code>${this.repository.path}</code></span>`:d?E`<span class="history-scope">Every branch needs your GitHub sign-in.</span>`:E`<div class="history-modes" role="group" aria-label="Branches"><button type="button" aria-pressed="${String(e===`all`)}" @click="${()=>this.pick(`all`)}">All branches</button> <button type="button" aria-pressed="${String(e===`unmerged`)}" @click="${()=>this.pick(`unmerged`)}">Unmerged</button></div>`} ${i?E`<span class="history-summary">${u}${l>0?` on ${l} branch${l===1?``:`es`}`:``}</span>`:O}</div>${i?this.renderCommits(e,n,r,o,a):n.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${n.error}</p><button type="button" @click="${()=>{A().delete(t),j()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading the history…</div>`}`}renderCommits(e,t,n,r,i){if(r.rows.length===0&&(e!==`unmerged`||!t.more&&!t.moreError))return E`<div class="bundles-slide-placeholder">${e===`unmerged`?`Every branch read is merged.`:`No commits.`}</div>`;let a=this.repository.commit,o=be(this.repository,this.refs),s=pt(t,i),c=Math.max(0,r.rows.findIndex(e=>e.commit.sha===a)),l=Ve*2+(r.width-1)*Be,u=this.repo??this.repository.repo,d=u?`https://github.com/${u.split(`/`).map(encodeURIComponent).join(`/`)}`:null;return E`<div class="history-scroll">${e===`all`&&!t.refreshing&&!(t.retryAt>Date.now())&&!r.rows.some(e=>e.commit.sha===a)?E`<p class="history-note"><code>${a.slice(0,7)}</code> isn’t among these commits.</p>`:O}<div class="history-lines" style="${T({"--history-graph":`${l}px`})}">${vt(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),l=e.sha.slice(0,7);return E`<li class="${De({"history-row":!0,"is-shown":e.sha===a})}">${d?E`<a class="history-sha" href="${`${d}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Commit ${l} on GitHub`}">${l}</a>`:E`<code class="history-sha">${l}</code>`} ${yt(r,t,o,d)} <span class="history-subject" id="${`history-subject-${e.sha}`}">${mt(e.subject||`(no message)`,d)}</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`:O}" @click="${()=>this.open(e,r)}"><span class="history-author">${Te(e.authorLogin,e.authorName,e.coauthors)}</span> ${i?E`<time class="history-time" datetime="${i.toISOString()}">${M(e.committedAt)}</time>`:E`<span class="history-time"></span>`}</button></li>`})}</ol></div>${t.cut?E`<p class="history-note">Only the first 5,000 branches by name are read.</p>`:O} ${t.more||t.moreError?E`<div class="history-more">${t.moreError?E`<span role="alert">${t.moreError}</span>`:O} <button type="button" ?disabled="${t.loadingMore}" @click="${n}">${t.loadingMore?`Reading…`:`Older commits`}</button></div>`:O}</div>`}};customElements.get(`repository-history`)||customElements.define(`repository-history`,Tt);function Et(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 Dt=e=>e.head&&e.fork?`${e.fork}:${e.head}`:e.head,Ot=e=>[...e.agents,...e.sessions.length>0||e.claude?[`claude`]:[],...e.tasks.length>0||e.codex?[`codex`]:[]],kt=new Set([`claude`,`codex`]);function At({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,Ot(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}=Et(e.name);n&&s(t,[n])}let u=new Map;for(let t of e){let e=Dt(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}=Et(t.head);n&&s(e,[n]);let i=Dt(t);if(t.signals.agents.length>0){i!==null&&u.get(i)===t.number&&a(e,`branch:${i}`);continue}i&&(n||Ot(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 jt=e=>(t,n)=>(e(t)??0)-(e(n)??0);function Mt({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(jt(e=>e.createdAt)),c=o(`commit:`).flatMap(e=>r.get(e)??[]).toSorted(jt(e=>e.at)),l=[...new Set([...o(`branch:`),...s.flatMap(e=>Dt(e)??[])])],u=[...new Set([...s.flatMap(e=>e.closes),...s.flatMap(e=>Et(e.head).issue??[]),...o(`branch:`).flatMap(e=>Et(e).issue??[])])].flatMap(e=>i.get(e)??[]).toSorted(jt(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(jt(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=>!kt.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 Nt(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 At(e).flatMap(e=>Mt(e,n)??[]).filter(e=>!r(e)).toSorted(jt(e=>e.updatedAt)).toReversed()}var Pt=3e5,Ft=/^[a-z][a-z\d-]{0,31}$/u,It=/^(?:app|user)-[1-9]\d{0,11}$/u,Lt=3e4,Rt=12,zt=new Map,Bt=new Set,Vt=null,Ht=`all`;function Ut(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Vt&&(zt.clear(),Vt=e),zt}var Wt=()=>{for(let e of Bt)e.requestUpdate()};function Gt(e){if(!Array.isArray(e?.pulls)||!Array.isArray(e.commits))throw Error(`The server answered with no pull requests or commits.`);let t=(Array.isArray(e.agents)?e.agents:[]).filter(e=>typeof e?.id==`string`&&Ft.test(e.id)&&![`claude`,`codex`,`all`].includes(e.id)&&typeof e.name==`string`&&e.name.trim()&&(e.avatar===void 0||typeof e.avatar==`string`&&It.test(e.avatar))).map(({id:e,name:t,avatar:n})=>[e,{id:e,name:t.trim().slice(0,64),avatar:n??null}]),n=e=>Array.isArray(e?.signals?.sessions)&&Array.isArray(e.signals.tasks),r=e=>({...e,signals:{...e.signals,agents:Array.isArray(e.signals.agents)?e.signals.agents.filter(e=>typeof e==`string`&&Ft.test(e)&&![`claude`,`codex`,`all`].includes(e)):[]}});return{pulls:e.pulls.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`&&Array.isArray(e.closes)&&n(e)).map(r),commits:e.commits.filter(e=>typeof e?.oid==`string`&&/^[a-f\d]{40}$/u.test(e.oid)&&n(e)).map(r),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`&&n(e)).map(r):[],agents:[...new Map(t).values()],more:e.more===!0,after:e.more===!0?{pulls:e.after?.pulls??null,commits:e.after?.commits??null}:null}}var Kt=e=>Object.assign(e,{sessions:Nt(e,{branchesSince:e.after?.pulls?Math.min(...e.pulls.map(e=>e.updatedAt??1/0)):null})});function qt(e,t){return ze(Ut(),e,()=>t(null).then(e=>(de(e.agents),e)),{ready:e=>Kt({status:`ready`,until:Date.now()+Pt,...e,loadingMore:!1,moreError:null}),failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+Lt,error:e?.message||`The agents' work could not be read.`},retryMs:Lt,repaint:Wt})}function Jt(e,t,n){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+Pt,Wt(),n(t.after).then(n=>{if(Ut().get(e)!==t)return null;let r=new Set(t.pulls.map(e=>e.number)),i=new Set(t.commits.map(e=>e.oid));t.pulls=[...t.pulls,...n.pulls.filter(e=>!r.has(e.number))],t.commits=[...t.commits,...n.commits.filter(e=>!i.has(e.oid))],t.more=n.more,t.after=n.after,t.until=Date.now()+Pt;let a=t.sessions.length;return Kt(t),t.stalled=t.sessions.length<=a,null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More could not be read.`),null)).finally(()=>{t.loadingMore=!1,Wt()}))}function Yt(e,t,n){let r=n.trim().toLowerCase().split(/\s+/u).filter(Boolean);return e.filter(e=>{if(t!==`all`&&!e.agents.includes(t))return!1;if(r.length===0)return!0;let n=[e.title,...e.authors,...e.authors.map(ye),...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])].join(`
3
+ `).toLowerCase();return r.every(e=>n.includes(e))})}var Xt={open:`open`,merged:`merged`,closed:`closed`,branch:`draft`},Zt=e=>(e.agents??[]).map(e=>e.id).filter(t=>(e.sessions??[]).some(e=>e.agents.includes(t))),Qt=e=>[`claude`,`codex`,...Zt(e)],$t=[[`pulls`,oe,`pull request`,`pull requests`],[`branches`,se,`branch`,`branches`],[`commits`,ce,`commit to the default branch without a pull request`,`commits to the default branch without a pull request`]];function en(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 tn(e,t,n){let r=2*Math.PI*9;return E`<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?D`<circle class="read-gauge-arc" cx="11" cy="11" r="9" transform="rotate(-90 11 11)" stroke-dasharray=${`${r*e/100} ${r}`}/>`:O}</svg> ${e===100?E`<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>`:E`<span class="read-gauge-value" aria-hidden="true">${e}%</span>`}</span>`}function nn(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 rn=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1},_filter:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this._filter=``,this._moreButton=null}connectedCallback(){super.connectedCallback(),Bt.add(this)}disconnectedCallback(){super.disconnectedCallback(),Bt.delete(this),this._moreButton&&S(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.issues-more > button`);this._moreButton&&this._moreButton!==e&&S(this._moreButton),this._moreButton=e,e&&me(e,t=>{t&&this.readNear(e)})}readNear(e){e===this._moreButton&&e.isConnected&&!e.disabled&&!this._filter.trim()&&!e.parentElement.querySelector(`[role=alert]`)&&!this.list().entry.stalled&&e.click()}list(){let{repoId:e}=this.repository,t=`${e}`,n=t=>d(e,t??{}).then(Gt),r=qt(t,n);return{key:t,entry:r,more:()=>Jt(t,r,n)}}pick(e){Ht=e,Wt()}render(){if(!this.repository)return O;let{key:e,entry:t,more:n}=this.list(),r=t.status===`ready`,i=r?t.sessions:[],a=e=>r?E`<span class="n">${(e===`all`?i:i.filter(t=>t.agents.includes(e))).length}${t.more?`+`:``}</span>`:O,o=Qt(t).includes(Ht)?Ht:`all`,c=Yt(i,o,this._filter);return E`<div class="history-bar issues-bar">${x(`agents`)}<div class="history-modes" role="group" aria-label="Agents"><button type="button" aria-pressed="${String(o===`all`)}" @click="${()=>this.pick(`all`)}">All${a(`all`)}</button> ${Qt(t).map(e=>E`<button type="button" class="${`agent-pick is-${e}`}" aria-pressed="${String(o===e)}" @click="${()=>this.pick(e)}">${s(e)}${fe(e)}${a(e)}</button>`)}</div><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):O} ${r?tn(en(t),`${t.pulls.length} pull request${t.pulls.length===1?``:`s`} read`,t.loadingMore):O}</div>${r?this.renderSessions(t,c,n,o):t.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${t.error}</p><button type="button" @click="${()=>{Ut().delete(e),Wt()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading what the agents did…</div>`}`}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 E`<span class="agent-totals">${[...Zt(e),`claude`,`codex`].filter(n).map(n=>{let r=nn(e.sessions,n);return E`<span class="agent-stats" role="group" aria-label="${fe(n)}"><span class="${`agent-mark is-${n}`}">${s(n)}</span> ${$t.filter(([e])=>r[e]>0).map(([e,n,i,a])=>{let o=`${r[e].toLocaleString(`en-US`)}${t[e]?`+`:``}`,s=`${o} ${r[e]===1&&!t[e]?i:a}`;return E`<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`:`${fe(r)} sessions`;return E`<div class="issues-scroll">${t.length>0?E`<ol class="issues-grid" aria-label="Sessions">${t.map(e=>this.renderSession(e))}</ol>`:E`<p class="history-note">${e.sessions.length>0&&this._filter.trim()?`None of the ${i} read match.`:`No ${i} among those read.`}</p>`} ${e.more||e.moreError?E`<div class="history-more issues-more">${e.moreError?E`<span role="alert">${e.moreError}</span>`:O} <button type="button" ?disabled="${e.loadingMore}" @click="${()=>{e.stalled=!1,n()}}">${e.loadingMore?`Reading…`:`More`}</button></div>`:O}</div>`}openSession(e,t){!pe(e)||e.target?.closest?.(`.agent-chip.is-commit`)||(e.preventDefault(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{session:t}}))}openItem(e,t,n){pe(e)&&(e.preventDefault(),e.stopPropagation(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{number:t,preview:n}}))}renderSession(e){let t=this.repo??this.repository.repo,n=he(e,t),r=e.updatedAt==null?null:new Date(e.updatedAt),i=e.authors.find(e=>!Se(e)),a=e.pulls.length+e.commits.length,o=a!==e.pulls.length+e.commits.length,c=r?E`<time datetime="${r.toISOString()}">${M(e.updatedAt)}</time>`:O,l=e.additions||e.deletions?E`<span class="issue-diff"><span class="is-added">+${e.additions.toLocaleString(`en-US`)}</span> <span class="is-deleted">−${e.deletions.toLocaleString(`en-US`)}</span></span>`:O,u=a===1,d=[i?E`<span class="issue-author">${xe(i)}</span>`:O,u?O:c,a===0?E`<span>no pull request</span>`:o?E`<span>${a} tasks</span>`:O,u?O:l].filter(e=>e!==O),f=[...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}`,E`<code>${e.oid.slice(0,7)}</code>`,null]),...e.issues.map(e=>[`is-issue is-${e.state===`open`?`open`:`merged`}`,`issues/${e.number}`,E`<span class="sr-only">Issue </span>#${e.number}`,{kind:`issues`,reason:null,...e}])];return E`<li class="${`issue-tile agent-tile is-${Xt[e.state]}`}"><div class="issue-body" @click="${t=>this.openSession(t,e)}"><span class="issue-rail">${e.agents.map(e=>E`<span class="${`agent-mark is-${e}`}" role="img" aria-label="${fe(e)}">${s(e)}</span>`)}</span> <span class="issue-lines">${n?E`<a class="issue-name" href="${n}" target="_blank" rel="noopener noreferrer">${e.title||`(no title)`}</a>`:E`<button type="button" class="issue-name">${e.title||`(no title)`}</button>`} ${d.length>0?E`<span class="issue-meta">${d}</span>`:O} ${f.length>0?E`<span class="agent-task-row"><span class="agent-chips">${f.slice(0,Rt).map(([e,n,r,i],a)=>E`<a class="${`agent-chip ${e}`}" href="${t?`https://github.com/${t}/${n}`:O}" target="_blank" rel="noopener noreferrer" @click="${i?e=>this.openItem(e,i.number,i):O}" data-rest="${a<f.length-1?f.length-1-a:O}">${r}</a>`)}</span>${u&&(c!==O||l!==O)?E`<span class="issue-meta">${c}${l}</span>`:O}</span>`:O} ${e.branches[0]?E`<span class="issue-branch"><code>${e.branches[0]}</code>${e.branches.length>1?E`<span>+${e.branches.length-1}</span>`:O}</span>`:O}</span></div></li>`}};customElements.get(`repository-agents`)||customElements.define(`repository-agents`,rn);var an=3e5,on=3e4,sn=1e3,cn=5,ln=5e3,un=12,P=864e5,F=7*P,dn=8,fn=3,pn=[[1,`Week`,`the week before`],[4,`Month`,`the month before`],[13,`Quarter`,`the quarter before`],[52,`Year`,`the year before`]],mn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],hn=[1,2,3,4,5,6,0],gn=6,_n=new Map,vn=new Map,yn=new Map,bn=new Map,xn=new Set,Sn=null,I=4,Cn={pulls:`merged`,issues:`closed`},wn={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:`]]]},Tn=[`merged`,`opened`,`closed`,`created`],En=te(D`<circle cx="8" cy="8" r="2.75"/><path d="M8 1v4.25M8 10.75V15"/>`),Dn={agent:`Commit with agents`,without:`Commit without agents`,release:`Release`},On=10,kn=10;function L(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Sn&&(_n.clear(),vn.clear(),yn.clear(),bn.clear(),Sn=e),_n}var R=()=>{for(let e of xn)e.requestUpdate()},z=e=>Number.isSafeInteger(e)&&e>=0?e:0,An=(e,t)=>({count:z(e?.[t]?.count),previous:Number.isSafeInteger(e?.[t]?.previous)?e[t].previous:null,items:Array.isArray(e?.[t]?.items)?e[t].items.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`):[]});function jn(e){if(!Number.isSafeInteger(e?.since)||!pn.some(([t])=>t===e.weeks))throw Error(`The server answered with no period.`);let t=t=>An(e,t),n=e=>Array.isArray(e)&&e.length===7&&e.every(Array.isArray)?e.map(([e,t])=>[z(e),z(t)]):null,r=e=>Array.isArray(e)&&e.length===7?e.map(z):null,i=Array.isArray(e.stats?.weeks)?e.stats.weeks.filter(e=>Number.isSafeInteger(e?.week)&&Array.isArray(e.days)).map(e=>({...e,dayLines:n(e.dayLines),agentDays:r(e.agentDays),releaseDays:r(e.releaseDays),directDays:r(e.directDays)})):[],a=e.stats&&Array.isArray(e.stats.weeks)&&Array.isArray(e.stats.contributors)&&Array.isArray(e.stats.punch)?{weeks:i,contributors:e.stats.contributors.filter(e=>(typeof e?.login==`string`||typeof e?.name==`string`)&&Array.isArray(e.weeks)).map(e=>({login:typeof e.login==`string`?e.login:null,id:Number.isSafeInteger(e.id)?e.id:null,name:typeof e.name==`string`?e.name:null,weeks:e.weeks,days:Array.isArray(e.days)?e.days:null})),punch:hn.map(t=>Array.from({length:24},(n,r)=>z(e.stats.punch[t]?.[r]))),periodPunch:e.stats.periodPunch===!0,lines:typeof e.stats.lines==`boolean`?e.stats.lines:null,agents:i.length>0&&i.every(e=>e.agentDays!==null),releases:i.length>0&&i.every(e=>e.releaseDays!==null),direct:i.length>0&&i.every(e=>e.directDays!==null)&&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:typeof e.subject==`string`?e.subject:``,login:typeof e.login==`string`?e.login:null,id:Number.isSafeInteger(e.id)?e.id:null,name:typeof e.name==`string`?e.name:null,kind:typeof e.kind==`string`&&Object.hasOwn(Dn,e.kind)?e.kind:null})):[]}:null;return{weeks:e.weeks,since:e.since,merged:t(`merged`),opened:t(`opened`),closed:t(`closed`),created:t(`created`),stats:a,reading:Number.isSafeInteger(e.reading)?e.reading:null,pulls:Number.isSafeInteger(e.pulls)?e.pulls:null,pending:e.pending===!0}}function Mn(e,t){yn.set(e,t),t.answer.stats&&bn.set(e,t.answer)}var B=e=>e.reading??e.pulls,Nn=e=>B(e)===null?e.pending?[ln,un]:null:[sn,cn];function Pn(e,t){let n=`${e}\0${t}`;return ze(L(),n,()=>m(e,t).then(jn),{ready:e=>({status:`ready`,until:Date.now()+an,answer:e,tries:0,asking:!1}),settled:r=>{Mn(e,r),Nn(r.answer)&&Fn(n,r,e,t,Nn(r.answer)[0])},failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+on,error:e?.message||`The repository’s pulse could not be read.`},retryMs:on,repaint:R})}function Fn(e,t,n,r,i){t.asking=!0,setTimeout(()=>{L().get(e)===t&&m(n,r).then(jn).then(i=>{if(L().get(e)!==t)return null;let a=B(i)!==null&&B(t.answer)!==null&&B(i)>B(t.answer);t.answer=i,t.until=Date.now()+an,t.tries=a?0:t.tries+1;let o=Nn(i);return o&&t.tries<o[1]?Fn(e,t,n,r,o[0]):t.asking=!1,null},()=>(t.asking=!1,null)).finally(R)},i)}function In(e,t,n){return L(),ze(vn,[e,t,n.from,n.to??``,n.authors.join(`,`)].join(`\0`),()=>g(e,t,n),{ready:e=>({status:`ready`,until:Date.now()+an,answer:Object.fromEntries(Tn.map(t=>[t,An(e,t)]))}),failed:e=>({status:`error`,until:Date.now()+on,error:e?.message||`These couldn’t be read.`}),retryMs:on,repaint:R})}var Ln=e=>e.agents===!0&&e.weeks.some(e=>e.agentDays.some(e=>e>0)),Rn=e=>e.releases===!0&&e.weeks.some(e=>e.releaseDays.some(e=>e>0)),V=(e,t,n,r=`days`)=>e.reduce((e,i)=>e+i[r].reduce((e,r,a)=>{let o=i.week+a*P;return o>=t&&o<=n?e+z(r):e},0),0);function zn(e,t=Date.now()){let n=Math.floor(t/P)*P;return n-new Date(n).getUTCDay()*P-(e-1)*F}function Bn(e,t,n,r=Date.now()){return{weeks:n,since:e?.since??zn(n,r),merged:e?.merged??null,opened:e?.opened??null,closed:e?.closed??null,created:e?.created??null,stats:{...t.stats,otherPunch:t.weeks!==n},reading:e?.reading??null,pulls:e?.pulls??null,pending:e?.pending??!1}}function Vn(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=Math.floor(t/P)*P,a=e.weeks*F,o=n.weeks.filter(e=>e.week>=r),s=n.weeks.length>0&&n.weeks[0].week<=r-a,c=e=>n.lines===!0?o.reduce((t,n)=>t+z(n[e]),0):null;return{commits:V(n.weeks,r,i),previous:s?V(n.weeks,r-a,i-a):null,agents:n.agents?V(n.weeks,r,i,`agentDays`):null,previousAgents:n.agents&&s?V(n.weeks,r-a,i-a,`agentDays`):null,releases:n.releases?V(n.weeks,r,i,`releaseDays`):null,previousReleases:n.releases&&s?V(n.weeks,r-a,i-a,`releaseDays`):null,additions:c(`additions`),deletions:c(`deletions`),authors:Un(n.contributors,r).length}}function Hn({id:e=null,login:t,name:n}){let r=Se(t,n);if(r)return`agent:${r}`;let i=ge(t)?.id;return i==null?e===null?t?`@${t.toLowerCase()}`:`=${n}`:`#${e}`:`user:${i}`}function Un(e,t,n=1/0){let r=new Map;for(let i of e){let{login:e,name:a}=i,o=Hn(i);r.set(o,(i.days??i.weeks).reduce((e,[r,i,a,o])=>r>=t&&r<n?{...e,commits:e.commits+z(i),additions:e.additions+z(a),deletions:e.deletions+z(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 Wn(e,t){let n=e.contributors.filter(e=>Hn(e)===t),r=n.length>0&&n.every(e=>e.days),i=e.weeks.map(({week:e})=>({week:e,days:Array.from({length:7},()=>0),dayLines:Array.from({length:7},()=>[0,0]),agentDays:Array.from({length:7},()=>0),releaseDays:Array.from({length:7},()=>0),directDays:Array.from({length:7},()=>0),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))/F)];if(!n||(n.commits+=z(t),n.additions+=z(a),n.deletions+=z(o),!r))continue;let u=Math.floor((e-n.week)/P);n.days[u]+=z(t),n.dayLines[u]=[n.dayLines[u][0]+z(a),n.dayLines[u][1]+z(o)],n.agentDays[u]+=z(s),n.releaseDays[u]+=z(c),n.directDays[u]+=z(l)}let a=e.agents===!0&&r&&n.every(e=>e.days.every(e=>e.length>4)),o=e.releases===!0&&r&&n.every(e=>e.days.every(e=>e.length>5)),s=e.direct===!0&&r&&n.every(e=>e.days.every(e=>e.length>6));return{...e,weeks:i,agents:a,releases:o,direct:s,byDays:r}}function Gn(e,t,n,r=null,i=Date.now()){let a=r===null?e:Wn(e,r);if(!e?.direct||!a.direct)return null;let o=Math.min(n-P,Math.floor(i/P)*P),s=e.directCommits.filter(e=>e.at>=t&&e.at<o+P&&(r===null||Hn(e)===r));return{count:V(a.weeks,t,o,`directDays`),items:s}}function Kn(e,t=Date.now()){let{stats:n,since:r,weeks:i}=e,a=n.lines===!0;if(i>4)return n.weeks.filter(e=>e.week>=r).map(e=>({from:e.week,to:e.week+F,day:!1,commits:z(e.commits),agents:n.agents?e.agentDays.reduce((e,t)=>e+t,0):null,releases:n.releases?e.releaseDays.reduce((e,t)=>e+t,0):null,additions:a?z(e.additions):null,deletions:a?z(e.deletions):null,future:!1}));let o=Math.floor(t/P)*P;return Array.from({length:i*7},(e,t)=>{let i=r+t*P,s=n.weeks.find(e=>i>=e.week&&i<e.week+F),c=s?Math.floor((i-s.week)/P):0,l=a?s?.dayLines?.[c]??null:null;return{from:i,to:i+P,day:!0,commits:z(s?.days[c]),agents:n.agents?z(s?.agentDays[c]):null,releases:n.releases?z(s?.releaseDays[c]):null,additions:l?.[0]??null,deletions:l?.[1]??null,future:i>o}})}function qn(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()*P;return[n,n+F,!0]}function Jn(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 H=e=>e.toLocaleString(`en-US`),Yn=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),U=e=>Yn.format(e),W=(e,t,n=`${t}s`)=>`${H(e)} ${e===1?t:n}`,G=(e,t=!1)=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...t?{year:`numeric`}:{},timeZone:`UTC`}),Xn=e=>new Date(e).toISOString().slice(0,10),Zn=(e,t)=>new Date(e).getUTCFullYear()!==new Date(t).getUTCFullYear(),Qn=(e,t)=>{let n=Math.floor(t/P)*P,r=Zn(e,n);return e>=n?G(n,r):`${G(e,r)} \u2013 ${G(n,r)}`},K=(e,t)=>e.day?new Date(e.from).toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`,...Zn(e.from,t)?{year:`numeric`}:{},timeZone:`UTC`}):`Week of ${G(e.from,Zn(e.from,t))}`,$n=(e,t,n={})=>`${K(e,t)}: ${W(e.commits,`commit`)}${n.agents?`, ${H(e.agents)} with agents`:``}${n.releases?`, ${W(e.releases,`release`)}`:``}${e.additions===null?``:`, +${H(e.additions)} \u2212${H(e.deletions)} lines`}`;function er(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?G(e[t].from):``;if(n===13)return t%2==0?G(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 tr=(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 ${H(t)} ${n}`,nr=(e,t)=>e===0?0:e===t?100:Math.min(99,Math.max(1,Math.round(e/t*100)));function rr(e,t=!1){let[n,r]=t?[`latest `,`: the year shown is as it was before.`]:[``,`.`];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 the pull requests merged in this repository\u2026 ${H(e.pulls)} so far`,`${H(e.pulls)} of the pull requests merged in this repository read so far${r}`,`Read on`]:[`Reading this repository\u2019s ${n}commits\u2026 ${H(e.reading)} of the last year so far`,`${H(e.reading)} of this repository\u2019s commits of the last year read so far${r}`,`Read on`]}var ir=(e,t,n)=>e===t?`Same as ${n}`:`${e>t?`↑`:`↓`} from ${t}% ${n}`,ar=E`<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>`,or=e=>e.endsWith(`[bot]`)?`https://github.com/apps/${encodeURIComponent(e.slice(0,-5))}`:`https://github.com/${encodeURIComponent(e)}`,sr=e=>e.login?Ce(e.login,e.name,e.login):Ce(null,e.name),cr=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1},_column:{state:!0},_typed:{state:!0},_picked:{state:!0},_everyone:{state:!0},_person:{state:!0},_allDirect:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this._column=null,this._typed=!1,this._picked=null,this._everyone=!1,this._person=null,this._allDirect=!1}connectedCallback(){super.connectedCallback(),xn.add(this)}disconnectedCallback(){super.disconnectedCallback(),xn.delete(this)}willUpdate(e){!e.has(`repository`)||e.get(`repository`)?.repoId===this.repository?.repoId||(this._column=null,this._picked=null,this._everyone=!1,this._person=null,this._allDirect=!1)}pick(e){I=e,this._column=null,this._picked=null,this._everyone=!1,this._allDirect=!1,R()}showList(e,t){Cn[e]=t,R()}askAgain(){let{repoId:e}=this.repository,t=`${e}\0${I}`,n=L().get(t);n?.status!==`ready`||n.asking||(n.tries=0,Fn(t,n,e,I,0),R())}render(){if(!this.repository)return O;let{repoId:e}=this.repository,t=Pn(e,I);t.status===`ready`&&Mn(e,t);let n=Date.now(),r=t.status===`ready`?t.answer:null,i=bn.get(e),a=r?.stats?r:i&&t.status!==`error`?Bn(r,i,I,n):r,o=!a&&t.status===`loading`?yn.get(e)??null:null,s=a?{answer:a,asking:t.asking===!0}:o,c=s?.answer.stats&&(B(s.answer)!==null||s.answer.pending);return E`<div class="history-bar">${x(`pulse`)}<div class="history-modes" role="group" aria-label="Period">${pn.map(([e,t])=>E`<button type="button" aria-pressed="${String(I===e)}" @click="${()=>this.pick(e)}">${t}</button>`)}</div>${s?E`<span class="pulse-range">${Qn(s.answer.since,n)}</span>`:O} ${c?E`<span class="pulse-updating" role="status">${this.renderWaiting(s,rr(s.answer,!0))}</span>`:O}</div>${s?E`<div class="${`pulse-scroll${o?` is-reading`:``}`}" aria-busy="${String(t.status!==`ready`)}">${this.renderPulse(s,n)}</div>`:t.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${t.error}</p><button type="button" @click="${()=>{L().delete(`${e}\0${I}`),R()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading the repository’s pulse…</div>`}`}renderPulse(e,t){let{answer:n}=e,r=pn.find(([e])=>e===n.weeks)[2],i=Vn(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,H(n[t].count),tr(n[t].count,n[t].previous,r),`${H(n[i].count)} opened`):this.renderTile(e,`–`,`Reading…`,``),l=this.renderLists(n,a,t);return E`<section class="pulse-tiles" aria-label="Figures">${this.renderTile(`Commits`,i.commits===null?`–`:H(i.commits),o??tr(i.commits,i.previous,r),`to the default branch`)} ${this.renderTile(`Contributors`,i.authors===null?`–`:H(i.authors),o,`who made them`)} ${c(`Pull requests merged`,`merged`,`opened`)} ${c(`Issues closed`,`closed`,`created`)} ${n.stats?.lines===!1?O:this.renderTile(`Lines`,i.additions===null?`–`:E`<span class="is-added">+${H(i.additions)}</span> <span class="is-removed">−${H(i.deletions)}</span>`,s,`added and removed`,i.additions===null?O:this.renderRatio(i.additions,i.deletions))} ${i.agents===null||!Ln(n.stats)?O:this.renderAgentsTile(i,r)}</section><div class="${`pulse-grid${l.length>2?` is-lists`:``}`}">${n.stats?E`${this.renderActivity(e,t)}${this.renderContributors(n,t)}`:E`<div class="pulse-pending pulse-wide" role="status">${this.renderWaiting(e,rr(n))}</div>`} ${l} ${n.stats?this.renderPunch(n.stats):O}</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?`, ${W(e.releases,`release`)} apart`:``;return this.renderTile(E`<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?`–`:`${nr(e.agents,n)}%`,e.previousAgents===null||n===0||!r?null:ir(nr(e.agents,n),nr(e.previousAgents,r),t),n===0?`no commits${i}`:`${H(e.agents)} of ${W(n,`commit`)}${i}`)}renderWaiting(e,[t,n,r]){return e.asking?t:E`${n} <button type="button" class="history-link" @click="${()=>this.askAgain()}">${r}</button>`}renderTile(e,t,n,r,i=O){return E`<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?E`<span class="pulse-tile-note">${r}</span>`:O}</div>`}renderRatio(e,t){return e+t===0?O:E`<span class="pulse-ratio" aria-hidden="true">${[[`is-added`,e],[`is-removed`,t]].map(([n,r])=>r>0?E`<span class="${n}" style="${T({"--share":`${r/(e+t)}`})}"></span>`:O)}</span>`}renderActivity(e,t){let{answer:n}=e,r=this._person===null?null:n.stats.contributors.find(e=>Hn(e)===this._person)??null,i=r?Wn(n.stats,this._person):n.stats,a=Kn({...n,stats:i},t),o=a[0]?.day?`day`:`week`,s=r?we(r.login,r.name):null,c=r?E`<span>a ${o} by</span><button type="button" class="pulse-picked is-person" aria-label="${`${s}\u2019s: show everyone\u2019s`}" @click="${()=>this.showPerson(null)}">${sr(r)}<span aria-hidden="true">×</span></button>`:E`<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 E`<figure class="pulse-panel pulse-activity"><figcaption class="pulse-head"><h3>Commits</h3>${c}</figcaption><p class="pulse-note">${l}</p></figure>`;let u=Jn(Math.max(...a.map(e=>e.commits))),d=i.lines===!0&&a.every(e=>e.additions!==null)?Jn(Math.max(...a.flatMap(e=>[e.additions,e.deletions]))):null,f={agents:Ln(n.stats)&&a.some(e=>e.agents!==null),releases:Rn(n.stats)&&a.some(e=>e.releases!==null)},p=f.agents||f.releases,m=n.weeks===1,h=Math.floor(t/P)*P,g=a[this._column]&&!a[this._column].future?this._column:null,_=a.findIndex(e=>e.from===this._picked),v=(e,r,i,o)=>E`<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`:O}" aria-label="${i?$n(e,t,f):O}" aria-hidden="${i?O:`true`}" @pointerenter="${()=>this.point(e.future?null:r)}" @click="${()=>this.pickColumn(a,r)}">${o}</span>`,y=(e,t)=>m&&!e.future?E`<span class="pulse-figure">${t}</span>`:O,b=(e,t,n=O)=>E`<span class="${`pulse-bar${e}`}" style="${T({"--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?E`<span class="${`pulse-part${e}`}" style="${T({"--part":`${t}`})}"></span>`:O)};return E`<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?E`<span class="pulse-legend">${f.agents?E`<span class="pulse-key"></span>With agents<span class="pulse-key is-without"></span>Without`:O}${f.releases?E`<span class="pulse-key is-release"></span>Releases`:O}</span>`:O}</figcaption><div class="pulse-plots" @pointerleave="${()=>this.point(null)}"><div class="pulse-plot">${this.renderTicks(u.ticks.map(e=>[e/u.top,U(e),e===0]))}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!0,E`${y(e,H(e.commits))}${p?b(` is-split`,e.commits/u.top,x(e)):b(``,e.commits/u.top)}`))}</div></div>${d?E`<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,`+${U(d.top)}`],[.5,`0`,!0],[0,`\u2212${U(d.top)}`]])}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!1,E`<span class="pulse-half">${y(e,`+${U(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${U(e.deletions)}`)}</span>`))}</div></div>`:i.lines===!1?E`<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?E`<p class="pulse-note">GitHub counts this repository’s lines a week, not a day: the quarter and the year show them.</p>`:E`<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)=>E`<span class="${e.future?`is-future`:e.day&&e.from===h?`is-today`:``}">${er(a,t,n.weeks)}</span>`)}</div>${g===null?O:this.renderTip(n,a,g,t,f,!r)}</div><span class="sr-only" aria-live="polite">${this._typed&&g!==null?$n(a[g],t,f):``}</span></figure>`}renderTip(e,t,n,r,i,a){let o=t[n],s=Math.floor(r/P)*P,[c,l,u]=qn(o,e.stats.contributors),d=a?Un(e.stats.contributors,c,l).slice(0,fn):[],f=(n+.5)/t.length;return E`<div class="${`pulse-tip${f>.6?` is-left`:``}`}" style="${T({"--x":`${f}`})}" aria-hidden="true"><span class="pulse-tip-when">${K(o,r)}${o.day?o.from===s?E`<span>today</span>`:O:r<o.to?E`<span>so far</span>`:O}</span> <span class="pulse-tip-row"><span class="${`pulse-tip-key${i.agents||i.releases?` is-none`:``}`}"></span><strong>${H(o.commits)}</strong> ${o.commits===1?`commit`:`commits`}</span> ${i.agents?E`<span class="pulse-tip-row"><span class="pulse-tip-key"></span><strong>${H(o.agents)}</strong> with agents</span>`:O} ${i.releases?E`<span class="pulse-tip-row"><span class="pulse-tip-key is-release"></span><strong>${H(o.releases)}</strong> ${o.releases===1?`release`:`releases`}</span>`:O} ${o.additions===null?O:E`<span class="pulse-tip-row"><span class="pulse-tip-key is-added"></span><strong>+${H(o.additions)}</strong> added</span> <span class="pulse-tip-row"><span class="pulse-tip-key is-removed"></span><strong>−${H(o.deletions)}</strong> removed</span>`} ${d.length>0?E`<span class="pulse-tip-people">${u?E`<span class="pulse-tip-note">Its week’s</span>`:O} ${d.map(e=>E`<span class="pulse-tip-person">${sr(e)}<strong>${H(e.commits)}</strong></span>`)}</span>`:O}</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 E`<div class="pulse-ticks" aria-hidden="true">${e.map(([e,t,n])=>E`<span class="${n?`is-zero`:O}" style="${T({"--at":`${e}`})}"><span>${t}</span></span>`)}</div>`}renderContributors(e,t){let{contributors:n}=e.stats,r=Kn(e,t).find(e=>e.from===this._picked)??null,[i,a,o]=r?qn(r,n):[e.since,1/0,!1],s=Un(n,i,a),c=s[0]?.commits??1,l=e.stats.lines===!0,u=r?o?`Week of ${G(i,Zn(i,t))}`:K(r,t):null;return E`<figure class="pulse-panel pulse-people"><figcaption class="pulse-head"><h3>Contributors</h3>${u?E`<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>`:E`<span>by their commits in the period</span>`}</figcaption>${s.length===0?E`<p class="pulse-note">No commits ${r?o||!r.day?`that week`:`that day`:`in the period`}.</p>`:E`<ol class="${`pulse-ranks${this._person===null?``:` is-picking`}`}">${(this._everyone?s:s.slice(0,dn)).map(e=>E`<li class="${e.key===this._person?`is-person`:O}"><span class="pulse-rank-who"><button type="button" class="pulse-rank-name" aria-pressed="${String(e.key===this._person)}" @click="${()=>this.showPerson(e.key)}">${sr(e)}</button> ${e.login?E`<a class="pulse-rank-profile" href="${or(e.login)}" target="_blank" rel="noopener noreferrer" aria-label="${`${we(e.login,e.name)} on GitHub`}">${ar}</a>`:O}</span> <span class="pulse-rank-bar"><span style="${T({"--value":`${e.commits/c}`})}"></span><span class="pulse-rank-value">${H(e.commits)}</span></span> ${l?E`<span class="pulse-rank-lines"><span class="is-added">+${U(e.additions)}</span> <span class="is-removed">−${U(e.deletions)}</span></span>`:O}</li>`)}</ol>${s.length>dn?E`<button type="button" class="history-link pulse-more" @click="${()=>{this._everyone=!this._everyone}}">${this._everyone?`Fewer`:`and ${W(s.length-dn,`more`,`more`)}`}</button>`:O}`}</figure>`}renderPunch(e){let{punch:t}=e,n=Math.max(1,...t.flat());return E`<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)=>E`<span class="pulse-punch-day">${mn[hn[t]].slice(0,3)}</span>${e.map((e,r)=>{let i=`${mn[hn[t]]}s, ${String(r).padStart(2,`0`)}:00\u2013${String(r+1).padStart(2,`0`)}:00: ${W(e,`commit`)}`;return E`<span class="${`pulse-cell is-${e===0?0:Math.ceil(e/n*gn)}`}" role="img" aria-label="${i}" data-tooltip="${i}"></span>`})}`)} <span></span>${Array.from({length:24},(e,t)=>E`<span class="pulse-punch-hour">${t%6==0?`${t}h`:``}</span>`)}</div><div class="pulse-scale" aria-hidden="true">Fewer${Array.from({length:gn},(e,t)=>E`<span class="${`pulse-cell is-${t+1}`}"></span>`)}More</div></figure>`}renderLists(e,t,n){let r=e.stats?Gn(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?Gn(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,r=t?.who?we(t.who.login,t.who.name):null,i=t?[r&&`by ${r}`,t.when].filter(Boolean).join(` `):``,a=t?[r&&`by ${r}`,t.when??`in the period`].filter(Boolean).join(` `):`in the period`,o=this._allDirect?e.items:e.items.slice(0,On),s=Math.max(0,e.count-e.items.length);return E`<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?E`<span class="pulse-narrowed">${i}</span>`:O}<span class="pulse-count">${H(e.count)}</span></div>${e.count===0?E`<p class="pulse-note">None ${a}.</p>`:E`<ol>${o.map(e=>E`<li><a class="${`pulse-item is-commit${e.kind?` is-${e.kind}`:``}`}" href="${n?`https://github.com/${n}/commit/${e.sha}`:O}" target="_blank" rel="noopener noreferrer"><span class="issue-state" role="img" aria-label="${e.kind?Dn[e.kind]:`Commit`}">${En}</span> <span class="pulse-item-title">${e.subject||`(no message)`}</span> <span class="pulse-item-meta"><span>${e.sha.slice(0,7)}</span><span>${sr(e)}</span><time datetime="${new Date(e.at).toISOString()}">${M(e.at)}</time></span></a></li>`)}</ol>`} ${e.items.length>On?E`<button type="button" class="history-link pulse-more" @click="${()=>{this._allDirect=!this._allDirect}}">${this._allDirect?`Fewer`:`and ${W(e.items.length-On,`more`,`more`)}`}</button>`:O} ${s>0?E`<p class="pulse-note">${e.items.length>0?W(s,`older commit`,`older commits`):W(s,`commit`)} not listed.</p>`:O}</section>`}narrowing(e,t){let n=this._picked===null||!e.stats?null:Kn(e,t).find(e=>e.from===this._picked)??null,r=this._person===null||!e.stats?null:e.stats.contributors.filter(e=>Hn(e)===this._person);if(!n&&!r)return null;let i=[...new Set((r??[]).flatMap(e=>e.login?[e.login]:[]))].slice(0,kn);return{from:Xn(n?.from??e.since),to:n?Xn(n.to-P):null,authors:i,nobody:r!==null&&i.length===0,who:r?.[0]??null,when:n?n.day?`on ${K(n,t)}`:`in the w${K(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]=wn[t],[a,,o]=i.find(([e])=>e===Cn[t]),s=n&&!n.nobody?In(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}`:`>=${Xn(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,h=n?.who?we(n.who.login,n.who.name):null,g=n?[h&&`by ${h}`,n.when??`in the period`].filter(Boolean).join(` `):`in the period`,_=n?[h&&`by ${h}`,n.when].filter(Boolean).join(` `):``;return E`<section class="pulse-panel pulse-list" aria-label="${r}"><div class="pulse-head"><h3>${r}</h3>${n?E`<span class="pulse-narrowed">${_}</span>`:O}<div class="history-modes" role="group" aria-label="${`${r} shown`}">${i.map(([e,n])=>E`<button type="button" aria-pressed="${String(e===a)}" @click="${()=>this.showList(t,e)}">${n}<span class="n">${c?.[e]?H(c[e].count):`–`}</span></button>`)}</div></div>${n?.nobody?E`<p class="pulse-note">${h}’s commits name no GitHub account to find their ${r.toLowerCase()} by.</p>`:s?.status===`error`?E`<p class="pulse-note" role="alert">${s.error}</p>`:u===null?E`<p class="pulse-note" role="status">Reading…</p>`:u.length===0?E`<p class="pulse-note">None ${g}.</p>`:E`<ol>${u.map(e=>{let[n,r]=ue(t,e);return E`<li><a class="${`pulse-item is-${n}`}" href="${d?`https://github.com/${d}/${t===`pulls`?`pull`:`issues`}/${e.number}`:O}" target="_blank" rel="noopener noreferrer" @click="${n=>this.openItem(n,t,e)}"><span class="issue-state" role="img" aria-label="${r}">${ne[t][n]}</span> <span class="pulse-item-title">${e.title||`(no title)`}</span> <span class="pulse-item-meta"><span>#${e.number}</span>${e.author?E`<span>${xe(e.author)}</span>`:O} ${e.at==null?O:E`<time datetime="${new Date(e.at).toISOString()}">${M(e.at)}</time>`}</span></a></li>`})}</ol>`} ${m&&u!==null&&l>u.length?E`<a class="pulse-all" href="${m}" target="_blank" rel="noopener noreferrer">All ${H(l)} on GitHub</a>`:O}</section>`}openItem(e,t,n){pe(e)&&(e.preventDefault(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{number:n.number,preview:{...n,kind:t,labels:[],comments:0}}}))}};customElements.get(`repository-pulse`)||customElements.define(`repository-pulse`,cr);var lr=864e5,ur=[100,300,1e3];function dr(e,t){return Ie(e).filter(e=>e.parents.length<=1&&Number.isFinite(e.committedAt)).slice(0,t).toReversed()}var fr=1,pr=.08,mr=.6;function hr(e){let t=[];for(let[n,r]of e.entries()){let i=n===0?0:(r.committedAt-e[n-1].committedAt)/lr;t.push(n===0?0:t[n-1]+Math.min(mr,Math.max(pr,i*fr)))}return t}function gr(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function _r(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 vr=.9,yr=2,br=1,xr=5,Sr=1,Cr=.06;function wr(){let e=Tr(``,null);return{root:e,dirs:new Map([[``,e]]),files:new Map,going:new Set,users:new Map,beams:[],due:[],layout:!0}}function Tr(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}}function Er(e,t){let n=e.dirs.get(t);if(n)return n;let r=t.lastIndexOf(`/`),i=Er(e,r===-1?``:t.slice(0,r)),a=Tr(t,i),[o,s]=[0,i.dirs.length];for(;o<s;){let e=o+s>>1;i.dirs[e].name<a.name?o=e+1:s=e}return i.dirs.splice(o,0,a),e.dirs.set(t,a),Ur(i),e.layout=!0,a}function Dr(e,t,n,r){let i=e.files.get(t);if(n===`D`&&!i)return null;if(!i){let a=t.lastIndexOf(`/`),o=Er(e,a===-1?``:t.slice(0,a));i={path:t,name:t.slice(a+1),extension:gr(t),dir:o,ox:0,oy:0,touched:r,kind:n,removed:null},o.files.push(i),e.files.set(t,i),Ur(o),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 Or(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);Ur(r),e.layout=!0}var kr=e=>e.flatMap(([e,t,n])=>t===`R`?[[n,`D`],[e,`A`]]:[[e,t]]);function Ar(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=kr(n),s=o.length>1?Math.min(Cr,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 jr(e,t){for(let[n,r]of kr(t)){let t=Dr(e,n,r,-1/0);t&&r===`D`&&Or(e,t)}}function Mr(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 Nr(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=Dr(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<vr);for(let n of[...e.going])t-n.removed>=br&&Or(e,n);for(let[n,r]of e.users)t-r.active>xr+Sr&&e.users.delete(n)}var Pr=6,Fr=2.2,Ir=12,Lr=Math.PI*(3-Math.sqrt(5)),Rr=46,zr=34,Br=e=>e===0?0:Pr*.62*Math.sqrt(e)+Fr;function Vr(e){let t=Pr*.62*Math.sqrt(e+.5);return[t*Math.cos(e*Lr),t*Math.sin(e*Lr)]}function Hr(e){Wr(e.root),Gr(e.root,-e.root.node[0],-e.root.node[1],0),e.layout=!1}function Ur(e){for(let t=e;t&&!t.dirty;t=t.parent)t.dirty=!0}function Wr(e){if(!e.dirty)return;for(let t of e.dirs)Wr(t);e.cluster=Math.max(Br(e.files.length),Fr)+Ir/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)ii(t,n);else{Kr([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=Zr([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 Gr(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);Gr(t,n,r,Math.atan2(r-e.ty,n-e.tx))}}function Kr(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;qr(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;e:for(let t=3;t<e.length;t++){let n=e[t];qr(i.c,a.c,n);let r=a.next,o=a.c.r,s=i.previous,c=i.c.r;do if(o<=c){if(Jr(r.c,n)){a=r,i.next=a,a.previous=i,t--;continue e}o+=r.c.r,r=r.next}else{if(Jr(s.c,n)){i=s,i.next=a,a.previous=i,t--;continue e}c+=s.c.r,s=s.previous}while(r!==s.next);let l={c:n,previous:i,next:a};i.next=a.previous=a=l;let u=Yr(i);for(let e=l.next;e!==a;e=e.next){let t=Yr(e);t<u&&([i,u]=[e,t])}a=i.next}}function qr(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;if(o>s){let t=(a+s-o)/(2*a),c=Math.sqrt(Math.max(0,s/a-t*t));[n.x,n.y]=[e.x-t*r-c*i,e.y-t*i+c*r]}else{let e=(a+o-s)/(2*a),c=Math.sqrt(Math.max(0,o/a-e*e));[n.x,n.y]=[t.x+e*r-c*i,t.y+e*i+c*r]}}var Jr=(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 Yr(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 Xr=64;function Zr(e){let t=e.toSorted((e,t)=>J(`${e.x},${e.y}`)-J(`${t.x},${t.y}`)),n=[],r=null,i=0;for(let a=0;a<t.length;a++)if(!(r&&ti(r,t[a]))){if(n=$r(n,t[a]),r=q(n),!Number.isFinite(r.x+r.y+r.r)||++i>Xr*t.length)return Qr(e);a=-1}return r}function Qr(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 $r(e,t){if(e.every(e=>ti(t,e)))return[t];for(let n of e)if(!ei(t,n)&&e.every(e=>ti(q([n,t]),e)))return[n,t];for(let[n,r]of e.entries())for(let i of e.slice(n+1))if(!ei(q([r,i]),t)&&!ei(q([r,t]),i)&&!ei(q([i,t]),r)&&e.every(e=>ti(q([r,i,t]),e)))return[r,i,t];return[...e,t].length<=3?[...e,t]:[t]}var ei=(e,t)=>e.r-t.r>=0&&(e.r-t.r)**2>=(t.x-e.x)**2+(t.y-e.y)**2;function ti(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 q([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 ni=60,ri=.5;function ii(e,t){let n=t.filter(e=>e.x!==void 0);for(let r of t)r.x===void 0&&(ai(r,e,n),n.push(r));for(let n=0;n<ni;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-ri)continue;let a=t>1e-6?Math.atan2(r.y,r.x):J(r.child.name);[r.x,r.y]=[Math.cos(a)*i,Math.sin(a)*i],n=!0}let r=t.toSorted((e,t)=>e.x-e.r-(t.x-t.r));for(let[e,t]of r.entries())for(let i=e+1;i<r.length&&r[i].x-r[i].r<t.x+t.r;i++){let e=r[i],a=t.r+e.r,[o,s]=[e.x-t.x,e.y-t.y];if(Math.abs(s)>=a-ri)continue;let c=Math.hypot(o,s);if(c>=a-ri)continue;let l=c>1e-6?Math.atan2(s,o):J(e.child.name),[u,d]=[e.r**2,t.r**2].map(n=>n/(t.r**2+e.r**2)*(a-c));[t.x,t.y]=[t.x-Math.cos(l)*u,t.y-Math.sin(l)*u],[e.x,e.y]=[e.x+Math.cos(l)*d,e.y+Math.sin(l)*d],n=!0}if(!n)return}}function ai(e,t,n){let r=r=>Math.hypot(r.x,r.y)>=t.r+e.r-ri&&n.every(t=>Math.hypot(t.x-r.x,t.y-r.y)>=t.r+e.r-ri),i=[],a=(t,n)=>{for(let[r,a]of[[t,n],[n,t]]){let t={r:e.r};qr(r,a,t),i.push(t)}};for(let e of n)a(t,e);let o=n.toSorted((e,t)=>e.x-e.r-(t.x-t.r));for(let[t,n]of o.entries())for(let r=t+1;r<o.length&&o[r].x-o[r].r<n.x+n.r+2*e.r;r++){let t=o[r];Math.hypot(t.x-n.x,t.y-n.y)<n.r+t.r+2*e.r&&a(n,t)}let s=J(e.child.name);n.length===0&&i.push({x:Math.cos(s)*(t.r+e.r),y:Math.sin(s)*(t.r+e.r)});let c=null;for(let e of i)r(e)&&(!c||Math.hypot(e.x,e.y)<Math.hypot(c.x,c.y))&&(c=e);let l=Math.max(t.r,...n.map(e=>Math.hypot(e.x,e.y)+e.r))+e.r;[e.x,e.y]=c?[c.x,c.y]:[Math.cos(s)*l,Math.sin(s)*l]}function oi(e,t,n=zr){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]=Vr(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=J(e.key);[e.x,e.y]=[n+Math.cos(t)*Rr*3,r+Math.sin(t)*Rr*3]}let i=Math.hypot(e.x-n,e.y-r)||1,[a,s]=[n+(e.x-n)/i*Rr,r+(e.y-r)/i*Rr];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(J(r.key)),Math.sin(J(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 J(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 si(e){e.layout&&Hr(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]=Vr(e)}}function ci(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,Br(t.files.length)+Fr);for(let t of e.users.values())Number.isNaN(t.x)||n(t.x,t.y,14);return t}var li=[.5,1,2,4,8],ui=20,di=50,fi=8,pi={side:40,top:64,bottom:40},mi=3,hi=10,Y=11,gi=72,_i=250,vi=1.8,yi=2,bi=new Set([`A`,`M`,`D`,`R`]),xi=new Map,Si=new Map,Ci=new Set,wi=new Map,Ti=new Set,Ei=new Map,Di=null,Oi=300,ki=1;function Ai(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Di&&(xi.clear(),Si.clear(),Ci.clear(),wi.clear(),Di=e),xi}var ji=()=>{for(let e of Ti)e.requestUpdate()},Mi=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;function Ni(e,t){let{repoId:n,commit:r,path:i}=e,a=`${n}\0${r}\0${i}\0${t}`,o=Ai().get(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:wr(),clock:0,next:0,playing:!1,waiting:!1,ended:!1,started:!1};return xi.set(a,s),s}var Pi={files:[],cut:!1},Fi=e=>e.commits[0]?.parents[0]??null,Ii=e=>`${e.repoId}\0${e.path}\0${Fi(e)}`,X=e=>Fi(e)?wi.get(Ii(e)):Pi,Z=(e,t)=>`${e.repoId}\0${e.path}\0${t}`,Q=(e,t)=>Si.get(Z(e,t)),Li=(e,t)=>Ci.has(Z(e,t)),Ri=(e,t)=>wi.get(Z(e,t)),zi=(e,t)=>!(!Q(e,t.sha)||Li(e,t.sha)&&!Ri(e,t.sha));function Bi(e){let t=0;for(;t<(e.commits?.length??0)&&zi(e,e.commits[t]);)t++;return t}function Vi(e,t){if(!Array.isArray(e)||!bi.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 Hi(e){let t=X(e),n=e.commits.filter(t=>Q(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(gr(t),(e.counts.get(gr(t))??0)+1);for(let e of t?.files??[])i(e);for(let t of n)for(let[n,r]of kr(Q(e,t.sha)))r!==`D`&&i(n);_r(e.colors,e.counts,fi)}function Ui(e){if(e.treeReading||e.error)return;let t=[...e.commits.slice(e.next),...e.commits.slice(0,e.next)],n=Fi(e)&&!X(e),r=n?Fi(e):t.find(t=>Li(e,t.sha)&&!Ri(e,t.sha))?.sha;if(!r)return;e.treeReading=!0;let i=Z(e,r);u(e.repoId,e.path,r).then(t=>{if(Ai().get(e.key)!==e)return null;let r=Array.isArray(t?.files)?t.files.map(t=>Vi([t,`A`],e.path)?.[0]).filter(Boolean):[];return wi.set(i,{files:r,cut:t?.cut===!0||!n&&!Array.isArray(t?.files)}),null},t=>(t?.name!==`AbortError`&&(e.error=t?.message||(n?`The files the commits start from could not be read.`:`The files a commit leaves could not be read.`)),null)).finally(()=>{e.treeReading=!1,ji()})}function Wi(e,t,n){let r=Q(e,n.sha),i=Li(e,n.sha)?Ri(e,n.sha):null;return i?[...r,...Mr(t,i.files,i.cut,kr(r))]:r}function Gi(e,t){let n=wr();n.start=X(e),jr(n,n.start.files.map(e=>[e,`A`]));for(let r of e.commits.slice(0,t))jr(n,Wi(e,n,r));return si(n),n}function Ki(e){if(e.reading||e.error||!e.commits)return;let t=Bi(e)===0?ui:di,n=[...e.commits.slice(e.next),...e.commits.slice(0,e.next)].filter(t=>!Q(e,t.sha)).slice(0,t).map(e=>e.sha);n.length!==0&&(e.reading=!0,l(e.repoId,e.path,n).then(t=>{if(Ai().get(e.key)!==e)return null;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)Si.set(Z(e,t),Array.isArray(r.get(t)?.files)?r.get(t).files.map(t=>Vi(t,e.path)).filter(Boolean):[]),r.get(t)?.more===!0&&Ci.add(Z(e,t));return null},t=>(t?.name!==`AbortError`&&(e.error=t?.message||`What the commits changed could not be read.`),null)).finally(()=>{e.reading=!1,ji()}))}function qi(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(C,i)?i:Se(n,r),a=e?null:ge(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?C[e].name:a?a.name??a.login:r??n,c=e?C[e].mark??null:null,l=e?!c&&C[e].avatar?`/api/avatar/${C[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 Ji={anthropic:[Ae,4,5,8],openai:[je,4,5,8],"github-copilot":[Me,0,0,24]},Yi={claude:[`#d97757`,`#fff`],codex:[`#fff`,`#000`],copilot:[`#0d1117`,`#fff`]},Xi=new Map,Zi=e=>Xi.get(e)??Xi.set(e,new Path2D(Ji[e][0])).get(e);function Qi(e){let t=Ei.get(e);return t||(t=new Image,t.decoding=`async`,t.src=e,Ei.set(e,t)),t.complete&&t.naturalWidth>0?t:null}var $=e=>e.toLocaleString(`en-US`),$i=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ea=e=>e===.5?`½×`:`${e}\xD7`,ta=D`<path d="M5 3.25v9.5L12.75 8z" fill="currentColor"/>`,na=D`<path d="M5.25 3.5v9M10.75 3.5v9"/>`,ra=D`<path d="M3.25 8a4.75 4.75 0 1 0 1.4-3.36M3.25 2.5v2.75H6"/>`,ia=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,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(),Ti.add(this),St(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(),Ti.delete(this),Ct(this),this._themes?.abort(),this._resize?.disconnect(),cancelAnimationFrame(this._frame),this._frame=null,this.replay&&![...Ti].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}=xt(this.repository);if(t.status!==`ready`)return;if(t.commits.filter(e=>e.parents.length<=1&&Number.isFinite(e.committedAt)).length<e.count&&t.more){!t.loadingMore&&!t.moreError&&n();return}e.commits=dr(t.commits,e.count),e.times=hr(e.commits)}Ui(e),Ki(e);let t=X(e);t&&(Hi(e),e.scene.start!==t&&this.seek(e.next),!e.started&&Bi(e)>0&&(e.started=!0,e.playing=!Mi(),this.requestUpdate()))}pickCount(e){Oi=e,ji()}pickSpeed(e){ki=e,ji()}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||!X(t))return;let n=Math.max(0,Math.min(e,Bi(t)));Object.assign(t,{scene:Gi(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)&&(Nr(n.scene,n.clock),n.scene.layout&&e-this._laidOut>=_i&&(Hr(n.scene),this._laidOut=e),oi(n.scene,t,Math.max(zr,gi/(this._camera?.zoom??1))),this.draw(n,t)))}play(e,t){let n=e.clock+t*ki,r=e.waiting;for(e.waiting=!1;e.next<e.commits.length&&e.times[e.next]<=n;){let t=e.commits[e.next];if(!zi(e,t)){n=e.times[e.next],e.waiting=!0;break}let r=e.times[e.next],i=(e.times[e.next+1]??r+mr)-r;Ar(e.scene,qi(t),Wi(e,e.scene,t),r,i*.8),e.next++}e.clock=n,e.next>=e.commits.length&&n>(e.times.at(-1)??0)+yi&&(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={background:t(`background`),text:t(`text`),muted:t(`muted`),surface:t(`surface`),added:t(`added`),modified:t(`modified`),removed:t(`removed`),kinds:Array.from({length:fi},(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,Fr*u.zoom),g=h<vi,_=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<yr){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)/yr),n=e.removed===null?1:Math.max(0,1-(l-e.removed)/br);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)/vr)*.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>yr||b(e.name,d(e.x)+Math.max(6,(Br(e.files.length)+3)*u.zoom),f(e.y));let x=v.filter(e=>e.removed===null);if(x.length<=hi){s.fillStyle=r.text;for(let e of x)s.globalAlpha=Math.max(0,1-(l-e.touched)/yr),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-xr)/Sr));let[i,a]=Object.hasOwn(Yi,e.agent)?Yi[e.agent]:[r.surface,r.text];s.fillStyle=i,s.beginPath(),s.arc(t,n,Y,0,2*Math.PI),s.fill();let o=e.image?Qi(e.image):null;if(e.mark&&Object.hasOwn(Ji,e.mark)){let[,r,i,o]=Ji[e.mark],c=Y*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(Zi(e.mark)),s.restore(),s.beginPath(),s.arc(t,n,Y,0,2*Math.PI)}else o?(s.save(),s.clip(),s.drawImage(o,t-Y,n-Y,Y*2,Y*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+Y+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=ci(e),a=Number.isFinite(i.minX),o=a?Math.max(.02,Math.min(mi,(t-2*pi.side)/Math.max(1,i.maxX-i.minX),(n-pi.top-pi.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-(pi.top-pi.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))<=Y+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 O;let e=Ni(this.repository,Oi);this.replay&&this.replay!==e&&(this.replay.playing=!1),this.replay=e;let t=e.commits?null:xt(this.repository),n=e.commits?.length??0,r=Bi(e),i=e.next>0?e.commits[e.next-1]:null,a=e.commits?e.people??=new Set(e.commits.flatMap(e=>qi(e).map(e=>e.key))).size:0,o=(e.commits?X(e):null)?.cut||e.commits?.some(t=>Li(e,t.sha)&&Ri(e,t.sha)?.cut),s=e.commits&&n>0?`${$(n)} commit${n===1?``:`s`} by ${$(a)}, ${$i(e.commits[0].committedAt)} \u2013 ${$i(e.commits.at(-1).committedAt)}${o?`, drawn in part: more files than are read`:``}`:``;return E`<div class="history-bar">${x(`replay`)}<div class="history-modes" role="group" aria-label="Commits played">${ur.map(e=>E`<button type="button" aria-pressed="${String(Oi===e)}" @click="${()=>this.pickCount(e)}">Last ${$(e)}</button>`)}</div>${s?E`<span class="history-summary">${s}</span>`:O}</div><div class="replay-stage"><canvas class="replay-canvas" role="img" aria-label="${i?`The repository\u2019s files as of ${$i(i.committedAt)}, ${$(e.next)} of ${$(n)} commits played`:`The repository’s files, as its commits change them`}" @pointermove="${this.pointer}" @pointerleave="${this.pointer}"></canvas>${i?E`<div class="replay-day"><time datetime="${new Date(i.committedAt).toISOString()}">${$i(i.committedAt)}</time> <span>${$(e.next)} of ${$(n)}</span></div>${this.renderCommit(i)}`:O} ${this.renderKey(e)} ${this.renderStatus(e,t,r)} ${this._hovered?E`<div class="replay-tip" style="${T({left:`${this._hovered.x}px`,top:`${this._hovered.y}px`})}">${this._hovered.text}</div>`:O}<div class="replay-swatches" aria-hidden="true">${[`background`,`text`,`muted`,`surface`,`added`,`modified`,`removed`,...Array.from({length:fi},(e,t)=>`kind-${t}`)].map(e=>E`<span class="${`is-${e}`}"></span>`)}</div></div>${this.renderControls(e,n,r)}`}renderCommit(e){let t=this.repo??this.repository.repo,n=t?`https://github.com/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:null,r=e.sha.slice(0,7);return E`<p class="replay-commit">${n?E`<a class="replay-sha" href="${`${n}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" aria-label="${`Commit ${r} on GitHub`}">${r}</a>`:E`<code class="replay-sha">${r}</code>`} <span class="replay-commit-subject">${mt(e.subject||`(no message)`,n)}</span> <span class="replay-commit-author">${Te(e.authorLogin,e.authorName,e.coauthors)}</span></p>`}renderKey(e){if(e.colors.size===0)return O;let t=[...e.colors].toSorted((t,n)=>(e.counts.get(n[0])??0)-(e.counts.get(t[0])??0));return E`<ul class="replay-key" aria-label="Kinds of files">${t.map(([e,t])=>E`<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){if(t?.entry.status===`error`)return E`<div class="replay-status is-error"><p role="alert">${t.entry.error}</p><button type="button" @click="${()=>wt(t.key)}">Retry</button></div>`;if(e.error)return E`<div class="replay-status is-error"><p role="alert">${e.error}</p><button type="button" @click="${()=>{e.error=null,ji()}}">Retry</button></div>`;if(t?.entry.status===`ready`&&t.entry.moreError)return E`<div class="replay-status is-error"><p role="alert">${t.entry.moreError}</p><button type="button" @click="${()=>t.more()}">Retry</button></div>`;if(t){let e=t.entry.status===`ready`?t.entry.commits.length:0;return E`<div class="replay-status" role="status">${e>0?`Reading commits\u2026 ${$(e)} so far`:`Reading the history…`}</div>`}return e.commits.length===0?E`<div class="replay-status">No commits to play.</div>`:X(e)?n===0?E`<div class="replay-status" role="status">Reading what the commits changed…</div>`:e.waiting?E`<div class="replay-status is-waiting" role="status">Reading what the next commits changed…</div>`:O:E`<div class="replay-status" role="status">Reading the files as they were before ${$i(e.commits[0].committedAt)}…</div>`}renderControls(e,t,n){let r=e.ended?`Play again`:e.playing?`Pause`:`Play`,i=n>0&&!!(e.commits&&X(e)),a=e=>`${t>0?e/t*100:0}%`;return E`<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?ra:e.playing?na:ta}</svg></button><div class="replay-track" style="${T({"--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="${`${$(e.next)} of ${$(t)} commits`}" @input="${e=>this.seek(Number(e.target.value))}"></div><div class="history-modes" role="group" aria-label="Speed">${li.map(e=>E`<button type="button" aria-pressed="${String(ki===e)}" @click="${()=>this.pickSpeed(e)}">${ea(e)}</button>`)}</div></div>`}};customElements.get(`repository-replay`)||customElements.define(`repository-replay`,ia);var aa=3e5,oa=3e4,sa=8,ca=20,la=new Map,ua=new Set,da=null,fa={issues:`open`,pulls:`open`};function pa(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==da&&(la.clear(),da=e),la}var ma=()=>{for(let e of ua)e.requestUpdate()};p(e=>{for(let t of ua)(!e||t.repository?.repoId===e.repoId)&&t.requestUpdate()});function ha(e){if(!Array.isArray(e?.items))throw Error(`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 ga(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 _a(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));n.counted=r}function va(e,t,n){return ze(pa(),e,()=>t(null),{ready:e=>{let t={status:`ready`,until:Date.now()+aa,...e,countsAt:e.readAt,loadingMore:!1,moreError:null};return n(t),t},failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+oa,error:e?.message||`The list could not be read.`},retryMs:oa,repaint:ma})}function ya(e,t,n,r){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+aa,ma(),n(t.after).then(n=>{if(pa().get(e)!==t)return null;let i=new Set(t.items.map(e=>e.number));return t.items=[...t.items,...n.items.filter(e=>!i.has(e.number))],n.readAt>=t.countsAt&&(t.counts=n.counts,t.countsAt=n.readAt,r(t)),t.more=n.more,t.after=n.after,t.until=Date.now()+aa,null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More could not be read.`),null)).finally(()=>{t.loadingMore=!1,ma()}))}function ba(e,t){let n=t.trim().toLowerCase().split(/\s+/u).filter(Boolean);return n.length===0?e:e.filter(e=>{let t=[`#${e.number}`,e.title,e.author??``,ye(e.author)??``,e.head??``,...e.labels.map(e=>e.name)].join(`
4
+ `).toLowerCase();return n.every(e=>t.includes(e))})}var xa=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumSignificantDigits:2}),Sa=e=>e<1e3?String(e):xa.format(e);function Ca(e){let t=e.labels.length+(e.moreLabels??0),n=e.labels.slice(0,t>sa?sa-1:sa),r=e=>E`<span class="issue-label" style="${T(e.color?{"--label":`#${e.color}`}:{})}" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span>`,i=e=>E`${r(e[0])}${e.length>1?E`<span class="issue-labels-rest" style="${T({"--labels":String(e.length-1)})}">${i(e.slice(1))}</span>`:O}`;return E`${n.length>0?i(n):O}${t>n.length?E`<span class="issue-label is-more">+${t-n.length}</span>`:O}`}var wa={git:`from git`,tarball:`a tarball not npm’s registry’s`,integrity:`locked with no integrity`};function Ta({versions:e,count:t,unread:n,unchecked:r,cut:i}){let a=t-Math.min(e.length,ca);return[t>0?`${e.slice(0,ca).map(e=>`${e.name}${e.version?`@${e.version}`:``} (${wa[e.unsupported]})`).join(`, `)}${a>0?` and ${a.toLocaleString(`en-US`)} more`:``} can\u2019t be reviewed`:null,n.length>0||r>0||i?`not every lockfile it changes was read`:null].filter(Boolean).join(`; `)}function Ea(e){if(e.status!==`ready`)return O;let{versions:t,fresh:n,updated:r,more:i,toReview:a}=v(e),o=e.review?b(e).count:0,s=ee(e);if(t.length===0&&o===0&&!s)return O;let c=i?`+`:``,l=t=>{let n=y(t,e.review);return n===`unsupported`?`, can\u2019t be reviewed: ${wa[t.unsupported]}`:n===`baseline`?`, needs no review`:t.reviewed?`, reviewed`:t.rejected?`, rejected`:t.patched&&n===`wanted`?`, patched, unreviewed`:n?`, ${t.reviews}/${e.review.required} reviews`:``},u=e=>`${e.name}@${e.version??`?`}${e.was?` (was ${e.was.join(`, `)}${l(e)})`:` (new${l(e)})`}`,d=t.length-ca,f=[t.length>0?`New in its lockfiles: ${t.slice(0,ca).map(u).join(`, `)}${d>0?` and ${d.toLocaleString(`en-US`)}${c} more`:i?` and more`:``}`:null,o>0?`${o.toLocaleString(`en-US`)} other ${o===1?`version`:`versions`} in its lockfiles unreviewed`:null,s?`Its review fails: ${Ta(s)}`:null].filter(Boolean).join(`. `),p=[n?`${n.toLocaleString(`en-US`)} new`:null,r?`${r.toLocaleString(`en-US`)} updated`:null].filter(Boolean).join(`, `),m=a&&o?`${a.toLocaleString(`en-US`)} + ${o.toLocaleString(`en-US`)} to review`:a?`${a.toLocaleString(`en-US`)} to review`:o?`${o.toLocaleString(`en-US`)} unreviewed`:``;return E`<span class="issue-deps" data-tooltip="${f}">${le}<span class="issue-deps-names">${[...new Set(t.map(e=>e.name))].join(`, `)}</span> ${p?E`<span class="issue-deps-count">${p}${c}</span>`:O} ${s?E`<span class="issue-deps-review is-failed">${s.count>0?`${s.count.toLocaleString(`en-US`)} can\u2019t be reviewed`:`lockfiles unread`}</span>`:e.review?m?E`<span class="issue-deps-review is-wanted">${m}</span>`:E`<span class="issue-deps-review is-passed" role="img" aria-label="Every version reviewed">${ie.success[1]}</span>`:O}</span>`}var Da=class extends _e{static properties={repository:{attribute:!1},repo:{attribute:!1},kind:{},_filter:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this.kind=`issues`,this._filter=``,this._moreButton=null}connectedCallback(){super.connectedCallback(),ua.add(this)}disconnectedCallback(){super.disconnectedCallback(),ua.delete(this),this._moreButton&&S(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.issues-more > button`);this._moreButton&&this._moreButton!==e&&S(this._moreButton),this._moreButton=e,e&&me(e,t=>{t&&this.readNear(e)})}readNear(e){e===this._moreButton&&e.isConnected&&!e.disabled&&!this._filter.trim()&&!e.parentElement.querySelector(`[role=alert]`)&&e.click()}list(e){let{repoId:t}=this.repository,r=this.kind,i=`${t}\0${r}\0${e}`,a=i=>f(t,r,{state:e,after:i}).then(ha).then(e=>(n(t,e.items,e.readAt,r),e)),o=e=>_a(t,r,e),s=va(i,a,o);return{key:i,entry:s,more:()=>ya(i,s,a,o)}}pick(e){fa[this.kind]=e,ma()}render(){if(!this.repository)return O;let e=fa[this.kind],{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=pa().get(`${this.repository.repoId}\0${this.kind}\0${o}`),c=i?ga(this.repository.repoId,this.kind,e,n):null,l=c?c.counts:s?.status===`ready`?ga(this.repository.repoId,this.kind,o,s).counts:null,u=e=>l?E`<span class="n">${l[e].toLocaleString(`en-US`)}</span>`:O,d=c?ba(c.items,this._filter):[];return E`<div class="history-bar issues-bar">${x(this.kind)}<div class="history-modes" role="group" aria-label="${this.kind===`pulls`?`Pull requests`:`Issues`}"><button type="button" aria-pressed="${String(e===`open`)}" @click="${()=>this.pick(`open`)}">Open${u(`open`)}</button> <button type="button" aria-pressed="${String(e===`closed`)}" @click="${()=>this.pick(`closed`)}">Closed${u(`closed`)}</button></div><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()?E`<span class="history-summary">${d.length} of ${c.items.length} read</span>`:O}</div>${c?this.renderTiles(n,c.items,d,r,`${e} ${a}`):n.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${n.error}</p><button type="button" @click="${()=>{pa().delete(t),ma()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading the ${a}…</div>`}`}renderTiles(e,t,n,r,i){if(t.length===0)return E`<div class="bundles-slide-placeholder">No ${i}.</div>`;let a=this.repo??this.repository.repo,o=this.kind===`pulls`?`pull`:`issues`;return E`<div class="issues-scroll">${n.length===0?E`<p class="history-note">None of the ${i} read match.</p>`:E`<ol class="issues-grid" aria-label="${i}">${n.map(e=>{let[t,n]=ue(this.kind,e),r=this.renderTile(e,t,n);return E`<li class="${De({"issue-tile":!0,[`is-${t}`]:!0})}">${a?E`<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>`:E`<div class="issue-body" @click="${t=>this.openTile(t,e)}">${r}</div>`}</li>`})}</ol>`} ${e.more||e.moreError?E`<div class="history-more issues-more">${e.moreError?E`<span role="alert">${e.moreError}</span>`:O} <button type="button" ?disabled="${e.loadingMore}" @click="${r}">${e.loadingMore?`Reading…`:`More`}</button></div>`:O}</div>`}openTile(e,t){pe(e)&&(e.preventDefault(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{number:t.number,preview:{...t,kind:this.kind}}}))}renderTile(t,n,r){let i=this.kind===`pulls`,a=i&&t.state===`open`&&h(t)?_(this.repository.repoId,t.number,!0):null,o=t.updatedAt==null?null:new Date(t.updatedAt),s=i&&t.checks?ie[t.checks]:null,c=i&&t.state===`open`&&t.review?ae[t.review]:null,l=t.comments>0?`${t.comments.toLocaleString(`en-US`)} comment${t.comments===1?``:`s`}`:null,u=(e,[n,r])=>E`<span class="${`issue-${e} is-${t[e]}`}" role="img" aria-label="${n}" data-tooltip="${n}">${r}</span>`;return E`<span class="issue-rail"><span class="issue-state" role="img" aria-label="${r}">${ne[this.kind][n]}</span> ${i?E`<span class="issue-marks">${c?u(`review`,c):O}${s?u(`checks`,s):O}</span>`:O} ${l?E`<span class="issue-comments" role="img" aria-label="${l}" data-tooltip="${l}">${re}<span>${Sa(t.comments)}</span></span>`:O} </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">${xe(t.author,t.author??`ghost`)}</span> ${o?E`<time datetime="${o.toISOString()}">${M(t.updatedAt)}</time>`:O} </span>${t.labels.length>0||t.moreLabels>0?E`<span class="issue-labels">${Ca(t)}</span>`:O} ${i&&t.head?E`<span class="issue-branch"><code>${t.head}</code>${t.base?E`<span aria-hidden="true">→</span><code>${t.base}</code>`:O} <span class="issue-diff"><span class="is-added">+${t.additions.toLocaleString(`en-US`)}</span> <span class="is-deleted">−${t.deletions.toLocaleString(`en-US`)}</span></span></span>`:O} ${i&&t.state===`open`?e(t.reviews):O} ${a?Ea(a):O}</span>`}};customElements.get(`repository-issues`)||customElements.define(`repository-issues`,Da);
@@ -0,0 +1,36 @@
1
+ import{b as e,h as t}from"./chunk-I2MDGSQX.js";import{a as n}from"./chunk-WCPJDAYA.js";import{a as r,b as i,e as a}from"./chunk-IYPY47MC.js";import{A as o,B as s,E as c,b as l,c as u,d,j as f,m as p,p as m,s as h,t as g,w as _,z as v}from"./chunk-SXV2T5C4.js";import{A as ee,b as y,c as b,i as te,w as x,y as S}from"./chunk-WFYLMF6Z.js";import{a as C,b as w,c as T}from"./chunk-C4Z6ZBXV.js";import{c as E,f as D,g as O,i as k}from"./chunk-2XUEZHIP.js";var ne=w(class extends T{constructor(e){if(super(e),e.type!==C.ATTRIBUTE||e.name!==`class`||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return` `+Object.keys(e).filter(t=>e[t]).join(` `)+` `}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(` `).split(/\s/).filter(e=>e!==``)));for(let e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}let n=e.element.classList;for(let e of this.st)e in t||(n.remove(e),this.st.delete(e));for(let e in t){let r=!!t[e];r===this.st.has(e)||this.nt?.has(e)||(r?(n.add(e),this.st.add(e)):(n.remove(e),this.st.delete(e)))}return D}}),re=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),ie=e=>y(e)?e:re(b(String(e))),A=globalThis.trustedTypes?.createPolicy(`deepview`,{createHTML:ie,createScriptURL:e=>{let t=new URL(e,globalThis.location.href);if(t.origin!==globalThis.location.origin)throw TypeError(`Not a same-origin script: ${t.href}`);return t.href}}),j=e=>A?A.createHTML(e):ie(e),ae=e=>A?A.createScriptURL(String(e)):e,M={showAll:!1,packagesView:!1,dependencyPackagesView:!1,flowPackagesView:!1,bundleIssues:!1,bundleLayout:`graph`,lockfileLayout:`dependencies`,bundleReason:null,bundleReasonFor:null,selected:null,focusedPkg:null,topPkgsTab:`issues`,edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:``,hidden:new Set,solo:null,graphState:null,layoutCache:null,keptViewport:null};function oe({keepViewport:e=!1}={}){M.graphState?._cleanup?M.graphState._cleanup({keepViewport:e}):e||(M.keptViewport=null),M.graphState=null}function N(e){return e.id??String(e._id)}function se(e){let t=m(e);return t!==``&&t!==`revalidation`}var ce=[{value:`confirmed`,label:`Confirmed`,kinds:[`confirmed`,`partial`,`revalidation`]},{value:`unreachable`,label:`Unreachable`,kinds:[`unreachable`]},{value:`refuted`,label:`Refuted`,kinds:[`refuted`]}];function le(e){return ce.find(t=>t.value===e)?.kinds??null}var ue=[``,`exclude`,`only`];function de(e,t){let n=le(e);return n?.includes(`partial`)?t===`only`?[`partial`]:t===`exclude`?[`confirmed`]:n:n}function P(e){if(e.confidence!==void 0)return e.confidence;if(e.critical===!0||e._source)return 10}var fe=e=>e.confidence!==void 0||e.critical===!0;function pe(e){return e.every(e=>e.every(e=>P(e)!==void 0))&&e.some(e=>e.some(fe))}function me(e,t,n){return e.some(e=>{let r=[`refuted`,`unreachable`].includes(n(e))?0:P(e);return r===void 0?t===0:r>=t})}function he(e,t){let n=e.map(t).filter(e=>e.length>0);if(!n.some(e=>e.some(e=>P(e)!==void 0)))return 0;let r=e=>n.reduce((t,n)=>t+ +!!n.some(t=>(P(t)??-1)>=e),0),i;for(i=r(6)<=25?6:r(7)<=25?7:8;i>0&&r(i-1)===r(i);)i--;return i}function ge(e,t){return pe(e)?t:0}function _e(e,t,n){let r=new Set(e.ruledOutIds??[]);for(let t of e)for(let e of t)[`refuted`,`unreachable`].includes(n(e))&&r.add(N(e));for(let i of e){let e=t(i);if(e.length!==0&&e.some(e=>de(`confirmed`,``).includes(n(e)||(e._source&&!e._sourcePass?`revalidation`:``)))){for(let e of i)if(r.add(N(e)),e.isApp&&Array.isArray(e.revalidateInputs))for(let t of e.revalidateInputs)t&&r.add(t)}}return r}function ve(e,t,n,r){let i=ge(e,t),a=e.filter(e=>me(e,i,r));if(a.length===0)return!1;let o=new Set(de(`confirmed`,``));return e.some(e=>e.some(e=>o.has(r(e))))?a.every(e=>e.every(e=>n.has(N(e)))):!1}function ye(e,{tabs:t,kindOf:n,severityMode:r}){let i=e.map(t).filter(e=>e.length>0),a=_e(e,t,n);if(!ve(i,he(e,t),a,n))return!1;let o=ge(i,6);return i.every(e=>!me(e,o,n)||!e.some(e=>p(e,r)!==`low`)||e.every(e=>a.has(N(e))))}var F=!0;function be(e,t=!1){F=e!==!1&&!t}function xe(){return F}function I(e){return F?m(e):``}function Se(e){return m(e)!==``}function Ce(e){return e.some(e=>(e.groups??[]).some(e=>e.some(se)))}function we(e){let t=I(e);return t&&t!==`revalidation`?t:null}function Te(e){return I(e)===`revalidation`}var Ee=new Set([`refuted`,`unreachable`]);function De(e){return Ee.has(I(e))}function Oe(e){return Ee.has(I(e))}function ke(e){let t=new Set(e);return ce.filter(e=>e.kinds.some(e=>t.has(e)))}function L(e){return RegExp(`(^|/)${e}/`,`u`)}function Ae(e){return RegExp(`^(?:.*/)?${e}/(?:@[^/]+/[^/]+|[^/]+)/(.*)$`,`u`)}var je=L(`node_modules`),Me=L(`vendor`),R=`node_modules`,z=L(R),Ne=Ae(R);function Pe(e){e!==R&&(R=e,z=L(e),Ne=Ae(e))}var B=null;function Fe(t){B?.length===t.length&&B.every((e,n)=>e===t[n])||(B=[...t],Pe(e(t)))}function Ie(){return R}function V(e){return z.test(e)}var Le=new WeakSet;function Re(e){let t=!1;for(let n of e??[])for(let e of n.groups??[])for(let n of e){if(n.isApp!==!1)continue;let e=Le.has(n);`isUpstream`in n&&!e||(V(n.file)?(n.isUpstream!==!0&&(t=!0),n.isUpstream=!0,Le.add(n)):e&&(t=!0,delete n.isUpstream,Le.delete(n)))}return t}function ze(e){let t=typeof e==`string`?e:``;return je.test(t)||Me.test(t)||z.test(t)}var Be=/^(.*(?:^|\/)node_modules\/(?:@[^/]+\/[^/]+|[^/]+))(?:\/|$)/u;function Ve(e){return Be.exec(typeof e==`string`?e:``)?.[1]??null}function He(e){return typeof e!=`number`||!Number.isFinite(e)?null:n(e)}function Ue(e){if(e.length<=1)return{prefix:``,stripped:[...e]};let t=e.map(e=>e.split(`/`)),n=Math.min(...t.map(e=>e.length)),r=0;for(let e=0;e<n-1&&t.every(n=>n[e]===t[0][e]);e++)r=e+1;return r>0&&t[0][r-1].startsWith(`@`)&&r--,r>0&&t[0][r-1]===`node_modules`&&r--,r===0?{prefix:``,stripped:[...e]}:{prefix:`${t[0].slice(0,r).join(`/`)}/`,stripped:t.map(e=>e.slice(r).join(`/`))}}function We(e){return e.match(Ne)?.[1]??e}var Ge={on:new WeakMap,off:new WeakMap};function Ke(e){let t=F?Ge.on:Ge.off,n=t.get(e);if(n===void 0){let r=F?[we(e),e.revalidateVerdict,e.revalidateRecommendation]:[];n=[e.file,e.title,e.description,e.impact,e.reproduction,Ot(e),e.recommendation,e.confidenceReason,...r,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
2
+ `).toLowerCase(),t.set(e,n)}return n}function qe(e){return[typeof e?.category==`string`?e.category.trim():``,h(e,F)].filter(Boolean).join(` · `)}function Je(e){if(e.length===0)return``;let t=e[0];for(let n=1;n<e.length;n++){for(;t&&!e[n].startsWith(t);)t=t.slice(0,-1);if(!t)return``}return t}function Ye(e){if(!e)return``;let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function Xe(e){if(!e)return null;let t=e.trim().replace(/\/$/u,``);return t?/^https?:\/\//iu.test(t)?t:/^github\.com\//iu.test(t)?`https://${t}`:`https://github.com/${t}`:null}var Ze=/^(?:@[\w.-]+\/)?[\w.-]+@[^/\s@]+$/u;function Qe(e){return Ze.test(e||``)}function $e(e){if(e==null||typeof e==`string`)return{id:e??``,prefix:``};let t=c(e);return{id:typeof e.github==`string`?e.github:``,prefix:t?`${t}/`:``}}function et(e,t,n){if(Qe(e))return null;let r=$e(t);if(r.id)return`https://github.com/${r.id}/blob/HEAD/${r.prefix}${We(e)}`;if(V(e))return null;let i=$e(n),a=Xe(i.id);return a?`${a}/blob/HEAD/${i.prefix}${e}`:null}function tt(e,t){let n=e?.file??``,r=H(e,t);return r?E`<a href="${nt(r)}" target="_blank" rel="noopener">${n}</a>`:n}function nt(e){return e.replace(/#L\d+(?:-L?\d+)?$/u,``)}function H(e,t){if(!e)return null;if(s(e.location))return e.location;let n=et(e.file,e.repo,t);if(!n)return null;let r=parseInt(e.line,10);return Number.isFinite(r)?`${n}#L${r}`:n}var rt=/^https?:\/\/(?:www\.)?github\.com\/([^/\s]+\/[^/\s]+)\/(?:blob|tree|blame)\/[^/\s]+\/(\S+)$/u,it=/#L(\d+)(?:-L?(\d+))?$/u;function at(e){let t=typeof e==`string`?rt.exec(e):null;if(!t)return``;let n=t[2],r=it.exec(n);if(!r)return`${t[1]}/${n}`;n=n.slice(0,r.index);let i=r[2]?`${r[1]}-${r[2]}`:r[1];return`${t[1]}/${n}:${i}`}var ot=/^(?:\s+\S|[-*+] |\d+[.)] |>|#{1,6}(?:[ \t]|$)|\||`{3}|~{3})/u;function st(e){return e.split(/(\n{2,})/u).map(e=>{if(/^\n+$/u.test(e))return e;let t=e.split(`
3
+ `);return t.some(e=>ot.test(e)||U.test(e))?e:t.map(e=>e.trim()).filter(Boolean).join(` `)}).join(``)}function ct(e,t,n){let r=t?/^\n*/u.exec(e)[0]:``,i=e.slice(r.length),a=n?/\n*$/u.exec(i)[0]:``;return r+st(i.slice(0,i.length-a.length))+a}function lt(e){if(!e)return e;let t=e.replaceAll(`\r
4
+ `,`
5
+ `),n=l(t);if(n.length===0)return st(t);let r=[],i=0;for(let[e,a]of n)e>i&&r.push(ct(t.slice(i,e),i>0,!0)),r.push(t.slice(e,a)),i=a;return i<t.length&&r.push(ct(t.slice(i),!0,!1)),r.join(``)}var ut=/^( *)(`{3,}|~{3,})(.*)$/u,dt=/^[a-z0-9+#._-]{1,20}$/u;function ft(e,t){let n=0;for(;n<t&&e[n]===` `;)n++;return e.slice(n)}function pt(e){let t=e.split(`
6
+ `),n=ut.exec(t[0]),r=(n?.[2]??"```").slice(0,3),i=(n?.[3]??``).trim().split(/\s+/u)[0].toLowerCase(),a=!!(t.length>1?ut.exec(t.at(-1)):null)?.[2].startsWith(r),o=n?.[1].length??0,s=t.slice(1,a?-1:void 0);return{lang:dt.test(i)?i:``,code:(o>0?s.map(e=>ft(e,o)):s).join(`
7
+ `)}}function mt(e){let t=l(e||``);if(t.length===0)return[e];let n=[],r=0,i=(e,t)=>{let r=(t?e.replace(/^\n+/u,``):e).replace(/\n+$/u,``);r&&n.push(r)};for(let[a,o]of t)a>r&&i(e.slice(r,a),r>0),n.push(pt(e.slice(a,o))),r=o;return r<e.length&&i(e.slice(r),!0),n}var ht=/^( *)(?:[-*+]|(\d{1,9})[.)]) +(?=\S)/u,U=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u;function gt(e){return/^ */u.exec(e)[0].length}function _t(e){let t=e.length;for(;t>0&&!e[t-1].trim();)t--;return e.slice(0,t).join(`
8
+ `)}function vt(e){let t=typeof e==`string`?e:``;if(!t)return[e];let n=l(t),r=t.split(`
9
+ `),i=[],a=0;for(let e of r)i.push(a),a+=e.length+1;let o=e=>!u(n,i[e])&&!U.test(r[e])&&ht.test(r[e]),s=[],c=0,d=0,f=e=>{let t=r.slice(c,e).join(`
10
+ `).replace(/^\n+/u,``).replace(/\n+$/u,``);t.trim()&&s.push(t)};for(;d<r.length;){if(!o(d)){d++;continue}f(d);let e=ht.exec(r[d]),t=!!e[2],a=[],l=null,p=!1;for(;d<r.length;){let e=r[d];if(!u(n,i[d])){if(!e.trim()){l.lines.push(``),p=!0,d++;continue}let n=gt(e),r=U.test(e)?null:ht.exec(e);if(r&&(!l||n<l.column)){if(!!r[2]!==t)break;l&&a.push(_t(l.lines)),l={column:r[0].length,lines:[e.slice(r[0].length)]},p=!1,d++;continue}if(n<l.column&&(p||yt.test(e)||U.test(e)))break}l.lines.push(ft(e,l.column)),p=!1,d++}l&&a.push(_t(l.lines)),s.push({ordered:t,start:t?Number(e[2]):null,items:a}),c=d}return s.length===0?[e]:(f(r.length),s)}var yt=/^ {0,3}(#{1,6})[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/u,bt=/^ {0,3}-+[ \t]*$/u;function xt(e){let t=e.split(`
11
+ `),n=[],r=0,i=e=>{let i=t.slice(r,e).join(`
12
+ `).replaceAll(/^(?:[ \t]*\n)+|(?:\n[ \t]*)+$/gu,``);i.trim()&&n.push(i)};return t.forEach((e,a)=>{let o=yt.exec(e),s=U.test(e)&&(a===r||!t[a-1].trim()||!bt.test(e));!o&&!s||(i(a),n.push(o?{level:o[1].length,text:o[2]}:{rule:!0}),r=a+1)}),n.length===0?[e]:(i(t.length),n)}var St=/^(\d+)(?:\s*-\s*(\d+))?$/u;function W(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=1?{start:Math.floor(e),end:Math.floor(e)}:null;let t=St.exec(String(e??``).trim());if(!t)return null;let n=parseInt(t[1],10),r=t[2]===void 0?n:parseInt(t[2],10);return!Number.isFinite(n)||n<1||!Number.isFinite(r)||r<1?null:{start:Math.min(n,r),end:Math.max(n,r)}}function Ct(e){return e?e.start===e.end?String(e.start):`${e.start}-${e.end}`:``}function wt(e){if(e&&typeof e==`object`){let t=W(e.start);if(!t)return null;let n=W(e.end)??t;return{start:t.start,end:Math.max(t.start,n.end)}}return W(e)}function Tt(e,t,n=4){let r=typeof e==`string`&&e!==``?e.split(`
13
+ `):[];if(r.length===0)return{text:``,startLine:1,lines:[]};let i=wt(t),a=i&&{start:Math.min(i.start,r.length),end:Math.min(i.end,r.length)},o=a?Math.max(1,a.start-n):1,s=a?Math.min(r.length,a.end+n):Math.min(r.length,n*2+1),c=r.slice(o-1,s);return{text:c.join(`
14
+ `),startLine:o,lines:c}}function Et(e,t,n,r){if(s(e?.url))return e.url;let i=e?.file;if(typeof i!=`string`||i===``)return null;let a=t?.file??``,o=t?.repo?.github,c=()=>o?H({file:i,line:e?.line,repo:t.repo},null):null;if(r===0&&i===a)return c();let l=Ve(i);return l!==null&&l===Ve(a)?c():ze(i)?null:o&&!ze(a)?c():H({file:i,line:e?.line},n)}function Dt(e,{spaced:t=!1}={}){let n=Array.isArray(e?.evidence)?e.evidence:[];return n.length===0?``:n.map((e,t)=>{let n=v(e),r=[`${t+1}. ${e.url?`[${n}](${e.url})`:n}`],i=o(e);if(i)for(let e of i.split(`
15
+ `))r.push(` ${e}`);return r.join(`
16
+ `)}).join(t?`
17
+
18
+ `:`
19
+ `)}function Ot(e){let t=Dt(e);return t?`**Evidence:**
20
+ ${t}`:``}function kt(e){let t=/^\[([^\]]+)\]\(([^)\s]+)\)$/u.exec(e);return!t||!s(t[2])?null:{label:d(t[1].trim())||t[2],url:t[2]}}function At(e,t){let n=parseInt(e?.line,10);if(!Number.isFinite(n))return O;let r=H(e,t),i=`line ${n}`;return r?E`<a href="${r}" target="_blank" rel="noopener">${i}</a>`:i}function jt(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,``):`https://github.com/${e}`}/commit/${t}`}var Mt=[[`Impact`,`impact`],[`Reproduction`,`reproduction`],[`Recommendation`,`recommendation`],[`Confidence reason`,`confidenceReason`],[`Revalidation verdict`,`revalidateVerdict`],[`Revalidation recommendation`,`revalidateRecommendation`]];function Nt(e,t){let n=[];t&&n.push(`Repo: ${t}`);let r=v(e);r&&n.push(`Location: ${r}`),e?.confidence!=null&&n.push(`Confidence: ${e.confidence}/10`);let i=I(e);i&&n.push(`Revalidation: ${i}`);let a=[];n.length>0&&a.push(n.join(`
21
+ `));let{title:o,body:s}=_(e);o&&a.push(`# ${o}`),s&&a.push(s.trim());let c=Dt(e,{spaced:!0});c&&a.push(`# Evidence
22
+
23
+ ${c}`);for(let[t,n]of Mt){if(!F&&n.startsWith(`revalidate`))continue;let r=g(e?.[n],e)?.trim();r&&a.push(`# ${t}
24
+
25
+ ${r}`)}return a.join(`
26
+
27
+ `)}function Pt(e,{title:t,body:n,labels:r=[]}={}){let i=Xe(e);if(!i)return null;let a;try{a=new URL(i).host.toLowerCase()}catch{return null}if(a!==`github.com`)return null;let o=new URLSearchParams;t&&o.set(`title`,t),n&&o.set(`body`,n),r.length>0&&o.set(`labels`,r.join(`,`));let s=o.toString();return s?`${i}/issues/new?${s}`:`${i}/issues/new`}var Ft=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,It=/^[a-zA-Z\d._-]+$/u,Lt=/^[1-9]\d{0,9}$/u,Rt=/^[a-fA-F\d]{7,40}$/u,zt=/^#[\w-]+$/u,Bt=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function Vt(e){return e.length<=39&&Ft.test(e)}function Ht(e){return e.length<=100&&e!==`.`&&e!==`..`&&It.test(e)}function Ut(e){let t;try{t=new URL(e)}catch{return null}if(t.href!==e||t.protocol!==`https:`||t.hostname.toLowerCase()!==`github.com`||t.port||t.username||t.password)return null;let n=t.pathname.split(`/`);if(n.at(-1)===``&&n.pop(),n.length===3&&n[1]===`advisories`){let e=n[2];return Bt.test(e)?{url:`https://github.com/advisories/${e}`,label:e}:null}if(n.length===6&&n[3]===`security`&&n[4]===`advisories`){let[,e,t,,,r]=n;return!Vt(e)||!Ht(t)||!Bt.test(r)?null:{url:`https://github.com/${e}/${t}/security/advisories/${r}`,label:r}}if(n.length!==5)return null;let[,r,i,a,o]=n;if(!Vt(r)||!Ht(i))return null;let s;if(a===`issues`||a===`pull`){if(!Lt.test(o))return null;s=`${r}/${i}#${o}`}else if(a===`commit`){if(!Rt.test(o))return null;s=`${r}/${i}@${o.slice(0,7)}`}else return null;return{url:`https://github.com/${r}/${i}/${a}/${o}${zt.test(t.hash)?t.hash:``}`,label:s}}var Wt=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u;function Gt(e){if(typeof e!=`string`)return null;let t=Kt(e);return t!==e||Wt.test(e)?t.slice(0,8):null}function Kt(e){let t=String(e);return t.startsWith(`https://chatgpt.com/codex/cloud/security/findings/`)?t.slice(50):t}function qt(e,n){let r=t(e,{managed:n});if(!r)return null;let i=Gt(r.id);return{url:n?r.path:`#${r.fragment}`,label:i?`finding ${i}`:`finding`,self:!0}}var Jt=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,Yt=new Set([`)`,`.`,`,`,`!`,`?`,`;`,`:`,`'`,`"`,`*`,`]`,`}`,`>`]);function Xt(e){let t=e.length;for(;t>0&&Yt.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function Zt(e,{managed:t=!1}={}){if(typeof e!=`string`||e.length===0)return[];let n=[],r=0;Jt.lastIndex=0;let i;for(;(i=Jt.exec(e))!==null;){let a=Xt(i[0]),o=a?Ut(a)??qt(a,t):null;o&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(o),r=i.index+a.length,Jt.lastIndex=r)}return r<e.length&&n.push(e.slice(r)),n}var Qt={commit:S},$t=8;function en(e){let t;try{t=e?JSON.parse(e):null}catch{return null}let n=e=>typeof e==`string`&&e?e:null;return t&&{tags:Array.isArray(t.tags)?t.tags.filter(n):[],details:typeof t.title==`string`?{title:t.title,authorName:n(t.authorName),authorLogin:n(t.authorLogin),date:Number.isSafeInteger(t.date)?t.date:null}:null}}function tn({title:e,authorName:t,authorLogin:n,date:r}){let i=document.createElement(`div`);i.className=`tooltip-commit-details`;let a=document.createElement(`span`);a.className=`tooltip-commit-message`,a.textContent=e;let o=document.createElement(`span`);return o.className=`tooltip-commit-meta`,o.textContent=[t&&n&&t!==n?`${t} (@${n})`:t??(n&&`@${n}`),r===null?``:new Date(r).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})].filter(Boolean).join(` · `),i.append(...e?[a]:[],o),i}var G;function nn(){return G||(G=document.createElement(`div`),G.id=`styled-tooltip`,G.setAttribute(`popover`,`manual`),document.body.append(G),G)}function rn(e){typeof e.showPopover==`function`&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}var K=null,an=``,q=null,J=null,on=0,sn=0,cn=!1;function Y(){if(!cn){cn=!0,document.addEventListener(`mousemove`,e=>{on=e.clientX,sn=e.clientY},{passive:!0});for(let e of[`pointerdown`,`wheel`,`scroll`])document.addEventListener(e,()=>Z(),{capture:!0,passive:!0});document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Z()}),window.addEventListener(`blur`,()=>Z())}}var ln=100,un=14,dn=8,X=8;function fn(e,{placement:t=`cursor`}={}){Y(),clearTimeout(q),q=null,J=null,e.prepareTooltip?.(e),t=e.dataset.tooltipPlacement??t;let n=nn(),i=e.dataset.tooltip??``,a=Object.hasOwn(Qt,e.dataset.tooltipIcon??``)?e.dataset.tooltipIcon:``,o=e.dataset.tooltipRepo??``,s=r(e.dataset.tooltipCommit),c=en(e.dataset.tooltipCommitInfo),l=[`stasis`,`sourcemap`].includes(e.dataset.tooltipBundle)?e.dataset.tooltipBundle:``,u=e.dataset.tooltipStats??``,d=e.dataset.tooltipBuilt===`true`,f=e.dataset.tooltipPackage??``,p=e.dataset.tooltipEcosystem??``,m=e.dataset.tooltipVersion??``,h=e.dataset.tooltipFiles??``,g=e.dataset.tooltipLoc??``,_=e.dataset.tooltipSize??``,v=e.tooltipContent??null,y=v??JSON.stringify([i,a,o,s,c,l,u,d,f,p,m,h,g,_]);if(!i){Z();return}if(K===e&&an===y)return;if(n.textContent=a||v?``:i,v){let e=document.createElement(`div`);e.className=`tooltip-rich`,k(v,e),n.append(e)}if(a){let e=document.createElement(`span`);e.className=`tooltip-text`,e.innerHTML=j(Qt[a]);let t=document.createElement(`span`);t.textContent=i,e.append(t),n.append(e)}if(f){let t=document.createElement(`div`);t.className=`tooltip-package`;let r=(e.querySelector(`[data-tooltip-package-icon] svg`)??e.querySelector(`svg`))?.cloneNode(!0);r&&t.append(r);let i=document.createElement(`span`);i.className=`tooltip-package-details`;let a=(e,t)=>/^\d+$/u.test(e)?`${Number(e).toLocaleString()} ${t}`:``;for(let e of[f,m,a(h,h===`1`?`file`:`files`),a(g,`LoC`),_].filter(Boolean)){let t=document.createElement(`span`);t.textContent=e,i.append(t)}t.append(i),n.append(t)}if(o||s){let e=document.createElement(`div`);if(e.className=`tooltip-repo`,o){e.innerHTML=j(x);let t=document.createElement(`span`);t.textContent=o,e.append(t)}if(s){let t=document.createElement(`span`);t.className=`tooltip-commit`,t.innerHTML=j(S);let n=document.createElement(`span`);n.textContent=s.slice(0,7),t.append(n),e.append(t)}if(n.append(e),s&&c?.tags.length){let e=document.createElement(`div`);e.className=`tooltip-tags`;for(let t of c.tags.slice(0,$t)){let n=document.createElement(`span`);n.className=`tooltip-tag`,n.innerHTML=j(ee);let r=document.createElement(`span`);r.textContent=t,n.append(r),e.append(n)}if(c.tags.length>$t){let t=document.createElement(`span`);t.className=`tooltip-tag-more`,t.textContent=`+${(c.tags.length-$t).toLocaleString()} more`,e.append(t)}n.append(e)}}if(c?.details&&n.append(tn(c.details)),l||u||d){let e=document.createElement(`div`);if(e.className=`tooltip-bundle`,l===`stasis`){let t=document.createElement(`img`);t.src=`./stasis.svg`,t.alt=``,e.append(t)}else e.innerHTML=j(te);let t=document.createElement(`span`);t.textContent=[l===`stasis`?`Stasis`:l===`sourcemap`?`Sourcemap`:``,d?`Built on server`:``,u].filter(Boolean).join(` · `),e.append(t),n.append(e)}rn(n),n.style.left=`0px`,n.style.top=`0px`,n.style.transform=`none`,n.classList.add(`visible`);let b=on,C=sn+un;if(t===`right`||t===`right-start`){let n=e.getBoundingClientRect();b=n.right+dn,C=n.top+(t===`right`?n.height/2:0)}let w=window.innerWidth-n.offsetWidth-X,T=Math.max(X,Math.min(b,w));n.style.left=`${Math.round(T)}px`;let E=n.offsetHeight,D=t===`right`?C-E/2:C,O=window.innerHeight-E-X,ne=Math.max(X,Math.min(D,O));n.style.top=`${Math.round(ne)}px`,K=e,an=y}function Z(e){e&&!e.contains(K)&&!e.contains(J)||(clearTimeout(q),q=null,J=null,G&&(G.classList.remove(`visible`),typeof G.hidePopover==`function`&&G.matches(`:popover-open`)&&G.hidePopover()),K=null)}function pn(e,{gate:t,placement:n}={}){Y();let r=()=>e.isConnected!==!1&&(!Object.hasOwn(e.dataset,`tooltipTruncated`)||e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&(!t||t(e));if(!r()){Z();return}e===K||e===J||(Z(),J=e,q=setTimeout(()=>{q=null,J=null,r()&&fn(e,{placement:n})},ln))}var mn=new WeakSet;function hn(e,t){for(let n of e.composedPath()){if(n===t)break;if(n.nodeType===1&&Object.hasOwn(n.dataset,`tooltip`))return n}return null}function gn(e,t){!e||mn.has(e)||(mn.add(e),e.ownerDocument&&Y(),e.addEventListener(`mouseover`,n=>{if(n.buttons){Z();return}let r=hn(n,e);if(!r){Z();return}r!==K&&pn(r,t)}),e.addEventListener(`mouseout`,t=>{let n=hn(t,e),r=t.relatedTarget?.closest?.(`[data-tooltip]`)??null;n&&n===r||Z()}),e.addEventListener(`scroll`,()=>Z(e),{capture:!0,passive:!0}))}var _n=!1;function vn(){_n||(_n=!0,Y(),document.addEventListener(`tooltip-root-connected`,e=>{gn(e.composedPath()[0]?.shadowRoot)}),document.body.addEventListener(`mouseover`,e=>{if(e.target.closest(`[data-tooltip-managed]`))return;if(e.buttons){Z();return}let t=e.target.closest(`[data-tooltip]`);!t||t===K||pn(t)}),document.body.addEventListener(`mouseout`,e=>{e.target.closest(`[data-tooltip-managed]`)||e.relatedTarget?.closest?.(`[data-tooltip-managed]`)||!K&&!q||(K??J)?.contains(e.relatedTarget)||Z()}))}function yn(e){return`tree-`+e.replaceAll(/[^\w-]+/gu,`_`)}var bn=()=>Object.fromEntries(f.map(e=>[e,0]));function xn(e,t){let n=new Map;for(let r of e)for(let e of r){n.has(e.file)||n.set(e.file,bn());let r=n.get(e.file),i=p(e,t);r[i]!==void 0&&r[i]++}return n}var Q={trees:[],merged:null};function Sn(e){let t=e.map(e=>e?.tree??null);return t.length===Q.trees.length&&t.every((e,t)=>e===Q.trees[t])||(Q={trees:t,merged:Cn(e)}),Q.merged}function Cn(e){let t=null;for(let n of e)if(n?.tree){t||={};for(let e of Object.keys(n.tree)){let r=n.tree[e];if(!t[e]){t[e]={...r,imports:[...r.imports??[]]};continue}let i=new Set(t[e].imports);for(let n of r.imports??[])i.has(n)||(i.add(n),t[e].imports.push(n));t[e].size==null&&r.size!=null&&(t[e].size=r.size)}}return t}function wn(e,t){let n=Object.keys(e),r=new Map(n.map((e,t)=>[e,t])),i=n.map(()=>bn()),a=n.map(()=>[]);for(let[t,i]of n.entries())for(let n of e[i].imports??[]){let e=r.get(n);e!==void 0&&a[e].push(t)}let o=new Uint32Array(n.length),s=0;for(let[e,n]of t){let t=r.get(e);if(t===void 0||!n)continue;let c=f.map(e=>[e,n[e]??0]).filter(([,e])=>e!==0);if(c.length===0)continue;let l=++s,u=[],d=e=>{o[e]!==l&&(o[e]=l,u.push(e))};for(let e of a[t])d(e);for(;u.length>0;){let e=u.pop();for(let[t,n]of c)i[e][t]+=n;for(let t of a[e])d(t)}}return new Map(n.map((e,t)=>[e,i[t]]))}function Tn(e,t,n){let r=t.get(e),i=n.get(e);return En(r)>0||En(i)>0}function En(e){if(!e)return 0;let t=0;for(let n of f)t+=e[n]??0;return t}function Dn(e){if(!e)return null;let t=Ie(),n=RegExp(`^(?:.*/)?${t}/(@[^/]+/[^/]+|[^/]+)`,`u`),r=e.match(n);return r?r[1]:`__own__`}function On(e){return new Set(e.filter(e=>!V(e)))}var kn=[`#4e9af1`,`#f28e2b`,`#59a14f`,`#e15759`,`#76b7b2`,`#edc948`,`#b07aa1`,`#ff9da7`,`#9c755f`,`#5cd1e5`,`#f1ce63`,`#d37295`,`#a0cbe8`,`#86bcb6`,`#8cd17d`,`#b6992d`,`#499894`,`#e15759`,`#e879c7`,`#d4a6c8`],An=[`#2f8aef`,`#d2691e`,`#2ea043`,`#e63946`,`#2e9a92`,`#b88817`,`#9560e8`,`#d24a9c`,`#8a5d40`,`#0891b2`,`#a07a14`,`#c14e8e`,`#1f7ad0`,`#549b94`,`#3fb95f`,`#a07a14`,`#2a8278`,`#cb2c40`,`#c026d3`,`#965f93`];function jn(){if(typeof document>`u`)return!1;let e=document.body?.classList;return!!e&&(e.contains(`theme-light`)||e.contains(`theme-pink`)||e.contains(`theme-w95`)||e.contains(`theme-paper`))}var $=new Map;function Mn(e){let t=jn()?An:kn;return t[e%t.length]}var Nn=()=>jn()?`#8c959f`:`#6e7681`;function Pn(e){let t=jn(),n=t?An:kn,r=e??`__own__`,i=`${t?`l`:`d`}:${r}`;if($.has(i))return $.get(i);let a=0;for(let e of r)a=a*37+e.codePointAt(0)|0;let o=n[((a%n.length+n.length)%n.length*7+3)%n.length];return $.set(i,o),o}var Fn={package:`@babel/core`,path:/^lib\/config\//u},In={package:`@babel/core`,path:/^lib\/config\/files\/(?:module-types|plugins)\.js$/u},Ln=Object.freeze([{id:`react-native-codegen-discovery`,reason:`Codegen discovers package metadata and React Native configuration.`,from:{package:`react-native`,path:/^scripts\/codegen\/generate-artifacts-executor\.js$/u},to:{path:/(?:^|\/)(?:package\.json|react-native\.config\.js)$/u}},{id:`react-native-release-version`,reason:`The CLI release checker reads the installed React Native version.`,from:{package:`@react-native-community/cli-tools`,path:/^build\/releaseChecker\/index\.js$/u},to:{package:`react-native`,path:/^package\.json$/u}},{id:`react-native-platform-config`,reason:`React Native configuration loads platform CLIs supplied by the host project.`,from:{package:`react-native`,path:/^react-native\.config\.js$/u},to:{package:/^@react-native-community\/cli-platform-(?:android|ios)$/u,path:/^build\/index\.js$/u}},{id:`babel-project-config`,reason:`Babel discovers project configuration.`,from:Fn,to:{path:/(?:^|\/)babel\.config\.js$/u}},{id:`babel-typescript-preset`,reason:`Babel configuration loads the TypeScript preset.`,from:Fn,to:{package:`@babel/preset-typescript`,path:/./u}},{id:`babel-react-native-preset`,reason:`Babel config loaders load the configured React Native preset.`,from:In,to:{package:`@react-native/babel-preset`,path:/^(?:src\/)?index\.js$/u}},{id:`babel-reanimated-plugin`,reason:`Babel config loaders load the configured Reanimated plugin, including scoped copies.`,from:In,to:{package:/^(?:@[^/]+\/)?react-native-reanimated$/u,path:/^plugin\/index\.js$/u}},{id:`babel-transform-plugin`,reason:`Babel config loaders load configured transform plugins.`,from:In,to:{package:/^@babel\/plugin-transform-[^/]+$/u,path:/^lib\/index\.js$/u}},{id:`cosmiconfig-config`,reason:`Cosmiconfig loads discovered configuration, including dependency configuration.`,from:{package:`cosmiconfig`,path:/^dist\/loaders\.js$/u},to:{path:/\.config\.js$/u}},{id:`import-fresh-own-config`,reason:`import-fresh loads host-project configuration.`,from:{package:`import-fresh`,path:/./u},to:{path:/\.config\.js$/u},ownSourceOnly:!0}].map(e=>Object.freeze({...e,from:Object.freeze(e.from),to:Object.freeze(e.to)})));function Rn(e){return typeof e==`string`&&!e.includes(`\\`)&&!e.includes(`:`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`node_modules`)}function zn(e,t){let n=e.package;return n!==void 0&&t.ownSource===!0?!1:(n===void 0||(typeof n==`string`?n===t.package:n.test(t.package??``)))&&e.path.test(t.path)}function Bn(e,t){if(e?.ownSource!==!0&&Rn(e?.path)&&Rn(t?.path))return Ln.find(n=>(!n.ownSourceOnly||t.ownSource===!0)&&zn(n.from,e)&&zn(n.to,t))}function Vn(e,t){let n=e.split(/(?:^|\/)node_modules\//u).slice(1).at(-1)?.match(/^(@[^/]+\/[^/]+|[^/]+)\/(.+)$/u);return{package:n?.[1],path:n?.[2]??e.replace(/^\/+/u,``),ownSource:t??i(e)===`__own__`}}function Hn(e,t,n,r){return!Bn(Vn(e,r),Vn(t,n))}function Un(e,t=e=>e.file){let n=new Map(e.nodes.map(e=>[e.file,e])),r=new Map(e.nodes.map(e=>[t(e),new Set]));for(let[i,a]of e.importsOf){let o=n.get(i);if(o)for(let s of a){let a=n.get(s);a&&Hn(o.origFile??i,a.origFile??s,e.ownSourceFiles?.has(s),e.ownSourceFiles?.has(i))&&r.get(t(o)).add(t(a))}}return r}var Wn=class{constructor(e){this.nodes=[...e];for(let[e,t]of this.nodes.entries())t.position=e;for(let e=(this.nodes.length>>1)-1;e>=0;e--)this.down(e)}before(e,t){return Math.abs(e.balance)>Math.abs(t.balance)||Math.abs(e.balance)===Math.abs(t.balance)&&(e.balance>t.balance||e.balance===t.balance&&e.tie<t.tie)}swap(e,t){let n=this.nodes,r=n[e];n[e]=n[t],n[t]=r,n[e].position=e,n[t].position=t}down(e){let t=this.nodes;for(;2*e+1<t.length;){let n=2*e+1;if(n+1<t.length&&this.before(t[n+1],t[n])&&n++,!this.before(t[n],t[e]))break;this.swap(e,n),e=n}}update(e){if(e.position<0)return;let t=e.position;for(;t>0;){let n=t-1>>1;if(!this.before(e,this.nodes[n]))break;this.swap(t,n),t=n}this.down(t)}take(){let e=this.nodes[0],t=this.nodes.pop();return e.position=-1,this.nodes.length>0&&(this.nodes[0]=t,t.position=0,this.down(0)),e}};function Gn(e,t){for(let n=0;n<8;n++){let r=!1;for(let i=0;i<e.length-1;i++){let a=n%2?e.length-2-i:i,o=e[a],s=e[a+1];(t.get(s)?.get(o)?.cycleCount??0)<=(t.get(o)?.get(s)?.cycleCount??0)||(e[a]=s,e[a+1]=o,r=!0)}if(!r)break}return e}function Kn(e){let t=[],n=new Set;for(let t of e.values())t.outgoing.sort((e,t)=>t[1]-e[1]||e[0].tie-t[0].tie);for(let r of e.values()){if(n.has(r))continue;let e=[{node:r,next:0}];for(n.add(r);e.length>0;){let r=e.at(-1);if(r.next===r.node.outgoing.length){t.push(r.node.id),e.pop();continue}let i=r.node.outgoing[r.next++][0];n.has(i)||(n.add(i),e.push({node:i,next:0}))}}return t.toReversed()}function qn(e,t){let n=new Map(e.map((e,t)=>[e,t])),r=0;for(let e of t.values())for(let[t,i]of e.outgoing)n.get(e.id)<n.get(t.id)&&(r+=i);return r}function Jn(e,t){let n=qn(e,t),r=n,i=0;for(let a=0;a<e.length-1;a++)n-=t.get(e[a]).originalBalance,n>r&&(r=n,i=a+1);return[...e.slice(i),...e.slice(0,i)]}function Yn(e,t){if(e.length<2)return e;let n=new Map(e.map((e,t)=>[e,{id:e,tie:t,balance:0,incoming:[],outgoing:[]}]));for(let e of n.values())for(let r of t.get(e.id)?.values()??[]){let t=n.get(r.to);!t||t===e||!r.cycleCount||(e.outgoing.push([t,r.cycleCount]),t.incoming.push([e,r.cycleCount]),e.balance+=r.cycleCount,t.balance-=r.cycleCount)}for(let e of n.values())e.originalBalance=e.balance;let r=[],i=new Wn(n.values()),a=[];for(;i.nodes.length>0;){let e=i.take();e.balance>=0?r.push(e.id):a.push(e.id);for(let[t,n]of e.outgoing)t.position<0||(t.balance+=n,i.update(t));for(let[t,n]of e.incoming)t.position<0||(t.balance-=n,i.update(t))}let o=e,s=qn(e,n);for(let i of[[...r,...a.toReversed()],Kn(n),e,e.toReversed()]){let e=Gn(Jn(i,n),t),r=qn(e,n);r>s&&(o=e,s=r)}return o}function Xn(e,t){let n=new Set(e),r=new Map(e.map(e=>[e,[]]));for(let[e,i]of t)for(let t of i)n.has(e)&&n.has(t)&&r.get(t).push(e);let i=[],a=new Set;for(let r of e){if(a.has(r))continue;a.add(r);let e=[[r,(t.get(r)??[])[Symbol.iterator]()]];for(;e.length>0;){let[r,o]=e.at(-1),s=o.next();if(s.done){i.push(r),e.pop();continue}n.has(s.value)&&!a.has(s.value)&&(a.add(s.value),e.push([s.value,(t.get(s.value)??[])[Symbol.iterator]()]))}}let o=new Map,s=[];for(let e of i.toReversed()){if(o.has(e))continue;let t=[],n=s.length,i=[e];for(o.set(e,n);i.length>0;){let e=i.pop();t.push(e);for(let t of r.get(e))o.has(t)||(o.set(t,n),i.push(t))}s.push(t.toSorted())}return{groups:s,componentOf:o}}function Zn(e,{expanded:t=new Set,order:n=`structure`,query:r=``,neighborhood:i=null,cyclesOnly:o=!1}={}){let s=new Map,c=new Map,l=new Map;for(let n of e.nodes){let e=t.has(n.pkg),r=`${e?`f`:`p`}:${e?n.file:n.pkg}`;s.has(r)||s.set(r,{id:r,pkg:n.pkg,file:e?n.file:null,label:e?n.file:a(n.pkg),files:[],size:0,issues:0,incoming:0,outgoing:0,importers:0,dependencies:0});let i=s.get(r);i.files.push(n.file),i.size+=n.size??0,i.issues+=n.totalIssues??0,c.set(n.file,r),l.set(n.file,n.origFile??n.file)}let u=new Map,d=new Set,f=new Set,p=new Map([...s.keys()].map(e=>[e,new Set])),m=0;for(let[t,n]of e.importsOf){let r=c.get(t);if(r)for(let i of new Set(n)){let n=c.get(i);if(!n)continue;u.has(r)||u.set(r,new Map),u.get(r).has(n)||u.get(r).set(n,{from:r,to:n,count:0,cycleCount:0,examples:[]});let a=u.get(r).get(n);a.count++;let h=Hn(l.get(t),l.get(i),e.ownSourceFiles?.has(i),e.ownSourceFiles?.has(t));a.examples.length<80&&(!o||h)&&a.examples.push([t,i]),m++,s.get(r).outgoing++,s.get(n).incoming++,r!==n&&(f.add(r),d.add(n)),h&&(a.cycleCount++,(r!==n||s.get(r).file)&&p.get(r).add(n))}}let h=[...s.keys()].toSorted(),{groups:g,componentOf:_}=Xn(h,p),v=new Set(g.flatMap(e=>e.length>1||p.get(e[0]).has(e[0])?e:[]));for(let e of s.values())e.cyclic=v.has(e.id),e.component=_.get(e.id);let ee=e.ownSourcePackages??new Set(e.layerRoots?.roots??[]),y=e=>e.pkg===`__own__`?0:ee.has(e.pkg)?1:2,b=e=>d.has(e.id)&&f.has(e.id)?0:1,te=new Map(g.map((e,t)=>[t,e.reduce((e,t)=>Math.min(e,y(s.get(t))),2)])),x=(e,t)=>e.pkg.localeCompare(t.pkg)||e.label.localeCompare(t.label),S=new Map;if(n===`structure`){for(let e of g)if(!(e.length<2))for(let t of Map.groupBy(e,e=>y(s.get(e))).values())Yn(t.toSorted((e,t)=>x(s.get(e),s.get(t))),u).forEach((e,t)=>S.set(e,t))}if(o){m=0,d.clear(),f.clear();for(let e of s.values())e.incoming=0,e.outgoing=0}for(let[e,t]of u){for(let n of t.values())if(n.cyclic=n.cycleCount>0&&v.has(e)&&_.get(e)===_.get(n.to)&&(e!==n.to||s.get(e).file!==null),o){if(!n.cyclic){t.delete(n.to);continue}n.count=n.cycleCount,m+=n.count,s.get(e).outgoing+=n.count,s.get(n.to).incoming+=n.count,e!==n.to&&(f.add(e),d.add(n.to))}t.size===0&&u.delete(e)}for(let[e,t]of u)for(let n of t.keys())e!==n&&(s.get(e).dependencies++,s.get(n).importers++);let C=r.trim().toLowerCase(),w=new Set(h.filter(e=>!C||s.get(e).files.some(e=>e.toLowerCase().includes(C))||s.get(e).label.toLowerCase().includes(C))),T=new Set(i?[i]:w);if(C||i)for(let[e,t]of u)for(let n of t.keys())(i?e===i:w.has(e))&&T.add(n),(i?n===i:w.has(n))&&T.add(e);let E=(e,t)=>{if(n===`structure`){let n=te.get(e.component)-te.get(t.component);if(n)return n;let r=b(e)-b(t);if(r)return r;let i=e.component-t.component;if(i)return i}let r=y(e)-y(t);if(r)return r;if(n===`importers`)return t.importers-e.importers||x(e,t);if(n===`imports`)return t.dependencies-e.dependencies||x(e,t);let i=b(e)-b(t);if(i)return i;if(n===`structure`&&e.component===t.component){let n=(S.get(e.id)??0)-(S.get(t.id)??0);if(n)return n}return x(e,t)},D=[...s.values()].filter(e=>T.has(e.id)&&(!o||e.cyclic)).toSorted(E),O=new Map(D.map((e,t)=>[e.id,t])),k=[];for(let[e,t]of u)if(O.has(e))for(let n of t.values())O.has(n.to)&&k.push({...n,row:O.get(e),col:O.get(n.to)});return{rows:D,byId:s,cells:u,visibleCells:k,index:O,matches:w,importCount:m,totalRows:s.size,cycleCount:g.filter(e=>v.has(e[0])).length}}export{ne as a,j as b,ae as c,M as d,oe as e,N as f,se as g,ce as h,le as i,ue as j,de as k,P as l,pe as m,he as n,_e as o,ve as p,ye as q,be as r,xe as s,I as t,Se as u,Ce as v,we as w,Te as x,De as y,Oe as z,ke as A,Fe as B,Ie as C,V as D,Re as E,He as F,Ue as G,Ke as H,qe as I,Je as J,Ye as K,tt as L,H as M,at as N,lt as O,mt as P,vt as Q,xt as R,W as S,Ct as T,Tt as U,Et as V,Ot as W,kt as X,At as Y,jt as Z,Nt as _,Pt as $,Gt as aa,Kt as ba,Zt as ca,fn as da,Z as ea,pn as fa,gn as ga,vn as ha,yn as ia,xn as ja,Sn as ka,wn as la,Tn as ma,En as na,Dn as oa,On as pa,Mn as qa,Nn as ra,Pn as sa,Yn as ta,Hn as ua,Un as va,Xn as wa,Zn as xa};
28
+ /*! Bundled license information:
29
+
30
+ lit-html/directives/class-map.js:
31
+ (**
32
+ * @license
33
+ * Copyright 2018 Google LLC
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ *)
36
+ */