ccdeck 3.22.1 → 3.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSING.md CHANGED
@@ -5,34 +5,108 @@ ccdeck is licensed under the **GNU Affero General Public License v3.0 only**
5
5
 
6
6
  Copyright © 2026 Bargan Constantin.
7
7
 
8
- ## What changed, and when
9
-
10
- Everything up to and including **3.21.4** was published under the MIT licence,
11
- under all three npm names (`ccdeck`, `agents-deck`, `agent-dag`). The AGPL
12
- applies from **3.22.0** onward, which is the first release cut under it.
13
-
14
- ## The old releases are still MIT
15
-
16
- This is the part worth being exact about, because relicensing is often
17
- described sloppily.
18
-
19
- - **Versions already published under MIT stay MIT.** 3.21.4 and everything
20
- before it were distributed under the MIT licence, and they remain available
21
- on those terms. Changing the licence in this repository does not reach
22
- backwards into copies that are already out in the world.
23
- - **Rights already granted are not revoked.** If you received ccdeck under
24
- MIT, you keep the MIT permissions you were given for that copy — including
25
- the right to use, modify, redistribute and sublicense it, and to build
26
- closed-source work on it. Nothing here takes that away.
27
- - **Old tags and releases stay up.** Git tags up to `v3.21.4`, the GitHub
28
- releases and the npm versions are not being deleted or rewritten. The MIT
29
- licence text that shipped inside each of those artifacts is still the licence
30
- for that artifact.
31
- - **The new licence is not retroactive.** Do not read this change as "ccdeck
32
- is now AGPL, therefore the old copies are too." It is not, and they are not.
33
-
34
- What the change does affect is the code in this repository going forward, and
35
- any release built from it after the relicensing commit.
8
+ ## The current licence covers the whole codebase
9
+
10
+ The **complete current ccdeck-owned codebase** is offered under
11
+ `AGPL-3.0-only`. Not merely the commits made after the change — the whole
12
+ work, as the project distributes it today.
13
+
14
+ This is worth stating plainly because relicensing is often misread as applying
15
+ only to what came after it. It does not. The code implementing the canvas, the
16
+ session clusters, the tool-call timeline, the quota and usage panels, the LAN
17
+ sync, the installer and the hook was written before the licence changed, and
18
+ it is part of the current work. When that code ships in a current release, the
19
+ licence the project offers it under is the AGPL.
20
+
21
+ A licence applies to software — to the code — rather than to a feature as an
22
+ idea. So the accurate statement is not "the features are AGPL" but: the
23
+ complete current ccdeck-owned codebase, including the code implementing
24
+ features that existed before the relicensing, is distributed by the project
25
+ under `AGPL-3.0-only`.
26
+
27
+ The copyright holder is relicensing the complete current work, which is
28
+ something a sole copyright holder may do with their own code. That some of
29
+ this code also appeared in older MIT releases does **not** mean the project
30
+ offers the current repository or the current release under MIT.
31
+
32
+ ## The version boundary
33
+
34
+ ```text
35
+ v3.22.0 and later:
36
+ Distributed by the project under AGPL-3.0-only — the complete current
37
+ ccdeck-owned codebase, including the code implementing features that
38
+ existed before the relicensing.
39
+
40
+ v3.21.4 and earlier:
41
+ Historically distributed under the MIT License. Previously granted MIT
42
+ rights in the material distributed in those releases remain valid.
43
+ ```
44
+
45
+ 3.22.0 is the first release the project distributes under the AGPL.
46
+
47
+ ## ccdeck is not offered as "MIT OR AGPL"
48
+
49
+ The project does **not** currently offer ccdeck under a choice of licences.
50
+ There is no MIT option and no MIT fallback on what the project distributes
51
+ today: obtain the current release from the project, and the licence it is
52
+ offered to you under is `AGPL-3.0-only`.
53
+
54
+ That is a statement about what the project offers now. It is not a statement
55
+ about rights somebody was already granted — see
56
+ [Historical releases](#historical-releases) for those.
57
+
58
+ ## Historical releases
59
+
60
+ Before the AGPL relicensing, certain ccdeck releases were distributed under the
61
+ MIT License.
62
+
63
+ Those historical copies retain the rights granted under the license under which
64
+ they were originally distributed. Those previously granted rights cannot be
65
+ retroactively revoked.
66
+
67
+ This does not mean that the project dual-licenses ccdeck, or offers part of the
68
+ current work under MIT. The current ccdeck-owned codebase and current releases
69
+ are offered by the project exclusively under `AGPL-3.0-only`.
70
+
71
+ Concretely, and without overstating it:
72
+
73
+ - **Old releases stay usable on their old terms.** Somebody who lawfully
74
+ obtained ccdeck 3.21.4 or earlier under MIT keeps the MIT rights they were
75
+ granted in the material distributed in those releases — including the right
76
+ to use, modify, redistribute and build closed-source work on it. Those
77
+ rights are theirs already, and this change does not touch them.
78
+ - **The old artifacts stay up.** Git tags through `v3.21.4`, the GitHub
79
+ releases and the npm versions are not being deleted, unpublished or
80
+ rewritten. The MIT text that shipped inside each of those artifacts is still
81
+ the licence for that artifact. Removing them would not withdraw anything
82
+ anyway.
83
+ - **Nothing became AGPL retroactively.** A copy distributed under MIT was
84
+ distributed under MIT and stays that way. Do not read this page as saying
85
+ the old releases are now AGPL, because they are not.
86
+
87
+ ## What the historical MIT grants do and do not cover
88
+
89
+ Two things are true at once, and both matter:
90
+
91
+ - **The current ccdeck release, as distributed by the project, is licensed
92
+ under `AGPL-3.0-only`.** That is the licence on offer for what you obtain
93
+ from the project today.
94
+ - **Previously granted MIT rights in material distributed in historical MIT
95
+ releases remain valid.** They were granted, they cannot be retroactively
96
+ revoked, and they do not disappear merely because identical or substantially
97
+ identical code also appears in a later AGPL release.
98
+
99
+ What those historical grants do **not** do is reach forward. They do not cover
100
+ new code, or modifications, first distributed under the AGPL. A later release
101
+ is not placed under MIT because it contains material that also appeared in an
102
+ MIT release: the new and changed code in it is offered by the project under
103
+ the AGPL only.
104
+
105
+ Where the line falls between material already distributed under MIT and code
106
+ first distributed under the AGPL is a question about specific code, and this
107
+ page does not try to settle it for any particular file. What the project can
108
+ state is what it offers, and what it offers for the current release is
109
+ `AGPL-3.0-only`.
36
110
 
37
111
  ## Why AGPL
38
112
 
@@ -41,13 +115,13 @@ functionality. The AGPL is chosen so that modifications to the covered software
41
115
  stay open — including modified versions that users interact with over a
42
116
  network, which is the case an ordinary GPL does not cover.
43
117
 
44
- The intent is to keep ccdeck open source while making it harder for a modified
45
- version to be run as a closed-source competing hosted service. Precisely: the
46
- AGPL requires whoever runs a modified version to make the corresponding source
47
- available **to the users interacting with that modified version over a
48
- network**. It does not require anyone to send changes to this repository, open
49
- a pull request, or contribute anything upstream — there is no obligation to
50
- this project, only to those users.
118
+ The intent is to keep ccdeck open source and ensure that users of modified
119
+ network-hosted versions can also access the corresponding source code.
120
+ Precisely: the AGPL requires whoever runs a modified version to make the
121
+ corresponding source available **to the users interacting with that modified
122
+ version over a network**. It does not require anyone to send changes to this
123
+ repository, open a pull request, or contribute anything upstream — there is no
124
+ obligation to this project, only to those users.
51
125
 
52
126
  ## What this means if you use ccdeck
53
127
 
@@ -73,6 +147,10 @@ Their copyright and permission notices are preserved in
73
147
  [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md) and must travel with any
74
148
  copy of ccdeck.
75
149
 
150
+ Those MIT and ISC notices describe **dependencies**, not ccdeck. They are not a
151
+ second licence on ccdeck's own code, and their presence in the tree does not
152
+ put ccdeck's own code under MIT.
153
+
76
154
  ccdeck claims copyright only over its own code, not over that third-party code.
77
155
 
78
156
  ## Contributing
package/README.md CHANGED
@@ -459,24 +459,17 @@ and starts again when you log in. `ccdeck --stop` ends it.
459
459
 
460
460
  ## License
461
461
 
462
- ccdeck is licensed under the GNU Affero General Public License v3.0 only
463
- (AGPL-3.0-only).
462
+ ccdeck is licensed under the **GNU Affero General Public License v3.0 only (AGPL-3.0-only)**.
464
463
 
465
- Copyright © 2026 [Bargan Constantin](https://github.com/BarganConstantin).
466
-
467
- See [LICENSE](./LICENSE) for the full text.
464
+ The current release, as distributed by the project, is offered under the AGPL
465
+ in full: the complete current ccdeck-owned codebase, including the code
466
+ implementing features that existed before the relicensing.
468
467
 
469
- Running the deck imposes nothing on you. The AGPL's obligations attach to
470
- distributing ccdeck or offering a **modified** version to users over a network
471
- — and what they require is that those users be offered the corresponding
472
- source of that modified version, not that anyone contribute changes back to
473
- this repository.
468
+ Copyright © 2026 [Bargan Constantin](https://github.com/BarganConstantin).
474
469
 
475
- Releases up to and including **3.21.4** were published under the MIT licence
476
- and remain available under MIT — this change is not retroactive and revokes
477
- nothing already granted. [LICENSING.md](./LICENSING.md) explains what applies
478
- to which version.
470
+ See [LICENSE](./LICENSE) for the full license text and
471
+ [LICENSING.md](./LICENSING.md) for licensing history and additional details.
479
472
 
480
473
  ccdeck bundles third-party code under permissive licences (MIT, ISC,
481
- BSD-3-Clause); their notices are preserved in
482
- [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).
474
+ BSD-3-Clause). Those licences are theirs, not ccdeck's, and their notices are
475
+ preserved in [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).
@@ -260,7 +260,7 @@ Both CLIs get the finish tone. The second tone — Claude is waiting for you —
260
260
 
261
261
  Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return c+d+h+`
262
262
 
263
- Click to set the volume and the sound of each tone, and to hear either one.`}function G2(e){const t=new Map;for(const n of e)for(const s of n.agents??[]){if(!s||typeof s.agent!="string"||s.agent==="")continue;const a=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};a.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,a.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,a)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function VF(e){const t=G2([{agents:e}]);return t.length<2?null:t.map(n=>`${_x(n.id)} ${tt(n.cost)}`).join(" · ")}function F1(e){switch(e.toLowerCase()){case"claude":return"var(--usage-purple)";case"codex":return"var(--usage-orange)";case"gemini":return"var(--usage-indigo)";case"copilot":return"var(--usage-green)";default:return"var(--usage-zinc)"}}function YF(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Ou(e){const t=e.toLowerCase();return t.includes("opus")?"var(--usage-purple)":t.includes("sonnet")?"var(--usage-blue)":t.includes("haiku")?"var(--usage-green)":t.includes("gpt-5")||t.includes("gpt5")?"var(--usage-amber)":t.includes("gpt")?"var(--usage-red)":t.includes("gemini")?"var(--usage-indigo)":t.includes("codex")?"var(--usage-orange)":"var(--usage-zinc)"}const KF=[7,14,30,90];function XF(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useState(FF)[0],c=b.useRef(!1),d=(h=!1)=>{if(h&&!hr(c.current))return;const p=l.begin();c.current=h;const f=e;a(!0);const y=`/api/ccusage?since=${Ev(f)}${h?"&refresh=1":""}`;fetch(y).then(v=>v.json()).then(v=>{p()&&n({range:f,resp:v})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(c.current=!1,a(!1))})};return b.useEffect(()=>(d(!1),()=>l.cancel()),[e]),{landed:t,loading:s,reload:()=>d(!0)}}function QF({onClose:e,providers:t}){var B;const[n,s]=b.useState(30),[a,l]=b.useState(null),{landed:c,loading:d,reload:h}=XF(n),p=b.useRef(null),f=Ht(e,{focusRef:p}),m=BF({loading:d,want:n,answer:c&&{range:c.range,ok:c.resp.ok===!0,days:((B=c.resp.days)==null?void 0:B.length)??0}}),y=m.phase==="chart"?c.resp.days??[]:[],v=b.useMemo(()=>y.reduce((O,M)=>Math.max(O,M.totalCost),0),[y]),S=b.useRef(null);b.useLayoutEffect(()=>{const O=S.current;O&&(O.scrollLeft=O.scrollWidth)},[y]);const{totalCost:_,totalTok:j,inOut:x,cacheRead:N,modelCosts:E}=b.useMemo(()=>{let O=0,M=0,L=0,H=0;const F=new Map;for(const A of y){O+=A.totalCost,M+=A.totalTokens,L+=A.inputTokens+A.outputTokens,H+=A.cacheReadTokens;for(const Q of A.modelBreakdowns)F.set(Q.modelName,(F.get(Q.modelName)??0)+Q.cost)}return{totalCost:O,totalTok:M,inOut:L,cacheRead:H,modelCosts:F}},[y]),C=b.useMemo(()=>Array.from(E.entries()).sort((O,M)=>M[1]-O[1]),[E]),R=b.useMemo(()=>G2(y),[y]),I=R.length>1,$=a?y.find(O=>O.period===a)??null:null;return i.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:f,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[i.jsxs("header",{className:"uh-head",children:[i.jsxs("div",{className:"uh-titlewrap",children:[i.jsx("div",{className:"uh-title",children:"Usage history"}),i.jsx("div",{className:"uh-sub",children:WF(t,R.map(O=>O.id))})]}),i.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:KF.map(O=>i.jsxs("button",{type:"button","aria-pressed":n===O,className:"uh-range-btn",onClick:()=>{s(O),l(null)},children:[O,"d"]},O))}),i.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...dr(d),title:"Re-run ccusage","aria-label":"Reload",children:d?"…":"↻"}),i.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),m.phase==="busy"?i.jsxs("div",{className:"uh-status uh-status-wait","aria-busy":"true",children:[i.jsx("span",{className:"uh-wait-word",children:c?"running ccusage…":"running ccusage… (first run downloads the package)"}),i.jsx("span",{className:"uh-wait-axis","aria-hidden":!0})]}):m.phase==="error"?i.jsxs("div",{className:"uh-status uh-err",title:oi(c.resp)||void 0,children:[GD(c.resp,"ccusage did not report usage"),i.jsx("div",{children:i.jsx("button",{className:"btn uh-retry",onClick:h,...dr(d),children:d?"trying…":"Try again"})})]}):m.phase==="empty"?i.jsx("div",{className:`uh-status${m.stale?" uh-stale":""}`,"aria-busy":m.stale||void 0,children:"no usage in this range"}):i.jsxs("div",{className:m.stale?"uh-stale":void 0,"aria-busy":m.stale||void 0,children:[i.jsxs("div",{className:"uh-totals",children:[i.jsx(Pu,{label:"total cost",val:tt(_),accent:!0}),i.jsx(Pu,{label:"tokens",val:At(j)}),i.jsx(Pu,{label:"input+output",val:At(x)}),i.jsx(Pu,{label:"cache reads",val:At(N)})]}),I&&i.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[i.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:R.map(O=>i.jsx("span",{className:"uh-agent-seg",style:{width:`${_>0?O.cost/_*100:0}%`,background:F1(O.id)}},O.id))}),i.jsx("div",{className:"uh-agent-keys",children:R.map(O=>i.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${At(O.tokens)} tokens`,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:F1(O.id)}}),_x(O.id),i.jsx("span",{className:"uh-agent-cost",children:tt(O.cost)}),i.jsx("span",{className:"uh-agent-share",children:YF(O.cost,_)})]},O.id))})]}),i.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map((O,M)=>{const L=v>0?O.totalCost/v*100:0,H=O.period===a,F=`${O.period}, ${tt(O.totalCost)}`;return i.jsxs("button",{className:`uh-bar-col${H?" sel":""}`,onClick:()=>l(H?null:O.period),"aria-pressed":H,"aria-label":F,title:`${O.period} · ${tt(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`,"--uh-i":M,"--uh-step":`${Math.min(10,200/Math.max(y.length,1))}ms`},children:[i.jsx("div",{className:"uh-bar",style:{height:`${Math.max(L,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((A,Q)=>Q.cost-A.cost).map(A=>{const Q=O.totalCost>0?A.cost/O.totalCost*100:0;return i.jsx("div",{className:"uh-bar-seg",style:{height:`${Q}%`,background:Ou(A.modelName)}},A.modelName)})}),i.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),i.jsx("div",{className:"uh-legend",children:C.map(([O,M])=>i.jsxs("span",{className:"uh-legend-item",title:O,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Ou(O)}}),Ys(O)," ",i.jsx("span",{className:"uh-legend-cost",children:tt(M)})]},O))}),$&&i.jsxs("div",{className:"uh-detail",children:[i.jsxs("div",{className:"uh-detail-head",children:[i.jsx("span",{className:"uh-detail-date",children:$.period}),i.jsx("span",{className:"uh-detail-cost",children:tt($.totalCost)}),(()=>{var L,H;const M=VF($.agents)??((H=(L=$.metadata)==null?void 0:L.agents)!=null&&H.length?$.metadata.agents.join(" · "):null);return M?i.jsx("span",{className:"uh-detail-agents",title:M,children:M}):null})()]}),i.jsxs("div",{className:"uh-detail-mini",children:[i.jsx(Lu,{label:"input",val:At($.inputTokens)}),i.jsx(Lu,{label:"output",val:At($.outputTokens)}),i.jsx(Lu,{label:"cache write",val:At($.cacheCreationTokens)}),i.jsx(Lu,{label:"cache read",val:At($.cacheReadTokens)})]}),i.jsx("div",{className:"uh-detail-models",children:$.modelBreakdowns.slice().sort((O,M)=>M.cost-O.cost).map(O=>{const M=$.totalCost>0?O.cost/$.totalCost*100:0;return i.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[i.jsxs("span",{className:"uh-model-name",children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Ou(O.modelName)}}),i.jsx("span",{className:"uh-model-label",children:Ys(O.modelName)})]}),i.jsx("span",{className:"uh-model-bar",children:i.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Ou(O.modelName)}})}),i.jsx("span",{className:"uh-model-cost",children:tt(O.cost)})]},O.modelName)})})]})]})]})})}function Pu({label:e,val:t,accent:n}){return i.jsxs("div",{className:"uh-stat",children:[i.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),i.jsx("span",{className:"uh-stat-label",children:e})]})}function Lu({label:e,val:t}){return i.jsxs("div",{className:"uh-ministat",children:[i.jsx("span",{className:"uh-ministat-val",children:t}),i.jsx("span",{className:"uh-ministat-label",children:e})]})}function ZF(e){const t=/^#?([0-9a-f]{6})$/i.exec((e??"").trim());if(!t)return!1;const n=parseInt(t[1],16),s=[n>>16&255,n>>8&255,n&255].map(a=>{const l=a/255;return l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const B1=1e4,JF=12e3;function e8({browsers:e,findings:t,watching:n,palette:s,now:a=()=>Date.now()}){const l=b.useRef(null),c=b.useRef(null);return c.current={browsers:e,findings:t,watching:n},b.useEffect(()=>{var v;const d=l.current;if(!d)return;const h=d.getContext("2d");if(!h)return;const p=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,m=!1;const y=()=>{var ee;if(m)return;const S=c.current;if(!S)return;const{browsers:_,findings:j,watching:x}=S,N=s["--accent"]||"#7dd3fc",E=s["--line"]||"#1f2229",C=s["--text-dim"]||"#6e727c",R=ZF(s["--bg"]),I=R?42:26,$=R?.85:.65,B=a(),O=Math.min(window.devicePixelRatio||1,2),M=d.clientWidth,L=d.clientHeight;(d.width!==M*O||d.height!==L*O)&&(d.width=M*O,d.height=L*O),h.setTransform(O,0,0,O,0,0),h.clearRect(0,0,M,L);const H=M/2,F=L/2,A=Math.min(M,L)/2-6;h.strokeStyle=E,h.lineWidth=1,h.globalAlpha=R?1:.9;for(const Z of[.4,.7,1])h.beginPath(),h.arc(H,F,A*Z,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(H-A,F),h.lineTo(H+A,F),h.moveTo(H,F-A),h.lineTo(H,F+A),h.stroke(),h.globalAlpha=1;const K=(x&&!p?B%B1/B1:0)*Math.PI*2-Math.PI/2;if(x){const Z=(ee=h.createConicGradient)==null?void 0:ee.call(h,K-.85,H,F);Z&&(Z.addColorStop(0,"transparent"),Z.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${I}%, transparent)`),Z.addColorStop(1,"transparent"),h.fillStyle=Z,h.beginPath(),h.moveTo(H,F),h.arc(H,F,A,K-.85,K),h.closePath(),h.fill()),h.strokeStyle=N,h.globalAlpha=$,h.beginPath(),h.moveTo(H,F),h.lineTo(H+Math.cos(K)*A,F+Math.sin(K)*A),h.stroke(),h.globalAlpha=1}_.forEach((Z,D)=>{const Y=D/Math.max(_.length,1)*Math.PI*2-Math.PI/2,P=Z.lastReadMs===null?1:Math.min(1,(B-Z.lastReadMs)/12e4),G=A*(.42+P*.5),de=H+Math.cos(Y)*G,W=F+Math.sin(Y)*G,U=Math.abs((K-Y+Math.PI*3)%(Math.PI*2)-Math.PI),J=x?Math.max(0,1-U/.55):0;h.beginPath(),h.arc(de,W,3+J*1.6,0,Math.PI*2),h.fillStyle=Z.running?N:C,h.globalAlpha=Z.running?.55+J*.45:.35,h.fill(),h.globalAlpha=1});for(const Z of j){const D=(B-Z.atMs)/JF;if(D<0||D>1)continue;const P=Math.max(0,_.findIndex(W=>W.key===Z.browser))/Math.max(_.length,1)*Math.PI*2-Math.PI/2,G=H+Math.cos(P)*A*.6,de=F+Math.sin(P)*A*.6;h.beginPath(),h.arc(G,de,4+D*22,0,Math.PI*2),h.strokeStyle=N,h.globalAlpha=(1-D)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(y)};return y(),()=>{m=!0,cancelAnimationFrame(f)}},[a,s]),i.jsx("canvas",{ref:l,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const z1="agent-dag.browserWatch.seenMs";function t8(e,t){return e.filter(n=>n.startMs>t)}function n8(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function r8(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function V2(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function U1(e,t){return t?{kind:"saving",word:"Saving",detail:""}:e.settings.enabled?{kind:"on",word:"Watching",detail:""}:{kind:"off",word:"Paused",detail:"nothing new is recorded"}}function s8(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,a)=>s+a.programVisits,0)}))}function a8(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function o8(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],a=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(a>0?`, and ${a} more`:"")+". The watch continues on the profiles it can read."}}const n=V2(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(s=>s.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}function i8(e){const t=n=>new Date(n).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.count===1||e.endMs-e.startMs<6e4?t(e.startMs):`${t(e.startMs)} → ${t(e.endMs)}`}function l8(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function W1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function c8({onClose:e,onSeen:t,onWatching:n,palette:s}){const a=Ht(e),[l,c]=b.useState(null),[d,h]=b.useState(null),[p,f]=b.useState(null),[m,y]=b.useState(!1),v=b.useRef(!1),[S,_]=b.useState(null),[j,x]=b.useState(null),[N,E]=b.useState(!1),C=b.useRef(!1),[R,I]=b.useState(!1),[$,B]=b.useState(!1),[O,M]=b.useState(!1),[L,H]=b.useState(!1),[F,A]=b.useState(!1),[Q,K]=b.useState(()=>Date.now());b.useEffect(()=>{const V=setInterval(()=>K(Date.now()),1e3);return()=>clearInterval(V)},[]);const ee=b.useCallback(async V=>{var ie,pe;if(!(V&&!hr(v.current))){v.current=V,y(!0);try{const me=await fetch(`/api/browser-watch${V?"?refresh=1":""}`);if(!me.ok)throw new Error(`the deck answered ${me.status}`);const Ie=await me.json();c(Ie),C.current||_(((ie=Ie==null?void 0:Ie.settings)==null?void 0:ie.quietMinutes)??15),n(((pe=Ie==null?void 0:Ie.settings)==null?void 0:pe.enabled)===!0),h(null)}catch(me){h(me instanceof Error?me.message:String(me))}finally{v.current=!1,y(!1)}}},[n]);b.useEffect(()=>{ee(!1)},[ee]),b.useEffect(()=>{const V=setInterval(()=>{ee(!1)},1e4);return()=>clearInterval(V)},[ee]);const Z=b.useCallback(async V=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:V.host,startMs:V.startMs})})}finally{await ee(!1)}},[ee]),D=b.useCallback(async V=>{C.current=!0,E(!0);try{const ie=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V)});if(!ie.ok)throw new Error(`the deck answered ${ie.status}`);await ee(!1),f(null)}catch(ie){f(ie instanceof Error?ie.message:String(ie))}finally{C.current=!1,E(!1)}},[ee]),Y=b.useRef(t);Y.current=t,b.useEffect(()=>()=>Y.current(Date.now()),[]);const P=b.useMemo(()=>{const V=[];for(const ie of(l==null?void 0:l.episodes)??[]){const pe=l8(ie.startMs),me=V[V.length-1];me&&me.label===pe?me.episodes.push(ie):V.push({label:pe,episodes:[ie]})}return V},[l]),G=V2(l==null?void 0:l.browsers),de=((l==null?void 0:l.browsers)??[]).filter(V=>!(V.installed&&V.profiles>0)),W=l?o8(l):null,U=G.reduce((V,ie)=>V+ie.profiles,0),J=l?n8(l.coverage.lastHumanMs,l.coverage.quietMs,Q):null;return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal bw-modal",onClick:V=>V.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),i.jsx("span",{className:"modal-tool-id",children:l?`${U} ${U===1?"profile":"profiles"} · local only`:"local only"})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("button",{className:"glyph-btn",onClick:()=>void ee(!0),...dr(m),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:m?"…":"↻"}),i.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("div",{className:"modal-body bw-body",children:[!l&&!d&&i.jsxs("div",{className:"bw-loading",children:[i.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),i.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),d&&i.jsx("div",{className:"bw-state",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not read"}),i.jsx("span",{className:"bw-row-detail",children:d})]})}),l&&W&&i.jsx("p",{className:`bw-trouble ${W.kind}`,role:"status",children:W.text}),l&&i.jsxs("div",{className:"bw-work",children:[i.jsxs("aside",{className:"bw-side",children:[i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",i.jsx("button",{className:"bw-help",onClick:()=>M(V=>!V),"aria-expanded":O,"aria-label":"What the sweep and the dots mean",children:"?"})]}),i.jsxs("div",{className:"bw-glance",children:[i.jsx(e8,{browsers:G.map(V=>{var ie;return{key:V.key,name:V.name,running:V.running,lastReadMs:((ie=l.profiles.find(pe=>pe.browser===V.key))==null?void 0:ie.lastWrittenMs)??null}}),findings:l.episodes.slice(0,6).map(V=>({browser:V.browser??null,atMs:V.endMs})),watching:l.settings.enabled,palette:s}),i.jsx("ul",{className:"bw-counts",children:s8(G,l.profiles).map(V=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-count-n",children:V.visits.toLocaleString("en-US")}),i.jsx("span",{className:"bw-count-of",children:V.name})]},V.key))})]}),i.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),l.coverage.checkedMs>0&&i.jsxs("p",{className:"bw-since",children:["Last checked ",a8(l.coverage.checkedMs,Q),l.coverage.checks>0&&i.jsxs(i.Fragment,{children:[" · ",l.coverage.checks.toLocaleString("en-US")," ",l.coverage.checks===1?"check":"checks"]})]}),J!==null&&i.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",r8(J)]}),O&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Sweep"}),i.jsx("dd",{children:"one poll of every watched profile"}),i.jsx("dt",{children:"Dot"}),i.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),i.jsx("dt",{children:"Ring"}),i.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",i.jsx("button",{className:"bw-help",onClick:()=>H(V=>!V),"aria-expanded":L,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),L&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Running"}),i.jsx("dd",{children:"the browser has a process on this machine right now"}),i.jsx("dt",{children:"Connected"}),i.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),i.jsx("ul",{className:"bw-profiles",children:G.map(V=>i.jsxs("li",{children:[i.jsx("span",{className:`bw-prof-dot${V.running?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-prof-name",children:V.name}),i.jsx("span",{className:"bw-prof-state",children:V.running?"running":"idle"}),V.running&&V.relay.state==="live"&&i.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},V.key))}),de.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>A(V=>!V),"aria-expanded":F,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:F?"▾":"▸"})," ",de.length," not watched"]}),F&&i.jsxs("p",{className:"bw-rest",children:[de.map(V=>V.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]}),l.relay&&i.jsx(u8,{relay:l.relay})]}),i.jsxs("div",{className:"bw-main",children:[i.jsxs("section",{className:"bw-findings",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",l.episodes.length>0&&i.jsxs("span",{className:"bw-feed-count",children:[l.episodes.length," ",l.episodes.length===1?"episode":"episodes"]})]}),i.jsx("div",{className:"bw-eps",children:P.length===0?i.jsxs("div",{className:"bw-empty",children:[i.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),i.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",l.settings.quietMinutes," ",l.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!l.settings.enabled&&i.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):P.map(V=>i.jsxs("div",{className:"bw-day",children:[i.jsx("h4",{className:"bw-sec-head",children:V.label}),V.episodes.map(ie=>{const pe=`${ie.host}-${ie.startMs}`,me=j===pe;return i.jsxs("div",{className:`bw-ep${me?" open":""}`,children:[i.jsxs("div",{className:"bw-ep-row",children:[i.jsxs("button",{className:"bw-ep-head",onClick:()=>x(me?null:pe),"aria-expanded":me,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:me?"▾":"▸"}),i.jsx("span",{className:"bw-ep-host",children:ie.host}),i.jsxs("span",{className:"bw-ep-meta",children:[i8(ie),W1(ie)&&i.jsxs(i.Fragment,{children:[" · ",W1(ie)]})]}),i.jsxs("span",{className:"bw-ep-count",children:[ie.count," ",ie.count===1?"page":"pages"]})]}),i.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Z(ie),"aria-label":`Dismiss ${ie.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),me&&i.jsx("ul",{className:"bw-urls",children:ie.urls.map((Ie,Le)=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-url-time",children:new Date(Ie.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),i.jsx("span",{className:"bw-url",children:Ie.url})]},`${Ie.url}-${Ie.timeMs}-${Le}`))})]},pe)})]},V.label))})]}),i.jsxs("section",{className:"bw-feed",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",i.jsxs("span",{className:"bw-feed-count",children:[l.log.length," ",l.log.length===1?"event":"events"]})]}),i.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),i.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:l.log.length===0?i.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):l.log.map(V=>i.jsxs("div",{className:`bw-log-line ${V.level}${V.parts?"":" sys"}`,children:[i.jsx("span",{className:"bw-log-time",children:new Date(V.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),V.parts?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"bw-log-browser",children:V.parts.browser}),i.jsx("span",{className:"bw-log-profile",title:V.parts.profile,children:V.parts.profile}),i.jsxs("span",{className:"bw-log-value",children:[V.parts.value,V.parts.flagged>0&&i.jsxs("span",{className:"bw-log-flag",children:[" · ",V.parts.flagged," flagged"]})]})]}):i.jsx("span",{className:"bw-log-sys",children:V.text})]},`${V.atMs}-${V.level}-${V.text}`))})]})]})]}),l&&R&&i.jsxs("div",{className:"bw-settings",children:[i.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[i.jsx("span",{children:"Nobody browsing for"}),i.jsxs("select",{value:S??l.settings.quietMinutes,onChange:V=>{_(Number(V.target.value)),D({quietMinutes:Number(V.target.value)})},children:[i.jsx("option",{value:1,children:"1 min"}),i.jsx("option",{value:5,children:"5 min"}),i.jsx("option",{value:15,children:"15 min"}),i.jsx("option",{value:30,children:"30 min"}),i.jsx("option",{value:60,children:"60 min"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"When it finds one"}),i.jsx("select",{value:l.settings.reaction,onChange:V=>void D({reaction:V.target.value}),disabled:!l.settings.enabled,title:l.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(l.reactions??["notify"]).map(V=>i.jsx("option",{value:V,children:V==="notify"?"notify me":V==="close-tab"?"close the tab":"quit the browser"},V))})]}),i.jsxs("div",{className:"bw-settings-note",children:[i.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",i.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),i.jsxs("button",{className:"bw-why",onClick:()=>B(V=>!V),"aria-expanded":$,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:$?"▾":"▸"})," What Browser Watch can access"]}),$&&i.jsxs("dl",{className:"bw-access",children:[i.jsx("dt",{children:"Reads"}),i.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(l.coverage.startedMs).toLocaleString(),"."]}),i.jsx("dt",{children:"Keeps"}),i.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",i.jsx("code",{className:"bw-path",children:l.coverage.logPath}),", with every address written in full so you can check it yourself."]}),i.jsx("dt",{children:"Sends"}),i.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),i.jsx("dt",{children:"Never reads"}),i.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),p&&i.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not save that setting"}),i.jsxs("span",{className:"bw-row-detail",children:[p," — the switches below show what is stored, not what you pressed."]}),i.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>f(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),l&&i.jsxs("footer",{className:"bw-status",children:[i.jsx("span",{className:`bw-mode-dot${l.settings.enabled?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-mode-word",children:U1(l,N).word},U1(l,N).kind),i.jsx("span",{className:"bw-status-text",children:l.coverage.archived===0?l.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${l.coverage.archived} ${l.coverage.archived===1?"episode":"episodes"} on disk`}),i.jsx("button",{className:`glyph-btn bw-gear${R?" on":""}`,onClick:()=>I(V=>!V),"aria-expanded":R,"aria-label":"Settings",title:"Settings",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[i.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),i.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),i.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[i.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),i.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":l.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void D({enabled:!l.settings.enabled}),title:l.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:i.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function u8({relay:e}){const[t,n]=b.useState(!1),[s,a]=b.useState(!1),l=e.killswitch.blocked?"unblock":"block",c=e.command[l],d=b.useCallback(async()=>{await P2(c.command)&&(a(!0),window.setTimeout(()=>a(!1),1600))},[c.command]),h=e.profiles.filter(f=>{var m;return(m=f.report)==null?void 0:m.present}),p=e.profiles.filter(f=>f.report===null);return i.jsxs("section",{className:"bw-sec",children:[i.jsx("h4",{className:"bw-sec-head",children:"Remote control"}),i.jsx("p",{className:`bw-rc-verdict ${e.verdict}`,role:"status",children:e.verdict==="exposed"?"Claude in Chrome is live here, so any Claude Code session signed in to your Anthropic account can drive this browser — from any machine, with no prompt on this one.":e.verdict==="protected"?`The relay is black-holed in ${e.hostsPath}, so no new connection to it can be made from this machine.`:"Claude in Chrome is not installed and enabled in any profile here, so there is nothing for the relay to drive."}),e.killswitch.foreign.length>0&&i.jsxs("p",{className:"bw-rc-foreign",children:["Another entry for this host is already in ",e.hostsPath,", and ccdeck will not touch it:",e.killswitch.foreign.map(f=>i.jsx("code",{className:"bw-path",children:f},f))]}),i.jsxs("button",{className:"bw-why",onClick:()=>n(f=>!f),"aria-expanded":t,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",e.verdict==="protected"?"How to undo the block":"What it can reach, and how to stop it"]}),t&&i.jsxs("div",{className:"bw-rc-body",children:[h.length>0&&i.jsx("dl",{className:"bw-key",children:h.map(f=>i.jsxs(b.Fragment,{children:[i.jsxs("dt",{children:[f.name,f.profile==="Default"?"":` · ${f.profile}`]}),i.jsxs("dd",{children:[f.report.enabled?"enabled":"installed but switched off",f.report.allUrls?", can act on every site":", limited to the sites it was granted",f.report.sensitiveApis.length>0&&i.jsxs(i.Fragment,{children:[" — ",f.report.sensitiveApis.join(", ")]})]})]},`${f.browser}/${f.profile}`))}),p.length>0&&i.jsxs("p",{className:"bw-rc-note",children:[p.map(f=>f.name).join(", ")," — its settings file could not be read, so nothing is claimed about it either way."]}),!e.hostsRead&&i.jsxs("p",{className:"bw-rc-note",children:[e.hostsPath," could not be read, so whether the relay is already blocked is unknown."]}),h.some(f=>f.report.allUrls)&&i.jsxs("p",{className:"bw-rc-note",children:["Narrowing the sites in ",i.jsx("code",{className:"bw-path",children:"chrome://extensions"})," does not change this: the grant is held at the browser level and the per-site list is enforced inside the extension, by the extension."]}),i.jsxs("div",{className:"bw-rc-cmd",children:[i.jsx("code",{children:c.command}),i.jsx("button",{className:"btn bw-rc-copy",onClick:d,children:s?"Copied":"Copy"})]}),i.jsx("p",{className:"bw-rc-note",children:c.note})]})]})}function d8(e,t){const n=(e??[]).filter(a=>a&&typeof a.fp=="string"&&!t.has(a.fp));if(!n.length)return{request:null,waiting:0};const s=[...n].sort((a,l)=>(a.at??0)-(l.at??0));return{request:s[0],waiting:s.length-1}}function h8({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:l,onLater:c}){const d=b.useRef(null),h=Ht(c,{focusRef:d}),p=Ks(n,"accept"),f=Ks(n,"dismiss");return i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:h,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0}),i.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:c,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsxs("p",{className:"lan-ask-who",children:[i.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",i.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",xx(e.at,s)]}),i.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),i.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",i.jsx("code",{className:"ap-lan-code",children:e.fp})," — it should match the one on their screen."]}),t>0&&i.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),i.jsxs("div",{className:"lan-ask-acts",children:[i.jsx("button",{type:"button",ref:d,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:l,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),i.jsx("button",{type:"button",className:"btn primary",disabled:p.disabled,"aria-busy":p.busy,onClick:a,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function Nx(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Df,H1;function f8(){if(H1)return Df;H1=1;function e(){this.__data__=[],this.size=0}return Df=e,Df}var qf,G1;function fi(){if(G1)return qf;G1=1;function e(t,n){return t===n||t!==t&&n!==n}return qf=e,qf}var Ff,V1;function jd(){if(V1)return Ff;V1=1;var e=fi();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Ff=t,Ff}var Bf,Y1;function p8(){if(Y1)return Bf;Y1=1;var e=jd(),t=Array.prototype,n=t.splice;function s(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var d=l.length-1;return c==d?l.pop():n.call(l,c,1),--this.size,!0}return Bf=s,Bf}var zf,K1;function m8(){if(K1)return zf;K1=1;var e=jd();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return zf=t,zf}var Uf,X1;function g8(){if(X1)return Uf;X1=1;var e=jd();function t(n){return e(this.__data__,n)>-1}return Uf=t,Uf}var Wf,Q1;function y8(){if(Q1)return Wf;Q1=1;var e=jd();function t(n,s){var a=this.__data__,l=e(a,n);return l<0?(++this.size,a.push([n,s])):a[l][1]=s,this}return Wf=t,Wf}var Hf,Z1;function Ed(){if(Z1)return Hf;Z1=1;var e=f8(),t=p8(),n=m8(),s=g8(),a=y8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,Hf=l,Hf}var Gf,J1;function w8(){if(J1)return Gf;J1=1;var e=Ed();function t(){this.__data__=new e,this.size=0}return Gf=t,Gf}var Vf,e_;function v8(){if(e_)return Vf;e_=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Vf=e,Vf}var Yf,t_;function x8(){if(t_)return Yf;t_=1;function e(t){return this.__data__.get(t)}return Yf=e,Yf}var Kf,n_;function b8(){if(n_)return Kf;n_=1;function e(t){return this.__data__.has(t)}return Kf=e,Kf}var Xf,r_;function Y2(){if(r_)return Xf;r_=1;var e=typeof gu=="object"&&gu&&gu.Object===Object&&gu;return Xf=e,Xf}var Qf,s_;function yr(){if(s_)return Qf;s_=1;var e=Y2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Qf=n,Qf}var Zf,a_;function pi(){if(a_)return Zf;a_=1;var e=yr(),t=e.Symbol;return Zf=t,Zf}var Jf,o_;function k8(){if(o_)return Jf;o_=1;var e=pi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function l(c){var d=n.call(c,a),h=c[a];try{c[a]=void 0;var p=!0}catch{}var f=s.call(c);return p&&(d?c[a]=h:delete c[a]),f}return Jf=l,Jf}var ep,i_;function _8(){if(i_)return ep;i_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return ep=n,ep}var tp,l_;function Xa(){if(l_)return tp;l_=1;var e=pi(),t=k8(),n=_8(),s="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(d){return d==null?d===void 0?a:s:l&&l in Object(d)?t(d):n(d)}return tp=c,tp}var np,c_;function Yn(){if(c_)return np;c_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return np=e,np}var rp,u_;function ec(){if(u_)return rp;u_=1;var e=Xa(),t=Yn(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(d){if(!t(d))return!1;var h=e(d);return h==s||h==a||h==n||h==l}return rp=c,rp}var sp,d_;function N8(){if(d_)return sp;d_=1;var e=yr(),t=e["__core-js_shared__"];return sp=t,sp}var ap,h_;function S8(){if(h_)return ap;h_=1;var e=N8(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return ap=n,ap}var op,f_;function K2(){if(f_)return op;f_=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return op=n,op}var ip,p_;function j8(){if(p_)return ip;p_=1;var e=ec(),t=S8(),n=Yn(),s=K2(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,d=Object.prototype,h=c.toString,p=d.hasOwnProperty,f=RegExp("^"+h.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!n(y)||t(y))return!1;var v=e(y)?f:l;return v.test(s(y))}return ip=m,ip}var lp,m_;function E8(){if(m_)return lp;m_=1;function e(t,n){return t==null?void 0:t[n]}return lp=e,lp}var cp,g_;function Qa(){if(g_)return cp;g_=1;var e=j8(),t=E8();function n(s,a){var l=t(s,a);return e(l)?l:void 0}return cp=n,cp}var up,y_;function Sx(){if(y_)return up;y_=1;var e=Qa(),t=yr(),n=e(t,"Map");return up=n,up}var dp,w_;function Cd(){if(w_)return dp;w_=1;var e=Qa(),t=e(Object,"create");return dp=t,dp}var hp,v_;function C8(){if(v_)return hp;v_=1;var e=Cd();function t(){this.__data__=e?e(null):{},this.size=0}return hp=t,hp}var fp,x_;function T8(){if(x_)return fp;x_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return fp=e,fp}var pp,b_;function A8(){if(b_)return pp;b_=1;var e=Cd(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var d=c[l];return d===t?void 0:d}return s.call(c,l)?c[l]:void 0}return pp=a,pp}var mp,k_;function R8(){if(k_)return mp;k_=1;var e=Cd(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return mp=s,mp}var gp,__;function M8(){if(__)return gp;__=1;var e=Cd(),t="__lodash_hash_undefined__";function n(s,a){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&a===void 0?t:a,this}return gp=n,gp}var yp,N_;function I8(){if(N_)return yp;N_=1;var e=C8(),t=T8(),n=A8(),s=R8(),a=M8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,yp=l,yp}var wp,S_;function $8(){if(S_)return wp;S_=1;var e=I8(),t=Ed(),n=Sx();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return wp=s,wp}var vp,j_;function O8(){if(j_)return vp;j_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return vp=e,vp}var xp,E_;function Td(){if(E_)return xp;E_=1;var e=O8();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return xp=t,xp}var bp,C_;function P8(){if(C_)return bp;C_=1;var e=Td();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return bp=t,bp}var kp,T_;function L8(){if(T_)return kp;T_=1;var e=Td();function t(n){return e(this,n).get(n)}return kp=t,kp}var _p,A_;function D8(){if(A_)return _p;A_=1;var e=Td();function t(n){return e(this,n).has(n)}return _p=t,_p}var Np,R_;function q8(){if(R_)return Np;R_=1;var e=Td();function t(n,s){var a=e(this,n),l=a.size;return a.set(n,s),this.size+=a.size==l?0:1,this}return Np=t,Np}var Sp,M_;function jx(){if(M_)return Sp;M_=1;var e=$8(),t=P8(),n=L8(),s=D8(),a=q8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,Sp=l,Sp}var jp,I_;function F8(){if(I_)return jp;I_=1;var e=Ed(),t=Sx(),n=jx(),s=200;function a(l,c){var d=this.__data__;if(d instanceof e){var h=d.__data__;if(!t||h.length<s-1)return h.push([l,c]),this.size=++d.size,this;d=this.__data__=new n(h)}return d.set(l,c),this.size=d.size,this}return jp=a,jp}var Ep,$_;function Ad(){if($_)return Ep;$_=1;var e=Ed(),t=w8(),n=v8(),s=x8(),a=b8(),l=F8();function c(d){var h=this.__data__=new e(d);this.size=h.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=s,c.prototype.has=a,c.prototype.set=l,Ep=c,Ep}var Cp,O_;function Ex(){if(O_)return Cp;O_=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a&&n(t[s],s,t)!==!1;);return t}return Cp=e,Cp}var Tp,P_;function X2(){if(P_)return Tp;P_=1;var e=Qa(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Tp=t,Tp}var Ap,L_;function Rd(){if(L_)return Ap;L_=1;var e=X2();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Ap=t,Ap}var Rp,D_;function Md(){if(D_)return Rp;D_=1;var e=Rd(),t=fi(),n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d){var h=l[c];(!(s.call(l,c)&&t(h,d))||d===void 0&&!(c in l))&&e(l,c,d)}return Rp=a,Rp}var Mp,q_;function tc(){if(q_)return Mp;q_=1;var e=Md(),t=Rd();function n(s,a,l,c){var d=!l;l||(l={});for(var h=-1,p=a.length;++h<p;){var f=a[h],m=c?c(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),d?t(l,f,m):e(l,f,m)}return l}return Mp=n,Mp}var Ip,F_;function B8(){if(F_)return Ip;F_=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return Ip=e,Ip}var $p,B_;function $r(){if(B_)return $p;B_=1;function e(t){return t!=null&&typeof t=="object"}return $p=e,$p}var Op,z_;function z8(){if(z_)return Op;z_=1;var e=Xa(),t=$r(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Op=s,Op}var Pp,U_;function nc(){if(U_)return Pp;U_=1;var e=z8(),t=$r(),n=Object.prototype,s=n.hasOwnProperty,a=n.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(c){return t(c)&&s.call(c,"callee")&&!a.call(c,"callee")};return Pp=l,Pp}var Lp,W_;function Mt(){if(W_)return Lp;W_=1;var e=Array.isArray;return Lp=e,Lp}var Sl={exports:{}},Dp,H_;function U8(){if(H_)return Dp;H_=1;function e(){return!1}return Dp=e,Dp}Sl.exports;var G_;function mi(){return G_||(G_=1,(function(e,t){var n=yr(),s=U8(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,d=c?n.Buffer:void 0,h=d?d.isBuffer:void 0,p=h||s;e.exports=p})(Sl,Sl.exports)),Sl.exports}var qp,V_;function Id(){if(V_)return qp;V_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,a){var l=typeof s;return a=a??e,!!a&&(l=="number"||l!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<a}return qp=n,qp}var Fp,Y_;function Cx(){if(Y_)return Fp;Y_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Fp=t,Fp}var Bp,K_;function W8(){if(K_)return Bp;K_=1;var e=Xa(),t=Cx(),n=$r(),s="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",d="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",v="[object Set]",S="[object String]",_="[object WeakMap]",j="[object ArrayBuffer]",x="[object DataView]",N="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",$="[object Uint8Array]",B="[object Uint8ClampedArray]",O="[object Uint16Array]",M="[object Uint32Array]",L={};L[N]=L[E]=L[C]=L[R]=L[I]=L[$]=L[B]=L[O]=L[M]=!0,L[s]=L[a]=L[j]=L[l]=L[x]=L[c]=L[d]=L[h]=L[p]=L[f]=L[m]=L[y]=L[v]=L[S]=L[_]=!1;function H(F){return n(F)&&t(F.length)&&!!L[e(F)]}return Bp=H,Bp}var zp,X_;function $d(){if(X_)return zp;X_=1;function e(t){return function(n){return t(n)}}return zp=e,zp}var jl={exports:{}};jl.exports;var Q_;function Tx(){return Q_||(Q_=1,(function(e,t){var n=Y2(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l&&n.process,d=(function(){try{var h=a&&a.require&&a.require("util").types;return h||c&&c.binding&&c.binding("util")}catch{}})();e.exports=d})(jl,jl.exports)),jl.exports}var Up,Z_;function rc(){if(Z_)return Up;Z_=1;var e=W8(),t=$d(),n=Tx(),s=n&&n.isTypedArray,a=s?t(s):e;return Up=a,Up}var Wp,J_;function Q2(){if(J_)return Wp;J_=1;var e=B8(),t=nc(),n=Mt(),s=mi(),a=Id(),l=rc(),c=Object.prototype,d=c.hasOwnProperty;function h(p,f){var m=n(p),y=!m&&t(p),v=!m&&!y&&s(p),S=!m&&!y&&!v&&l(p),_=m||y||v||S,j=_?e(p.length,String):[],x=j.length;for(var N in p)(f||d.call(p,N))&&!(_&&(N=="length"||v&&(N=="offset"||N=="parent")||S&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,x)))&&j.push(N);return j}return Wp=h,Wp}var Hp,eN;function Od(){if(eN)return Hp;eN=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Hp=t,Hp}var Gp,tN;function Z2(){if(tN)return Gp;tN=1;function e(t,n){return function(s){return t(n(s))}}return Gp=e,Gp}var Vp,nN;function H8(){if(nN)return Vp;nN=1;var e=Z2(),t=e(Object.keys,Object);return Vp=t,Vp}var Yp,rN;function Ax(){if(rN)return Yp;rN=1;var e=Od(),t=H8(),n=Object.prototype,s=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var d in Object(l))s.call(l,d)&&d!="constructor"&&c.push(d);return c}return Yp=a,Yp}var Kp,sN;function ls(){if(sN)return Kp;sN=1;var e=ec(),t=Cx();function n(s){return s!=null&&t(s.length)&&!e(s)}return Kp=n,Kp}var Xp,aN;function Xs(){if(aN)return Xp;aN=1;var e=Q2(),t=Ax(),n=ls();function s(a){return n(a)?e(a):t(a)}return Xp=s,Xp}var Qp,oN;function G8(){if(oN)return Qp;oN=1;var e=tc(),t=Xs();function n(s,a){return s&&e(a,t(a),s)}return Qp=n,Qp}var Zp,iN;function V8(){if(iN)return Zp;iN=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Zp=e,Zp}var Jp,lN;function Y8(){if(lN)return Jp;lN=1;var e=Yn(),t=Od(),n=V8(),s=Object.prototype,a=s.hasOwnProperty;function l(c){if(!e(c))return n(c);var d=t(c),h=[];for(var p in c)p=="constructor"&&(d||!a.call(c,p))||h.push(p);return h}return Jp=l,Jp}var em,cN;function Za(){if(cN)return em;cN=1;var e=Q2(),t=Y8(),n=ls();function s(a){return n(a)?e(a,!0):t(a)}return em=s,em}var tm,uN;function K8(){if(uN)return tm;uN=1;var e=tc(),t=Za();function n(s,a){return s&&e(a,t(a),s)}return tm=n,tm}var El={exports:{}};El.exports;var dN;function J2(){return dN||(dN=1,(function(e,t){var n=yr(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?n.Buffer:void 0,d=c?c.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var m=p.length,y=d?d(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(El,El.exports)),El.exports}var nm,hN;function eA(){if(hN)return nm;hN=1;function e(t,n){var s=-1,a=t.length;for(n||(n=Array(a));++s<a;)n[s]=t[s];return n}return nm=e,nm}var rm,fN;function tA(){if(fN)return rm;fN=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=0,c=[];++s<a;){var d=t[s];n(d,s,t)&&(c[l++]=d)}return c}return rm=e,rm}var sm,pN;function nA(){if(pN)return sm;pN=1;function e(){return[]}return sm=e,sm}var am,mN;function Rx(){if(mN)return am;mN=1;var e=tA(),t=nA(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(d){return s.call(c,d)}))}:t;return am=l,am}var om,gN;function X8(){if(gN)return om;gN=1;var e=tc(),t=Rx();function n(s,a){return e(s,t(s),a)}return om=n,om}var im,yN;function Mx(){if(yN)return im;yN=1;function e(t,n){for(var s=-1,a=n.length,l=t.length;++s<a;)t[l+s]=n[s];return t}return im=e,im}var lm,wN;function Pd(){if(wN)return lm;wN=1;var e=Z2(),t=e(Object.getPrototypeOf,Object);return lm=t,lm}var cm,vN;function rA(){if(vN)return cm;vN=1;var e=Mx(),t=Pd(),n=Rx(),s=nA(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var d=[];c;)e(d,n(c)),c=t(c);return d}:s;return cm=l,cm}var um,xN;function Q8(){if(xN)return um;xN=1;var e=tc(),t=rA();function n(s,a){return e(s,t(s),a)}return um=n,um}var dm,bN;function sA(){if(bN)return dm;bN=1;var e=Mx(),t=Mt();function n(s,a,l){var c=a(s);return t(s)?c:e(c,l(s))}return dm=n,dm}var hm,kN;function aA(){if(kN)return hm;kN=1;var e=sA(),t=Rx(),n=Xs();function s(a){return e(a,n,t)}return hm=s,hm}var fm,_N;function Z8(){if(_N)return fm;_N=1;var e=sA(),t=rA(),n=Za();function s(a){return e(a,n,t)}return fm=s,fm}var pm,NN;function J8(){if(NN)return pm;NN=1;var e=Qa(),t=yr(),n=e(t,"DataView");return pm=n,pm}var mm,SN;function eB(){if(SN)return mm;SN=1;var e=Qa(),t=yr(),n=e(t,"Promise");return mm=n,mm}var gm,jN;function oA(){if(jN)return gm;jN=1;var e=Qa(),t=yr(),n=e(t,"Set");return gm=n,gm}var ym,EN;function tB(){if(EN)return ym;EN=1;var e=Qa(),t=yr(),n=e(t,"WeakMap");return ym=n,ym}var wm,CN;function gi(){if(CN)return wm;CN=1;var e=J8(),t=Sx(),n=eB(),s=oA(),a=tB(),l=Xa(),c=K2(),d="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",v=c(e),S=c(t),_=c(n),j=c(s),x=c(a),N=l;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=d||n&&N(n.resolve())!=p||s&&N(new s)!=f||a&&N(new a)!=m)&&(N=function(E){var C=l(E),R=C==h?E.constructor:void 0,I=R?c(R):"";if(I)switch(I){case v:return y;case S:return d;case _:return p;case j:return f;case x:return m}return C}),wm=N,wm}var vm,TN;function nB(){if(TN)return vm;TN=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var a=s.length,l=new s.constructor(a);return a&&typeof s[0]=="string"&&t.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return vm=n,vm}var xm,AN;function iA(){if(AN)return xm;AN=1;var e=yr(),t=e.Uint8Array;return xm=t,xm}var bm,RN;function Ix(){if(RN)return bm;RN=1;var e=iA();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return bm=t,bm}var km,MN;function rB(){if(MN)return km;MN=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return km=t,km}var _m,IN;function sB(){if(IN)return _m;IN=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return _m=t,_m}var Nm,$N;function aB(){if($N)return Nm;$N=1;var e=pi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return Nm=s,Nm}var Sm,ON;function lA(){if(ON)return Sm;ON=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return Sm=t,Sm}var jm,PN;function oB(){if(PN)return jm;PN=1;var e=Ix(),t=rB(),n=sB(),s=aB(),a=lA(),l="[object Boolean]",c="[object Date]",d="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",v="[object ArrayBuffer]",S="[object DataView]",_="[object Float32Array]",j="[object Float64Array]",x="[object Int8Array]",N="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",$="[object Uint32Array]";function B(O,M,L){var H=O.constructor;switch(M){case v:return e(O);case l:case c:return new H(+O);case S:return t(O,L);case _:case j:case x:case N:case E:case C:case R:case I:case $:return a(O,L);case d:return new H;case h:case m:return new H(O);case p:return n(O);case f:return new H;case y:return s(O)}}return jm=B,jm}var Em,LN;function cA(){if(LN)return Em;LN=1;var e=Yn(),t=Object.create,n=(function(){function s(){}return function(a){if(!e(a))return{};if(t)return t(a);s.prototype=a;var l=new s;return s.prototype=void 0,l}})();return Em=n,Em}var Cm,DN;function uA(){if(DN)return Cm;DN=1;var e=cA(),t=Pd(),n=Od();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Cm=s,Cm}var Tm,qN;function iB(){if(qN)return Tm;qN=1;var e=gi(),t=$r(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return Tm=s,Tm}var Am,FN;function lB(){if(FN)return Am;FN=1;var e=iB(),t=$d(),n=Tx(),s=n&&n.isMap,a=s?t(s):e;return Am=a,Am}var Rm,BN;function cB(){if(BN)return Rm;BN=1;var e=gi(),t=$r(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return Rm=s,Rm}var Mm,zN;function uB(){if(zN)return Mm;zN=1;var e=cB(),t=$d(),n=Tx(),s=n&&n.isSet,a=s?t(s):e;return Mm=a,Mm}var Im,UN;function dA(){if(UN)return Im;UN=1;var e=Ad(),t=Ex(),n=Md(),s=G8(),a=K8(),l=J2(),c=eA(),d=X8(),h=Q8(),p=aA(),f=Z8(),m=gi(),y=nB(),v=oB(),S=uA(),_=Mt(),j=mi(),x=lB(),N=Yn(),E=uB(),C=Xs(),R=Za(),I=1,$=2,B=4,O="[object Arguments]",M="[object Array]",L="[object Boolean]",H="[object Date]",F="[object Error]",A="[object Function]",Q="[object GeneratorFunction]",K="[object Map]",ee="[object Number]",Z="[object Object]",D="[object RegExp]",Y="[object Set]",P="[object String]",G="[object Symbol]",de="[object WeakMap]",W="[object ArrayBuffer]",U="[object DataView]",J="[object Float32Array]",V="[object Float64Array]",ie="[object Int8Array]",pe="[object Int16Array]",me="[object Int32Array]",Ie="[object Uint8Array]",Le="[object Uint8ClampedArray]",ce="[object Uint16Array]",xe="[object Uint32Array]",ye={};ye[O]=ye[M]=ye[W]=ye[U]=ye[L]=ye[H]=ye[J]=ye[V]=ye[ie]=ye[pe]=ye[me]=ye[K]=ye[ee]=ye[Z]=ye[D]=ye[Y]=ye[P]=ye[G]=ye[Ie]=ye[Le]=ye[ce]=ye[xe]=!0,ye[F]=ye[A]=ye[de]=!1;function ze(ke,je,Ye,it,Ne,He){var Xe,he=je&I,ge=je&$,Se=je&B;if(Ye&&(Xe=Ne?Ye(ke,it,Ne,He):Ye(ke)),Xe!==void 0)return Xe;if(!N(ke))return ke;var Fe=_(ke);if(Fe){if(Xe=y(ke),!he)return c(ke,Xe)}else{var et=m(ke),xt=et==A||et==Q;if(j(ke))return l(ke,he);if(et==Z||et==O||xt&&!Ne){if(Xe=ge||xt?{}:S(ke),!he)return ge?h(ke,a(Xe,ke)):d(ke,s(Xe,ke))}else{if(!ye[et])return Ne?ke:{};Xe=v(ke,et,he)}}He||(He=new e);var ht=He.get(ke);if(ht)return ht;He.set(ke,Xe),E(ke)?ke.forEach(function(Oe){Xe.add(ze(Oe,je,Ye,Oe,ke,He))}):x(ke)&&ke.forEach(function(Oe,Te){Xe.set(Te,ze(Oe,je,Ye,Te,ke,He))});var ne=Se?ge?f:p:ge?R:C,De=Fe?void 0:ne(ke);return t(De||ke,function(Oe,Te){De&&(Te=Oe,Oe=ke[Te]),n(Xe,Te,ze(Oe,je,Ye,Te,ke,He))}),Xe}return Im=ze,Im}var $m,WN;function dB(){if(WN)return $m;WN=1;var e=dA(),t=4;function n(s){return e(s,t)}return $m=n,$m}var Om,HN;function $x(){if(HN)return Om;HN=1;function e(t){return function(){return t}}return Om=e,Om}var Pm,GN;function hB(){if(GN)return Pm;GN=1;function e(t){return function(n,s,a){for(var l=-1,c=Object(n),d=a(n),h=d.length;h--;){var p=d[t?h:++l];if(s(c[p],p,c)===!1)break}return n}}return Pm=e,Pm}var Lm,VN;function Ox(){if(VN)return Lm;VN=1;var e=hB(),t=e();return Lm=t,Lm}var Dm,YN;function Px(){if(YN)return Dm;YN=1;var e=Ox(),t=Xs();function n(s,a){return s&&e(s,a,t)}return Dm=n,Dm}var qm,KN;function fB(){if(KN)return qm;KN=1;var e=ls();function t(n,s){return function(a,l){if(a==null)return a;if(!e(a))return n(a,l);for(var c=a.length,d=s?c:-1,h=Object(a);(s?d--:++d<c)&&l(h[d],d,h)!==!1;);return a}}return qm=t,qm}var Fm,XN;function Ld(){if(XN)return Fm;XN=1;var e=Px(),t=fB(),n=t(e);return Fm=n,Fm}var Bm,QN;function Ja(){if(QN)return Bm;QN=1;function e(t){return t}return Bm=e,Bm}var zm,ZN;function hA(){if(ZN)return zm;ZN=1;var e=Ja();function t(n){return typeof n=="function"?n:e}return zm=t,zm}var Um,JN;function fA(){if(JN)return Um;JN=1;var e=Ex(),t=Ld(),n=hA(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c))}return Um=a,Um}var Wm,eS;function pA(){return eS||(eS=1,Wm=fA()),Wm}var Hm,tS;function pB(){if(tS)return Hm;tS=1;var e=Ld();function t(n,s){var a=[];return e(n,function(l,c,d){s(l,c,d)&&a.push(l)}),a}return Hm=t,Hm}var Gm,nS;function mB(){if(nS)return Gm;nS=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Gm=t,Gm}var Vm,rS;function gB(){if(rS)return Vm;rS=1;function e(t){return this.__data__.has(t)}return Vm=e,Vm}var Ym,sS;function mA(){if(sS)return Ym;sS=1;var e=jx(),t=mB(),n=gB();function s(a){var l=-1,c=a==null?0:a.length;for(this.__data__=new e;++l<c;)this.add(a[l])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,Ym=s,Ym}var Km,aS;function yB(){if(aS)return Km;aS=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(t[s],s,t))return!0;return!1}return Km=e,Km}var Xm,oS;function gA(){if(oS)return Xm;oS=1;function e(t,n){return t.has(n)}return Xm=e,Xm}var Qm,iS;function yA(){if(iS)return Qm;iS=1;var e=mA(),t=yB(),n=gA(),s=1,a=2;function l(c,d,h,p,f,m){var y=h&s,v=c.length,S=d.length;if(v!=S&&!(y&&S>v))return!1;var _=m.get(c),j=m.get(d);if(_&&j)return _==d&&j==c;var x=-1,N=!0,E=h&a?new e:void 0;for(m.set(c,d),m.set(d,c);++x<v;){var C=c[x],R=d[x];if(p)var I=y?p(R,C,x,d,c,m):p(C,R,x,c,d,m);if(I!==void 0){if(I)continue;N=!1;break}if(E){if(!t(d,function($,B){if(!n(E,B)&&(C===$||f(C,$,h,p,m)))return E.push(B)})){N=!1;break}}else if(!(C===R||f(C,R,h,p,m))){N=!1;break}}return m.delete(c),m.delete(d),N}return Qm=l,Qm}var Zm,lS;function wB(){if(lS)return Zm;lS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,l){s[++n]=[l,a]}),s}return Zm=e,Zm}var Jm,cS;function Lx(){if(cS)return Jm;cS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Jm=e,Jm}var eg,uS;function vB(){if(uS)return eg;uS=1;var e=pi(),t=iA(),n=fi(),s=yA(),a=wB(),l=Lx(),c=1,d=2,h="[object Boolean]",p="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",v="[object RegExp]",S="[object Set]",_="[object String]",j="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function R(I,$,B,O,M,L,H){switch(B){case N:if(I.byteLength!=$.byteLength||I.byteOffset!=$.byteOffset)return!1;I=I.buffer,$=$.buffer;case x:return!(I.byteLength!=$.byteLength||!L(new t(I),new t($)));case h:case p:case y:return n(+I,+$);case f:return I.name==$.name&&I.message==$.message;case v:case _:return I==$+"";case m:var F=a;case S:var A=O&c;if(F||(F=l),I.size!=$.size&&!A)return!1;var Q=H.get(I);if(Q)return Q==$;O|=d,H.set(I,$);var K=s(F(I),F($),O,M,L,H);return H.delete(I),K;case j:if(C)return C.call(I)==C.call($)}return!1}return eg=R,eg}var tg,dS;function xB(){if(dS)return tg;dS=1;var e=aA(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d,h,p,f){var m=d&t,y=e(l),v=y.length,S=e(c),_=S.length;if(v!=_&&!m)return!1;for(var j=v;j--;){var x=y[j];if(!(m?x in c:s.call(c,x)))return!1}var N=f.get(l),E=f.get(c);if(N&&E)return N==c&&E==l;var C=!0;f.set(l,c),f.set(c,l);for(var R=m;++j<v;){x=y[j];var I=l[x],$=c[x];if(h)var B=m?h($,I,x,c,l,f):h(I,$,x,l,c,f);if(!(B===void 0?I===$||p(I,$,d,h,f):B)){C=!1;break}R||(R=x=="constructor")}if(C&&!R){var O=l.constructor,M=c.constructor;O!=M&&"constructor"in l&&"constructor"in c&&!(typeof O=="function"&&O instanceof O&&typeof M=="function"&&M instanceof M)&&(C=!1)}return f.delete(l),f.delete(c),C}return tg=a,tg}var ng,hS;function bB(){if(hS)return ng;hS=1;var e=Ad(),t=yA(),n=vB(),s=xB(),a=gi(),l=Mt(),c=mi(),d=rc(),h=1,p="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,v=y.hasOwnProperty;function S(_,j,x,N,E,C){var R=l(_),I=l(j),$=R?f:a(_),B=I?f:a(j);$=$==p?m:$,B=B==p?m:B;var O=$==m,M=B==m,L=$==B;if(L&&c(_)){if(!c(j))return!1;R=!0,O=!1}if(L&&!O)return C||(C=new e),R||d(_)?t(_,j,x,N,E,C):n(_,j,$,x,N,E,C);if(!(x&h)){var H=O&&v.call(_,"__wrapped__"),F=M&&v.call(j,"__wrapped__");if(H||F){var A=H?_.value():_,Q=F?j.value():j;return C||(C=new e),E(A,Q,x,N,C)}}return L?(C||(C=new e),s(_,j,x,N,E,C)):!1}return ng=S,ng}var rg,fS;function wA(){if(fS)return rg;fS=1;var e=bB(),t=$r();function n(s,a,l,c,d){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,l,c,n,d)}return rg=n,rg}var sg,pS;function kB(){if(pS)return sg;pS=1;var e=Ad(),t=wA(),n=1,s=2;function a(l,c,d,h){var p=d.length,f=p,m=!h;if(l==null)return!f;for(l=Object(l);p--;){var y=d[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<f;){y=d[p];var v=y[0],S=l[v],_=y[1];if(m&&y[2]){if(S===void 0&&!(v in l))return!1}else{var j=new e;if(h)var x=h(S,_,v,l,c,j);if(!(x===void 0?t(_,S,n|s,h,j):x))return!1}}return!0}return sg=a,sg}var ag,mS;function vA(){if(mS)return ag;mS=1;var e=Yn();function t(n){return n===n&&!e(n)}return ag=t,ag}var og,gS;function _B(){if(gS)return og;gS=1;var e=vA(),t=Xs();function n(s){for(var a=t(s),l=a.length;l--;){var c=a[l],d=s[c];a[l]=[c,d,e(d)]}return a}return og=n,og}var ig,yS;function xA(){if(yS)return ig;yS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return ig=e,ig}var lg,wS;function NB(){if(wS)return lg;wS=1;var e=kB(),t=_B(),n=xA();function s(a){var l=t(a);return l.length==1&&l[0][2]?n(l[0][0],l[0][1]):function(c){return c===a||e(c,a,l)}}return lg=s,lg}var cg,vS;function yi(){if(vS)return cg;vS=1;var e=Xa(),t=$r(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return cg=s,cg}var ug,xS;function Dx(){if(xS)return ug;xS=1;var e=Mt(),t=yi(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(l,c){if(e(l))return!1;var d=typeof l;return d=="number"||d=="symbol"||d=="boolean"||l==null||t(l)?!0:s.test(l)||!n.test(l)||c!=null&&l in Object(c)}return ug=a,ug}var dg,bS;function SB(){if(bS)return dg;bS=1;var e=jx(),t="Expected a function";function n(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var l=function(){var c=arguments,d=a?a.apply(this,c):c[0],h=l.cache;if(h.has(d))return h.get(d);var p=s.apply(this,c);return l.cache=h.set(d,p)||h,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,dg=n,dg}var hg,kS;function jB(){if(kS)return hg;kS=1;var e=SB(),t=500;function n(s){var a=e(s,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return hg=n,hg}var fg,_S;function EB(){if(_S)return fg;_S=1;var e=jB(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(a){var l=[];return a.charCodeAt(0)===46&&l.push(""),a.replace(t,function(c,d,h,p){l.push(h?p.replace(n,"$1"):d||c)}),l});return fg=s,fg}var pg,NS;function Dd(){if(NS)return pg;NS=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=Array(a);++s<a;)l[s]=n(t[s],s,t);return l}return pg=e,pg}var mg,SS;function CB(){if(SS)return mg;SS=1;var e=pi(),t=Dd(),n=Mt(),s=yi(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(d){if(typeof d=="string")return d;if(n(d))return t(d,c)+"";if(s(d))return l?l.call(d):"";var h=d+"";return h=="0"&&1/d==-1/0?"-0":h}return mg=c,mg}var gg,jS;function bA(){if(jS)return gg;jS=1;var e=CB();function t(n){return n==null?"":e(n)}return gg=t,gg}var yg,ES;function qd(){if(ES)return yg;ES=1;var e=Mt(),t=Dx(),n=EB(),s=bA();function a(l,c){return e(l)?l:t(l,c)?[l]:n(s(l))}return yg=a,yg}var wg,CS;function sc(){if(CS)return wg;CS=1;var e=yi();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return wg=t,wg}var vg,TS;function Fd(){if(TS)return vg;TS=1;var e=qd(),t=sc();function n(s,a){a=e(a,s);for(var l=0,c=a.length;s!=null&&l<c;)s=s[t(a[l++])];return l&&l==c?s:void 0}return vg=n,vg}var xg,AS;function TB(){if(AS)return xg;AS=1;var e=Fd();function t(n,s,a){var l=n==null?void 0:e(n,s);return l===void 0?a:l}return xg=t,xg}var bg,RS;function AB(){if(RS)return bg;RS=1;function e(t,n){return t!=null&&n in Object(t)}return bg=e,bg}var kg,MS;function kA(){if(MS)return kg;MS=1;var e=qd(),t=nc(),n=Mt(),s=Id(),a=Cx(),l=sc();function c(d,h,p){h=e(h,d);for(var f=-1,m=h.length,y=!1;++f<m;){var v=l(h[f]);if(!(y=d!=null&&p(d,v)))break;d=d[v]}return y||++f!=m?y:(m=d==null?0:d.length,!!m&&a(m)&&s(v,m)&&(n(d)||t(d)))}return kg=c,kg}var _g,IS;function _A(){if(IS)return _g;IS=1;var e=AB(),t=kA();function n(s,a){return s!=null&&t(s,a,e)}return _g=n,_g}var Ng,$S;function RB(){if($S)return Ng;$S=1;var e=wA(),t=TB(),n=_A(),s=Dx(),a=vA(),l=xA(),c=sc(),d=1,h=2;function p(f,m){return s(f)&&a(m)?l(c(f),m):function(y){var v=t(y,f);return v===void 0&&v===m?n(y,f):e(m,v,d|h)}}return Ng=p,Ng}var Sg,OS;function NA(){if(OS)return Sg;OS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Sg=e,Sg}var jg,PS;function MB(){if(PS)return jg;PS=1;var e=Fd();function t(n){return function(s){return e(s,n)}}return jg=t,jg}var Eg,LS;function IB(){if(LS)return Eg;LS=1;var e=NA(),t=MB(),n=Dx(),s=sc();function a(l){return n(l)?e(s(l)):t(l)}return Eg=a,Eg}var Cg,DS;function cs(){if(DS)return Cg;DS=1;var e=NB(),t=RB(),n=Ja(),s=Mt(),a=IB();function l(c){return typeof c=="function"?c:c==null?n:typeof c=="object"?s(c)?t(c[0],c[1]):e(c):a(c)}return Cg=l,Cg}var Tg,qS;function SA(){if(qS)return Tg;qS=1;var e=tA(),t=pB(),n=cs(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c,3))}return Tg=a,Tg}var Ag,FS;function $B(){if(FS)return Ag;FS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Ag=n,Ag}var Rg,BS;function jA(){if(BS)return Rg;BS=1;var e=$B(),t=kA();function n(s,a){return s!=null&&t(s,a,e)}return Rg=n,Rg}var Mg,zS;function OB(){if(zS)return Mg;zS=1;var e=Ax(),t=gi(),n=nc(),s=Mt(),a=ls(),l=mi(),c=Od(),d=rc(),h="[object Map]",p="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(v){if(v==null)return!0;if(a(v)&&(s(v)||typeof v=="string"||typeof v.splice=="function"||l(v)||d(v)||n(v)))return!v.length;var S=t(v);if(S==h||S==p)return!v.size;if(c(v))return!e(v).length;for(var _ in v)if(m.call(v,_))return!1;return!0}return Mg=y,Mg}var Ig,US;function EA(){if(US)return Ig;US=1;function e(t){return t===void 0}return Ig=e,Ig}var $g,WS;function CA(){if(WS)return $g;WS=1;var e=Ld(),t=ls();function n(s,a){var l=-1,c=t(s)?Array(s.length):[];return e(s,function(d,h,p){c[++l]=a(d,h,p)}),c}return $g=n,$g}var Og,HS;function TA(){if(HS)return Og;HS=1;var e=Dd(),t=cs(),n=CA(),s=Mt();function a(l,c){var d=s(l)?e:n;return d(l,t(c,3))}return Og=a,Og}var Pg,GS;function PB(){if(GS)return Pg;GS=1;function e(t,n,s,a){var l=-1,c=t==null?0:t.length;for(a&&c&&(s=t[++l]);++l<c;)s=n(s,t[l],l,t);return s}return Pg=e,Pg}var Lg,VS;function LB(){if(VS)return Lg;VS=1;function e(t,n,s,a,l){return l(t,function(c,d,h){s=a?(a=!1,c):n(s,c,d,h)}),s}return Lg=e,Lg}var Dg,YS;function AA(){if(YS)return Dg;YS=1;var e=PB(),t=Ld(),n=cs(),s=LB(),a=Mt();function l(c,d,h){var p=a(c)?e:s,f=arguments.length<3;return p(c,n(d,4),h,f,t)}return Dg=l,Dg}var qg,KS;function DB(){if(KS)return qg;KS=1;var e=Xa(),t=Mt(),n=$r(),s="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==s}return qg=a,qg}var Fg,XS;function qB(){if(XS)return Fg;XS=1;var e=NA(),t=e("length");return Fg=t,Fg}var Bg,QS;function FB(){if(QS)return Bg;QS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="\\u200d",d=RegExp("["+c+e+a+l+"]");function h(p){return d.test(p)}return Bg=h,Bg}var zg,ZS;function BB(){if(ZS)return zg;ZS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="["+e+"]",d="["+a+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+d+"|"+h+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",S=p+"?",_="["+l+"]?",j="(?:"+v+"(?:"+[f,m,y].join("|")+")"+_+S+")*",x=_+S+j,N="(?:"+[f+d+"?",d,m,y,c].join("|")+")",E=RegExp(h+"(?="+h+")|"+N+x,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return zg=C,zg}var Ug,JS;function zB(){if(JS)return Ug;JS=1;var e=qB(),t=FB(),n=BB();function s(a){return t(a)?n(a):e(a)}return Ug=s,Ug}var Wg,ej;function UB(){if(ej)return Wg;ej=1;var e=Ax(),t=gi(),n=ls(),s=DB(),a=zB(),l="[object Map]",c="[object Set]";function d(h){if(h==null)return 0;if(n(h))return s(h)?a(h):h.length;var p=t(h);return p==l||p==c?h.size:e(h).length}return Wg=d,Wg}var Hg,tj;function WB(){if(tj)return Hg;tj=1;var e=Ex(),t=cA(),n=Px(),s=cs(),a=Pd(),l=Mt(),c=mi(),d=ec(),h=Yn(),p=rc();function f(m,y,v){var S=l(m),_=S||c(m)||p(m);if(y=s(y,4),v==null){var j=m&&m.constructor;_?v=S?new j:[]:h(m)?v=d(j)?t(a(m)):{}:v={}}return(_?e:n)(m,function(x,N,E){return y(v,x,N,E)}),v}return Hg=f,Hg}var Gg,nj;function HB(){if(nj)return Gg;nj=1;var e=pi(),t=nc(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(s&&l&&l[s])}return Gg=a,Gg}var Vg,rj;function qx(){if(rj)return Vg;rj=1;var e=Mx(),t=HB();function n(s,a,l,c,d){var h=-1,p=s.length;for(l||(l=t),d||(d=[]);++h<p;){var f=s[h];a>0&&l(f)?a>1?n(f,a-1,l,c,d):e(d,f):c||(d[d.length]=f)}return d}return Vg=n,Vg}var Yg,sj;function GB(){if(sj)return Yg;sj=1;function e(t,n,s){switch(s.length){case 0:return t.call(n);case 1:return t.call(n,s[0]);case 2:return t.call(n,s[0],s[1]);case 3:return t.call(n,s[0],s[1],s[2])}return t.apply(n,s)}return Yg=e,Yg}var Kg,aj;function RA(){if(aj)return Kg;aj=1;var e=GB(),t=Math.max;function n(s,a,l){return a=t(a===void 0?s.length-1:a,0),function(){for(var c=arguments,d=-1,h=t(c.length-a,0),p=Array(h);++d<h;)p[d]=c[a+d];d=-1;for(var f=Array(a+1);++d<a;)f[d]=c[d];return f[a]=l(p),e(s,this,f)}}return Kg=n,Kg}var Xg,oj;function VB(){if(oj)return Xg;oj=1;var e=$x(),t=X2(),n=Ja(),s=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return Xg=s,Xg}var Qg,ij;function YB(){if(ij)return Qg;ij=1;var e=800,t=16,n=Date.now;function s(a){var l=0,c=0;return function(){var d=n(),h=t-(d-c);if(c=d,h>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return Qg=s,Qg}var Zg,lj;function MA(){if(lj)return Zg;lj=1;var e=VB(),t=YB(),n=t(e);return Zg=n,Zg}var Jg,cj;function Bd(){if(cj)return Jg;cj=1;var e=Ja(),t=RA(),n=MA();function s(a,l){return n(t(a,l,e),a+"")}return Jg=s,Jg}var ey,uj;function IA(){if(uj)return ey;uj=1;function e(t,n,s,a){for(var l=t.length,c=s+(a?1:-1);a?c--:++c<l;)if(n(t[c],c,t))return c;return-1}return ey=e,ey}var ty,dj;function KB(){if(dj)return ty;dj=1;function e(t){return t!==t}return ty=e,ty}var ny,hj;function XB(){if(hj)return ny;hj=1;function e(t,n,s){for(var a=s-1,l=t.length;++a<l;)if(t[a]===n)return a;return-1}return ny=e,ny}var ry,fj;function QB(){if(fj)return ry;fj=1;var e=IA(),t=KB(),n=XB();function s(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return ry=s,ry}var sy,pj;function ZB(){if(pj)return sy;pj=1;var e=QB();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return sy=t,sy}var ay,mj;function JB(){if(mj)return ay;mj=1;function e(t,n,s){for(var a=-1,l=t==null?0:t.length;++a<l;)if(s(n,t[a]))return!0;return!1}return ay=e,ay}var oy,gj;function ez(){if(gj)return oy;gj=1;function e(){}return oy=e,oy}var iy,yj;function tz(){if(yj)return iy;yj=1;var e=oA(),t=ez(),n=Lx(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(l){return new e(l)}:t;return iy=a,iy}var ly,wj;function nz(){if(wj)return ly;wj=1;var e=mA(),t=ZB(),n=JB(),s=gA(),a=tz(),l=Lx(),c=200;function d(h,p,f){var m=-1,y=t,v=h.length,S=!0,_=[],j=_;if(f)S=!1,y=n;else if(v>=c){var x=p?null:a(h);if(x)return l(x);S=!1,y=s,j=new e}else j=p?[]:_;e:for(;++m<v;){var N=h[m],E=p?p(N):N;if(N=f||N!==0?N:0,S&&E===E){for(var C=j.length;C--;)if(j[C]===E)continue e;p&&j.push(E),_.push(N)}else y(j,E,f)||(j!==_&&j.push(E),_.push(N))}return _}return ly=d,ly}var cy,vj;function $A(){if(vj)return cy;vj=1;var e=ls(),t=$r();function n(s){return t(s)&&e(s)}return cy=n,cy}var uy,xj;function rz(){if(xj)return uy;xj=1;var e=qx(),t=Bd(),n=nz(),s=$A(),a=t(function(l){return n(e(l,1,s,!0))});return uy=a,uy}var dy,bj;function sz(){if(bj)return dy;bj=1;var e=Dd();function t(n,s){return e(s,function(a){return n[a]})}return dy=t,dy}var hy,kj;function OA(){if(kj)return hy;kj=1;var e=sz(),t=Xs();function n(s){return s==null?[]:e(s,t(s))}return hy=n,hy}var fy,_j;function Kn(){if(_j)return fy;_j=1;var e;if(typeof Nx=="function")try{e={clone:dB(),constant:$x(),each:pA(),filter:SA(),has:jA(),isArray:Mt(),isEmpty:OB(),isFunction:ec(),isUndefined:EA(),keys:Xs(),map:TA(),reduce:AA(),size:UB(),transform:WB(),union:rz(),values:OA()}}catch{}return e||(e=window._),fy=e,fy}var py,Nj;function Fx(){if(Nj)return py;Nj=1;var e=Kn();py=a;var t="\0",n="\0",s="";function a(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(f){return this._label=f,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},a.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},a.prototype.setNodes=function(f,m){var y=arguments,v=this;return e.each(f,function(S){y.length>1?v.setNode(S,m):v.setNode(S)}),this},a.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},a.prototype.node=function(f){return this._nodes[f]},a.prototype.hasNode=function(f){return e.has(this._nodes,f)},a.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(v){m.removeEdge(m._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){m.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},a.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==n)return m}},a.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},a.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},a.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},a.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},a.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},a.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,j){f(j)&&m.setNode(j,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var v={};function S(_){var j=y.parent(_);return j===void 0||m.hasNode(j)?(v[_]=j,j):j in v?v[j]:S(j)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,S(_))}),m},a.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(f,m){var y=this,v=arguments;return e.reduce(f,function(S,_){return v.length>1?y.setEdge(S,_,m):y.setEdge(S,_),_}),this},a.prototype.setEdge=function(){var f,m,y,v,S=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(v=arguments[1],S=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(v=arguments[2],S=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var j=d(this._isDirected,f,m,y);if(e.has(this._edgeLabels,j))return S&&(this._edgeLabels[j]=v),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[j]=S?v:this._defaultEdgeLabelFn(f,m,y);var x=h(this._isDirected,f,m,y);return f=x.v,m=x.w,Object.freeze(x),this._edgeObjs[j]=x,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][j]=x,this._out[f][j]=x,this._edgeCount++,this},a.prototype.edge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return this._edgeLabels[v]},a.prototype.hasEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return e.has(this._edgeLabels,v)},a.prototype.removeEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y),S=this._edgeObjs[v];return S&&(f=S.v,m=S.w,delete this._edgeLabels[v],delete this._edgeObjs[v],c(this._preds[m],f),c(this._sucs[f],m),delete this._in[m][v],delete this._out[f][v],this._edgeCount--),this},a.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var v=e.values(y);return m?e.filter(v,function(S){return S.v===m}):v}},a.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var v=e.values(y);return m?e.filter(v,function(S){return S.w===m}):v}},a.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function c(f,m){--f[m]||delete f[m]}function d(f,m,y,v){var S=""+m,_=""+y;if(!f&&S>_){var j=S;S=_,_=j}return S+s+_+s+(e.isUndefined(v)?t:v)}function h(f,m,y,v){var S=""+m,_=""+y;if(!f&&S>_){var j=S;S=_,_=j}var x={v:S,w:_};return v&&(x.name=v),x}function p(f,m){return d(f,m.v,m.w,m.name)}return py}var my,Sj;function az(){return Sj||(Sj=1,my="2.1.8"),my}var gy,jj;function oz(){return jj||(jj=1,gy={Graph:Fx(),version:az()}),gy}var yy,Ej;function iz(){if(Ej)return yy;Ej=1;var e=Kn(),t=Fx();yy={write:n,read:l};function n(c){var d={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:s(c),edges:a(c)};return e.isUndefined(c.graph())||(d.value=e.clone(c.graph())),d}function s(c){return e.map(c.nodes(),function(d){var h=c.node(d),p=c.parent(d),f={v:d};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function a(c){return e.map(c.edges(),function(d){var h=c.edge(d),p={v:d.v,w:d.w};return e.isUndefined(d.name)||(p.name=d.name),e.isUndefined(h)||(p.value=h),p})}function l(c){var d=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(h){d.setNode(h.v,h.value),h.parent&&d.setParent(h.v,h.parent)}),e.each(c.edges,function(h){d.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),d}return yy}var wy,Cj;function lz(){if(Cj)return wy;Cj=1;var e=Kn();wy=t;function t(n){var s={},a=[],l;function c(d){e.has(s,d)||(s[d]=!0,l.push(d),e.each(n.successors(d),c),e.each(n.predecessors(d),c))}return e.each(n.nodes(),function(d){l=[],c(d),l.length&&a.push(l)}),a}return wy}var vy,Tj;function PA(){if(Tj)return vy;Tj=1;var e=Kn();vy=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var s=this._keyIndices[n];if(s!==void 0)return this._arr[s].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,s){var a=this._keyIndices;if(n=String(n),!e.has(a,n)){var l=this._arr,c=l.length;return a[n]=c,l.push({key:n,priority:s}),this._decrease(c),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,s){var a=this._keyIndices[n];if(s>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+s);this._arr[a].priority=s,this._decrease(a)},t.prototype._heapify=function(n){var s=this._arr,a=2*n,l=a+1,c=n;a<s.length&&(c=s[a].priority<s[c].priority?a:c,l<s.length&&(c=s[l].priority<s[c].priority?l:c),c!==n&&(this._swap(n,c),this._heapify(c)))},t.prototype._decrease=function(n){for(var s=this._arr,a=s[n].priority,l;n!==0&&(l=n>>1,!(s[l].priority<a));)this._swap(n,l),n=l},t.prototype._swap=function(n,s){var a=this._arr,l=this._keyIndices,c=a[n],d=a[s];a[n]=d,a[s]=c,l[d.key]=n,l[c.key]=s},vy}var xy,Aj;function LA(){if(Aj)return xy;Aj=1;var e=Kn(),t=PA();xy=s;var n=e.constant(1);function s(l,c,d,h){return a(l,String(c),d||n,h||function(p){return l.outEdges(p)})}function a(l,c,d,h){var p={},f=new t,m,y,v=function(S){var _=S.v!==m?S.v:S.w,j=p[_],x=d(S),N=y.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+S+" Weight: "+x);N<j.distance&&(j.distance=N,j.predecessor=m,f.decrease(_,N))};for(l.nodes().forEach(function(S){var _=S===c?0:Number.POSITIVE_INFINITY;p[S]={distance:_},f.add(S,_)});f.size()>0&&(m=f.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(v);return p}return xy}var by,Rj;function cz(){if(Rj)return by;Rj=1;var e=LA(),t=Kn();by=n;function n(s,a,l){return t.transform(s.nodes(),function(c,d){c[d]=e(s,d,a,l)},{})}return by}var ky,Mj;function DA(){if(Mj)return ky;Mj=1;var e=Kn();ky=t;function t(n){var s=0,a=[],l={},c=[];function d(h){var p=l[h]={onStack:!0,lowlink:s,index:s++};if(a.push(h),n.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(d(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var f=[],m;do m=a.pop(),l[m].onStack=!1,f.push(m);while(h!==m);c.push(f)}}return n.nodes().forEach(function(h){e.has(l,h)||d(h)}),c}return ky}var _y,Ij;function uz(){if(Ij)return _y;Ij=1;var e=Kn(),t=DA();_y=n;function n(s){return e.filter(t(s),function(a){return a.length>1||a.length===1&&s.hasEdge(a[0],a[0])})}return _y}var Ny,$j;function dz(){if($j)return Ny;$j=1;var e=Kn();Ny=n;var t=e.constant(1);function n(a,l,c){return s(a,l||t,c||function(d){return a.outEdges(d)})}function s(a,l,c){var d={},h=a.nodes();return h.forEach(function(p){d[p]={},d[p][p]={distance:0},h.forEach(function(f){p!==f&&(d[p][f]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(f){var m=f.v===p?f.w:f.v,y=l(f);d[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var f=d[p];h.forEach(function(m){var y=d[m];h.forEach(function(v){var S=y[p],_=f[v],j=y[v],x=S.distance+_.distance;x<j.distance&&(j.distance=x,j.predecessor=_.predecessor)})})}),d}return Ny}var Sy,Oj;function qA(){if(Oj)return Sy;Oj=1;var e=Kn();Sy=t,t.CycleException=n;function t(s){var a={},l={},c=[];function d(h){if(e.has(l,h))throw new n;e.has(a,h)||(l[h]=!0,a[h]=!0,e.each(s.predecessors(h),d),delete l[h],c.push(h))}if(e.each(s.sinks(),d),e.size(a)!==s.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,Sy}var jy,Pj;function hz(){if(Pj)return jy;Pj=1;var e=qA();jy=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return jy}var Ey,Lj;function FA(){if(Lj)return Ey;Lj=1;var e=Kn();Ey=t;function t(s,a,l){e.isArray(a)||(a=[a]);var c=(s.isDirected()?s.successors:s.neighbors).bind(s),d=[],h={};return e.each(a,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,l==="post",h,c,d)}),d}function n(s,a,l,c,d,h){e.has(c,a)||(c[a]=!0,l||h.push(a),e.each(d(a),function(p){n(s,p,l,c,d,h)}),l&&h.push(a))}return Ey}var Cy,Dj;function fz(){if(Dj)return Cy;Dj=1;var e=FA();Cy=t;function t(n,s){return e(n,s,"post")}return Cy}var Ty,qj;function pz(){if(qj)return Ty;qj=1;var e=FA();Ty=t;function t(n,s){return e(n,s,"pre")}return Ty}var Ay,Fj;function mz(){if(Fj)return Ay;Fj=1;var e=Kn(),t=Fx(),n=PA();Ay=s;function s(a,l){var c=new t,d={},h=new n,p;function f(y){var v=y.v===p?y.w:y.v,S=h.priority(v);if(S!==void 0){var _=l(y);_<S&&(d[v]=p,h.decrease(v,_))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),h.decrease(a.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(d,p))c.setEdge(p,d[p]);else{if(m)throw new Error("Input graph is not connected: "+a);m=!0}a.nodeEdges(p).forEach(f)}return c}return Ay}var Ry,Bj;function gz(){return Bj||(Bj=1,Ry={components:lz(),dijkstra:LA(),dijkstraAll:cz(),findCycles:uz(),floydWarshall:dz(),isAcyclic:hz(),postorder:fz(),preorder:pz(),prim:mz(),tarjan:DA(),topsort:qA()}),Ry}var My,zj;function yz(){if(zj)return My;zj=1;var e=oz();return My={Graph:e.Graph,json:iz(),alg:gz(),version:e.version},My}var Iy,Uj;function mr(){if(Uj)return Iy;Uj=1;var e;if(typeof Nx=="function")try{e=yz()}catch{}return e||(e=window.graphlib),Iy=e,Iy}var $y,Wj;function wz(){if(Wj)return $y;Wj=1;var e=dA(),t=1,n=4;function s(a){return e(a,t|n)}return $y=s,$y}var Oy,Hj;function zd(){if(Hj)return Oy;Hj=1;var e=fi(),t=ls(),n=Id(),s=Yn();function a(l,c,d){if(!s(d))return!1;var h=typeof c;return(h=="number"?t(d)&&n(c,d.length):h=="string"&&c in d)?e(d[c],l):!1}return Oy=a,Oy}var Py,Gj;function vz(){if(Gj)return Py;Gj=1;var e=Bd(),t=fi(),n=zd(),s=Za(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(d,h){d=Object(d);var p=-1,f=h.length,m=f>2?h[2]:void 0;for(m&&n(h[0],h[1],m)&&(f=1);++p<f;)for(var y=h[p],v=s(y),S=-1,_=v.length;++S<_;){var j=v[S],x=d[j];(x===void 0||t(x,a[j])&&!l.call(d,j))&&(d[j]=y[j])}return d});return Py=c,Py}var Ly,Vj;function xz(){if(Vj)return Ly;Vj=1;var e=cs(),t=ls(),n=Xs();function s(a){return function(l,c,d){var h=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(m){return p(h[m],m,h)}}var f=a(l,c,d);return f>-1?h[p?l[f]:f]:void 0}}return Ly=s,Ly}var Dy,Yj;function bz(){if(Yj)return Dy;Yj=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Dy=t,Dy}var qy,Kj;function kz(){if(Kj)return qy;Kj=1;var e=bz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return qy=n,qy}var Fy,Xj;function _z(){if(Xj)return Fy;Xj=1;var e=kz(),t=Yn(),n=yi(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,d=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||c.test(p)?d(p.slice(2),m?2:8):a.test(p)?s:+p}return Fy=h,Fy}var By,Qj;function BA(){if(Qj)return By;Qj=1;var e=_z(),t=1/0,n=17976931348623157e292;function s(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var l=a<0?-1:1;return l*n}return a===a?a:0}return By=s,By}var zy,Zj;function Nz(){if(Zj)return zy;Zj=1;var e=BA();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return zy=t,zy}var Uy,Jj;function Sz(){if(Jj)return Uy;Jj=1;var e=IA(),t=cs(),n=Nz(),s=Math.max;function a(l,c,d){var h=l==null?0:l.length;if(!h)return-1;var p=d==null?0:n(d);return p<0&&(p=s(h+p,0)),e(l,t(c,3),p)}return Uy=a,Uy}var Wy,eE;function jz(){if(eE)return Wy;eE=1;var e=xz(),t=Sz(),n=e(t);return Wy=n,Wy}var Hy,tE;function zA(){if(tE)return Hy;tE=1;var e=qx();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Hy=t,Hy}var Gy,nE;function Ez(){if(nE)return Gy;nE=1;var e=Ox(),t=hA(),n=Za();function s(a,l){return a==null?a:e(a,t(l),n)}return Gy=s,Gy}var Vy,rE;function Cz(){if(rE)return Vy;rE=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Vy=e,Vy}var Yy,sE;function Tz(){if(sE)return Yy;sE=1;var e=Rd(),t=Px(),n=cs();function s(a,l){var c={};return l=n(l,3),t(a,function(d,h,p){e(c,h,l(d,h,p))}),c}return Yy=s,Yy}var Ky,aE;function Bx(){if(aE)return Ky;aE=1;var e=yi();function t(n,s,a){for(var l=-1,c=n.length;++l<c;){var d=n[l],h=s(d);if(h!=null&&(p===void 0?h===h&&!e(h):a(h,p)))var p=h,f=d}return f}return Ky=t,Ky}var Xy,oE;function Az(){if(oE)return Xy;oE=1;function e(t,n){return t>n}return Xy=e,Xy}var Qy,iE;function Rz(){if(iE)return Qy;iE=1;var e=Bx(),t=Az(),n=Ja();function s(a){return a&&a.length?e(a,n,t):void 0}return Qy=s,Qy}var Zy,lE;function UA(){if(lE)return Zy;lE=1;var e=Rd(),t=fi();function n(s,a,l){(l!==void 0&&!t(s[a],l)||l===void 0&&!(a in s))&&e(s,a,l)}return Zy=n,Zy}var Jy,cE;function Mz(){if(cE)return Jy;cE=1;var e=Xa(),t=Pd(),n=$r(),s="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,d=l.hasOwnProperty,h=c.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var m=t(f);if(m===null)return!0;var y=d.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==h}return Jy=p,Jy}var ew,uE;function WA(){if(uE)return ew;uE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return ew=e,ew}var tw,dE;function Iz(){if(dE)return tw;dE=1;var e=tc(),t=Za();function n(s){return e(s,t(s))}return tw=n,tw}var nw,hE;function $z(){if(hE)return nw;hE=1;var e=UA(),t=J2(),n=lA(),s=eA(),a=uA(),l=nc(),c=Mt(),d=$A(),h=mi(),p=ec(),f=Yn(),m=Mz(),y=rc(),v=WA(),S=Iz();function _(j,x,N,E,C,R,I){var $=v(j,N),B=v(x,N),O=I.get(B);if(O){e(j,N,O);return}var M=R?R($,B,N+"",j,x,I):void 0,L=M===void 0;if(L){var H=c(B),F=!H&&h(B),A=!H&&!F&&y(B);M=B,H||F||A?c($)?M=$:d($)?M=s($):F?(L=!1,M=t(B,!0)):A?(L=!1,M=n(B,!0)):M=[]:m(B)||l(B)?(M=$,l($)?M=S($):(!f($)||p($))&&(M=a(B))):L=!1}L&&(I.set(B,M),C(M,B,E,R,I),I.delete(B)),e(j,N,M)}return nw=_,nw}var rw,fE;function Oz(){if(fE)return rw;fE=1;var e=Ad(),t=UA(),n=Ox(),s=$z(),a=Yn(),l=Za(),c=WA();function d(h,p,f,m,y){h!==p&&n(p,function(v,S){if(y||(y=new e),a(v))s(h,p,S,f,d,m,y);else{var _=m?m(c(h,S),v,S+"",h,p,y):void 0;_===void 0&&(_=v),t(h,S,_)}},l)}return rw=d,rw}var sw,pE;function Pz(){if(pE)return sw;pE=1;var e=Bd(),t=zd();function n(s){return e(function(a,l){var c=-1,d=l.length,h=d>1?l[d-1]:void 0,p=d>2?l[2]:void 0;for(h=s.length>3&&typeof h=="function"?(d--,h):void 0,p&&t(l[0],l[1],p)&&(h=d<3?void 0:h,d=1),a=Object(a);++c<d;){var f=l[c];f&&s(a,f,c,h)}return a})}return sw=n,sw}var aw,mE;function Lz(){if(mE)return aw;mE=1;var e=Oz(),t=Pz(),n=t(function(s,a,l){e(s,a,l)});return aw=n,aw}var ow,gE;function HA(){if(gE)return ow;gE=1;function e(t,n){return t<n}return ow=e,ow}var iw,yE;function Dz(){if(yE)return iw;yE=1;var e=Bx(),t=HA(),n=Ja();function s(a){return a&&a.length?e(a,n,t):void 0}return iw=s,iw}var lw,wE;function qz(){if(wE)return lw;wE=1;var e=Bx(),t=cs(),n=HA();function s(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return lw=s,lw}var cw,vE;function Fz(){if(vE)return cw;vE=1;var e=yr(),t=function(){return e.Date.now()};return cw=t,cw}var uw,xE;function Bz(){if(xE)return uw;xE=1;var e=Md(),t=qd(),n=Id(),s=Yn(),a=sc();function l(c,d,h,p){if(!s(c))return c;d=t(d,c);for(var f=-1,m=d.length,y=m-1,v=c;v!=null&&++f<m;){var S=a(d[f]),_=h;if(S==="__proto__"||S==="constructor"||S==="prototype")return c;if(f!=y){var j=v[S];_=p?p(j,S,v):void 0,_===void 0&&(_=s(j)?j:n(d[f+1])?[]:{})}e(v,S,_),v=v[S]}return c}return uw=l,uw}var dw,bE;function zz(){if(bE)return dw;bE=1;var e=Fd(),t=Bz(),n=qd();function s(a,l,c){for(var d=-1,h=l.length,p={};++d<h;){var f=l[d],m=e(a,f);c(m,f)&&t(p,n(f,a),m)}return p}return dw=s,dw}var hw,kE;function Uz(){if(kE)return hw;kE=1;var e=zz(),t=_A();function n(s,a){return e(s,a,function(l,c){return t(s,c)})}return hw=n,hw}var fw,_E;function Wz(){if(_E)return fw;_E=1;var e=zA(),t=RA(),n=MA();function s(a){return n(t(a,void 0,e),a+"")}return fw=s,fw}var pw,NE;function Hz(){if(NE)return pw;NE=1;var e=Uz(),t=Wz(),n=t(function(s,a){return s==null?{}:e(s,a)});return pw=n,pw}var mw,SE;function Gz(){if(SE)return mw;SE=1;var e=Math.ceil,t=Math.max;function n(s,a,l,c){for(var d=-1,h=t(e((a-s)/(l||1)),0),p=Array(h);h--;)p[c?h:++d]=s,s+=l;return p}return mw=n,mw}var gw,jE;function Vz(){if(jE)return gw;jE=1;var e=Gz(),t=zd(),n=BA();function s(a){return function(l,c,d){return d&&typeof d!="number"&&t(l,c,d)&&(c=d=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),d=d===void 0?l<c?1:-1:n(d),e(l,c,d,a)}}return gw=s,gw}var yw,EE;function Yz(){if(EE)return yw;EE=1;var e=Vz(),t=e();return yw=t,yw}var ww,CE;function Kz(){if(CE)return ww;CE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return ww=e,ww}var vw,TE;function Xz(){if(TE)return vw;TE=1;var e=yi();function t(n,s){if(n!==s){var a=n!==void 0,l=n===null,c=n===n,d=e(n),h=s!==void 0,p=s===null,f=s===s,m=e(s);if(!p&&!m&&!d&&n>s||d&&h&&f&&!p&&!m||l&&h&&f||!a&&f||!c)return 1;if(!l&&!d&&!m&&n<s||m&&a&&c&&!l&&!d||p&&a&&c||!h&&c||!f)return-1}return 0}return vw=t,vw}var xw,AE;function Qz(){if(AE)return xw;AE=1;var e=Xz();function t(n,s,a){for(var l=-1,c=n.criteria,d=s.criteria,h=c.length,p=a.length;++l<h;){var f=e(c[l],d[l]);if(f){if(l>=p)return f;var m=a[l];return f*(m=="desc"?-1:1)}}return n.index-s.index}return xw=t,xw}var bw,RE;function Zz(){if(RE)return bw;RE=1;var e=Dd(),t=Fd(),n=cs(),s=CA(),a=Kz(),l=$d(),c=Qz(),d=Ja(),h=Mt();function p(f,m,y){m.length?m=e(m,function(_){return h(_)?function(j){return t(j,_.length===1?_[0]:_)}:_}):m=[d];var v=-1;m=e(m,l(n));var S=s(f,function(_,j,x){var N=e(m,function(E){return E(_)});return{criteria:N,index:++v,value:_}});return a(S,function(_,j){return c(_,j,y)})}return bw=p,bw}var kw,ME;function Jz(){if(ME)return kw;ME=1;var e=qx(),t=Zz(),n=Bd(),s=zd(),a=n(function(l,c){if(l==null)return[];var d=c.length;return d>1&&s(l,c[0],c[1])?c=[]:d>2&&s(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return kw=a,kw}var _w,IE;function eU(){if(IE)return _w;IE=1;var e=bA(),t=0;function n(s){var a=++t;return e(s)+a}return _w=n,_w}var Nw,$E;function tU(){if($E)return Nw;$E=1;function e(t,n,s){for(var a=-1,l=t.length,c=n.length,d={};++a<l;){var h=a<c?n[a]:void 0;s(d,t[a],h)}return d}return Nw=e,Nw}var Sw,OE;function nU(){if(OE)return Sw;OE=1;var e=Md(),t=tU();function n(s,a){return t(s||[],a||[],e)}return Sw=n,Sw}var jw,PE;function vt(){if(PE)return jw;PE=1;var e;if(typeof Nx=="function")try{e={cloneDeep:wz(),constant:$x(),defaults:vz(),each:pA(),filter:SA(),find:jz(),flatten:zA(),forEach:fA(),forIn:Ez(),has:jA(),isUndefined:EA(),last:Cz(),map:TA(),mapValues:Tz(),max:Rz(),merge:Lz(),min:Dz(),minBy:qz(),now:Fz(),pick:Hz(),range:Yz(),reduce:AA(),sortBy:Jz(),uniqueId:eU(),values:OA(),zipObject:nU()}}catch{}return e||(e=window._),jw=e,jw}var Ew,LE;function rU(){if(LE)return Ew;LE=1,Ew=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,a=s._prev;if(a!==s)return t(a),a},e.prototype.enqueue=function(s){var a=this._sentinel;s._prev&&s._next&&t(s),s._next=a._next,a._next._prev=s,a._next=s,s._prev=a},e.prototype.toString=function(){for(var s=[],a=this._sentinel,l=a._prev;l!==a;)s.push(JSON.stringify(l,n)),l=l._prev;return"["+s.join(", ")+"]"};function t(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function n(s,a){if(s!=="_next"&&s!=="_prev")return a}return Ew}var Cw,DE;function sU(){if(DE)return Cw;DE=1;var e=vt(),t=mr().Graph,n=rU();Cw=a;var s=e.constant(1);function a(p,f){if(p.nodeCount()<=1)return[];var m=d(p,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(v){return p.outEdges(v.v,v.w)}),!0)}function l(p,f,m){for(var y=[],v=f[f.length-1],S=f[0],_;p.nodeCount();){for(;_=S.dequeue();)c(p,f,m,_);for(;_=v.dequeue();)c(p,f,m,_);if(p.nodeCount()){for(var j=f.length-2;j>0;--j)if(_=f[j].dequeue(),_){y=y.concat(c(p,f,m,_,!0));break}}}return y}function c(p,f,m,y,v){var S=v?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var j=p.edge(_),x=p.node(_.v);v&&S.push({v:_.v,w:_.w}),x.out-=j,h(f,m,x)}),e.forEach(p.outEdges(y.v),function(_){var j=p.edge(_),x=_.w,N=p.node(x);N.in-=j,h(f,m,N)}),p.removeNode(y.v),S}function d(p,f){var m=new t,y=0,v=0;e.forEach(p.nodes(),function(j){m.setNode(j,{v:j,in:0,out:0})}),e.forEach(p.edges(),function(j){var x=m.edge(j.v,j.w)||0,N=f(j),E=x+N;m.setEdge(j.v,j.w,E),v=Math.max(v,m.node(j.v).out+=N),y=Math.max(y,m.node(j.w).in+=N)});var S=e.range(v+y+3).map(function(){return new n}),_=y+1;return e.forEach(m.nodes(),function(j){h(S,_,m.node(j))}),{graph:m,buckets:S,zeroIdx:_}}function h(p,f,m){m.out?m.in?p[m.out-m.in+f].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Cw}var Tw,qE;function aU(){if(qE)return Tw;qE=1;var e=vt(),t=sU();Tw={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,d(l)):s(l);e.forEach(c,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function d(h){return function(p){return h.edge(p).weight}}}function s(l){var c=[],d={},h={};function p(f){e.has(h,f)||(h[f]=!0,d[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(d,m.w)?c.push(m):p(m.w)}),delete d[f])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var d=l.edge(c);if(d.reversed){l.removeEdge(c);var h=d.forwardName;delete d.reversed,delete d.forwardName,l.setEdge(c.w,c.v,d,h)}})}return Tw}var Aw,FE;function vn(){if(FE)return Aw;FE=1;var e=vt(),t=mr().Graph;Aw={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:d,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:v,time:S,notime:_};function n(j,x,N,E){var C;do C=e.uniqueId(E);while(j.hasNode(C));return N.dummy=x,j.setNode(C,N),C}function s(j){var x=new t().setGraph(j.graph());return e.forEach(j.nodes(),function(N){x.setNode(N,j.node(N))}),e.forEach(j.edges(),function(N){var E=x.edge(N.v,N.w)||{weight:0,minlen:1},C=j.edge(N);x.setEdge(N.v,N.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),x}function a(j){var x=new t({multigraph:j.isMultigraph()}).setGraph(j.graph());return e.forEach(j.nodes(),function(N){j.children(N).length||x.setNode(N,j.node(N))}),e.forEach(j.edges(),function(N){x.setEdge(N,j.edge(N))}),x}function l(j){var x=e.map(j.nodes(),function(N){var E={};return e.forEach(j.outEdges(N),function(C){E[C.w]=(E[C.w]||0)+j.edge(C).weight}),E});return e.zipObject(j.nodes(),x)}function c(j){var x=e.map(j.nodes(),function(N){var E={};return e.forEach(j.inEdges(N),function(C){E[C.v]=(E[C.v]||0)+j.edge(C).weight}),E});return e.zipObject(j.nodes(),x)}function d(j,x){var N=j.x,E=j.y,C=x.x-N,R=x.y-E,I=j.width/2,$=j.height/2;if(!C&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var B,O;return Math.abs(R)*I>Math.abs(C)*$?(R<0&&($=-$),B=$*C/R,O=$):(C<0&&(I=-I),B=I,O=I*R/C),{x:N+B,y:E+O}}function h(j){var x=e.map(e.range(y(j)+1),function(){return[]});return e.forEach(j.nodes(),function(N){var E=j.node(N),C=E.rank;e.isUndefined(C)||(x[C][E.order]=N)}),x}function p(j){var x=e.min(e.map(j.nodes(),function(N){return j.node(N).rank}));e.forEach(j.nodes(),function(N){var E=j.node(N);e.has(E,"rank")&&(E.rank-=x)})}function f(j){var x=e.min(e.map(j.nodes(),function(R){return j.node(R).rank})),N=[];e.forEach(j.nodes(),function(R){var I=j.node(R).rank-x;N[I]||(N[I]=[]),N[I].push(R)});var E=0,C=j.graph().nodeRankFactor;e.forEach(N,function(R,I){e.isUndefined(R)&&I%C!==0?--E:E&&e.forEach(R,function($){j.node($).rank+=E})})}function m(j,x,N,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=N,C.order=E),n(j,"border",C,x)}function y(j){return e.max(e.map(j.nodes(),function(x){var N=j.node(x).rank;if(!e.isUndefined(N))return N}))}function v(j,x){var N={lhs:[],rhs:[]};return e.forEach(j,function(E){x(E)?N.lhs.push(E):N.rhs.push(E)}),N}function S(j,x){var N=e.now();try{return x()}finally{console.log(j+" time: "+(e.now()-N)+"ms")}}function _(j,x){return x()}return Aw}var Rw,BE;function oU(){if(BE)return Rw;BE=1;var e=vt(),t=vn();Rw={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){s(l,c)})}function s(l,c){var d=c.v,h=l.node(d).rank,p=c.w,f=l.node(p).rank,m=c.name,y=l.edge(c),v=y.labelRank;if(f!==h+1){l.removeEdge(c);var S,_,j;for(j=0,++h;h<f;++j,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:c,rank:h},S=t.addDummyNode(l,"edge",_,"_d"),h===v&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(d,S,{weight:y.weight},m),j===0&&l.graph().dummyChains.push(S),d=S;l.setEdge(d,p,{weight:y.weight},m)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var d=l.node(c),h=d.edgeLabel,p;for(l.setEdge(d.edgeObj,h);d.dummy;)p=l.successors(c)[0],l.removeNode(c),h.points.push({x:d.x,y:d.y}),d.dummy==="edge-label"&&(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height),c=p,d=l.node(c)})}return Rw}var Mw,zE;function dd(){if(zE)return Mw;zE=1;var e=vt();Mw={longestPath:t,slack:n};function t(s){var a={};function l(c){var d=s.node(c);if(e.has(a,c))return d.rank;a[c]=!0;var h=e.min(e.map(s.outEdges(c),function(p){return l(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),d.rank=h}e.forEach(s.sources(),l)}function n(s,a){return s.node(a.w).rank-s.node(a.v).rank-s.edge(a).minlen}return Mw}var Iw,UE;function GA(){if(UE)return Iw;UE=1;var e=vt(),t=mr().Graph,n=dd().slack;Iw=s;function s(d){var h=new t({directed:!1}),p=d.nodes()[0],f=d.nodeCount();h.setNode(p,{});for(var m,y;a(h,d)<f;)m=l(h,d),y=h.hasNode(m.v)?n(d,m):-n(d,m),c(h,d,y);return h}function a(d,h){function p(f){e.forEach(h.nodeEdges(f),function(m){var y=m.v,v=f===y?m.w:y;!d.hasNode(v)&&!n(h,m)&&(d.setNode(v,{}),d.setEdge(f,v,{}),p(v))})}return e.forEach(d.nodes(),p),d.nodeCount()}function l(d,h){return e.minBy(h.edges(),function(p){if(d.hasNode(p.v)!==d.hasNode(p.w))return n(h,p)})}function c(d,h,p){e.forEach(d.nodes(),function(f){h.node(f).rank+=p})}return Iw}var $w,WE;function iU(){if(WE)return $w;WE=1;var e=vt(),t=GA(),n=dd().slack,s=dd().longestPath,a=mr().alg.preorder,l=mr().alg.postorder,c=vn().simplify;$w=d,d.initLowLimValues=m,d.initCutValues=h,d.calcCutValue=f,d.leaveEdge=v,d.enterEdge=S,d.exchangeEdges=_;function d(E){E=c(E),s(E);var C=t(E);m(C),h(C,E);for(var R,I;R=v(C);)I=S(C,E,R),_(C,E,R,I)}function h(E,C){var R=l(E,E.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){p(E,C,I)})}function p(E,C,R){var I=E.node(R),$=I.parent;E.edge(R,$).cutvalue=f(E,C,R)}function f(E,C,R){var I=E.node(R),$=I.parent,B=!0,O=C.edge(R,$),M=0;return O||(B=!1,O=C.edge($,R)),M=O.weight,e.forEach(C.nodeEdges(R),function(L){var H=L.v===R,F=H?L.w:L.v;if(F!==$){var A=H===B,Q=C.edge(L).weight;if(M+=A?Q:-Q,x(E,R,F)){var K=E.edge(R,F).cutvalue;M+=A?-K:K}}}),M}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,$){var B=R,O=E.node(I);return C[I]=!0,e.forEach(E.neighbors(I),function(M){e.has(C,M)||(R=y(E,C,R,M,I))}),O.low=B,O.lim=R++,$?O.parent=$:delete O.parent,R}function v(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function S(E,C,R){var I=R.v,$=R.w;C.hasEdge(I,$)||(I=R.w,$=R.v);var B=E.node(I),O=E.node($),M=B,L=!1;B.lim>O.lim&&(M=O,L=!0);var H=e.filter(C.edges(),function(F){return L===N(E,E.node(F.v),M)&&L!==N(E,E.node(F.w),M)});return e.minBy(H,function(F){return n(C,F)})}function _(E,C,R,I){var $=R.v,B=R.w;E.removeEdge($,B),E.setEdge(I.v,I.w,{}),m(E),h(E,C),j(E,C)}function j(E,C){var R=e.find(E.nodes(),function($){return!C.node($).parent}),I=a(E,R);I=I.slice(1),e.forEach(I,function($){var B=E.node($).parent,O=C.edge($,B),M=!1;O||(O=C.edge(B,$),M=!0),C.node($).rank=C.node(B).rank+(M?O.minlen:-O.minlen)})}function x(E,C,R){return E.hasEdge(C,R)}function N(E,C,R){return R.low<=C.lim&&C.lim<=R.lim}return $w}var Ow,HE;function lU(){if(HE)return Ow;HE=1;var e=dd(),t=e.longestPath,n=GA(),s=iU();Ow=a;function a(h){switch(h.graph().ranker){case"network-simplex":d(h);break;case"tight-tree":c(h);break;case"longest-path":l(h);break;default:d(h)}}var l=t;function c(h){t(h),n(h)}function d(h){s(h)}return Ow}var Pw,GE;function cU(){if(GE)return Pw;GE=1;var e=vt();Pw=t;function t(a){var l=s(a);e.forEach(a.graph().dummyChains,function(c){for(var d=a.node(c),h=d.edgeObj,p=n(a,l,h.v,h.w),f=p.path,m=p.lca,y=0,v=f[y],S=!0;c!==h.w;){if(d=a.node(c),S){for(;(v=f[y])!==m&&a.node(v).maxRank<d.rank;)y++;v===m&&(S=!1)}if(!S){for(;y<f.length-1&&a.node(v=f[y+1]).minRank<=d.rank;)y++;v=f[y]}a.setParent(c,v),c=a.successors(c)[0]}})}function n(a,l,c,d){var h=[],p=[],f=Math.min(l[c].low,l[d].low),m=Math.max(l[c].lim,l[d].lim),y,v;y=c;do y=a.parent(y),h.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(v=y,y=d;(y=a.parent(y))!==v;)p.push(y);return{path:h.concat(p.reverse()),lca:v}}function s(a){var l={},c=0;function d(h){var p=c;e.forEach(a.children(h),d),l[h]={low:p,lim:c++}}return e.forEach(a.children(),d),l}return Pw}var Lw,VE;function uU(){if(VE)return Lw;VE=1;var e=vt(),t=vn();Lw={run:n,cleanup:c};function n(d){var h=t.addDummyNode(d,"root",{},"_root"),p=a(d),f=e.max(e.values(p))-1,m=2*f+1;d.graph().nestingRoot=h,e.forEach(d.edges(),function(v){d.edge(v).minlen*=m});var y=l(d)+1;e.forEach(d.children(),function(v){s(d,h,m,y,f,p,v)}),d.graph().nodeRankFactor=m}function s(d,h,p,f,m,y,v){var S=d.children(v);if(!S.length){v!==h&&d.setEdge(h,v,{weight:0,minlen:p});return}var _=t.addBorderNode(d,"_bt"),j=t.addBorderNode(d,"_bb"),x=d.node(v);d.setParent(_,v),x.borderTop=_,d.setParent(j,v),x.borderBottom=j,e.forEach(S,function(N){s(d,h,p,f,m,y,N);var E=d.node(N),C=E.borderTop?E.borderTop:N,R=E.borderBottom?E.borderBottom:N,I=E.borderTop?f:2*f,$=C!==R?1:m-y[v]+1;d.setEdge(_,C,{weight:I,minlen:$,nestingEdge:!0}),d.setEdge(R,j,{weight:I,minlen:$,nestingEdge:!0})}),d.parent(v)||d.setEdge(h,_,{weight:0,minlen:m+y[v]})}function a(d){var h={};function p(f,m){var y=d.children(f);y&&y.length&&e.forEach(y,function(v){p(v,m+1)}),h[f]=m}return e.forEach(d.children(),function(f){p(f,1)}),h}function l(d){return e.reduce(d.edges(),function(h,p){return h+d.edge(p).weight},0)}function c(d){var h=d.graph();d.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(d.edges(),function(p){var f=d.edge(p);f.nestingEdge&&d.removeEdge(p)})}return Lw}var Dw,YE;function dU(){if(YE)return Dw;YE=1;var e=vt(),t=vn();Dw=n;function n(a){function l(c){var d=a.children(c),h=a.node(c);if(d.length&&e.forEach(d,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(a,"borderLeft","_bl",c,h,p),s(a,"borderRight","_br",c,h,p)}}e.forEach(a.children(),l)}function s(a,l,c,d,h,p){var f={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=t.addDummyNode(a,"border",f,c);h[l][p]=y,a.setParent(y,d),m&&a.setEdge(m,y,{weight:1})}return Dw}var qw,KE;function hU(){if(KE)return qw;KE=1;var e=vt();qw={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(p),(f==="lr"||f==="rl")&&(d(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){a(p.node(f))}),e.forEach(p.edges(),function(f){a(p.edge(f))})}function a(p){var f=p.width;p.width=p.height,p.height=f}function l(p){e.forEach(p.nodes(),function(f){c(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,c),e.has(m,"y")&&c(m)})}function c(p){p.y=-p.y}function d(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return qw}var Fw,XE;function fU(){if(XE)return Fw;XE=1;var e=vt();Fw=t;function t(n){var s={},a=e.filter(n.nodes(),function(p){return!n.children(p).length}),l=e.max(e.map(a,function(p){return n.node(p).rank})),c=e.map(e.range(l+1),function(){return[]});function d(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);c[f.rank].push(p),e.forEach(n.successors(p),d)}}var h=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(h,d),c}return Fw}var Bw,QE;function pU(){if(QE)return Bw;QE=1;var e=vt();Bw=t;function t(s,a){for(var l=0,c=1;c<a.length;++c)l+=n(s,a[c-1],a[c]);return l}function n(s,a,l){for(var c=e.zipObject(l,e.map(l,function(y,v){return v})),d=e.flatten(e.map(a,function(y){return e.sortBy(e.map(s.outEdges(y),function(v){return{pos:c[v.w],weight:s.edge(v).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(d.forEach(function(y){var v=y.pos+h;f[v]+=y.weight;for(var S=0;v>0;)v%2&&(S+=f[v+1]),v=v-1>>1,f[v]+=y.weight;m+=y.weight*S})),m}return Bw}var zw,ZE;function mU(){if(ZE)return zw;ZE=1;var e=vt();zw=t;function t(n,s){return e.map(s,function(a){var l=n.inEdges(a);if(l.length){var c=e.reduce(l,function(d,h){var p=n.edge(h),f=n.node(h.v);return{sum:d.sum+p.weight*f.order,weight:d.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return zw}var Uw,JE;function gU(){if(JE)return Uw;JE=1;var e=vt();Uw=t;function t(a,l){var c={};e.forEach(a,function(h,p){var f=c[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=c[h.v],f=c[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(c[h.w]))});var d=e.filter(c,function(h){return!h.indegree});return n(d)}function n(a){var l=[];function c(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function d(p){return function(f){f.in.push(p),--f.indegree===0&&a.push(f)}}for(;a.length;){var h=a.pop();l.push(h),e.forEach(h.in.reverse(),c(h)),e.forEach(h.out,d(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(a,l){var c=0,d=0;a.weight&&(c+=a.barycenter*a.weight,d+=a.weight),l.weight&&(c+=l.barycenter*l.weight,d+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/d,a.weight=d,a.i=Math.min(l.i,a.i),l.merged=!0}return Uw}var Ww,eC;function yU(){if(eC)return Ww;eC=1;var e=vt(),t=vn();Ww=n;function n(l,c){var d=t.partition(l,function(_){return e.has(_,"barycenter")}),h=d.lhs,p=e.sortBy(d.rhs,function(_){return-_.i}),f=[],m=0,y=0,v=0;h.sort(a(!!c)),v=s(f,p,v),e.forEach(h,function(_){v+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,v=s(f,p,v)});var S={vs:e.flatten(f,!0)};return y&&(S.barycenter=m/y,S.weight=y),S}function s(l,c,d){for(var h;c.length&&(h=e.last(c)).i<=d;)c.pop(),l.push(h.vs),d++;return d}function a(l){return function(c,d){return c.barycenter<d.barycenter?-1:c.barycenter>d.barycenter?1:l?d.i-c.i:c.i-d.i}}return Ww}var Hw,tC;function wU(){if(tC)return Hw;tC=1;var e=vt(),t=mU(),n=gU(),s=yU();Hw=a;function a(d,h,p,f){var m=d.children(h),y=d.node(h),v=y?y.borderLeft:void 0,S=y?y.borderRight:void 0,_={};v&&(m=e.filter(m,function(R){return R!==v&&R!==S}));var j=t(d,m);e.forEach(j,function(R){if(d.children(R.v).length){var I=a(d,R.v,p,f);_[R.v]=I,e.has(I,"barycenter")&&c(R,I)}});var x=n(j,p);l(x,_);var N=s(x,f);if(v&&(N.vs=e.flatten([v,N.vs,S],!0),d.predecessors(v).length)){var E=d.node(d.predecessors(v)[0]),C=d.node(d.predecessors(S)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+E.order+C.order)/(N.weight+2),N.weight+=2}return N}function l(d,h){e.forEach(d,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function c(d,h){e.isUndefined(d.barycenter)?(d.barycenter=h.barycenter,d.weight=h.weight):(d.barycenter=(d.barycenter*d.weight+h.barycenter*h.weight)/(d.weight+h.weight),d.weight+=h.weight)}return Hw}var Gw,nC;function vU(){if(nC)return Gw;nC=1;var e=vt(),t=mr().Graph;Gw=n;function n(a,l,c){var d=s(a),h=new t({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var f=a.node(p),m=a.parent(p);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(h.setNode(p),h.setParent(p,m||d),e.forEach(a[c](p),function(y){var v=y.v===p?y.w:y.v,S=h.edge(v,p),_=e.isUndefined(S)?0:S.weight;h.setEdge(v,p,{weight:a.edge(y).weight+_})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),h}function s(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return Gw}var Vw,rC;function xU(){if(rC)return Vw;rC=1;var e=vt();Vw=t;function t(n,s,a){var l={},c;e.forEach(a,function(d){for(var h=n.parent(d),p,f;h;){if(p=n.parent(h),p?(f=l[p],l[p]=h):(f=c,c=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return Vw}var Yw,sC;function bU(){if(sC)return Yw;sC=1;var e=vt(),t=fU(),n=pU(),s=wU(),a=vU(),l=xU(),c=mr().Graph,d=vn();Yw=h;function h(y){var v=d.maxRank(y),S=p(y,e.range(1,v+1),"inEdges"),_=p(y,e.range(v-1,-1,-1),"outEdges"),j=t(y);m(y,j);for(var x=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){f(E%2?S:_,E%4>=2),j=d.buildLayerMatrix(y);var R=n(y,j);R<x&&(C=0,N=e.cloneDeep(j),x=R)}m(y,N)}function p(y,v,S){return e.map(v,function(_){return a(y,_,S)})}function f(y,v){var S=new c;e.forEach(y,function(_){var j=_.graph().root,x=s(_,j,S,v);e.forEach(x.vs,function(N,E){_.node(N).order=E}),l(_,S,x.vs)})}function m(y,v){e.forEach(v,function(S){e.forEach(S,function(_,j){y.node(_).order=j})})}return Yw}var Kw,aC;function kU(){if(aC)return Kw;aC=1;var e=vt(),t=mr().Graph,n=vn();Kw={positionX:S,findType1Conflicts:s,findType2Conflicts:a,addConflict:c,hasConflict:d,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:v};function s(x,N){var E={};function C(R,I){var $=0,B=0,O=R.length,M=e.last(I);return e.forEach(I,function(L,H){var F=l(x,L),A=F?x.node(F).order:O;(F||L===M)&&(e.forEach(I.slice(B,H+1),function(Q){e.forEach(x.predecessors(Q),function(K){var ee=x.node(K),Z=ee.order;(Z<$||A<Z)&&!(ee.dummy&&x.node(Q).dummy)&&c(E,K,Q)})}),B=H+1,$=A)}),I}return e.reduce(N,C),E}function a(x,N){var E={};function C(I,$,B,O,M){var L;e.forEach(e.range($,B),function(H){L=I[H],x.node(L).dummy&&e.forEach(x.predecessors(L),function(F){var A=x.node(F);A.dummy&&(A.order<O||A.order>M)&&c(E,F,L)})})}function R(I,$){var B=-1,O,M=0;return e.forEach($,function(L,H){if(x.node(L).dummy==="border"){var F=x.predecessors(L);F.length&&(O=x.node(F[0]).order,C($,M,H,B,O),M=H,B=O)}C($,M,$.length,O,I.length)}),$}return e.reduce(N,R),E}function l(x,N){if(x.node(N).dummy)return e.find(x.predecessors(N),function(E){return x.node(E).dummy})}function c(x,N,E){if(N>E){var C=N;N=E,E=C}var R=x[N];R||(x[N]=R={}),R[E]=!0}function d(x,N,E){if(N>E){var C=N;N=E,E=C}return e.has(x[N],E)}function h(x,N,E,C){var R={},I={},$={};return e.forEach(N,function(B){e.forEach(B,function(O,M){R[O]=O,I[O]=O,$[O]=M})}),e.forEach(N,function(B){var O=-1;e.forEach(B,function(M){var L=C(M);if(L.length){L=e.sortBy(L,function(K){return $[K]});for(var H=(L.length-1)/2,F=Math.floor(H),A=Math.ceil(H);F<=A;++F){var Q=L[F];I[M]===M&&O<$[Q]&&!d(E,M,Q)&&(I[Q]=M,I[M]=R[M]=R[Q],O=$[Q])}}})}),{root:R,align:I}}function p(x,N,E,C,R){var I={},$=f(x,N,E,R),B=R?"borderLeft":"borderRight";function O(H,F){for(var A=$.nodes(),Q=A.pop(),K={};Q;)K[Q]?H(Q):(K[Q]=!0,A.push(Q),A=A.concat(F(Q))),Q=A.pop()}function M(H){I[H]=$.inEdges(H).reduce(function(F,A){return Math.max(F,I[A.v]+$.edge(A))},0)}function L(H){var F=$.outEdges(H).reduce(function(Q,K){return Math.min(Q,I[K.w]-$.edge(K))},Number.POSITIVE_INFINITY),A=x.node(H);F!==Number.POSITIVE_INFINITY&&A.borderType!==B&&(I[H]=Math.max(I[H],F))}return O(M,$.predecessors.bind($)),O(L,$.successors.bind($)),e.forEach(C,function(H){I[H]=I[E[H]]}),I}function f(x,N,E,C){var R=new t,I=x.graph(),$=_(I.nodesep,I.edgesep,C);return e.forEach(N,function(B){var O;e.forEach(B,function(M){var L=E[M];if(R.setNode(L),O){var H=E[O],F=R.edge(H,L);R.setEdge(H,L,Math.max($(x,M,O),F||0))}O=M})}),R}function m(x,N){return e.minBy(e.values(N),function(E){var C=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(E,function(I,$){var B=j(x,$)/2;C=Math.max(I+B,C),R=Math.min(I-B,R)}),C-R})}function y(x,N){var E=e.values(N),C=e.min(E),R=e.max(E);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function($){var B=I+$,O=x[B],M;if(O!==N){var L=e.values(O);M=$==="l"?C-e.min(L):R-e.max(L),M&&(x[B]=e.mapValues(O,function(H){return H+M}))}})})}function v(x,N){return e.mapValues(x.ul,function(E,C){if(N)return x[N.toLowerCase()][C];var R=e.sortBy(e.map(x,C));return(R[1]+R[2])/2})}function S(x){var N=n.buildLayerMatrix(x),E=e.merge(s(x,N),a(x,N)),C={},R;e.forEach(["u","d"],function($){R=$==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(R=e.map(R,function(H){return e.values(H).reverse()}));var O=($==="u"?x.predecessors:x.successors).bind(x),M=h(x,R,E,O),L=p(x,R,M.root,M.align,B==="r");B==="r"&&(L=e.mapValues(L,function(H){return-H})),C[$+B]=L})});var I=m(x,C);return y(C,I),v(C,x.graph().align)}function _(x,N,E){return function(C,R,I){var $=C.node(R),B=C.node(I),O=0,M;if(O+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":M=-$.width/2;break;case"r":M=$.width/2;break}if(M&&(O+=E?M:-M),M=0,O+=($.dummy?N:x)/2,O+=(B.dummy?N:x)/2,O+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":M=B.width/2;break;case"r":M=-B.width/2;break}return M&&(O+=E?M:-M),M=0,O}}function j(x,N){return x.node(N).width}return Kw}var Xw,oC;function _U(){if(oC)return Xw;oC=1;var e=vt(),t=vn(),n=kU().positionX;Xw=s;function s(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,d){l.node(d).x=c})}function a(l){var c=t.buildLayerMatrix(l),d=l.graph().ranksep,h=0;e.forEach(c,function(p){var f=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+f/2}),h+=f+d})}return Xw}var Qw,iC;function NU(){if(iC)return Qw;iC=1;var e=vt(),t=aU(),n=oU(),s=lU(),a=vn().normalizeRanks,l=cU(),c=vn().removeEmptyRanks,d=uU(),h=dU(),p=hU(),f=bU(),m=_U(),y=vn(),v=mr().Graph;Qw=S;function S(W,U){var J=U&&U.debugTiming?y.time:y.notime;J("layout",function(){var V=J(" buildLayoutGraph",function(){return O(W)});J(" runLayout",function(){_(V,J)}),J(" updateInputGraph",function(){j(W,V)})})}function _(W,U){U(" makeSpaceForEdgeLabels",function(){M(W)}),U(" removeSelfEdges",function(){D(W)}),U(" acyclic",function(){t.run(W)}),U(" nestingGraph.run",function(){d.run(W)}),U(" rank",function(){s(y.asNonCompoundGraph(W))}),U(" injectEdgeLabelProxies",function(){L(W)}),U(" removeEmptyRanks",function(){c(W)}),U(" nestingGraph.cleanup",function(){d.cleanup(W)}),U(" normalizeRanks",function(){a(W)}),U(" assignRankMinMax",function(){H(W)}),U(" removeEdgeLabelProxies",function(){F(W)}),U(" normalize.run",function(){n.run(W)}),U(" parentDummyChains",function(){l(W)}),U(" addBorderSegments",function(){h(W)}),U(" order",function(){f(W)}),U(" insertSelfEdges",function(){Y(W)}),U(" adjustCoordinateSystem",function(){p.adjust(W)}),U(" position",function(){m(W)}),U(" positionSelfEdges",function(){P(W)}),U(" removeBorderNodes",function(){Z(W)}),U(" normalize.undo",function(){n.undo(W)}),U(" fixupEdgeLabelCoords",function(){K(W)}),U(" undoCoordinateSystem",function(){p.undo(W)}),U(" translateGraph",function(){A(W)}),U(" assignNodeIntersects",function(){Q(W)}),U(" reversePoints",function(){ee(W)}),U(" acyclic.undo",function(){t.undo(W)})}function j(W,U){e.forEach(W.nodes(),function(J){var V=W.node(J),ie=U.node(J);V&&(V.x=ie.x,V.y=ie.y,U.children(J).length&&(V.width=ie.width,V.height=ie.height))}),e.forEach(W.edges(),function(J){var V=W.edge(J),ie=U.edge(J);V.points=ie.points,e.has(ie,"x")&&(V.x=ie.x,V.y=ie.y)}),W.graph().width=U.graph().width,W.graph().height=U.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],$={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function O(W){var U=new v({multigraph:!0,compound:!0}),J=de(W.graph());return U.setGraph(e.merge({},N,G(J,x),e.pick(J,E))),e.forEach(W.nodes(),function(V){var ie=de(W.node(V));U.setNode(V,e.defaults(G(ie,C),R)),U.setParent(V,W.parent(V))}),e.forEach(W.edges(),function(V){var ie=de(W.edge(V));U.setEdge(V,e.merge({},$,G(ie,I),e.pick(ie,B)))}),U}function M(W){var U=W.graph();U.ranksep/=2,e.forEach(W.edges(),function(J){var V=W.edge(J);V.minlen*=2,V.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?V.width+=V.labeloffset:V.height+=V.labeloffset)})}function L(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(J.width&&J.height){var V=W.node(U.v),ie=W.node(U.w),pe={rank:(ie.rank-V.rank)/2+V.rank,e:U};y.addDummyNode(W,"edge-proxy",pe,"_ep")}})}function H(W){var U=0;e.forEach(W.nodes(),function(J){var V=W.node(J);V.borderTop&&(V.minRank=W.node(V.borderTop).rank,V.maxRank=W.node(V.borderBottom).rank,U=e.max(U,V.maxRank))}),W.graph().maxRank=U}function F(W){e.forEach(W.nodes(),function(U){var J=W.node(U);J.dummy==="edge-proxy"&&(W.edge(J.e).labelRank=J.rank,W.removeNode(U))})}function A(W){var U=Number.POSITIVE_INFINITY,J=0,V=Number.POSITIVE_INFINITY,ie=0,pe=W.graph(),me=pe.marginx||0,Ie=pe.marginy||0;function Le(ce){var xe=ce.x,ye=ce.y,ze=ce.width,ke=ce.height;U=Math.min(U,xe-ze/2),J=Math.max(J,xe+ze/2),V=Math.min(V,ye-ke/2),ie=Math.max(ie,ye+ke/2)}e.forEach(W.nodes(),function(ce){Le(W.node(ce))}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.has(xe,"x")&&Le(xe)}),U-=me,V-=Ie,e.forEach(W.nodes(),function(ce){var xe=W.node(ce);xe.x-=U,xe.y-=V}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.forEach(xe.points,function(ye){ye.x-=U,ye.y-=V}),e.has(xe,"x")&&(xe.x-=U),e.has(xe,"y")&&(xe.y-=V)}),pe.width=J-U+me,pe.height=ie-V+Ie}function Q(W){e.forEach(W.edges(),function(U){var J=W.edge(U),V=W.node(U.v),ie=W.node(U.w),pe,me;J.points?(pe=J.points[0],me=J.points[J.points.length-1]):(J.points=[],pe=ie,me=V),J.points.unshift(y.intersectRect(V,pe)),J.points.push(y.intersectRect(ie,me))})}function K(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(e.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function ee(W){e.forEach(W.edges(),function(U){var J=W.edge(U);J.reversed&&J.points.reverse()})}function Z(W){e.forEach(W.nodes(),function(U){if(W.children(U).length){var J=W.node(U),V=W.node(J.borderTop),ie=W.node(J.borderBottom),pe=W.node(e.last(J.borderLeft)),me=W.node(e.last(J.borderRight));J.width=Math.abs(me.x-pe.x),J.height=Math.abs(ie.y-V.y),J.x=pe.x+J.width/2,J.y=V.y+J.height/2}}),e.forEach(W.nodes(),function(U){W.node(U).dummy==="border"&&W.removeNode(U)})}function D(W){e.forEach(W.edges(),function(U){if(U.v===U.w){var J=W.node(U.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:U,label:W.edge(U)}),W.removeEdge(U)}})}function Y(W){var U=y.buildLayerMatrix(W);e.forEach(U,function(J){var V=0;e.forEach(J,function(ie,pe){var me=W.node(ie);me.order=pe+V,e.forEach(me.selfEdges,function(Ie){y.addDummyNode(W,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:me.rank,order:pe+ ++V,e:Ie.e,label:Ie.label},"_se")}),delete me.selfEdges})})}function P(W){e.forEach(W.nodes(),function(U){var J=W.node(U);if(J.dummy==="selfedge"){var V=W.node(J.e.v),ie=V.x+V.width/2,pe=V.y,me=J.x-ie,Ie=V.height/2;W.setEdge(J.e,J.label),W.removeNode(U),J.label.points=[{x:ie+2*me/3,y:pe-Ie},{x:ie+5*me/6,y:pe-Ie},{x:ie+me,y:pe},{x:ie+5*me/6,y:pe+Ie},{x:ie+2*me/3,y:pe+Ie}],J.label.x=J.x,J.label.y=J.y}})}function G(W,U){return e.mapValues(e.pick(W,U),Number)}function de(W){var U={};return e.forEach(W,function(J,V){U[V.toLowerCase()]=J}),U}return Qw}var Zw,lC;function SU(){if(lC)return Zw;lC=1;var e=vt(),t=vn(),n=mr().Graph;Zw={debugOrdering:s};function s(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(d){c.setNode(d,{label:d}),c.setParent(d,"layer"+a.node(d).rank)}),e.forEach(a.edges(),function(d){c.setEdge(d.v,d.w,{},d.name)}),e.forEach(l,function(d,h){var p="layer"+h;c.setNode(p,{rank:"same"}),e.reduce(d,function(f,m){return c.setEdge(f,m,{style:"invis"}),m})}),c}return Zw}var Jw,cC;function jU(){return cC||(cC=1,Jw="0.8.5"),Jw}var ev,uC;function EU(){return uC||(uC=1,ev={graphlib:mr(),layout:NU(),debug:SU(),util:{time:vn().time,notime:vn().notime},version:jU()}),ev}var CU=EU();const dC=Bv(CU),ui=240,hd=130,ti=74,Ud=72,hC=ti+Ud;function TU(e,t){var s;let n=ui;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??ui);return n}const VA=420,AU=2;function Bl(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function RU(e,t){return((t==null?void 0:t.get(e))??0)>0?VA:0}function MU(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function zl(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??ui)+RU(e,n),h:Math.max((s==null?void 0:s.height)??hd,MU(e,n))}}function IU(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function $U(e,t,n,s,a,l){const c=new dC.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const d=e.filter(x=>!a.has(x)),h=new Set(d);for(const x of d){const{w:N,h:E}=zl(x,s,l);c.setNode(x,{width:N,height:E})}for(const x of t)h.has(x.source)&&h.has(x.target)&&c.setEdge(x.source,x.target);dC.layout(c);const p=new Map;let f=1/0,m=1/0,y=-1/0,v=-1/0;for(const x of d){const N=c.node(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ui,R=(E==null?void 0:E.height)??hd,I=zl(x,s,l),$=N.x-I.w/2,B=N.y-I.h/2;p.set(x,{x:$,y:B}),$<f&&(f=$),B<m&&(m=B),$+C>y&&(y=$+C),B+R>v&&(v=B+R)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[x,N]of p)p.set(x,{x:N.x-f,y:N.y-m});const S=Number.isFinite(y)?y-f:0,_=Number.isFinite(v)?v-m:0;let j=null;for(const x of e){const N=a.get(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ui,R=(E==null?void 0:E.height)??hd;j=j===null?{minX:N.x,minY:N.y,maxX:N.x+C,maxY:N.y+R}:{minX:Math.min(j.minX,N.x),minY:Math.min(j.minY,N.y),maxX:Math.max(j.maxX,N.x+C),maxY:Math.max(j.maxY,N.y+R)}}return{positions:p,width:S,height:_,pinnedBox:j}}function OU(e,t,n={}){const s=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,d=new Map;for(const x of e){const N=Bl(x),E=d.get(N);E?E.push(x.id):d.set(N,[x.id])}const p=Array.from(d.keys()).sort().map(x=>({sid:x,...$U(d.get(x),t,s,l,a,c)})),f=TU(e,l),m=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,y=x=>{const N=[[]];let E=0;for(const C of p)N.length<x&&E>0&&E+C.height>m&&(N.push([]),E=0),N[N.length-1].push(C),E+=C.height+hC;return N},v=x=>x.reduce((N,E)=>Math.max(N,E.width),0)+VA;let S=y(n.availableWidth?AU:1);S.length>1&&S.reduce((N,E)=>N+v(E),0)+f*(S.length-1)>(n.availableWidth??0)&&(S=y(1));const _=new Map;let j=0;for(const x of S){const N=v(x);let E=0;for(const{positions:C,height:R,pinnedBox:I}of x){for(const[B,O]of C)_.set(B,{x:O.x+j,y:O.y+E});let $=E+R;I&&I.maxY>$&&I.minX<j+N&&j<I.maxX&&($=I.maxY),E=$+hC}j+=N+f}return e.map(x=>{const N=a.get(x.id);if(N)return{...x,position:N};const E=_.get(x.id);return E?{...x,position:E}:x})}function PU(e,t,n,s,a){const c=ti+Ud,d=60,h=v=>zl(v,s,a),p=new Map(e.map(v=>[v.id,Bl(v)])),f=[],m=e.map(v=>({id:v.id,pos:n.get(v.id)??t.get(v.id)})).filter(v=>v.pos!=null).sort((v,S)=>v.pos.y-S.pos.y||v.pos.x-S.pos.x||v.id.localeCompare(S.id)),y=[];for(const{id:v,pos:S}of m){const{w:_,h:j}=h(v),x=p.get(v)??"_default";if(n.has(v)){f.push({x:S.x,y:S.y,w:_,h:j,sid:x});continue}let N=S.y;for(let E=0;E<f.length+1;E++){const C=f.find(R=>{const I=R.sid===x?24:d,$=R.sid===x?24:c;return S.x<R.x+R.w+I&&R.x<S.x+_+I&&N<R.y+R.h+$&&R.y<N+j+$});if(!C)break;N=C.y+C.h+(C.sid===x?24:c)}N!==S.y&&(t.set(v,{x:S.x,y:N}),y.push(v)),f.push({x:S.x,y:N,w:_,h:j,sid:x})}return y}function LU(e,t,n,s,a,l){const c=_=>zl(_,s,l),d=_=>n.get(_)??t.get(_),h=new Map;for(const _ of e){if(!d(_.id))continue;const j=Bl(_),x=h.get(j);x?x.push(_):h.set(j,[_])}const p=new Set;for(const[_,j]of h)j.every(x=>a.has(x.id)&&!n.has(x.id))&&p.add(_);const f=new Map,m=[];for(const _ of e){const j=d(_.id);if(!j)continue;const{w:x,h:N}=c(_.id),E=Bl(_);p.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):m.push({x:j.x,y:j.y,w:x,h:N})}if(f.size===0)return[];const y=ti+Ud,v=(_,j,x,N)=>m.some(E=>_<E.x+E.w+ti&&E.x<_+x+ti&&j<E.y+E.h+y&&E.y<j+N+y),S=[];for(const _ of[...f.keys()].sort()){const j=f.get(_);let x=1/0,N=1/0,E=-1/0,C=-1/0;for(const L of j){const H=d(L.id),{w:F,h:A}=c(L.id);x=Math.min(x,H.x),N=Math.min(N,H.y),E=Math.max(E,H.x+F),C=Math.max(C,H.y+A)}const R=E-x,I=C-N,$=[...new Set(m.map(L=>Math.round(L.x)))].sort((L,H)=>L-H),B=$.length?$:[x],O=[0,...m.map(L=>L.y+L.h+y)].sort((L,H)=>L-H);let M=null;e:for(const L of B)for(const H of O){if(H>=N)break;if(!v(L,H,R,I)){M={x:L,y:H};break e}}if(M){const L=M.x-x,H=M.y-N;for(const F of j){const A=d(F.id);t.set(F.id,{x:A.x+L,y:A.y+H})}S.push(_)}for(const L of j){const H=d(L.id),{w:F,h:A}=c(L.id);m.push({x:H.x,y:H.y,w:F,h:A})}}return S}function DU(e,t,n,s,a,l=!1,c){const p=ti+Ud+1,f=8,m=1.75,y=200,v=.7,S=.01,_=M=>zl(M,s,c),j=M=>n.get(M)??t.get(M),x=new Map;for(const M of e){if(!j(M.id))continue;const L=Bl(M),H=x.get(L);H?H.push(M):x.set(L,[M])}const N=[],E=new Set,C=new Set,R=a.size===0;for(const M of[...x.keys()].sort()){const L=x.get(M);let H=1/0,F=1/0,A=-1/0,Q=-1/0,K=!1;for(const Y of L){const P=j(Y.id),{w:G,h:de}=_(Y.id);H=Math.min(H,P.x),F=Math.min(F,P.y),A=Math.max(A,P.x+G),Q=Math.max(Q,P.y+de),n.has(Y.id)&&(K=!0)}const ee=A-H,Z=Q-F;C.add(M);const D=a.get(M);D&&(ee>D.w+f||Z>D.h+f)&&E.add(M),a.set(M,{w:ee,h:Z}),N.push({sid:M,members:L.map(Y=>Y.id),x:H,y:F,w:ee,h:Z,anchored:K,mass:1})}for(const M of[...a.keys()])C.has(M)||a.delete(M);if(l||R)return[];let I=!1;for(let M=0;M<N.length&&!I;M++)for(let L=M+1;L<N.length;L++){const H=N[M],F=N[L];if(!(H.anchored&&F.anchored)&&Math.abs(H.x+H.w/2-(F.x+F.w/2))<(H.w+F.w)/2+61&&Math.abs(H.y+H.h/2-(F.y+F.h/2))<(H.h+F.h)/2+p){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const M of N)E.has(M.sid)&&(M.mass=8);else for(const M of N)M.mass=Math.max(1,M.w*M.h/(ui*hd));const $=new Map(N.map(M=>[M.sid,M.x])),B=new Map(N.map(M=>[M.sid,M.y]));for(let M=0;M<y;M++){const L=new Map,H=new Map;let F=0;for(let A=0;A<N.length;A++)for(let Q=A+1;Q<N.length;Q++){const K=N[A],ee=N[Q];if(K.anchored&&ee.anchored)continue;const Z=K.x+K.w/2,D=K.y+K.h/2,Y=ee.x+ee.w/2,P=ee.y+ee.h/2,G=(K.w+ee.w)/2+61-Math.abs(Z-Y),de=(K.h+ee.h)/2+p-Math.abs(D-P);if(G<=0||de<=0)continue;const W=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.x<=0),U=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.y<=0),J=(Xe,he,ge)=>{const Se=Xe===he,Fe=Se?K.sid<ee.sid?-1:1:Math.sign(Xe-he);return ge(K,Fe)||ge(ee,-Fe)?Fe:Se&&(ge(K,-Fe)||ge(ee,Fe))?-Fe:0},V=J(Z,Y,W),ie=J(D,P,U),pe=V!==0,me=ie!==0;if(!pe&&!me)continue;const Ie=pe&&(!me||G*m<de),[Le,ce,xe,ye]=Ie?[V,G,L,W]:[ie,de,H,U],ze=ye(K,Le),ke=ye(ee,-Le),je=K.mass,Ye=ee.mass,it=ze?ke?Ye/(je+Ye):1:0,Ne=ke?ze?je/(je+Ye):1:0,He=ce*v;xe.set(K.sid,(xe.get(K.sid)??0)+Le*He*it),xe.set(ee.sid,(xe.get(ee.sid)??0)-Le*He*Ne),F+=He}for(const A of N)A.anchored||(A.x=Math.max(0,A.x+(L.get(A.sid)??0)),A.y=Math.max(0,A.y+(H.get(A.sid)??0)));if(F<S)break}const O=[];for(const M of N){const L=M.x-$.get(M.sid),H=M.y-B.get(M.sid);if(!(Math.abs(L)<1&&Math.abs(H)<1)){for(const F of M.members){if(n.has(F))continue;const A=t.get(F);A&&t.set(F,{x:A.x+L,y:A.y+H})}O.push(M.sid)}}return O}const qU=600;function Lv(e,t){return!(e.exitAt!=null&&t-e.exitAt>qU||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function FU(e,t){const n=new Set;for(const s of e.agents.values())Lv(s,t)&&n.add(s.id);return n}function BU(e,t,n=0){return e.right+n>t.left&&e.left-n<t.right&&e.bottom+n>t.top&&e.top-n<t.bottom}function zU(e,t,n=0){if(!e)return!1;for(const s of t)if(BU(e,s,n))return!0;return!1}const YA="sessionGroup";function UU(e,t){var s;if(e.type===YA)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const KA=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function fC(e){const t={};for(const n of KA)t[n]=e(n);return t}function WU(e){return t=>e[t]??""}function HU(e,t){return KA.every(n=>e[n]===t[n])}function GU(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[a,l]of e.positions)n.set(a,l),t.has(a)&&s.set(a,l);return{positions:n,pinned:s}}const VU=1200,YU=1e3;function pC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<VU?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<YU}function tv({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function KU(e,t,n){const s=e.x*t.zoom+t.x,a=e.y*t.zoom+t.y,l=(e.x+e.width)*t.zoom+t.x,c=(e.y+e.height)*t.zoom+t.y;return l>0&&s<n.width&&c>0&&a<n.height}function XU({pane:e,viewport:t,boxes:n}){if(!e||!(e.width>0)||!(e.height>0)||!Number.isFinite(t.zoom)||t.zoom<=0||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;let s=!1;for(const a of n)if(s=!0,KU(a,t,e))return!1;return s}const QU="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",nv="click for what's new";function ZU(e){if(e.checkDisabled)return`${QU} · ${nv}`;if(e.checking)return`Asking npm for the newest release… · ${nv}`;const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",n=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${nv}, and to check npm now`}function JU(e){const t=`Version v${e.running}, show what's new`;return e.checkDisabled?`${t} — update checks are off`:e.checking?`${t} — checking npm for a newer release`:`${t} and check npm for a newer release`}function eW(e){const t=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`,n=e.open?"show what's new":"show what's new and the notice";return`Version v${e.from}, ${t} — ${n}`}function tW(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Dv={kind:"assumed",claude:!0,codex:!0};function nW(e){if(!e||typeof e!="object")return Dv;const t=e.providers;if(!t||typeof t!="object")return Dv;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function fd(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const mC=99;function rW(e){const t=Math.max(0,Math.floor(e));return t>mC?`${mC}+`:String(t)}const sW="Pause the canvas";function aW(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${fd(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${fd(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function oW(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const XA="paused · full",iW=(e,t)=>t>0?XA:e>0?`paused · ${rW(e)}`:"paused";function lW(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:iW(e.held,t),widest:XA,title:t>0?`Connected — the pause is full at ${fd(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${fd(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function gC(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const cW={agent:u4,sessionGroup:E4},QA="react-flow__node";function yC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,QA))===!0}function uW(e){try{const t=document.querySelector(`.${QA}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const dW=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),hW=420;function fW(e){return e<.35?"far":e<.55?"mid":"full"}const Du=18,pW=200,mW=5*6e4,gW=6,yW=2*6e4,wC=400,zx="agent-dag.layout",Ux="agent-dag.viewport",ZA="agent-dag.summariesDismissed",JA="agent-dag.sessionListOpen",eR="agent-dag.detailOpen",tR="agent-dag.usagePanelOpen",nR="agent-dag.systemPanelOpen",vC="agent-dag.accountsPanelOpen",rv="agent-dag.versionNoticeDismissed",xC="agent-dag.oldNameNoticeDismissed",wW=15*6e4,sv={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},qu="agent-dag.autoRestart",bC="agent-dag.bundleReloadedFor";function vW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(JA)==="1"}catch{return!1}}function xW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(JA,e?"1":"0")}catch{}}function bW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eR)==="1"}catch{return!1}}function kW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eR,e?"1":"0")}catch{}}function _W(){const e=hi(tR);return e===null?!0:e==="1"}function NW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tR,e?"1":"0")}catch{}}function SW(){const e=hi(nR);return e===null?!0:e==="1"}function jW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(nR,e?"1":"0")}catch{}}function EW(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(ZA);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function kC(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(ZA,JSON.stringify(n))}catch{}}function CW(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(zx);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const a=Object.entries(n).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:a,pins:a.map(([l])=>l)}}return{positions:Object.entries(n.positions??{}).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function av(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,a]of e)n[s]=a;for(const[s,a]of t)n[s]=a;window.localStorage.setItem(zx,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function TW(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ux);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function AW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ux,JSON.stringify(e))}catch{}}function _C(){if(!(typeof window>"u")){try{window.localStorage.removeItem(zx)}catch{}try{window.localStorage.removeItem(Ux)}catch{}}}function RW(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const a={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(a,null,2),c=new Blob([l],{type:"application/json"}),d=URL.createObjectURL(c),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=d,h.download=`${Wt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(d),1e3)}const qv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Fv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},rR=c2;function MW(e,t,n,s,a,l,c,d,h,p,f,m,y,v,S,_,j,x){const N=[],E=[];for(const M of e.agents.values()){if(!j.has(M.id))continue;const L=M.exitAt!=null,H=_!=null&&!_.has(M.id),F=[L?"rf-exiting":"",H?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=l.get(M.id);if(N.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:t,onOpenContext:x},className:F,...A?{width:A.width,height:A.height}:null}),M.parentId&&j.has(M.parentId)){const Q=ix(M.sessionId),K=L,ee=S.size>0&&(S.has(M.id)||S.has(M.parentId)),Z=_!=null&&!_.has(M.id)&&!_.has(M.parentId),D=M.state==="active"?2:1.5,Y=ee?D+1.5:D,P=K?.2:Z?.12:1,G=["sess-edge",M.state==="active"?"sess-live":"sess-idle",K?"rf-edge-exiting":"",ee?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||ee)&&!K,type:"smoothstep",style:{"--session-hue":Q,strokeWidth:Y,opacity:P,transition:"var(--edge-transition)"},className:G})}}const C=new Map;for(const M of e.agents.values())M.tools.length>0&&C.set(M.id,Math.min(4,M.tools.length));const R=`${y}#lanes:${IU(C)}`,I=N.filter(M=>SF(M.id,a,f,m));if(I.length>0||R!==v.current){if(I.length>0){const M=OU(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:s,lanes:C});for(const L of M)W2(L.id,f,m)&&EF(L.id,L.position,f,m);LU(N,f,a,l,new Set(I.map(L=>L.id)),C)}PU(N,f,a,l,C),v.current=R}const $=DU(N,f,a,l,c,!h||p,C);$.length>0&&d($),Mu(f,e.agents),Mu(m,e.agents),Mu(a,e.agents),Mu(l,kF(e.agents.values()));const B=[];let O=!1;for(const M of N){let L=a.get(M.id)??f.get(M.id);L||(L=jF(M.id,f,m),O=!0),B.push({...M,position:L})}return O&&(v.current=""),{nodes:B,edges:E}}function IW(){return i.jsx(ax,{children:i.jsx($W,{})})}function $W(){var Hi,Gi,Vi,Yi;const e=Vl(),t=Rt(),n=b.useState(kv)[0],s=b.useRef(n),[,a]=b.useState(0),l=b.useCallback(()=>a(q=>q+1),[]),[c,d]=b.useState(()=>new Set),[h,p]=b.useState(null),[f,m]=b.useState(null),y=b.useCallback((q,z)=>{d(se=>{if(!z)return new Set([q]);const oe=new Set(se);return oe.has(q)?oe.delete(q):oe.add(q),oe}),p(se=>z&&se===q?se:q)},[]),v=b.useCallback(()=>{d(new Set),p(null)},[]),[S,_]=b.useState(null),[j,x]=b.useState(null),N=b.useCallback(q=>x(q),[]),[E,C]=b.useState(!1),[R,I]=b.useState(!1),[$,B]=b.useState(!1),O=b.useRef(null),M=b.useState(EW)[0],[L,H]=b.useState(vW);b.useEffect(()=>{xW(L)},[L]);const[F,A]=b.useState(bW);b.useEffect(()=>{kW(F)},[F]);const[Q,K]=b.useState(_W);b.useEffect(()=>{NW(Q)},[Q]);const[ee,Z]=b.useState(SW);b.useEffect(()=>{jW(ee)},[ee]);const[D,Y]=b.useState(()=>{try{const q=window.localStorage.getItem(vC);return q===null?!0:q==="1"}catch{return!0}});b.useEffect(()=>{try{window.localStorage.setItem(vC,D?"1":"0")}catch{}},[D]);const P=$f(D,200),G=$f(Q,130),de=$f(ee,130),[W,U]=b.useState(null);b.useEffect(()=>{let q=null;try{q=localStorage.getItem("agent-dag.sound")}catch{}U(q===null?!0:q==="on")},[]);const J=b.useCallback(()=>{U(q=>{var se;const z=q!==!0;try{localStorage.setItem("agent-dag.sound",z?"on":"off")}catch{}return z&&((se=Ye.current)==null||se.unlock()),z})},[]),V=b.useCallback(q=>{J()},[J]),ie=b.useRef(V);ie.current=V;const pe=b.useRef(W);pe.current=W;const[me,Ie]=b.useState(()=>qq(hi)),Le=b.useRef(me);Le.current=me;const ce=b.useRef(null),xe=b.useCallback((q,z=!1)=>{var se,oe;if((se=Ye.current)==null||se.unlock(),ce.current!==null&&clearTimeout(ce.current),ce.current=null,!z){(oe=Ye.current)==null||oe.play(q,!0);return}ce.current=setTimeout(()=>{var Ee;ce.current=null,(Ee=Ye.current)==null||Ee.play(q,!0)},$q)},[]),ye=b.useCallback((q,z)=>{Ie(se=>{const oe={level:Fl(z.level??se[q].level),figure:L2(q,z.figure??se[q].figure)};try{localStorage.setItem(D2[q],String(oe.level)),localStorage.setItem(q2[q],oe.figure)}catch{}return{...se,[q]:oe}}),xe(q,!0)},[xe]);b.useEffect(()=>()=>{ce.current!==null&&clearTimeout(ce.current)},[]);const[ze,ke]=b.useState(!1),je=b.useRef(null),Ye=b.useRef(null),[it,Ne]=b.useState("locked");b.useEffect(()=>{const q=zq({enabled:()=>pe.current===!0,prefs:()=>Le.current,onState:Ne});Ye.current=q,Ne(q.state());const z=()=>q.unlock();return window.addEventListener("pointerdown",z,{once:!0,capture:!0}),window.addEventListener("keydown",z,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",z,{capture:!0}),window.removeEventListener("keydown",z,{capture:!0})}},[]);const[He,Xe]=b.useState(!1),[he,ge]=b.useState(null),[Se,Fe]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(rv)??""}catch{return""}}),[et,xt]=b.useState(!1),ht=b.useRef(0),[ne,De]=b.useState(!1),Oe=b.useCallback((q=!1)=>(q&&(ht.current=Date.now(),De(!0)),fetch(q?"/api/version?refresh=1":"/api/version").then(z=>z.ok?z.json():null).then(z=>{z&&ge(z)}).catch(()=>{}).finally(()=>{q&&De(!1)})),[]),Te=b.useCallback(()=>{Oe(Date.now()-ht.current>=wW)},[Oe]);b.useEffect(()=>{Oe();const q=window.setInterval(Te,5*6e4),z=()=>{document.visibilityState==="visible"&&Te()};return document.addEventListener("visibilitychange",z),()=>{window.clearInterval(q),document.removeEventListener("visibilitychange",z)}},[Oe,Te]),b.useEffect(()=>{He&&Oe()},[He,Oe]),b.useEffect(()=>{const q=Qq();let z=null;const se=We=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:q,looking:We}),keepalive:!0}).catch(()=>{})},oe=()=>{const We=Kq(document);Xq(z,We)&&se(We),z=We},Ee=()=>{z&&se(!1),z=!1};oe();const Me=window.setInterval(oe,Yq);return window.addEventListener("focus",oe),window.addEventListener("blur",oe),document.addEventListener("visibilitychange",oe),window.addEventListener("pagehide",Ee),()=>{window.clearInterval(Me),window.removeEventListener("focus",oe),window.removeEventListener("blur",oe),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",Ee),Ee()}},[]);const Ce=(he==null?void 0:he.notice)??null,[lt,ut]=b.useState(null),Re=b.useRef(!1);b.useEffect(()=>{if(Re.current)return;const q=D1(),z=oF(q),se=hF({stored:z,running:(he==null?void 0:he.running)??null,notes:L1,remembers:iF(q)});if(se.reason==="no-version")return;Re.current=!0,se.record&&lF(q,se.record);const oe=dF({tourSeen:cF(q),decision:se}),Ee=se.show.length?{entries:se.show,since:z,firstRun:!1}:null;oe.tour&&B(!0),oe.notes==="now"?ut(Ee):oe.notes==="after"&&(O.current=Ee)},[he==null?void 0:he.running]);const mt=(he==null?void 0:he.running)??"3.22.1",ft=b.useMemo(()=>F2(L1,null,mt),[mt]),bt=b.useCallback(()=>{ut({entries:ft,since:null,firstRun:!1})},[ft]),[Xn,Tn]=b.useState(null),[ln,eo]=b.useState(Dv);b.useEffect(()=>{let q=!1;return fetch("/api/health").then(z=>z.ok?z.json():null).then(z=>{q||(eo(nW(z)),!(!z||typeof z.workspace!="string")&&Tn(z.workspace))}).catch(()=>{}),()=>{q=!0}},[He]);const us=b.useRef(ln);us.current=ln;const Or=Ce?`${Ce.kind}:${Ce.to}`:"",Qn=Ce!=null&&Se!==Or,to=b.useCallback(()=>{Fe("");try{window.localStorage.setItem(rv,"")}catch{}},[]),Pr=b.useCallback(()=>{if(Ce){Fe(Or);try{window.localStorage.setItem(rv,Or)}catch{}}},[Ce,Or]),[Qs,Lr]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(xC)??""}catch{return""}}),An=he!=null&&he.invokedAs&&he.invokedAs!==Wt?he.invokedAs:null,Dr=An!=null&&Qs!==An,ds=b.useCallback(()=>{if(An){Lr(An);try{window.localStorage.setItem(xC,An)}catch{}}},[An]),qt=((Hi=he==null?void 0:he.upgrade)==null?void 0:Hi.state)??"idle",wr=fq(he==null?void 0:he.upgrade),Zs=b.useRef(!1),wi=b.useCallback(async()=>{if(hr(Zs.current||qt==="running")){Zs.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Oe(),Zs.current=!1}},[qt,Oe]);b.useEffect(()=>{if(qt!=="running")return;const q=window.setInterval(Oe,3e3);return()=>window.clearInterval(q)},[qt,Oe]);const no=b.useCallback(async()=>{const q=he==null?void 0:he.command;!q||!await P2(q)||(xt(!0),window.setTimeout(()=>xt(!1),1600))},[he==null?void 0:he.command]),Rn=b.useCallback(()=>{H(q=>(q||Y(!1),!q))},[]),Js=b.useCallback(()=>{Y(q=>(q||H(!1),!q))},[]),[ea,ta]=b.useState(!1),[na,ra]=b.useState(!1),[sa,ro]=b.useState(()=>{try{return Number(localStorage.getItem(z1))||0}catch{return 0}}),[aa,vi]=b.useState([]),[dt,so]=b.useState(!1);b.useEffect(()=>{let q=!0;const z=()=>{fetch("/api/browser-watch?live=0").then(oe=>oe.ok?oe.json():null).then(oe=>{var Ee;!q||!(oe!=null&&oe.ok)||(vi(oe.episodes??[]),so(((Ee=oe.settings)==null?void 0:Ee.enabled)===!0))}).catch(()=>{})};z();const se=setInterval(z,5*6e4);return()=>{q=!1,clearInterval(se)}},[]);const[oa,qr]=b.useState([]),Fr=b.useRef(new Set),[Br,ia]=b.useState(null);b.useEffect(()=>{let q=!0,z=0;const se=()=>{fetch("/api/lan").then(oe=>oe.ok?oe.json():null).then(oe=>q?(oe!=null&&oe.ok&&qr(j1(Array.isArray(oe.pending)?oe.pending:[],oe.aliases)),oe):null).catch(()=>null).then(oe=>{q&&(z=window.setTimeout(se,(oe==null?void 0:oe.enabled)===!0?Iv:M2))})};return se(),()=>{q=!1,window.clearTimeout(z)}},[]);const zr=b.useCallback(async(q,z)=>{if(!Br){ia(q);try{const oe=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:q,fp:z})})).json().catch(()=>null);oe&&Array.isArray(oe.pending)?qr(j1(oe.pending,oe.aliases)):qr(Ee=>Ee.filter(Me=>Me.fp!==z))}catch{}finally{ia(null)}}},[Br]),It=b.useMemo(()=>t8(aa,sa).length,[aa,sa]),[la,cn]=b.useState(0),ac=b.useRef(null),[Wd,oc]=b.useState(!1),vr=b.useRef(null),[ao,hs]=b.useState(0),Xt=b.useState(()=>MF({protect:q=>gL(s.current,q)}))[0],[oo,Hd]=b.useState(!1),ca=b.useCallback(()=>{const q=Xt.paused&&Xt.dropped>0,z=Xt.setPaused(!Xt.paused);q&&yL(s.current);for(const se of z)s.current=Mk(s.current,se);Hd(Xt.paused)},[Xt]),[Et,xi]=b.useState(Date.now()),[rn,io]=b.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(qu)!=="0"}catch{return!0}}),lo=b.useRef(!1),at=b.useCallback(()=>{const q=!rn;lo.current=!0;try{window.localStorage.removeItem(qu)}catch{}io(q),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&io(((se=z.prefs)==null?void 0:se.autoUpdate)!==!1)}).catch(()=>{})},[rn]),[Zn,ua]=b.useState(!1),[bi,ic]=b.useState("restart"),[ki,_i]=b.useState(null),xr=b.useRef(!1),da=b.useRef(null),Jn=b.useRef(0),xn=b.useCallback(async q=>{if(!hr(xr.current))return;const z=(q==null?void 0:q.upgrade)===!0;xr.current=!0,da.current=wr;const se=++Jn.current;ic(z?"npx":"restart"),ua(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(Ce==null?void 0:Ce.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:z})})}catch{}window.setTimeout(()=>{if(Jn.current===se&&xr.current){xr.current=!1,ua(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},z?18e4:3e4)},[Ce==null?void 0:Ce.to,wr]),Mn=b.useRef(null);b.useEffect(()=>{const q=M1(s.current.agents.values())>0,z=wq({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:q,idleSince:Mn.current,now:Et});Mn.current=z.idleSince,z.restart&&xn()},[rn,Ce==null?void 0:Ce.kind,he==null?void 0:he.canRestart,Qn,Et,xn]);const fs=M1(s.current.agents.values()),ps=yq(fs),er=O2({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:fs>0,idleSince:Mn.current,now:Et});b.useEffect(()=>{const q=he==null?void 0:he.running;let z=null,se=null;try{z=window.sessionStorage.getItem("agent-dag.restartPending"),se=window.sessionStorage.getItem(bC)}catch{return}const oe=hq({bundle:"3.22.1",running:q,pending:z,lastTried:se});if(oe==="reload"){try{window.sessionStorage.setItem(bC,q??"")}catch{return}window.location.reload();return}if(oe!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,ua(!1),_i(q??null);const Ee=window.setTimeout(()=>_i(null),6e3);return()=>window.clearTimeout(Ee)},[he==null?void 0:he.running]),b.useEffect(()=>{if(Zn&&pq({asked:da.current,reported:wr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,ua(!1)}},[Zn,wr]);const lc=b.useState(()=>GU(CW()))[0],Qt=b.useRef(lc.pinned),br=b.useRef(null),co=b.useState(()=>TW())[0],[uo,ho]=b.useState(()=>new Set),[ms,cc]=b.useState($F),[un,ha]=b.useState(()=>fC(gC)),Ur=b.useMemo(()=>WU(un),[un]),fo=b.useCallback(q=>UU(q,Ur),[Ur]),Gd=b.useMemo(()=>({background:un["--panel"],border:`1px solid ${un["--line"]}`,borderRadius:8}),[un]),[uc,Ni]=b.useState(!1);b.useEffect(()=>{document.documentElement.dataset.theme=ms;try{window.localStorage.setItem(H2,ms)}catch{}ha(q=>{const z=fC(gC);return HU(q,z)?q:z})},[ms]);const In=b.useCallback((q,z)=>{if(tv({durationMs:z,documentHidden:document.hidden})){e.setViewport(q,{duration:z});return}const{d3Zoom:se,d3Selection:oe}=t.getState(),Ee=oe==null?void 0:oe.property("__zoom");if(se&&oe&&Ee&&Ee.k>0&&q.zoom>0){se.transform(oe,Ee.scale(q.zoom/Ee.k).translate((q.x-Ee.x)/q.zoom,(q.y-Ee.y)/q.zoom));return}e.setViewport(q,{duration:0})},[e,t]),Wr=b.useRef(null);b.useEffect(()=>{if(!co)return;const q=window.setTimeout(()=>{try{In(co,0)}catch{}bn.current=Date.now()},60);return()=>window.clearTimeout(q)},[In,co]);const Si=b.useRef(!0);b.useEffect(()=>{const q=new EventSource("/events"),z=AF(l,{now:()=>Date.now(),setTimeout:(se,oe)=>window.setTimeout(se,oe),clearTimeout:se=>window.clearTimeout(se)});return q.addEventListener("open",()=>{Xe(!0),Ni(!0)}),q.addEventListener("error",()=>Xe(!1)),q.addEventListener("replay-end",()=>{Si.current=!1,z.flush()}),q.addEventListener("hook",se=>{var oe;try{const Ee=JSON.parse(se.data);if(!Xt.accept(Ee))return;s.current=Mk(s.current,Ee);const Me=Ee.replay===!0||Si.current||Date.now()-Ee.receivedAt>3e4;Me?z.replay():z.live();const We=Bq(Ee,Me);We&&((oe=Ye.current)==null||oe.play(We))}catch{}}),()=>{q.close(),z.cancel()}},[l]),b.useEffect(()=>{const q=setInterval(()=>{const z=Date.now();xi(z);let se=wL(s.current,z,Rk);vL(s.current,z,Rk)&&(se=!0),pL(s.current,z,pW,mW)&&(se=!0),mL(s.current,z,gW,yW)&&(se=!0),d(oe=>bF(oe,s.current.agents)),p(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),x(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),_(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),se&&l()},250);return()=>clearInterval(q)},[l]);const $n=b.useRef(null),bn=b.useRef(0),po=420,kn=b.useCallback((q=500)=>{try{const Me=document.querySelector(".canvas-wrap"),We=Array.from(document.querySelectorAll(".react-flow__node")).filter(Ct=>Ct.offsetWidth>0);if(!Me||We.length===0)return;const rt=Me.getBoundingClientRect(),gt=e.getViewport();if(!Number.isFinite(gt.zoom)||gt.zoom<=0)return;const ot=Ct=>(Ct-rt.left-gt.x)/gt.zoom,Qe=Ct=>(Ct-rt.top-gt.y)/gt.zoom,Ns=We.map(Ct=>Ct.getBoundingClientRect()),Ea=Math.min(...Ns.map(Ct=>ot(Ct.left))),Ca=Math.max(...Ns.map(Ct=>ot(Ct.right))),Ki=Math.min(...Ns.map(Ct=>Qe(Ct.top))),Xi=Math.max(...Ns.map(Ct=>Qe(Ct.bottom))),Ss=Ca-Ea,js=Xi-Ki;if(!(Ss>0&&js>0))return;const Pn=Math.max(.2,Math.min(1,(rt.width-160)/(Ss+po)*.86,(rt.height-160)/js*.86)),Es={x:80-Ea*Pn,y:Math.max(80,(rt.height-js*Pn)/2)-Ki*Pn,zoom:Pn};In(Es,q),bn.current=Date.now(),Wr.current=tv({durationMs:q,documentHidden:document.hidden})?{target:Es,until:Date.now()+q+60}:null,window.setTimeout(()=>{var Ct;try{((Ct=Wr.current)==null?void 0:Ct.target)===Es&&(Wr.current=null);const Cc=e.getViewport();(Math.abs(Cc.zoom-Pn)>.01||Math.abs(Cc.x-Es.x)>2)&&In(Es,0)}catch{}},q+60)}catch{}},[e,In]);b.useEffect(()=>{const q=()=>{if(!document.hidden)return;const z=Wr.current;if(Wr.current=null,!(!z||Date.now()>z.until)){try{In(z.target,0)}catch{}bn.current=Date.now()}};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[In]);const gs=b.useRef(""),ys=b.useRef(null),ji=b.useRef(0),Ft=b.useCallback(()=>{ji.current=Date.now()},[]),kr=b.useRef(null),mo=b.useRef(0),Hr=b.useCallback(()=>{mo.current=Date.now()},[]),dc=b.useCallback(q=>({hasSourceEvent:!!q,at:Date.now(),lastDeckFitAt:bn.current,lastCanvasInputAt:mo.current}),[]),fa="agent-dag.autoFitDisabled",go=b.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(fa)==="1"}catch{return!1}})[0],On=b.useRef(go),[pa,Ei]=b.useState(go),Ci=b.useCallback(()=>{if(!On.current){On.current=!0,Ei(!0);try{window.localStorage.setItem(fa,"1")}catch{}}},[]),Vd=b.useCallback(()=>{On.current=!1,Ei(!1);try{window.localStorage.removeItem(fa)}catch{}kn(400)},[e,kn]);b.useEffect(()=>{const q=setInterval(()=>{if(On.current||Date.now()-ji.current<800)return;const z=s.current,se=Date.now(),oe=[];for(const Me of z.agents.values())Lv(Me,se)&&oe.push({id:Me.id});if(oe.length===0)return;const Ee=[];for(const{id:Me}of oe){const We=_r.current.get(Me),rt=Qt.current.get(Me)??sn.current.get(Me);!We||!rt||Ee.push({x:rt.x,y:rt.y,width:We.width,height:We.height})}XU({pane:kr.current,viewport:e.getViewport(),boxes:Ee})&&kn(600)},1500);return()=>clearInterval(q)},[e]);const Ti=b.useRef(!1),_r=b.useRef(new Map),hc=b.useRef(0),Yd=b.useCallback(q=>{const z=_r.current;let se=!1;for(const oe of q.nodeInternals.values()){const Ee=oe.width,Me=oe.height;if(Ee==null||Me==null)continue;const We=z.get(oe.id);We?(Math.abs(We.height-Me)>4||Math.abs(We.width-Ee)>4)&&(z.set(oe.id,{width:Ee,height:Me}),se=!0):(z.set(oe.id,{width:Ee,height:Me}),se=!0)}return se&&(hc.current+=1),hc.current},[]),fc=ct(Yd),[pc,Kd]=b.useState(0);b.useEffect(()=>{let q=0;const z=()=>{const oe=_r.current;let Ee=!1;for(const Me of document.querySelectorAll(".react-flow__node[data-id]")){const We=Me.getAttribute("data-id");if(!We)continue;const rt=Me.offsetWidth,gt=Me.offsetHeight;if(!rt||!gt)continue;const ot=oe.get(We);(!ot||Math.abs(ot.width-rt)>4||Math.abs(ot.height-gt)>4)&&(oe.set(We,{width:rt,height:gt}),Ee=!0)}Ee&&Kd(Me=>Me+1)};if(Ti.current)return;let se=0;return document.visibilityState==="hidden"?se=window.setTimeout(z,32):q=requestAnimationFrame(z),()=>{cancelAnimationFrame(q),window.clearTimeout(se)}});const sn=b.useRef(lc.positions),Xd=b.useRef(new Set),Ai=b.useRef(""),ws=b.useMemo(()=>{const q=[];for(const z of s.current.agents.values())Lv(z,Et)&&q.push(z.id+(z.parentId?`>${z.parentId}`:""));return q.sort(),`${q.join("|")}#sv${fc}.${pc}`},[s.current,s.current.revision,Et,fc,pc]),ma=b.useRef(null);b.useEffect(()=>(ma.current!=null&&window.clearTimeout(ma.current),ma.current=window.setTimeout(()=>{av(sn.current,Qt.current)},1500),()=>{ma.current!=null&&window.clearTimeout(ma.current)}),[ws]),b.useEffect(()=>{if(gs.current===ws)return;const q=gs.current;if(gs.current=ws,!q||On.current)return;Date.now()-bn.current>1200&&kn(400),$n.current&&window.clearTimeout($n.current),$n.current=window.setTimeout(()=>{On.current||kn(500)},280)},[ws,e,kn]);const ga=b.useMemo(()=>NF(s.current,c),[s.current,s.current.revision,c]),Ri=b.useMemo(()=>FU(s.current,Et),[s.current,s.current.revision,Et]),mc=b.useRef(null),[yo,Mi]=b.useState({w:0,h:0});b.useEffect(()=>{const q=mc.current;if(!q||typeof ResizeObserver>"u")return;const z=new ResizeObserver(se=>{var Ee;const oe=(Ee=se[0])==null?void 0:Ee.contentRect;oe&&(kr.current={width:oe.width,height:oe.height},Mi(Me=>Math.abs(Me.w-oe.width)>40||Math.abs(Me.h-oe.height)>40?{w:oe.width,h:oe.height}:Me))});return z.observe(q),kr.current={width:q.clientWidth,height:q.clientHeight},Mi({w:q.clientWidth,h:q.clientHeight}),()=>z.disconnect()},[]);const Qd=b.useCallback(q=>{var se,oe;const z=q.target;!(z!=null&&z.closest)||z.closest(dW)!==q.currentTarget||(q.preventDefault(),(oe=(se=document.activeElement)==null?void 0:se.blur)==null||oe.call(se))},[]),Zd=b.useRef(new Map),[gc,Jd]=b.useState(!1);b.useEffect(()=>{const q=window.setTimeout(()=>Jd(!0),2500);return()=>window.clearTimeout(q)},[]);const[eh,Ii]=b.useState(!1),Nr=b.useRef(null),[ya,vs]=b.useState(!1),[th,yc]=b.useState("full"),$i=b.useRef("full"),wc=b.useCallback(()=>{Nr.current&&(window.clearTimeout(Nr.current),Nr.current=null),Ii(!1)},[]),vc=b.useCallback(q=>{q.length!==0&&queueMicrotask(()=>{Ii(!0),Nr.current&&window.clearTimeout(Nr.current),Nr.current=window.setTimeout(()=>Ii(!1),hW+80)})},[]);b.useEffect(()=>()=>{Nr.current&&window.clearTimeout(Nr.current)},[]);const Oi=yo.w>0?yo.w*.92:0,Gr=yo.h>0?yo.h:0,{nodes:Sr,edges:nh}=b.useMemo(()=>MW(s.current,Et,Oi,Gr,Qt.current,_r.current,Zd.current,vc,gc,ya,sn.current,Xd.current,ws,Ai,c,ga,Ri,N),[s.current,s.current.revision,Et,Oi,Gr,gc,ya,ws,c,ga,Ri,N,la]),xc=b.useMemo(()=>{const q=new Map;for(const se of Sr){const oe=se.data;if(!(oe!=null&&oe.sessionId)||oe.exitAt!=null)continue;const Ee=se.width,Me=se.height;if(Ee==null||Me==null)continue;const We=se.position.x,rt=se.position.y,gt=We+Ee,ot=rt+Me,Qe=q.get(oe.sessionId);Qe?(Qe.minX=Math.min(Qe.minX,We),Qe.minY=Math.min(Qe.minY,rt),Qe.maxX=Math.max(Qe.maxX,gt),Qe.maxY=Math.max(Qe.maxY,ot)):q.set(oe.sessionId,{minX:We,minY:rt,maxX:gt,maxY:ot})}const z=[];for(const[se,oe]of q){const Ee=oe.maxX-oe.minX+Du*2,Me=oe.maxY-oe.minY+Du*2;z.push({id:`group:${se}`,type:YA,position:{x:oe.minX-Du,y:oe.minY-Du},data:{sessionId:se,w:Ee,h:Me},width:Ee,height:Me,style:{width:Ee,height:Me},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return z},[Sr,Et]),bc=b.useMemo(()=>{const q=[...xc,...Sr],z=vr.current;return!z||z.size===0?q:q.map(se=>{const oe=z.get(se.id);return oe?{...se,position:oe}:se})},[xc,Sr,ao]),wa=b.useMemo(()=>{const q=new Set;for(const z of s.current.agents.values())for(const se of z.tools)q.add(rR(se.name));return Object.keys(qv).filter(z=>q.has(z))},[s.current,s.current.revision]);b.useEffect(()=>{if(wa.length<=1){oc(!1);return}let q=0;const z=()=>{const se=ac.current;if(se&&!document.hidden){const oe=se.getBoundingClientRect(),Ee=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(We=>We.getBoundingClientRect()),Me=zU(oe,Ee,8);oc(We=>We===Me?We:Me)}q=window.setTimeout(z,300)};return z(),()=>window.clearTimeout(q)},[wa.length]);const va=b.useCallback(q=>{ho(z=>{const se=new Set(z);return se.has(q)?se.delete(q):se.add(q),se})},[]),$t=h?s.current.agents.get(h):null,Pi=f?Array.from(s.current.agents.values()).flatMap(q=>q.tools).find(q=>q.id===f)??null:null,xa=b.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=kv(),Qt.current.clear(),_r.current.clear(),sn.current.clear(),Ai.current="",_C(),v(),l()},[l,v]),kc=b.useRef(E);kc.current=E;const Li=b.useRef(R);Li.current=R;const ba=b.useRef(!1);ba.current=Pi!=null||ea||j!=null||$||S!=null||na||R||lt!=null;const xs=b.useCallback(q=>{const z=vq(q,{confirmOpen:kc.current,modalOpen:ba.current});z==="confirm"?C(!0):z==="clear"&&(C(!1),xa())},[xa]),wo=b.useCallback(()=>{Qt.current.clear(),sn.current.clear(),Ai.current="",_C(),l(),window.setTimeout(()=>kn(500),80)},[l,e,kn]),Di=b.useCallback(()=>kn(500),[kn]),ka=b.useRef(Sr);ka.current=Sr;const _c=b.useRef(h);_c.current=h;const qi=b.useCallback(q=>{const z=ka.current,se=gF(z.map(Me=>({id:Me.id,x:Me.position.x,y:Me.position.y})),_c.current,q),oe=se?z.find(Me=>Me.id===se):void 0;if(!oe)return;const Ee=yC(document.activeElement);y(oe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[oe]})}catch{}bn.current=Date.now(),Ee&&uW(oe.id)},30)},[y,e]),Fi=b.useCallback(q=>{y(q,!1),window.setTimeout(()=>{try{const z=ka.current.find(se=>se.id===q);z&&e.fitView({padding:.3,duration:500,nodes:[z]}),bn.current=Date.now()}catch{}},60)},[y,e]);b.useEffect(()=>{const q=z=>{var rt,gt;const se=z.target,oe={tagName:se==null?void 0:se.tagName,isContentEditable:se==null?void 0:se.isContentEditable,role:(rt=se==null?void 0:se.getAttribute)==null?void 0:rt.call(se,"role"),type:se==null?void 0:se.type};if(z.key==="Escape"){const ot=VL({overlayOpen:ad.depth()>0,typing:dx(oe)});ot==="dismiss"?ad.dismissTop():ot==="blur"?se==null||se.blur():(xF(oe)&&(se==null||se.blur()),v());return}if(ux(z))return;const Ee=yC(se)?(gt=se==null?void 0:se.getAttribute)==null?void 0:gt.call(se,"data-id"):null,Me=Ee&&ka.current.some(ot=>ot.id===Ee)?Ee:null,We=wF(z,Me);if(We.kind==="activate"){z.preventDefault(),y(We.nodeId,We.additive);return}We.kind!=="node"&&(We.nodeId==null&&t4(oe)||n4({key:z.key,modalOpen:ba.current,sheetOpen:Li.current})||(z.key===" "&&(z.preventDefault(),ca()),(z.key==="c"||z.key==="C")&&xs("shortcut"),(z.key==="r"||z.key==="R")&&wo(),(z.key==="f"||z.key==="F")&&Di(),(z.key==="l"||z.key==="L")&&Rn(),(z.key==="d"||z.key==="D")&&A(ot=>!ot),(z.key==="h"||z.key==="H")&&ta(ot=>!ot),(z.key==="u"||z.key==="U")&&K(ot=>!ot),(z.key==="a"||z.key==="A")&&us.current.claude&&Js(),(z.key==="j"||z.key==="J")&&qi(1),(z.key==="k"||z.key==="K")&&qi(-1),(z.key==="t"||z.key==="T")&&cc(ot=>ot==="dark"?"light":"dark"),(z.key==="m"||z.key==="M")&&us.current.claude&&pe.current!==null&&ie.current(z.shiftKey),z.key==="?"&&I(ot=>!ot)))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[xs,wo,Di,v,y,qi,ca]);const Nc=s.current.agents.size,Zt=b.useMemo(()=>qL(s.current.agents.values()),[s.current,s.current.revision]),dn=b.useMemo(()=>FL(s.current.agents.values()),[s.current,s.current.revision]),bs=b.useRef(null);b.useEffect(()=>{const q=OF({waiting:Zt.length,running:dn,connected:He}),z=bs.current;if(bs.current=q,(z==null?void 0:z.title)!==q.title&&(document.title=q.title),(z==null?void 0:z.icon)!==q.icon){const se=document.querySelector('link[rel="icon"]');se&&(se.href=PF[q.icon])}},[Zt.length,dn,He]);const[Sc,jc]=b.useState(""),Bi=DF(Zt);b.useEffect(()=>{jc(q=>qF(q,Bi))},[Bi]);const[_a,zi]=b.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Vr,Ui]=b.useState(null),[tr,Na]=b.useState(!0),[Sa,vo]=b.useState(!1);b.useEffect(()=>{let q=!0;return fetch("/api/prefs").then(z=>z.ok?z.json():null).then(z=>{var se,oe,Ee;if(!(!q||!(z!=null&&z.ok))){if(!lo.current){let Me=!1;try{Me=window.localStorage.getItem(qu)==="0",window.localStorage.removeItem(qu)}catch{}Me&&((se=z.prefs)==null?void 0:se.autoUpdate)!==!1?(io(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):io(((oe=z.prefs)==null?void 0:oe.autoUpdate)!==!1)}Na(((Ee=z.prefs)==null?void 0:Ee.notifications)!==!1),vo(z.notificationsVetoed===!0)}}).catch(()=>{}),()=>{q=!1}},[]);const Wi=b.useRef(()=>{}),xo=b.useCallback(()=>{const q=!tr;Na(q),q&&typeof Notification<"u"&&Notification.permission==="default"&&Wi.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&(Na(((se=z.prefs)==null?void 0:se.notifications)!==!1),vo(z.notificationsVetoed===!0))}).catch(()=>{})},[tr]),ks=typeof Notification<"u";b.useEffect(()=>{if(!Vr)return;const z=setTimeout(()=>Ui(null),Vr==="blocked"?8e3:4e3);return()=>clearTimeout(z)},[Vr]);const bo=b.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(q=>{const z=q;zi(z),z==="granted"?Ui("on"):z==="denied"&&Ui("blocked")})},[]);Wi.current=bo;const ja=b.useRef(new Set),_s=b.useRef(null),Ec=Zt.map(q=>kd(q.id,q.waiting)).join("|");return b.useEffect(()=>{WL(_s.current,_a)&&(_s.current=_a,ja.current=Ok(Zt))},[_a]),b.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||_s.current===null)return;const q=typeof document>"u"||!document.hidden,z=zL(Zt,ja.current,q,tr);for(const se of z)try{const oe=new Notification(se.title,{body:se.body,tag:se.key});oe.onclick=()=>{window.focus(),Fi(se.sessionId),oe.close()}}catch{}ja.current=q?Ok(Zt):UL(Zt,z,ja.current)},[Ec]),i.jsxs("div",{className:"app",children:[i.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),i.jsxs("header",{className:"topbar",children:[i.jsxs("div",{className:"readout",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"logo"}),i.jsx("h1",{children:Wt}),Ce?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{bt(),to()},"aria-haspopup":"dialog","aria-label":eW({...Ce,open:Qn}),title:Ce.kind==="restart"?`Running v${Ce.from}; v${Ce.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${Ce.from}; v${Ce.to} is on npm · click for what's new`,children:["v",Ce.from,i.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const q={running:mt,latest:he==null?void 0:he.latest,latestPending:he==null?void 0:he.latestPending,checkedAgo:he!=null&&he.checkedAt?Cv(Et-he.checkedAt):null,checkDisabled:he==null?void 0:he.checkDisabled,checking:ne};return i.jsxs("button",{type:"button",className:ne?"v checking":"v",onClick:()=>{bt(),Oe(!0)},"aria-busy":ne||void 0,"aria-haspopup":"dialog","aria-label":JU(q),title:ZU(q),children:["v",q.running]})})()]}),i.jsx("span",{className:"status",children:(()=>{const q=lW({connected:He,paused:oo,held:Xt.size,dropped:Xt.dropped});return q.resting?null:i.jsx("span",{className:`pill ${q.tone}`,title:q.title,children:i.jsxs("span",{className:"pill-box",children:[i.jsx("span",{className:"pill-widest","aria-hidden":!0,children:q.widest}),i.jsx("span",{className:"pill-label",children:q.label})]})})})()}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Sc}),Zt.length>0&&i.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Fi(Zt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
263
+ Click to set the volume and the sound of each tone, and to hear either one.`}function G2(e){const t=new Map;for(const n of e)for(const s of n.agents??[]){if(!s||typeof s.agent!="string"||s.agent==="")continue;const a=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};a.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,a.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,a)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function VF(e){const t=G2([{agents:e}]);return t.length<2?null:t.map(n=>`${_x(n.id)} ${tt(n.cost)}`).join(" · ")}function F1(e){switch(e.toLowerCase()){case"claude":return"var(--usage-purple)";case"codex":return"var(--usage-orange)";case"gemini":return"var(--usage-indigo)";case"copilot":return"var(--usage-green)";default:return"var(--usage-zinc)"}}function YF(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Ou(e){const t=e.toLowerCase();return t.includes("opus")?"var(--usage-purple)":t.includes("sonnet")?"var(--usage-blue)":t.includes("haiku")?"var(--usage-green)":t.includes("gpt-5")||t.includes("gpt5")?"var(--usage-amber)":t.includes("gpt")?"var(--usage-red)":t.includes("gemini")?"var(--usage-indigo)":t.includes("codex")?"var(--usage-orange)":"var(--usage-zinc)"}const KF=[7,14,30,90];function XF(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useState(FF)[0],c=b.useRef(!1),d=(h=!1)=>{if(h&&!hr(c.current))return;const p=l.begin();c.current=h;const f=e;a(!0);const y=`/api/ccusage?since=${Ev(f)}${h?"&refresh=1":""}`;fetch(y).then(v=>v.json()).then(v=>{p()&&n({range:f,resp:v})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(c.current=!1,a(!1))})};return b.useEffect(()=>(d(!1),()=>l.cancel()),[e]),{landed:t,loading:s,reload:()=>d(!0)}}function QF({onClose:e,providers:t}){var B;const[n,s]=b.useState(30),[a,l]=b.useState(null),{landed:c,loading:d,reload:h}=XF(n),p=b.useRef(null),f=Ht(e,{focusRef:p}),m=BF({loading:d,want:n,answer:c&&{range:c.range,ok:c.resp.ok===!0,days:((B=c.resp.days)==null?void 0:B.length)??0}}),y=m.phase==="chart"?c.resp.days??[]:[],v=b.useMemo(()=>y.reduce((O,M)=>Math.max(O,M.totalCost),0),[y]),S=b.useRef(null);b.useLayoutEffect(()=>{const O=S.current;O&&(O.scrollLeft=O.scrollWidth)},[y]);const{totalCost:_,totalTok:j,inOut:x,cacheRead:N,modelCosts:E}=b.useMemo(()=>{let O=0,M=0,L=0,H=0;const F=new Map;for(const A of y){O+=A.totalCost,M+=A.totalTokens,L+=A.inputTokens+A.outputTokens,H+=A.cacheReadTokens;for(const Q of A.modelBreakdowns)F.set(Q.modelName,(F.get(Q.modelName)??0)+Q.cost)}return{totalCost:O,totalTok:M,inOut:L,cacheRead:H,modelCosts:F}},[y]),C=b.useMemo(()=>Array.from(E.entries()).sort((O,M)=>M[1]-O[1]),[E]),R=b.useMemo(()=>G2(y),[y]),I=R.length>1,$=a?y.find(O=>O.period===a)??null:null;return i.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:f,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[i.jsxs("header",{className:"uh-head",children:[i.jsxs("div",{className:"uh-titlewrap",children:[i.jsx("div",{className:"uh-title",children:"Usage history"}),i.jsx("div",{className:"uh-sub",children:WF(t,R.map(O=>O.id))})]}),i.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:KF.map(O=>i.jsxs("button",{type:"button","aria-pressed":n===O,className:"uh-range-btn",onClick:()=>{s(O),l(null)},children:[O,"d"]},O))}),i.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...dr(d),title:"Re-run ccusage","aria-label":"Reload",children:d?"…":"↻"}),i.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),m.phase==="busy"?i.jsxs("div",{className:"uh-status uh-status-wait","aria-busy":"true",children:[i.jsx("span",{className:"uh-wait-word",children:c?"running ccusage…":"running ccusage… (first run downloads the package)"}),i.jsx("span",{className:"uh-wait-axis","aria-hidden":!0})]}):m.phase==="error"?i.jsxs("div",{className:"uh-status uh-err",title:oi(c.resp)||void 0,children:[GD(c.resp,"ccusage did not report usage"),i.jsx("div",{children:i.jsx("button",{className:"btn uh-retry",onClick:h,...dr(d),children:d?"trying…":"Try again"})})]}):m.phase==="empty"?i.jsx("div",{className:`uh-status${m.stale?" uh-stale":""}`,"aria-busy":m.stale||void 0,children:"no usage in this range"}):i.jsxs("div",{className:m.stale?"uh-stale":void 0,"aria-busy":m.stale||void 0,children:[i.jsxs("div",{className:"uh-totals",children:[i.jsx(Pu,{label:"total cost",val:tt(_),accent:!0}),i.jsx(Pu,{label:"tokens",val:At(j)}),i.jsx(Pu,{label:"input+output",val:At(x)}),i.jsx(Pu,{label:"cache reads",val:At(N)})]}),I&&i.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[i.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:R.map(O=>i.jsx("span",{className:"uh-agent-seg",style:{width:`${_>0?O.cost/_*100:0}%`,background:F1(O.id)}},O.id))}),i.jsx("div",{className:"uh-agent-keys",children:R.map(O=>i.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${At(O.tokens)} tokens`,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:F1(O.id)}}),_x(O.id),i.jsx("span",{className:"uh-agent-cost",children:tt(O.cost)}),i.jsx("span",{className:"uh-agent-share",children:YF(O.cost,_)})]},O.id))})]}),i.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map((O,M)=>{const L=v>0?O.totalCost/v*100:0,H=O.period===a,F=`${O.period}, ${tt(O.totalCost)}`;return i.jsxs("button",{className:`uh-bar-col${H?" sel":""}`,onClick:()=>l(H?null:O.period),"aria-pressed":H,"aria-label":F,title:`${O.period} · ${tt(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`,"--uh-i":M,"--uh-step":`${Math.min(10,200/Math.max(y.length,1))}ms`},children:[i.jsx("div",{className:"uh-bar",style:{height:`${Math.max(L,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((A,Q)=>Q.cost-A.cost).map(A=>{const Q=O.totalCost>0?A.cost/O.totalCost*100:0;return i.jsx("div",{className:"uh-bar-seg",style:{height:`${Q}%`,background:Ou(A.modelName)}},A.modelName)})}),i.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),i.jsx("div",{className:"uh-legend",children:C.map(([O,M])=>i.jsxs("span",{className:"uh-legend-item",title:O,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Ou(O)}}),Ys(O)," ",i.jsx("span",{className:"uh-legend-cost",children:tt(M)})]},O))}),$&&i.jsxs("div",{className:"uh-detail",children:[i.jsxs("div",{className:"uh-detail-head",children:[i.jsx("span",{className:"uh-detail-date",children:$.period}),i.jsx("span",{className:"uh-detail-cost",children:tt($.totalCost)}),(()=>{var L,H;const M=VF($.agents)??((H=(L=$.metadata)==null?void 0:L.agents)!=null&&H.length?$.metadata.agents.join(" · "):null);return M?i.jsx("span",{className:"uh-detail-agents",title:M,children:M}):null})()]}),i.jsxs("div",{className:"uh-detail-mini",children:[i.jsx(Lu,{label:"input",val:At($.inputTokens)}),i.jsx(Lu,{label:"output",val:At($.outputTokens)}),i.jsx(Lu,{label:"cache write",val:At($.cacheCreationTokens)}),i.jsx(Lu,{label:"cache read",val:At($.cacheReadTokens)})]}),i.jsx("div",{className:"uh-detail-models",children:$.modelBreakdowns.slice().sort((O,M)=>M.cost-O.cost).map(O=>{const M=$.totalCost>0?O.cost/$.totalCost*100:0;return i.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[i.jsxs("span",{className:"uh-model-name",children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Ou(O.modelName)}}),i.jsx("span",{className:"uh-model-label",children:Ys(O.modelName)})]}),i.jsx("span",{className:"uh-model-bar",children:i.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Ou(O.modelName)}})}),i.jsx("span",{className:"uh-model-cost",children:tt(O.cost)})]},O.modelName)})})]})]})]})})}function Pu({label:e,val:t,accent:n}){return i.jsxs("div",{className:"uh-stat",children:[i.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),i.jsx("span",{className:"uh-stat-label",children:e})]})}function Lu({label:e,val:t}){return i.jsxs("div",{className:"uh-ministat",children:[i.jsx("span",{className:"uh-ministat-val",children:t}),i.jsx("span",{className:"uh-ministat-label",children:e})]})}function ZF(e){const t=/^#?([0-9a-f]{6})$/i.exec((e??"").trim());if(!t)return!1;const n=parseInt(t[1],16),s=[n>>16&255,n>>8&255,n&255].map(a=>{const l=a/255;return l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const B1=1e4,JF=12e3;function e8({browsers:e,findings:t,watching:n,palette:s,now:a=()=>Date.now()}){const l=b.useRef(null),c=b.useRef(null);return c.current={browsers:e,findings:t,watching:n},b.useEffect(()=>{var v;const d=l.current;if(!d)return;const h=d.getContext("2d");if(!h)return;const p=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,m=!1;const y=()=>{var ee;if(m)return;const S=c.current;if(!S)return;const{browsers:_,findings:j,watching:x}=S,N=s["--accent"]||"#7dd3fc",E=s["--line"]||"#1f2229",C=s["--text-dim"]||"#6e727c",R=ZF(s["--bg"]),I=R?42:26,$=R?.85:.65,B=a(),O=Math.min(window.devicePixelRatio||1,2),M=d.clientWidth,L=d.clientHeight;(d.width!==M*O||d.height!==L*O)&&(d.width=M*O,d.height=L*O),h.setTransform(O,0,0,O,0,0),h.clearRect(0,0,M,L);const H=M/2,F=L/2,A=Math.min(M,L)/2-6;h.strokeStyle=E,h.lineWidth=1,h.globalAlpha=R?1:.9;for(const Z of[.4,.7,1])h.beginPath(),h.arc(H,F,A*Z,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(H-A,F),h.lineTo(H+A,F),h.moveTo(H,F-A),h.lineTo(H,F+A),h.stroke(),h.globalAlpha=1;const K=(x&&!p?B%B1/B1:0)*Math.PI*2-Math.PI/2;if(x){const Z=(ee=h.createConicGradient)==null?void 0:ee.call(h,K-.85,H,F);Z&&(Z.addColorStop(0,"transparent"),Z.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${I}%, transparent)`),Z.addColorStop(1,"transparent"),h.fillStyle=Z,h.beginPath(),h.moveTo(H,F),h.arc(H,F,A,K-.85,K),h.closePath(),h.fill()),h.strokeStyle=N,h.globalAlpha=$,h.beginPath(),h.moveTo(H,F),h.lineTo(H+Math.cos(K)*A,F+Math.sin(K)*A),h.stroke(),h.globalAlpha=1}_.forEach((Z,D)=>{const Y=D/Math.max(_.length,1)*Math.PI*2-Math.PI/2,P=Z.lastReadMs===null?1:Math.min(1,(B-Z.lastReadMs)/12e4),G=A*(.42+P*.5),de=H+Math.cos(Y)*G,W=F+Math.sin(Y)*G,U=Math.abs((K-Y+Math.PI*3)%(Math.PI*2)-Math.PI),J=x?Math.max(0,1-U/.55):0;h.beginPath(),h.arc(de,W,3+J*1.6,0,Math.PI*2),h.fillStyle=Z.running?N:C,h.globalAlpha=Z.running?.55+J*.45:.35,h.fill(),h.globalAlpha=1});for(const Z of j){const D=(B-Z.atMs)/JF;if(D<0||D>1)continue;const P=Math.max(0,_.findIndex(W=>W.key===Z.browser))/Math.max(_.length,1)*Math.PI*2-Math.PI/2,G=H+Math.cos(P)*A*.6,de=F+Math.sin(P)*A*.6;h.beginPath(),h.arc(G,de,4+D*22,0,Math.PI*2),h.strokeStyle=N,h.globalAlpha=(1-D)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(y)};return y(),()=>{m=!0,cancelAnimationFrame(f)}},[a,s]),i.jsx("canvas",{ref:l,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const z1="agent-dag.browserWatch.seenMs";function t8(e,t){return e.filter(n=>n.startMs>t)}function n8(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function r8(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function V2(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function U1(e,t){return t?{kind:"saving",word:"Saving",detail:""}:e.settings.enabled?{kind:"on",word:"Watching",detail:""}:{kind:"off",word:"Paused",detail:"nothing new is recorded"}}function s8(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,a)=>s+a.programVisits,0)}))}function a8(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function o8(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],a=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(a>0?`, and ${a} more`:"")+". The watch continues on the profiles it can read."}}const n=V2(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(s=>s.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}function i8(e){const t=n=>new Date(n).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.count===1||e.endMs-e.startMs<6e4?t(e.startMs):`${t(e.startMs)} → ${t(e.endMs)}`}function l8(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function W1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function c8({onClose:e,onSeen:t,onWatching:n,palette:s}){const a=Ht(e),[l,c]=b.useState(null),[d,h]=b.useState(null),[p,f]=b.useState(null),[m,y]=b.useState(!1),v=b.useRef(!1),[S,_]=b.useState(null),[j,x]=b.useState(null),[N,E]=b.useState(!1),C=b.useRef(!1),[R,I]=b.useState(!1),[$,B]=b.useState(!1),[O,M]=b.useState(!1),[L,H]=b.useState(!1),[F,A]=b.useState(!1),[Q,K]=b.useState(()=>Date.now());b.useEffect(()=>{const V=setInterval(()=>K(Date.now()),1e3);return()=>clearInterval(V)},[]);const ee=b.useCallback(async V=>{var ie,pe;if(!(V&&!hr(v.current))){v.current=V,y(!0);try{const me=await fetch(`/api/browser-watch${V?"?refresh=1":""}`);if(!me.ok)throw new Error(`the deck answered ${me.status}`);const Ie=await me.json();c(Ie),C.current||_(((ie=Ie==null?void 0:Ie.settings)==null?void 0:ie.quietMinutes)??15),n(((pe=Ie==null?void 0:Ie.settings)==null?void 0:pe.enabled)===!0),h(null)}catch(me){h(me instanceof Error?me.message:String(me))}finally{v.current=!1,y(!1)}}},[n]);b.useEffect(()=>{ee(!1)},[ee]),b.useEffect(()=>{const V=setInterval(()=>{ee(!1)},1e4);return()=>clearInterval(V)},[ee]);const Z=b.useCallback(async V=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:V.host,startMs:V.startMs})})}finally{await ee(!1)}},[ee]),D=b.useCallback(async V=>{C.current=!0,E(!0);try{const ie=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V)});if(!ie.ok)throw new Error(`the deck answered ${ie.status}`);await ee(!1),f(null)}catch(ie){f(ie instanceof Error?ie.message:String(ie))}finally{C.current=!1,E(!1)}},[ee]),Y=b.useRef(t);Y.current=t,b.useEffect(()=>()=>Y.current(Date.now()),[]);const P=b.useMemo(()=>{const V=[];for(const ie of(l==null?void 0:l.episodes)??[]){const pe=l8(ie.startMs),me=V[V.length-1];me&&me.label===pe?me.episodes.push(ie):V.push({label:pe,episodes:[ie]})}return V},[l]),G=V2(l==null?void 0:l.browsers),de=((l==null?void 0:l.browsers)??[]).filter(V=>!(V.installed&&V.profiles>0)),W=l?o8(l):null,U=G.reduce((V,ie)=>V+ie.profiles,0),J=l?n8(l.coverage.lastHumanMs,l.coverage.quietMs,Q):null;return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal bw-modal",onClick:V=>V.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),i.jsx("span",{className:"modal-tool-id",children:l?`${U} ${U===1?"profile":"profiles"} · local only`:"local only"})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("button",{className:"glyph-btn",onClick:()=>void ee(!0),...dr(m),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:m?"…":"↻"}),i.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("div",{className:"modal-body bw-body",children:[!l&&!d&&i.jsxs("div",{className:"bw-loading",children:[i.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),i.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),d&&i.jsx("div",{className:"bw-state",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not read"}),i.jsx("span",{className:"bw-row-detail",children:d})]})}),l&&W&&i.jsx("p",{className:`bw-trouble ${W.kind}`,role:"status",children:W.text}),l&&i.jsxs("div",{className:"bw-work",children:[i.jsxs("aside",{className:"bw-side",children:[i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",i.jsx("button",{className:"bw-help",onClick:()=>M(V=>!V),"aria-expanded":O,"aria-label":"What the sweep and the dots mean",children:"?"})]}),i.jsxs("div",{className:"bw-glance",children:[i.jsx(e8,{browsers:G.map(V=>{var ie;return{key:V.key,name:V.name,running:V.running,lastReadMs:((ie=l.profiles.find(pe=>pe.browser===V.key))==null?void 0:ie.lastWrittenMs)??null}}),findings:l.episodes.slice(0,6).map(V=>({browser:V.browser??null,atMs:V.endMs})),watching:l.settings.enabled,palette:s}),i.jsx("ul",{className:"bw-counts",children:s8(G,l.profiles).map(V=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-count-n",children:V.visits.toLocaleString("en-US")}),i.jsx("span",{className:"bw-count-of",children:V.name})]},V.key))})]}),i.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),l.coverage.checkedMs>0&&i.jsxs("p",{className:"bw-since",children:["Last checked ",a8(l.coverage.checkedMs,Q),l.coverage.checks>0&&i.jsxs(i.Fragment,{children:[" · ",l.coverage.checks.toLocaleString("en-US")," ",l.coverage.checks===1?"check":"checks"]})]}),J!==null&&i.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",r8(J)]}),O&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Sweep"}),i.jsx("dd",{children:"one poll of every watched profile"}),i.jsx("dt",{children:"Dot"}),i.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),i.jsx("dt",{children:"Ring"}),i.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",i.jsx("button",{className:"bw-help",onClick:()=>H(V=>!V),"aria-expanded":L,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),L&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Running"}),i.jsx("dd",{children:"the browser has a process on this machine right now"}),i.jsx("dt",{children:"Connected"}),i.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),i.jsx("ul",{className:"bw-profiles",children:G.map(V=>i.jsxs("li",{children:[i.jsx("span",{className:`bw-prof-dot${V.running?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-prof-name",children:V.name}),i.jsx("span",{className:"bw-prof-state",children:V.running?"running":"idle"}),V.running&&V.relay.state==="live"&&i.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},V.key))}),de.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>A(V=>!V),"aria-expanded":F,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:F?"▾":"▸"})," ",de.length," not watched"]}),F&&i.jsxs("p",{className:"bw-rest",children:[de.map(V=>V.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]}),l.relay&&i.jsx(u8,{relay:l.relay})]}),i.jsxs("div",{className:"bw-main",children:[i.jsxs("section",{className:"bw-findings",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",l.episodes.length>0&&i.jsxs("span",{className:"bw-feed-count",children:[l.episodes.length," ",l.episodes.length===1?"episode":"episodes"]})]}),i.jsx("div",{className:"bw-eps",children:P.length===0?i.jsxs("div",{className:"bw-empty",children:[i.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),i.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",l.settings.quietMinutes," ",l.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!l.settings.enabled&&i.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):P.map(V=>i.jsxs("div",{className:"bw-day",children:[i.jsx("h4",{className:"bw-sec-head",children:V.label}),V.episodes.map(ie=>{const pe=`${ie.host}-${ie.startMs}`,me=j===pe;return i.jsxs("div",{className:`bw-ep${me?" open":""}`,children:[i.jsxs("div",{className:"bw-ep-row",children:[i.jsxs("button",{className:"bw-ep-head",onClick:()=>x(me?null:pe),"aria-expanded":me,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:me?"▾":"▸"}),i.jsx("span",{className:"bw-ep-host",children:ie.host}),i.jsxs("span",{className:"bw-ep-meta",children:[i8(ie),W1(ie)&&i.jsxs(i.Fragment,{children:[" · ",W1(ie)]})]}),i.jsxs("span",{className:"bw-ep-count",children:[ie.count," ",ie.count===1?"page":"pages"]})]}),i.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Z(ie),"aria-label":`Dismiss ${ie.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),me&&i.jsx("ul",{className:"bw-urls",children:ie.urls.map((Ie,Le)=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-url-time",children:new Date(Ie.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),i.jsx("span",{className:"bw-url",children:Ie.url})]},`${Ie.url}-${Ie.timeMs}-${Le}`))})]},pe)})]},V.label))})]}),i.jsxs("section",{className:"bw-feed",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",i.jsxs("span",{className:"bw-feed-count",children:[l.log.length," ",l.log.length===1?"event":"events"]})]}),i.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),i.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:l.log.length===0?i.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):l.log.map(V=>i.jsxs("div",{className:`bw-log-line ${V.level}${V.parts?"":" sys"}`,children:[i.jsx("span",{className:"bw-log-time",children:new Date(V.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),V.parts?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"bw-log-browser",children:V.parts.browser}),i.jsx("span",{className:"bw-log-profile",title:V.parts.profile,children:V.parts.profile}),i.jsxs("span",{className:"bw-log-value",children:[V.parts.value,V.parts.flagged>0&&i.jsxs("span",{className:"bw-log-flag",children:[" · ",V.parts.flagged," flagged"]})]})]}):i.jsx("span",{className:"bw-log-sys",children:V.text})]},`${V.atMs}-${V.level}-${V.text}`))})]})]})]}),l&&R&&i.jsxs("div",{className:"bw-settings",children:[i.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[i.jsx("span",{children:"Nobody browsing for"}),i.jsxs("select",{value:S??l.settings.quietMinutes,onChange:V=>{_(Number(V.target.value)),D({quietMinutes:Number(V.target.value)})},children:[i.jsx("option",{value:1,children:"1 min"}),i.jsx("option",{value:5,children:"5 min"}),i.jsx("option",{value:15,children:"15 min"}),i.jsx("option",{value:30,children:"30 min"}),i.jsx("option",{value:60,children:"60 min"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"When it finds one"}),i.jsx("select",{value:l.settings.reaction,onChange:V=>void D({reaction:V.target.value}),disabled:!l.settings.enabled,title:l.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(l.reactions??["notify"]).map(V=>i.jsx("option",{value:V,children:V==="notify"?"notify me":V==="close-tab"?"close the tab":"quit the browser"},V))})]}),i.jsxs("div",{className:"bw-settings-note",children:[i.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",i.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),i.jsxs("button",{className:"bw-why",onClick:()=>B(V=>!V),"aria-expanded":$,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:$?"▾":"▸"})," What Browser Watch can access"]}),$&&i.jsxs("dl",{className:"bw-access",children:[i.jsx("dt",{children:"Reads"}),i.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(l.coverage.startedMs).toLocaleString(),"."]}),i.jsx("dt",{children:"Keeps"}),i.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",i.jsx("code",{className:"bw-path",children:l.coverage.logPath}),", with every address written in full so you can check it yourself."]}),i.jsx("dt",{children:"Sends"}),i.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),i.jsx("dt",{children:"Never reads"}),i.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),p&&i.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not save that setting"}),i.jsxs("span",{className:"bw-row-detail",children:[p," — the switches below show what is stored, not what you pressed."]}),i.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>f(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),l&&i.jsxs("footer",{className:"bw-status",children:[i.jsx("span",{className:`bw-mode-dot${l.settings.enabled?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-mode-word",children:U1(l,N).word},U1(l,N).kind),i.jsx("span",{className:"bw-status-text",children:l.coverage.archived===0?l.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${l.coverage.archived} ${l.coverage.archived===1?"episode":"episodes"} on disk`}),i.jsx("button",{className:`glyph-btn bw-gear${R?" on":""}`,onClick:()=>I(V=>!V),"aria-expanded":R,"aria-label":"Settings",title:"Settings",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[i.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),i.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),i.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[i.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),i.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":l.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void D({enabled:!l.settings.enabled}),title:l.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:i.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function u8({relay:e}){const[t,n]=b.useState(!1),[s,a]=b.useState(!1),l=e.killswitch.blocked?"unblock":"block",c=e.command[l],d=b.useCallback(async()=>{await P2(c.command)&&(a(!0),window.setTimeout(()=>a(!1),1600))},[c.command]),h=e.profiles.filter(f=>{var m;return(m=f.report)==null?void 0:m.present}),p=e.profiles.filter(f=>f.report===null);return i.jsxs("section",{className:"bw-sec",children:[i.jsx("h4",{className:"bw-sec-head",children:"Remote control"}),i.jsx("p",{className:`bw-rc-verdict ${e.verdict}`,role:"status",children:e.verdict==="exposed"?"Claude in Chrome is live here, so any Claude Code session signed in to your Anthropic account can drive this browser — from any machine, with no prompt on this one.":e.verdict==="protected"?`The relay is black-holed in ${e.hostsPath}, so no new connection to it can be made from this machine.`:"Claude in Chrome is not installed and enabled in any profile here, so there is nothing for the relay to drive."}),e.killswitch.foreign.length>0&&i.jsxs("p",{className:"bw-rc-foreign",children:["Another entry for this host is already in ",e.hostsPath,", and ccdeck will not touch it:",e.killswitch.foreign.map(f=>i.jsx("code",{className:"bw-path",children:f},f))]}),i.jsxs("button",{className:"bw-why",onClick:()=>n(f=>!f),"aria-expanded":t,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",e.verdict==="protected"?"How to undo the block":"What it can reach, and how to stop it"]}),t&&i.jsxs("div",{className:"bw-rc-body",children:[h.length>0&&i.jsx("dl",{className:"bw-key",children:h.map(f=>i.jsxs(b.Fragment,{children:[i.jsxs("dt",{children:[f.name,f.profile==="Default"?"":` · ${f.profile}`]}),i.jsxs("dd",{children:[f.report.enabled?"enabled":"installed but switched off",f.report.allUrls?", can act on every site":", limited to the sites it was granted",f.report.sensitiveApis.length>0&&i.jsxs(i.Fragment,{children:[" — ",f.report.sensitiveApis.join(", ")]})]})]},`${f.browser}/${f.profile}`))}),p.length>0&&i.jsxs("p",{className:"bw-rc-note",children:[p.map(f=>f.name).join(", ")," — its settings file could not be read, so nothing is claimed about it either way."]}),!e.hostsRead&&i.jsxs("p",{className:"bw-rc-note",children:[e.hostsPath," could not be read, so whether the relay is already blocked is unknown."]}),h.some(f=>f.report.allUrls)&&i.jsxs("p",{className:"bw-rc-note",children:["Narrowing the sites in ",i.jsx("code",{className:"bw-path",children:"chrome://extensions"})," does not change this: the grant is held at the browser level and the per-site list is enforced inside the extension, by the extension."]}),i.jsxs("div",{className:"bw-rc-cmd",children:[i.jsx("code",{children:c.command}),i.jsx("button",{className:"btn bw-rc-copy",onClick:d,children:s?"Copied":"Copy"})]}),i.jsx("p",{className:"bw-rc-note",children:c.note})]})]})}function d8(e,t){const n=(e??[]).filter(a=>a&&typeof a.fp=="string"&&!t.has(a.fp));if(!n.length)return{request:null,waiting:0};const s=[...n].sort((a,l)=>(a.at??0)-(l.at??0));return{request:s[0],waiting:s.length-1}}function h8({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:l,onLater:c}){const d=b.useRef(null),h=Ht(c,{focusRef:d}),p=Ks(n,"accept"),f=Ks(n,"dismiss");return i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:h,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0}),i.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:c,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsxs("p",{className:"lan-ask-who",children:[i.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",i.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",xx(e.at,s)]}),i.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),i.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",i.jsx("code",{className:"ap-lan-code",children:e.fp})," — it should match the one on their screen."]}),t>0&&i.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),i.jsxs("div",{className:"lan-ask-acts",children:[i.jsx("button",{type:"button",ref:d,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:l,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),i.jsx("button",{type:"button",className:"btn primary",disabled:p.disabled,"aria-busy":p.busy,onClick:a,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function Nx(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Df,H1;function f8(){if(H1)return Df;H1=1;function e(){this.__data__=[],this.size=0}return Df=e,Df}var qf,G1;function fi(){if(G1)return qf;G1=1;function e(t,n){return t===n||t!==t&&n!==n}return qf=e,qf}var Ff,V1;function jd(){if(V1)return Ff;V1=1;var e=fi();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Ff=t,Ff}var Bf,Y1;function p8(){if(Y1)return Bf;Y1=1;var e=jd(),t=Array.prototype,n=t.splice;function s(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var d=l.length-1;return c==d?l.pop():n.call(l,c,1),--this.size,!0}return Bf=s,Bf}var zf,K1;function m8(){if(K1)return zf;K1=1;var e=jd();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return zf=t,zf}var Uf,X1;function g8(){if(X1)return Uf;X1=1;var e=jd();function t(n){return e(this.__data__,n)>-1}return Uf=t,Uf}var Wf,Q1;function y8(){if(Q1)return Wf;Q1=1;var e=jd();function t(n,s){var a=this.__data__,l=e(a,n);return l<0?(++this.size,a.push([n,s])):a[l][1]=s,this}return Wf=t,Wf}var Hf,Z1;function Ed(){if(Z1)return Hf;Z1=1;var e=f8(),t=p8(),n=m8(),s=g8(),a=y8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,Hf=l,Hf}var Gf,J1;function w8(){if(J1)return Gf;J1=1;var e=Ed();function t(){this.__data__=new e,this.size=0}return Gf=t,Gf}var Vf,e_;function v8(){if(e_)return Vf;e_=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Vf=e,Vf}var Yf,t_;function x8(){if(t_)return Yf;t_=1;function e(t){return this.__data__.get(t)}return Yf=e,Yf}var Kf,n_;function b8(){if(n_)return Kf;n_=1;function e(t){return this.__data__.has(t)}return Kf=e,Kf}var Xf,r_;function Y2(){if(r_)return Xf;r_=1;var e=typeof gu=="object"&&gu&&gu.Object===Object&&gu;return Xf=e,Xf}var Qf,s_;function yr(){if(s_)return Qf;s_=1;var e=Y2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Qf=n,Qf}var Zf,a_;function pi(){if(a_)return Zf;a_=1;var e=yr(),t=e.Symbol;return Zf=t,Zf}var Jf,o_;function k8(){if(o_)return Jf;o_=1;var e=pi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function l(c){var d=n.call(c,a),h=c[a];try{c[a]=void 0;var p=!0}catch{}var f=s.call(c);return p&&(d?c[a]=h:delete c[a]),f}return Jf=l,Jf}var ep,i_;function _8(){if(i_)return ep;i_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return ep=n,ep}var tp,l_;function Xa(){if(l_)return tp;l_=1;var e=pi(),t=k8(),n=_8(),s="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(d){return d==null?d===void 0?a:s:l&&l in Object(d)?t(d):n(d)}return tp=c,tp}var np,c_;function Yn(){if(c_)return np;c_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return np=e,np}var rp,u_;function ec(){if(u_)return rp;u_=1;var e=Xa(),t=Yn(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(d){if(!t(d))return!1;var h=e(d);return h==s||h==a||h==n||h==l}return rp=c,rp}var sp,d_;function N8(){if(d_)return sp;d_=1;var e=yr(),t=e["__core-js_shared__"];return sp=t,sp}var ap,h_;function S8(){if(h_)return ap;h_=1;var e=N8(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return ap=n,ap}var op,f_;function K2(){if(f_)return op;f_=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return op=n,op}var ip,p_;function j8(){if(p_)return ip;p_=1;var e=ec(),t=S8(),n=Yn(),s=K2(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,d=Object.prototype,h=c.toString,p=d.hasOwnProperty,f=RegExp("^"+h.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!n(y)||t(y))return!1;var v=e(y)?f:l;return v.test(s(y))}return ip=m,ip}var lp,m_;function E8(){if(m_)return lp;m_=1;function e(t,n){return t==null?void 0:t[n]}return lp=e,lp}var cp,g_;function Qa(){if(g_)return cp;g_=1;var e=j8(),t=E8();function n(s,a){var l=t(s,a);return e(l)?l:void 0}return cp=n,cp}var up,y_;function Sx(){if(y_)return up;y_=1;var e=Qa(),t=yr(),n=e(t,"Map");return up=n,up}var dp,w_;function Cd(){if(w_)return dp;w_=1;var e=Qa(),t=e(Object,"create");return dp=t,dp}var hp,v_;function C8(){if(v_)return hp;v_=1;var e=Cd();function t(){this.__data__=e?e(null):{},this.size=0}return hp=t,hp}var fp,x_;function T8(){if(x_)return fp;x_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return fp=e,fp}var pp,b_;function A8(){if(b_)return pp;b_=1;var e=Cd(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var d=c[l];return d===t?void 0:d}return s.call(c,l)?c[l]:void 0}return pp=a,pp}var mp,k_;function R8(){if(k_)return mp;k_=1;var e=Cd(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return mp=s,mp}var gp,__;function M8(){if(__)return gp;__=1;var e=Cd(),t="__lodash_hash_undefined__";function n(s,a){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&a===void 0?t:a,this}return gp=n,gp}var yp,N_;function I8(){if(N_)return yp;N_=1;var e=C8(),t=T8(),n=A8(),s=R8(),a=M8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,yp=l,yp}var wp,S_;function $8(){if(S_)return wp;S_=1;var e=I8(),t=Ed(),n=Sx();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return wp=s,wp}var vp,j_;function O8(){if(j_)return vp;j_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return vp=e,vp}var xp,E_;function Td(){if(E_)return xp;E_=1;var e=O8();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return xp=t,xp}var bp,C_;function P8(){if(C_)return bp;C_=1;var e=Td();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return bp=t,bp}var kp,T_;function L8(){if(T_)return kp;T_=1;var e=Td();function t(n){return e(this,n).get(n)}return kp=t,kp}var _p,A_;function D8(){if(A_)return _p;A_=1;var e=Td();function t(n){return e(this,n).has(n)}return _p=t,_p}var Np,R_;function q8(){if(R_)return Np;R_=1;var e=Td();function t(n,s){var a=e(this,n),l=a.size;return a.set(n,s),this.size+=a.size==l?0:1,this}return Np=t,Np}var Sp,M_;function jx(){if(M_)return Sp;M_=1;var e=$8(),t=P8(),n=L8(),s=D8(),a=q8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,Sp=l,Sp}var jp,I_;function F8(){if(I_)return jp;I_=1;var e=Ed(),t=Sx(),n=jx(),s=200;function a(l,c){var d=this.__data__;if(d instanceof e){var h=d.__data__;if(!t||h.length<s-1)return h.push([l,c]),this.size=++d.size,this;d=this.__data__=new n(h)}return d.set(l,c),this.size=d.size,this}return jp=a,jp}var Ep,$_;function Ad(){if($_)return Ep;$_=1;var e=Ed(),t=w8(),n=v8(),s=x8(),a=b8(),l=F8();function c(d){var h=this.__data__=new e(d);this.size=h.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=s,c.prototype.has=a,c.prototype.set=l,Ep=c,Ep}var Cp,O_;function Ex(){if(O_)return Cp;O_=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a&&n(t[s],s,t)!==!1;);return t}return Cp=e,Cp}var Tp,P_;function X2(){if(P_)return Tp;P_=1;var e=Qa(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Tp=t,Tp}var Ap,L_;function Rd(){if(L_)return Ap;L_=1;var e=X2();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Ap=t,Ap}var Rp,D_;function Md(){if(D_)return Rp;D_=1;var e=Rd(),t=fi(),n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d){var h=l[c];(!(s.call(l,c)&&t(h,d))||d===void 0&&!(c in l))&&e(l,c,d)}return Rp=a,Rp}var Mp,q_;function tc(){if(q_)return Mp;q_=1;var e=Md(),t=Rd();function n(s,a,l,c){var d=!l;l||(l={});for(var h=-1,p=a.length;++h<p;){var f=a[h],m=c?c(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),d?t(l,f,m):e(l,f,m)}return l}return Mp=n,Mp}var Ip,F_;function B8(){if(F_)return Ip;F_=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return Ip=e,Ip}var $p,B_;function $r(){if(B_)return $p;B_=1;function e(t){return t!=null&&typeof t=="object"}return $p=e,$p}var Op,z_;function z8(){if(z_)return Op;z_=1;var e=Xa(),t=$r(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Op=s,Op}var Pp,U_;function nc(){if(U_)return Pp;U_=1;var e=z8(),t=$r(),n=Object.prototype,s=n.hasOwnProperty,a=n.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(c){return t(c)&&s.call(c,"callee")&&!a.call(c,"callee")};return Pp=l,Pp}var Lp,W_;function Mt(){if(W_)return Lp;W_=1;var e=Array.isArray;return Lp=e,Lp}var Sl={exports:{}},Dp,H_;function U8(){if(H_)return Dp;H_=1;function e(){return!1}return Dp=e,Dp}Sl.exports;var G_;function mi(){return G_||(G_=1,(function(e,t){var n=yr(),s=U8(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,d=c?n.Buffer:void 0,h=d?d.isBuffer:void 0,p=h||s;e.exports=p})(Sl,Sl.exports)),Sl.exports}var qp,V_;function Id(){if(V_)return qp;V_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,a){var l=typeof s;return a=a??e,!!a&&(l=="number"||l!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<a}return qp=n,qp}var Fp,Y_;function Cx(){if(Y_)return Fp;Y_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Fp=t,Fp}var Bp,K_;function W8(){if(K_)return Bp;K_=1;var e=Xa(),t=Cx(),n=$r(),s="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",d="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",v="[object Set]",S="[object String]",_="[object WeakMap]",j="[object ArrayBuffer]",x="[object DataView]",N="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",$="[object Uint8Array]",B="[object Uint8ClampedArray]",O="[object Uint16Array]",M="[object Uint32Array]",L={};L[N]=L[E]=L[C]=L[R]=L[I]=L[$]=L[B]=L[O]=L[M]=!0,L[s]=L[a]=L[j]=L[l]=L[x]=L[c]=L[d]=L[h]=L[p]=L[f]=L[m]=L[y]=L[v]=L[S]=L[_]=!1;function H(F){return n(F)&&t(F.length)&&!!L[e(F)]}return Bp=H,Bp}var zp,X_;function $d(){if(X_)return zp;X_=1;function e(t){return function(n){return t(n)}}return zp=e,zp}var jl={exports:{}};jl.exports;var Q_;function Tx(){return Q_||(Q_=1,(function(e,t){var n=Y2(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l&&n.process,d=(function(){try{var h=a&&a.require&&a.require("util").types;return h||c&&c.binding&&c.binding("util")}catch{}})();e.exports=d})(jl,jl.exports)),jl.exports}var Up,Z_;function rc(){if(Z_)return Up;Z_=1;var e=W8(),t=$d(),n=Tx(),s=n&&n.isTypedArray,a=s?t(s):e;return Up=a,Up}var Wp,J_;function Q2(){if(J_)return Wp;J_=1;var e=B8(),t=nc(),n=Mt(),s=mi(),a=Id(),l=rc(),c=Object.prototype,d=c.hasOwnProperty;function h(p,f){var m=n(p),y=!m&&t(p),v=!m&&!y&&s(p),S=!m&&!y&&!v&&l(p),_=m||y||v||S,j=_?e(p.length,String):[],x=j.length;for(var N in p)(f||d.call(p,N))&&!(_&&(N=="length"||v&&(N=="offset"||N=="parent")||S&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,x)))&&j.push(N);return j}return Wp=h,Wp}var Hp,eN;function Od(){if(eN)return Hp;eN=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Hp=t,Hp}var Gp,tN;function Z2(){if(tN)return Gp;tN=1;function e(t,n){return function(s){return t(n(s))}}return Gp=e,Gp}var Vp,nN;function H8(){if(nN)return Vp;nN=1;var e=Z2(),t=e(Object.keys,Object);return Vp=t,Vp}var Yp,rN;function Ax(){if(rN)return Yp;rN=1;var e=Od(),t=H8(),n=Object.prototype,s=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var d in Object(l))s.call(l,d)&&d!="constructor"&&c.push(d);return c}return Yp=a,Yp}var Kp,sN;function ls(){if(sN)return Kp;sN=1;var e=ec(),t=Cx();function n(s){return s!=null&&t(s.length)&&!e(s)}return Kp=n,Kp}var Xp,aN;function Xs(){if(aN)return Xp;aN=1;var e=Q2(),t=Ax(),n=ls();function s(a){return n(a)?e(a):t(a)}return Xp=s,Xp}var Qp,oN;function G8(){if(oN)return Qp;oN=1;var e=tc(),t=Xs();function n(s,a){return s&&e(a,t(a),s)}return Qp=n,Qp}var Zp,iN;function V8(){if(iN)return Zp;iN=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Zp=e,Zp}var Jp,lN;function Y8(){if(lN)return Jp;lN=1;var e=Yn(),t=Od(),n=V8(),s=Object.prototype,a=s.hasOwnProperty;function l(c){if(!e(c))return n(c);var d=t(c),h=[];for(var p in c)p=="constructor"&&(d||!a.call(c,p))||h.push(p);return h}return Jp=l,Jp}var em,cN;function Za(){if(cN)return em;cN=1;var e=Q2(),t=Y8(),n=ls();function s(a){return n(a)?e(a,!0):t(a)}return em=s,em}var tm,uN;function K8(){if(uN)return tm;uN=1;var e=tc(),t=Za();function n(s,a){return s&&e(a,t(a),s)}return tm=n,tm}var El={exports:{}};El.exports;var dN;function J2(){return dN||(dN=1,(function(e,t){var n=yr(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?n.Buffer:void 0,d=c?c.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var m=p.length,y=d?d(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(El,El.exports)),El.exports}var nm,hN;function eA(){if(hN)return nm;hN=1;function e(t,n){var s=-1,a=t.length;for(n||(n=Array(a));++s<a;)n[s]=t[s];return n}return nm=e,nm}var rm,fN;function tA(){if(fN)return rm;fN=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=0,c=[];++s<a;){var d=t[s];n(d,s,t)&&(c[l++]=d)}return c}return rm=e,rm}var sm,pN;function nA(){if(pN)return sm;pN=1;function e(){return[]}return sm=e,sm}var am,mN;function Rx(){if(mN)return am;mN=1;var e=tA(),t=nA(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(d){return s.call(c,d)}))}:t;return am=l,am}var om,gN;function X8(){if(gN)return om;gN=1;var e=tc(),t=Rx();function n(s,a){return e(s,t(s),a)}return om=n,om}var im,yN;function Mx(){if(yN)return im;yN=1;function e(t,n){for(var s=-1,a=n.length,l=t.length;++s<a;)t[l+s]=n[s];return t}return im=e,im}var lm,wN;function Pd(){if(wN)return lm;wN=1;var e=Z2(),t=e(Object.getPrototypeOf,Object);return lm=t,lm}var cm,vN;function rA(){if(vN)return cm;vN=1;var e=Mx(),t=Pd(),n=Rx(),s=nA(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var d=[];c;)e(d,n(c)),c=t(c);return d}:s;return cm=l,cm}var um,xN;function Q8(){if(xN)return um;xN=1;var e=tc(),t=rA();function n(s,a){return e(s,t(s),a)}return um=n,um}var dm,bN;function sA(){if(bN)return dm;bN=1;var e=Mx(),t=Mt();function n(s,a,l){var c=a(s);return t(s)?c:e(c,l(s))}return dm=n,dm}var hm,kN;function aA(){if(kN)return hm;kN=1;var e=sA(),t=Rx(),n=Xs();function s(a){return e(a,n,t)}return hm=s,hm}var fm,_N;function Z8(){if(_N)return fm;_N=1;var e=sA(),t=rA(),n=Za();function s(a){return e(a,n,t)}return fm=s,fm}var pm,NN;function J8(){if(NN)return pm;NN=1;var e=Qa(),t=yr(),n=e(t,"DataView");return pm=n,pm}var mm,SN;function eB(){if(SN)return mm;SN=1;var e=Qa(),t=yr(),n=e(t,"Promise");return mm=n,mm}var gm,jN;function oA(){if(jN)return gm;jN=1;var e=Qa(),t=yr(),n=e(t,"Set");return gm=n,gm}var ym,EN;function tB(){if(EN)return ym;EN=1;var e=Qa(),t=yr(),n=e(t,"WeakMap");return ym=n,ym}var wm,CN;function gi(){if(CN)return wm;CN=1;var e=J8(),t=Sx(),n=eB(),s=oA(),a=tB(),l=Xa(),c=K2(),d="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",v=c(e),S=c(t),_=c(n),j=c(s),x=c(a),N=l;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=d||n&&N(n.resolve())!=p||s&&N(new s)!=f||a&&N(new a)!=m)&&(N=function(E){var C=l(E),R=C==h?E.constructor:void 0,I=R?c(R):"";if(I)switch(I){case v:return y;case S:return d;case _:return p;case j:return f;case x:return m}return C}),wm=N,wm}var vm,TN;function nB(){if(TN)return vm;TN=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var a=s.length,l=new s.constructor(a);return a&&typeof s[0]=="string"&&t.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return vm=n,vm}var xm,AN;function iA(){if(AN)return xm;AN=1;var e=yr(),t=e.Uint8Array;return xm=t,xm}var bm,RN;function Ix(){if(RN)return bm;RN=1;var e=iA();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return bm=t,bm}var km,MN;function rB(){if(MN)return km;MN=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return km=t,km}var _m,IN;function sB(){if(IN)return _m;IN=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return _m=t,_m}var Nm,$N;function aB(){if($N)return Nm;$N=1;var e=pi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return Nm=s,Nm}var Sm,ON;function lA(){if(ON)return Sm;ON=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return Sm=t,Sm}var jm,PN;function oB(){if(PN)return jm;PN=1;var e=Ix(),t=rB(),n=sB(),s=aB(),a=lA(),l="[object Boolean]",c="[object Date]",d="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",v="[object ArrayBuffer]",S="[object DataView]",_="[object Float32Array]",j="[object Float64Array]",x="[object Int8Array]",N="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",$="[object Uint32Array]";function B(O,M,L){var H=O.constructor;switch(M){case v:return e(O);case l:case c:return new H(+O);case S:return t(O,L);case _:case j:case x:case N:case E:case C:case R:case I:case $:return a(O,L);case d:return new H;case h:case m:return new H(O);case p:return n(O);case f:return new H;case y:return s(O)}}return jm=B,jm}var Em,LN;function cA(){if(LN)return Em;LN=1;var e=Yn(),t=Object.create,n=(function(){function s(){}return function(a){if(!e(a))return{};if(t)return t(a);s.prototype=a;var l=new s;return s.prototype=void 0,l}})();return Em=n,Em}var Cm,DN;function uA(){if(DN)return Cm;DN=1;var e=cA(),t=Pd(),n=Od();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Cm=s,Cm}var Tm,qN;function iB(){if(qN)return Tm;qN=1;var e=gi(),t=$r(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return Tm=s,Tm}var Am,FN;function lB(){if(FN)return Am;FN=1;var e=iB(),t=$d(),n=Tx(),s=n&&n.isMap,a=s?t(s):e;return Am=a,Am}var Rm,BN;function cB(){if(BN)return Rm;BN=1;var e=gi(),t=$r(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return Rm=s,Rm}var Mm,zN;function uB(){if(zN)return Mm;zN=1;var e=cB(),t=$d(),n=Tx(),s=n&&n.isSet,a=s?t(s):e;return Mm=a,Mm}var Im,UN;function dA(){if(UN)return Im;UN=1;var e=Ad(),t=Ex(),n=Md(),s=G8(),a=K8(),l=J2(),c=eA(),d=X8(),h=Q8(),p=aA(),f=Z8(),m=gi(),y=nB(),v=oB(),S=uA(),_=Mt(),j=mi(),x=lB(),N=Yn(),E=uB(),C=Xs(),R=Za(),I=1,$=2,B=4,O="[object Arguments]",M="[object Array]",L="[object Boolean]",H="[object Date]",F="[object Error]",A="[object Function]",Q="[object GeneratorFunction]",K="[object Map]",ee="[object Number]",Z="[object Object]",D="[object RegExp]",Y="[object Set]",P="[object String]",G="[object Symbol]",de="[object WeakMap]",W="[object ArrayBuffer]",U="[object DataView]",J="[object Float32Array]",V="[object Float64Array]",ie="[object Int8Array]",pe="[object Int16Array]",me="[object Int32Array]",Ie="[object Uint8Array]",Le="[object Uint8ClampedArray]",ce="[object Uint16Array]",xe="[object Uint32Array]",ye={};ye[O]=ye[M]=ye[W]=ye[U]=ye[L]=ye[H]=ye[J]=ye[V]=ye[ie]=ye[pe]=ye[me]=ye[K]=ye[ee]=ye[Z]=ye[D]=ye[Y]=ye[P]=ye[G]=ye[Ie]=ye[Le]=ye[ce]=ye[xe]=!0,ye[F]=ye[A]=ye[de]=!1;function ze(ke,je,Ye,it,Ne,He){var Xe,he=je&I,ge=je&$,Se=je&B;if(Ye&&(Xe=Ne?Ye(ke,it,Ne,He):Ye(ke)),Xe!==void 0)return Xe;if(!N(ke))return ke;var Fe=_(ke);if(Fe){if(Xe=y(ke),!he)return c(ke,Xe)}else{var et=m(ke),xt=et==A||et==Q;if(j(ke))return l(ke,he);if(et==Z||et==O||xt&&!Ne){if(Xe=ge||xt?{}:S(ke),!he)return ge?h(ke,a(Xe,ke)):d(ke,s(Xe,ke))}else{if(!ye[et])return Ne?ke:{};Xe=v(ke,et,he)}}He||(He=new e);var ht=He.get(ke);if(ht)return ht;He.set(ke,Xe),E(ke)?ke.forEach(function(Oe){Xe.add(ze(Oe,je,Ye,Oe,ke,He))}):x(ke)&&ke.forEach(function(Oe,Te){Xe.set(Te,ze(Oe,je,Ye,Te,ke,He))});var ne=Se?ge?f:p:ge?R:C,De=Fe?void 0:ne(ke);return t(De||ke,function(Oe,Te){De&&(Te=Oe,Oe=ke[Te]),n(Xe,Te,ze(Oe,je,Ye,Te,ke,He))}),Xe}return Im=ze,Im}var $m,WN;function dB(){if(WN)return $m;WN=1;var e=dA(),t=4;function n(s){return e(s,t)}return $m=n,$m}var Om,HN;function $x(){if(HN)return Om;HN=1;function e(t){return function(){return t}}return Om=e,Om}var Pm,GN;function hB(){if(GN)return Pm;GN=1;function e(t){return function(n,s,a){for(var l=-1,c=Object(n),d=a(n),h=d.length;h--;){var p=d[t?h:++l];if(s(c[p],p,c)===!1)break}return n}}return Pm=e,Pm}var Lm,VN;function Ox(){if(VN)return Lm;VN=1;var e=hB(),t=e();return Lm=t,Lm}var Dm,YN;function Px(){if(YN)return Dm;YN=1;var e=Ox(),t=Xs();function n(s,a){return s&&e(s,a,t)}return Dm=n,Dm}var qm,KN;function fB(){if(KN)return qm;KN=1;var e=ls();function t(n,s){return function(a,l){if(a==null)return a;if(!e(a))return n(a,l);for(var c=a.length,d=s?c:-1,h=Object(a);(s?d--:++d<c)&&l(h[d],d,h)!==!1;);return a}}return qm=t,qm}var Fm,XN;function Ld(){if(XN)return Fm;XN=1;var e=Px(),t=fB(),n=t(e);return Fm=n,Fm}var Bm,QN;function Ja(){if(QN)return Bm;QN=1;function e(t){return t}return Bm=e,Bm}var zm,ZN;function hA(){if(ZN)return zm;ZN=1;var e=Ja();function t(n){return typeof n=="function"?n:e}return zm=t,zm}var Um,JN;function fA(){if(JN)return Um;JN=1;var e=Ex(),t=Ld(),n=hA(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c))}return Um=a,Um}var Wm,eS;function pA(){return eS||(eS=1,Wm=fA()),Wm}var Hm,tS;function pB(){if(tS)return Hm;tS=1;var e=Ld();function t(n,s){var a=[];return e(n,function(l,c,d){s(l,c,d)&&a.push(l)}),a}return Hm=t,Hm}var Gm,nS;function mB(){if(nS)return Gm;nS=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Gm=t,Gm}var Vm,rS;function gB(){if(rS)return Vm;rS=1;function e(t){return this.__data__.has(t)}return Vm=e,Vm}var Ym,sS;function mA(){if(sS)return Ym;sS=1;var e=jx(),t=mB(),n=gB();function s(a){var l=-1,c=a==null?0:a.length;for(this.__data__=new e;++l<c;)this.add(a[l])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,Ym=s,Ym}var Km,aS;function yB(){if(aS)return Km;aS=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(t[s],s,t))return!0;return!1}return Km=e,Km}var Xm,oS;function gA(){if(oS)return Xm;oS=1;function e(t,n){return t.has(n)}return Xm=e,Xm}var Qm,iS;function yA(){if(iS)return Qm;iS=1;var e=mA(),t=yB(),n=gA(),s=1,a=2;function l(c,d,h,p,f,m){var y=h&s,v=c.length,S=d.length;if(v!=S&&!(y&&S>v))return!1;var _=m.get(c),j=m.get(d);if(_&&j)return _==d&&j==c;var x=-1,N=!0,E=h&a?new e:void 0;for(m.set(c,d),m.set(d,c);++x<v;){var C=c[x],R=d[x];if(p)var I=y?p(R,C,x,d,c,m):p(C,R,x,c,d,m);if(I!==void 0){if(I)continue;N=!1;break}if(E){if(!t(d,function($,B){if(!n(E,B)&&(C===$||f(C,$,h,p,m)))return E.push(B)})){N=!1;break}}else if(!(C===R||f(C,R,h,p,m))){N=!1;break}}return m.delete(c),m.delete(d),N}return Qm=l,Qm}var Zm,lS;function wB(){if(lS)return Zm;lS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,l){s[++n]=[l,a]}),s}return Zm=e,Zm}var Jm,cS;function Lx(){if(cS)return Jm;cS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Jm=e,Jm}var eg,uS;function vB(){if(uS)return eg;uS=1;var e=pi(),t=iA(),n=fi(),s=yA(),a=wB(),l=Lx(),c=1,d=2,h="[object Boolean]",p="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",v="[object RegExp]",S="[object Set]",_="[object String]",j="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function R(I,$,B,O,M,L,H){switch(B){case N:if(I.byteLength!=$.byteLength||I.byteOffset!=$.byteOffset)return!1;I=I.buffer,$=$.buffer;case x:return!(I.byteLength!=$.byteLength||!L(new t(I),new t($)));case h:case p:case y:return n(+I,+$);case f:return I.name==$.name&&I.message==$.message;case v:case _:return I==$+"";case m:var F=a;case S:var A=O&c;if(F||(F=l),I.size!=$.size&&!A)return!1;var Q=H.get(I);if(Q)return Q==$;O|=d,H.set(I,$);var K=s(F(I),F($),O,M,L,H);return H.delete(I),K;case j:if(C)return C.call(I)==C.call($)}return!1}return eg=R,eg}var tg,dS;function xB(){if(dS)return tg;dS=1;var e=aA(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d,h,p,f){var m=d&t,y=e(l),v=y.length,S=e(c),_=S.length;if(v!=_&&!m)return!1;for(var j=v;j--;){var x=y[j];if(!(m?x in c:s.call(c,x)))return!1}var N=f.get(l),E=f.get(c);if(N&&E)return N==c&&E==l;var C=!0;f.set(l,c),f.set(c,l);for(var R=m;++j<v;){x=y[j];var I=l[x],$=c[x];if(h)var B=m?h($,I,x,c,l,f):h(I,$,x,l,c,f);if(!(B===void 0?I===$||p(I,$,d,h,f):B)){C=!1;break}R||(R=x=="constructor")}if(C&&!R){var O=l.constructor,M=c.constructor;O!=M&&"constructor"in l&&"constructor"in c&&!(typeof O=="function"&&O instanceof O&&typeof M=="function"&&M instanceof M)&&(C=!1)}return f.delete(l),f.delete(c),C}return tg=a,tg}var ng,hS;function bB(){if(hS)return ng;hS=1;var e=Ad(),t=yA(),n=vB(),s=xB(),a=gi(),l=Mt(),c=mi(),d=rc(),h=1,p="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,v=y.hasOwnProperty;function S(_,j,x,N,E,C){var R=l(_),I=l(j),$=R?f:a(_),B=I?f:a(j);$=$==p?m:$,B=B==p?m:B;var O=$==m,M=B==m,L=$==B;if(L&&c(_)){if(!c(j))return!1;R=!0,O=!1}if(L&&!O)return C||(C=new e),R||d(_)?t(_,j,x,N,E,C):n(_,j,$,x,N,E,C);if(!(x&h)){var H=O&&v.call(_,"__wrapped__"),F=M&&v.call(j,"__wrapped__");if(H||F){var A=H?_.value():_,Q=F?j.value():j;return C||(C=new e),E(A,Q,x,N,C)}}return L?(C||(C=new e),s(_,j,x,N,E,C)):!1}return ng=S,ng}var rg,fS;function wA(){if(fS)return rg;fS=1;var e=bB(),t=$r();function n(s,a,l,c,d){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,l,c,n,d)}return rg=n,rg}var sg,pS;function kB(){if(pS)return sg;pS=1;var e=Ad(),t=wA(),n=1,s=2;function a(l,c,d,h){var p=d.length,f=p,m=!h;if(l==null)return!f;for(l=Object(l);p--;){var y=d[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<f;){y=d[p];var v=y[0],S=l[v],_=y[1];if(m&&y[2]){if(S===void 0&&!(v in l))return!1}else{var j=new e;if(h)var x=h(S,_,v,l,c,j);if(!(x===void 0?t(_,S,n|s,h,j):x))return!1}}return!0}return sg=a,sg}var ag,mS;function vA(){if(mS)return ag;mS=1;var e=Yn();function t(n){return n===n&&!e(n)}return ag=t,ag}var og,gS;function _B(){if(gS)return og;gS=1;var e=vA(),t=Xs();function n(s){for(var a=t(s),l=a.length;l--;){var c=a[l],d=s[c];a[l]=[c,d,e(d)]}return a}return og=n,og}var ig,yS;function xA(){if(yS)return ig;yS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return ig=e,ig}var lg,wS;function NB(){if(wS)return lg;wS=1;var e=kB(),t=_B(),n=xA();function s(a){var l=t(a);return l.length==1&&l[0][2]?n(l[0][0],l[0][1]):function(c){return c===a||e(c,a,l)}}return lg=s,lg}var cg,vS;function yi(){if(vS)return cg;vS=1;var e=Xa(),t=$r(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return cg=s,cg}var ug,xS;function Dx(){if(xS)return ug;xS=1;var e=Mt(),t=yi(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(l,c){if(e(l))return!1;var d=typeof l;return d=="number"||d=="symbol"||d=="boolean"||l==null||t(l)?!0:s.test(l)||!n.test(l)||c!=null&&l in Object(c)}return ug=a,ug}var dg,bS;function SB(){if(bS)return dg;bS=1;var e=jx(),t="Expected a function";function n(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var l=function(){var c=arguments,d=a?a.apply(this,c):c[0],h=l.cache;if(h.has(d))return h.get(d);var p=s.apply(this,c);return l.cache=h.set(d,p)||h,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,dg=n,dg}var hg,kS;function jB(){if(kS)return hg;kS=1;var e=SB(),t=500;function n(s){var a=e(s,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return hg=n,hg}var fg,_S;function EB(){if(_S)return fg;_S=1;var e=jB(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(a){var l=[];return a.charCodeAt(0)===46&&l.push(""),a.replace(t,function(c,d,h,p){l.push(h?p.replace(n,"$1"):d||c)}),l});return fg=s,fg}var pg,NS;function Dd(){if(NS)return pg;NS=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=Array(a);++s<a;)l[s]=n(t[s],s,t);return l}return pg=e,pg}var mg,SS;function CB(){if(SS)return mg;SS=1;var e=pi(),t=Dd(),n=Mt(),s=yi(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(d){if(typeof d=="string")return d;if(n(d))return t(d,c)+"";if(s(d))return l?l.call(d):"";var h=d+"";return h=="0"&&1/d==-1/0?"-0":h}return mg=c,mg}var gg,jS;function bA(){if(jS)return gg;jS=1;var e=CB();function t(n){return n==null?"":e(n)}return gg=t,gg}var yg,ES;function qd(){if(ES)return yg;ES=1;var e=Mt(),t=Dx(),n=EB(),s=bA();function a(l,c){return e(l)?l:t(l,c)?[l]:n(s(l))}return yg=a,yg}var wg,CS;function sc(){if(CS)return wg;CS=1;var e=yi();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return wg=t,wg}var vg,TS;function Fd(){if(TS)return vg;TS=1;var e=qd(),t=sc();function n(s,a){a=e(a,s);for(var l=0,c=a.length;s!=null&&l<c;)s=s[t(a[l++])];return l&&l==c?s:void 0}return vg=n,vg}var xg,AS;function TB(){if(AS)return xg;AS=1;var e=Fd();function t(n,s,a){var l=n==null?void 0:e(n,s);return l===void 0?a:l}return xg=t,xg}var bg,RS;function AB(){if(RS)return bg;RS=1;function e(t,n){return t!=null&&n in Object(t)}return bg=e,bg}var kg,MS;function kA(){if(MS)return kg;MS=1;var e=qd(),t=nc(),n=Mt(),s=Id(),a=Cx(),l=sc();function c(d,h,p){h=e(h,d);for(var f=-1,m=h.length,y=!1;++f<m;){var v=l(h[f]);if(!(y=d!=null&&p(d,v)))break;d=d[v]}return y||++f!=m?y:(m=d==null?0:d.length,!!m&&a(m)&&s(v,m)&&(n(d)||t(d)))}return kg=c,kg}var _g,IS;function _A(){if(IS)return _g;IS=1;var e=AB(),t=kA();function n(s,a){return s!=null&&t(s,a,e)}return _g=n,_g}var Ng,$S;function RB(){if($S)return Ng;$S=1;var e=wA(),t=TB(),n=_A(),s=Dx(),a=vA(),l=xA(),c=sc(),d=1,h=2;function p(f,m){return s(f)&&a(m)?l(c(f),m):function(y){var v=t(y,f);return v===void 0&&v===m?n(y,f):e(m,v,d|h)}}return Ng=p,Ng}var Sg,OS;function NA(){if(OS)return Sg;OS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Sg=e,Sg}var jg,PS;function MB(){if(PS)return jg;PS=1;var e=Fd();function t(n){return function(s){return e(s,n)}}return jg=t,jg}var Eg,LS;function IB(){if(LS)return Eg;LS=1;var e=NA(),t=MB(),n=Dx(),s=sc();function a(l){return n(l)?e(s(l)):t(l)}return Eg=a,Eg}var Cg,DS;function cs(){if(DS)return Cg;DS=1;var e=NB(),t=RB(),n=Ja(),s=Mt(),a=IB();function l(c){return typeof c=="function"?c:c==null?n:typeof c=="object"?s(c)?t(c[0],c[1]):e(c):a(c)}return Cg=l,Cg}var Tg,qS;function SA(){if(qS)return Tg;qS=1;var e=tA(),t=pB(),n=cs(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c,3))}return Tg=a,Tg}var Ag,FS;function $B(){if(FS)return Ag;FS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Ag=n,Ag}var Rg,BS;function jA(){if(BS)return Rg;BS=1;var e=$B(),t=kA();function n(s,a){return s!=null&&t(s,a,e)}return Rg=n,Rg}var Mg,zS;function OB(){if(zS)return Mg;zS=1;var e=Ax(),t=gi(),n=nc(),s=Mt(),a=ls(),l=mi(),c=Od(),d=rc(),h="[object Map]",p="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(v){if(v==null)return!0;if(a(v)&&(s(v)||typeof v=="string"||typeof v.splice=="function"||l(v)||d(v)||n(v)))return!v.length;var S=t(v);if(S==h||S==p)return!v.size;if(c(v))return!e(v).length;for(var _ in v)if(m.call(v,_))return!1;return!0}return Mg=y,Mg}var Ig,US;function EA(){if(US)return Ig;US=1;function e(t){return t===void 0}return Ig=e,Ig}var $g,WS;function CA(){if(WS)return $g;WS=1;var e=Ld(),t=ls();function n(s,a){var l=-1,c=t(s)?Array(s.length):[];return e(s,function(d,h,p){c[++l]=a(d,h,p)}),c}return $g=n,$g}var Og,HS;function TA(){if(HS)return Og;HS=1;var e=Dd(),t=cs(),n=CA(),s=Mt();function a(l,c){var d=s(l)?e:n;return d(l,t(c,3))}return Og=a,Og}var Pg,GS;function PB(){if(GS)return Pg;GS=1;function e(t,n,s,a){var l=-1,c=t==null?0:t.length;for(a&&c&&(s=t[++l]);++l<c;)s=n(s,t[l],l,t);return s}return Pg=e,Pg}var Lg,VS;function LB(){if(VS)return Lg;VS=1;function e(t,n,s,a,l){return l(t,function(c,d,h){s=a?(a=!1,c):n(s,c,d,h)}),s}return Lg=e,Lg}var Dg,YS;function AA(){if(YS)return Dg;YS=1;var e=PB(),t=Ld(),n=cs(),s=LB(),a=Mt();function l(c,d,h){var p=a(c)?e:s,f=arguments.length<3;return p(c,n(d,4),h,f,t)}return Dg=l,Dg}var qg,KS;function DB(){if(KS)return qg;KS=1;var e=Xa(),t=Mt(),n=$r(),s="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==s}return qg=a,qg}var Fg,XS;function qB(){if(XS)return Fg;XS=1;var e=NA(),t=e("length");return Fg=t,Fg}var Bg,QS;function FB(){if(QS)return Bg;QS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="\\u200d",d=RegExp("["+c+e+a+l+"]");function h(p){return d.test(p)}return Bg=h,Bg}var zg,ZS;function BB(){if(ZS)return zg;ZS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="["+e+"]",d="["+a+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+d+"|"+h+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",S=p+"?",_="["+l+"]?",j="(?:"+v+"(?:"+[f,m,y].join("|")+")"+_+S+")*",x=_+S+j,N="(?:"+[f+d+"?",d,m,y,c].join("|")+")",E=RegExp(h+"(?="+h+")|"+N+x,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return zg=C,zg}var Ug,JS;function zB(){if(JS)return Ug;JS=1;var e=qB(),t=FB(),n=BB();function s(a){return t(a)?n(a):e(a)}return Ug=s,Ug}var Wg,ej;function UB(){if(ej)return Wg;ej=1;var e=Ax(),t=gi(),n=ls(),s=DB(),a=zB(),l="[object Map]",c="[object Set]";function d(h){if(h==null)return 0;if(n(h))return s(h)?a(h):h.length;var p=t(h);return p==l||p==c?h.size:e(h).length}return Wg=d,Wg}var Hg,tj;function WB(){if(tj)return Hg;tj=1;var e=Ex(),t=cA(),n=Px(),s=cs(),a=Pd(),l=Mt(),c=mi(),d=ec(),h=Yn(),p=rc();function f(m,y,v){var S=l(m),_=S||c(m)||p(m);if(y=s(y,4),v==null){var j=m&&m.constructor;_?v=S?new j:[]:h(m)?v=d(j)?t(a(m)):{}:v={}}return(_?e:n)(m,function(x,N,E){return y(v,x,N,E)}),v}return Hg=f,Hg}var Gg,nj;function HB(){if(nj)return Gg;nj=1;var e=pi(),t=nc(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(s&&l&&l[s])}return Gg=a,Gg}var Vg,rj;function qx(){if(rj)return Vg;rj=1;var e=Mx(),t=HB();function n(s,a,l,c,d){var h=-1,p=s.length;for(l||(l=t),d||(d=[]);++h<p;){var f=s[h];a>0&&l(f)?a>1?n(f,a-1,l,c,d):e(d,f):c||(d[d.length]=f)}return d}return Vg=n,Vg}var Yg,sj;function GB(){if(sj)return Yg;sj=1;function e(t,n,s){switch(s.length){case 0:return t.call(n);case 1:return t.call(n,s[0]);case 2:return t.call(n,s[0],s[1]);case 3:return t.call(n,s[0],s[1],s[2])}return t.apply(n,s)}return Yg=e,Yg}var Kg,aj;function RA(){if(aj)return Kg;aj=1;var e=GB(),t=Math.max;function n(s,a,l){return a=t(a===void 0?s.length-1:a,0),function(){for(var c=arguments,d=-1,h=t(c.length-a,0),p=Array(h);++d<h;)p[d]=c[a+d];d=-1;for(var f=Array(a+1);++d<a;)f[d]=c[d];return f[a]=l(p),e(s,this,f)}}return Kg=n,Kg}var Xg,oj;function VB(){if(oj)return Xg;oj=1;var e=$x(),t=X2(),n=Ja(),s=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return Xg=s,Xg}var Qg,ij;function YB(){if(ij)return Qg;ij=1;var e=800,t=16,n=Date.now;function s(a){var l=0,c=0;return function(){var d=n(),h=t-(d-c);if(c=d,h>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return Qg=s,Qg}var Zg,lj;function MA(){if(lj)return Zg;lj=1;var e=VB(),t=YB(),n=t(e);return Zg=n,Zg}var Jg,cj;function Bd(){if(cj)return Jg;cj=1;var e=Ja(),t=RA(),n=MA();function s(a,l){return n(t(a,l,e),a+"")}return Jg=s,Jg}var ey,uj;function IA(){if(uj)return ey;uj=1;function e(t,n,s,a){for(var l=t.length,c=s+(a?1:-1);a?c--:++c<l;)if(n(t[c],c,t))return c;return-1}return ey=e,ey}var ty,dj;function KB(){if(dj)return ty;dj=1;function e(t){return t!==t}return ty=e,ty}var ny,hj;function XB(){if(hj)return ny;hj=1;function e(t,n,s){for(var a=s-1,l=t.length;++a<l;)if(t[a]===n)return a;return-1}return ny=e,ny}var ry,fj;function QB(){if(fj)return ry;fj=1;var e=IA(),t=KB(),n=XB();function s(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return ry=s,ry}var sy,pj;function ZB(){if(pj)return sy;pj=1;var e=QB();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return sy=t,sy}var ay,mj;function JB(){if(mj)return ay;mj=1;function e(t,n,s){for(var a=-1,l=t==null?0:t.length;++a<l;)if(s(n,t[a]))return!0;return!1}return ay=e,ay}var oy,gj;function ez(){if(gj)return oy;gj=1;function e(){}return oy=e,oy}var iy,yj;function tz(){if(yj)return iy;yj=1;var e=oA(),t=ez(),n=Lx(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(l){return new e(l)}:t;return iy=a,iy}var ly,wj;function nz(){if(wj)return ly;wj=1;var e=mA(),t=ZB(),n=JB(),s=gA(),a=tz(),l=Lx(),c=200;function d(h,p,f){var m=-1,y=t,v=h.length,S=!0,_=[],j=_;if(f)S=!1,y=n;else if(v>=c){var x=p?null:a(h);if(x)return l(x);S=!1,y=s,j=new e}else j=p?[]:_;e:for(;++m<v;){var N=h[m],E=p?p(N):N;if(N=f||N!==0?N:0,S&&E===E){for(var C=j.length;C--;)if(j[C]===E)continue e;p&&j.push(E),_.push(N)}else y(j,E,f)||(j!==_&&j.push(E),_.push(N))}return _}return ly=d,ly}var cy,vj;function $A(){if(vj)return cy;vj=1;var e=ls(),t=$r();function n(s){return t(s)&&e(s)}return cy=n,cy}var uy,xj;function rz(){if(xj)return uy;xj=1;var e=qx(),t=Bd(),n=nz(),s=$A(),a=t(function(l){return n(e(l,1,s,!0))});return uy=a,uy}var dy,bj;function sz(){if(bj)return dy;bj=1;var e=Dd();function t(n,s){return e(s,function(a){return n[a]})}return dy=t,dy}var hy,kj;function OA(){if(kj)return hy;kj=1;var e=sz(),t=Xs();function n(s){return s==null?[]:e(s,t(s))}return hy=n,hy}var fy,_j;function Kn(){if(_j)return fy;_j=1;var e;if(typeof Nx=="function")try{e={clone:dB(),constant:$x(),each:pA(),filter:SA(),has:jA(),isArray:Mt(),isEmpty:OB(),isFunction:ec(),isUndefined:EA(),keys:Xs(),map:TA(),reduce:AA(),size:UB(),transform:WB(),union:rz(),values:OA()}}catch{}return e||(e=window._),fy=e,fy}var py,Nj;function Fx(){if(Nj)return py;Nj=1;var e=Kn();py=a;var t="\0",n="\0",s="";function a(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(f){return this._label=f,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},a.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},a.prototype.setNodes=function(f,m){var y=arguments,v=this;return e.each(f,function(S){y.length>1?v.setNode(S,m):v.setNode(S)}),this},a.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},a.prototype.node=function(f){return this._nodes[f]},a.prototype.hasNode=function(f){return e.has(this._nodes,f)},a.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(v){m.removeEdge(m._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){m.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},a.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==n)return m}},a.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},a.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},a.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},a.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},a.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},a.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,j){f(j)&&m.setNode(j,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var v={};function S(_){var j=y.parent(_);return j===void 0||m.hasNode(j)?(v[_]=j,j):j in v?v[j]:S(j)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,S(_))}),m},a.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(f,m){var y=this,v=arguments;return e.reduce(f,function(S,_){return v.length>1?y.setEdge(S,_,m):y.setEdge(S,_),_}),this},a.prototype.setEdge=function(){var f,m,y,v,S=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(v=arguments[1],S=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(v=arguments[2],S=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var j=d(this._isDirected,f,m,y);if(e.has(this._edgeLabels,j))return S&&(this._edgeLabels[j]=v),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[j]=S?v:this._defaultEdgeLabelFn(f,m,y);var x=h(this._isDirected,f,m,y);return f=x.v,m=x.w,Object.freeze(x),this._edgeObjs[j]=x,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][j]=x,this._out[f][j]=x,this._edgeCount++,this},a.prototype.edge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return this._edgeLabels[v]},a.prototype.hasEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return e.has(this._edgeLabels,v)},a.prototype.removeEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y),S=this._edgeObjs[v];return S&&(f=S.v,m=S.w,delete this._edgeLabels[v],delete this._edgeObjs[v],c(this._preds[m],f),c(this._sucs[f],m),delete this._in[m][v],delete this._out[f][v],this._edgeCount--),this},a.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var v=e.values(y);return m?e.filter(v,function(S){return S.v===m}):v}},a.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var v=e.values(y);return m?e.filter(v,function(S){return S.w===m}):v}},a.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function c(f,m){--f[m]||delete f[m]}function d(f,m,y,v){var S=""+m,_=""+y;if(!f&&S>_){var j=S;S=_,_=j}return S+s+_+s+(e.isUndefined(v)?t:v)}function h(f,m,y,v){var S=""+m,_=""+y;if(!f&&S>_){var j=S;S=_,_=j}var x={v:S,w:_};return v&&(x.name=v),x}function p(f,m){return d(f,m.v,m.w,m.name)}return py}var my,Sj;function az(){return Sj||(Sj=1,my="2.1.8"),my}var gy,jj;function oz(){return jj||(jj=1,gy={Graph:Fx(),version:az()}),gy}var yy,Ej;function iz(){if(Ej)return yy;Ej=1;var e=Kn(),t=Fx();yy={write:n,read:l};function n(c){var d={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:s(c),edges:a(c)};return e.isUndefined(c.graph())||(d.value=e.clone(c.graph())),d}function s(c){return e.map(c.nodes(),function(d){var h=c.node(d),p=c.parent(d),f={v:d};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function a(c){return e.map(c.edges(),function(d){var h=c.edge(d),p={v:d.v,w:d.w};return e.isUndefined(d.name)||(p.name=d.name),e.isUndefined(h)||(p.value=h),p})}function l(c){var d=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(h){d.setNode(h.v,h.value),h.parent&&d.setParent(h.v,h.parent)}),e.each(c.edges,function(h){d.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),d}return yy}var wy,Cj;function lz(){if(Cj)return wy;Cj=1;var e=Kn();wy=t;function t(n){var s={},a=[],l;function c(d){e.has(s,d)||(s[d]=!0,l.push(d),e.each(n.successors(d),c),e.each(n.predecessors(d),c))}return e.each(n.nodes(),function(d){l=[],c(d),l.length&&a.push(l)}),a}return wy}var vy,Tj;function PA(){if(Tj)return vy;Tj=1;var e=Kn();vy=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var s=this._keyIndices[n];if(s!==void 0)return this._arr[s].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,s){var a=this._keyIndices;if(n=String(n),!e.has(a,n)){var l=this._arr,c=l.length;return a[n]=c,l.push({key:n,priority:s}),this._decrease(c),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,s){var a=this._keyIndices[n];if(s>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+s);this._arr[a].priority=s,this._decrease(a)},t.prototype._heapify=function(n){var s=this._arr,a=2*n,l=a+1,c=n;a<s.length&&(c=s[a].priority<s[c].priority?a:c,l<s.length&&(c=s[l].priority<s[c].priority?l:c),c!==n&&(this._swap(n,c),this._heapify(c)))},t.prototype._decrease=function(n){for(var s=this._arr,a=s[n].priority,l;n!==0&&(l=n>>1,!(s[l].priority<a));)this._swap(n,l),n=l},t.prototype._swap=function(n,s){var a=this._arr,l=this._keyIndices,c=a[n],d=a[s];a[n]=d,a[s]=c,l[d.key]=n,l[c.key]=s},vy}var xy,Aj;function LA(){if(Aj)return xy;Aj=1;var e=Kn(),t=PA();xy=s;var n=e.constant(1);function s(l,c,d,h){return a(l,String(c),d||n,h||function(p){return l.outEdges(p)})}function a(l,c,d,h){var p={},f=new t,m,y,v=function(S){var _=S.v!==m?S.v:S.w,j=p[_],x=d(S),N=y.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+S+" Weight: "+x);N<j.distance&&(j.distance=N,j.predecessor=m,f.decrease(_,N))};for(l.nodes().forEach(function(S){var _=S===c?0:Number.POSITIVE_INFINITY;p[S]={distance:_},f.add(S,_)});f.size()>0&&(m=f.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(v);return p}return xy}var by,Rj;function cz(){if(Rj)return by;Rj=1;var e=LA(),t=Kn();by=n;function n(s,a,l){return t.transform(s.nodes(),function(c,d){c[d]=e(s,d,a,l)},{})}return by}var ky,Mj;function DA(){if(Mj)return ky;Mj=1;var e=Kn();ky=t;function t(n){var s=0,a=[],l={},c=[];function d(h){var p=l[h]={onStack:!0,lowlink:s,index:s++};if(a.push(h),n.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(d(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var f=[],m;do m=a.pop(),l[m].onStack=!1,f.push(m);while(h!==m);c.push(f)}}return n.nodes().forEach(function(h){e.has(l,h)||d(h)}),c}return ky}var _y,Ij;function uz(){if(Ij)return _y;Ij=1;var e=Kn(),t=DA();_y=n;function n(s){return e.filter(t(s),function(a){return a.length>1||a.length===1&&s.hasEdge(a[0],a[0])})}return _y}var Ny,$j;function dz(){if($j)return Ny;$j=1;var e=Kn();Ny=n;var t=e.constant(1);function n(a,l,c){return s(a,l||t,c||function(d){return a.outEdges(d)})}function s(a,l,c){var d={},h=a.nodes();return h.forEach(function(p){d[p]={},d[p][p]={distance:0},h.forEach(function(f){p!==f&&(d[p][f]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(f){var m=f.v===p?f.w:f.v,y=l(f);d[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var f=d[p];h.forEach(function(m){var y=d[m];h.forEach(function(v){var S=y[p],_=f[v],j=y[v],x=S.distance+_.distance;x<j.distance&&(j.distance=x,j.predecessor=_.predecessor)})})}),d}return Ny}var Sy,Oj;function qA(){if(Oj)return Sy;Oj=1;var e=Kn();Sy=t,t.CycleException=n;function t(s){var a={},l={},c=[];function d(h){if(e.has(l,h))throw new n;e.has(a,h)||(l[h]=!0,a[h]=!0,e.each(s.predecessors(h),d),delete l[h],c.push(h))}if(e.each(s.sinks(),d),e.size(a)!==s.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,Sy}var jy,Pj;function hz(){if(Pj)return jy;Pj=1;var e=qA();jy=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return jy}var Ey,Lj;function FA(){if(Lj)return Ey;Lj=1;var e=Kn();Ey=t;function t(s,a,l){e.isArray(a)||(a=[a]);var c=(s.isDirected()?s.successors:s.neighbors).bind(s),d=[],h={};return e.each(a,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,l==="post",h,c,d)}),d}function n(s,a,l,c,d,h){e.has(c,a)||(c[a]=!0,l||h.push(a),e.each(d(a),function(p){n(s,p,l,c,d,h)}),l&&h.push(a))}return Ey}var Cy,Dj;function fz(){if(Dj)return Cy;Dj=1;var e=FA();Cy=t;function t(n,s){return e(n,s,"post")}return Cy}var Ty,qj;function pz(){if(qj)return Ty;qj=1;var e=FA();Ty=t;function t(n,s){return e(n,s,"pre")}return Ty}var Ay,Fj;function mz(){if(Fj)return Ay;Fj=1;var e=Kn(),t=Fx(),n=PA();Ay=s;function s(a,l){var c=new t,d={},h=new n,p;function f(y){var v=y.v===p?y.w:y.v,S=h.priority(v);if(S!==void 0){var _=l(y);_<S&&(d[v]=p,h.decrease(v,_))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),h.decrease(a.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(d,p))c.setEdge(p,d[p]);else{if(m)throw new Error("Input graph is not connected: "+a);m=!0}a.nodeEdges(p).forEach(f)}return c}return Ay}var Ry,Bj;function gz(){return Bj||(Bj=1,Ry={components:lz(),dijkstra:LA(),dijkstraAll:cz(),findCycles:uz(),floydWarshall:dz(),isAcyclic:hz(),postorder:fz(),preorder:pz(),prim:mz(),tarjan:DA(),topsort:qA()}),Ry}var My,zj;function yz(){if(zj)return My;zj=1;var e=oz();return My={Graph:e.Graph,json:iz(),alg:gz(),version:e.version},My}var Iy,Uj;function mr(){if(Uj)return Iy;Uj=1;var e;if(typeof Nx=="function")try{e=yz()}catch{}return e||(e=window.graphlib),Iy=e,Iy}var $y,Wj;function wz(){if(Wj)return $y;Wj=1;var e=dA(),t=1,n=4;function s(a){return e(a,t|n)}return $y=s,$y}var Oy,Hj;function zd(){if(Hj)return Oy;Hj=1;var e=fi(),t=ls(),n=Id(),s=Yn();function a(l,c,d){if(!s(d))return!1;var h=typeof c;return(h=="number"?t(d)&&n(c,d.length):h=="string"&&c in d)?e(d[c],l):!1}return Oy=a,Oy}var Py,Gj;function vz(){if(Gj)return Py;Gj=1;var e=Bd(),t=fi(),n=zd(),s=Za(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(d,h){d=Object(d);var p=-1,f=h.length,m=f>2?h[2]:void 0;for(m&&n(h[0],h[1],m)&&(f=1);++p<f;)for(var y=h[p],v=s(y),S=-1,_=v.length;++S<_;){var j=v[S],x=d[j];(x===void 0||t(x,a[j])&&!l.call(d,j))&&(d[j]=y[j])}return d});return Py=c,Py}var Ly,Vj;function xz(){if(Vj)return Ly;Vj=1;var e=cs(),t=ls(),n=Xs();function s(a){return function(l,c,d){var h=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(m){return p(h[m],m,h)}}var f=a(l,c,d);return f>-1?h[p?l[f]:f]:void 0}}return Ly=s,Ly}var Dy,Yj;function bz(){if(Yj)return Dy;Yj=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Dy=t,Dy}var qy,Kj;function kz(){if(Kj)return qy;Kj=1;var e=bz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return qy=n,qy}var Fy,Xj;function _z(){if(Xj)return Fy;Xj=1;var e=kz(),t=Yn(),n=yi(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,d=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||c.test(p)?d(p.slice(2),m?2:8):a.test(p)?s:+p}return Fy=h,Fy}var By,Qj;function BA(){if(Qj)return By;Qj=1;var e=_z(),t=1/0,n=17976931348623157e292;function s(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var l=a<0?-1:1;return l*n}return a===a?a:0}return By=s,By}var zy,Zj;function Nz(){if(Zj)return zy;Zj=1;var e=BA();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return zy=t,zy}var Uy,Jj;function Sz(){if(Jj)return Uy;Jj=1;var e=IA(),t=cs(),n=Nz(),s=Math.max;function a(l,c,d){var h=l==null?0:l.length;if(!h)return-1;var p=d==null?0:n(d);return p<0&&(p=s(h+p,0)),e(l,t(c,3),p)}return Uy=a,Uy}var Wy,eE;function jz(){if(eE)return Wy;eE=1;var e=xz(),t=Sz(),n=e(t);return Wy=n,Wy}var Hy,tE;function zA(){if(tE)return Hy;tE=1;var e=qx();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Hy=t,Hy}var Gy,nE;function Ez(){if(nE)return Gy;nE=1;var e=Ox(),t=hA(),n=Za();function s(a,l){return a==null?a:e(a,t(l),n)}return Gy=s,Gy}var Vy,rE;function Cz(){if(rE)return Vy;rE=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Vy=e,Vy}var Yy,sE;function Tz(){if(sE)return Yy;sE=1;var e=Rd(),t=Px(),n=cs();function s(a,l){var c={};return l=n(l,3),t(a,function(d,h,p){e(c,h,l(d,h,p))}),c}return Yy=s,Yy}var Ky,aE;function Bx(){if(aE)return Ky;aE=1;var e=yi();function t(n,s,a){for(var l=-1,c=n.length;++l<c;){var d=n[l],h=s(d);if(h!=null&&(p===void 0?h===h&&!e(h):a(h,p)))var p=h,f=d}return f}return Ky=t,Ky}var Xy,oE;function Az(){if(oE)return Xy;oE=1;function e(t,n){return t>n}return Xy=e,Xy}var Qy,iE;function Rz(){if(iE)return Qy;iE=1;var e=Bx(),t=Az(),n=Ja();function s(a){return a&&a.length?e(a,n,t):void 0}return Qy=s,Qy}var Zy,lE;function UA(){if(lE)return Zy;lE=1;var e=Rd(),t=fi();function n(s,a,l){(l!==void 0&&!t(s[a],l)||l===void 0&&!(a in s))&&e(s,a,l)}return Zy=n,Zy}var Jy,cE;function Mz(){if(cE)return Jy;cE=1;var e=Xa(),t=Pd(),n=$r(),s="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,d=l.hasOwnProperty,h=c.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var m=t(f);if(m===null)return!0;var y=d.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==h}return Jy=p,Jy}var ew,uE;function WA(){if(uE)return ew;uE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return ew=e,ew}var tw,dE;function Iz(){if(dE)return tw;dE=1;var e=tc(),t=Za();function n(s){return e(s,t(s))}return tw=n,tw}var nw,hE;function $z(){if(hE)return nw;hE=1;var e=UA(),t=J2(),n=lA(),s=eA(),a=uA(),l=nc(),c=Mt(),d=$A(),h=mi(),p=ec(),f=Yn(),m=Mz(),y=rc(),v=WA(),S=Iz();function _(j,x,N,E,C,R,I){var $=v(j,N),B=v(x,N),O=I.get(B);if(O){e(j,N,O);return}var M=R?R($,B,N+"",j,x,I):void 0,L=M===void 0;if(L){var H=c(B),F=!H&&h(B),A=!H&&!F&&y(B);M=B,H||F||A?c($)?M=$:d($)?M=s($):F?(L=!1,M=t(B,!0)):A?(L=!1,M=n(B,!0)):M=[]:m(B)||l(B)?(M=$,l($)?M=S($):(!f($)||p($))&&(M=a(B))):L=!1}L&&(I.set(B,M),C(M,B,E,R,I),I.delete(B)),e(j,N,M)}return nw=_,nw}var rw,fE;function Oz(){if(fE)return rw;fE=1;var e=Ad(),t=UA(),n=Ox(),s=$z(),a=Yn(),l=Za(),c=WA();function d(h,p,f,m,y){h!==p&&n(p,function(v,S){if(y||(y=new e),a(v))s(h,p,S,f,d,m,y);else{var _=m?m(c(h,S),v,S+"",h,p,y):void 0;_===void 0&&(_=v),t(h,S,_)}},l)}return rw=d,rw}var sw,pE;function Pz(){if(pE)return sw;pE=1;var e=Bd(),t=zd();function n(s){return e(function(a,l){var c=-1,d=l.length,h=d>1?l[d-1]:void 0,p=d>2?l[2]:void 0;for(h=s.length>3&&typeof h=="function"?(d--,h):void 0,p&&t(l[0],l[1],p)&&(h=d<3?void 0:h,d=1),a=Object(a);++c<d;){var f=l[c];f&&s(a,f,c,h)}return a})}return sw=n,sw}var aw,mE;function Lz(){if(mE)return aw;mE=1;var e=Oz(),t=Pz(),n=t(function(s,a,l){e(s,a,l)});return aw=n,aw}var ow,gE;function HA(){if(gE)return ow;gE=1;function e(t,n){return t<n}return ow=e,ow}var iw,yE;function Dz(){if(yE)return iw;yE=1;var e=Bx(),t=HA(),n=Ja();function s(a){return a&&a.length?e(a,n,t):void 0}return iw=s,iw}var lw,wE;function qz(){if(wE)return lw;wE=1;var e=Bx(),t=cs(),n=HA();function s(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return lw=s,lw}var cw,vE;function Fz(){if(vE)return cw;vE=1;var e=yr(),t=function(){return e.Date.now()};return cw=t,cw}var uw,xE;function Bz(){if(xE)return uw;xE=1;var e=Md(),t=qd(),n=Id(),s=Yn(),a=sc();function l(c,d,h,p){if(!s(c))return c;d=t(d,c);for(var f=-1,m=d.length,y=m-1,v=c;v!=null&&++f<m;){var S=a(d[f]),_=h;if(S==="__proto__"||S==="constructor"||S==="prototype")return c;if(f!=y){var j=v[S];_=p?p(j,S,v):void 0,_===void 0&&(_=s(j)?j:n(d[f+1])?[]:{})}e(v,S,_),v=v[S]}return c}return uw=l,uw}var dw,bE;function zz(){if(bE)return dw;bE=1;var e=Fd(),t=Bz(),n=qd();function s(a,l,c){for(var d=-1,h=l.length,p={};++d<h;){var f=l[d],m=e(a,f);c(m,f)&&t(p,n(f,a),m)}return p}return dw=s,dw}var hw,kE;function Uz(){if(kE)return hw;kE=1;var e=zz(),t=_A();function n(s,a){return e(s,a,function(l,c){return t(s,c)})}return hw=n,hw}var fw,_E;function Wz(){if(_E)return fw;_E=1;var e=zA(),t=RA(),n=MA();function s(a){return n(t(a,void 0,e),a+"")}return fw=s,fw}var pw,NE;function Hz(){if(NE)return pw;NE=1;var e=Uz(),t=Wz(),n=t(function(s,a){return s==null?{}:e(s,a)});return pw=n,pw}var mw,SE;function Gz(){if(SE)return mw;SE=1;var e=Math.ceil,t=Math.max;function n(s,a,l,c){for(var d=-1,h=t(e((a-s)/(l||1)),0),p=Array(h);h--;)p[c?h:++d]=s,s+=l;return p}return mw=n,mw}var gw,jE;function Vz(){if(jE)return gw;jE=1;var e=Gz(),t=zd(),n=BA();function s(a){return function(l,c,d){return d&&typeof d!="number"&&t(l,c,d)&&(c=d=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),d=d===void 0?l<c?1:-1:n(d),e(l,c,d,a)}}return gw=s,gw}var yw,EE;function Yz(){if(EE)return yw;EE=1;var e=Vz(),t=e();return yw=t,yw}var ww,CE;function Kz(){if(CE)return ww;CE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return ww=e,ww}var vw,TE;function Xz(){if(TE)return vw;TE=1;var e=yi();function t(n,s){if(n!==s){var a=n!==void 0,l=n===null,c=n===n,d=e(n),h=s!==void 0,p=s===null,f=s===s,m=e(s);if(!p&&!m&&!d&&n>s||d&&h&&f&&!p&&!m||l&&h&&f||!a&&f||!c)return 1;if(!l&&!d&&!m&&n<s||m&&a&&c&&!l&&!d||p&&a&&c||!h&&c||!f)return-1}return 0}return vw=t,vw}var xw,AE;function Qz(){if(AE)return xw;AE=1;var e=Xz();function t(n,s,a){for(var l=-1,c=n.criteria,d=s.criteria,h=c.length,p=a.length;++l<h;){var f=e(c[l],d[l]);if(f){if(l>=p)return f;var m=a[l];return f*(m=="desc"?-1:1)}}return n.index-s.index}return xw=t,xw}var bw,RE;function Zz(){if(RE)return bw;RE=1;var e=Dd(),t=Fd(),n=cs(),s=CA(),a=Kz(),l=$d(),c=Qz(),d=Ja(),h=Mt();function p(f,m,y){m.length?m=e(m,function(_){return h(_)?function(j){return t(j,_.length===1?_[0]:_)}:_}):m=[d];var v=-1;m=e(m,l(n));var S=s(f,function(_,j,x){var N=e(m,function(E){return E(_)});return{criteria:N,index:++v,value:_}});return a(S,function(_,j){return c(_,j,y)})}return bw=p,bw}var kw,ME;function Jz(){if(ME)return kw;ME=1;var e=qx(),t=Zz(),n=Bd(),s=zd(),a=n(function(l,c){if(l==null)return[];var d=c.length;return d>1&&s(l,c[0],c[1])?c=[]:d>2&&s(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return kw=a,kw}var _w,IE;function eU(){if(IE)return _w;IE=1;var e=bA(),t=0;function n(s){var a=++t;return e(s)+a}return _w=n,_w}var Nw,$E;function tU(){if($E)return Nw;$E=1;function e(t,n,s){for(var a=-1,l=t.length,c=n.length,d={};++a<l;){var h=a<c?n[a]:void 0;s(d,t[a],h)}return d}return Nw=e,Nw}var Sw,OE;function nU(){if(OE)return Sw;OE=1;var e=Md(),t=tU();function n(s,a){return t(s||[],a||[],e)}return Sw=n,Sw}var jw,PE;function vt(){if(PE)return jw;PE=1;var e;if(typeof Nx=="function")try{e={cloneDeep:wz(),constant:$x(),defaults:vz(),each:pA(),filter:SA(),find:jz(),flatten:zA(),forEach:fA(),forIn:Ez(),has:jA(),isUndefined:EA(),last:Cz(),map:TA(),mapValues:Tz(),max:Rz(),merge:Lz(),min:Dz(),minBy:qz(),now:Fz(),pick:Hz(),range:Yz(),reduce:AA(),sortBy:Jz(),uniqueId:eU(),values:OA(),zipObject:nU()}}catch{}return e||(e=window._),jw=e,jw}var Ew,LE;function rU(){if(LE)return Ew;LE=1,Ew=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,a=s._prev;if(a!==s)return t(a),a},e.prototype.enqueue=function(s){var a=this._sentinel;s._prev&&s._next&&t(s),s._next=a._next,a._next._prev=s,a._next=s,s._prev=a},e.prototype.toString=function(){for(var s=[],a=this._sentinel,l=a._prev;l!==a;)s.push(JSON.stringify(l,n)),l=l._prev;return"["+s.join(", ")+"]"};function t(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function n(s,a){if(s!=="_next"&&s!=="_prev")return a}return Ew}var Cw,DE;function sU(){if(DE)return Cw;DE=1;var e=vt(),t=mr().Graph,n=rU();Cw=a;var s=e.constant(1);function a(p,f){if(p.nodeCount()<=1)return[];var m=d(p,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(v){return p.outEdges(v.v,v.w)}),!0)}function l(p,f,m){for(var y=[],v=f[f.length-1],S=f[0],_;p.nodeCount();){for(;_=S.dequeue();)c(p,f,m,_);for(;_=v.dequeue();)c(p,f,m,_);if(p.nodeCount()){for(var j=f.length-2;j>0;--j)if(_=f[j].dequeue(),_){y=y.concat(c(p,f,m,_,!0));break}}}return y}function c(p,f,m,y,v){var S=v?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var j=p.edge(_),x=p.node(_.v);v&&S.push({v:_.v,w:_.w}),x.out-=j,h(f,m,x)}),e.forEach(p.outEdges(y.v),function(_){var j=p.edge(_),x=_.w,N=p.node(x);N.in-=j,h(f,m,N)}),p.removeNode(y.v),S}function d(p,f){var m=new t,y=0,v=0;e.forEach(p.nodes(),function(j){m.setNode(j,{v:j,in:0,out:0})}),e.forEach(p.edges(),function(j){var x=m.edge(j.v,j.w)||0,N=f(j),E=x+N;m.setEdge(j.v,j.w,E),v=Math.max(v,m.node(j.v).out+=N),y=Math.max(y,m.node(j.w).in+=N)});var S=e.range(v+y+3).map(function(){return new n}),_=y+1;return e.forEach(m.nodes(),function(j){h(S,_,m.node(j))}),{graph:m,buckets:S,zeroIdx:_}}function h(p,f,m){m.out?m.in?p[m.out-m.in+f].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Cw}var Tw,qE;function aU(){if(qE)return Tw;qE=1;var e=vt(),t=sU();Tw={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,d(l)):s(l);e.forEach(c,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function d(h){return function(p){return h.edge(p).weight}}}function s(l){var c=[],d={},h={};function p(f){e.has(h,f)||(h[f]=!0,d[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(d,m.w)?c.push(m):p(m.w)}),delete d[f])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var d=l.edge(c);if(d.reversed){l.removeEdge(c);var h=d.forwardName;delete d.reversed,delete d.forwardName,l.setEdge(c.w,c.v,d,h)}})}return Tw}var Aw,FE;function vn(){if(FE)return Aw;FE=1;var e=vt(),t=mr().Graph;Aw={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:d,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:v,time:S,notime:_};function n(j,x,N,E){var C;do C=e.uniqueId(E);while(j.hasNode(C));return N.dummy=x,j.setNode(C,N),C}function s(j){var x=new t().setGraph(j.graph());return e.forEach(j.nodes(),function(N){x.setNode(N,j.node(N))}),e.forEach(j.edges(),function(N){var E=x.edge(N.v,N.w)||{weight:0,minlen:1},C=j.edge(N);x.setEdge(N.v,N.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),x}function a(j){var x=new t({multigraph:j.isMultigraph()}).setGraph(j.graph());return e.forEach(j.nodes(),function(N){j.children(N).length||x.setNode(N,j.node(N))}),e.forEach(j.edges(),function(N){x.setEdge(N,j.edge(N))}),x}function l(j){var x=e.map(j.nodes(),function(N){var E={};return e.forEach(j.outEdges(N),function(C){E[C.w]=(E[C.w]||0)+j.edge(C).weight}),E});return e.zipObject(j.nodes(),x)}function c(j){var x=e.map(j.nodes(),function(N){var E={};return e.forEach(j.inEdges(N),function(C){E[C.v]=(E[C.v]||0)+j.edge(C).weight}),E});return e.zipObject(j.nodes(),x)}function d(j,x){var N=j.x,E=j.y,C=x.x-N,R=x.y-E,I=j.width/2,$=j.height/2;if(!C&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var B,O;return Math.abs(R)*I>Math.abs(C)*$?(R<0&&($=-$),B=$*C/R,O=$):(C<0&&(I=-I),B=I,O=I*R/C),{x:N+B,y:E+O}}function h(j){var x=e.map(e.range(y(j)+1),function(){return[]});return e.forEach(j.nodes(),function(N){var E=j.node(N),C=E.rank;e.isUndefined(C)||(x[C][E.order]=N)}),x}function p(j){var x=e.min(e.map(j.nodes(),function(N){return j.node(N).rank}));e.forEach(j.nodes(),function(N){var E=j.node(N);e.has(E,"rank")&&(E.rank-=x)})}function f(j){var x=e.min(e.map(j.nodes(),function(R){return j.node(R).rank})),N=[];e.forEach(j.nodes(),function(R){var I=j.node(R).rank-x;N[I]||(N[I]=[]),N[I].push(R)});var E=0,C=j.graph().nodeRankFactor;e.forEach(N,function(R,I){e.isUndefined(R)&&I%C!==0?--E:E&&e.forEach(R,function($){j.node($).rank+=E})})}function m(j,x,N,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=N,C.order=E),n(j,"border",C,x)}function y(j){return e.max(e.map(j.nodes(),function(x){var N=j.node(x).rank;if(!e.isUndefined(N))return N}))}function v(j,x){var N={lhs:[],rhs:[]};return e.forEach(j,function(E){x(E)?N.lhs.push(E):N.rhs.push(E)}),N}function S(j,x){var N=e.now();try{return x()}finally{console.log(j+" time: "+(e.now()-N)+"ms")}}function _(j,x){return x()}return Aw}var Rw,BE;function oU(){if(BE)return Rw;BE=1;var e=vt(),t=vn();Rw={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){s(l,c)})}function s(l,c){var d=c.v,h=l.node(d).rank,p=c.w,f=l.node(p).rank,m=c.name,y=l.edge(c),v=y.labelRank;if(f!==h+1){l.removeEdge(c);var S,_,j;for(j=0,++h;h<f;++j,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:c,rank:h},S=t.addDummyNode(l,"edge",_,"_d"),h===v&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(d,S,{weight:y.weight},m),j===0&&l.graph().dummyChains.push(S),d=S;l.setEdge(d,p,{weight:y.weight},m)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var d=l.node(c),h=d.edgeLabel,p;for(l.setEdge(d.edgeObj,h);d.dummy;)p=l.successors(c)[0],l.removeNode(c),h.points.push({x:d.x,y:d.y}),d.dummy==="edge-label"&&(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height),c=p,d=l.node(c)})}return Rw}var Mw,zE;function dd(){if(zE)return Mw;zE=1;var e=vt();Mw={longestPath:t,slack:n};function t(s){var a={};function l(c){var d=s.node(c);if(e.has(a,c))return d.rank;a[c]=!0;var h=e.min(e.map(s.outEdges(c),function(p){return l(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),d.rank=h}e.forEach(s.sources(),l)}function n(s,a){return s.node(a.w).rank-s.node(a.v).rank-s.edge(a).minlen}return Mw}var Iw,UE;function GA(){if(UE)return Iw;UE=1;var e=vt(),t=mr().Graph,n=dd().slack;Iw=s;function s(d){var h=new t({directed:!1}),p=d.nodes()[0],f=d.nodeCount();h.setNode(p,{});for(var m,y;a(h,d)<f;)m=l(h,d),y=h.hasNode(m.v)?n(d,m):-n(d,m),c(h,d,y);return h}function a(d,h){function p(f){e.forEach(h.nodeEdges(f),function(m){var y=m.v,v=f===y?m.w:y;!d.hasNode(v)&&!n(h,m)&&(d.setNode(v,{}),d.setEdge(f,v,{}),p(v))})}return e.forEach(d.nodes(),p),d.nodeCount()}function l(d,h){return e.minBy(h.edges(),function(p){if(d.hasNode(p.v)!==d.hasNode(p.w))return n(h,p)})}function c(d,h,p){e.forEach(d.nodes(),function(f){h.node(f).rank+=p})}return Iw}var $w,WE;function iU(){if(WE)return $w;WE=1;var e=vt(),t=GA(),n=dd().slack,s=dd().longestPath,a=mr().alg.preorder,l=mr().alg.postorder,c=vn().simplify;$w=d,d.initLowLimValues=m,d.initCutValues=h,d.calcCutValue=f,d.leaveEdge=v,d.enterEdge=S,d.exchangeEdges=_;function d(E){E=c(E),s(E);var C=t(E);m(C),h(C,E);for(var R,I;R=v(C);)I=S(C,E,R),_(C,E,R,I)}function h(E,C){var R=l(E,E.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){p(E,C,I)})}function p(E,C,R){var I=E.node(R),$=I.parent;E.edge(R,$).cutvalue=f(E,C,R)}function f(E,C,R){var I=E.node(R),$=I.parent,B=!0,O=C.edge(R,$),M=0;return O||(B=!1,O=C.edge($,R)),M=O.weight,e.forEach(C.nodeEdges(R),function(L){var H=L.v===R,F=H?L.w:L.v;if(F!==$){var A=H===B,Q=C.edge(L).weight;if(M+=A?Q:-Q,x(E,R,F)){var K=E.edge(R,F).cutvalue;M+=A?-K:K}}}),M}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,$){var B=R,O=E.node(I);return C[I]=!0,e.forEach(E.neighbors(I),function(M){e.has(C,M)||(R=y(E,C,R,M,I))}),O.low=B,O.lim=R++,$?O.parent=$:delete O.parent,R}function v(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function S(E,C,R){var I=R.v,$=R.w;C.hasEdge(I,$)||(I=R.w,$=R.v);var B=E.node(I),O=E.node($),M=B,L=!1;B.lim>O.lim&&(M=O,L=!0);var H=e.filter(C.edges(),function(F){return L===N(E,E.node(F.v),M)&&L!==N(E,E.node(F.w),M)});return e.minBy(H,function(F){return n(C,F)})}function _(E,C,R,I){var $=R.v,B=R.w;E.removeEdge($,B),E.setEdge(I.v,I.w,{}),m(E),h(E,C),j(E,C)}function j(E,C){var R=e.find(E.nodes(),function($){return!C.node($).parent}),I=a(E,R);I=I.slice(1),e.forEach(I,function($){var B=E.node($).parent,O=C.edge($,B),M=!1;O||(O=C.edge(B,$),M=!0),C.node($).rank=C.node(B).rank+(M?O.minlen:-O.minlen)})}function x(E,C,R){return E.hasEdge(C,R)}function N(E,C,R){return R.low<=C.lim&&C.lim<=R.lim}return $w}var Ow,HE;function lU(){if(HE)return Ow;HE=1;var e=dd(),t=e.longestPath,n=GA(),s=iU();Ow=a;function a(h){switch(h.graph().ranker){case"network-simplex":d(h);break;case"tight-tree":c(h);break;case"longest-path":l(h);break;default:d(h)}}var l=t;function c(h){t(h),n(h)}function d(h){s(h)}return Ow}var Pw,GE;function cU(){if(GE)return Pw;GE=1;var e=vt();Pw=t;function t(a){var l=s(a);e.forEach(a.graph().dummyChains,function(c){for(var d=a.node(c),h=d.edgeObj,p=n(a,l,h.v,h.w),f=p.path,m=p.lca,y=0,v=f[y],S=!0;c!==h.w;){if(d=a.node(c),S){for(;(v=f[y])!==m&&a.node(v).maxRank<d.rank;)y++;v===m&&(S=!1)}if(!S){for(;y<f.length-1&&a.node(v=f[y+1]).minRank<=d.rank;)y++;v=f[y]}a.setParent(c,v),c=a.successors(c)[0]}})}function n(a,l,c,d){var h=[],p=[],f=Math.min(l[c].low,l[d].low),m=Math.max(l[c].lim,l[d].lim),y,v;y=c;do y=a.parent(y),h.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(v=y,y=d;(y=a.parent(y))!==v;)p.push(y);return{path:h.concat(p.reverse()),lca:v}}function s(a){var l={},c=0;function d(h){var p=c;e.forEach(a.children(h),d),l[h]={low:p,lim:c++}}return e.forEach(a.children(),d),l}return Pw}var Lw,VE;function uU(){if(VE)return Lw;VE=1;var e=vt(),t=vn();Lw={run:n,cleanup:c};function n(d){var h=t.addDummyNode(d,"root",{},"_root"),p=a(d),f=e.max(e.values(p))-1,m=2*f+1;d.graph().nestingRoot=h,e.forEach(d.edges(),function(v){d.edge(v).minlen*=m});var y=l(d)+1;e.forEach(d.children(),function(v){s(d,h,m,y,f,p,v)}),d.graph().nodeRankFactor=m}function s(d,h,p,f,m,y,v){var S=d.children(v);if(!S.length){v!==h&&d.setEdge(h,v,{weight:0,minlen:p});return}var _=t.addBorderNode(d,"_bt"),j=t.addBorderNode(d,"_bb"),x=d.node(v);d.setParent(_,v),x.borderTop=_,d.setParent(j,v),x.borderBottom=j,e.forEach(S,function(N){s(d,h,p,f,m,y,N);var E=d.node(N),C=E.borderTop?E.borderTop:N,R=E.borderBottom?E.borderBottom:N,I=E.borderTop?f:2*f,$=C!==R?1:m-y[v]+1;d.setEdge(_,C,{weight:I,minlen:$,nestingEdge:!0}),d.setEdge(R,j,{weight:I,minlen:$,nestingEdge:!0})}),d.parent(v)||d.setEdge(h,_,{weight:0,minlen:m+y[v]})}function a(d){var h={};function p(f,m){var y=d.children(f);y&&y.length&&e.forEach(y,function(v){p(v,m+1)}),h[f]=m}return e.forEach(d.children(),function(f){p(f,1)}),h}function l(d){return e.reduce(d.edges(),function(h,p){return h+d.edge(p).weight},0)}function c(d){var h=d.graph();d.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(d.edges(),function(p){var f=d.edge(p);f.nestingEdge&&d.removeEdge(p)})}return Lw}var Dw,YE;function dU(){if(YE)return Dw;YE=1;var e=vt(),t=vn();Dw=n;function n(a){function l(c){var d=a.children(c),h=a.node(c);if(d.length&&e.forEach(d,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(a,"borderLeft","_bl",c,h,p),s(a,"borderRight","_br",c,h,p)}}e.forEach(a.children(),l)}function s(a,l,c,d,h,p){var f={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=t.addDummyNode(a,"border",f,c);h[l][p]=y,a.setParent(y,d),m&&a.setEdge(m,y,{weight:1})}return Dw}var qw,KE;function hU(){if(KE)return qw;KE=1;var e=vt();qw={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(p),(f==="lr"||f==="rl")&&(d(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){a(p.node(f))}),e.forEach(p.edges(),function(f){a(p.edge(f))})}function a(p){var f=p.width;p.width=p.height,p.height=f}function l(p){e.forEach(p.nodes(),function(f){c(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,c),e.has(m,"y")&&c(m)})}function c(p){p.y=-p.y}function d(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return qw}var Fw,XE;function fU(){if(XE)return Fw;XE=1;var e=vt();Fw=t;function t(n){var s={},a=e.filter(n.nodes(),function(p){return!n.children(p).length}),l=e.max(e.map(a,function(p){return n.node(p).rank})),c=e.map(e.range(l+1),function(){return[]});function d(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);c[f.rank].push(p),e.forEach(n.successors(p),d)}}var h=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(h,d),c}return Fw}var Bw,QE;function pU(){if(QE)return Bw;QE=1;var e=vt();Bw=t;function t(s,a){for(var l=0,c=1;c<a.length;++c)l+=n(s,a[c-1],a[c]);return l}function n(s,a,l){for(var c=e.zipObject(l,e.map(l,function(y,v){return v})),d=e.flatten(e.map(a,function(y){return e.sortBy(e.map(s.outEdges(y),function(v){return{pos:c[v.w],weight:s.edge(v).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(d.forEach(function(y){var v=y.pos+h;f[v]+=y.weight;for(var S=0;v>0;)v%2&&(S+=f[v+1]),v=v-1>>1,f[v]+=y.weight;m+=y.weight*S})),m}return Bw}var zw,ZE;function mU(){if(ZE)return zw;ZE=1;var e=vt();zw=t;function t(n,s){return e.map(s,function(a){var l=n.inEdges(a);if(l.length){var c=e.reduce(l,function(d,h){var p=n.edge(h),f=n.node(h.v);return{sum:d.sum+p.weight*f.order,weight:d.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return zw}var Uw,JE;function gU(){if(JE)return Uw;JE=1;var e=vt();Uw=t;function t(a,l){var c={};e.forEach(a,function(h,p){var f=c[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=c[h.v],f=c[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(c[h.w]))});var d=e.filter(c,function(h){return!h.indegree});return n(d)}function n(a){var l=[];function c(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function d(p){return function(f){f.in.push(p),--f.indegree===0&&a.push(f)}}for(;a.length;){var h=a.pop();l.push(h),e.forEach(h.in.reverse(),c(h)),e.forEach(h.out,d(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(a,l){var c=0,d=0;a.weight&&(c+=a.barycenter*a.weight,d+=a.weight),l.weight&&(c+=l.barycenter*l.weight,d+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/d,a.weight=d,a.i=Math.min(l.i,a.i),l.merged=!0}return Uw}var Ww,eC;function yU(){if(eC)return Ww;eC=1;var e=vt(),t=vn();Ww=n;function n(l,c){var d=t.partition(l,function(_){return e.has(_,"barycenter")}),h=d.lhs,p=e.sortBy(d.rhs,function(_){return-_.i}),f=[],m=0,y=0,v=0;h.sort(a(!!c)),v=s(f,p,v),e.forEach(h,function(_){v+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,v=s(f,p,v)});var S={vs:e.flatten(f,!0)};return y&&(S.barycenter=m/y,S.weight=y),S}function s(l,c,d){for(var h;c.length&&(h=e.last(c)).i<=d;)c.pop(),l.push(h.vs),d++;return d}function a(l){return function(c,d){return c.barycenter<d.barycenter?-1:c.barycenter>d.barycenter?1:l?d.i-c.i:c.i-d.i}}return Ww}var Hw,tC;function wU(){if(tC)return Hw;tC=1;var e=vt(),t=mU(),n=gU(),s=yU();Hw=a;function a(d,h,p,f){var m=d.children(h),y=d.node(h),v=y?y.borderLeft:void 0,S=y?y.borderRight:void 0,_={};v&&(m=e.filter(m,function(R){return R!==v&&R!==S}));var j=t(d,m);e.forEach(j,function(R){if(d.children(R.v).length){var I=a(d,R.v,p,f);_[R.v]=I,e.has(I,"barycenter")&&c(R,I)}});var x=n(j,p);l(x,_);var N=s(x,f);if(v&&(N.vs=e.flatten([v,N.vs,S],!0),d.predecessors(v).length)){var E=d.node(d.predecessors(v)[0]),C=d.node(d.predecessors(S)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+E.order+C.order)/(N.weight+2),N.weight+=2}return N}function l(d,h){e.forEach(d,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function c(d,h){e.isUndefined(d.barycenter)?(d.barycenter=h.barycenter,d.weight=h.weight):(d.barycenter=(d.barycenter*d.weight+h.barycenter*h.weight)/(d.weight+h.weight),d.weight+=h.weight)}return Hw}var Gw,nC;function vU(){if(nC)return Gw;nC=1;var e=vt(),t=mr().Graph;Gw=n;function n(a,l,c){var d=s(a),h=new t({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var f=a.node(p),m=a.parent(p);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(h.setNode(p),h.setParent(p,m||d),e.forEach(a[c](p),function(y){var v=y.v===p?y.w:y.v,S=h.edge(v,p),_=e.isUndefined(S)?0:S.weight;h.setEdge(v,p,{weight:a.edge(y).weight+_})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),h}function s(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return Gw}var Vw,rC;function xU(){if(rC)return Vw;rC=1;var e=vt();Vw=t;function t(n,s,a){var l={},c;e.forEach(a,function(d){for(var h=n.parent(d),p,f;h;){if(p=n.parent(h),p?(f=l[p],l[p]=h):(f=c,c=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return Vw}var Yw,sC;function bU(){if(sC)return Yw;sC=1;var e=vt(),t=fU(),n=pU(),s=wU(),a=vU(),l=xU(),c=mr().Graph,d=vn();Yw=h;function h(y){var v=d.maxRank(y),S=p(y,e.range(1,v+1),"inEdges"),_=p(y,e.range(v-1,-1,-1),"outEdges"),j=t(y);m(y,j);for(var x=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){f(E%2?S:_,E%4>=2),j=d.buildLayerMatrix(y);var R=n(y,j);R<x&&(C=0,N=e.cloneDeep(j),x=R)}m(y,N)}function p(y,v,S){return e.map(v,function(_){return a(y,_,S)})}function f(y,v){var S=new c;e.forEach(y,function(_){var j=_.graph().root,x=s(_,j,S,v);e.forEach(x.vs,function(N,E){_.node(N).order=E}),l(_,S,x.vs)})}function m(y,v){e.forEach(v,function(S){e.forEach(S,function(_,j){y.node(_).order=j})})}return Yw}var Kw,aC;function kU(){if(aC)return Kw;aC=1;var e=vt(),t=mr().Graph,n=vn();Kw={positionX:S,findType1Conflicts:s,findType2Conflicts:a,addConflict:c,hasConflict:d,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:v};function s(x,N){var E={};function C(R,I){var $=0,B=0,O=R.length,M=e.last(I);return e.forEach(I,function(L,H){var F=l(x,L),A=F?x.node(F).order:O;(F||L===M)&&(e.forEach(I.slice(B,H+1),function(Q){e.forEach(x.predecessors(Q),function(K){var ee=x.node(K),Z=ee.order;(Z<$||A<Z)&&!(ee.dummy&&x.node(Q).dummy)&&c(E,K,Q)})}),B=H+1,$=A)}),I}return e.reduce(N,C),E}function a(x,N){var E={};function C(I,$,B,O,M){var L;e.forEach(e.range($,B),function(H){L=I[H],x.node(L).dummy&&e.forEach(x.predecessors(L),function(F){var A=x.node(F);A.dummy&&(A.order<O||A.order>M)&&c(E,F,L)})})}function R(I,$){var B=-1,O,M=0;return e.forEach($,function(L,H){if(x.node(L).dummy==="border"){var F=x.predecessors(L);F.length&&(O=x.node(F[0]).order,C($,M,H,B,O),M=H,B=O)}C($,M,$.length,O,I.length)}),$}return e.reduce(N,R),E}function l(x,N){if(x.node(N).dummy)return e.find(x.predecessors(N),function(E){return x.node(E).dummy})}function c(x,N,E){if(N>E){var C=N;N=E,E=C}var R=x[N];R||(x[N]=R={}),R[E]=!0}function d(x,N,E){if(N>E){var C=N;N=E,E=C}return e.has(x[N],E)}function h(x,N,E,C){var R={},I={},$={};return e.forEach(N,function(B){e.forEach(B,function(O,M){R[O]=O,I[O]=O,$[O]=M})}),e.forEach(N,function(B){var O=-1;e.forEach(B,function(M){var L=C(M);if(L.length){L=e.sortBy(L,function(K){return $[K]});for(var H=(L.length-1)/2,F=Math.floor(H),A=Math.ceil(H);F<=A;++F){var Q=L[F];I[M]===M&&O<$[Q]&&!d(E,M,Q)&&(I[Q]=M,I[M]=R[M]=R[Q],O=$[Q])}}})}),{root:R,align:I}}function p(x,N,E,C,R){var I={},$=f(x,N,E,R),B=R?"borderLeft":"borderRight";function O(H,F){for(var A=$.nodes(),Q=A.pop(),K={};Q;)K[Q]?H(Q):(K[Q]=!0,A.push(Q),A=A.concat(F(Q))),Q=A.pop()}function M(H){I[H]=$.inEdges(H).reduce(function(F,A){return Math.max(F,I[A.v]+$.edge(A))},0)}function L(H){var F=$.outEdges(H).reduce(function(Q,K){return Math.min(Q,I[K.w]-$.edge(K))},Number.POSITIVE_INFINITY),A=x.node(H);F!==Number.POSITIVE_INFINITY&&A.borderType!==B&&(I[H]=Math.max(I[H],F))}return O(M,$.predecessors.bind($)),O(L,$.successors.bind($)),e.forEach(C,function(H){I[H]=I[E[H]]}),I}function f(x,N,E,C){var R=new t,I=x.graph(),$=_(I.nodesep,I.edgesep,C);return e.forEach(N,function(B){var O;e.forEach(B,function(M){var L=E[M];if(R.setNode(L),O){var H=E[O],F=R.edge(H,L);R.setEdge(H,L,Math.max($(x,M,O),F||0))}O=M})}),R}function m(x,N){return e.minBy(e.values(N),function(E){var C=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(E,function(I,$){var B=j(x,$)/2;C=Math.max(I+B,C),R=Math.min(I-B,R)}),C-R})}function y(x,N){var E=e.values(N),C=e.min(E),R=e.max(E);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function($){var B=I+$,O=x[B],M;if(O!==N){var L=e.values(O);M=$==="l"?C-e.min(L):R-e.max(L),M&&(x[B]=e.mapValues(O,function(H){return H+M}))}})})}function v(x,N){return e.mapValues(x.ul,function(E,C){if(N)return x[N.toLowerCase()][C];var R=e.sortBy(e.map(x,C));return(R[1]+R[2])/2})}function S(x){var N=n.buildLayerMatrix(x),E=e.merge(s(x,N),a(x,N)),C={},R;e.forEach(["u","d"],function($){R=$==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(R=e.map(R,function(H){return e.values(H).reverse()}));var O=($==="u"?x.predecessors:x.successors).bind(x),M=h(x,R,E,O),L=p(x,R,M.root,M.align,B==="r");B==="r"&&(L=e.mapValues(L,function(H){return-H})),C[$+B]=L})});var I=m(x,C);return y(C,I),v(C,x.graph().align)}function _(x,N,E){return function(C,R,I){var $=C.node(R),B=C.node(I),O=0,M;if(O+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":M=-$.width/2;break;case"r":M=$.width/2;break}if(M&&(O+=E?M:-M),M=0,O+=($.dummy?N:x)/2,O+=(B.dummy?N:x)/2,O+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":M=B.width/2;break;case"r":M=-B.width/2;break}return M&&(O+=E?M:-M),M=0,O}}function j(x,N){return x.node(N).width}return Kw}var Xw,oC;function _U(){if(oC)return Xw;oC=1;var e=vt(),t=vn(),n=kU().positionX;Xw=s;function s(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,d){l.node(d).x=c})}function a(l){var c=t.buildLayerMatrix(l),d=l.graph().ranksep,h=0;e.forEach(c,function(p){var f=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+f/2}),h+=f+d})}return Xw}var Qw,iC;function NU(){if(iC)return Qw;iC=1;var e=vt(),t=aU(),n=oU(),s=lU(),a=vn().normalizeRanks,l=cU(),c=vn().removeEmptyRanks,d=uU(),h=dU(),p=hU(),f=bU(),m=_U(),y=vn(),v=mr().Graph;Qw=S;function S(W,U){var J=U&&U.debugTiming?y.time:y.notime;J("layout",function(){var V=J(" buildLayoutGraph",function(){return O(W)});J(" runLayout",function(){_(V,J)}),J(" updateInputGraph",function(){j(W,V)})})}function _(W,U){U(" makeSpaceForEdgeLabels",function(){M(W)}),U(" removeSelfEdges",function(){D(W)}),U(" acyclic",function(){t.run(W)}),U(" nestingGraph.run",function(){d.run(W)}),U(" rank",function(){s(y.asNonCompoundGraph(W))}),U(" injectEdgeLabelProxies",function(){L(W)}),U(" removeEmptyRanks",function(){c(W)}),U(" nestingGraph.cleanup",function(){d.cleanup(W)}),U(" normalizeRanks",function(){a(W)}),U(" assignRankMinMax",function(){H(W)}),U(" removeEdgeLabelProxies",function(){F(W)}),U(" normalize.run",function(){n.run(W)}),U(" parentDummyChains",function(){l(W)}),U(" addBorderSegments",function(){h(W)}),U(" order",function(){f(W)}),U(" insertSelfEdges",function(){Y(W)}),U(" adjustCoordinateSystem",function(){p.adjust(W)}),U(" position",function(){m(W)}),U(" positionSelfEdges",function(){P(W)}),U(" removeBorderNodes",function(){Z(W)}),U(" normalize.undo",function(){n.undo(W)}),U(" fixupEdgeLabelCoords",function(){K(W)}),U(" undoCoordinateSystem",function(){p.undo(W)}),U(" translateGraph",function(){A(W)}),U(" assignNodeIntersects",function(){Q(W)}),U(" reversePoints",function(){ee(W)}),U(" acyclic.undo",function(){t.undo(W)})}function j(W,U){e.forEach(W.nodes(),function(J){var V=W.node(J),ie=U.node(J);V&&(V.x=ie.x,V.y=ie.y,U.children(J).length&&(V.width=ie.width,V.height=ie.height))}),e.forEach(W.edges(),function(J){var V=W.edge(J),ie=U.edge(J);V.points=ie.points,e.has(ie,"x")&&(V.x=ie.x,V.y=ie.y)}),W.graph().width=U.graph().width,W.graph().height=U.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],$={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function O(W){var U=new v({multigraph:!0,compound:!0}),J=de(W.graph());return U.setGraph(e.merge({},N,G(J,x),e.pick(J,E))),e.forEach(W.nodes(),function(V){var ie=de(W.node(V));U.setNode(V,e.defaults(G(ie,C),R)),U.setParent(V,W.parent(V))}),e.forEach(W.edges(),function(V){var ie=de(W.edge(V));U.setEdge(V,e.merge({},$,G(ie,I),e.pick(ie,B)))}),U}function M(W){var U=W.graph();U.ranksep/=2,e.forEach(W.edges(),function(J){var V=W.edge(J);V.minlen*=2,V.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?V.width+=V.labeloffset:V.height+=V.labeloffset)})}function L(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(J.width&&J.height){var V=W.node(U.v),ie=W.node(U.w),pe={rank:(ie.rank-V.rank)/2+V.rank,e:U};y.addDummyNode(W,"edge-proxy",pe,"_ep")}})}function H(W){var U=0;e.forEach(W.nodes(),function(J){var V=W.node(J);V.borderTop&&(V.minRank=W.node(V.borderTop).rank,V.maxRank=W.node(V.borderBottom).rank,U=e.max(U,V.maxRank))}),W.graph().maxRank=U}function F(W){e.forEach(W.nodes(),function(U){var J=W.node(U);J.dummy==="edge-proxy"&&(W.edge(J.e).labelRank=J.rank,W.removeNode(U))})}function A(W){var U=Number.POSITIVE_INFINITY,J=0,V=Number.POSITIVE_INFINITY,ie=0,pe=W.graph(),me=pe.marginx||0,Ie=pe.marginy||0;function Le(ce){var xe=ce.x,ye=ce.y,ze=ce.width,ke=ce.height;U=Math.min(U,xe-ze/2),J=Math.max(J,xe+ze/2),V=Math.min(V,ye-ke/2),ie=Math.max(ie,ye+ke/2)}e.forEach(W.nodes(),function(ce){Le(W.node(ce))}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.has(xe,"x")&&Le(xe)}),U-=me,V-=Ie,e.forEach(W.nodes(),function(ce){var xe=W.node(ce);xe.x-=U,xe.y-=V}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.forEach(xe.points,function(ye){ye.x-=U,ye.y-=V}),e.has(xe,"x")&&(xe.x-=U),e.has(xe,"y")&&(xe.y-=V)}),pe.width=J-U+me,pe.height=ie-V+Ie}function Q(W){e.forEach(W.edges(),function(U){var J=W.edge(U),V=W.node(U.v),ie=W.node(U.w),pe,me;J.points?(pe=J.points[0],me=J.points[J.points.length-1]):(J.points=[],pe=ie,me=V),J.points.unshift(y.intersectRect(V,pe)),J.points.push(y.intersectRect(ie,me))})}function K(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(e.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function ee(W){e.forEach(W.edges(),function(U){var J=W.edge(U);J.reversed&&J.points.reverse()})}function Z(W){e.forEach(W.nodes(),function(U){if(W.children(U).length){var J=W.node(U),V=W.node(J.borderTop),ie=W.node(J.borderBottom),pe=W.node(e.last(J.borderLeft)),me=W.node(e.last(J.borderRight));J.width=Math.abs(me.x-pe.x),J.height=Math.abs(ie.y-V.y),J.x=pe.x+J.width/2,J.y=V.y+J.height/2}}),e.forEach(W.nodes(),function(U){W.node(U).dummy==="border"&&W.removeNode(U)})}function D(W){e.forEach(W.edges(),function(U){if(U.v===U.w){var J=W.node(U.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:U,label:W.edge(U)}),W.removeEdge(U)}})}function Y(W){var U=y.buildLayerMatrix(W);e.forEach(U,function(J){var V=0;e.forEach(J,function(ie,pe){var me=W.node(ie);me.order=pe+V,e.forEach(me.selfEdges,function(Ie){y.addDummyNode(W,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:me.rank,order:pe+ ++V,e:Ie.e,label:Ie.label},"_se")}),delete me.selfEdges})})}function P(W){e.forEach(W.nodes(),function(U){var J=W.node(U);if(J.dummy==="selfedge"){var V=W.node(J.e.v),ie=V.x+V.width/2,pe=V.y,me=J.x-ie,Ie=V.height/2;W.setEdge(J.e,J.label),W.removeNode(U),J.label.points=[{x:ie+2*me/3,y:pe-Ie},{x:ie+5*me/6,y:pe-Ie},{x:ie+me,y:pe},{x:ie+5*me/6,y:pe+Ie},{x:ie+2*me/3,y:pe+Ie}],J.label.x=J.x,J.label.y=J.y}})}function G(W,U){return e.mapValues(e.pick(W,U),Number)}function de(W){var U={};return e.forEach(W,function(J,V){U[V.toLowerCase()]=J}),U}return Qw}var Zw,lC;function SU(){if(lC)return Zw;lC=1;var e=vt(),t=vn(),n=mr().Graph;Zw={debugOrdering:s};function s(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(d){c.setNode(d,{label:d}),c.setParent(d,"layer"+a.node(d).rank)}),e.forEach(a.edges(),function(d){c.setEdge(d.v,d.w,{},d.name)}),e.forEach(l,function(d,h){var p="layer"+h;c.setNode(p,{rank:"same"}),e.reduce(d,function(f,m){return c.setEdge(f,m,{style:"invis"}),m})}),c}return Zw}var Jw,cC;function jU(){return cC||(cC=1,Jw="0.8.5"),Jw}var ev,uC;function EU(){return uC||(uC=1,ev={graphlib:mr(),layout:NU(),debug:SU(),util:{time:vn().time,notime:vn().notime},version:jU()}),ev}var CU=EU();const dC=Bv(CU),ui=240,hd=130,ti=74,Ud=72,hC=ti+Ud;function TU(e,t){var s;let n=ui;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??ui);return n}const VA=420,AU=2;function Bl(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function RU(e,t){return((t==null?void 0:t.get(e))??0)>0?VA:0}function MU(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function zl(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??ui)+RU(e,n),h:Math.max((s==null?void 0:s.height)??hd,MU(e,n))}}function IU(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function $U(e,t,n,s,a,l){const c=new dC.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const d=e.filter(x=>!a.has(x)),h=new Set(d);for(const x of d){const{w:N,h:E}=zl(x,s,l);c.setNode(x,{width:N,height:E})}for(const x of t)h.has(x.source)&&h.has(x.target)&&c.setEdge(x.source,x.target);dC.layout(c);const p=new Map;let f=1/0,m=1/0,y=-1/0,v=-1/0;for(const x of d){const N=c.node(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ui,R=(E==null?void 0:E.height)??hd,I=zl(x,s,l),$=N.x-I.w/2,B=N.y-I.h/2;p.set(x,{x:$,y:B}),$<f&&(f=$),B<m&&(m=B),$+C>y&&(y=$+C),B+R>v&&(v=B+R)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[x,N]of p)p.set(x,{x:N.x-f,y:N.y-m});const S=Number.isFinite(y)?y-f:0,_=Number.isFinite(v)?v-m:0;let j=null;for(const x of e){const N=a.get(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ui,R=(E==null?void 0:E.height)??hd;j=j===null?{minX:N.x,minY:N.y,maxX:N.x+C,maxY:N.y+R}:{minX:Math.min(j.minX,N.x),minY:Math.min(j.minY,N.y),maxX:Math.max(j.maxX,N.x+C),maxY:Math.max(j.maxY,N.y+R)}}return{positions:p,width:S,height:_,pinnedBox:j}}function OU(e,t,n={}){const s=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,d=new Map;for(const x of e){const N=Bl(x),E=d.get(N);E?E.push(x.id):d.set(N,[x.id])}const p=Array.from(d.keys()).sort().map(x=>({sid:x,...$U(d.get(x),t,s,l,a,c)})),f=TU(e,l),m=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,y=x=>{const N=[[]];let E=0;for(const C of p)N.length<x&&E>0&&E+C.height>m&&(N.push([]),E=0),N[N.length-1].push(C),E+=C.height+hC;return N},v=x=>x.reduce((N,E)=>Math.max(N,E.width),0)+VA;let S=y(n.availableWidth?AU:1);S.length>1&&S.reduce((N,E)=>N+v(E),0)+f*(S.length-1)>(n.availableWidth??0)&&(S=y(1));const _=new Map;let j=0;for(const x of S){const N=v(x);let E=0;for(const{positions:C,height:R,pinnedBox:I}of x){for(const[B,O]of C)_.set(B,{x:O.x+j,y:O.y+E});let $=E+R;I&&I.maxY>$&&I.minX<j+N&&j<I.maxX&&($=I.maxY),E=$+hC}j+=N+f}return e.map(x=>{const N=a.get(x.id);if(N)return{...x,position:N};const E=_.get(x.id);return E?{...x,position:E}:x})}function PU(e,t,n,s,a){const c=ti+Ud,d=60,h=v=>zl(v,s,a),p=new Map(e.map(v=>[v.id,Bl(v)])),f=[],m=e.map(v=>({id:v.id,pos:n.get(v.id)??t.get(v.id)})).filter(v=>v.pos!=null).sort((v,S)=>v.pos.y-S.pos.y||v.pos.x-S.pos.x||v.id.localeCompare(S.id)),y=[];for(const{id:v,pos:S}of m){const{w:_,h:j}=h(v),x=p.get(v)??"_default";if(n.has(v)){f.push({x:S.x,y:S.y,w:_,h:j,sid:x});continue}let N=S.y;for(let E=0;E<f.length+1;E++){const C=f.find(R=>{const I=R.sid===x?24:d,$=R.sid===x?24:c;return S.x<R.x+R.w+I&&R.x<S.x+_+I&&N<R.y+R.h+$&&R.y<N+j+$});if(!C)break;N=C.y+C.h+(C.sid===x?24:c)}N!==S.y&&(t.set(v,{x:S.x,y:N}),y.push(v)),f.push({x:S.x,y:N,w:_,h:j,sid:x})}return y}function LU(e,t,n,s,a,l){const c=_=>zl(_,s,l),d=_=>n.get(_)??t.get(_),h=new Map;for(const _ of e){if(!d(_.id))continue;const j=Bl(_),x=h.get(j);x?x.push(_):h.set(j,[_])}const p=new Set;for(const[_,j]of h)j.every(x=>a.has(x.id)&&!n.has(x.id))&&p.add(_);const f=new Map,m=[];for(const _ of e){const j=d(_.id);if(!j)continue;const{w:x,h:N}=c(_.id),E=Bl(_);p.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):m.push({x:j.x,y:j.y,w:x,h:N})}if(f.size===0)return[];const y=ti+Ud,v=(_,j,x,N)=>m.some(E=>_<E.x+E.w+ti&&E.x<_+x+ti&&j<E.y+E.h+y&&E.y<j+N+y),S=[];for(const _ of[...f.keys()].sort()){const j=f.get(_);let x=1/0,N=1/0,E=-1/0,C=-1/0;for(const L of j){const H=d(L.id),{w:F,h:A}=c(L.id);x=Math.min(x,H.x),N=Math.min(N,H.y),E=Math.max(E,H.x+F),C=Math.max(C,H.y+A)}const R=E-x,I=C-N,$=[...new Set(m.map(L=>Math.round(L.x)))].sort((L,H)=>L-H),B=$.length?$:[x],O=[0,...m.map(L=>L.y+L.h+y)].sort((L,H)=>L-H);let M=null;e:for(const L of B)for(const H of O){if(H>=N)break;if(!v(L,H,R,I)){M={x:L,y:H};break e}}if(M){const L=M.x-x,H=M.y-N;for(const F of j){const A=d(F.id);t.set(F.id,{x:A.x+L,y:A.y+H})}S.push(_)}for(const L of j){const H=d(L.id),{w:F,h:A}=c(L.id);m.push({x:H.x,y:H.y,w:F,h:A})}}return S}function DU(e,t,n,s,a,l=!1,c){const p=ti+Ud+1,f=8,m=1.75,y=200,v=.7,S=.01,_=M=>zl(M,s,c),j=M=>n.get(M)??t.get(M),x=new Map;for(const M of e){if(!j(M.id))continue;const L=Bl(M),H=x.get(L);H?H.push(M):x.set(L,[M])}const N=[],E=new Set,C=new Set,R=a.size===0;for(const M of[...x.keys()].sort()){const L=x.get(M);let H=1/0,F=1/0,A=-1/0,Q=-1/0,K=!1;for(const Y of L){const P=j(Y.id),{w:G,h:de}=_(Y.id);H=Math.min(H,P.x),F=Math.min(F,P.y),A=Math.max(A,P.x+G),Q=Math.max(Q,P.y+de),n.has(Y.id)&&(K=!0)}const ee=A-H,Z=Q-F;C.add(M);const D=a.get(M);D&&(ee>D.w+f||Z>D.h+f)&&E.add(M),a.set(M,{w:ee,h:Z}),N.push({sid:M,members:L.map(Y=>Y.id),x:H,y:F,w:ee,h:Z,anchored:K,mass:1})}for(const M of[...a.keys()])C.has(M)||a.delete(M);if(l||R)return[];let I=!1;for(let M=0;M<N.length&&!I;M++)for(let L=M+1;L<N.length;L++){const H=N[M],F=N[L];if(!(H.anchored&&F.anchored)&&Math.abs(H.x+H.w/2-(F.x+F.w/2))<(H.w+F.w)/2+61&&Math.abs(H.y+H.h/2-(F.y+F.h/2))<(H.h+F.h)/2+p){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const M of N)E.has(M.sid)&&(M.mass=8);else for(const M of N)M.mass=Math.max(1,M.w*M.h/(ui*hd));const $=new Map(N.map(M=>[M.sid,M.x])),B=new Map(N.map(M=>[M.sid,M.y]));for(let M=0;M<y;M++){const L=new Map,H=new Map;let F=0;for(let A=0;A<N.length;A++)for(let Q=A+1;Q<N.length;Q++){const K=N[A],ee=N[Q];if(K.anchored&&ee.anchored)continue;const Z=K.x+K.w/2,D=K.y+K.h/2,Y=ee.x+ee.w/2,P=ee.y+ee.h/2,G=(K.w+ee.w)/2+61-Math.abs(Z-Y),de=(K.h+ee.h)/2+p-Math.abs(D-P);if(G<=0||de<=0)continue;const W=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.x<=0),U=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.y<=0),J=(Xe,he,ge)=>{const Se=Xe===he,Fe=Se?K.sid<ee.sid?-1:1:Math.sign(Xe-he);return ge(K,Fe)||ge(ee,-Fe)?Fe:Se&&(ge(K,-Fe)||ge(ee,Fe))?-Fe:0},V=J(Z,Y,W),ie=J(D,P,U),pe=V!==0,me=ie!==0;if(!pe&&!me)continue;const Ie=pe&&(!me||G*m<de),[Le,ce,xe,ye]=Ie?[V,G,L,W]:[ie,de,H,U],ze=ye(K,Le),ke=ye(ee,-Le),je=K.mass,Ye=ee.mass,it=ze?ke?Ye/(je+Ye):1:0,Ne=ke?ze?je/(je+Ye):1:0,He=ce*v;xe.set(K.sid,(xe.get(K.sid)??0)+Le*He*it),xe.set(ee.sid,(xe.get(ee.sid)??0)-Le*He*Ne),F+=He}for(const A of N)A.anchored||(A.x=Math.max(0,A.x+(L.get(A.sid)??0)),A.y=Math.max(0,A.y+(H.get(A.sid)??0)));if(F<S)break}const O=[];for(const M of N){const L=M.x-$.get(M.sid),H=M.y-B.get(M.sid);if(!(Math.abs(L)<1&&Math.abs(H)<1)){for(const F of M.members){if(n.has(F))continue;const A=t.get(F);A&&t.set(F,{x:A.x+L,y:A.y+H})}O.push(M.sid)}}return O}const qU=600;function Lv(e,t){return!(e.exitAt!=null&&t-e.exitAt>qU||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function FU(e,t){const n=new Set;for(const s of e.agents.values())Lv(s,t)&&n.add(s.id);return n}function BU(e,t,n=0){return e.right+n>t.left&&e.left-n<t.right&&e.bottom+n>t.top&&e.top-n<t.bottom}function zU(e,t,n=0){if(!e)return!1;for(const s of t)if(BU(e,s,n))return!0;return!1}const YA="sessionGroup";function UU(e,t){var s;if(e.type===YA)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const KA=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function fC(e){const t={};for(const n of KA)t[n]=e(n);return t}function WU(e){return t=>e[t]??""}function HU(e,t){return KA.every(n=>e[n]===t[n])}function GU(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[a,l]of e.positions)n.set(a,l),t.has(a)&&s.set(a,l);return{positions:n,pinned:s}}const VU=1200,YU=1e3;function pC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<VU?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<YU}function tv({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function KU(e,t,n){const s=e.x*t.zoom+t.x,a=e.y*t.zoom+t.y,l=(e.x+e.width)*t.zoom+t.x,c=(e.y+e.height)*t.zoom+t.y;return l>0&&s<n.width&&c>0&&a<n.height}function XU({pane:e,viewport:t,boxes:n}){if(!e||!(e.width>0)||!(e.height>0)||!Number.isFinite(t.zoom)||t.zoom<=0||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;let s=!1;for(const a of n)if(s=!0,KU(a,t,e))return!1;return s}const QU="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",nv="click for what's new";function ZU(e){if(e.checkDisabled)return`${QU} · ${nv}`;if(e.checking)return`Asking npm for the newest release… · ${nv}`;const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",n=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${nv}, and to check npm now`}function JU(e){const t=`Version v${e.running}, show what's new`;return e.checkDisabled?`${t} — update checks are off`:e.checking?`${t} — checking npm for a newer release`:`${t} and check npm for a newer release`}function eW(e){const t=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`,n=e.open?"show what's new":"show what's new and the notice";return`Version v${e.from}, ${t} — ${n}`}function tW(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Dv={kind:"assumed",claude:!0,codex:!0};function nW(e){if(!e||typeof e!="object")return Dv;const t=e.providers;if(!t||typeof t!="object")return Dv;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function fd(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const mC=99;function rW(e){const t=Math.max(0,Math.floor(e));return t>mC?`${mC}+`:String(t)}const sW="Pause the canvas";function aW(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${fd(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${fd(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function oW(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const XA="paused · full",iW=(e,t)=>t>0?XA:e>0?`paused · ${rW(e)}`:"paused";function lW(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:iW(e.held,t),widest:XA,title:t>0?`Connected — the pause is full at ${fd(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${fd(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function gC(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const cW={agent:u4,sessionGroup:E4},QA="react-flow__node";function yC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,QA))===!0}function uW(e){try{const t=document.querySelector(`.${QA}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const dW=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),hW=420;function fW(e){return e<.35?"far":e<.55?"mid":"full"}const Du=18,pW=200,mW=5*6e4,gW=6,yW=2*6e4,wC=400,zx="agent-dag.layout",Ux="agent-dag.viewport",ZA="agent-dag.summariesDismissed",JA="agent-dag.sessionListOpen",eR="agent-dag.detailOpen",tR="agent-dag.usagePanelOpen",nR="agent-dag.systemPanelOpen",vC="agent-dag.accountsPanelOpen",rv="agent-dag.versionNoticeDismissed",xC="agent-dag.oldNameNoticeDismissed",wW=15*6e4,sv={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},qu="agent-dag.autoRestart",bC="agent-dag.bundleReloadedFor";function vW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(JA)==="1"}catch{return!1}}function xW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(JA,e?"1":"0")}catch{}}function bW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eR)==="1"}catch{return!1}}function kW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eR,e?"1":"0")}catch{}}function _W(){const e=hi(tR);return e===null?!0:e==="1"}function NW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tR,e?"1":"0")}catch{}}function SW(){const e=hi(nR);return e===null?!0:e==="1"}function jW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(nR,e?"1":"0")}catch{}}function EW(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(ZA);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function kC(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(ZA,JSON.stringify(n))}catch{}}function CW(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(zx);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const a=Object.entries(n).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:a,pins:a.map(([l])=>l)}}return{positions:Object.entries(n.positions??{}).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function av(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,a]of e)n[s]=a;for(const[s,a]of t)n[s]=a;window.localStorage.setItem(zx,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function TW(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ux);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function AW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ux,JSON.stringify(e))}catch{}}function _C(){if(!(typeof window>"u")){try{window.localStorage.removeItem(zx)}catch{}try{window.localStorage.removeItem(Ux)}catch{}}}function RW(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const a={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(a,null,2),c=new Blob([l],{type:"application/json"}),d=URL.createObjectURL(c),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=d,h.download=`${Wt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(d),1e3)}const qv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Fv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},rR=c2;function MW(e,t,n,s,a,l,c,d,h,p,f,m,y,v,S,_,j,x){const N=[],E=[];for(const M of e.agents.values()){if(!j.has(M.id))continue;const L=M.exitAt!=null,H=_!=null&&!_.has(M.id),F=[L?"rf-exiting":"",H?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=l.get(M.id);if(N.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:t,onOpenContext:x},className:F,...A?{width:A.width,height:A.height}:null}),M.parentId&&j.has(M.parentId)){const Q=ix(M.sessionId),K=L,ee=S.size>0&&(S.has(M.id)||S.has(M.parentId)),Z=_!=null&&!_.has(M.id)&&!_.has(M.parentId),D=M.state==="active"?2:1.5,Y=ee?D+1.5:D,P=K?.2:Z?.12:1,G=["sess-edge",M.state==="active"?"sess-live":"sess-idle",K?"rf-edge-exiting":"",ee?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||ee)&&!K,type:"smoothstep",style:{"--session-hue":Q,strokeWidth:Y,opacity:P,transition:"var(--edge-transition)"},className:G})}}const C=new Map;for(const M of e.agents.values())M.tools.length>0&&C.set(M.id,Math.min(4,M.tools.length));const R=`${y}#lanes:${IU(C)}`,I=N.filter(M=>SF(M.id,a,f,m));if(I.length>0||R!==v.current){if(I.length>0){const M=OU(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:s,lanes:C});for(const L of M)W2(L.id,f,m)&&EF(L.id,L.position,f,m);LU(N,f,a,l,new Set(I.map(L=>L.id)),C)}PU(N,f,a,l,C),v.current=R}const $=DU(N,f,a,l,c,!h||p,C);$.length>0&&d($),Mu(f,e.agents),Mu(m,e.agents),Mu(a,e.agents),Mu(l,kF(e.agents.values()));const B=[];let O=!1;for(const M of N){let L=a.get(M.id)??f.get(M.id);L||(L=jF(M.id,f,m),O=!0),B.push({...M,position:L})}return O&&(v.current=""),{nodes:B,edges:E}}function IW(){return i.jsx(ax,{children:i.jsx($W,{})})}function $W(){var Hi,Gi,Vi,Yi;const e=Vl(),t=Rt(),n=b.useState(kv)[0],s=b.useRef(n),[,a]=b.useState(0),l=b.useCallback(()=>a(q=>q+1),[]),[c,d]=b.useState(()=>new Set),[h,p]=b.useState(null),[f,m]=b.useState(null),y=b.useCallback((q,z)=>{d(se=>{if(!z)return new Set([q]);const oe=new Set(se);return oe.has(q)?oe.delete(q):oe.add(q),oe}),p(se=>z&&se===q?se:q)},[]),v=b.useCallback(()=>{d(new Set),p(null)},[]),[S,_]=b.useState(null),[j,x]=b.useState(null),N=b.useCallback(q=>x(q),[]),[E,C]=b.useState(!1),[R,I]=b.useState(!1),[$,B]=b.useState(!1),O=b.useRef(null),M=b.useState(EW)[0],[L,H]=b.useState(vW);b.useEffect(()=>{xW(L)},[L]);const[F,A]=b.useState(bW);b.useEffect(()=>{kW(F)},[F]);const[Q,K]=b.useState(_W);b.useEffect(()=>{NW(Q)},[Q]);const[ee,Z]=b.useState(SW);b.useEffect(()=>{jW(ee)},[ee]);const[D,Y]=b.useState(()=>{try{const q=window.localStorage.getItem(vC);return q===null?!0:q==="1"}catch{return!0}});b.useEffect(()=>{try{window.localStorage.setItem(vC,D?"1":"0")}catch{}},[D]);const P=$f(D,200),G=$f(Q,130),de=$f(ee,130),[W,U]=b.useState(null);b.useEffect(()=>{let q=null;try{q=localStorage.getItem("agent-dag.sound")}catch{}U(q===null?!0:q==="on")},[]);const J=b.useCallback(()=>{U(q=>{var se;const z=q!==!0;try{localStorage.setItem("agent-dag.sound",z?"on":"off")}catch{}return z&&((se=Ye.current)==null||se.unlock()),z})},[]),V=b.useCallback(q=>{J()},[J]),ie=b.useRef(V);ie.current=V;const pe=b.useRef(W);pe.current=W;const[me,Ie]=b.useState(()=>qq(hi)),Le=b.useRef(me);Le.current=me;const ce=b.useRef(null),xe=b.useCallback((q,z=!1)=>{var se,oe;if((se=Ye.current)==null||se.unlock(),ce.current!==null&&clearTimeout(ce.current),ce.current=null,!z){(oe=Ye.current)==null||oe.play(q,!0);return}ce.current=setTimeout(()=>{var Ee;ce.current=null,(Ee=Ye.current)==null||Ee.play(q,!0)},$q)},[]),ye=b.useCallback((q,z)=>{Ie(se=>{const oe={level:Fl(z.level??se[q].level),figure:L2(q,z.figure??se[q].figure)};try{localStorage.setItem(D2[q],String(oe.level)),localStorage.setItem(q2[q],oe.figure)}catch{}return{...se,[q]:oe}}),xe(q,!0)},[xe]);b.useEffect(()=>()=>{ce.current!==null&&clearTimeout(ce.current)},[]);const[ze,ke]=b.useState(!1),je=b.useRef(null),Ye=b.useRef(null),[it,Ne]=b.useState("locked");b.useEffect(()=>{const q=zq({enabled:()=>pe.current===!0,prefs:()=>Le.current,onState:Ne});Ye.current=q,Ne(q.state());const z=()=>q.unlock();return window.addEventListener("pointerdown",z,{once:!0,capture:!0}),window.addEventListener("keydown",z,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",z,{capture:!0}),window.removeEventListener("keydown",z,{capture:!0})}},[]);const[He,Xe]=b.useState(!1),[he,ge]=b.useState(null),[Se,Fe]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(rv)??""}catch{return""}}),[et,xt]=b.useState(!1),ht=b.useRef(0),[ne,De]=b.useState(!1),Oe=b.useCallback((q=!1)=>(q&&(ht.current=Date.now(),De(!0)),fetch(q?"/api/version?refresh=1":"/api/version").then(z=>z.ok?z.json():null).then(z=>{z&&ge(z)}).catch(()=>{}).finally(()=>{q&&De(!1)})),[]),Te=b.useCallback(()=>{Oe(Date.now()-ht.current>=wW)},[Oe]);b.useEffect(()=>{Oe();const q=window.setInterval(Te,5*6e4),z=()=>{document.visibilityState==="visible"&&Te()};return document.addEventListener("visibilitychange",z),()=>{window.clearInterval(q),document.removeEventListener("visibilitychange",z)}},[Oe,Te]),b.useEffect(()=>{He&&Oe()},[He,Oe]),b.useEffect(()=>{const q=Qq();let z=null;const se=We=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:q,looking:We}),keepalive:!0}).catch(()=>{})},oe=()=>{const We=Kq(document);Xq(z,We)&&se(We),z=We},Ee=()=>{z&&se(!1),z=!1};oe();const Me=window.setInterval(oe,Yq);return window.addEventListener("focus",oe),window.addEventListener("blur",oe),document.addEventListener("visibilitychange",oe),window.addEventListener("pagehide",Ee),()=>{window.clearInterval(Me),window.removeEventListener("focus",oe),window.removeEventListener("blur",oe),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",Ee),Ee()}},[]);const Ce=(he==null?void 0:he.notice)??null,[lt,ut]=b.useState(null),Re=b.useRef(!1);b.useEffect(()=>{if(Re.current)return;const q=D1(),z=oF(q),se=hF({stored:z,running:(he==null?void 0:he.running)??null,notes:L1,remembers:iF(q)});if(se.reason==="no-version")return;Re.current=!0,se.record&&lF(q,se.record);const oe=dF({tourSeen:cF(q),decision:se}),Ee=se.show.length?{entries:se.show,since:z,firstRun:!1}:null;oe.tour&&B(!0),oe.notes==="now"?ut(Ee):oe.notes==="after"&&(O.current=Ee)},[he==null?void 0:he.running]);const mt=(he==null?void 0:he.running)??"3.22.3",ft=b.useMemo(()=>F2(L1,null,mt),[mt]),bt=b.useCallback(()=>{ut({entries:ft,since:null,firstRun:!1})},[ft]),[Xn,Tn]=b.useState(null),[ln,eo]=b.useState(Dv);b.useEffect(()=>{let q=!1;return fetch("/api/health").then(z=>z.ok?z.json():null).then(z=>{q||(eo(nW(z)),!(!z||typeof z.workspace!="string")&&Tn(z.workspace))}).catch(()=>{}),()=>{q=!0}},[He]);const us=b.useRef(ln);us.current=ln;const Or=Ce?`${Ce.kind}:${Ce.to}`:"",Qn=Ce!=null&&Se!==Or,to=b.useCallback(()=>{Fe("");try{window.localStorage.setItem(rv,"")}catch{}},[]),Pr=b.useCallback(()=>{if(Ce){Fe(Or);try{window.localStorage.setItem(rv,Or)}catch{}}},[Ce,Or]),[Qs,Lr]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(xC)??""}catch{return""}}),An=he!=null&&he.invokedAs&&he.invokedAs!==Wt?he.invokedAs:null,Dr=An!=null&&Qs!==An,ds=b.useCallback(()=>{if(An){Lr(An);try{window.localStorage.setItem(xC,An)}catch{}}},[An]),qt=((Hi=he==null?void 0:he.upgrade)==null?void 0:Hi.state)??"idle",wr=fq(he==null?void 0:he.upgrade),Zs=b.useRef(!1),wi=b.useCallback(async()=>{if(hr(Zs.current||qt==="running")){Zs.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Oe(),Zs.current=!1}},[qt,Oe]);b.useEffect(()=>{if(qt!=="running")return;const q=window.setInterval(Oe,3e3);return()=>window.clearInterval(q)},[qt,Oe]);const no=b.useCallback(async()=>{const q=he==null?void 0:he.command;!q||!await P2(q)||(xt(!0),window.setTimeout(()=>xt(!1),1600))},[he==null?void 0:he.command]),Rn=b.useCallback(()=>{H(q=>(q||Y(!1),!q))},[]),Js=b.useCallback(()=>{Y(q=>(q||H(!1),!q))},[]),[ea,ta]=b.useState(!1),[na,ra]=b.useState(!1),[sa,ro]=b.useState(()=>{try{return Number(localStorage.getItem(z1))||0}catch{return 0}}),[aa,vi]=b.useState([]),[dt,so]=b.useState(!1);b.useEffect(()=>{let q=!0;const z=()=>{fetch("/api/browser-watch?live=0").then(oe=>oe.ok?oe.json():null).then(oe=>{var Ee;!q||!(oe!=null&&oe.ok)||(vi(oe.episodes??[]),so(((Ee=oe.settings)==null?void 0:Ee.enabled)===!0))}).catch(()=>{})};z();const se=setInterval(z,5*6e4);return()=>{q=!1,clearInterval(se)}},[]);const[oa,qr]=b.useState([]),Fr=b.useRef(new Set),[Br,ia]=b.useState(null);b.useEffect(()=>{let q=!0,z=0;const se=()=>{fetch("/api/lan").then(oe=>oe.ok?oe.json():null).then(oe=>q?(oe!=null&&oe.ok&&qr(j1(Array.isArray(oe.pending)?oe.pending:[],oe.aliases)),oe):null).catch(()=>null).then(oe=>{q&&(z=window.setTimeout(se,(oe==null?void 0:oe.enabled)===!0?Iv:M2))})};return se(),()=>{q=!1,window.clearTimeout(z)}},[]);const zr=b.useCallback(async(q,z)=>{if(!Br){ia(q);try{const oe=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:q,fp:z})})).json().catch(()=>null);oe&&Array.isArray(oe.pending)?qr(j1(oe.pending,oe.aliases)):qr(Ee=>Ee.filter(Me=>Me.fp!==z))}catch{}finally{ia(null)}}},[Br]),It=b.useMemo(()=>t8(aa,sa).length,[aa,sa]),[la,cn]=b.useState(0),ac=b.useRef(null),[Wd,oc]=b.useState(!1),vr=b.useRef(null),[ao,hs]=b.useState(0),Xt=b.useState(()=>MF({protect:q=>gL(s.current,q)}))[0],[oo,Hd]=b.useState(!1),ca=b.useCallback(()=>{const q=Xt.paused&&Xt.dropped>0,z=Xt.setPaused(!Xt.paused);q&&yL(s.current);for(const se of z)s.current=Mk(s.current,se);Hd(Xt.paused)},[Xt]),[Et,xi]=b.useState(Date.now()),[rn,io]=b.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(qu)!=="0"}catch{return!0}}),lo=b.useRef(!1),at=b.useCallback(()=>{const q=!rn;lo.current=!0;try{window.localStorage.removeItem(qu)}catch{}io(q),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&io(((se=z.prefs)==null?void 0:se.autoUpdate)!==!1)}).catch(()=>{})},[rn]),[Zn,ua]=b.useState(!1),[bi,ic]=b.useState("restart"),[ki,_i]=b.useState(null),xr=b.useRef(!1),da=b.useRef(null),Jn=b.useRef(0),xn=b.useCallback(async q=>{if(!hr(xr.current))return;const z=(q==null?void 0:q.upgrade)===!0;xr.current=!0,da.current=wr;const se=++Jn.current;ic(z?"npx":"restart"),ua(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(Ce==null?void 0:Ce.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:z})})}catch{}window.setTimeout(()=>{if(Jn.current===se&&xr.current){xr.current=!1,ua(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},z?18e4:3e4)},[Ce==null?void 0:Ce.to,wr]),Mn=b.useRef(null);b.useEffect(()=>{const q=M1(s.current.agents.values())>0,z=wq({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:q,idleSince:Mn.current,now:Et});Mn.current=z.idleSince,z.restart&&xn()},[rn,Ce==null?void 0:Ce.kind,he==null?void 0:he.canRestart,Qn,Et,xn]);const fs=M1(s.current.agents.values()),ps=yq(fs),er=O2({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:fs>0,idleSince:Mn.current,now:Et});b.useEffect(()=>{const q=he==null?void 0:he.running;let z=null,se=null;try{z=window.sessionStorage.getItem("agent-dag.restartPending"),se=window.sessionStorage.getItem(bC)}catch{return}const oe=hq({bundle:"3.22.3",running:q,pending:z,lastTried:se});if(oe==="reload"){try{window.sessionStorage.setItem(bC,q??"")}catch{return}window.location.reload();return}if(oe!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,ua(!1),_i(q??null);const Ee=window.setTimeout(()=>_i(null),6e3);return()=>window.clearTimeout(Ee)},[he==null?void 0:he.running]),b.useEffect(()=>{if(Zn&&pq({asked:da.current,reported:wr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,ua(!1)}},[Zn,wr]);const lc=b.useState(()=>GU(CW()))[0],Qt=b.useRef(lc.pinned),br=b.useRef(null),co=b.useState(()=>TW())[0],[uo,ho]=b.useState(()=>new Set),[ms,cc]=b.useState($F),[un,ha]=b.useState(()=>fC(gC)),Ur=b.useMemo(()=>WU(un),[un]),fo=b.useCallback(q=>UU(q,Ur),[Ur]),Gd=b.useMemo(()=>({background:un["--panel"],border:`1px solid ${un["--line"]}`,borderRadius:8}),[un]),[uc,Ni]=b.useState(!1);b.useEffect(()=>{document.documentElement.dataset.theme=ms;try{window.localStorage.setItem(H2,ms)}catch{}ha(q=>{const z=fC(gC);return HU(q,z)?q:z})},[ms]);const In=b.useCallback((q,z)=>{if(tv({durationMs:z,documentHidden:document.hidden})){e.setViewport(q,{duration:z});return}const{d3Zoom:se,d3Selection:oe}=t.getState(),Ee=oe==null?void 0:oe.property("__zoom");if(se&&oe&&Ee&&Ee.k>0&&q.zoom>0){se.transform(oe,Ee.scale(q.zoom/Ee.k).translate((q.x-Ee.x)/q.zoom,(q.y-Ee.y)/q.zoom));return}e.setViewport(q,{duration:0})},[e,t]),Wr=b.useRef(null);b.useEffect(()=>{if(!co)return;const q=window.setTimeout(()=>{try{In(co,0)}catch{}bn.current=Date.now()},60);return()=>window.clearTimeout(q)},[In,co]);const Si=b.useRef(!0);b.useEffect(()=>{const q=new EventSource("/events"),z=AF(l,{now:()=>Date.now(),setTimeout:(se,oe)=>window.setTimeout(se,oe),clearTimeout:se=>window.clearTimeout(se)});return q.addEventListener("open",()=>{Xe(!0),Ni(!0)}),q.addEventListener("error",()=>Xe(!1)),q.addEventListener("replay-end",()=>{Si.current=!1,z.flush()}),q.addEventListener("hook",se=>{var oe;try{const Ee=JSON.parse(se.data);if(!Xt.accept(Ee))return;s.current=Mk(s.current,Ee);const Me=Ee.replay===!0||Si.current||Date.now()-Ee.receivedAt>3e4;Me?z.replay():z.live();const We=Bq(Ee,Me);We&&((oe=Ye.current)==null||oe.play(We))}catch{}}),()=>{q.close(),z.cancel()}},[l]),b.useEffect(()=>{const q=setInterval(()=>{const z=Date.now();xi(z);let se=wL(s.current,z,Rk);vL(s.current,z,Rk)&&(se=!0),pL(s.current,z,pW,mW)&&(se=!0),mL(s.current,z,gW,yW)&&(se=!0),d(oe=>bF(oe,s.current.agents)),p(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),x(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),_(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),se&&l()},250);return()=>clearInterval(q)},[l]);const $n=b.useRef(null),bn=b.useRef(0),po=420,kn=b.useCallback((q=500)=>{try{const Me=document.querySelector(".canvas-wrap"),We=Array.from(document.querySelectorAll(".react-flow__node")).filter(Ct=>Ct.offsetWidth>0);if(!Me||We.length===0)return;const rt=Me.getBoundingClientRect(),gt=e.getViewport();if(!Number.isFinite(gt.zoom)||gt.zoom<=0)return;const ot=Ct=>(Ct-rt.left-gt.x)/gt.zoom,Qe=Ct=>(Ct-rt.top-gt.y)/gt.zoom,Ns=We.map(Ct=>Ct.getBoundingClientRect()),Ea=Math.min(...Ns.map(Ct=>ot(Ct.left))),Ca=Math.max(...Ns.map(Ct=>ot(Ct.right))),Ki=Math.min(...Ns.map(Ct=>Qe(Ct.top))),Xi=Math.max(...Ns.map(Ct=>Qe(Ct.bottom))),Ss=Ca-Ea,js=Xi-Ki;if(!(Ss>0&&js>0))return;const Pn=Math.max(.2,Math.min(1,(rt.width-160)/(Ss+po)*.86,(rt.height-160)/js*.86)),Es={x:80-Ea*Pn,y:Math.max(80,(rt.height-js*Pn)/2)-Ki*Pn,zoom:Pn};In(Es,q),bn.current=Date.now(),Wr.current=tv({durationMs:q,documentHidden:document.hidden})?{target:Es,until:Date.now()+q+60}:null,window.setTimeout(()=>{var Ct;try{((Ct=Wr.current)==null?void 0:Ct.target)===Es&&(Wr.current=null);const Cc=e.getViewport();(Math.abs(Cc.zoom-Pn)>.01||Math.abs(Cc.x-Es.x)>2)&&In(Es,0)}catch{}},q+60)}catch{}},[e,In]);b.useEffect(()=>{const q=()=>{if(!document.hidden)return;const z=Wr.current;if(Wr.current=null,!(!z||Date.now()>z.until)){try{In(z.target,0)}catch{}bn.current=Date.now()}};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[In]);const gs=b.useRef(""),ys=b.useRef(null),ji=b.useRef(0),Ft=b.useCallback(()=>{ji.current=Date.now()},[]),kr=b.useRef(null),mo=b.useRef(0),Hr=b.useCallback(()=>{mo.current=Date.now()},[]),dc=b.useCallback(q=>({hasSourceEvent:!!q,at:Date.now(),lastDeckFitAt:bn.current,lastCanvasInputAt:mo.current}),[]),fa="agent-dag.autoFitDisabled",go=b.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(fa)==="1"}catch{return!1}})[0],On=b.useRef(go),[pa,Ei]=b.useState(go),Ci=b.useCallback(()=>{if(!On.current){On.current=!0,Ei(!0);try{window.localStorage.setItem(fa,"1")}catch{}}},[]),Vd=b.useCallback(()=>{On.current=!1,Ei(!1);try{window.localStorage.removeItem(fa)}catch{}kn(400)},[e,kn]);b.useEffect(()=>{const q=setInterval(()=>{if(On.current||Date.now()-ji.current<800)return;const z=s.current,se=Date.now(),oe=[];for(const Me of z.agents.values())Lv(Me,se)&&oe.push({id:Me.id});if(oe.length===0)return;const Ee=[];for(const{id:Me}of oe){const We=_r.current.get(Me),rt=Qt.current.get(Me)??sn.current.get(Me);!We||!rt||Ee.push({x:rt.x,y:rt.y,width:We.width,height:We.height})}XU({pane:kr.current,viewport:e.getViewport(),boxes:Ee})&&kn(600)},1500);return()=>clearInterval(q)},[e]);const Ti=b.useRef(!1),_r=b.useRef(new Map),hc=b.useRef(0),Yd=b.useCallback(q=>{const z=_r.current;let se=!1;for(const oe of q.nodeInternals.values()){const Ee=oe.width,Me=oe.height;if(Ee==null||Me==null)continue;const We=z.get(oe.id);We?(Math.abs(We.height-Me)>4||Math.abs(We.width-Ee)>4)&&(z.set(oe.id,{width:Ee,height:Me}),se=!0):(z.set(oe.id,{width:Ee,height:Me}),se=!0)}return se&&(hc.current+=1),hc.current},[]),fc=ct(Yd),[pc,Kd]=b.useState(0);b.useEffect(()=>{let q=0;const z=()=>{const oe=_r.current;let Ee=!1;for(const Me of document.querySelectorAll(".react-flow__node[data-id]")){const We=Me.getAttribute("data-id");if(!We)continue;const rt=Me.offsetWidth,gt=Me.offsetHeight;if(!rt||!gt)continue;const ot=oe.get(We);(!ot||Math.abs(ot.width-rt)>4||Math.abs(ot.height-gt)>4)&&(oe.set(We,{width:rt,height:gt}),Ee=!0)}Ee&&Kd(Me=>Me+1)};if(Ti.current)return;let se=0;return document.visibilityState==="hidden"?se=window.setTimeout(z,32):q=requestAnimationFrame(z),()=>{cancelAnimationFrame(q),window.clearTimeout(se)}});const sn=b.useRef(lc.positions),Xd=b.useRef(new Set),Ai=b.useRef(""),ws=b.useMemo(()=>{const q=[];for(const z of s.current.agents.values())Lv(z,Et)&&q.push(z.id+(z.parentId?`>${z.parentId}`:""));return q.sort(),`${q.join("|")}#sv${fc}.${pc}`},[s.current,s.current.revision,Et,fc,pc]),ma=b.useRef(null);b.useEffect(()=>(ma.current!=null&&window.clearTimeout(ma.current),ma.current=window.setTimeout(()=>{av(sn.current,Qt.current)},1500),()=>{ma.current!=null&&window.clearTimeout(ma.current)}),[ws]),b.useEffect(()=>{if(gs.current===ws)return;const q=gs.current;if(gs.current=ws,!q||On.current)return;Date.now()-bn.current>1200&&kn(400),$n.current&&window.clearTimeout($n.current),$n.current=window.setTimeout(()=>{On.current||kn(500)},280)},[ws,e,kn]);const ga=b.useMemo(()=>NF(s.current,c),[s.current,s.current.revision,c]),Ri=b.useMemo(()=>FU(s.current,Et),[s.current,s.current.revision,Et]),mc=b.useRef(null),[yo,Mi]=b.useState({w:0,h:0});b.useEffect(()=>{const q=mc.current;if(!q||typeof ResizeObserver>"u")return;const z=new ResizeObserver(se=>{var Ee;const oe=(Ee=se[0])==null?void 0:Ee.contentRect;oe&&(kr.current={width:oe.width,height:oe.height},Mi(Me=>Math.abs(Me.w-oe.width)>40||Math.abs(Me.h-oe.height)>40?{w:oe.width,h:oe.height}:Me))});return z.observe(q),kr.current={width:q.clientWidth,height:q.clientHeight},Mi({w:q.clientWidth,h:q.clientHeight}),()=>z.disconnect()},[]);const Qd=b.useCallback(q=>{var se,oe;const z=q.target;!(z!=null&&z.closest)||z.closest(dW)!==q.currentTarget||(q.preventDefault(),(oe=(se=document.activeElement)==null?void 0:se.blur)==null||oe.call(se))},[]),Zd=b.useRef(new Map),[gc,Jd]=b.useState(!1);b.useEffect(()=>{const q=window.setTimeout(()=>Jd(!0),2500);return()=>window.clearTimeout(q)},[]);const[eh,Ii]=b.useState(!1),Nr=b.useRef(null),[ya,vs]=b.useState(!1),[th,yc]=b.useState("full"),$i=b.useRef("full"),wc=b.useCallback(()=>{Nr.current&&(window.clearTimeout(Nr.current),Nr.current=null),Ii(!1)},[]),vc=b.useCallback(q=>{q.length!==0&&queueMicrotask(()=>{Ii(!0),Nr.current&&window.clearTimeout(Nr.current),Nr.current=window.setTimeout(()=>Ii(!1),hW+80)})},[]);b.useEffect(()=>()=>{Nr.current&&window.clearTimeout(Nr.current)},[]);const Oi=yo.w>0?yo.w*.92:0,Gr=yo.h>0?yo.h:0,{nodes:Sr,edges:nh}=b.useMemo(()=>MW(s.current,Et,Oi,Gr,Qt.current,_r.current,Zd.current,vc,gc,ya,sn.current,Xd.current,ws,Ai,c,ga,Ri,N),[s.current,s.current.revision,Et,Oi,Gr,gc,ya,ws,c,ga,Ri,N,la]),xc=b.useMemo(()=>{const q=new Map;for(const se of Sr){const oe=se.data;if(!(oe!=null&&oe.sessionId)||oe.exitAt!=null)continue;const Ee=se.width,Me=se.height;if(Ee==null||Me==null)continue;const We=se.position.x,rt=se.position.y,gt=We+Ee,ot=rt+Me,Qe=q.get(oe.sessionId);Qe?(Qe.minX=Math.min(Qe.minX,We),Qe.minY=Math.min(Qe.minY,rt),Qe.maxX=Math.max(Qe.maxX,gt),Qe.maxY=Math.max(Qe.maxY,ot)):q.set(oe.sessionId,{minX:We,minY:rt,maxX:gt,maxY:ot})}const z=[];for(const[se,oe]of q){const Ee=oe.maxX-oe.minX+Du*2,Me=oe.maxY-oe.minY+Du*2;z.push({id:`group:${se}`,type:YA,position:{x:oe.minX-Du,y:oe.minY-Du},data:{sessionId:se,w:Ee,h:Me},width:Ee,height:Me,style:{width:Ee,height:Me},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return z},[Sr,Et]),bc=b.useMemo(()=>{const q=[...xc,...Sr],z=vr.current;return!z||z.size===0?q:q.map(se=>{const oe=z.get(se.id);return oe?{...se,position:oe}:se})},[xc,Sr,ao]),wa=b.useMemo(()=>{const q=new Set;for(const z of s.current.agents.values())for(const se of z.tools)q.add(rR(se.name));return Object.keys(qv).filter(z=>q.has(z))},[s.current,s.current.revision]);b.useEffect(()=>{if(wa.length<=1){oc(!1);return}let q=0;const z=()=>{const se=ac.current;if(se&&!document.hidden){const oe=se.getBoundingClientRect(),Ee=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(We=>We.getBoundingClientRect()),Me=zU(oe,Ee,8);oc(We=>We===Me?We:Me)}q=window.setTimeout(z,300)};return z(),()=>window.clearTimeout(q)},[wa.length]);const va=b.useCallback(q=>{ho(z=>{const se=new Set(z);return se.has(q)?se.delete(q):se.add(q),se})},[]),$t=h?s.current.agents.get(h):null,Pi=f?Array.from(s.current.agents.values()).flatMap(q=>q.tools).find(q=>q.id===f)??null:null,xa=b.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=kv(),Qt.current.clear(),_r.current.clear(),sn.current.clear(),Ai.current="",_C(),v(),l()},[l,v]),kc=b.useRef(E);kc.current=E;const Li=b.useRef(R);Li.current=R;const ba=b.useRef(!1);ba.current=Pi!=null||ea||j!=null||$||S!=null||na||R||lt!=null;const xs=b.useCallback(q=>{const z=vq(q,{confirmOpen:kc.current,modalOpen:ba.current});z==="confirm"?C(!0):z==="clear"&&(C(!1),xa())},[xa]),wo=b.useCallback(()=>{Qt.current.clear(),sn.current.clear(),Ai.current="",_C(),l(),window.setTimeout(()=>kn(500),80)},[l,e,kn]),Di=b.useCallback(()=>kn(500),[kn]),ka=b.useRef(Sr);ka.current=Sr;const _c=b.useRef(h);_c.current=h;const qi=b.useCallback(q=>{const z=ka.current,se=gF(z.map(Me=>({id:Me.id,x:Me.position.x,y:Me.position.y})),_c.current,q),oe=se?z.find(Me=>Me.id===se):void 0;if(!oe)return;const Ee=yC(document.activeElement);y(oe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[oe]})}catch{}bn.current=Date.now(),Ee&&uW(oe.id)},30)},[y,e]),Fi=b.useCallback(q=>{y(q,!1),window.setTimeout(()=>{try{const z=ka.current.find(se=>se.id===q);z&&e.fitView({padding:.3,duration:500,nodes:[z]}),bn.current=Date.now()}catch{}},60)},[y,e]);b.useEffect(()=>{const q=z=>{var rt,gt;const se=z.target,oe={tagName:se==null?void 0:se.tagName,isContentEditable:se==null?void 0:se.isContentEditable,role:(rt=se==null?void 0:se.getAttribute)==null?void 0:rt.call(se,"role"),type:se==null?void 0:se.type};if(z.key==="Escape"){const ot=VL({overlayOpen:ad.depth()>0,typing:dx(oe)});ot==="dismiss"?ad.dismissTop():ot==="blur"?se==null||se.blur():(xF(oe)&&(se==null||se.blur()),v());return}if(ux(z))return;const Ee=yC(se)?(gt=se==null?void 0:se.getAttribute)==null?void 0:gt.call(se,"data-id"):null,Me=Ee&&ka.current.some(ot=>ot.id===Ee)?Ee:null,We=wF(z,Me);if(We.kind==="activate"){z.preventDefault(),y(We.nodeId,We.additive);return}We.kind!=="node"&&(We.nodeId==null&&t4(oe)||n4({key:z.key,modalOpen:ba.current,sheetOpen:Li.current})||(z.key===" "&&(z.preventDefault(),ca()),(z.key==="c"||z.key==="C")&&xs("shortcut"),(z.key==="r"||z.key==="R")&&wo(),(z.key==="f"||z.key==="F")&&Di(),(z.key==="l"||z.key==="L")&&Rn(),(z.key==="d"||z.key==="D")&&A(ot=>!ot),(z.key==="h"||z.key==="H")&&ta(ot=>!ot),(z.key==="u"||z.key==="U")&&K(ot=>!ot),(z.key==="a"||z.key==="A")&&us.current.claude&&Js(),(z.key==="j"||z.key==="J")&&qi(1),(z.key==="k"||z.key==="K")&&qi(-1),(z.key==="t"||z.key==="T")&&cc(ot=>ot==="dark"?"light":"dark"),(z.key==="m"||z.key==="M")&&us.current.claude&&pe.current!==null&&ie.current(z.shiftKey),z.key==="?"&&I(ot=>!ot)))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[xs,wo,Di,v,y,qi,ca]);const Nc=s.current.agents.size,Zt=b.useMemo(()=>qL(s.current.agents.values()),[s.current,s.current.revision]),dn=b.useMemo(()=>FL(s.current.agents.values()),[s.current,s.current.revision]),bs=b.useRef(null);b.useEffect(()=>{const q=OF({waiting:Zt.length,running:dn,connected:He}),z=bs.current;if(bs.current=q,(z==null?void 0:z.title)!==q.title&&(document.title=q.title),(z==null?void 0:z.icon)!==q.icon){const se=document.querySelector('link[rel="icon"]');se&&(se.href=PF[q.icon])}},[Zt.length,dn,He]);const[Sc,jc]=b.useState(""),Bi=DF(Zt);b.useEffect(()=>{jc(q=>qF(q,Bi))},[Bi]);const[_a,zi]=b.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Vr,Ui]=b.useState(null),[tr,Na]=b.useState(!0),[Sa,vo]=b.useState(!1);b.useEffect(()=>{let q=!0;return fetch("/api/prefs").then(z=>z.ok?z.json():null).then(z=>{var se,oe,Ee;if(!(!q||!(z!=null&&z.ok))){if(!lo.current){let Me=!1;try{Me=window.localStorage.getItem(qu)==="0",window.localStorage.removeItem(qu)}catch{}Me&&((se=z.prefs)==null?void 0:se.autoUpdate)!==!1?(io(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):io(((oe=z.prefs)==null?void 0:oe.autoUpdate)!==!1)}Na(((Ee=z.prefs)==null?void 0:Ee.notifications)!==!1),vo(z.notificationsVetoed===!0)}}).catch(()=>{}),()=>{q=!1}},[]);const Wi=b.useRef(()=>{}),xo=b.useCallback(()=>{const q=!tr;Na(q),q&&typeof Notification<"u"&&Notification.permission==="default"&&Wi.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&(Na(((se=z.prefs)==null?void 0:se.notifications)!==!1),vo(z.notificationsVetoed===!0))}).catch(()=>{})},[tr]),ks=typeof Notification<"u";b.useEffect(()=>{if(!Vr)return;const z=setTimeout(()=>Ui(null),Vr==="blocked"?8e3:4e3);return()=>clearTimeout(z)},[Vr]);const bo=b.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(q=>{const z=q;zi(z),z==="granted"?Ui("on"):z==="denied"&&Ui("blocked")})},[]);Wi.current=bo;const ja=b.useRef(new Set),_s=b.useRef(null),Ec=Zt.map(q=>kd(q.id,q.waiting)).join("|");return b.useEffect(()=>{WL(_s.current,_a)&&(_s.current=_a,ja.current=Ok(Zt))},[_a]),b.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||_s.current===null)return;const q=typeof document>"u"||!document.hidden,z=zL(Zt,ja.current,q,tr);for(const se of z)try{const oe=new Notification(se.title,{body:se.body,tag:se.key});oe.onclick=()=>{window.focus(),Fi(se.sessionId),oe.close()}}catch{}ja.current=q?Ok(Zt):UL(Zt,z,ja.current)},[Ec]),i.jsxs("div",{className:"app",children:[i.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),i.jsxs("header",{className:"topbar",children:[i.jsxs("div",{className:"readout",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"logo"}),i.jsx("h1",{children:Wt}),Ce?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{bt(),to()},"aria-haspopup":"dialog","aria-label":eW({...Ce,open:Qn}),title:Ce.kind==="restart"?`Running v${Ce.from}; v${Ce.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${Ce.from}; v${Ce.to} is on npm · click for what's new`,children:["v",Ce.from,i.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const q={running:mt,latest:he==null?void 0:he.latest,latestPending:he==null?void 0:he.latestPending,checkedAgo:he!=null&&he.checkedAt?Cv(Et-he.checkedAt):null,checkDisabled:he==null?void 0:he.checkDisabled,checking:ne};return i.jsxs("button",{type:"button",className:ne?"v checking":"v",onClick:()=>{bt(),Oe(!0)},"aria-busy":ne||void 0,"aria-haspopup":"dialog","aria-label":JU(q),title:ZU(q),children:["v",q.running]})})()]}),i.jsx("span",{className:"status",children:(()=>{const q=lW({connected:He,paused:oo,held:Xt.size,dropped:Xt.dropped});return q.resting?null:i.jsx("span",{className:`pill ${q.tone}`,title:q.title,children:i.jsxs("span",{className:"pill-box",children:[i.jsx("span",{className:"pill-widest","aria-hidden":!0,children:q.widest}),i.jsx("span",{className:"pill-label",children:q.label})]})})})()}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Sc}),Zt.length>0&&i.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Fi(Zt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
264
264
  ${Zt.map(q=>` ${q.label}: ${Dl(q.waiting)} (${Cv(Et-q.waiting.since)})`).join(`
265
265
  `)}`,"aria-label":`${Zt.length} session${Zt.length===1?"":"s"} waiting for you`,children:[i.jsx("span",{className:"ap-pulse","aria-hidden":!0}),i.jsx("b",{children:Zt.length})," waiting"]}),Vr&&i.jsx("span",{className:Vr==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:Vr==="on"?"The deck will raise a system notification when a session blocks on you and this tab is in the background":"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address",children:Vr==="on"?"notifications on":"notifications blocked"})]}),$t&&(()=>{const q=En($t),z=Math.max(0,(($t.endedAt??Et)-$t.startedAt)/1e3),se=$t.state==="active"?cx(q.total,z):null,oe=c.size-1;return i.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${$t.label}`,onClick:()=>{try{const Ee=Sr.find(Me=>Me.id===$t.id);Ee&&e.fitView({padding:.35,duration:500,nodes:[Ee]}),bn.current=Date.now()}catch{}},children:[i.jsx("span",{className:`state-pill state-${$t.state}`,children:$t.state==="active"?"live":$t.state}),i.jsx("span",{className:"selected-label",children:$t.label}),q.total>0&&i.jsxs("span",{className:"selected-cost",children:[tt(q.total),se?i.jsxs("span",{className:"selected-rate",children:[" · ",se]}):null]}),oe>0&&i.jsxs("span",{className:"selected-extra",children:["+",oe]}),i.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:Ee=>{Ee.stopPropagation(),v()},children:"×"})]})})(),i.jsxs("div",{className:"actions",children:[i.jsxs("div",{className:"action-run",children:[i.jsx("button",{className:"btn icon-btn",onClick:Rn,title:`${L?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":L,"aria-controls":L?"session-list":void 0,children:"☰"}),i.jsx("button",{className:"btn icon-btn",onClick:()=>K(q=>!q),title:`${Q?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":Q,"aria-controls":Q?"usage-panel":void 0,children:"$"}),ln.claude&&i.jsx("button",{className:"btn icon-btn",onClick:Js,title:`${D?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":D,"aria-controls":D?"accounts-panel":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),i.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),i.jsx("button",{className:"btn icon-btn",onClick:()=>Z(q=>!q),title:`${ee?"Hide":"Show"} this machine — cores, memory, temperature`,"aria-label":"Toggle machine detail","aria-expanded":ee,"aria-controls":ee?"system-panel":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),i.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]})}),i.jsx("button",{className:"btn icon-btn",onClick:()=>ta(q=>!q),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),i.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),i.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),i.jsxs("button",{className:`btn icon-btn bw-btn${It>0?" has-findings":dt?" watching":""}`,onClick:()=>ra(q=>!q),title:dt?"Browser watch — watching; the deck is keeping its own copy":"Browser watch — not watching; reading the browser's history live","aria-label":`Browser watch, ${dt?"watching":"not watching"}`+(It>0?`, ${It} unread`:""),"aria-haspopup":"dialog",children:[i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:[i.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),dt||It>0?i.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):i.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),It>0&&i.jsx("span",{className:"bw-badge","aria-hidden":!0,children:It})]})]}),i.jsxs("div",{className:"action-run",children:[ln.claude&&W!==null&&i.jsxs("div",{className:"sound-slot",children:[i.jsx("button",{ref:je,className:"btn icon-btn",onClick:()=>ke(q=>!q),...dr(!1),title:GF(ln,{on:W===!0,locked:it==="locked",prefs:me}),"aria-label":"Sound settings","aria-haspopup":"dialog","aria-expanded":ze,"aria-controls":ze?"sound-menu":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),W?i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),i.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M10 5.6l2.6 2.8"}),i.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),ze&&i.jsx(Vq,{onClose:()=>ke(!1),soundOn:W===!0,onToggleSound:J,prefs:me,onLevel:(q,z)=>ye(q,{level:z}),onFigure:(q,z)=>ye(q,{figure:z}),onPreview:q=>xe(q),notifyOn:tr,onToggleNotify:xo,notifyVetoed:Sa,notifyPermission:ks?_a:"unsupported",onAskNotify:bo,openerRef:je})]}),i.jsx("button",{className:"btn icon-btn",onClick:()=>cc(q=>q==="dark"?"light":"dark"),title:`Switch to ${ms==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:ms==="dark"?"☀":"☾"})]})]})]}),ki?i.jsxs("div",{className:"ver-banner done",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:["Restarted — now running v",ki,"."]}),i.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):uc&&!He?i.jsxs("div",{className:"conn-banner",role:"alert",children:[i.jsx("span",{className:"conn-dot"}),Zn?bi==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Wt}…`:(()=>{const q=oW({connected:He,paused:oo});return i.jsxs(i.Fragment,{children:[`Lost connection to the ${Wt} server. Reconnecting…`,q&&i.jsx("span",{className:"conn-sub",children:q})]})})()]}):Qn&&Ce?i.jsxs("div",{className:`ver-banner ${Ce.kind}`,role:"status",children:[i.jsx("span",{className:`ver-dot${er==null?"":" armed"}`}),Ce.kind==="restart"?i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:["v",Ce.to," is installed — this deck still runs v",Ce.from,"."]}),he!=null&&he.canRestart?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"ver-act",onClick:()=>xn(),...dr(Zn),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
266
266
 
@@ -40,7 +40,7 @@
40
40
  document.documentElement.setAttribute("data-theme", stored === "light" ? "light" : "dark");
41
41
  })();
42
42
  </script>
43
- <script type="module" crossorigin src="/assets/index-Ifm23DDC.js"></script>
43
+ <script type="module" crossorigin src="/assets/index-BDUK5zhD.js"></script>
44
44
  <link rel="stylesheet" crossorigin href="/assets/index-CJYsv0lr.css">
45
45
  </head>
46
46
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccdeck",
3
- "version": "3.22.1",
3
+ "version": "3.22.3",
4
4
  "description": "Live deck of Claude Code and Codex agents — watch tool calls, token spend and every Claude Code subagent on one calm canvas. Run it with npx ccdeck.",
5
5
  "type": "module",
6
6
  "bin": {