agent-dag 3.21.0 → 3.21.1
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.
|
@@ -256,7 +256,7 @@ Both CLIs get the finish tone. The second tone — Claude is waiting for you —
|
|
|
256
256
|
|
|
257
257
|
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+u+f+`
|
|
258
258
|
|
|
259
|
-
Click to set the volume and the sound of each tone, and to hear either one.`}function D2(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 LF(e){const t=D2([{agents:e}]);return t.length<2?null:t.map(n=>`${wx(n.id)} ${Ze(n.cost)}`).join(" · ")}function I1(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 DF(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Cu(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 qF=[7,14,30,90];function FF(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useState(AF)[0],c=b.useRef(!1),u=(f=!1)=>{if(f&&!hr(c.current))return;const p=l.begin();c.current=f;const h=e;a(!0);const y=`/api/ccusage?since=${kv(h)}${f?"&refresh=1":""}`;fetch(y).then(v=>v.json()).then(v=>{p()&&n({range:h,resp:v})}).catch(()=>{p()&&n({range:h,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(c.current=!1,a(!1))})};return b.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:t,loading:s,reload:()=>u(!0)}}function BF({onClose:e,providers:t}){var q;const[n,s]=b.useState(30),[a,l]=b.useState(null),{landed:c,loading:u,reload:f}=FF(n),p=b.useRef(null),h=Wt(e,{focusRef:p}),g=RF({loading:u,want:n,answer:c&&{range:c.range,ok:c.resp.ok===!0,days:((q=c.resp.days)==null?void 0:q.length)??0}}),y=g.phase==="chart"?c.resp.days??[]:[],v=b.useMemo(()=>y.reduce((P,M)=>Math.max(P,M.totalCost),0),[y]),S=b.useRef(null);b.useLayoutEffect(()=>{const P=S.current;P&&(P.scrollLeft=P.scrollWidth)},[y]);const{totalCost:_,totalTok:j,inOut:x,cacheRead:N,modelCosts:E}=b.useMemo(()=>{let P=0,M=0,O=0,V=0;const X=new Map;for(const A of y){P+=A.totalCost,M+=A.totalTokens,O+=A.inputTokens+A.outputTokens,V+=A.cacheReadTokens;for(const Z of A.modelBreakdowns)X.set(Z.modelName,(X.get(Z.modelName)??0)+Z.cost)}return{totalCost:P,totalTok:M,inOut:O,cacheRead:V,modelCosts:X}},[y]),C=b.useMemo(()=>Array.from(E.entries()).sort((P,M)=>M[1]-P[1]),[E]),R=b.useMemo(()=>D2(y),[y]),I=R.length>1,$=a?y.find(P=>P.period===a)??null:null;return i.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:h,className:"uh-modal",onClick:P=>P.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:$F(t,R.map(P=>P.id))})]}),i.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:qF.map(P=>i.jsxs("button",{type:"button","aria-pressed":n===P,className:"uh-range-btn",onClick:()=>{s(P),l(null)},children:[P,"d"]},P))}),i.jsx("button",{className:"glyph-btn uh-reload",onClick:f,...dr(u),title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),i.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.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})]}):g.phase==="error"?i.jsxs("div",{className:"uh-status uh-err",title:ai(c.resp)||void 0,children:[qD(c.resp,"ccusage did not report usage"),i.jsx("div",{children:i.jsx("button",{className:"btn uh-retry",onClick:f,...dr(u),children:u?"trying…":"Try again"})})]}):g.phase==="empty"?i.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):i.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[i.jsxs("div",{className:"uh-totals",children:[i.jsx(Tu,{label:"total cost",val:Ze(_),accent:!0}),i.jsx(Tu,{label:"tokens",val:At(j)}),i.jsx(Tu,{label:"input+output",val:At(x)}),i.jsx(Tu,{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(P=>i.jsx("span",{className:"uh-agent-seg",style:{width:`${_>0?P.cost/_*100:0}%`,background:I1(P.id)}},P.id))}),i.jsx("div",{className:"uh-agent-keys",children:R.map(P=>i.jsxs("span",{className:"uh-agent-key",title:`${P.id} · ${At(P.tokens)} tokens`,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:I1(P.id)}}),wx(P.id),i.jsx("span",{className:"uh-agent-cost",children:Ze(P.cost)}),i.jsx("span",{className:"uh-agent-share",children:DF(P.cost,_)})]},P.id))})]}),i.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map((P,M)=>{const O=v>0?P.totalCost/v*100:0,V=P.period===a,X=`${P.period}, ${Ze(P.totalCost)}`;return i.jsxs("button",{className:`uh-bar-col${V?" sel":""}`,onClick:()=>l(V?null:P.period),"aria-pressed":V,"aria-label":X,title:`${P.period} · ${Ze(P.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(O,P.totalCost>0?2:0)}%`},children:P.modelBreakdowns.slice().sort((A,Z)=>Z.cost-A.cost).map(A=>{const Z=P.totalCost>0?A.cost/P.totalCost*100:0;return i.jsx("div",{className:"uh-bar-seg",style:{height:`${Z}%`,background:Cu(A.modelName)}},A.modelName)})}),i.jsx("span",{className:"uh-bar-label",children:P.period.slice(5)})]},P.period)})}),i.jsx("div",{className:"uh-legend",children:C.map(([P,M])=>i.jsxs("span",{className:"uh-legend-item",title:P,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Cu(P)}}),Ys(P)," ",i.jsx("span",{className:"uh-legend-cost",children:Ze(M)})]},P))}),$&&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:Ze($.totalCost)}),(()=>{var O,V;const M=LF($.agents)??((V=(O=$.metadata)==null?void 0:O.agents)!=null&&V.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(Au,{label:"input",val:At($.inputTokens)}),i.jsx(Au,{label:"output",val:At($.outputTokens)}),i.jsx(Au,{label:"cache write",val:At($.cacheCreationTokens)}),i.jsx(Au,{label:"cache read",val:At($.cacheReadTokens)})]}),i.jsx("div",{className:"uh-detail-models",children:$.modelBreakdowns.slice().sort((P,M)=>M.cost-P.cost).map(P=>{const M=$.totalCost>0?P.cost/$.totalCost*100:0;return i.jsxs("div",{className:"uh-model-row",title:P.modelName,children:[i.jsxs("span",{className:"uh-model-name",children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Cu(P.modelName)}}),i.jsx("span",{className:"uh-model-label",children:Ys(P.modelName)})]}),i.jsx("span",{className:"uh-model-bar",children:i.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Cu(P.modelName)}})}),i.jsx("span",{className:"uh-model-cost",children:Ze(P.cost)})]},P.modelName)})})]})]})]})})}function Tu({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 Au({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 $1=1e4,UF=12e3;function WF({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 u=l.current;if(!u)return;const f=u.getContext("2d");if(!f)return;const p=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let h=0,g=!1;const y=()=>{var te;if(g)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,q=a(),P=Math.min(window.devicePixelRatio||1,2),M=u.clientWidth,O=u.clientHeight;(u.width!==M*P||u.height!==O*P)&&(u.width=M*P,u.height=O*P),f.setTransform(P,0,0,P,0,0),f.clearRect(0,0,M,O);const V=M/2,X=O/2,A=Math.min(M,O)/2-6;f.strokeStyle=E,f.lineWidth=1,f.globalAlpha=R?1:.9;for(const Q of[.4,.7,1])f.beginPath(),f.arc(V,X,A*Q,0,Math.PI*2),f.stroke();f.beginPath(),f.moveTo(V-A,X),f.lineTo(V+A,X),f.moveTo(V,X-A),f.lineTo(V,X+A),f.stroke(),f.globalAlpha=1;const B=(x&&!p?q%$1/$1:0)*Math.PI*2-Math.PI/2;if(x){const Q=(te=f.createConicGradient)==null?void 0:te.call(f,B-.85,V,X);Q&&(Q.addColorStop(0,"transparent"),Q.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${I}%, transparent)`),Q.addColorStop(1,"transparent"),f.fillStyle=Q,f.beginPath(),f.moveTo(V,X),f.arc(V,X,A,B-.85,B),f.closePath(),f.fill()),f.strokeStyle=N,f.globalAlpha=$,f.beginPath(),f.moveTo(V,X),f.lineTo(V+Math.cos(B)*A,X+Math.sin(B)*A),f.stroke(),f.globalAlpha=1}_.forEach((Q,D)=>{const K=D/Math.max(_.length,1)*Math.PI*2-Math.PI/2,L=Q.lastReadMs===null?1:Math.min(1,(q-Q.lastReadMs)/12e4),G=A*(.42+L*.5),de=V+Math.cos(K)*G,z=X+Math.sin(K)*G,U=Math.abs((B-K+Math.PI*3)%(Math.PI*2)-Math.PI),J=x?Math.max(0,1-U/.55):0;f.beginPath(),f.arc(de,z,3+J*1.6,0,Math.PI*2),f.fillStyle=Q.running?N:C,f.globalAlpha=Q.running?.55+J*.45:.35,f.fill(),f.globalAlpha=1});for(const Q of j){const D=(q-Q.atMs)/UF;if(D<0||D>1)continue;const L=Math.max(0,_.findIndex(z=>z.key===Q.browser))/Math.max(_.length,1)*Math.PI*2-Math.PI/2,G=V+Math.cos(L)*A*.6,de=X+Math.sin(L)*A*.6;f.beginPath(),f.arc(G,de,4+D*22,0,Math.PI*2),f.strokeStyle=N,f.globalAlpha=(1-D)*.8,f.lineWidth=1.5,f.stroke(),f.globalAlpha=1}h=requestAnimationFrame(y)};return y(),()=>{g=!0,cancelAnimationFrame(h)}},[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 O1="agent-dag.browserWatch.seenMs";function HF(e,t){return e.filter(n=>n.startMs>t)}function GF(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function VF(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 q2(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function P1(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 YF(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 KF(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 XF(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=q2(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 QF(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 ZF(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function L1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function JF({onClose:e,onSeen:t,onWatching:n,palette:s}){const a=Wt(e),[l,c]=b.useState(null),[u,f]=b.useState(null),[p,h]=b.useState(null),[g,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),[$,q]=b.useState(!1),[P,M]=b.useState(!1),[O,V]=b.useState(!1),[X,A]=b.useState(!1),[Z,B]=b.useState(()=>Date.now());b.useEffect(()=>{const H=setInterval(()=>B(Date.now()),1e3);return()=>clearInterval(H)},[]);const te=b.useCallback(async H=>{var oe,me;if(!(H&&!hr(v.current))){v.current=H,y(!0);try{const ye=await fetch(`/api/browser-watch${H?"?refresh=1":""}`);if(!ye.ok)throw new Error(`the deck answered ${ye.status}`);const Ee=await ye.json();c(Ee),C.current||_(((oe=Ee==null?void 0:Ee.settings)==null?void 0:oe.quietMinutes)??15),n(((me=Ee==null?void 0:Ee.settings)==null?void 0:me.enabled)===!0),f(null)}catch(ye){f(ye instanceof Error?ye.message:String(ye))}finally{v.current=!1,y(!1)}}},[n]);b.useEffect(()=>{te(!1)},[te]),b.useEffect(()=>{const H=setInterval(()=>{te(!1)},1e4);return()=>clearInterval(H)},[te]);const Q=b.useCallback(async H=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:H.host,startMs:H.startMs})})}finally{await te(!1)}},[te]),D=b.useCallback(async H=>{C.current=!0,E(!0);try{const oe=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(H)});if(!oe.ok)throw new Error(`the deck answered ${oe.status}`);await te(!1),h(null)}catch(oe){h(oe instanceof Error?oe.message:String(oe))}finally{C.current=!1,E(!1)}},[te]),K=b.useRef(t);K.current=t,b.useEffect(()=>()=>K.current(Date.now()),[]);const L=b.useMemo(()=>{const H=[];for(const oe of(l==null?void 0:l.episodes)??[]){const me=ZF(oe.startMs),ye=H[H.length-1];ye&&ye.label===me?ye.episodes.push(oe):H.push({label:me,episodes:[oe]})}return H},[l]),G=q2(l==null?void 0:l.browsers),de=((l==null?void 0:l.browsers)??[]).filter(H=>!(H.installed&&H.profiles>0)),z=l?XF(l):null,U=G.reduce((H,oe)=>H+oe.profiles,0),J=l?GF(l.coverage.lastHumanMs,l.coverage.quietMs,Z):null;return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal bw-modal",onClick:H=>H.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 te(!0),...dr(g),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:g?"…":"↻"}),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&&!u&&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."})]}),u&&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:u})]})}),l&&z&&i.jsx("p",{className:`bw-trouble ${z.kind}`,role:"status",children:z.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(H=>!H),"aria-expanded":P,"aria-label":"What the sweep and the dots mean",children:"?"})]}),i.jsxs("div",{className:"bw-glance",children:[i.jsx(WF,{browsers:G.map(H=>{var oe;return{key:H.key,name:H.name,running:H.running,lastReadMs:((oe=l.profiles.find(me=>me.browser===H.key))==null?void 0:oe.lastWrittenMs)??null}}),findings:l.episodes.slice(0,6).map(H=>({browser:H.browser??null,atMs:H.endMs})),watching:l.settings.enabled,palette:s}),i.jsx("ul",{className:"bw-counts",children:YF(G,l.profiles).map(H=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-count-n",children:H.visits.toLocaleString("en-US")}),i.jsx("span",{className:"bw-count-of",children:H.name})]},H.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 ",KF(l.coverage.checkedMs,Z),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 ",VF(J)]}),P&&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:()=>V(H=>!H),"aria-expanded":O,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),O&&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(H=>i.jsxs("li",{children:[i.jsx("span",{className:`bw-prof-dot${H.running?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-prof-name",children:H.name}),i.jsx("span",{className:"bw-prof-state",children:H.running?"running":"idle"}),H.running&&H.relay.state==="live"&&i.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},H.key))}),de.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>A(H=>!H),"aria-expanded":X,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:X?"▾":"▸"})," ",de.length," not watched"]}),X&&i.jsxs("p",{className:"bw-rest",children:[de.map(H=>H.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]}),l.relay&&i.jsx(e8,{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:L.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."})]}):L.map(H=>i.jsxs("div",{className:"bw-day",children:[i.jsx("h4",{className:"bw-sec-head",children:H.label}),H.episodes.map(oe=>{const me=`${oe.host}-${oe.startMs}`,ye=j===me;return i.jsxs("div",{className:`bw-ep${ye?" open":""}`,children:[i.jsxs("div",{className:"bw-ep-row",children:[i.jsxs("button",{className:"bw-ep-head",onClick:()=>x(ye?null:me),"aria-expanded":ye,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:ye?"▾":"▸"}),i.jsx("span",{className:"bw-ep-host",children:oe.host}),i.jsxs("span",{className:"bw-ep-meta",children:[QF(oe),L1(oe)&&i.jsxs(i.Fragment,{children:[" · ",L1(oe)]})]}),i.jsxs("span",{className:"bw-ep-count",children:[oe.count," ",oe.count===1?"page":"pages"]})]}),i.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Q(oe),"aria-label":`Dismiss ${oe.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),ye&&i.jsx("ul",{className:"bw-urls",children:oe.urls.map((Ee,Be)=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-url-time",children:new Date(Ee.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),i.jsx("span",{className:"bw-url",children:Ee.url})]},`${Ee.url}-${Ee.timeMs}-${Be}`))})]},me)})]},H.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(H=>i.jsxs("div",{className:`bw-log-line ${H.level}${H.parts?"":" sys"}`,children:[i.jsx("span",{className:"bw-log-time",children:new Date(H.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),H.parts?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"bw-log-browser",children:H.parts.browser}),i.jsx("span",{className:"bw-log-profile",title:H.parts.profile,children:H.parts.profile}),i.jsxs("span",{className:"bw-log-value",children:[H.parts.value,H.parts.flagged>0&&i.jsxs("span",{className:"bw-log-flag",children:[" · ",H.parts.flagged," flagged"]})]})]}):i.jsx("span",{className:"bw-log-sys",children:H.text})]},`${H.atMs}-${H.level}-${H.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:H=>{_(Number(H.target.value)),D({quietMinutes:Number(H.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:H=>void D({reaction:H.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(H=>i.jsx("option",{value:H,children:H==="notify"?"notify me":H==="close-tab"?"close the tab":"quit the browser"},H))})]}),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:()=>q(H=>!H),"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:()=>h(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:P1(l,N).word},P1(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(H=>!H),"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 e8({relay:e}){const[t,n]=b.useState(!1),[s,a]=b.useState(!1),l=e.killswitch.blocked?"unblock":"block",c=e.command[l],u=b.useCallback(async()=>{await T2(c.command)&&(a(!0),window.setTimeout(()=>a(!1),1600))},[c.command]),f=e.profiles.filter(h=>{var g;return(g=h.report)==null?void 0:g.present}),p=e.profiles.filter(h=>h.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(h=>i.jsx("code",{className:"bw-path",children:h},h))]}),i.jsxs("button",{className:"bw-why",onClick:()=>n(h=>!h),"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:[f.length>0&&i.jsx("dl",{className:"bw-key",children:f.map(h=>i.jsxs(b.Fragment,{children:[i.jsxs("dt",{children:[h.name,h.profile==="Default"?"":` · ${h.profile}`]}),i.jsxs("dd",{children:[h.report.enabled?"enabled":"installed but switched off",h.report.allUrls?", can act on every site":", limited to the sites it was granted",h.report.sensitiveApis.length>0&&i.jsxs(i.Fragment,{children:[" — ",h.report.sensitiveApis.join(", ")]})]})]},`${h.browser}/${h.profile}`))}),p.length>0&&i.jsxs("p",{className:"bw-rc-note",children:[p.map(h=>h.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."]}),f.some(h=>h.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:u,children:s?"Copied":"Copy"})]}),i.jsx("p",{className:"bw-rc-note",children:c.note})]})]})}function t8(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 n8({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:l,onLater:c}){const u=b.useRef(null),f=Wt(c,{focusRef:u}),p=Ks(n,"accept"),h=Ks(n,"dismiss");return i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:f,className:"modal lan-ask",onClick:g=>g.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 ",mx(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:u,className:"btn",disabled:h.disabled,"aria-busy":h.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 vx(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 If,D1;function r8(){if(D1)return If;D1=1;function e(){this.__data__=[],this.size=0}return If=e,If}var $f,q1;function hi(){if(q1)return $f;q1=1;function e(t,n){return t===n||t!==t&&n!==n}return $f=e,$f}var Of,F1;function vd(){if(F1)return Of;F1=1;var e=hi();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Of=t,Of}var Pf,B1;function s8(){if(B1)return Pf;B1=1;var e=vd(),t=Array.prototype,n=t.splice;function s(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var u=l.length-1;return c==u?l.pop():n.call(l,c,1),--this.size,!0}return Pf=s,Pf}var Lf,z1;function a8(){if(z1)return Lf;z1=1;var e=vd();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return Lf=t,Lf}var Df,U1;function o8(){if(U1)return Df;U1=1;var e=vd();function t(n){return e(this.__data__,n)>-1}return Df=t,Df}var qf,W1;function i8(){if(W1)return qf;W1=1;var e=vd();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 qf=t,qf}var Ff,H1;function xd(){if(H1)return Ff;H1=1;var e=r8(),t=s8(),n=a8(),s=o8(),a=i8();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];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,Ff=l,Ff}var Bf,G1;function l8(){if(G1)return Bf;G1=1;var e=xd();function t(){this.__data__=new e,this.size=0}return Bf=t,Bf}var zf,V1;function c8(){if(V1)return zf;V1=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return zf=e,zf}var Uf,Y1;function u8(){if(Y1)return Uf;Y1=1;function e(t){return this.__data__.get(t)}return Uf=e,Uf}var Wf,K1;function d8(){if(K1)return Wf;K1=1;function e(t){return this.__data__.has(t)}return Wf=e,Wf}var Hf,X1;function F2(){if(X1)return Hf;X1=1;var e=typeof cu=="object"&&cu&&cu.Object===Object&&cu;return Hf=e,Hf}var Gf,Q1;function yr(){if(Q1)return Gf;Q1=1;var e=F2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Gf=n,Gf}var Vf,Z1;function fi(){if(Z1)return Vf;Z1=1;var e=yr(),t=e.Symbol;return Vf=t,Vf}var Yf,J1;function h8(){if(J1)return Yf;J1=1;var e=fi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function l(c){var u=n.call(c,a),f=c[a];try{c[a]=void 0;var p=!0}catch{}var h=s.call(c);return p&&(u?c[a]=f:delete c[a]),h}return Yf=l,Yf}var Kf,e_;function f8(){if(e_)return Kf;e_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Kf=n,Kf}var Xf,t_;function Ua(){if(t_)return Xf;t_=1;var e=fi(),t=h8(),n=f8(),s="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(u){return u==null?u===void 0?a:s:l&&l in Object(u)?t(u):n(u)}return Xf=c,Xf}var Qf,n_;function Vn(){if(n_)return Qf;n_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Qf=e,Qf}var Zf,r_;function Vl(){if(r_)return Zf;r_=1;var e=Ua(),t=Vn(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(u){if(!t(u))return!1;var f=e(u);return f==s||f==a||f==n||f==l}return Zf=c,Zf}var Jf,s_;function p8(){if(s_)return Jf;s_=1;var e=yr(),t=e["__core-js_shared__"];return Jf=t,Jf}var ep,a_;function m8(){if(a_)return ep;a_=1;var e=p8(),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 ep=n,ep}var tp,o_;function B2(){if(o_)return tp;o_=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 tp=n,tp}var np,i_;function g8(){if(i_)return np;i_=1;var e=Vl(),t=m8(),n=Vn(),s=B2(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,f=c.toString,p=u.hasOwnProperty,h=RegExp("^"+f.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!n(y)||t(y))return!1;var v=e(y)?h:l;return v.test(s(y))}return np=g,np}var rp,l_;function y8(){if(l_)return rp;l_=1;function e(t,n){return t==null?void 0:t[n]}return rp=e,rp}var sp,c_;function Wa(){if(c_)return sp;c_=1;var e=g8(),t=y8();function n(s,a){var l=t(s,a);return e(l)?l:void 0}return sp=n,sp}var ap,u_;function xx(){if(u_)return ap;u_=1;var e=Wa(),t=yr(),n=e(t,"Map");return ap=n,ap}var op,d_;function bd(){if(d_)return op;d_=1;var e=Wa(),t=e(Object,"create");return op=t,op}var ip,h_;function w8(){if(h_)return ip;h_=1;var e=bd();function t(){this.__data__=e?e(null):{},this.size=0}return ip=t,ip}var lp,f_;function v8(){if(f_)return lp;f_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return lp=e,lp}var cp,p_;function x8(){if(p_)return cp;p_=1;var e=bd(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var u=c[l];return u===t?void 0:u}return s.call(c,l)?c[l]:void 0}return cp=a,cp}var up,m_;function b8(){if(m_)return up;m_=1;var e=bd(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return up=s,up}var dp,g_;function k8(){if(g_)return dp;g_=1;var e=bd(),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 dp=n,dp}var hp,y_;function _8(){if(y_)return hp;y_=1;var e=w8(),t=v8(),n=x8(),s=b8(),a=k8();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];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,hp=l,hp}var fp,w_;function N8(){if(w_)return fp;w_=1;var e=_8(),t=xd(),n=xx();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return fp=s,fp}var pp,v_;function S8(){if(v_)return pp;v_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return pp=e,pp}var mp,x_;function kd(){if(x_)return mp;x_=1;var e=S8();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return mp=t,mp}var gp,b_;function j8(){if(b_)return gp;b_=1;var e=kd();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return gp=t,gp}var yp,k_;function E8(){if(k_)return yp;k_=1;var e=kd();function t(n){return e(this,n).get(n)}return yp=t,yp}var wp,__;function C8(){if(__)return wp;__=1;var e=kd();function t(n){return e(this,n).has(n)}return wp=t,wp}var vp,N_;function T8(){if(N_)return vp;N_=1;var e=kd();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 vp=t,vp}var xp,S_;function bx(){if(S_)return xp;S_=1;var e=N8(),t=j8(),n=E8(),s=C8(),a=T8();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];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,xp=l,xp}var bp,j_;function A8(){if(j_)return bp;j_=1;var e=xd(),t=xx(),n=bx(),s=200;function a(l,c){var u=this.__data__;if(u instanceof e){var f=u.__data__;if(!t||f.length<s-1)return f.push([l,c]),this.size=++u.size,this;u=this.__data__=new n(f)}return u.set(l,c),this.size=u.size,this}return bp=a,bp}var kp,E_;function _d(){if(E_)return kp;E_=1;var e=xd(),t=l8(),n=c8(),s=u8(),a=d8(),l=A8();function c(u){var f=this.__data__=new e(u);this.size=f.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=s,c.prototype.has=a,c.prototype.set=l,kp=c,kp}var _p,C_;function kx(){if(C_)return _p;C_=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 _p=e,_p}var Np,T_;function z2(){if(T_)return Np;T_=1;var e=Wa(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Np=t,Np}var Sp,A_;function Nd(){if(A_)return Sp;A_=1;var e=z2();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Sp=t,Sp}var jp,R_;function Sd(){if(R_)return jp;R_=1;var e=Nd(),t=hi(),n=Object.prototype,s=n.hasOwnProperty;function a(l,c,u){var f=l[c];(!(s.call(l,c)&&t(f,u))||u===void 0&&!(c in l))&&e(l,c,u)}return jp=a,jp}var Ep,M_;function Yl(){if(M_)return Ep;M_=1;var e=Sd(),t=Nd();function n(s,a,l,c){var u=!l;l||(l={});for(var f=-1,p=a.length;++f<p;){var h=a[f],g=c?c(l[h],s[h],h,l,s):void 0;g===void 0&&(g=s[h]),u?t(l,h,g):e(l,h,g)}return l}return Ep=n,Ep}var Cp,I_;function R8(){if(I_)return Cp;I_=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return Cp=e,Cp}var Tp,$_;function $r(){if($_)return Tp;$_=1;function e(t){return t!=null&&typeof t=="object"}return Tp=e,Tp}var Ap,O_;function M8(){if(O_)return Ap;O_=1;var e=Ua(),t=$r(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Ap=s,Ap}var Rp,P_;function Kl(){if(P_)return Rp;P_=1;var e=M8(),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 Rp=l,Rp}var Mp,L_;function Mt(){if(L_)return Mp;L_=1;var e=Array.isArray;return Mp=e,Mp}var wl={exports:{}},Ip,D_;function I8(){if(D_)return Ip;D_=1;function e(){return!1}return Ip=e,Ip}wl.exports;var q_;function pi(){return q_||(q_=1,(function(e,t){var n=yr(),s=I8(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,u=c?n.Buffer:void 0,f=u?u.isBuffer:void 0,p=f||s;e.exports=p})(wl,wl.exports)),wl.exports}var $p,F_;function jd(){if(F_)return $p;F_=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 $p=n,$p}var Op,B_;function _x(){if(B_)return Op;B_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Op=t,Op}var Pp,z_;function $8(){if(z_)return Pp;z_=1;var e=Ua(),t=_x(),n=$r(),s="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",u="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",g="[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]",q="[object Uint8ClampedArray]",P="[object Uint16Array]",M="[object Uint32Array]",O={};O[N]=O[E]=O[C]=O[R]=O[I]=O[$]=O[q]=O[P]=O[M]=!0,O[s]=O[a]=O[j]=O[l]=O[x]=O[c]=O[u]=O[f]=O[p]=O[h]=O[g]=O[y]=O[v]=O[S]=O[_]=!1;function V(X){return n(X)&&t(X.length)&&!!O[e(X)]}return Pp=V,Pp}var Lp,U_;function Ed(){if(U_)return Lp;U_=1;function e(t){return function(n){return t(n)}}return Lp=e,Lp}var vl={exports:{}};vl.exports;var W_;function Nx(){return W_||(W_=1,(function(e,t){var n=F2(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l&&n.process,u=(function(){try{var f=a&&a.require&&a.require("util").types;return f||c&&c.binding&&c.binding("util")}catch{}})();e.exports=u})(vl,vl.exports)),vl.exports}var Dp,H_;function Xl(){if(H_)return Dp;H_=1;var e=$8(),t=Ed(),n=Nx(),s=n&&n.isTypedArray,a=s?t(s):e;return Dp=a,Dp}var qp,G_;function U2(){if(G_)return qp;G_=1;var e=R8(),t=Kl(),n=Mt(),s=pi(),a=jd(),l=Xl(),c=Object.prototype,u=c.hasOwnProperty;function f(p,h){var g=n(p),y=!g&&t(p),v=!g&&!y&&s(p),S=!g&&!y&&!v&&l(p),_=g||y||v||S,j=_?e(p.length,String):[],x=j.length;for(var N in p)(h||u.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 qp=f,qp}var Fp,V_;function Cd(){if(V_)return Fp;V_=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Fp=t,Fp}var Bp,Y_;function W2(){if(Y_)return Bp;Y_=1;function e(t,n){return function(s){return t(n(s))}}return Bp=e,Bp}var zp,K_;function O8(){if(K_)return zp;K_=1;var e=W2(),t=e(Object.keys,Object);return zp=t,zp}var Up,X_;function Sx(){if(X_)return Up;X_=1;var e=Cd(),t=O8(),n=Object.prototype,s=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var u in Object(l))s.call(l,u)&&u!="constructor"&&c.push(u);return c}return Up=a,Up}var Wp,Q_;function ls(){if(Q_)return Wp;Q_=1;var e=Vl(),t=_x();function n(s){return s!=null&&t(s.length)&&!e(s)}return Wp=n,Wp}var Hp,Z_;function Xs(){if(Z_)return Hp;Z_=1;var e=U2(),t=Sx(),n=ls();function s(a){return n(a)?e(a):t(a)}return Hp=s,Hp}var Gp,J_;function P8(){if(J_)return Gp;J_=1;var e=Yl(),t=Xs();function n(s,a){return s&&e(a,t(a),s)}return Gp=n,Gp}var Vp,eN;function L8(){if(eN)return Vp;eN=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Vp=e,Vp}var Yp,tN;function D8(){if(tN)return Yp;tN=1;var e=Vn(),t=Cd(),n=L8(),s=Object.prototype,a=s.hasOwnProperty;function l(c){if(!e(c))return n(c);var u=t(c),f=[];for(var p in c)p=="constructor"&&(u||!a.call(c,p))||f.push(p);return f}return Yp=l,Yp}var Kp,nN;function Ha(){if(nN)return Kp;nN=1;var e=U2(),t=D8(),n=ls();function s(a){return n(a)?e(a,!0):t(a)}return Kp=s,Kp}var Xp,rN;function q8(){if(rN)return Xp;rN=1;var e=Yl(),t=Ha();function n(s,a){return s&&e(a,t(a),s)}return Xp=n,Xp}var xl={exports:{}};xl.exports;var sN;function H2(){return sN||(sN=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,u=c?c.allocUnsafe:void 0;function f(p,h){if(h)return p.slice();var g=p.length,y=u?u(g):new p.constructor(g);return p.copy(y),y}e.exports=f})(xl,xl.exports)),xl.exports}var Qp,aN;function G2(){if(aN)return Qp;aN=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 Qp=e,Qp}var Zp,oN;function V2(){if(oN)return Zp;oN=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=0,c=[];++s<a;){var u=t[s];n(u,s,t)&&(c[l++]=u)}return c}return Zp=e,Zp}var Jp,iN;function Y2(){if(iN)return Jp;iN=1;function e(){return[]}return Jp=e,Jp}var em,lN;function jx(){if(lN)return em;lN=1;var e=V2(),t=Y2(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(u){return s.call(c,u)}))}:t;return em=l,em}var tm,cN;function F8(){if(cN)return tm;cN=1;var e=Yl(),t=jx();function n(s,a){return e(s,t(s),a)}return tm=n,tm}var nm,uN;function Ex(){if(uN)return nm;uN=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 nm=e,nm}var rm,dN;function Td(){if(dN)return rm;dN=1;var e=W2(),t=e(Object.getPrototypeOf,Object);return rm=t,rm}var sm,hN;function K2(){if(hN)return sm;hN=1;var e=Ex(),t=Td(),n=jx(),s=Y2(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var u=[];c;)e(u,n(c)),c=t(c);return u}:s;return sm=l,sm}var am,fN;function B8(){if(fN)return am;fN=1;var e=Yl(),t=K2();function n(s,a){return e(s,t(s),a)}return am=n,am}var om,pN;function X2(){if(pN)return om;pN=1;var e=Ex(),t=Mt();function n(s,a,l){var c=a(s);return t(s)?c:e(c,l(s))}return om=n,om}var im,mN;function Q2(){if(mN)return im;mN=1;var e=X2(),t=jx(),n=Xs();function s(a){return e(a,n,t)}return im=s,im}var lm,gN;function z8(){if(gN)return lm;gN=1;var e=X2(),t=K2(),n=Ha();function s(a){return e(a,n,t)}return lm=s,lm}var cm,yN;function U8(){if(yN)return cm;yN=1;var e=Wa(),t=yr(),n=e(t,"DataView");return cm=n,cm}var um,wN;function W8(){if(wN)return um;wN=1;var e=Wa(),t=yr(),n=e(t,"Promise");return um=n,um}var dm,vN;function Z2(){if(vN)return dm;vN=1;var e=Wa(),t=yr(),n=e(t,"Set");return dm=n,dm}var hm,xN;function H8(){if(xN)return hm;xN=1;var e=Wa(),t=yr(),n=e(t,"WeakMap");return hm=n,hm}var fm,bN;function mi(){if(bN)return fm;bN=1;var e=U8(),t=xx(),n=W8(),s=Z2(),a=H8(),l=Ua(),c=B2(),u="[object Map]",f="[object Object]",p="[object Promise]",h="[object Set]",g="[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)!=u||n&&N(n.resolve())!=p||s&&N(new s)!=h||a&&N(new a)!=g)&&(N=function(E){var C=l(E),R=C==f?E.constructor:void 0,I=R?c(R):"";if(I)switch(I){case v:return y;case S:return u;case _:return p;case j:return h;case x:return g}return C}),fm=N,fm}var pm,kN;function G8(){if(kN)return pm;kN=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 pm=n,pm}var mm,_N;function J2(){if(_N)return mm;_N=1;var e=yr(),t=e.Uint8Array;return mm=t,mm}var gm,NN;function Cx(){if(NN)return gm;NN=1;var e=J2();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return gm=t,gm}var ym,SN;function V8(){if(SN)return ym;SN=1;var e=Cx();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return ym=t,ym}var wm,jN;function Y8(){if(jN)return wm;jN=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return wm=t,wm}var vm,EN;function K8(){if(EN)return vm;EN=1;var e=fi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return vm=s,vm}var xm,CN;function eA(){if(CN)return xm;CN=1;var e=Cx();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return xm=t,xm}var bm,TN;function X8(){if(TN)return bm;TN=1;var e=Cx(),t=V8(),n=Y8(),s=K8(),a=eA(),l="[object Boolean]",c="[object Date]",u="[object Map]",f="[object Number]",p="[object RegExp]",h="[object Set]",g="[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 q(P,M,O){var V=P.constructor;switch(M){case v:return e(P);case l:case c:return new V(+P);case S:return t(P,O);case _:case j:case x:case N:case E:case C:case R:case I:case $:return a(P,O);case u:return new V;case f:case g:return new V(P);case p:return n(P);case h:return new V;case y:return s(P)}}return bm=q,bm}var km,AN;function tA(){if(AN)return km;AN=1;var e=Vn(),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 km=n,km}var _m,RN;function nA(){if(RN)return _m;RN=1;var e=tA(),t=Td(),n=Cd();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return _m=s,_m}var Nm,MN;function Q8(){if(MN)return Nm;MN=1;var e=mi(),t=$r(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return Nm=s,Nm}var Sm,IN;function Z8(){if(IN)return Sm;IN=1;var e=Q8(),t=Ed(),n=Nx(),s=n&&n.isMap,a=s?t(s):e;return Sm=a,Sm}var jm,$N;function J8(){if($N)return jm;$N=1;var e=mi(),t=$r(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return jm=s,jm}var Em,ON;function eB(){if(ON)return Em;ON=1;var e=J8(),t=Ed(),n=Nx(),s=n&&n.isSet,a=s?t(s):e;return Em=a,Em}var Cm,PN;function rA(){if(PN)return Cm;PN=1;var e=_d(),t=kx(),n=Sd(),s=P8(),a=q8(),l=H2(),c=G2(),u=F8(),f=B8(),p=Q2(),h=z8(),g=mi(),y=G8(),v=X8(),S=nA(),_=Mt(),j=pi(),x=Z8(),N=Vn(),E=eB(),C=Xs(),R=Ha(),I=1,$=2,q=4,P="[object Arguments]",M="[object Array]",O="[object Boolean]",V="[object Date]",X="[object Error]",A="[object Function]",Z="[object GeneratorFunction]",B="[object Map]",te="[object Number]",Q="[object Object]",D="[object RegExp]",K="[object Set]",L="[object String]",G="[object Symbol]",de="[object WeakMap]",z="[object ArrayBuffer]",U="[object DataView]",J="[object Float32Array]",H="[object Float64Array]",oe="[object Int8Array]",me="[object Int16Array]",ye="[object Int32Array]",Ee="[object Uint8Array]",Be="[object Uint8ClampedArray]",ce="[object Uint16Array]",Ne="[object Uint32Array]",ve={};ve[P]=ve[M]=ve[z]=ve[U]=ve[O]=ve[V]=ve[J]=ve[H]=ve[oe]=ve[me]=ve[ye]=ve[B]=ve[te]=ve[Q]=ve[D]=ve[K]=ve[L]=ve[G]=ve[Ee]=ve[Be]=ve[ce]=ve[Ne]=!0,ve[X]=ve[A]=ve[de]=!1;function Fe(he,ke,Ke,pe,dt,ot){var Ve,ge=ke&I,Se=ke&$,qe=ke&q;if(Ke&&(Ve=dt?Ke(he,pe,dt,ot):Ke(he)),Ve!==void 0)return Ve;if(!N(he))return he;var Ye=_(he);if(Ye){if(Ve=y(he),!ge)return c(he,Ve)}else{var it=g(he),Je=it==A||it==Z;if(j(he))return l(he,ge);if(it==Q||it==P||Je&&!dt){if(Ve=Se||Je?{}:S(he),!ge)return Se?f(he,a(Ve,he)):u(he,s(Ve,he))}else{if(!ve[it])return dt?he:{};Ve=v(he,it,ge)}}ot||(ot=new e);var re=ot.get(he);if(re)return re;ot.set(he,Ve),E(he)?he.forEach(function(Te){Ve.add(Fe(Te,ke,Ke,Te,he,ot))}):x(he)&&he.forEach(function(Te,He){Ve.set(He,Fe(Te,ke,Ke,He,he,ot))});var we=qe?Se?h:p:Se?R:C,Le=Ye?void 0:we(he);return t(Le||he,function(Te,He){Le&&(He=Te,Te=he[He]),n(Ve,He,Fe(Te,ke,Ke,He,he,ot))}),Ve}return Cm=Fe,Cm}var Tm,LN;function tB(){if(LN)return Tm;LN=1;var e=rA(),t=4;function n(s){return e(s,t)}return Tm=n,Tm}var Am,DN;function Tx(){if(DN)return Am;DN=1;function e(t){return function(){return t}}return Am=e,Am}var Rm,qN;function nB(){if(qN)return Rm;qN=1;function e(t){return function(n,s,a){for(var l=-1,c=Object(n),u=a(n),f=u.length;f--;){var p=u[t?f:++l];if(s(c[p],p,c)===!1)break}return n}}return Rm=e,Rm}var Mm,FN;function Ax(){if(FN)return Mm;FN=1;var e=nB(),t=e();return Mm=t,Mm}var Im,BN;function Rx(){if(BN)return Im;BN=1;var e=Ax(),t=Xs();function n(s,a){return s&&e(s,a,t)}return Im=n,Im}var $m,zN;function rB(){if(zN)return $m;zN=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,u=s?c:-1,f=Object(a);(s?u--:++u<c)&&l(f[u],u,f)!==!1;);return a}}return $m=t,$m}var Om,UN;function Ad(){if(UN)return Om;UN=1;var e=Rx(),t=rB(),n=t(e);return Om=n,Om}var Pm,WN;function Ga(){if(WN)return Pm;WN=1;function e(t){return t}return Pm=e,Pm}var Lm,HN;function sA(){if(HN)return Lm;HN=1;var e=Ga();function t(n){return typeof n=="function"?n:e}return Lm=t,Lm}var Dm,GN;function aA(){if(GN)return Dm;GN=1;var e=kx(),t=Ad(),n=sA(),s=Mt();function a(l,c){var u=s(l)?e:t;return u(l,n(c))}return Dm=a,Dm}var qm,VN;function oA(){return VN||(VN=1,qm=aA()),qm}var Fm,YN;function sB(){if(YN)return Fm;YN=1;var e=Ad();function t(n,s){var a=[];return e(n,function(l,c,u){s(l,c,u)&&a.push(l)}),a}return Fm=t,Fm}var Bm,KN;function aB(){if(KN)return Bm;KN=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Bm=t,Bm}var zm,XN;function oB(){if(XN)return zm;XN=1;function e(t){return this.__data__.has(t)}return zm=e,zm}var Um,QN;function iA(){if(QN)return Um;QN=1;var e=bx(),t=aB(),n=oB();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,Um=s,Um}var Wm,ZN;function iB(){if(ZN)return Wm;ZN=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 Wm=e,Wm}var Hm,JN;function lA(){if(JN)return Hm;JN=1;function e(t,n){return t.has(n)}return Hm=e,Hm}var Gm,eS;function cA(){if(eS)return Gm;eS=1;var e=iA(),t=iB(),n=lA(),s=1,a=2;function l(c,u,f,p,h,g){var y=f&s,v=c.length,S=u.length;if(v!=S&&!(y&&S>v))return!1;var _=g.get(c),j=g.get(u);if(_&&j)return _==u&&j==c;var x=-1,N=!0,E=f&a?new e:void 0;for(g.set(c,u),g.set(u,c);++x<v;){var C=c[x],R=u[x];if(p)var I=y?p(R,C,x,u,c,g):p(C,R,x,c,u,g);if(I!==void 0){if(I)continue;N=!1;break}if(E){if(!t(u,function($,q){if(!n(E,q)&&(C===$||h(C,$,f,p,g)))return E.push(q)})){N=!1;break}}else if(!(C===R||h(C,R,f,p,g))){N=!1;break}}return g.delete(c),g.delete(u),N}return Gm=l,Gm}var Vm,tS;function lB(){if(tS)return Vm;tS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,l){s[++n]=[l,a]}),s}return Vm=e,Vm}var Ym,nS;function Mx(){if(nS)return Ym;nS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Ym=e,Ym}var Km,rS;function cB(){if(rS)return Km;rS=1;var e=fi(),t=J2(),n=hi(),s=cA(),a=lB(),l=Mx(),c=1,u=2,f="[object Boolean]",p="[object Date]",h="[object Error]",g="[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,$,q,P,M,O,V){switch(q){case N:if(I.byteLength!=$.byteLength||I.byteOffset!=$.byteOffset)return!1;I=I.buffer,$=$.buffer;case x:return!(I.byteLength!=$.byteLength||!O(new t(I),new t($)));case f:case p:case y:return n(+I,+$);case h:return I.name==$.name&&I.message==$.message;case v:case _:return I==$+"";case g:var X=a;case S:var A=P&c;if(X||(X=l),I.size!=$.size&&!A)return!1;var Z=V.get(I);if(Z)return Z==$;P|=u,V.set(I,$);var B=s(X(I),X($),P,M,O,V);return V.delete(I),B;case j:if(C)return C.call(I)==C.call($)}return!1}return Km=R,Km}var Xm,sS;function uB(){if(sS)return Xm;sS=1;var e=Q2(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(l,c,u,f,p,h){var g=u&t,y=e(l),v=y.length,S=e(c),_=S.length;if(v!=_&&!g)return!1;for(var j=v;j--;){var x=y[j];if(!(g?x in c:s.call(c,x)))return!1}var N=h.get(l),E=h.get(c);if(N&&E)return N==c&&E==l;var C=!0;h.set(l,c),h.set(c,l);for(var R=g;++j<v;){x=y[j];var I=l[x],$=c[x];if(f)var q=g?f($,I,x,c,l,h):f(I,$,x,l,c,h);if(!(q===void 0?I===$||p(I,$,u,f,h):q)){C=!1;break}R||(R=x=="constructor")}if(C&&!R){var P=l.constructor,M=c.constructor;P!=M&&"constructor"in l&&"constructor"in c&&!(typeof P=="function"&&P instanceof P&&typeof M=="function"&&M instanceof M)&&(C=!1)}return h.delete(l),h.delete(c),C}return Xm=a,Xm}var Qm,aS;function dB(){if(aS)return Qm;aS=1;var e=_d(),t=cA(),n=cB(),s=uB(),a=mi(),l=Mt(),c=pi(),u=Xl(),f=1,p="[object Arguments]",h="[object Array]",g="[object Object]",y=Object.prototype,v=y.hasOwnProperty;function S(_,j,x,N,E,C){var R=l(_),I=l(j),$=R?h:a(_),q=I?h:a(j);$=$==p?g:$,q=q==p?g:q;var P=$==g,M=q==g,O=$==q;if(O&&c(_)){if(!c(j))return!1;R=!0,P=!1}if(O&&!P)return C||(C=new e),R||u(_)?t(_,j,x,N,E,C):n(_,j,$,x,N,E,C);if(!(x&f)){var V=P&&v.call(_,"__wrapped__"),X=M&&v.call(j,"__wrapped__");if(V||X){var A=V?_.value():_,Z=X?j.value():j;return C||(C=new e),E(A,Z,x,N,C)}}return O?(C||(C=new e),s(_,j,x,N,E,C)):!1}return Qm=S,Qm}var Zm,oS;function uA(){if(oS)return Zm;oS=1;var e=dB(),t=$r();function n(s,a,l,c,u){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,l,c,n,u)}return Zm=n,Zm}var Jm,iS;function hB(){if(iS)return Jm;iS=1;var e=_d(),t=uA(),n=1,s=2;function a(l,c,u,f){var p=u.length,h=p,g=!f;if(l==null)return!h;for(l=Object(l);p--;){var y=u[p];if(g&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<h;){y=u[p];var v=y[0],S=l[v],_=y[1];if(g&&y[2]){if(S===void 0&&!(v in l))return!1}else{var j=new e;if(f)var x=f(S,_,v,l,c,j);if(!(x===void 0?t(_,S,n|s,f,j):x))return!1}}return!0}return Jm=a,Jm}var eg,lS;function dA(){if(lS)return eg;lS=1;var e=Vn();function t(n){return n===n&&!e(n)}return eg=t,eg}var tg,cS;function fB(){if(cS)return tg;cS=1;var e=dA(),t=Xs();function n(s){for(var a=t(s),l=a.length;l--;){var c=a[l],u=s[c];a[l]=[c,u,e(u)]}return a}return tg=n,tg}var ng,uS;function hA(){if(uS)return ng;uS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return ng=e,ng}var rg,dS;function pB(){if(dS)return rg;dS=1;var e=hB(),t=fB(),n=hA();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 rg=s,rg}var sg,hS;function gi(){if(hS)return sg;hS=1;var e=Ua(),t=$r(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return sg=s,sg}var ag,fS;function Ix(){if(fS)return ag;fS=1;var e=Mt(),t=gi(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(l,c){if(e(l))return!1;var u=typeof l;return u=="number"||u=="symbol"||u=="boolean"||l==null||t(l)?!0:s.test(l)||!n.test(l)||c!=null&&l in Object(c)}return ag=a,ag}var og,pS;function mB(){if(pS)return og;pS=1;var e=bx(),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,u=a?a.apply(this,c):c[0],f=l.cache;if(f.has(u))return f.get(u);var p=s.apply(this,c);return l.cache=f.set(u,p)||f,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,og=n,og}var ig,mS;function gB(){if(mS)return ig;mS=1;var e=mB(),t=500;function n(s){var a=e(s,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return ig=n,ig}var lg,gS;function yB(){if(gS)return lg;gS=1;var e=gB(),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,u,f,p){l.push(f?p.replace(n,"$1"):u||c)}),l});return lg=s,lg}var cg,yS;function Rd(){if(yS)return cg;yS=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 cg=e,cg}var ug,wS;function wB(){if(wS)return ug;wS=1;var e=fi(),t=Rd(),n=Mt(),s=gi(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(u){if(typeof u=="string")return u;if(n(u))return t(u,c)+"";if(s(u))return l?l.call(u):"";var f=u+"";return f=="0"&&1/u==-1/0?"-0":f}return ug=c,ug}var dg,vS;function fA(){if(vS)return dg;vS=1;var e=wB();function t(n){return n==null?"":e(n)}return dg=t,dg}var hg,xS;function Md(){if(xS)return hg;xS=1;var e=Mt(),t=Ix(),n=yB(),s=fA();function a(l,c){return e(l)?l:t(l,c)?[l]:n(s(l))}return hg=a,hg}var fg,bS;function Ql(){if(bS)return fg;bS=1;var e=gi();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return fg=t,fg}var pg,kS;function Id(){if(kS)return pg;kS=1;var e=Md(),t=Ql();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 pg=n,pg}var mg,_S;function vB(){if(_S)return mg;_S=1;var e=Id();function t(n,s,a){var l=n==null?void 0:e(n,s);return l===void 0?a:l}return mg=t,mg}var gg,NS;function xB(){if(NS)return gg;NS=1;function e(t,n){return t!=null&&n in Object(t)}return gg=e,gg}var yg,SS;function pA(){if(SS)return yg;SS=1;var e=Md(),t=Kl(),n=Mt(),s=jd(),a=_x(),l=Ql();function c(u,f,p){f=e(f,u);for(var h=-1,g=f.length,y=!1;++h<g;){var v=l(f[h]);if(!(y=u!=null&&p(u,v)))break;u=u[v]}return y||++h!=g?y:(g=u==null?0:u.length,!!g&&a(g)&&s(v,g)&&(n(u)||t(u)))}return yg=c,yg}var wg,jS;function mA(){if(jS)return wg;jS=1;var e=xB(),t=pA();function n(s,a){return s!=null&&t(s,a,e)}return wg=n,wg}var vg,ES;function bB(){if(ES)return vg;ES=1;var e=uA(),t=vB(),n=mA(),s=Ix(),a=dA(),l=hA(),c=Ql(),u=1,f=2;function p(h,g){return s(h)&&a(g)?l(c(h),g):function(y){var v=t(y,h);return v===void 0&&v===g?n(y,h):e(g,v,u|f)}}return vg=p,vg}var xg,CS;function gA(){if(CS)return xg;CS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return xg=e,xg}var bg,TS;function kB(){if(TS)return bg;TS=1;var e=Id();function t(n){return function(s){return e(s,n)}}return bg=t,bg}var kg,AS;function _B(){if(AS)return kg;AS=1;var e=gA(),t=kB(),n=Ix(),s=Ql();function a(l){return n(l)?e(s(l)):t(l)}return kg=a,kg}var _g,RS;function cs(){if(RS)return _g;RS=1;var e=pB(),t=bB(),n=Ga(),s=Mt(),a=_B();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 _g=l,_g}var Ng,MS;function yA(){if(MS)return Ng;MS=1;var e=V2(),t=sB(),n=cs(),s=Mt();function a(l,c){var u=s(l)?e:t;return u(l,n(c,3))}return Ng=a,Ng}var Sg,IS;function NB(){if(IS)return Sg;IS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Sg=n,Sg}var jg,$S;function wA(){if($S)return jg;$S=1;var e=NB(),t=pA();function n(s,a){return s!=null&&t(s,a,e)}return jg=n,jg}var Eg,OS;function SB(){if(OS)return Eg;OS=1;var e=Sx(),t=mi(),n=Kl(),s=Mt(),a=ls(),l=pi(),c=Cd(),u=Xl(),f="[object Map]",p="[object Set]",h=Object.prototype,g=h.hasOwnProperty;function y(v){if(v==null)return!0;if(a(v)&&(s(v)||typeof v=="string"||typeof v.splice=="function"||l(v)||u(v)||n(v)))return!v.length;var S=t(v);if(S==f||S==p)return!v.size;if(c(v))return!e(v).length;for(var _ in v)if(g.call(v,_))return!1;return!0}return Eg=y,Eg}var Cg,PS;function vA(){if(PS)return Cg;PS=1;function e(t){return t===void 0}return Cg=e,Cg}var Tg,LS;function xA(){if(LS)return Tg;LS=1;var e=Ad(),t=ls();function n(s,a){var l=-1,c=t(s)?Array(s.length):[];return e(s,function(u,f,p){c[++l]=a(u,f,p)}),c}return Tg=n,Tg}var Ag,DS;function bA(){if(DS)return Ag;DS=1;var e=Rd(),t=cs(),n=xA(),s=Mt();function a(l,c){var u=s(l)?e:n;return u(l,t(c,3))}return Ag=a,Ag}var Rg,qS;function jB(){if(qS)return Rg;qS=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 Rg=e,Rg}var Mg,FS;function EB(){if(FS)return Mg;FS=1;function e(t,n,s,a,l){return l(t,function(c,u,f){s=a?(a=!1,c):n(s,c,u,f)}),s}return Mg=e,Mg}var Ig,BS;function kA(){if(BS)return Ig;BS=1;var e=jB(),t=Ad(),n=cs(),s=EB(),a=Mt();function l(c,u,f){var p=a(c)?e:s,h=arguments.length<3;return p(c,n(u,4),f,h,t)}return Ig=l,Ig}var $g,zS;function CB(){if(zS)return $g;zS=1;var e=Ua(),t=Mt(),n=$r(),s="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==s}return $g=a,$g}var Og,US;function TB(){if(US)return Og;US=1;var e=gA(),t=e("length");return Og=t,Og}var Pg,WS;function AB(){if(WS)return Pg;WS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="\\u200d",u=RegExp("["+c+e+a+l+"]");function f(p){return u.test(p)}return Pg=f,Pg}var Lg,HS;function RB(){if(HS)return Lg;HS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="["+e+"]",u="["+a+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+f+")",h="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",S=p+"?",_="["+l+"]?",j="(?:"+v+"(?:"+[h,g,y].join("|")+")"+_+S+")*",x=_+S+j,N="(?:"+[h+u+"?",u,g,y,c].join("|")+")",E=RegExp(f+"(?="+f+")|"+N+x,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return Lg=C,Lg}var Dg,GS;function MB(){if(GS)return Dg;GS=1;var e=TB(),t=AB(),n=RB();function s(a){return t(a)?n(a):e(a)}return Dg=s,Dg}var qg,VS;function IB(){if(VS)return qg;VS=1;var e=Sx(),t=mi(),n=ls(),s=CB(),a=MB(),l="[object Map]",c="[object Set]";function u(f){if(f==null)return 0;if(n(f))return s(f)?a(f):f.length;var p=t(f);return p==l||p==c?f.size:e(f).length}return qg=u,qg}var Fg,YS;function $B(){if(YS)return Fg;YS=1;var e=kx(),t=tA(),n=Rx(),s=cs(),a=Td(),l=Mt(),c=pi(),u=Vl(),f=Vn(),p=Xl();function h(g,y,v){var S=l(g),_=S||c(g)||p(g);if(y=s(y,4),v==null){var j=g&&g.constructor;_?v=S?new j:[]:f(g)?v=u(j)?t(a(g)):{}:v={}}return(_?e:n)(g,function(x,N,E){return y(v,x,N,E)}),v}return Fg=h,Fg}var Bg,KS;function OB(){if(KS)return Bg;KS=1;var e=fi(),t=Kl(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(s&&l&&l[s])}return Bg=a,Bg}var zg,XS;function $x(){if(XS)return zg;XS=1;var e=Ex(),t=OB();function n(s,a,l,c,u){var f=-1,p=s.length;for(l||(l=t),u||(u=[]);++f<p;){var h=s[f];a>0&&l(h)?a>1?n(h,a-1,l,c,u):e(u,h):c||(u[u.length]=h)}return u}return zg=n,zg}var Ug,QS;function PB(){if(QS)return Ug;QS=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 Ug=e,Ug}var Wg,ZS;function _A(){if(ZS)return Wg;ZS=1;var e=PB(),t=Math.max;function n(s,a,l){return a=t(a===void 0?s.length-1:a,0),function(){for(var c=arguments,u=-1,f=t(c.length-a,0),p=Array(f);++u<f;)p[u]=c[a+u];u=-1;for(var h=Array(a+1);++u<a;)h[u]=c[u];return h[a]=l(p),e(s,this,h)}}return Wg=n,Wg}var Hg,JS;function LB(){if(JS)return Hg;JS=1;var e=Tx(),t=z2(),n=Ga(),s=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return Hg=s,Hg}var Gg,ej;function DB(){if(ej)return Gg;ej=1;var e=800,t=16,n=Date.now;function s(a){var l=0,c=0;return function(){var u=n(),f=t-(u-c);if(c=u,f>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return Gg=s,Gg}var Vg,tj;function NA(){if(tj)return Vg;tj=1;var e=LB(),t=DB(),n=t(e);return Vg=n,Vg}var Yg,nj;function $d(){if(nj)return Yg;nj=1;var e=Ga(),t=_A(),n=NA();function s(a,l){return n(t(a,l,e),a+"")}return Yg=s,Yg}var Kg,rj;function SA(){if(rj)return Kg;rj=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 Kg=e,Kg}var Xg,sj;function qB(){if(sj)return Xg;sj=1;function e(t){return t!==t}return Xg=e,Xg}var Qg,aj;function FB(){if(aj)return Qg;aj=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 Qg=e,Qg}var Zg,oj;function BB(){if(oj)return Zg;oj=1;var e=SA(),t=qB(),n=FB();function s(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return Zg=s,Zg}var Jg,ij;function zB(){if(ij)return Jg;ij=1;var e=BB();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return Jg=t,Jg}var ey,lj;function UB(){if(lj)return ey;lj=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 ey=e,ey}var ty,cj;function WB(){if(cj)return ty;cj=1;function e(){}return ty=e,ty}var ny,uj;function HB(){if(uj)return ny;uj=1;var e=Z2(),t=WB(),n=Mx(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(l){return new e(l)}:t;return ny=a,ny}var ry,dj;function GB(){if(dj)return ry;dj=1;var e=iA(),t=zB(),n=UB(),s=lA(),a=HB(),l=Mx(),c=200;function u(f,p,h){var g=-1,y=t,v=f.length,S=!0,_=[],j=_;if(h)S=!1,y=n;else if(v>=c){var x=p?null:a(f);if(x)return l(x);S=!1,y=s,j=new e}else j=p?[]:_;e:for(;++g<v;){var N=f[g],E=p?p(N):N;if(N=h||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,h)||(j!==_&&j.push(E),_.push(N))}return _}return ry=u,ry}var sy,hj;function jA(){if(hj)return sy;hj=1;var e=ls(),t=$r();function n(s){return t(s)&&e(s)}return sy=n,sy}var ay,fj;function VB(){if(fj)return ay;fj=1;var e=$x(),t=$d(),n=GB(),s=jA(),a=t(function(l){return n(e(l,1,s,!0))});return ay=a,ay}var oy,pj;function YB(){if(pj)return oy;pj=1;var e=Rd();function t(n,s){return e(s,function(a){return n[a]})}return oy=t,oy}var iy,mj;function EA(){if(mj)return iy;mj=1;var e=YB(),t=Xs();function n(s){return s==null?[]:e(s,t(s))}return iy=n,iy}var ly,gj;function Yn(){if(gj)return ly;gj=1;var e;if(typeof vx=="function")try{e={clone:tB(),constant:Tx(),each:oA(),filter:yA(),has:wA(),isArray:Mt(),isEmpty:SB(),isFunction:Vl(),isUndefined:vA(),keys:Xs(),map:bA(),reduce:kA(),size:IB(),transform:$B(),union:VB(),values:EA()}}catch{}return e||(e=window._),ly=e,ly}var cy,yj;function Ox(){if(yj)return cy;yj=1;var e=Yn();cy=a;var t="\0",n="\0",s="";function a(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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(h){return this._label=h,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._in[g])})},a.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._out[g])})},a.prototype.setNodes=function(h,g){var y=arguments,v=this;return e.each(h,function(S){y.length>1?v.setNode(S,g):v.setNode(S)}),this},a.prototype.setNode=function(h,g){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=g),this):(this._nodes[h]=arguments.length>1?g:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=n,this._children[h]={},this._children[n][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},a.prototype.node=function(h){return this._nodes[h]},a.prototype.hasNode=function(h){return e.has(this._nodes,h)},a.prototype.removeNode=function(h){var g=this;if(e.has(this._nodes,h)){var y=function(v){g.removeEdge(g._edgeObjs[v])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(v){g.setParent(v)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},a.prototype.setParent=function(h,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=n;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===h)throw new Error("Setting "+g+" as parent of "+h+" would create a cycle");this.setNode(g)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=g,this._children[g][h]=!0,this},a.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},a.prototype.parent=function(h){if(this._isCompound){var g=this._parent[h];if(g!==n)return g}},a.prototype.children=function(h){if(e.isUndefined(h)&&(h=n),this._isCompound){var g=this._children[h];if(g)return e.keys(g)}else{if(h===n)return this.nodes();if(this.hasNode(h))return[]}},a.prototype.predecessors=function(h){var g=this._preds[h];if(g)return e.keys(g)},a.prototype.successors=function(h){var g=this._sucs[h];if(g)return e.keys(g)},a.prototype.neighbors=function(h){var g=this.predecessors(h);if(g)return e.union(g,this.successors(h))},a.prototype.isLeaf=function(h){var g;return this.isDirected()?g=this.successors(h):g=this.neighbors(h),g.length===0},a.prototype.filterNodes=function(h){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,j){h(j)&&g.setNode(j,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var v={};function S(_){var j=y.parent(_);return j===void 0||g.hasNode(j)?(v[_]=j,j):j in v?v[j]:S(j)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,S(_))}),g},a.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(h,g){var y=this,v=arguments;return e.reduce(h,function(S,_){return v.length>1?y.setEdge(S,_,g):y.setEdge(S,_),_}),this},a.prototype.setEdge=function(){var h,g,y,v,S=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,g=_.w,y=_.name,arguments.length===2&&(v=arguments[1],S=!0)):(h=_,g=arguments[1],y=arguments[3],arguments.length>2&&(v=arguments[2],S=!0)),h=""+h,g=""+g,e.isUndefined(y)||(y=""+y);var j=u(this._isDirected,h,g,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(h),this.setNode(g),this._edgeLabels[j]=S?v:this._defaultEdgeLabelFn(h,g,y);var x=f(this._isDirected,h,g,y);return h=x.v,g=x.w,Object.freeze(x),this._edgeObjs[j]=x,l(this._preds[g],h),l(this._sucs[h],g),this._in[g][j]=x,this._out[h][j]=x,this._edgeCount++,this},a.prototype.edge=function(h,g,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,g,y);return this._edgeLabels[v]},a.prototype.hasEdge=function(h,g,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,g,y);return e.has(this._edgeLabels,v)},a.prototype.removeEdge=function(h,g,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,g,y),S=this._edgeObjs[v];return S&&(h=S.v,g=S.w,delete this._edgeLabels[v],delete this._edgeObjs[v],c(this._preds[g],h),c(this._sucs[h],g),delete this._in[g][v],delete this._out[h][v],this._edgeCount--),this},a.prototype.inEdges=function(h,g){var y=this._in[h];if(y){var v=e.values(y);return g?e.filter(v,function(S){return S.v===g}):v}},a.prototype.outEdges=function(h,g){var y=this._out[h];if(y){var v=e.values(y);return g?e.filter(v,function(S){return S.w===g}):v}},a.prototype.nodeEdges=function(h,g){var y=this.inEdges(h,g);if(y)return y.concat(this.outEdges(h,g))};function l(h,g){h[g]?h[g]++:h[g]=1}function c(h,g){--h[g]||delete h[g]}function u(h,g,y,v){var S=""+g,_=""+y;if(!h&&S>_){var j=S;S=_,_=j}return S+s+_+s+(e.isUndefined(v)?t:v)}function f(h,g,y,v){var S=""+g,_=""+y;if(!h&&S>_){var j=S;S=_,_=j}var x={v:S,w:_};return v&&(x.name=v),x}function p(h,g){return u(h,g.v,g.w,g.name)}return cy}var uy,wj;function KB(){return wj||(wj=1,uy="2.1.8"),uy}var dy,vj;function XB(){return vj||(vj=1,dy={Graph:Ox(),version:KB()}),dy}var hy,xj;function QB(){if(xj)return hy;xj=1;var e=Yn(),t=Ox();hy={write:n,read:l};function n(c){var u={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:s(c),edges:a(c)};return e.isUndefined(c.graph())||(u.value=e.clone(c.graph())),u}function s(c){return e.map(c.nodes(),function(u){var f=c.node(u),p=c.parent(u),h={v:u};return e.isUndefined(f)||(h.value=f),e.isUndefined(p)||(h.parent=p),h})}function a(c){return e.map(c.edges(),function(u){var f=c.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(f)||(p.value=f),p})}function l(c){var u=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(f){u.setNode(f.v,f.value),f.parent&&u.setParent(f.v,f.parent)}),e.each(c.edges,function(f){u.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),u}return hy}var fy,bj;function ZB(){if(bj)return fy;bj=1;var e=Yn();fy=t;function t(n){var s={},a=[],l;function c(u){e.has(s,u)||(s[u]=!0,l.push(u),e.each(n.successors(u),c),e.each(n.predecessors(u),c))}return e.each(n.nodes(),function(u){l=[],c(u),l.length&&a.push(l)}),a}return fy}var py,kj;function CA(){if(kj)return py;kj=1;var e=Yn();py=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],u=a[s];a[n]=u,a[s]=c,l[u.key]=n,l[c.key]=s},py}var my,_j;function TA(){if(_j)return my;_j=1;var e=Yn(),t=CA();my=s;var n=e.constant(1);function s(l,c,u,f){return a(l,String(c),u||n,f||function(p){return l.outEdges(p)})}function a(l,c,u,f){var p={},h=new t,g,y,v=function(S){var _=S.v!==g?S.v:S.w,j=p[_],x=u(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=g,h.decrease(_,N))};for(l.nodes().forEach(function(S){var _=S===c?0:Number.POSITIVE_INFINITY;p[S]={distance:_},h.add(S,_)});h.size()>0&&(g=h.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)f(g).forEach(v);return p}return my}var gy,Nj;function JB(){if(Nj)return gy;Nj=1;var e=TA(),t=Yn();gy=n;function n(s,a,l){return t.transform(s.nodes(),function(c,u){c[u]=e(s,u,a,l)},{})}return gy}var yy,Sj;function AA(){if(Sj)return yy;Sj=1;var e=Yn();yy=t;function t(n){var s=0,a=[],l={},c=[];function u(f){var p=l[f]={onStack:!0,lowlink:s,index:s++};if(a.push(f),n.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(u(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var h=[],g;do g=a.pop(),l[g].onStack=!1,h.push(g);while(f!==g);c.push(h)}}return n.nodes().forEach(function(f){e.has(l,f)||u(f)}),c}return yy}var wy,jj;function ez(){if(jj)return wy;jj=1;var e=Yn(),t=AA();wy=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 wy}var vy,Ej;function tz(){if(Ej)return vy;Ej=1;var e=Yn();vy=n;var t=e.constant(1);function n(a,l,c){return s(a,l||t,c||function(u){return a.outEdges(u)})}function s(a,l,c){var u={},f=a.nodes();return f.forEach(function(p){u[p]={},u[p][p]={distance:0},f.forEach(function(h){p!==h&&(u[p][h]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(h){var g=h.v===p?h.w:h.v,y=l(h);u[p][g]={distance:y,predecessor:p}})}),f.forEach(function(p){var h=u[p];f.forEach(function(g){var y=u[g];f.forEach(function(v){var S=y[p],_=h[v],j=y[v],x=S.distance+_.distance;x<j.distance&&(j.distance=x,j.predecessor=_.predecessor)})})}),u}return vy}var xy,Cj;function RA(){if(Cj)return xy;Cj=1;var e=Yn();xy=t,t.CycleException=n;function t(s){var a={},l={},c=[];function u(f){if(e.has(l,f))throw new n;e.has(a,f)||(l[f]=!0,a[f]=!0,e.each(s.predecessors(f),u),delete l[f],c.push(f))}if(e.each(s.sinks(),u),e.size(a)!==s.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,xy}var by,Tj;function nz(){if(Tj)return by;Tj=1;var e=RA();by=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return by}var ky,Aj;function MA(){if(Aj)return ky;Aj=1;var e=Yn();ky=t;function t(s,a,l){e.isArray(a)||(a=[a]);var c=(s.isDirected()?s.successors:s.neighbors).bind(s),u=[],f={};return e.each(a,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,l==="post",f,c,u)}),u}function n(s,a,l,c,u,f){e.has(c,a)||(c[a]=!0,l||f.push(a),e.each(u(a),function(p){n(s,p,l,c,u,f)}),l&&f.push(a))}return ky}var _y,Rj;function rz(){if(Rj)return _y;Rj=1;var e=MA();_y=t;function t(n,s){return e(n,s,"post")}return _y}var Ny,Mj;function sz(){if(Mj)return Ny;Mj=1;var e=MA();Ny=t;function t(n,s){return e(n,s,"pre")}return Ny}var Sy,Ij;function az(){if(Ij)return Sy;Ij=1;var e=Yn(),t=Ox(),n=CA();Sy=s;function s(a,l){var c=new t,u={},f=new n,p;function h(y){var v=y.v===p?y.w:y.v,S=f.priority(v);if(S!==void 0){var _=l(y);_<S&&(u[v]=p,f.decrease(v,_))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),f.decrease(a.nodes()[0],0);for(var g=!1;f.size()>0;){if(p=f.removeMin(),e.has(u,p))c.setEdge(p,u[p]);else{if(g)throw new Error("Input graph is not connected: "+a);g=!0}a.nodeEdges(p).forEach(h)}return c}return Sy}var jy,$j;function oz(){return $j||($j=1,jy={components:ZB(),dijkstra:TA(),dijkstraAll:JB(),findCycles:ez(),floydWarshall:tz(),isAcyclic:nz(),postorder:rz(),preorder:sz(),prim:az(),tarjan:AA(),topsort:RA()}),jy}var Ey,Oj;function iz(){if(Oj)return Ey;Oj=1;var e=XB();return Ey={Graph:e.Graph,json:QB(),alg:oz(),version:e.version},Ey}var Cy,Pj;function mr(){if(Pj)return Cy;Pj=1;var e;if(typeof vx=="function")try{e=iz()}catch{}return e||(e=window.graphlib),Cy=e,Cy}var Ty,Lj;function lz(){if(Lj)return Ty;Lj=1;var e=rA(),t=1,n=4;function s(a){return e(a,t|n)}return Ty=s,Ty}var Ay,Dj;function Od(){if(Dj)return Ay;Dj=1;var e=hi(),t=ls(),n=jd(),s=Vn();function a(l,c,u){if(!s(u))return!1;var f=typeof c;return(f=="number"?t(u)&&n(c,u.length):f=="string"&&c in u)?e(u[c],l):!1}return Ay=a,Ay}var Ry,qj;function cz(){if(qj)return Ry;qj=1;var e=$d(),t=hi(),n=Od(),s=Ha(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(u,f){u=Object(u);var p=-1,h=f.length,g=h>2?f[2]:void 0;for(g&&n(f[0],f[1],g)&&(h=1);++p<h;)for(var y=f[p],v=s(y),S=-1,_=v.length;++S<_;){var j=v[S],x=u[j];(x===void 0||t(x,a[j])&&!l.call(u,j))&&(u[j]=y[j])}return u});return Ry=c,Ry}var My,Fj;function uz(){if(Fj)return My;Fj=1;var e=cs(),t=ls(),n=Xs();function s(a){return function(l,c,u){var f=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(g){return p(f[g],g,f)}}var h=a(l,c,u);return h>-1?f[p?l[h]:h]:void 0}}return My=s,My}var Iy,Bj;function dz(){if(Bj)return Iy;Bj=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Iy=t,Iy}var $y,zj;function hz(){if(zj)return $y;zj=1;var e=dz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return $y=n,$y}var Oy,Uj;function fz(){if(Uj)return Oy;Uj=1;var e=hz(),t=Vn(),n=gi(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;function f(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=t(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=l.test(p);return g||c.test(p)?u(p.slice(2),g?2:8):a.test(p)?s:+p}return Oy=f,Oy}var Py,Wj;function IA(){if(Wj)return Py;Wj=1;var e=fz(),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 Py=s,Py}var Ly,Hj;function pz(){if(Hj)return Ly;Hj=1;var e=IA();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return Ly=t,Ly}var Dy,Gj;function mz(){if(Gj)return Dy;Gj=1;var e=SA(),t=cs(),n=pz(),s=Math.max;function a(l,c,u){var f=l==null?0:l.length;if(!f)return-1;var p=u==null?0:n(u);return p<0&&(p=s(f+p,0)),e(l,t(c,3),p)}return Dy=a,Dy}var qy,Vj;function gz(){if(Vj)return qy;Vj=1;var e=uz(),t=mz(),n=e(t);return qy=n,qy}var Fy,Yj;function $A(){if(Yj)return Fy;Yj=1;var e=$x();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Fy=t,Fy}var By,Kj;function yz(){if(Kj)return By;Kj=1;var e=Ax(),t=sA(),n=Ha();function s(a,l){return a==null?a:e(a,t(l),n)}return By=s,By}var zy,Xj;function wz(){if(Xj)return zy;Xj=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return zy=e,zy}var Uy,Qj;function vz(){if(Qj)return Uy;Qj=1;var e=Nd(),t=Rx(),n=cs();function s(a,l){var c={};return l=n(l,3),t(a,function(u,f,p){e(c,f,l(u,f,p))}),c}return Uy=s,Uy}var Wy,Zj;function Px(){if(Zj)return Wy;Zj=1;var e=gi();function t(n,s,a){for(var l=-1,c=n.length;++l<c;){var u=n[l],f=s(u);if(f!=null&&(p===void 0?f===f&&!e(f):a(f,p)))var p=f,h=u}return h}return Wy=t,Wy}var Hy,Jj;function xz(){if(Jj)return Hy;Jj=1;function e(t,n){return t>n}return Hy=e,Hy}var Gy,eE;function bz(){if(eE)return Gy;eE=1;var e=Px(),t=xz(),n=Ga();function s(a){return a&&a.length?e(a,n,t):void 0}return Gy=s,Gy}var Vy,tE;function OA(){if(tE)return Vy;tE=1;var e=Nd(),t=hi();function n(s,a,l){(l!==void 0&&!t(s[a],l)||l===void 0&&!(a in s))&&e(s,a,l)}return Vy=n,Vy}var Yy,nE;function kz(){if(nE)return Yy;nE=1;var e=Ua(),t=Td(),n=$r(),s="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,u=l.hasOwnProperty,f=c.call(Object);function p(h){if(!n(h)||e(h)!=s)return!1;var g=t(h);if(g===null)return!0;var y=u.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==f}return Yy=p,Yy}var Ky,rE;function PA(){if(rE)return Ky;rE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Ky=e,Ky}var Xy,sE;function _z(){if(sE)return Xy;sE=1;var e=Yl(),t=Ha();function n(s){return e(s,t(s))}return Xy=n,Xy}var Qy,aE;function Nz(){if(aE)return Qy;aE=1;var e=OA(),t=H2(),n=eA(),s=G2(),a=nA(),l=Kl(),c=Mt(),u=jA(),f=pi(),p=Vl(),h=Vn(),g=kz(),y=Xl(),v=PA(),S=_z();function _(j,x,N,E,C,R,I){var $=v(j,N),q=v(x,N),P=I.get(q);if(P){e(j,N,P);return}var M=R?R($,q,N+"",j,x,I):void 0,O=M===void 0;if(O){var V=c(q),X=!V&&f(q),A=!V&&!X&&y(q);M=q,V||X||A?c($)?M=$:u($)?M=s($):X?(O=!1,M=t(q,!0)):A?(O=!1,M=n(q,!0)):M=[]:g(q)||l(q)?(M=$,l($)?M=S($):(!h($)||p($))&&(M=a(q))):O=!1}O&&(I.set(q,M),C(M,q,E,R,I),I.delete(q)),e(j,N,M)}return Qy=_,Qy}var Zy,oE;function Sz(){if(oE)return Zy;oE=1;var e=_d(),t=OA(),n=Ax(),s=Nz(),a=Vn(),l=Ha(),c=PA();function u(f,p,h,g,y){f!==p&&n(p,function(v,S){if(y||(y=new e),a(v))s(f,p,S,h,u,g,y);else{var _=g?g(c(f,S),v,S+"",f,p,y):void 0;_===void 0&&(_=v),t(f,S,_)}},l)}return Zy=u,Zy}var Jy,iE;function jz(){if(iE)return Jy;iE=1;var e=$d(),t=Od();function n(s){return e(function(a,l){var c=-1,u=l.length,f=u>1?l[u-1]:void 0,p=u>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(u--,f):void 0,p&&t(l[0],l[1],p)&&(f=u<3?void 0:f,u=1),a=Object(a);++c<u;){var h=l[c];h&&s(a,h,c,f)}return a})}return Jy=n,Jy}var ew,lE;function Ez(){if(lE)return ew;lE=1;var e=Sz(),t=jz(),n=t(function(s,a,l){e(s,a,l)});return ew=n,ew}var tw,cE;function LA(){if(cE)return tw;cE=1;function e(t,n){return t<n}return tw=e,tw}var nw,uE;function Cz(){if(uE)return nw;uE=1;var e=Px(),t=LA(),n=Ga();function s(a){return a&&a.length?e(a,n,t):void 0}return nw=s,nw}var rw,dE;function Tz(){if(dE)return rw;dE=1;var e=Px(),t=cs(),n=LA();function s(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return rw=s,rw}var sw,hE;function Az(){if(hE)return sw;hE=1;var e=yr(),t=function(){return e.Date.now()};return sw=t,sw}var aw,fE;function Rz(){if(fE)return aw;fE=1;var e=Sd(),t=Md(),n=jd(),s=Vn(),a=Ql();function l(c,u,f,p){if(!s(c))return c;u=t(u,c);for(var h=-1,g=u.length,y=g-1,v=c;v!=null&&++h<g;){var S=a(u[h]),_=f;if(S==="__proto__"||S==="constructor"||S==="prototype")return c;if(h!=y){var j=v[S];_=p?p(j,S,v):void 0,_===void 0&&(_=s(j)?j:n(u[h+1])?[]:{})}e(v,S,_),v=v[S]}return c}return aw=l,aw}var ow,pE;function Mz(){if(pE)return ow;pE=1;var e=Id(),t=Rz(),n=Md();function s(a,l,c){for(var u=-1,f=l.length,p={};++u<f;){var h=l[u],g=e(a,h);c(g,h)&&t(p,n(h,a),g)}return p}return ow=s,ow}var iw,mE;function Iz(){if(mE)return iw;mE=1;var e=Mz(),t=mA();function n(s,a){return e(s,a,function(l,c){return t(s,c)})}return iw=n,iw}var lw,gE;function $z(){if(gE)return lw;gE=1;var e=$A(),t=_A(),n=NA();function s(a){return n(t(a,void 0,e),a+"")}return lw=s,lw}var cw,yE;function Oz(){if(yE)return cw;yE=1;var e=Iz(),t=$z(),n=t(function(s,a){return s==null?{}:e(s,a)});return cw=n,cw}var uw,wE;function Pz(){if(wE)return uw;wE=1;var e=Math.ceil,t=Math.max;function n(s,a,l,c){for(var u=-1,f=t(e((a-s)/(l||1)),0),p=Array(f);f--;)p[c?f:++u]=s,s+=l;return p}return uw=n,uw}var dw,vE;function Lz(){if(vE)return dw;vE=1;var e=Pz(),t=Od(),n=IA();function s(a){return function(l,c,u){return u&&typeof u!="number"&&t(l,c,u)&&(c=u=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),u=u===void 0?l<c?1:-1:n(u),e(l,c,u,a)}}return dw=s,dw}var hw,xE;function Dz(){if(xE)return hw;xE=1;var e=Lz(),t=e();return hw=t,hw}var fw,bE;function qz(){if(bE)return fw;bE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return fw=e,fw}var pw,kE;function Fz(){if(kE)return pw;kE=1;var e=gi();function t(n,s){if(n!==s){var a=n!==void 0,l=n===null,c=n===n,u=e(n),f=s!==void 0,p=s===null,h=s===s,g=e(s);if(!p&&!g&&!u&&n>s||u&&f&&h&&!p&&!g||l&&f&&h||!a&&h||!c)return 1;if(!l&&!u&&!g&&n<s||g&&a&&c&&!l&&!u||p&&a&&c||!f&&c||!h)return-1}return 0}return pw=t,pw}var mw,_E;function Bz(){if(_E)return mw;_E=1;var e=Fz();function t(n,s,a){for(var l=-1,c=n.criteria,u=s.criteria,f=c.length,p=a.length;++l<f;){var h=e(c[l],u[l]);if(h){if(l>=p)return h;var g=a[l];return h*(g=="desc"?-1:1)}}return n.index-s.index}return mw=t,mw}var gw,NE;function zz(){if(NE)return gw;NE=1;var e=Rd(),t=Id(),n=cs(),s=xA(),a=qz(),l=Ed(),c=Bz(),u=Ga(),f=Mt();function p(h,g,y){g.length?g=e(g,function(_){return f(_)?function(j){return t(j,_.length===1?_[0]:_)}:_}):g=[u];var v=-1;g=e(g,l(n));var S=s(h,function(_,j,x){var N=e(g,function(E){return E(_)});return{criteria:N,index:++v,value:_}});return a(S,function(_,j){return c(_,j,y)})}return gw=p,gw}var yw,SE;function Uz(){if(SE)return yw;SE=1;var e=$x(),t=zz(),n=$d(),s=Od(),a=n(function(l,c){if(l==null)return[];var u=c.length;return u>1&&s(l,c[0],c[1])?c=[]:u>2&&s(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return yw=a,yw}var ww,jE;function Wz(){if(jE)return ww;jE=1;var e=fA(),t=0;function n(s){var a=++t;return e(s)+a}return ww=n,ww}var vw,EE;function Hz(){if(EE)return vw;EE=1;function e(t,n,s){for(var a=-1,l=t.length,c=n.length,u={};++a<l;){var f=a<c?n[a]:void 0;s(u,t[a],f)}return u}return vw=e,vw}var xw,CE;function Gz(){if(CE)return xw;CE=1;var e=Sd(),t=Hz();function n(s,a){return t(s||[],a||[],e)}return xw=n,xw}var bw,TE;function xt(){if(TE)return bw;TE=1;var e;if(typeof vx=="function")try{e={cloneDeep:lz(),constant:Tx(),defaults:cz(),each:oA(),filter:yA(),find:gz(),flatten:$A(),forEach:aA(),forIn:yz(),has:wA(),isUndefined:vA(),last:wz(),map:bA(),mapValues:vz(),max:bz(),merge:Ez(),min:Cz(),minBy:Tz(),now:Az(),pick:Oz(),range:Dz(),reduce:kA(),sortBy:Uz(),uniqueId:Wz(),values:EA(),zipObject:Gz()}}catch{}return e||(e=window._),bw=e,bw}var kw,AE;function Vz(){if(AE)return kw;AE=1,kw=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 kw}var _w,RE;function Yz(){if(RE)return _w;RE=1;var e=xt(),t=mr().Graph,n=Vz();_w=a;var s=e.constant(1);function a(p,h){if(p.nodeCount()<=1)return[];var g=u(p,h||s),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(v){return p.outEdges(v.v,v.w)}),!0)}function l(p,h,g){for(var y=[],v=h[h.length-1],S=h[0],_;p.nodeCount();){for(;_=S.dequeue();)c(p,h,g,_);for(;_=v.dequeue();)c(p,h,g,_);if(p.nodeCount()){for(var j=h.length-2;j>0;--j)if(_=h[j].dequeue(),_){y=y.concat(c(p,h,g,_,!0));break}}}return y}function c(p,h,g,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,f(h,g,x)}),e.forEach(p.outEdges(y.v),function(_){var j=p.edge(_),x=_.w,N=p.node(x);N.in-=j,f(h,g,N)}),p.removeNode(y.v),S}function u(p,h){var g=new t,y=0,v=0;e.forEach(p.nodes(),function(j){g.setNode(j,{v:j,in:0,out:0})}),e.forEach(p.edges(),function(j){var x=g.edge(j.v,j.w)||0,N=h(j),E=x+N;g.setEdge(j.v,j.w,E),v=Math.max(v,g.node(j.v).out+=N),y=Math.max(y,g.node(j.w).in+=N)});var S=e.range(v+y+3).map(function(){return new n}),_=y+1;return e.forEach(g.nodes(),function(j){f(S,_,g.node(j))}),{graph:g,buckets:S,zeroIdx:_}}function f(p,h,g){g.out?g.in?p[g.out-g.in+h].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return _w}var Nw,ME;function Kz(){if(ME)return Nw;ME=1;var e=xt(),t=Yz();Nw={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,u(l)):s(l);e.forEach(c,function(f){var p=l.edge(f);l.removeEdge(f),p.forwardName=f.name,p.reversed=!0,l.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function u(f){return function(p){return f.edge(p).weight}}}function s(l){var c=[],u={},f={};function p(h){e.has(f,h)||(f[h]=!0,u[h]=!0,e.forEach(l.outEdges(h),function(g){e.has(u,g.w)?c.push(g):p(g.w)}),delete u[h])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var u=l.edge(c);if(u.reversed){l.removeEdge(c);var f=u.forwardName;delete u.reversed,delete u.forwardName,l.setEdge(c.w,c.v,u,f)}})}return Nw}var Sw,IE;function wn(){if(IE)return Sw;IE=1;var e=xt(),t=mr().Graph;Sw={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:u,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:g,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 u(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 q,P;return Math.abs(R)*I>Math.abs(C)*$?(R<0&&($=-$),q=$*C/R,P=$):(C<0&&(I=-I),q=I,P=I*R/C),{x:N+q,y:E+P}}function f(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 h(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 g(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 Sw}var jw,$E;function Xz(){if($E)return jw;$E=1;var e=xt(),t=wn();jw={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){s(l,c)})}function s(l,c){var u=c.v,f=l.node(u).rank,p=c.w,h=l.node(p).rank,g=c.name,y=l.edge(c),v=y.labelRank;if(h!==f+1){l.removeEdge(c);var S,_,j;for(j=0,++f;f<h;++j,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:c,rank:f},S=t.addDummyNode(l,"edge",_,"_d"),f===v&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(u,S,{weight:y.weight},g),j===0&&l.graph().dummyChains.push(S),u=S;l.setEdge(u,p,{weight:y.weight},g)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var u=l.node(c),f=u.edgeLabel,p;for(l.setEdge(u.edgeObj,f);u.dummy;)p=l.successors(c)[0],l.removeNode(c),f.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(f.x=u.x,f.y=u.y,f.width=u.width,f.height=u.height),c=p,u=l.node(c)})}return jw}var Ew,OE;function sd(){if(OE)return Ew;OE=1;var e=xt();Ew={longestPath:t,slack:n};function t(s){var a={};function l(c){var u=s.node(c);if(e.has(a,c))return u.rank;a[c]=!0;var f=e.min(e.map(s.outEdges(c),function(p){return l(p.w)-s.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),u.rank=f}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 Ew}var Cw,PE;function DA(){if(PE)return Cw;PE=1;var e=xt(),t=mr().Graph,n=sd().slack;Cw=s;function s(u){var f=new t({directed:!1}),p=u.nodes()[0],h=u.nodeCount();f.setNode(p,{});for(var g,y;a(f,u)<h;)g=l(f,u),y=f.hasNode(g.v)?n(u,g):-n(u,g),c(f,u,y);return f}function a(u,f){function p(h){e.forEach(f.nodeEdges(h),function(g){var y=g.v,v=h===y?g.w:y;!u.hasNode(v)&&!n(f,g)&&(u.setNode(v,{}),u.setEdge(h,v,{}),p(v))})}return e.forEach(u.nodes(),p),u.nodeCount()}function l(u,f){return e.minBy(f.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(f,p)})}function c(u,f,p){e.forEach(u.nodes(),function(h){f.node(h).rank+=p})}return Cw}var Tw,LE;function Qz(){if(LE)return Tw;LE=1;var e=xt(),t=DA(),n=sd().slack,s=sd().longestPath,a=mr().alg.preorder,l=mr().alg.postorder,c=wn().simplify;Tw=u,u.initLowLimValues=g,u.initCutValues=f,u.calcCutValue=h,u.leaveEdge=v,u.enterEdge=S,u.exchangeEdges=_;function u(E){E=c(E),s(E);var C=t(E);g(C),f(C,E);for(var R,I;R=v(C);)I=S(C,E,R),_(C,E,R,I)}function f(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=h(E,C,R)}function h(E,C,R){var I=E.node(R),$=I.parent,q=!0,P=C.edge(R,$),M=0;return P||(q=!1,P=C.edge($,R)),M=P.weight,e.forEach(C.nodeEdges(R),function(O){var V=O.v===R,X=V?O.w:O.v;if(X!==$){var A=V===q,Z=C.edge(O).weight;if(M+=A?Z:-Z,x(E,R,X)){var B=E.edge(R,X).cutvalue;M+=A?-B:B}}}),M}function g(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,$){var q=R,P=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))}),P.low=q,P.lim=R++,$?P.parent=$:delete P.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 q=E.node(I),P=E.node($),M=q,O=!1;q.lim>P.lim&&(M=P,O=!0);var V=e.filter(C.edges(),function(X){return O===N(E,E.node(X.v),M)&&O!==N(E,E.node(X.w),M)});return e.minBy(V,function(X){return n(C,X)})}function _(E,C,R,I){var $=R.v,q=R.w;E.removeEdge($,q),E.setEdge(I.v,I.w,{}),g(E),f(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 q=E.node($).parent,P=C.edge($,q),M=!1;P||(P=C.edge(q,$),M=!0),C.node($).rank=C.node(q).rank+(M?P.minlen:-P.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 Tw}var Aw,DE;function Zz(){if(DE)return Aw;DE=1;var e=sd(),t=e.longestPath,n=DA(),s=Qz();Aw=a;function a(f){switch(f.graph().ranker){case"network-simplex":u(f);break;case"tight-tree":c(f);break;case"longest-path":l(f);break;default:u(f)}}var l=t;function c(f){t(f),n(f)}function u(f){s(f)}return Aw}var Rw,qE;function Jz(){if(qE)return Rw;qE=1;var e=xt();Rw=t;function t(a){var l=s(a);e.forEach(a.graph().dummyChains,function(c){for(var u=a.node(c),f=u.edgeObj,p=n(a,l,f.v,f.w),h=p.path,g=p.lca,y=0,v=h[y],S=!0;c!==f.w;){if(u=a.node(c),S){for(;(v=h[y])!==g&&a.node(v).maxRank<u.rank;)y++;v===g&&(S=!1)}if(!S){for(;y<h.length-1&&a.node(v=h[y+1]).minRank<=u.rank;)y++;v=h[y]}a.setParent(c,v),c=a.successors(c)[0]}})}function n(a,l,c,u){var f=[],p=[],h=Math.min(l[c].low,l[u].low),g=Math.max(l[c].lim,l[u].lim),y,v;y=c;do y=a.parent(y),f.push(y);while(y&&(l[y].low>h||g>l[y].lim));for(v=y,y=u;(y=a.parent(y))!==v;)p.push(y);return{path:f.concat(p.reverse()),lca:v}}function s(a){var l={},c=0;function u(f){var p=c;e.forEach(a.children(f),u),l[f]={low:p,lim:c++}}return e.forEach(a.children(),u),l}return Rw}var Mw,FE;function eU(){if(FE)return Mw;FE=1;var e=xt(),t=wn();Mw={run:n,cleanup:c};function n(u){var f=t.addDummyNode(u,"root",{},"_root"),p=a(u),h=e.max(e.values(p))-1,g=2*h+1;u.graph().nestingRoot=f,e.forEach(u.edges(),function(v){u.edge(v).minlen*=g});var y=l(u)+1;e.forEach(u.children(),function(v){s(u,f,g,y,h,p,v)}),u.graph().nodeRankFactor=g}function s(u,f,p,h,g,y,v){var S=u.children(v);if(!S.length){v!==f&&u.setEdge(f,v,{weight:0,minlen:p});return}var _=t.addBorderNode(u,"_bt"),j=t.addBorderNode(u,"_bb"),x=u.node(v);u.setParent(_,v),x.borderTop=_,u.setParent(j,v),x.borderBottom=j,e.forEach(S,function(N){s(u,f,p,h,g,y,N);var E=u.node(N),C=E.borderTop?E.borderTop:N,R=E.borderBottom?E.borderBottom:N,I=E.borderTop?h:2*h,$=C!==R?1:g-y[v]+1;u.setEdge(_,C,{weight:I,minlen:$,nestingEdge:!0}),u.setEdge(R,j,{weight:I,minlen:$,nestingEdge:!0})}),u.parent(v)||u.setEdge(f,_,{weight:0,minlen:g+y[v]})}function a(u){var f={};function p(h,g){var y=u.children(h);y&&y.length&&e.forEach(y,function(v){p(v,g+1)}),f[h]=g}return e.forEach(u.children(),function(h){p(h,1)}),f}function l(u){return e.reduce(u.edges(),function(f,p){return f+u.edge(p).weight},0)}function c(u){var f=u.graph();u.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(u.edges(),function(p){var h=u.edge(p);h.nestingEdge&&u.removeEdge(p)})}return Mw}var Iw,BE;function tU(){if(BE)return Iw;BE=1;var e=xt(),t=wn();Iw=n;function n(a){function l(c){var u=a.children(c),f=a.node(c);if(u.length&&e.forEach(u,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,h=f.maxRank+1;p<h;++p)s(a,"borderLeft","_bl",c,f,p),s(a,"borderRight","_br",c,f,p)}}e.forEach(a.children(),l)}function s(a,l,c,u,f,p){var h={width:0,height:0,rank:p,borderType:l},g=f[l][p-1],y=t.addDummyNode(a,"border",h,c);f[l][p]=y,a.setParent(y,u),g&&a.setEdge(g,y,{weight:1})}return Iw}var $w,zE;function nU(){if(zE)return $w;zE=1;var e=xt();$w={adjust:t,undo:n};function t(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&s(p)}function n(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(p),(h==="lr"||h==="rl")&&(u(p),s(p))}function s(p){e.forEach(p.nodes(),function(h){a(p.node(h))}),e.forEach(p.edges(),function(h){a(p.edge(h))})}function a(p){var h=p.width;p.width=p.height,p.height=h}function l(p){e.forEach(p.nodes(),function(h){c(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,c),e.has(g,"y")&&c(g)})}function c(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(h){f(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,f),e.has(g,"x")&&f(g)})}function f(p){var h=p.x;p.x=p.y,p.y=h}return $w}var Ow,UE;function rU(){if(UE)return Ow;UE=1;var e=xt();Ow=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 u(p){if(!e.has(s,p)){s[p]=!0;var h=n.node(p);c[h.rank].push(p),e.forEach(n.successors(p),u)}}var f=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(f,u),c}return Ow}var Pw,WE;function sU(){if(WE)return Pw;WE=1;var e=xt();Pw=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})),u=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),f=1;f<l.length;)f<<=1;var p=2*f-1;f-=1;var h=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(u.forEach(function(y){var v=y.pos+f;h[v]+=y.weight;for(var S=0;v>0;)v%2&&(S+=h[v+1]),v=v-1>>1,h[v]+=y.weight;g+=y.weight*S})),g}return Pw}var Lw,HE;function aU(){if(HE)return Lw;HE=1;var e=xt();Lw=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(u,f){var p=n.edge(f),h=n.node(f.v);return{sum:u.sum+p.weight*h.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return Lw}var Dw,GE;function oU(){if(GE)return Dw;GE=1;var e=xt();Dw=t;function t(a,l){var c={};e.forEach(a,function(f,p){var h=c[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(h.barycenter=f.barycenter,h.weight=f.weight)}),e.forEach(l.edges(),function(f){var p=c[f.v],h=c[f.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(c[f.w]))});var u=e.filter(c,function(f){return!f.indegree});return n(u)}function n(a){var l=[];function c(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&s(p,h)}}function u(p){return function(h){h.in.push(p),--h.indegree===0&&a.push(h)}}for(;a.length;){var f=a.pop();l.push(f),e.forEach(f.in.reverse(),c(f)),e.forEach(f.out,u(f))}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,u=0;a.weight&&(c+=a.barycenter*a.weight,u+=a.weight),l.weight&&(c+=l.barycenter*l.weight,u+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/u,a.weight=u,a.i=Math.min(l.i,a.i),l.merged=!0}return Dw}var qw,VE;function iU(){if(VE)return qw;VE=1;var e=xt(),t=wn();qw=n;function n(l,c){var u=t.partition(l,function(_){return e.has(_,"barycenter")}),f=u.lhs,p=e.sortBy(u.rhs,function(_){return-_.i}),h=[],g=0,y=0,v=0;f.sort(a(!!c)),v=s(h,p,v),e.forEach(f,function(_){v+=_.vs.length,h.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,v=s(h,p,v)});var S={vs:e.flatten(h,!0)};return y&&(S.barycenter=g/y,S.weight=y),S}function s(l,c,u){for(var f;c.length&&(f=e.last(c)).i<=u;)c.pop(),l.push(f.vs),u++;return u}function a(l){return function(c,u){return c.barycenter<u.barycenter?-1:c.barycenter>u.barycenter?1:l?u.i-c.i:c.i-u.i}}return qw}var Fw,YE;function lU(){if(YE)return Fw;YE=1;var e=xt(),t=aU(),n=oU(),s=iU();Fw=a;function a(u,f,p,h){var g=u.children(f),y=u.node(f),v=y?y.borderLeft:void 0,S=y?y.borderRight:void 0,_={};v&&(g=e.filter(g,function(R){return R!==v&&R!==S}));var j=t(u,g);e.forEach(j,function(R){if(u.children(R.v).length){var I=a(u,R.v,p,h);_[R.v]=I,e.has(I,"barycenter")&&c(R,I)}});var x=n(j,p);l(x,_);var N=s(x,h);if(v&&(N.vs=e.flatten([v,N.vs,S],!0),u.predecessors(v).length)){var E=u.node(u.predecessors(v)[0]),C=u.node(u.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(u,f){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(h){return f[h]?f[h].vs:h}),!0)})}function c(u,f){e.isUndefined(u.barycenter)?(u.barycenter=f.barycenter,u.weight=f.weight):(u.barycenter=(u.barycenter*u.weight+f.barycenter*f.weight)/(u.weight+f.weight),u.weight+=f.weight)}return Fw}var Bw,KE;function cU(){if(KE)return Bw;KE=1;var e=xt(),t=mr().Graph;Bw=n;function n(a,l,c){var u=s(a),f=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var h=a.node(p),g=a.parent(p);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(f.setNode(p),f.setParent(p,g||u),e.forEach(a[c](p),function(y){var v=y.v===p?y.w:y.v,S=f.edge(v,p),_=e.isUndefined(S)?0:S.weight;f.setEdge(v,p,{weight:a.edge(y).weight+_})}),e.has(h,"minRank")&&f.setNode(p,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),f}function s(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return Bw}var zw,XE;function uU(){if(XE)return zw;XE=1;var e=xt();zw=t;function t(n,s,a){var l={},c;e.forEach(a,function(u){for(var f=n.parent(u),p,h;f;){if(p=n.parent(f),p?(h=l[p],l[p]=f):(h=c,c=f),h&&h!==f){s.setEdge(h,f);return}f=p}})}return zw}var Uw,QE;function dU(){if(QE)return Uw;QE=1;var e=xt(),t=rU(),n=sU(),s=lU(),a=cU(),l=uU(),c=mr().Graph,u=wn();Uw=f;function f(y){var v=u.maxRank(y),S=p(y,e.range(1,v+1),"inEdges"),_=p(y,e.range(v-1,-1,-1),"outEdges"),j=t(y);g(y,j);for(var x=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){h(E%2?S:_,E%4>=2),j=u.buildLayerMatrix(y);var R=n(y,j);R<x&&(C=0,N=e.cloneDeep(j),x=R)}g(y,N)}function p(y,v,S){return e.map(v,function(_){return a(y,_,S)})}function h(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 g(y,v){e.forEach(v,function(S){e.forEach(S,function(_,j){y.node(_).order=j})})}return Uw}var Ww,ZE;function hU(){if(ZE)return Ww;ZE=1;var e=xt(),t=mr().Graph,n=wn();Ww={positionX:S,findType1Conflicts:s,findType2Conflicts:a,addConflict:c,hasConflict:u,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:v};function s(x,N){var E={};function C(R,I){var $=0,q=0,P=R.length,M=e.last(I);return e.forEach(I,function(O,V){var X=l(x,O),A=X?x.node(X).order:P;(X||O===M)&&(e.forEach(I.slice(q,V+1),function(Z){e.forEach(x.predecessors(Z),function(B){var te=x.node(B),Q=te.order;(Q<$||A<Q)&&!(te.dummy&&x.node(Z).dummy)&&c(E,B,Z)})}),q=V+1,$=A)}),I}return e.reduce(N,C),E}function a(x,N){var E={};function C(I,$,q,P,M){var O;e.forEach(e.range($,q),function(V){O=I[V],x.node(O).dummy&&e.forEach(x.predecessors(O),function(X){var A=x.node(X);A.dummy&&(A.order<P||A.order>M)&&c(E,X,O)})})}function R(I,$){var q=-1,P,M=0;return e.forEach($,function(O,V){if(x.node(O).dummy==="border"){var X=x.predecessors(O);X.length&&(P=x.node(X[0]).order,C($,M,V,q,P),M=V,q=P)}C($,M,$.length,P,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 u(x,N,E){if(N>E){var C=N;N=E,E=C}return e.has(x[N],E)}function f(x,N,E,C){var R={},I={},$={};return e.forEach(N,function(q){e.forEach(q,function(P,M){R[P]=P,I[P]=P,$[P]=M})}),e.forEach(N,function(q){var P=-1;e.forEach(q,function(M){var O=C(M);if(O.length){O=e.sortBy(O,function(B){return $[B]});for(var V=(O.length-1)/2,X=Math.floor(V),A=Math.ceil(V);X<=A;++X){var Z=O[X];I[M]===M&&P<$[Z]&&!u(E,M,Z)&&(I[Z]=M,I[M]=R[M]=R[Z],P=$[Z])}}})}),{root:R,align:I}}function p(x,N,E,C,R){var I={},$=h(x,N,E,R),q=R?"borderLeft":"borderRight";function P(V,X){for(var A=$.nodes(),Z=A.pop(),B={};Z;)B[Z]?V(Z):(B[Z]=!0,A.push(Z),A=A.concat(X(Z))),Z=A.pop()}function M(V){I[V]=$.inEdges(V).reduce(function(X,A){return Math.max(X,I[A.v]+$.edge(A))},0)}function O(V){var X=$.outEdges(V).reduce(function(Z,B){return Math.min(Z,I[B.w]-$.edge(B))},Number.POSITIVE_INFINITY),A=x.node(V);X!==Number.POSITIVE_INFINITY&&A.borderType!==q&&(I[V]=Math.max(I[V],X))}return P(M,$.predecessors.bind($)),P(O,$.successors.bind($)),e.forEach(C,function(V){I[V]=I[E[V]]}),I}function h(x,N,E,C){var R=new t,I=x.graph(),$=_(I.nodesep,I.edgesep,C);return e.forEach(N,function(q){var P;e.forEach(q,function(M){var O=E[M];if(R.setNode(O),P){var V=E[P],X=R.edge(V,O);R.setEdge(V,O,Math.max($(x,M,P),X||0))}P=M})}),R}function g(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 q=j(x,$)/2;C=Math.max(I+q,C),R=Math.min(I-q,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 q=I+$,P=x[q],M;if(P!==N){var O=e.values(P);M=$==="l"?C-e.min(O):R-e.max(O),M&&(x[q]=e.mapValues(P,function(V){return V+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(q){q==="r"&&(R=e.map(R,function(V){return e.values(V).reverse()}));var P=($==="u"?x.predecessors:x.successors).bind(x),M=f(x,R,E,P),O=p(x,R,M.root,M.align,q==="r");q==="r"&&(O=e.mapValues(O,function(V){return-V})),C[$+q]=O})});var I=g(x,C);return y(C,I),v(C,x.graph().align)}function _(x,N,E){return function(C,R,I){var $=C.node(R),q=C.node(I),P=0,M;if(P+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":M=-$.width/2;break;case"r":M=$.width/2;break}if(M&&(P+=E?M:-M),M=0,P+=($.dummy?N:x)/2,P+=(q.dummy?N:x)/2,P+=q.width/2,e.has(q,"labelpos"))switch(q.labelpos.toLowerCase()){case"l":M=q.width/2;break;case"r":M=-q.width/2;break}return M&&(P+=E?M:-M),M=0,P}}function j(x,N){return x.node(N).width}return Ww}var Hw,JE;function fU(){if(JE)return Hw;JE=1;var e=xt(),t=wn(),n=hU().positionX;Hw=s;function s(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,u){l.node(u).x=c})}function a(l){var c=t.buildLayerMatrix(l),u=l.graph().ranksep,f=0;e.forEach(c,function(p){var h=e.max(e.map(p,function(g){return l.node(g).height}));e.forEach(p,function(g){l.node(g).y=f+h/2}),f+=h+u})}return Hw}var Gw,eC;function pU(){if(eC)return Gw;eC=1;var e=xt(),t=Kz(),n=Xz(),s=Zz(),a=wn().normalizeRanks,l=Jz(),c=wn().removeEmptyRanks,u=eU(),f=tU(),p=nU(),h=dU(),g=fU(),y=wn(),v=mr().Graph;Gw=S;function S(z,U){var J=U&&U.debugTiming?y.time:y.notime;J("layout",function(){var H=J(" buildLayoutGraph",function(){return P(z)});J(" runLayout",function(){_(H,J)}),J(" updateInputGraph",function(){j(z,H)})})}function _(z,U){U(" makeSpaceForEdgeLabels",function(){M(z)}),U(" removeSelfEdges",function(){D(z)}),U(" acyclic",function(){t.run(z)}),U(" nestingGraph.run",function(){u.run(z)}),U(" rank",function(){s(y.asNonCompoundGraph(z))}),U(" injectEdgeLabelProxies",function(){O(z)}),U(" removeEmptyRanks",function(){c(z)}),U(" nestingGraph.cleanup",function(){u.cleanup(z)}),U(" normalizeRanks",function(){a(z)}),U(" assignRankMinMax",function(){V(z)}),U(" removeEdgeLabelProxies",function(){X(z)}),U(" normalize.run",function(){n.run(z)}),U(" parentDummyChains",function(){l(z)}),U(" addBorderSegments",function(){f(z)}),U(" order",function(){h(z)}),U(" insertSelfEdges",function(){K(z)}),U(" adjustCoordinateSystem",function(){p.adjust(z)}),U(" position",function(){g(z)}),U(" positionSelfEdges",function(){L(z)}),U(" removeBorderNodes",function(){Q(z)}),U(" normalize.undo",function(){n.undo(z)}),U(" fixupEdgeLabelCoords",function(){B(z)}),U(" undoCoordinateSystem",function(){p.undo(z)}),U(" translateGraph",function(){A(z)}),U(" assignNodeIntersects",function(){Z(z)}),U(" reversePoints",function(){te(z)}),U(" acyclic.undo",function(){t.undo(z)})}function j(z,U){e.forEach(z.nodes(),function(J){var H=z.node(J),oe=U.node(J);H&&(H.x=oe.x,H.y=oe.y,U.children(J).length&&(H.width=oe.width,H.height=oe.height))}),e.forEach(z.edges(),function(J){var H=z.edge(J),oe=U.edge(J);H.points=oe.points,e.has(oe,"x")&&(H.x=oe.x,H.y=oe.y)}),z.graph().width=U.graph().width,z.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"},q=["labelpos"];function P(z){var U=new v({multigraph:!0,compound:!0}),J=de(z.graph());return U.setGraph(e.merge({},N,G(J,x),e.pick(J,E))),e.forEach(z.nodes(),function(H){var oe=de(z.node(H));U.setNode(H,e.defaults(G(oe,C),R)),U.setParent(H,z.parent(H))}),e.forEach(z.edges(),function(H){var oe=de(z.edge(H));U.setEdge(H,e.merge({},$,G(oe,I),e.pick(oe,q)))}),U}function M(z){var U=z.graph();U.ranksep/=2,e.forEach(z.edges(),function(J){var H=z.edge(J);H.minlen*=2,H.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?H.width+=H.labeloffset:H.height+=H.labeloffset)})}function O(z){e.forEach(z.edges(),function(U){var J=z.edge(U);if(J.width&&J.height){var H=z.node(U.v),oe=z.node(U.w),me={rank:(oe.rank-H.rank)/2+H.rank,e:U};y.addDummyNode(z,"edge-proxy",me,"_ep")}})}function V(z){var U=0;e.forEach(z.nodes(),function(J){var H=z.node(J);H.borderTop&&(H.minRank=z.node(H.borderTop).rank,H.maxRank=z.node(H.borderBottom).rank,U=e.max(U,H.maxRank))}),z.graph().maxRank=U}function X(z){e.forEach(z.nodes(),function(U){var J=z.node(U);J.dummy==="edge-proxy"&&(z.edge(J.e).labelRank=J.rank,z.removeNode(U))})}function A(z){var U=Number.POSITIVE_INFINITY,J=0,H=Number.POSITIVE_INFINITY,oe=0,me=z.graph(),ye=me.marginx||0,Ee=me.marginy||0;function Be(ce){var Ne=ce.x,ve=ce.y,Fe=ce.width,he=ce.height;U=Math.min(U,Ne-Fe/2),J=Math.max(J,Ne+Fe/2),H=Math.min(H,ve-he/2),oe=Math.max(oe,ve+he/2)}e.forEach(z.nodes(),function(ce){Be(z.node(ce))}),e.forEach(z.edges(),function(ce){var Ne=z.edge(ce);e.has(Ne,"x")&&Be(Ne)}),U-=ye,H-=Ee,e.forEach(z.nodes(),function(ce){var Ne=z.node(ce);Ne.x-=U,Ne.y-=H}),e.forEach(z.edges(),function(ce){var Ne=z.edge(ce);e.forEach(Ne.points,function(ve){ve.x-=U,ve.y-=H}),e.has(Ne,"x")&&(Ne.x-=U),e.has(Ne,"y")&&(Ne.y-=H)}),me.width=J-U+ye,me.height=oe-H+Ee}function Z(z){e.forEach(z.edges(),function(U){var J=z.edge(U),H=z.node(U.v),oe=z.node(U.w),me,ye;J.points?(me=J.points[0],ye=J.points[J.points.length-1]):(J.points=[],me=oe,ye=H),J.points.unshift(y.intersectRect(H,me)),J.points.push(y.intersectRect(oe,ye))})}function B(z){e.forEach(z.edges(),function(U){var J=z.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 te(z){e.forEach(z.edges(),function(U){var J=z.edge(U);J.reversed&&J.points.reverse()})}function Q(z){e.forEach(z.nodes(),function(U){if(z.children(U).length){var J=z.node(U),H=z.node(J.borderTop),oe=z.node(J.borderBottom),me=z.node(e.last(J.borderLeft)),ye=z.node(e.last(J.borderRight));J.width=Math.abs(ye.x-me.x),J.height=Math.abs(oe.y-H.y),J.x=me.x+J.width/2,J.y=H.y+J.height/2}}),e.forEach(z.nodes(),function(U){z.node(U).dummy==="border"&&z.removeNode(U)})}function D(z){e.forEach(z.edges(),function(U){if(U.v===U.w){var J=z.node(U.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:U,label:z.edge(U)}),z.removeEdge(U)}})}function K(z){var U=y.buildLayerMatrix(z);e.forEach(U,function(J){var H=0;e.forEach(J,function(oe,me){var ye=z.node(oe);ye.order=me+H,e.forEach(ye.selfEdges,function(Ee){y.addDummyNode(z,"selfedge",{width:Ee.label.width,height:Ee.label.height,rank:ye.rank,order:me+ ++H,e:Ee.e,label:Ee.label},"_se")}),delete ye.selfEdges})})}function L(z){e.forEach(z.nodes(),function(U){var J=z.node(U);if(J.dummy==="selfedge"){var H=z.node(J.e.v),oe=H.x+H.width/2,me=H.y,ye=J.x-oe,Ee=H.height/2;z.setEdge(J.e,J.label),z.removeNode(U),J.label.points=[{x:oe+2*ye/3,y:me-Ee},{x:oe+5*ye/6,y:me-Ee},{x:oe+ye,y:me},{x:oe+5*ye/6,y:me+Ee},{x:oe+2*ye/3,y:me+Ee}],J.label.x=J.x,J.label.y=J.y}})}function G(z,U){return e.mapValues(e.pick(z,U),Number)}function de(z){var U={};return e.forEach(z,function(J,H){U[H.toLowerCase()]=J}),U}return Gw}var Vw,tC;function mU(){if(tC)return Vw;tC=1;var e=xt(),t=wn(),n=mr().Graph;Vw={debugOrdering:s};function s(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(u){c.setNode(u,{label:u}),c.setParent(u,"layer"+a.node(u).rank)}),e.forEach(a.edges(),function(u){c.setEdge(u.v,u.w,{},u.name)}),e.forEach(l,function(u,f){var p="layer"+f;c.setNode(p,{rank:"same"}),e.reduce(u,function(h,g){return c.setEdge(h,g,{style:"invis"}),g})}),c}return Vw}var Yw,nC;function gU(){return nC||(nC=1,Yw="0.8.5"),Yw}var Kw,rC;function yU(){return rC||(rC=1,Kw={graphlib:mr(),layout:pU(),debug:mU(),util:{time:wn().time,notime:wn().notime},version:gU()}),Kw}var wU=yU();const sC=Pv(wU),ci=240,ad=130,ei=74,Pd=72,aC=ei+Pd;function vU(e,t){var s;let n=ci;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??ci);return n}const qA=420,xU=2;function $l(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function bU(e,t){return((t==null?void 0:t.get(e))??0)>0?qA:0}function kU(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Ol(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??ci)+bU(e,n),h:Math.max((s==null?void 0:s.height)??ad,kU(e,n))}}function _U(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function NU(e,t,n,s,a,l){const c=new sC.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(x=>!a.has(x)),f=new Set(u);for(const x of u){const{w:N,h:E}=Ol(x,s,l);c.setNode(x,{width:N,height:E})}for(const x of t)f.has(x.source)&&f.has(x.target)&&c.setEdge(x.source,x.target);sC.layout(c);const p=new Map;let h=1/0,g=1/0,y=-1/0,v=-1/0;for(const x of u){const N=c.node(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ci,R=(E==null?void 0:E.height)??ad,I=Ol(x,s,l),$=N.x-I.w/2,q=N.y-I.h/2;p.set(x,{x:$,y:q}),$<h&&(h=$),q<g&&(g=q),$+C>y&&(y=$+C),q+R>v&&(v=q+R)}if(Number.isFinite(h)&&Number.isFinite(g))for(const[x,N]of p)p.set(x,{x:N.x-h,y:N.y-g});const S=Number.isFinite(y)?y-h:0,_=Number.isFinite(v)?v-g: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)??ci,R=(E==null?void 0:E.height)??ad;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 SU(e,t,n={}){const s=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,u=new Map;for(const x of e){const N=$l(x),E=u.get(N);E?E.push(x.id):u.set(N,[x.id])}const p=Array.from(u.keys()).sort().map(x=>({sid:x,...NU(u.get(x),t,s,l,a,c)})),h=vU(e,l),g=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>g&&(N.push([]),E=0),N[N.length-1].push(C),E+=C.height+aC;return N},v=x=>x.reduce((N,E)=>Math.max(N,E.width),0)+qA;let S=y(n.availableWidth?xU:1);S.length>1&&S.reduce((N,E)=>N+v(E),0)+h*(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[q,P]of C)_.set(q,{x:P.x+j,y:P.y+E});let $=E+R;I&&I.maxY>$&&I.minX<j+N&&j<I.maxX&&($=I.maxY),E=$+aC}j+=N+h}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 jU(e,t,n,s,a){const c=ei+Pd,u=60,f=v=>Ol(v,s,a),p=new Map(e.map(v=>[v.id,$l(v)])),h=[],g=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 g){const{w:_,h:j}=f(v),x=p.get(v)??"_default";if(n.has(v)){h.push({x:S.x,y:S.y,w:_,h:j,sid:x});continue}let N=S.y;for(let E=0;E<h.length+1;E++){const C=h.find(R=>{const I=R.sid===x?24:u,$=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)),h.push({x:S.x,y:N,w:_,h:j,sid:x})}return y}function EU(e,t,n,s,a,l){const c=_=>Ol(_,s,l),u=_=>n.get(_)??t.get(_),f=new Map;for(const _ of e){if(!u(_.id))continue;const j=$l(_),x=f.get(j);x?x.push(_):f.set(j,[_])}const p=new Set;for(const[_,j]of f)j.every(x=>a.has(x.id)&&!n.has(x.id))&&p.add(_);const h=new Map,g=[];for(const _ of e){const j=u(_.id);if(!j)continue;const{w:x,h:N}=c(_.id),E=$l(_);p.has(E)?(h.get(E)??h.set(E,[]).get(E)).push(_):g.push({x:j.x,y:j.y,w:x,h:N})}if(h.size===0)return[];const y=ei+Pd,v=(_,j,x,N)=>g.some(E=>_<E.x+E.w+ei&&E.x<_+x+ei&&j<E.y+E.h+y&&E.y<j+N+y),S=[];for(const _ of[...h.keys()].sort()){const j=h.get(_);let x=1/0,N=1/0,E=-1/0,C=-1/0;for(const O of j){const V=u(O.id),{w:X,h:A}=c(O.id);x=Math.min(x,V.x),N=Math.min(N,V.y),E=Math.max(E,V.x+X),C=Math.max(C,V.y+A)}const R=E-x,I=C-N,$=[...new Set(g.map(O=>Math.round(O.x)))].sort((O,V)=>O-V),q=$.length?$:[x],P=[0,...g.map(O=>O.y+O.h+y)].sort((O,V)=>O-V);let M=null;e:for(const O of q)for(const V of P){if(V>=N)break;if(!v(O,V,R,I)){M={x:O,y:V};break e}}if(M){const O=M.x-x,V=M.y-N;for(const X of j){const A=u(X.id);t.set(X.id,{x:A.x+O,y:A.y+V})}S.push(_)}for(const O of j){const V=u(O.id),{w:X,h:A}=c(O.id);g.push({x:V.x,y:V.y,w:X,h:A})}}return S}function CU(e,t,n,s,a,l=!1,c){const p=ei+Pd+1,h=8,g=1.75,y=200,v=.7,S=.01,_=M=>Ol(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 O=$l(M),V=x.get(O);V?V.push(M):x.set(O,[M])}const N=[],E=new Set,C=new Set,R=a.size===0;for(const M of[...x.keys()].sort()){const O=x.get(M);let V=1/0,X=1/0,A=-1/0,Z=-1/0,B=!1;for(const K of O){const L=j(K.id),{w:G,h:de}=_(K.id);V=Math.min(V,L.x),X=Math.min(X,L.y),A=Math.max(A,L.x+G),Z=Math.max(Z,L.y+de),n.has(K.id)&&(B=!0)}const te=A-V,Q=Z-X;C.add(M);const D=a.get(M);D&&(te>D.w+h||Q>D.h+h)&&E.add(M),a.set(M,{w:te,h:Q}),N.push({sid:M,members:O.map(K=>K.id),x:V,y:X,w:te,h:Q,anchored:B,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 O=M+1;O<N.length;O++){const V=N[M],X=N[O];if(!(V.anchored&&X.anchored)&&Math.abs(V.x+V.w/2-(X.x+X.w/2))<(V.w+X.w)/2+61&&Math.abs(V.y+V.h/2-(X.y+X.h/2))<(V.h+X.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/(ci*ad));const $=new Map(N.map(M=>[M.sid,M.x])),q=new Map(N.map(M=>[M.sid,M.y]));for(let M=0;M<y;M++){const O=new Map,V=new Map;let X=0;for(let A=0;A<N.length;A++)for(let Z=A+1;Z<N.length;Z++){const B=N[A],te=N[Z];if(B.anchored&&te.anchored)continue;const Q=B.x+B.w/2,D=B.y+B.h/2,K=te.x+te.w/2,L=te.y+te.h/2,G=(B.w+te.w)/2+61-Math.abs(Q-K),de=(B.h+te.h)/2+p-Math.abs(D-L);if(G<=0||de<=0)continue;const z=(Ve,ge)=>!Ve.anchored&&!(ge<0&&Ve.x<=0),U=(Ve,ge)=>!Ve.anchored&&!(ge<0&&Ve.y<=0),J=(Ve,ge,Se)=>{const qe=Ve===ge,Ye=qe?B.sid<te.sid?-1:1:Math.sign(Ve-ge);return Se(B,Ye)||Se(te,-Ye)?Ye:qe&&(Se(B,-Ye)||Se(te,Ye))?-Ye:0},H=J(Q,K,z),oe=J(D,L,U),me=H!==0,ye=oe!==0;if(!me&&!ye)continue;const Ee=me&&(!ye||G*g<de),[Be,ce,Ne,ve]=Ee?[H,G,O,z]:[oe,de,V,U],Fe=ve(B,Be),he=ve(te,-Be),ke=B.mass,Ke=te.mass,pe=Fe?he?Ke/(ke+Ke):1:0,dt=he?Fe?ke/(ke+Ke):1:0,ot=ce*v;Ne.set(B.sid,(Ne.get(B.sid)??0)+Be*ot*pe),Ne.set(te.sid,(Ne.get(te.sid)??0)-Be*ot*dt),X+=ot}for(const A of N)A.anchored||(A.x=Math.max(0,A.x+(O.get(A.sid)??0)),A.y=Math.max(0,A.y+(V.get(A.sid)??0)));if(X<S)break}const P=[];for(const M of N){const O=M.x-$.get(M.sid),V=M.y-q.get(M.sid);if(!(Math.abs(O)<1&&Math.abs(V)<1)){for(const X of M.members){if(n.has(X))continue;const A=t.get(X);A&&t.set(X,{x:A.x+O,y:A.y+V})}P.push(M.sid)}}return P}const TU=600;function Mv(e,t){return!(e.exitAt!=null&&t-e.exitAt>TU||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function AU(e,t){const n=new Set;for(const s of e.agents.values())Mv(s,t)&&n.add(s.id);return n}function RU(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 MU(e,t,n=0){if(!e)return!1;for(const s of t)if(RU(e,s,n))return!0;return!1}const FA="sessionGroup";function IU(e,t){var s;if(e.type===FA)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const BA=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function oC(e){const t={};for(const n of BA)t[n]=e(n);return t}function $U(e){return t=>e[t]??""}function OU(e,t){return BA.every(n=>e[n]===t[n])}function PU(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 LU=1200,DU=1e3;function iC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<LU?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<DU}function Xw({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function qU(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 FU({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,qU(a,t,e))return!1;return s}const BU="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Qw="click for what's new";function zU(e){if(e.checkDisabled)return`${BU} · ${Qw}`;if(e.checking)return`Asking npm for the newest release… · ${Qw}`;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 · ${Qw}, and to check npm now`}function UU(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 WU(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 HU(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 Iv={kind:"assumed",claude:!0,codex:!0};function GU(e){if(!e||typeof e!="object")return Iv;const t=e.providers;if(!t||typeof t!="object")return Iv;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function od(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const lC=99;function VU(e){const t=Math.max(0,Math.floor(e));return t>lC?`${lC}+`:String(t)}const YU="Pause the canvas";function KU(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 — ${od(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)":`${od(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function XU(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 zA="paused · full",QU=(e,t)=>t>0?zA:e>0?`paused · ${VU(e)}`:"paused";function ZU(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:QU(e.held,t),widest:zA,title:t>0?`Connected — the pause is full at ${od(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${od(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 cC(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const JU={agent:sL,sessionGroup:bL},UA="react-flow__node";function uC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,UA))===!0}function eW(e){try{const t=document.querySelector(`.${UA}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const tW=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),nW=420,Ru=18,rW=200,sW=5*6e4,aW=6,oW=2*6e4,dC=400,Lx="agent-dag.layout",Dx="agent-dag.viewport",WA="agent-dag.summariesDismissed",HA="agent-dag.sessionListOpen",GA="agent-dag.detailOpen",VA="agent-dag.usagePanelOpen",YA="agent-dag.systemPanelOpen",hC="agent-dag.accountsPanelOpen",Zw="agent-dag.versionNoticeDismissed",fC="agent-dag.oldNameNoticeDismissed",iW=15*6e4,Jw={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:"},Mu="agent-dag.autoRestart",pC="agent-dag.bundleReloadedFor";function lW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(HA)==="1"}catch{return!1}}function cW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(HA,e?"1":"0")}catch{}}function uW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(GA)==="1"}catch{return!1}}function dW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(GA,e?"1":"0")}catch{}}function hW(){const e=di(VA);return e===null?!0:e==="1"}function fW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(VA,e?"1":"0")}catch{}}function pW(){return di(YA)==="1"}function mW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(YA,e?"1":"0")}catch{}}function gW(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(WA);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 mC(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(WA,JSON.stringify(n))}catch{}}function yW(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Lx);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 ev(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(Lx,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function wW(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Dx);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 vW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Dx,JSON.stringify(e))}catch{}}function gC(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Lx)}catch{}try{window.localStorage.removeItem(Dx)}catch{}}}function xW(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const h of e.agents.values())h.sessionId===t&&s.push(h);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(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},l=JSON.stringify(a,null,2),c=new Blob([l],{type:"application/json"}),u=URL.createObjectURL(c),f=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=u,f.download=`${Ut}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(u),1e3)}const $v={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Ov={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},KA=n2;function bW(e,t,n,s,a,l,c,u,f,p,h,g,y,v,S,_,j,x){const N=[],E=[];for(const M of e.agents.values()){if(!j.has(M.id))continue;const O=M.exitAt!=null,V=_!=null&&!_.has(M.id),X=[O?"rf-exiting":"",V?"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:X,...A?{width:A.width,height:A.height}:null}),M.parentId&&j.has(M.parentId)){const Z=nx(M.sessionId),B=O,te=S.size>0&&(S.has(M.id)||S.has(M.parentId)),Q=_!=null&&!_.has(M.id)&&!_.has(M.parentId),D=M.state==="active"?2:1.5,K=te?D+1.5:D,L=B?.2:Q?.12:1,G=["sess-edge",M.state==="active"?"sess-live":"sess-idle",B?"rf-edge-exiting":"",te?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||te)&&!B,type:"smoothstep",style:{"--session-hue":Z,strokeWidth:K,opacity:L,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:${_U(C)}`,I=N.filter(M=>mF(M.id,a,h,g));if(I.length>0||R!==v.current){if(I.length>0){const M=SU(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:s,lanes:C});for(const O of M)P2(O.id,h,g)&&yF(O.id,O.position,h,g);EU(N,h,a,l,new Set(I.map(O=>O.id)),C)}jU(N,h,a,l,C),v.current=R}const $=CU(N,h,a,l,c,!f||p,C);$.length>0&&u($),Su(h,e.agents),Su(g,e.agents),Su(a,e.agents),Su(l,hF(e.agents.values()));const q=[];let P=!1;for(const M of N){let O=a.get(M.id)??h.get(M.id);O||(O=gF(M.id,h,g),P=!0),q.push({...M,position:O})}return P&&(v.current=""),{nodes:q,edges:E}}function kW(){return i.jsx(ex,{children:i.jsx(_W,{})})}function _W(){var Fi,xa,Gr,wo;const e=Fl(),t=Rt(),n=b.useState(yv)[0],s=b.useRef(n),[,a]=b.useState(0),l=b.useCallback(()=>a(F=>F+1),[]),[c,u]=b.useState(()=>new Set),[f,p]=b.useState(null),[h,g]=b.useState(null),y=b.useCallback((F,W)=>{u(ae=>{if(!W)return new Set([F]);const ie=new Set(ae);return ie.has(F)?ie.delete(F):ie.add(F),ie}),p(ae=>W&&ae===F?ae:F)},[]),v=b.useCallback(()=>{u(new Set),p(null)},[]),[S,_]=b.useState(null),[j,x]=b.useState(null),N=b.useCallback(F=>x(F),[]),[E,C]=b.useState(!1),[R,I]=b.useState(!1),[$,q]=b.useState(!1),P=b.useState(gW)[0],[M,O]=b.useState(lW);b.useEffect(()=>{cW(M)},[M]);const[V,X]=b.useState(uW);b.useEffect(()=>{dW(V)},[V]);const[A,Z]=b.useState(hW);b.useEffect(()=>{fW(A)},[A]);const[B,te]=b.useState(pW);b.useEffect(()=>{mW(B)},[B]);const[Q,D]=b.useState(()=>{try{const F=window.localStorage.getItem(hC);return F===null?!0:F==="1"}catch{return!0}});b.useEffect(()=>{try{window.localStorage.setItem(hC,Q?"1":"0")}catch{}},[Q]);const[K,L]=b.useState(null);b.useEffect(()=>{let F=null;try{F=localStorage.getItem("agent-dag.sound")}catch{}L(F===null?!0:F==="on")},[]);const G=b.useCallback(()=>{L(F=>{var ae;const W=F!==!0;try{localStorage.setItem("agent-dag.sound",W?"on":"off")}catch{}return W&&((ae=ve.current)==null||ae.unlock()),W})},[]),de=b.useCallback(F=>{G()},[G]),z=b.useRef(de);z.current=de;const U=b.useRef(K);U.current=K;const[J,H]=b.useState(()=>Rq(di)),oe=b.useRef(J);oe.current=J;const me=b.useRef(null),ye=b.useCallback((F,W=!1)=>{var ae,ie;if((ae=ve.current)==null||ae.unlock(),me.current!==null&&clearTimeout(me.current),me.current=null,!W){(ie=ve.current)==null||ie.play(F,!0);return}me.current=setTimeout(()=>{var Ce;me.current=null,(Ce=ve.current)==null||Ce.play(F,!0)},jq)},[]),Ee=b.useCallback((F,W)=>{H(ae=>{const ie={level:Il(W.level??ae[F].level),figure:A2(F,W.figure??ae[F].figure)};try{localStorage.setItem(R2[F],String(ie.level)),localStorage.setItem(M2[F],ie.figure)}catch{}return{...ae,[F]:ie}}),ye(F,!0)},[ye]);b.useEffect(()=>()=>{me.current!==null&&clearTimeout(me.current)},[]);const[Be,ce]=b.useState(!1),Ne=b.useRef(null),ve=b.useRef(null),[Fe,he]=b.useState("locked");b.useEffect(()=>{const F=$q({enabled:()=>U.current===!0,prefs:()=>oe.current,onState:he});ve.current=F,he(F.state());const W=()=>F.unlock();return window.addEventListener("pointerdown",W,{once:!0,capture:!0}),window.addEventListener("keydown",W,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",W,{capture:!0}),window.removeEventListener("keydown",W,{capture:!0})}},[]);const[ke,Ke]=b.useState(!1),[pe,dt]=b.useState(null),[ot,Ve]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Zw)??""}catch{return""}}),[ge,Se]=b.useState(!1),qe=b.useRef(0),[Ye,it]=b.useState(!1),Je=b.useCallback((F=!1)=>(F&&(qe.current=Date.now(),it(!0)),fetch(F?"/api/version?refresh=1":"/api/version").then(W=>W.ok?W.json():null).then(W=>{W&&dt(W)}).catch(()=>{}).finally(()=>{F&&it(!1)})),[]),re=b.useCallback(()=>{Je(Date.now()-qe.current>=iW)},[Je]);b.useEffect(()=>{Je();const F=window.setInterval(re,5*6e4),W=()=>{document.visibilityState==="visible"&&re()};return document.addEventListener("visibilitychange",W),()=>{window.clearInterval(F),document.removeEventListener("visibilitychange",W)}},[Je,re]),b.useEffect(()=>{ke&&Je()},[ke,Je]),b.useEffect(()=>{const F=Uq();let W=null;const ae=ze=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:F,looking:ze}),keepalive:!0}).catch(()=>{})},ie=()=>{const ze=Bq(document);zq(W,ze)&&ae(ze),W=ze},Ce=()=>{W&&ae(!1),W=!1};ie();const Me=window.setInterval(ie,Fq);return window.addEventListener("focus",ie),window.addEventListener("blur",ie),document.addEventListener("visibilitychange",ie),window.addEventListener("pagehide",Ce),()=>{window.clearInterval(Me),window.removeEventListener("focus",ie),window.removeEventListener("blur",ie),document.removeEventListener("visibilitychange",ie),window.removeEventListener("pagehide",Ce),Ce()}},[]);const we=(pe==null?void 0:pe.notice)??null,[Le,Te]=b.useState(null),He=b.useRef(!1);b.useEffect(()=>{if(He.current)return;const F=Zq(),W=Jq(F),ae=nF({stored:W,running:(pe==null?void 0:pe.running)??null,notes:R1,remembers:eF(F)});if(ae.reason!=="no-version"){if(He.current=!0,ae.record&&tF(F,ae.record),ae.reason==="welcome"||ae.reason==="first-run"){q(!0);return}ae.show.length&&Te({entries:ae.show,since:W,firstRun:!1})}},[pe==null?void 0:pe.running]);const mt=(pe==null?void 0:pe.running)??"3.21.0",gt=b.useMemo(()=>I2(R1,null,mt),[mt]),Ae=b.useCallback(()=>{Te({entries:gt,since:null,firstRun:!1})},[gt]),[yt,bt]=b.useState(null),[lt,Rn]=b.useState(Iv);b.useEffect(()=>{let F=!1;return fetch("/api/health").then(W=>W.ok?W.json():null).then(W=>{F||(Rn(GU(W)),!(!W||typeof W.workspace!="string")&&bt(W.workspace))}).catch(()=>{}),()=>{F=!0}},[ke]);const vn=b.useRef(lt);vn.current=lt;const rn=we?`${we.kind}:${we.to}`:"",wr=we!=null&&ot!==rn,Va=b.useCallback(()=>{Ve("");try{window.localStorage.setItem(Zw,"")}catch{}},[]),Ya=b.useCallback(()=>{if(we){Ve(rn);try{window.localStorage.setItem(Zw,rn)}catch{}}},[we,rn]),[Ka,Qs]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(fC)??""}catch{return""}}),xn=pe!=null&&pe.invokedAs&&pe.invokedAs!==Ut?pe.invokedAs:null,Or=xn!=null&&Ka!==xn,Zs=b.useCallback(()=>{if(xn){Qs(xn);try{window.localStorage.setItem(fC,xn)}catch{}}},[xn]),It=((Fi=pe==null?void 0:pe.upgrade)==null?void 0:Fi.state)??"idle",us=aq(pe==null?void 0:pe.upgrade),Kn=b.useRef(!1),ds=b.useCallback(async()=>{if(hr(Kn.current||It==="running")){Kn.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Je(),Kn.current=!1}},[It,Je]);b.useEffect(()=>{if(It!=="running")return;const F=window.setInterval(Je,3e3);return()=>window.clearInterval(F)},[It,Je]);const hs=b.useCallback(async()=>{const F=pe==null?void 0:pe.command;!F||!await T2(F)||(Se(!0),window.setTimeout(()=>Se(!1),1600))},[pe==null?void 0:pe.command]),fs=b.useCallback(()=>{O(F=>(F||D(!1),!F))},[]),Xa=b.useCallback(()=>{D(F=>(F||O(!1),!F))},[]),[Qa,ps]=b.useState(!1),[Mn,Js]=b.useState(!1),[ea,yi]=b.useState(()=>{try{return Number(localStorage.getItem(O1))||0}catch{return 0}}),[ta,Za]=b.useState([]),[Pr,na]=b.useState(!1);b.useEffect(()=>{let F=!0;const W=()=>{fetch("/api/browser-watch?live=0").then(ie=>ie.ok?ie.json():null).then(ie=>{var Ce;!F||!(ie!=null&&ie.ok)||(Za(ie.episodes??[]),na(((Ce=ie.settings)==null?void 0:Ce.enabled)===!0))}).catch(()=>{})};W();const ae=setInterval(W,5*6e4);return()=>{F=!1,clearInterval(ae)}},[]);const[Ja,ms]=b.useState([]),ht=b.useRef(new Set),[gs,ys]=b.useState(null);b.useEffect(()=>{let F=!0,W=0;const ae=()=>{fetch("/api/lan").then(ie=>ie.ok?ie.json():null).then(ie=>F?(ie!=null&&ie.ok&&ms(x1(Array.isArray(ie.pending)?ie.pending:[],ie.aliases)),ie):null).catch(()=>null).then(ie=>{F&&(W=window.setTimeout(ae,(ie==null?void 0:ie.enabled)===!0?Cv:S2))})};return ae(),()=>{F=!1,window.clearTimeout(W)}},[]);const ra=b.useCallback(async(F,W)=>{if(!gs){ys(F);try{const ie=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:F,fp:W})})).json().catch(()=>null);ie&&Array.isArray(ie.pending)?ms(x1(ie.pending,ie.aliases)):ms(Ce=>Ce.filter(Me=>Me.fp!==W))}catch{}finally{ys(null)}}},[gs]),bn=b.useMemo(()=>HF(ta,ea).length,[ta,ea]),[eo,sa]=b.useState(0),Lr=b.useRef(null),[on,ws]=b.useState(!1),Ht=b.useRef(null),[Ld,Zl]=b.useState(0),kn=b.useState(()=>kF({protect:F=>u4(s.current,F)}))[0],[Dr,to]=b.useState(!1),qr=b.useCallback(()=>{const F=kn.paused&&kn.dropped>0,W=kn.setPaused(!kn.paused);F&&d4(s.current);for(const ae of W)s.current=Ck(s.current,ae);to(kn.paused)},[kn]),[Nt,Dd]=b.useState(Date.now()),[Xn,vs]=b.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Mu)!=="0"}catch{return!0}}),wi=b.useRef(!1),vi=b.useCallback(()=>{const F=!Xn;wi.current=!0;try{window.localStorage.removeItem(Mu)}catch{}vs(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:F})}).then(W=>W.ok?W.json():null).then(W=>{var ae;W!=null&&W.ok&&vs(((ae=W.prefs)==null?void 0:ae.autoUpdate)!==!1)}).catch(()=>{})},[Xn]),[ln,no]=b.useState(!1),[xi,rt]=b.useState("restart"),[bi,ki]=b.useState(null),vr=b.useRef(!1),_i=b.useRef(null),Ni=b.useRef(0),aa=b.useCallback(async F=>{if(!hr(vr.current))return;const W=(F==null?void 0:F.upgrade)===!0;vr.current=!0,_i.current=us;const ae=++Ni.current;rt(W?"npx":"restart"),no(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(we==null?void 0:we.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:W})})}catch{}window.setTimeout(()=>{if(Ni.current===ae&&vr.current){vr.current=!1,no(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},W?18e4:3e4)},[we==null?void 0:we.to,us]),oa=b.useRef(null);b.useEffect(()=>{const F=j1(s.current.agents.values())>0,W=uq({enabled:Xn,kind:we==null?void 0:we.kind,canRestart:(pe==null?void 0:pe.canRestart)===!0,noticeOpen:wr,visible:document.visibilityState==="visible",busy:F,idleSince:oa.current,now:Nt});oa.current=W.idleSince,W.restart&&aa()},[Xn,we==null?void 0:we.kind,pe==null?void 0:pe.canRestart,wr,Nt,aa]);const ia=j1(s.current.agents.values()),Qn=cq(ia),Zn=C2({enabled:Xn,kind:we==null?void 0:we.kind,canRestart:(pe==null?void 0:pe.canRestart)===!0,noticeOpen:wr,visible:document.visibilityState==="visible",busy:ia>0,idleSince:oa.current,now:Nt});b.useEffect(()=>{const F=pe==null?void 0:pe.running;let W=null,ae=null;try{W=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(pC)}catch{return}const ie=sq({bundle:"3.21.0",running:F,pending:W,lastTried:ae});if(ie==="reload"){try{window.sessionStorage.setItem(pC,F??"")}catch{return}window.location.reload();return}if(ie!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}vr.current=!1,no(!1),ki(F??null);const Ce=window.setTimeout(()=>ki(null),6e3);return()=>window.clearTimeout(Ce)},[pe==null?void 0:pe.running]),b.useEffect(()=>{if(ln&&oq({asked:_i.current,reported:us})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}vr.current=!1,no(!1)}},[ln,us]);const Jn=b.useState(()=>PU(yW()))[0],$t=b.useRef(Jn.pinned),xr=b.useRef(null),_n=b.useState(()=>wW())[0],[Si,Jl]=b.useState(()=>new Set),[er,ec]=b.useState(NF),[tr,ro]=b.useState(()=>oC(cC)),ji=b.useMemo(()=>$U(tr),[tr]),qd=b.useCallback(F=>IU(F,ji),[ji]),la=b.useMemo(()=>({background:tr["--panel"],border:`1px solid ${tr["--line"]}`,borderRadius:8}),[tr]),[xs,bs]=b.useState(!1);b.useEffect(()=>{document.documentElement.dataset.theme=er;try{window.localStorage.setItem(L2,er)}catch{}ro(F=>{const W=oC(cC);return OU(F,W)?F:W})},[er]);const In=b.useCallback((F,W)=>{if(Xw({durationMs:W,documentHidden:document.hidden})){e.setViewport(F,{duration:W});return}const{d3Zoom:ae,d3Selection:ie}=t.getState(),Ce=ie==null?void 0:ie.property("__zoom");if(ae&&ie&&Ce&&Ce.k>0&&F.zoom>0){ae.transform(ie,Ce.scale(F.zoom/Ce.k).translate((F.x-Ce.x)/F.zoom,(F.y-Ce.y)/F.zoom));return}e.setViewport(F,{duration:0})},[e,t]),ca=b.useRef(null);b.useEffect(()=>{if(!_n)return;const F=window.setTimeout(()=>{try{In(_n,0)}catch{}cn.current=Date.now()},60);return()=>window.clearTimeout(F)},[In,_n]);const tc=b.useRef(!0);b.useEffect(()=>{const F=new EventSource("/events"),W=xF(l,{now:()=>Date.now(),setTimeout:(ae,ie)=>window.setTimeout(ae,ie),clearTimeout:ae=>window.clearTimeout(ae)});return F.addEventListener("open",()=>{Ke(!0),bs(!0)}),F.addEventListener("error",()=>Ke(!1)),F.addEventListener("replay-end",()=>{tc.current=!1,W.flush()}),F.addEventListener("hook",ae=>{var ie;try{const Ce=JSON.parse(ae.data);if(!kn.accept(Ce))return;s.current=Ck(s.current,Ce);const Me=Ce.replay===!0||tc.current||Date.now()-Ce.receivedAt>3e4;Me?W.replay():W.live();const ze=Iq(Ce,Me);ze&&((ie=ve.current)==null||ie.play(ze))}catch{}}),()=>{F.close(),W.cancel()}},[l]),b.useEffect(()=>{const F=setInterval(()=>{const W=Date.now();Dd(W);let ae=h4(s.current,W,Ek);f4(s.current,W,Ek)&&(ae=!0),l4(s.current,W,rW,sW)&&(ae=!0),c4(s.current,W,aW,oW)&&(ae=!0),u(ie=>dF(ie,s.current.agents)),p(ie=>ie!=null&&!s.current.agents.has(ie)?null:ie),x(ie=>ie!=null&&!s.current.agents.has(ie)?null:ie),_(ie=>ie!=null&&!s.current.agents.has(ie)?null:ie),ae&&l()},250);return()=>clearInterval(F)},[l]);const ua=b.useRef(null),cn=b.useRef(0),Ei=420,Nn=b.useCallback((F=500)=>{try{const Me=document.querySelector(".canvas-wrap"),ze=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Me||ze.length===0)return;const et=Me.getBoundingClientRect(),st=e.getViewport();if(!Number.isFinite(st.zoom)||st.zoom<=0)return;const at=wt=>(wt-et.left-st.x)/st.zoom,Zt=wt=>(wt-et.top-st.y)/st.zoom,vo=ze.map(wt=>wt.getBoundingClientRect()),wc=Math.min(...vo.map(wt=>at(wt.left))),ba=Math.max(...vo.map(wt=>at(wt.right))),vc=Math.min(...vo.map(wt=>Zt(wt.top))),xc=Math.max(...vo.map(wt=>Zt(wt.bottom))),Bi=ba-wc,ct=xc-vc;if(!(Bi>0&&ct>0))return;const Vr=Math.max(.2,Math.min(1,(et.width-160)/(Bi+Ei)*.86,(et.height-160)/ct*.86)),Sr={x:80-wc*Vr,y:Math.max(80,(et.height-ct*Vr)/2)-vc*Vr,zoom:Vr};In(Sr,F),cn.current=Date.now(),ca.current=Xw({durationMs:F,documentHidden:document.hidden})?{target:Sr,until:Date.now()+F+60}:null,window.setTimeout(()=>{var wt;try{((wt=ca.current)==null?void 0:wt.target)===Sr&&(ca.current=null);const zi=e.getViewport();(Math.abs(zi.zoom-Vr)>.01||Math.abs(zi.x-Sr.x)>2)&&In(Sr,0)}catch{}},F+60)}catch{}},[e,In]);b.useEffect(()=>{const F=()=>{if(!document.hidden)return;const W=ca.current;if(ca.current=null,!(!W||Date.now()>W.until)){try{In(W.target,0)}catch{}cn.current=Date.now()}};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[In]);const $n=b.useRef(""),da=b.useRef(null),ha=b.useRef(0),fa=b.useCallback(()=>{ha.current=Date.now()},[]),ks=b.useRef(null),pa=b.useRef(0),so=b.useCallback(()=>{pa.current=Date.now()},[]),Qt=b.useCallback(F=>({hasSourceEvent:!!F,at:Date.now(),lastDeckFitAt:cn.current,lastCanvasInputAt:pa.current}),[]),br="agent-dag.autoFitDisabled",ao=b.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(br)==="1"}catch{return!1}})[0],On=b.useRef(ao),[nc,oo]=b.useState(ao),ma=b.useCallback(()=>{if(!On.current){On.current=!0,oo(!0);try{window.localStorage.setItem(br,"1")}catch{}}},[]),ga=b.useCallback(()=>{On.current=!1,oo(!1);try{window.localStorage.removeItem(br)}catch{}Nn(400)},[e,Nn]);b.useEffect(()=>{const F=setInterval(()=>{if(On.current||Date.now()-ha.current<800)return;const W=s.current,ae=Date.now(),ie=[];for(const Me of W.agents.values())Mv(Me,ae)&&ie.push({id:Me.id});if(ie.length===0)return;const Ce=[];for(const{id:Me}of ie){const ze=Fr.current.get(Me),et=$t.current.get(Me)??un.current.get(Me);!ze||!et||Ce.push({x:et.x,y:et.y,width:ze.width,height:ze.height})}FU({pane:ks.current,viewport:e.getViewport(),boxes:Ce})&&Nn(600)},1500);return()=>clearInterval(F)},[e]);const _s=b.useRef(!1),Fr=b.useRef(new Map),rc=b.useRef(0),Fd=b.useCallback(F=>{const W=Fr.current;let ae=!1;for(const ie of F.nodeInternals.values()){const Ce=ie.width,Me=ie.height;if(Ce==null||Me==null)continue;const ze=W.get(ie.id);ze?(Math.abs(ze.height-Me)>4||Math.abs(ze.width-Ce)>4)&&(W.set(ie.id,{width:Ce,height:Me}),ae=!0):(W.set(ie.id,{width:Ce,height:Me}),ae=!0)}return ae&&(rc.current+=1),rc.current},[]),sc=ut(Fd),[io,Bd]=b.useState(0);b.useEffect(()=>{let F=0;const W=()=>{const ie=Fr.current;let Ce=!1;for(const Me of document.querySelectorAll(".react-flow__node[data-id]")){const ze=Me.getAttribute("data-id");if(!ze)continue;const et=Me.offsetWidth,st=Me.offsetHeight;if(!et||!st)continue;const at=ie.get(ze);(!at||Math.abs(at.width-et)>4||Math.abs(at.height-st)>4)&&(ie.set(ze,{width:et,height:st}),Ce=!0)}Ce&&Bd(Me=>Me+1)};if(_s.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(W,32):F=requestAnimationFrame(W),()=>{cancelAnimationFrame(F),window.clearTimeout(ae)}});const un=b.useRef(Jn.positions),zd=b.useRef(new Set),Ci=b.useRef(""),Ns=b.useMemo(()=>{const F=[];for(const W of s.current.agents.values())Mv(W,Nt)&&F.push(W.id+(W.parentId?`>${W.parentId}`:""));return F.sort(),`${F.join("|")}#sv${sc}.${io}`},[s.current,s.current.revision,Nt,sc,io]),Ss=b.useRef(null);b.useEffect(()=>(Ss.current!=null&&window.clearTimeout(Ss.current),Ss.current=window.setTimeout(()=>{ev(un.current,$t.current)},1500),()=>{Ss.current!=null&&window.clearTimeout(Ss.current)}),[Ns]),b.useEffect(()=>{if($n.current===Ns)return;const F=$n.current;if($n.current=Ns,!F||On.current)return;Date.now()-cn.current>1200&&Nn(400),ua.current&&window.clearTimeout(ua.current),ua.current=window.setTimeout(()=>{On.current||Nn(500)},280)},[Ns,e,Nn]);const Ti=b.useMemo(()=>pF(s.current,c),[s.current,s.current.revision,c]),Ai=b.useMemo(()=>AU(s.current,Nt),[s.current,s.current.revision,Nt]),ac=b.useRef(null),[lo,co]=b.useState({w:0,h:0});b.useEffect(()=>{const F=ac.current;if(!F||typeof ResizeObserver>"u")return;const W=new ResizeObserver(ae=>{var Ce;const ie=(Ce=ae[0])==null?void 0:Ce.contentRect;ie&&(ks.current={width:ie.width,height:ie.height},co(Me=>Math.abs(Me.w-ie.width)>40||Math.abs(Me.h-ie.height)>40?{w:ie.width,h:ie.height}:Me))});return W.observe(F),ks.current={width:F.clientWidth,height:F.clientHeight},co({w:F.clientWidth,h:F.clientHeight}),()=>W.disconnect()},[]);const Ud=b.useCallback(F=>{var ae,ie;const W=F.target;!(W!=null&&W.closest)||W.closest(tW)!==F.currentTarget||(F.preventDefault(),(ie=(ae=document.activeElement)==null?void 0:ae.blur)==null||ie.call(ae))},[]),Wd=b.useRef(new Map),[oc,ic]=b.useState(!1);b.useEffect(()=>{const F=window.setTimeout(()=>ic(!0),2500);return()=>window.clearTimeout(F)},[]);const[Hd,Ri]=b.useState(!1),kr=b.useRef(null),[Mi,lc]=b.useState(!1),Gd=b.useCallback(()=>{kr.current&&(window.clearTimeout(kr.current),kr.current=null),Ri(!1)},[]),Vd=b.useCallback(F=>{F.length!==0&&queueMicrotask(()=>{Ri(!0),kr.current&&window.clearTimeout(kr.current),kr.current=window.setTimeout(()=>Ri(!1),nW+80)})},[]);b.useEffect(()=>()=>{kr.current&&window.clearTimeout(kr.current)},[]);const uo=lo.w>0?lo.w*.92:0,js=lo.h>0?lo.h:0,{nodes:_r,edges:cc}=b.useMemo(()=>bW(s.current,Nt,uo,js,$t.current,Fr.current,Wd.current,Vd,oc,Mi,un.current,zd.current,Ns,Ci,c,Ti,Ai,N),[s.current,s.current.revision,Nt,uo,js,oc,Mi,Ns,c,Ti,Ai,N,eo]),Ii=b.useMemo(()=>{const F=new Map;for(const ae of _r){const ie=ae.data;if(!(ie!=null&&ie.sessionId)||ie.exitAt!=null)continue;const Ce=ae.width,Me=ae.height;if(Ce==null||Me==null)continue;const ze=ae.position.x,et=ae.position.y,st=ze+Ce,at=et+Me,Zt=F.get(ie.sessionId);Zt?(Zt.minX=Math.min(Zt.minX,ze),Zt.minY=Math.min(Zt.minY,et),Zt.maxX=Math.max(Zt.maxX,st),Zt.maxY=Math.max(Zt.maxY,at)):F.set(ie.sessionId,{minX:ze,minY:et,maxX:st,maxY:at})}const W=[];for(const[ae,ie]of F){const Ce=ie.maxX-ie.minX+Ru*2,Me=ie.maxY-ie.minY+Ru*2;W.push({id:`group:${ae}`,type:FA,position:{x:ie.minX-Ru,y:ie.minY-Ru},data:{sessionId:ae,w:Ce,h:Me},width:Ce,height:Me,style:{width:Ce,height:Me},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return W},[_r,Nt]),uc=b.useMemo(()=>{const F=[...Ii,..._r],W=Ht.current;return!W||W.size===0?F:F.map(ae=>{const ie=W.get(ae.id);return ie?{...ae,position:ie}:ae})},[Ii,_r,Ld]),ya=b.useMemo(()=>{const F=new Set;for(const W of s.current.agents.values())for(const ae of W.tools)F.add(KA(ae.name));return Object.keys($v).filter(W=>F.has(W))},[s.current,s.current.revision]);b.useEffect(()=>{if(ya.length<=1){ws(!1);return}let F=0;const W=()=>{const ae=Lr.current;if(ae&&!document.hidden){const ie=ae.getBoundingClientRect(),Ce=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(ze=>ze.getBoundingClientRect()),Me=MU(ie,Ce,8);ws(ze=>ze===Me?ze:Me)}F=window.setTimeout(W,300)};return W(),()=>window.clearTimeout(F)},[ya.length]);const dc=b.useCallback(F=>{Jl(W=>{const ae=new Set(W);return ae.has(F)?ae.delete(F):ae.add(F),ae})},[]),Ct=f?s.current.agents.get(f):null,$i=h?Array.from(s.current.agents.values()).flatMap(F=>F.tools).find(F=>F.id===h)??null:null,hc=b.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=yv(),$t.current.clear(),Fr.current.clear(),un.current.clear(),Ci.current="",gC(),v(),l()},[l,v]),fc=b.useRef(E);fc.current=E;const Oi=b.useRef(R);Oi.current=R;const ho=b.useRef(!1);ho.current=$i!=null||Qa||j!=null||$||S!=null||Mn||R||Le!=null;const Nr=b.useCallback(F=>{const W=dq(F,{confirmOpen:fc.current,modalOpen:ho.current});W==="confirm"?C(!0):W==="clear"&&(C(!1),hc())},[hc]),Br=b.useCallback(()=>{$t.current.clear(),un.current.clear(),Ci.current="",gC(),l(),window.setTimeout(()=>Nn(500),80)},[l,e,Nn]),pc=b.useCallback(()=>Nn(500),[Nn]),zr=b.useRef(_r);zr.current=_r;const mc=b.useRef(f);mc.current=f;const fo=b.useCallback(F=>{const W=zr.current,ae=oF(W.map(Me=>({id:Me.id,x:Me.position.x,y:Me.position.y})),mc.current,F),ie=ae?W.find(Me=>Me.id===ae):void 0;if(!ie)return;const Ce=uC(document.activeElement);y(ie.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[ie]})}catch{}cn.current=Date.now(),Ce&&eW(ie.id)},30)},[y,e]),wa=b.useCallback(F=>{y(F,!1),window.setTimeout(()=>{try{const W=zr.current.find(ae=>ae.id===F);W&&e.fitView({padding:.3,duration:500,nodes:[W]}),cn.current=Date.now()}catch{}},60)},[y,e]);b.useEffect(()=>{const F=W=>{var et,st;const ae=W.target,ie={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(et=ae==null?void 0:ae.getAttribute)==null?void 0:et.call(ae,"role"),type:ae==null?void 0:ae.type};if(W.key==="Escape"){const at=B4({overlayOpen:Zu.depth()>0,typing:ox(ie)});at==="dismiss"?Zu.dismissTop():at==="blur"?ae==null||ae.blur():(uF(ie)&&(ae==null||ae.blur()),v());return}if(ax(W))return;const Ce=uC(ae)?(st=ae==null?void 0:ae.getAttribute)==null?void 0:st.call(ae,"data-id"):null,Me=Ce&&zr.current.some(at=>at.id===Ce)?Ce:null,ze=lF(W,Me);if(ze.kind==="activate"){W.preventDefault(),y(ze.nodeId,ze.additive);return}ze.kind!=="node"&&(ze.nodeId==null&&K4(ie)||X4({key:W.key,modalOpen:ho.current,sheetOpen:Oi.current})||(W.key===" "&&(W.preventDefault(),qr()),(W.key==="c"||W.key==="C")&&Nr("shortcut"),(W.key==="r"||W.key==="R")&&Br(),(W.key==="f"||W.key==="F")&&pc(),(W.key==="l"||W.key==="L")&&fs(),(W.key==="d"||W.key==="D")&&X(at=>!at),(W.key==="h"||W.key==="H")&&ps(at=>!at),(W.key==="u"||W.key==="U")&&Z(at=>!at),(W.key==="a"||W.key==="A")&&vn.current.claude&&Xa(),(W.key==="j"||W.key==="J")&&fo(1),(W.key==="k"||W.key==="K")&&fo(-1),(W.key==="t"||W.key==="T")&&ec(at=>at==="dark"?"light":"dark"),(W.key==="m"||W.key==="M")&&vn.current.claude&&U.current!==null&&z.current(W.shiftKey),W.key==="?"&&I(at=>!at)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Nr,Br,pc,v,y,fo,qr]);const po=s.current.agents.size,Gt=b.useMemo(()=>I4(s.current.agents.values()),[s.current,s.current.revision]),Pi=b.useMemo(()=>$4(s.current.agents.values()),[s.current,s.current.revision]),Li=b.useRef(null);b.useEffect(()=>{const F=SF({waiting:Gt.length,running:Pi,connected:ke}),W=Li.current;if(Li.current=F,(W==null?void 0:W.title)!==F.title&&(document.title=F.title),(W==null?void 0:W.icon)!==F.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=jF[F.icon])}},[Gt.length,Pi,ke]);const[Yd,Kd]=b.useState(""),gc=CF(Gt);b.useEffect(()=>{Kd(F=>TF(F,gc))},[gc]);const[mo,Xd]=b.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Ot,Ur]=b.useState(null),[va,go]=b.useState(!0),[yc,Di]=b.useState(!1);b.useEffect(()=>{let F=!0;return fetch("/api/prefs").then(W=>W.ok?W.json():null).then(W=>{var ae,ie,Ce;if(!(!F||!(W!=null&&W.ok))){if(!wi.current){let Me=!1;try{Me=window.localStorage.getItem(Mu)==="0",window.localStorage.removeItem(Mu)}catch{}Me&&((ae=W.prefs)==null?void 0:ae.autoUpdate)!==!1?(vs(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):vs(((ie=W.prefs)==null?void 0:ie.autoUpdate)!==!1)}go(((Ce=W.prefs)==null?void 0:Ce.notifications)!==!1),Di(W.notificationsVetoed===!0)}}).catch(()=>{}),()=>{F=!1}},[]);const yo=b.useRef(()=>{}),Qd=b.useCallback(()=>{const F=!va;go(F),F&&typeof Notification<"u"&&Notification.permission==="default"&&yo.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:F})}).then(W=>W.ok?W.json():null).then(W=>{var ae;W!=null&&W.ok&&(go(((ae=W.prefs)==null?void 0:ae.notifications)!==!1),Di(W.notificationsVetoed===!0))}).catch(()=>{})},[va]),Zd=typeof Notification<"u";b.useEffect(()=>{if(!Ot)return;const W=setTimeout(()=>Ur(null),Ot==="blocked"?8e3:4e3);return()=>clearTimeout(W)},[Ot]);const Wr=b.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(F=>{const W=F;Xd(W),W==="granted"?Ur("on"):W==="denied"&&Ur("blocked")})},[]);yo.current=Wr;const Es=b.useRef(new Set),Hr=b.useRef(null),qi=Gt.map(F=>md(F.id,F.waiting)).join("|");return b.useEffect(()=>{D4(Hr.current,mo)&&(Hr.current=mo,Es.current=Rk(Gt))},[mo]),b.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||Hr.current===null)return;const F=typeof document>"u"||!document.hidden,W=P4(Gt,Es.current,F,va);for(const ae of W)try{const ie=new Notification(ae.title,{body:ae.body,tag:ae.key});ie.onclick=()=>{window.focus(),wa(ae.sessionId),ie.close()}}catch{}Es.current=F?Rk(Gt):L4(Gt,W,Es.current)},[qi]),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:Ut}),we?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{Ae(),Va()},"aria-haspopup":"dialog","aria-label":WU({...we,open:wr}),title:we.kind==="restart"?`Running v${we.from}; v${we.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${we.from}; v${we.to} is on npm · click for what's new`,children:["v",we.from,i.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const F={running:mt,latest:pe==null?void 0:pe.latest,latestPending:pe==null?void 0:pe.latestPending,checkedAgo:pe!=null&&pe.checkedAt?_v(Nt-pe.checkedAt):null,checkDisabled:pe==null?void 0:pe.checkDisabled,checking:Ye};return i.jsxs("button",{type:"button",className:Ye?"v checking":"v",onClick:()=>{Ae(),Je(!0)},"aria-busy":Ye||void 0,"aria-haspopup":"dialog","aria-label":UU(F),title:zU(F),children:["v",F.running]})})()]}),i.jsx("span",{className:"status",children:(()=>{const F=ZU({connected:ke,paused:Dr,held:kn.size,dropped:kn.dropped});return F.resting?null:i.jsx("span",{className:`pill ${F.tone}`,title:F.title,children:i.jsxs("span",{className:"pill-box",children:[i.jsx("span",{className:"pill-widest","aria-hidden":!0,children:F.widest}),i.jsx("span",{className:"pill-label",children:F.label})]})})})()}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Yd}),Gt.length>0&&i.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>wa(Gt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
|
|
259
|
+
Click to set the volume and the sound of each tone, and to hear either one.`}function D2(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 LF(e){const t=D2([{agents:e}]);return t.length<2?null:t.map(n=>`${wx(n.id)} ${Ze(n.cost)}`).join(" · ")}function I1(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 DF(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Cu(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 qF=[7,14,30,90];function FF(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useState(AF)[0],c=b.useRef(!1),u=(f=!1)=>{if(f&&!hr(c.current))return;const p=l.begin();c.current=f;const h=e;a(!0);const y=`/api/ccusage?since=${kv(h)}${f?"&refresh=1":""}`;fetch(y).then(v=>v.json()).then(v=>{p()&&n({range:h,resp:v})}).catch(()=>{p()&&n({range:h,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(c.current=!1,a(!1))})};return b.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:t,loading:s,reload:()=>u(!0)}}function BF({onClose:e,providers:t}){var q;const[n,s]=b.useState(30),[a,l]=b.useState(null),{landed:c,loading:u,reload:f}=FF(n),p=b.useRef(null),h=Wt(e,{focusRef:p}),g=RF({loading:u,want:n,answer:c&&{range:c.range,ok:c.resp.ok===!0,days:((q=c.resp.days)==null?void 0:q.length)??0}}),y=g.phase==="chart"?c.resp.days??[]:[],v=b.useMemo(()=>y.reduce((P,M)=>Math.max(P,M.totalCost),0),[y]),S=b.useRef(null);b.useLayoutEffect(()=>{const P=S.current;P&&(P.scrollLeft=P.scrollWidth)},[y]);const{totalCost:_,totalTok:j,inOut:x,cacheRead:N,modelCosts:E}=b.useMemo(()=>{let P=0,M=0,O=0,V=0;const X=new Map;for(const A of y){P+=A.totalCost,M+=A.totalTokens,O+=A.inputTokens+A.outputTokens,V+=A.cacheReadTokens;for(const Z of A.modelBreakdowns)X.set(Z.modelName,(X.get(Z.modelName)??0)+Z.cost)}return{totalCost:P,totalTok:M,inOut:O,cacheRead:V,modelCosts:X}},[y]),C=b.useMemo(()=>Array.from(E.entries()).sort((P,M)=>M[1]-P[1]),[E]),R=b.useMemo(()=>D2(y),[y]),I=R.length>1,$=a?y.find(P=>P.period===a)??null:null;return i.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:h,className:"uh-modal",onClick:P=>P.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:$F(t,R.map(P=>P.id))})]}),i.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:qF.map(P=>i.jsxs("button",{type:"button","aria-pressed":n===P,className:"uh-range-btn",onClick:()=>{s(P),l(null)},children:[P,"d"]},P))}),i.jsx("button",{className:"glyph-btn uh-reload",onClick:f,...dr(u),title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),i.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.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})]}):g.phase==="error"?i.jsxs("div",{className:"uh-status uh-err",title:ai(c.resp)||void 0,children:[qD(c.resp,"ccusage did not report usage"),i.jsx("div",{children:i.jsx("button",{className:"btn uh-retry",onClick:f,...dr(u),children:u?"trying…":"Try again"})})]}):g.phase==="empty"?i.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):i.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[i.jsxs("div",{className:"uh-totals",children:[i.jsx(Tu,{label:"total cost",val:Ze(_),accent:!0}),i.jsx(Tu,{label:"tokens",val:At(j)}),i.jsx(Tu,{label:"input+output",val:At(x)}),i.jsx(Tu,{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(P=>i.jsx("span",{className:"uh-agent-seg",style:{width:`${_>0?P.cost/_*100:0}%`,background:I1(P.id)}},P.id))}),i.jsx("div",{className:"uh-agent-keys",children:R.map(P=>i.jsxs("span",{className:"uh-agent-key",title:`${P.id} · ${At(P.tokens)} tokens`,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:I1(P.id)}}),wx(P.id),i.jsx("span",{className:"uh-agent-cost",children:Ze(P.cost)}),i.jsx("span",{className:"uh-agent-share",children:DF(P.cost,_)})]},P.id))})]}),i.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map((P,M)=>{const O=v>0?P.totalCost/v*100:0,V=P.period===a,X=`${P.period}, ${Ze(P.totalCost)}`;return i.jsxs("button",{className:`uh-bar-col${V?" sel":""}`,onClick:()=>l(V?null:P.period),"aria-pressed":V,"aria-label":X,title:`${P.period} · ${Ze(P.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(O,P.totalCost>0?2:0)}%`},children:P.modelBreakdowns.slice().sort((A,Z)=>Z.cost-A.cost).map(A=>{const Z=P.totalCost>0?A.cost/P.totalCost*100:0;return i.jsx("div",{className:"uh-bar-seg",style:{height:`${Z}%`,background:Cu(A.modelName)}},A.modelName)})}),i.jsx("span",{className:"uh-bar-label",children:P.period.slice(5)})]},P.period)})}),i.jsx("div",{className:"uh-legend",children:C.map(([P,M])=>i.jsxs("span",{className:"uh-legend-item",title:P,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Cu(P)}}),Ys(P)," ",i.jsx("span",{className:"uh-legend-cost",children:Ze(M)})]},P))}),$&&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:Ze($.totalCost)}),(()=>{var O,V;const M=LF($.agents)??((V=(O=$.metadata)==null?void 0:O.agents)!=null&&V.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(Au,{label:"input",val:At($.inputTokens)}),i.jsx(Au,{label:"output",val:At($.outputTokens)}),i.jsx(Au,{label:"cache write",val:At($.cacheCreationTokens)}),i.jsx(Au,{label:"cache read",val:At($.cacheReadTokens)})]}),i.jsx("div",{className:"uh-detail-models",children:$.modelBreakdowns.slice().sort((P,M)=>M.cost-P.cost).map(P=>{const M=$.totalCost>0?P.cost/$.totalCost*100:0;return i.jsxs("div",{className:"uh-model-row",title:P.modelName,children:[i.jsxs("span",{className:"uh-model-name",children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Cu(P.modelName)}}),i.jsx("span",{className:"uh-model-label",children:Ys(P.modelName)})]}),i.jsx("span",{className:"uh-model-bar",children:i.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Cu(P.modelName)}})}),i.jsx("span",{className:"uh-model-cost",children:Ze(P.cost)})]},P.modelName)})})]})]})]})})}function Tu({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 Au({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 $1=1e4,UF=12e3;function WF({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 u=l.current;if(!u)return;const f=u.getContext("2d");if(!f)return;const p=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let h=0,g=!1;const y=()=>{var te;if(g)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,q=a(),P=Math.min(window.devicePixelRatio||1,2),M=u.clientWidth,O=u.clientHeight;(u.width!==M*P||u.height!==O*P)&&(u.width=M*P,u.height=O*P),f.setTransform(P,0,0,P,0,0),f.clearRect(0,0,M,O);const V=M/2,X=O/2,A=Math.min(M,O)/2-6;f.strokeStyle=E,f.lineWidth=1,f.globalAlpha=R?1:.9;for(const Q of[.4,.7,1])f.beginPath(),f.arc(V,X,A*Q,0,Math.PI*2),f.stroke();f.beginPath(),f.moveTo(V-A,X),f.lineTo(V+A,X),f.moveTo(V,X-A),f.lineTo(V,X+A),f.stroke(),f.globalAlpha=1;const B=(x&&!p?q%$1/$1:0)*Math.PI*2-Math.PI/2;if(x){const Q=(te=f.createConicGradient)==null?void 0:te.call(f,B-.85,V,X);Q&&(Q.addColorStop(0,"transparent"),Q.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${I}%, transparent)`),Q.addColorStop(1,"transparent"),f.fillStyle=Q,f.beginPath(),f.moveTo(V,X),f.arc(V,X,A,B-.85,B),f.closePath(),f.fill()),f.strokeStyle=N,f.globalAlpha=$,f.beginPath(),f.moveTo(V,X),f.lineTo(V+Math.cos(B)*A,X+Math.sin(B)*A),f.stroke(),f.globalAlpha=1}_.forEach((Q,D)=>{const K=D/Math.max(_.length,1)*Math.PI*2-Math.PI/2,L=Q.lastReadMs===null?1:Math.min(1,(q-Q.lastReadMs)/12e4),G=A*(.42+L*.5),de=V+Math.cos(K)*G,z=X+Math.sin(K)*G,U=Math.abs((B-K+Math.PI*3)%(Math.PI*2)-Math.PI),J=x?Math.max(0,1-U/.55):0;f.beginPath(),f.arc(de,z,3+J*1.6,0,Math.PI*2),f.fillStyle=Q.running?N:C,f.globalAlpha=Q.running?.55+J*.45:.35,f.fill(),f.globalAlpha=1});for(const Q of j){const D=(q-Q.atMs)/UF;if(D<0||D>1)continue;const L=Math.max(0,_.findIndex(z=>z.key===Q.browser))/Math.max(_.length,1)*Math.PI*2-Math.PI/2,G=V+Math.cos(L)*A*.6,de=X+Math.sin(L)*A*.6;f.beginPath(),f.arc(G,de,4+D*22,0,Math.PI*2),f.strokeStyle=N,f.globalAlpha=(1-D)*.8,f.lineWidth=1.5,f.stroke(),f.globalAlpha=1}h=requestAnimationFrame(y)};return y(),()=>{g=!0,cancelAnimationFrame(h)}},[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 O1="agent-dag.browserWatch.seenMs";function HF(e,t){return e.filter(n=>n.startMs>t)}function GF(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function VF(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 q2(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function P1(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 YF(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 KF(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 XF(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=q2(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 QF(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 ZF(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function L1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function JF({onClose:e,onSeen:t,onWatching:n,palette:s}){const a=Wt(e),[l,c]=b.useState(null),[u,f]=b.useState(null),[p,h]=b.useState(null),[g,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),[$,q]=b.useState(!1),[P,M]=b.useState(!1),[O,V]=b.useState(!1),[X,A]=b.useState(!1),[Z,B]=b.useState(()=>Date.now());b.useEffect(()=>{const H=setInterval(()=>B(Date.now()),1e3);return()=>clearInterval(H)},[]);const te=b.useCallback(async H=>{var oe,me;if(!(H&&!hr(v.current))){v.current=H,y(!0);try{const ye=await fetch(`/api/browser-watch${H?"?refresh=1":""}`);if(!ye.ok)throw new Error(`the deck answered ${ye.status}`);const Ee=await ye.json();c(Ee),C.current||_(((oe=Ee==null?void 0:Ee.settings)==null?void 0:oe.quietMinutes)??15),n(((me=Ee==null?void 0:Ee.settings)==null?void 0:me.enabled)===!0),f(null)}catch(ye){f(ye instanceof Error?ye.message:String(ye))}finally{v.current=!1,y(!1)}}},[n]);b.useEffect(()=>{te(!1)},[te]),b.useEffect(()=>{const H=setInterval(()=>{te(!1)},1e4);return()=>clearInterval(H)},[te]);const Q=b.useCallback(async H=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:H.host,startMs:H.startMs})})}finally{await te(!1)}},[te]),D=b.useCallback(async H=>{C.current=!0,E(!0);try{const oe=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(H)});if(!oe.ok)throw new Error(`the deck answered ${oe.status}`);await te(!1),h(null)}catch(oe){h(oe instanceof Error?oe.message:String(oe))}finally{C.current=!1,E(!1)}},[te]),K=b.useRef(t);K.current=t,b.useEffect(()=>()=>K.current(Date.now()),[]);const L=b.useMemo(()=>{const H=[];for(const oe of(l==null?void 0:l.episodes)??[]){const me=ZF(oe.startMs),ye=H[H.length-1];ye&&ye.label===me?ye.episodes.push(oe):H.push({label:me,episodes:[oe]})}return H},[l]),G=q2(l==null?void 0:l.browsers),de=((l==null?void 0:l.browsers)??[]).filter(H=>!(H.installed&&H.profiles>0)),z=l?XF(l):null,U=G.reduce((H,oe)=>H+oe.profiles,0),J=l?GF(l.coverage.lastHumanMs,l.coverage.quietMs,Z):null;return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal bw-modal",onClick:H=>H.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 te(!0),...dr(g),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:g?"…":"↻"}),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&&!u&&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."})]}),u&&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:u})]})}),l&&z&&i.jsx("p",{className:`bw-trouble ${z.kind}`,role:"status",children:z.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(H=>!H),"aria-expanded":P,"aria-label":"What the sweep and the dots mean",children:"?"})]}),i.jsxs("div",{className:"bw-glance",children:[i.jsx(WF,{browsers:G.map(H=>{var oe;return{key:H.key,name:H.name,running:H.running,lastReadMs:((oe=l.profiles.find(me=>me.browser===H.key))==null?void 0:oe.lastWrittenMs)??null}}),findings:l.episodes.slice(0,6).map(H=>({browser:H.browser??null,atMs:H.endMs})),watching:l.settings.enabled,palette:s}),i.jsx("ul",{className:"bw-counts",children:YF(G,l.profiles).map(H=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-count-n",children:H.visits.toLocaleString("en-US")}),i.jsx("span",{className:"bw-count-of",children:H.name})]},H.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 ",KF(l.coverage.checkedMs,Z),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 ",VF(J)]}),P&&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:()=>V(H=>!H),"aria-expanded":O,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),O&&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(H=>i.jsxs("li",{children:[i.jsx("span",{className:`bw-prof-dot${H.running?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-prof-name",children:H.name}),i.jsx("span",{className:"bw-prof-state",children:H.running?"running":"idle"}),H.running&&H.relay.state==="live"&&i.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},H.key))}),de.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>A(H=>!H),"aria-expanded":X,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:X?"▾":"▸"})," ",de.length," not watched"]}),X&&i.jsxs("p",{className:"bw-rest",children:[de.map(H=>H.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]}),l.relay&&i.jsx(e8,{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:L.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."})]}):L.map(H=>i.jsxs("div",{className:"bw-day",children:[i.jsx("h4",{className:"bw-sec-head",children:H.label}),H.episodes.map(oe=>{const me=`${oe.host}-${oe.startMs}`,ye=j===me;return i.jsxs("div",{className:`bw-ep${ye?" open":""}`,children:[i.jsxs("div",{className:"bw-ep-row",children:[i.jsxs("button",{className:"bw-ep-head",onClick:()=>x(ye?null:me),"aria-expanded":ye,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:ye?"▾":"▸"}),i.jsx("span",{className:"bw-ep-host",children:oe.host}),i.jsxs("span",{className:"bw-ep-meta",children:[QF(oe),L1(oe)&&i.jsxs(i.Fragment,{children:[" · ",L1(oe)]})]}),i.jsxs("span",{className:"bw-ep-count",children:[oe.count," ",oe.count===1?"page":"pages"]})]}),i.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Q(oe),"aria-label":`Dismiss ${oe.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),ye&&i.jsx("ul",{className:"bw-urls",children:oe.urls.map((Ee,Be)=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-url-time",children:new Date(Ee.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),i.jsx("span",{className:"bw-url",children:Ee.url})]},`${Ee.url}-${Ee.timeMs}-${Be}`))})]},me)})]},H.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(H=>i.jsxs("div",{className:`bw-log-line ${H.level}${H.parts?"":" sys"}`,children:[i.jsx("span",{className:"bw-log-time",children:new Date(H.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),H.parts?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"bw-log-browser",children:H.parts.browser}),i.jsx("span",{className:"bw-log-profile",title:H.parts.profile,children:H.parts.profile}),i.jsxs("span",{className:"bw-log-value",children:[H.parts.value,H.parts.flagged>0&&i.jsxs("span",{className:"bw-log-flag",children:[" · ",H.parts.flagged," flagged"]})]})]}):i.jsx("span",{className:"bw-log-sys",children:H.text})]},`${H.atMs}-${H.level}-${H.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:H=>{_(Number(H.target.value)),D({quietMinutes:Number(H.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:H=>void D({reaction:H.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(H=>i.jsx("option",{value:H,children:H==="notify"?"notify me":H==="close-tab"?"close the tab":"quit the browser"},H))})]}),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:()=>q(H=>!H),"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:()=>h(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:P1(l,N).word},P1(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(H=>!H),"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 e8({relay:e}){const[t,n]=b.useState(!1),[s,a]=b.useState(!1),l=e.killswitch.blocked?"unblock":"block",c=e.command[l],u=b.useCallback(async()=>{await T2(c.command)&&(a(!0),window.setTimeout(()=>a(!1),1600))},[c.command]),f=e.profiles.filter(h=>{var g;return(g=h.report)==null?void 0:g.present}),p=e.profiles.filter(h=>h.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(h=>i.jsx("code",{className:"bw-path",children:h},h))]}),i.jsxs("button",{className:"bw-why",onClick:()=>n(h=>!h),"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:[f.length>0&&i.jsx("dl",{className:"bw-key",children:f.map(h=>i.jsxs(b.Fragment,{children:[i.jsxs("dt",{children:[h.name,h.profile==="Default"?"":` · ${h.profile}`]}),i.jsxs("dd",{children:[h.report.enabled?"enabled":"installed but switched off",h.report.allUrls?", can act on every site":", limited to the sites it was granted",h.report.sensitiveApis.length>0&&i.jsxs(i.Fragment,{children:[" — ",h.report.sensitiveApis.join(", ")]})]})]},`${h.browser}/${h.profile}`))}),p.length>0&&i.jsxs("p",{className:"bw-rc-note",children:[p.map(h=>h.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."]}),f.some(h=>h.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:u,children:s?"Copied":"Copy"})]}),i.jsx("p",{className:"bw-rc-note",children:c.note})]})]})}function t8(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 n8({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:l,onLater:c}){const u=b.useRef(null),f=Wt(c,{focusRef:u}),p=Ks(n,"accept"),h=Ks(n,"dismiss");return i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:f,className:"modal lan-ask",onClick:g=>g.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 ",mx(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:u,className:"btn",disabled:h.disabled,"aria-busy":h.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 vx(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 If,D1;function r8(){if(D1)return If;D1=1;function e(){this.__data__=[],this.size=0}return If=e,If}var $f,q1;function hi(){if(q1)return $f;q1=1;function e(t,n){return t===n||t!==t&&n!==n}return $f=e,$f}var Of,F1;function vd(){if(F1)return Of;F1=1;var e=hi();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Of=t,Of}var Pf,B1;function s8(){if(B1)return Pf;B1=1;var e=vd(),t=Array.prototype,n=t.splice;function s(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var u=l.length-1;return c==u?l.pop():n.call(l,c,1),--this.size,!0}return Pf=s,Pf}var Lf,z1;function a8(){if(z1)return Lf;z1=1;var e=vd();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return Lf=t,Lf}var Df,U1;function o8(){if(U1)return Df;U1=1;var e=vd();function t(n){return e(this.__data__,n)>-1}return Df=t,Df}var qf,W1;function i8(){if(W1)return qf;W1=1;var e=vd();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 qf=t,qf}var Ff,H1;function xd(){if(H1)return Ff;H1=1;var e=r8(),t=s8(),n=a8(),s=o8(),a=i8();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];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,Ff=l,Ff}var Bf,G1;function l8(){if(G1)return Bf;G1=1;var e=xd();function t(){this.__data__=new e,this.size=0}return Bf=t,Bf}var zf,V1;function c8(){if(V1)return zf;V1=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return zf=e,zf}var Uf,Y1;function u8(){if(Y1)return Uf;Y1=1;function e(t){return this.__data__.get(t)}return Uf=e,Uf}var Wf,K1;function d8(){if(K1)return Wf;K1=1;function e(t){return this.__data__.has(t)}return Wf=e,Wf}var Hf,X1;function F2(){if(X1)return Hf;X1=1;var e=typeof cu=="object"&&cu&&cu.Object===Object&&cu;return Hf=e,Hf}var Gf,Q1;function yr(){if(Q1)return Gf;Q1=1;var e=F2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Gf=n,Gf}var Vf,Z1;function fi(){if(Z1)return Vf;Z1=1;var e=yr(),t=e.Symbol;return Vf=t,Vf}var Yf,J1;function h8(){if(J1)return Yf;J1=1;var e=fi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function l(c){var u=n.call(c,a),f=c[a];try{c[a]=void 0;var p=!0}catch{}var h=s.call(c);return p&&(u?c[a]=f:delete c[a]),h}return Yf=l,Yf}var Kf,e_;function f8(){if(e_)return Kf;e_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Kf=n,Kf}var Xf,t_;function Ua(){if(t_)return Xf;t_=1;var e=fi(),t=h8(),n=f8(),s="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(u){return u==null?u===void 0?a:s:l&&l in Object(u)?t(u):n(u)}return Xf=c,Xf}var Qf,n_;function Vn(){if(n_)return Qf;n_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Qf=e,Qf}var Zf,r_;function Vl(){if(r_)return Zf;r_=1;var e=Ua(),t=Vn(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(u){if(!t(u))return!1;var f=e(u);return f==s||f==a||f==n||f==l}return Zf=c,Zf}var Jf,s_;function p8(){if(s_)return Jf;s_=1;var e=yr(),t=e["__core-js_shared__"];return Jf=t,Jf}var ep,a_;function m8(){if(a_)return ep;a_=1;var e=p8(),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 ep=n,ep}var tp,o_;function B2(){if(o_)return tp;o_=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 tp=n,tp}var np,i_;function g8(){if(i_)return np;i_=1;var e=Vl(),t=m8(),n=Vn(),s=B2(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,f=c.toString,p=u.hasOwnProperty,h=RegExp("^"+f.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!n(y)||t(y))return!1;var v=e(y)?h:l;return v.test(s(y))}return np=g,np}var rp,l_;function y8(){if(l_)return rp;l_=1;function e(t,n){return t==null?void 0:t[n]}return rp=e,rp}var sp,c_;function Wa(){if(c_)return sp;c_=1;var e=g8(),t=y8();function n(s,a){var l=t(s,a);return e(l)?l:void 0}return sp=n,sp}var ap,u_;function xx(){if(u_)return ap;u_=1;var e=Wa(),t=yr(),n=e(t,"Map");return ap=n,ap}var op,d_;function bd(){if(d_)return op;d_=1;var e=Wa(),t=e(Object,"create");return op=t,op}var ip,h_;function w8(){if(h_)return ip;h_=1;var e=bd();function t(){this.__data__=e?e(null):{},this.size=0}return ip=t,ip}var lp,f_;function v8(){if(f_)return lp;f_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return lp=e,lp}var cp,p_;function x8(){if(p_)return cp;p_=1;var e=bd(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var u=c[l];return u===t?void 0:u}return s.call(c,l)?c[l]:void 0}return cp=a,cp}var up,m_;function b8(){if(m_)return up;m_=1;var e=bd(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return up=s,up}var dp,g_;function k8(){if(g_)return dp;g_=1;var e=bd(),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 dp=n,dp}var hp,y_;function _8(){if(y_)return hp;y_=1;var e=w8(),t=v8(),n=x8(),s=b8(),a=k8();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];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,hp=l,hp}var fp,w_;function N8(){if(w_)return fp;w_=1;var e=_8(),t=xd(),n=xx();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return fp=s,fp}var pp,v_;function S8(){if(v_)return pp;v_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return pp=e,pp}var mp,x_;function kd(){if(x_)return mp;x_=1;var e=S8();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return mp=t,mp}var gp,b_;function j8(){if(b_)return gp;b_=1;var e=kd();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return gp=t,gp}var yp,k_;function E8(){if(k_)return yp;k_=1;var e=kd();function t(n){return e(this,n).get(n)}return yp=t,yp}var wp,__;function C8(){if(__)return wp;__=1;var e=kd();function t(n){return e(this,n).has(n)}return wp=t,wp}var vp,N_;function T8(){if(N_)return vp;N_=1;var e=kd();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 vp=t,vp}var xp,S_;function bx(){if(S_)return xp;S_=1;var e=N8(),t=j8(),n=E8(),s=C8(),a=T8();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];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,xp=l,xp}var bp,j_;function A8(){if(j_)return bp;j_=1;var e=xd(),t=xx(),n=bx(),s=200;function a(l,c){var u=this.__data__;if(u instanceof e){var f=u.__data__;if(!t||f.length<s-1)return f.push([l,c]),this.size=++u.size,this;u=this.__data__=new n(f)}return u.set(l,c),this.size=u.size,this}return bp=a,bp}var kp,E_;function _d(){if(E_)return kp;E_=1;var e=xd(),t=l8(),n=c8(),s=u8(),a=d8(),l=A8();function c(u){var f=this.__data__=new e(u);this.size=f.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=s,c.prototype.has=a,c.prototype.set=l,kp=c,kp}var _p,C_;function kx(){if(C_)return _p;C_=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 _p=e,_p}var Np,T_;function z2(){if(T_)return Np;T_=1;var e=Wa(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Np=t,Np}var Sp,A_;function Nd(){if(A_)return Sp;A_=1;var e=z2();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Sp=t,Sp}var jp,R_;function Sd(){if(R_)return jp;R_=1;var e=Nd(),t=hi(),n=Object.prototype,s=n.hasOwnProperty;function a(l,c,u){var f=l[c];(!(s.call(l,c)&&t(f,u))||u===void 0&&!(c in l))&&e(l,c,u)}return jp=a,jp}var Ep,M_;function Yl(){if(M_)return Ep;M_=1;var e=Sd(),t=Nd();function n(s,a,l,c){var u=!l;l||(l={});for(var f=-1,p=a.length;++f<p;){var h=a[f],g=c?c(l[h],s[h],h,l,s):void 0;g===void 0&&(g=s[h]),u?t(l,h,g):e(l,h,g)}return l}return Ep=n,Ep}var Cp,I_;function R8(){if(I_)return Cp;I_=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return Cp=e,Cp}var Tp,$_;function $r(){if($_)return Tp;$_=1;function e(t){return t!=null&&typeof t=="object"}return Tp=e,Tp}var Ap,O_;function M8(){if(O_)return Ap;O_=1;var e=Ua(),t=$r(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Ap=s,Ap}var Rp,P_;function Kl(){if(P_)return Rp;P_=1;var e=M8(),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 Rp=l,Rp}var Mp,L_;function Mt(){if(L_)return Mp;L_=1;var e=Array.isArray;return Mp=e,Mp}var wl={exports:{}},Ip,D_;function I8(){if(D_)return Ip;D_=1;function e(){return!1}return Ip=e,Ip}wl.exports;var q_;function pi(){return q_||(q_=1,(function(e,t){var n=yr(),s=I8(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,u=c?n.Buffer:void 0,f=u?u.isBuffer:void 0,p=f||s;e.exports=p})(wl,wl.exports)),wl.exports}var $p,F_;function jd(){if(F_)return $p;F_=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 $p=n,$p}var Op,B_;function _x(){if(B_)return Op;B_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Op=t,Op}var Pp,z_;function $8(){if(z_)return Pp;z_=1;var e=Ua(),t=_x(),n=$r(),s="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",u="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",g="[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]",q="[object Uint8ClampedArray]",P="[object Uint16Array]",M="[object Uint32Array]",O={};O[N]=O[E]=O[C]=O[R]=O[I]=O[$]=O[q]=O[P]=O[M]=!0,O[s]=O[a]=O[j]=O[l]=O[x]=O[c]=O[u]=O[f]=O[p]=O[h]=O[g]=O[y]=O[v]=O[S]=O[_]=!1;function V(X){return n(X)&&t(X.length)&&!!O[e(X)]}return Pp=V,Pp}var Lp,U_;function Ed(){if(U_)return Lp;U_=1;function e(t){return function(n){return t(n)}}return Lp=e,Lp}var vl={exports:{}};vl.exports;var W_;function Nx(){return W_||(W_=1,(function(e,t){var n=F2(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l&&n.process,u=(function(){try{var f=a&&a.require&&a.require("util").types;return f||c&&c.binding&&c.binding("util")}catch{}})();e.exports=u})(vl,vl.exports)),vl.exports}var Dp,H_;function Xl(){if(H_)return Dp;H_=1;var e=$8(),t=Ed(),n=Nx(),s=n&&n.isTypedArray,a=s?t(s):e;return Dp=a,Dp}var qp,G_;function U2(){if(G_)return qp;G_=1;var e=R8(),t=Kl(),n=Mt(),s=pi(),a=jd(),l=Xl(),c=Object.prototype,u=c.hasOwnProperty;function f(p,h){var g=n(p),y=!g&&t(p),v=!g&&!y&&s(p),S=!g&&!y&&!v&&l(p),_=g||y||v||S,j=_?e(p.length,String):[],x=j.length;for(var N in p)(h||u.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 qp=f,qp}var Fp,V_;function Cd(){if(V_)return Fp;V_=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Fp=t,Fp}var Bp,Y_;function W2(){if(Y_)return Bp;Y_=1;function e(t,n){return function(s){return t(n(s))}}return Bp=e,Bp}var zp,K_;function O8(){if(K_)return zp;K_=1;var e=W2(),t=e(Object.keys,Object);return zp=t,zp}var Up,X_;function Sx(){if(X_)return Up;X_=1;var e=Cd(),t=O8(),n=Object.prototype,s=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var u in Object(l))s.call(l,u)&&u!="constructor"&&c.push(u);return c}return Up=a,Up}var Wp,Q_;function ls(){if(Q_)return Wp;Q_=1;var e=Vl(),t=_x();function n(s){return s!=null&&t(s.length)&&!e(s)}return Wp=n,Wp}var Hp,Z_;function Xs(){if(Z_)return Hp;Z_=1;var e=U2(),t=Sx(),n=ls();function s(a){return n(a)?e(a):t(a)}return Hp=s,Hp}var Gp,J_;function P8(){if(J_)return Gp;J_=1;var e=Yl(),t=Xs();function n(s,a){return s&&e(a,t(a),s)}return Gp=n,Gp}var Vp,eN;function L8(){if(eN)return Vp;eN=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Vp=e,Vp}var Yp,tN;function D8(){if(tN)return Yp;tN=1;var e=Vn(),t=Cd(),n=L8(),s=Object.prototype,a=s.hasOwnProperty;function l(c){if(!e(c))return n(c);var u=t(c),f=[];for(var p in c)p=="constructor"&&(u||!a.call(c,p))||f.push(p);return f}return Yp=l,Yp}var Kp,nN;function Ha(){if(nN)return Kp;nN=1;var e=U2(),t=D8(),n=ls();function s(a){return n(a)?e(a,!0):t(a)}return Kp=s,Kp}var Xp,rN;function q8(){if(rN)return Xp;rN=1;var e=Yl(),t=Ha();function n(s,a){return s&&e(a,t(a),s)}return Xp=n,Xp}var xl={exports:{}};xl.exports;var sN;function H2(){return sN||(sN=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,u=c?c.allocUnsafe:void 0;function f(p,h){if(h)return p.slice();var g=p.length,y=u?u(g):new p.constructor(g);return p.copy(y),y}e.exports=f})(xl,xl.exports)),xl.exports}var Qp,aN;function G2(){if(aN)return Qp;aN=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 Qp=e,Qp}var Zp,oN;function V2(){if(oN)return Zp;oN=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=0,c=[];++s<a;){var u=t[s];n(u,s,t)&&(c[l++]=u)}return c}return Zp=e,Zp}var Jp,iN;function Y2(){if(iN)return Jp;iN=1;function e(){return[]}return Jp=e,Jp}var em,lN;function jx(){if(lN)return em;lN=1;var e=V2(),t=Y2(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(u){return s.call(c,u)}))}:t;return em=l,em}var tm,cN;function F8(){if(cN)return tm;cN=1;var e=Yl(),t=jx();function n(s,a){return e(s,t(s),a)}return tm=n,tm}var nm,uN;function Ex(){if(uN)return nm;uN=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 nm=e,nm}var rm,dN;function Td(){if(dN)return rm;dN=1;var e=W2(),t=e(Object.getPrototypeOf,Object);return rm=t,rm}var sm,hN;function K2(){if(hN)return sm;hN=1;var e=Ex(),t=Td(),n=jx(),s=Y2(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var u=[];c;)e(u,n(c)),c=t(c);return u}:s;return sm=l,sm}var am,fN;function B8(){if(fN)return am;fN=1;var e=Yl(),t=K2();function n(s,a){return e(s,t(s),a)}return am=n,am}var om,pN;function X2(){if(pN)return om;pN=1;var e=Ex(),t=Mt();function n(s,a,l){var c=a(s);return t(s)?c:e(c,l(s))}return om=n,om}var im,mN;function Q2(){if(mN)return im;mN=1;var e=X2(),t=jx(),n=Xs();function s(a){return e(a,n,t)}return im=s,im}var lm,gN;function z8(){if(gN)return lm;gN=1;var e=X2(),t=K2(),n=Ha();function s(a){return e(a,n,t)}return lm=s,lm}var cm,yN;function U8(){if(yN)return cm;yN=1;var e=Wa(),t=yr(),n=e(t,"DataView");return cm=n,cm}var um,wN;function W8(){if(wN)return um;wN=1;var e=Wa(),t=yr(),n=e(t,"Promise");return um=n,um}var dm,vN;function Z2(){if(vN)return dm;vN=1;var e=Wa(),t=yr(),n=e(t,"Set");return dm=n,dm}var hm,xN;function H8(){if(xN)return hm;xN=1;var e=Wa(),t=yr(),n=e(t,"WeakMap");return hm=n,hm}var fm,bN;function mi(){if(bN)return fm;bN=1;var e=U8(),t=xx(),n=W8(),s=Z2(),a=H8(),l=Ua(),c=B2(),u="[object Map]",f="[object Object]",p="[object Promise]",h="[object Set]",g="[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)!=u||n&&N(n.resolve())!=p||s&&N(new s)!=h||a&&N(new a)!=g)&&(N=function(E){var C=l(E),R=C==f?E.constructor:void 0,I=R?c(R):"";if(I)switch(I){case v:return y;case S:return u;case _:return p;case j:return h;case x:return g}return C}),fm=N,fm}var pm,kN;function G8(){if(kN)return pm;kN=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 pm=n,pm}var mm,_N;function J2(){if(_N)return mm;_N=1;var e=yr(),t=e.Uint8Array;return mm=t,mm}var gm,NN;function Cx(){if(NN)return gm;NN=1;var e=J2();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return gm=t,gm}var ym,SN;function V8(){if(SN)return ym;SN=1;var e=Cx();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return ym=t,ym}var wm,jN;function Y8(){if(jN)return wm;jN=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return wm=t,wm}var vm,EN;function K8(){if(EN)return vm;EN=1;var e=fi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return vm=s,vm}var xm,CN;function eA(){if(CN)return xm;CN=1;var e=Cx();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return xm=t,xm}var bm,TN;function X8(){if(TN)return bm;TN=1;var e=Cx(),t=V8(),n=Y8(),s=K8(),a=eA(),l="[object Boolean]",c="[object Date]",u="[object Map]",f="[object Number]",p="[object RegExp]",h="[object Set]",g="[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 q(P,M,O){var V=P.constructor;switch(M){case v:return e(P);case l:case c:return new V(+P);case S:return t(P,O);case _:case j:case x:case N:case E:case C:case R:case I:case $:return a(P,O);case u:return new V;case f:case g:return new V(P);case p:return n(P);case h:return new V;case y:return s(P)}}return bm=q,bm}var km,AN;function tA(){if(AN)return km;AN=1;var e=Vn(),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 km=n,km}var _m,RN;function nA(){if(RN)return _m;RN=1;var e=tA(),t=Td(),n=Cd();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return _m=s,_m}var Nm,MN;function Q8(){if(MN)return Nm;MN=1;var e=mi(),t=$r(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return Nm=s,Nm}var Sm,IN;function Z8(){if(IN)return Sm;IN=1;var e=Q8(),t=Ed(),n=Nx(),s=n&&n.isMap,a=s?t(s):e;return Sm=a,Sm}var jm,$N;function J8(){if($N)return jm;$N=1;var e=mi(),t=$r(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return jm=s,jm}var Em,ON;function eB(){if(ON)return Em;ON=1;var e=J8(),t=Ed(),n=Nx(),s=n&&n.isSet,a=s?t(s):e;return Em=a,Em}var Cm,PN;function rA(){if(PN)return Cm;PN=1;var e=_d(),t=kx(),n=Sd(),s=P8(),a=q8(),l=H2(),c=G2(),u=F8(),f=B8(),p=Q2(),h=z8(),g=mi(),y=G8(),v=X8(),S=nA(),_=Mt(),j=pi(),x=Z8(),N=Vn(),E=eB(),C=Xs(),R=Ha(),I=1,$=2,q=4,P="[object Arguments]",M="[object Array]",O="[object Boolean]",V="[object Date]",X="[object Error]",A="[object Function]",Z="[object GeneratorFunction]",B="[object Map]",te="[object Number]",Q="[object Object]",D="[object RegExp]",K="[object Set]",L="[object String]",G="[object Symbol]",de="[object WeakMap]",z="[object ArrayBuffer]",U="[object DataView]",J="[object Float32Array]",H="[object Float64Array]",oe="[object Int8Array]",me="[object Int16Array]",ye="[object Int32Array]",Ee="[object Uint8Array]",Be="[object Uint8ClampedArray]",ce="[object Uint16Array]",Ne="[object Uint32Array]",ve={};ve[P]=ve[M]=ve[z]=ve[U]=ve[O]=ve[V]=ve[J]=ve[H]=ve[oe]=ve[me]=ve[ye]=ve[B]=ve[te]=ve[Q]=ve[D]=ve[K]=ve[L]=ve[G]=ve[Ee]=ve[Be]=ve[ce]=ve[Ne]=!0,ve[X]=ve[A]=ve[de]=!1;function Fe(he,ke,Ke,pe,dt,ot){var Ve,ge=ke&I,Se=ke&$,qe=ke&q;if(Ke&&(Ve=dt?Ke(he,pe,dt,ot):Ke(he)),Ve!==void 0)return Ve;if(!N(he))return he;var Ye=_(he);if(Ye){if(Ve=y(he),!ge)return c(he,Ve)}else{var it=g(he),Je=it==A||it==Z;if(j(he))return l(he,ge);if(it==Q||it==P||Je&&!dt){if(Ve=Se||Je?{}:S(he),!ge)return Se?f(he,a(Ve,he)):u(he,s(Ve,he))}else{if(!ve[it])return dt?he:{};Ve=v(he,it,ge)}}ot||(ot=new e);var re=ot.get(he);if(re)return re;ot.set(he,Ve),E(he)?he.forEach(function(Te){Ve.add(Fe(Te,ke,Ke,Te,he,ot))}):x(he)&&he.forEach(function(Te,He){Ve.set(He,Fe(Te,ke,Ke,He,he,ot))});var we=qe?Se?h:p:Se?R:C,Le=Ye?void 0:we(he);return t(Le||he,function(Te,He){Le&&(He=Te,Te=he[He]),n(Ve,He,Fe(Te,ke,Ke,He,he,ot))}),Ve}return Cm=Fe,Cm}var Tm,LN;function tB(){if(LN)return Tm;LN=1;var e=rA(),t=4;function n(s){return e(s,t)}return Tm=n,Tm}var Am,DN;function Tx(){if(DN)return Am;DN=1;function e(t){return function(){return t}}return Am=e,Am}var Rm,qN;function nB(){if(qN)return Rm;qN=1;function e(t){return function(n,s,a){for(var l=-1,c=Object(n),u=a(n),f=u.length;f--;){var p=u[t?f:++l];if(s(c[p],p,c)===!1)break}return n}}return Rm=e,Rm}var Mm,FN;function Ax(){if(FN)return Mm;FN=1;var e=nB(),t=e();return Mm=t,Mm}var Im,BN;function Rx(){if(BN)return Im;BN=1;var e=Ax(),t=Xs();function n(s,a){return s&&e(s,a,t)}return Im=n,Im}var $m,zN;function rB(){if(zN)return $m;zN=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,u=s?c:-1,f=Object(a);(s?u--:++u<c)&&l(f[u],u,f)!==!1;);return a}}return $m=t,$m}var Om,UN;function Ad(){if(UN)return Om;UN=1;var e=Rx(),t=rB(),n=t(e);return Om=n,Om}var Pm,WN;function Ga(){if(WN)return Pm;WN=1;function e(t){return t}return Pm=e,Pm}var Lm,HN;function sA(){if(HN)return Lm;HN=1;var e=Ga();function t(n){return typeof n=="function"?n:e}return Lm=t,Lm}var Dm,GN;function aA(){if(GN)return Dm;GN=1;var e=kx(),t=Ad(),n=sA(),s=Mt();function a(l,c){var u=s(l)?e:t;return u(l,n(c))}return Dm=a,Dm}var qm,VN;function oA(){return VN||(VN=1,qm=aA()),qm}var Fm,YN;function sB(){if(YN)return Fm;YN=1;var e=Ad();function t(n,s){var a=[];return e(n,function(l,c,u){s(l,c,u)&&a.push(l)}),a}return Fm=t,Fm}var Bm,KN;function aB(){if(KN)return Bm;KN=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Bm=t,Bm}var zm,XN;function oB(){if(XN)return zm;XN=1;function e(t){return this.__data__.has(t)}return zm=e,zm}var Um,QN;function iA(){if(QN)return Um;QN=1;var e=bx(),t=aB(),n=oB();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,Um=s,Um}var Wm,ZN;function iB(){if(ZN)return Wm;ZN=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 Wm=e,Wm}var Hm,JN;function lA(){if(JN)return Hm;JN=1;function e(t,n){return t.has(n)}return Hm=e,Hm}var Gm,eS;function cA(){if(eS)return Gm;eS=1;var e=iA(),t=iB(),n=lA(),s=1,a=2;function l(c,u,f,p,h,g){var y=f&s,v=c.length,S=u.length;if(v!=S&&!(y&&S>v))return!1;var _=g.get(c),j=g.get(u);if(_&&j)return _==u&&j==c;var x=-1,N=!0,E=f&a?new e:void 0;for(g.set(c,u),g.set(u,c);++x<v;){var C=c[x],R=u[x];if(p)var I=y?p(R,C,x,u,c,g):p(C,R,x,c,u,g);if(I!==void 0){if(I)continue;N=!1;break}if(E){if(!t(u,function($,q){if(!n(E,q)&&(C===$||h(C,$,f,p,g)))return E.push(q)})){N=!1;break}}else if(!(C===R||h(C,R,f,p,g))){N=!1;break}}return g.delete(c),g.delete(u),N}return Gm=l,Gm}var Vm,tS;function lB(){if(tS)return Vm;tS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,l){s[++n]=[l,a]}),s}return Vm=e,Vm}var Ym,nS;function Mx(){if(nS)return Ym;nS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Ym=e,Ym}var Km,rS;function cB(){if(rS)return Km;rS=1;var e=fi(),t=J2(),n=hi(),s=cA(),a=lB(),l=Mx(),c=1,u=2,f="[object Boolean]",p="[object Date]",h="[object Error]",g="[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,$,q,P,M,O,V){switch(q){case N:if(I.byteLength!=$.byteLength||I.byteOffset!=$.byteOffset)return!1;I=I.buffer,$=$.buffer;case x:return!(I.byteLength!=$.byteLength||!O(new t(I),new t($)));case f:case p:case y:return n(+I,+$);case h:return I.name==$.name&&I.message==$.message;case v:case _:return I==$+"";case g:var X=a;case S:var A=P&c;if(X||(X=l),I.size!=$.size&&!A)return!1;var Z=V.get(I);if(Z)return Z==$;P|=u,V.set(I,$);var B=s(X(I),X($),P,M,O,V);return V.delete(I),B;case j:if(C)return C.call(I)==C.call($)}return!1}return Km=R,Km}var Xm,sS;function uB(){if(sS)return Xm;sS=1;var e=Q2(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(l,c,u,f,p,h){var g=u&t,y=e(l),v=y.length,S=e(c),_=S.length;if(v!=_&&!g)return!1;for(var j=v;j--;){var x=y[j];if(!(g?x in c:s.call(c,x)))return!1}var N=h.get(l),E=h.get(c);if(N&&E)return N==c&&E==l;var C=!0;h.set(l,c),h.set(c,l);for(var R=g;++j<v;){x=y[j];var I=l[x],$=c[x];if(f)var q=g?f($,I,x,c,l,h):f(I,$,x,l,c,h);if(!(q===void 0?I===$||p(I,$,u,f,h):q)){C=!1;break}R||(R=x=="constructor")}if(C&&!R){var P=l.constructor,M=c.constructor;P!=M&&"constructor"in l&&"constructor"in c&&!(typeof P=="function"&&P instanceof P&&typeof M=="function"&&M instanceof M)&&(C=!1)}return h.delete(l),h.delete(c),C}return Xm=a,Xm}var Qm,aS;function dB(){if(aS)return Qm;aS=1;var e=_d(),t=cA(),n=cB(),s=uB(),a=mi(),l=Mt(),c=pi(),u=Xl(),f=1,p="[object Arguments]",h="[object Array]",g="[object Object]",y=Object.prototype,v=y.hasOwnProperty;function S(_,j,x,N,E,C){var R=l(_),I=l(j),$=R?h:a(_),q=I?h:a(j);$=$==p?g:$,q=q==p?g:q;var P=$==g,M=q==g,O=$==q;if(O&&c(_)){if(!c(j))return!1;R=!0,P=!1}if(O&&!P)return C||(C=new e),R||u(_)?t(_,j,x,N,E,C):n(_,j,$,x,N,E,C);if(!(x&f)){var V=P&&v.call(_,"__wrapped__"),X=M&&v.call(j,"__wrapped__");if(V||X){var A=V?_.value():_,Z=X?j.value():j;return C||(C=new e),E(A,Z,x,N,C)}}return O?(C||(C=new e),s(_,j,x,N,E,C)):!1}return Qm=S,Qm}var Zm,oS;function uA(){if(oS)return Zm;oS=1;var e=dB(),t=$r();function n(s,a,l,c,u){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,l,c,n,u)}return Zm=n,Zm}var Jm,iS;function hB(){if(iS)return Jm;iS=1;var e=_d(),t=uA(),n=1,s=2;function a(l,c,u,f){var p=u.length,h=p,g=!f;if(l==null)return!h;for(l=Object(l);p--;){var y=u[p];if(g&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<h;){y=u[p];var v=y[0],S=l[v],_=y[1];if(g&&y[2]){if(S===void 0&&!(v in l))return!1}else{var j=new e;if(f)var x=f(S,_,v,l,c,j);if(!(x===void 0?t(_,S,n|s,f,j):x))return!1}}return!0}return Jm=a,Jm}var eg,lS;function dA(){if(lS)return eg;lS=1;var e=Vn();function t(n){return n===n&&!e(n)}return eg=t,eg}var tg,cS;function fB(){if(cS)return tg;cS=1;var e=dA(),t=Xs();function n(s){for(var a=t(s),l=a.length;l--;){var c=a[l],u=s[c];a[l]=[c,u,e(u)]}return a}return tg=n,tg}var ng,uS;function hA(){if(uS)return ng;uS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return ng=e,ng}var rg,dS;function pB(){if(dS)return rg;dS=1;var e=hB(),t=fB(),n=hA();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 rg=s,rg}var sg,hS;function gi(){if(hS)return sg;hS=1;var e=Ua(),t=$r(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return sg=s,sg}var ag,fS;function Ix(){if(fS)return ag;fS=1;var e=Mt(),t=gi(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(l,c){if(e(l))return!1;var u=typeof l;return u=="number"||u=="symbol"||u=="boolean"||l==null||t(l)?!0:s.test(l)||!n.test(l)||c!=null&&l in Object(c)}return ag=a,ag}var og,pS;function mB(){if(pS)return og;pS=1;var e=bx(),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,u=a?a.apply(this,c):c[0],f=l.cache;if(f.has(u))return f.get(u);var p=s.apply(this,c);return l.cache=f.set(u,p)||f,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,og=n,og}var ig,mS;function gB(){if(mS)return ig;mS=1;var e=mB(),t=500;function n(s){var a=e(s,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return ig=n,ig}var lg,gS;function yB(){if(gS)return lg;gS=1;var e=gB(),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,u,f,p){l.push(f?p.replace(n,"$1"):u||c)}),l});return lg=s,lg}var cg,yS;function Rd(){if(yS)return cg;yS=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 cg=e,cg}var ug,wS;function wB(){if(wS)return ug;wS=1;var e=fi(),t=Rd(),n=Mt(),s=gi(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(u){if(typeof u=="string")return u;if(n(u))return t(u,c)+"";if(s(u))return l?l.call(u):"";var f=u+"";return f=="0"&&1/u==-1/0?"-0":f}return ug=c,ug}var dg,vS;function fA(){if(vS)return dg;vS=1;var e=wB();function t(n){return n==null?"":e(n)}return dg=t,dg}var hg,xS;function Md(){if(xS)return hg;xS=1;var e=Mt(),t=Ix(),n=yB(),s=fA();function a(l,c){return e(l)?l:t(l,c)?[l]:n(s(l))}return hg=a,hg}var fg,bS;function Ql(){if(bS)return fg;bS=1;var e=gi();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return fg=t,fg}var pg,kS;function Id(){if(kS)return pg;kS=1;var e=Md(),t=Ql();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 pg=n,pg}var mg,_S;function vB(){if(_S)return mg;_S=1;var e=Id();function t(n,s,a){var l=n==null?void 0:e(n,s);return l===void 0?a:l}return mg=t,mg}var gg,NS;function xB(){if(NS)return gg;NS=1;function e(t,n){return t!=null&&n in Object(t)}return gg=e,gg}var yg,SS;function pA(){if(SS)return yg;SS=1;var e=Md(),t=Kl(),n=Mt(),s=jd(),a=_x(),l=Ql();function c(u,f,p){f=e(f,u);for(var h=-1,g=f.length,y=!1;++h<g;){var v=l(f[h]);if(!(y=u!=null&&p(u,v)))break;u=u[v]}return y||++h!=g?y:(g=u==null?0:u.length,!!g&&a(g)&&s(v,g)&&(n(u)||t(u)))}return yg=c,yg}var wg,jS;function mA(){if(jS)return wg;jS=1;var e=xB(),t=pA();function n(s,a){return s!=null&&t(s,a,e)}return wg=n,wg}var vg,ES;function bB(){if(ES)return vg;ES=1;var e=uA(),t=vB(),n=mA(),s=Ix(),a=dA(),l=hA(),c=Ql(),u=1,f=2;function p(h,g){return s(h)&&a(g)?l(c(h),g):function(y){var v=t(y,h);return v===void 0&&v===g?n(y,h):e(g,v,u|f)}}return vg=p,vg}var xg,CS;function gA(){if(CS)return xg;CS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return xg=e,xg}var bg,TS;function kB(){if(TS)return bg;TS=1;var e=Id();function t(n){return function(s){return e(s,n)}}return bg=t,bg}var kg,AS;function _B(){if(AS)return kg;AS=1;var e=gA(),t=kB(),n=Ix(),s=Ql();function a(l){return n(l)?e(s(l)):t(l)}return kg=a,kg}var _g,RS;function cs(){if(RS)return _g;RS=1;var e=pB(),t=bB(),n=Ga(),s=Mt(),a=_B();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 _g=l,_g}var Ng,MS;function yA(){if(MS)return Ng;MS=1;var e=V2(),t=sB(),n=cs(),s=Mt();function a(l,c){var u=s(l)?e:t;return u(l,n(c,3))}return Ng=a,Ng}var Sg,IS;function NB(){if(IS)return Sg;IS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Sg=n,Sg}var jg,$S;function wA(){if($S)return jg;$S=1;var e=NB(),t=pA();function n(s,a){return s!=null&&t(s,a,e)}return jg=n,jg}var Eg,OS;function SB(){if(OS)return Eg;OS=1;var e=Sx(),t=mi(),n=Kl(),s=Mt(),a=ls(),l=pi(),c=Cd(),u=Xl(),f="[object Map]",p="[object Set]",h=Object.prototype,g=h.hasOwnProperty;function y(v){if(v==null)return!0;if(a(v)&&(s(v)||typeof v=="string"||typeof v.splice=="function"||l(v)||u(v)||n(v)))return!v.length;var S=t(v);if(S==f||S==p)return!v.size;if(c(v))return!e(v).length;for(var _ in v)if(g.call(v,_))return!1;return!0}return Eg=y,Eg}var Cg,PS;function vA(){if(PS)return Cg;PS=1;function e(t){return t===void 0}return Cg=e,Cg}var Tg,LS;function xA(){if(LS)return Tg;LS=1;var e=Ad(),t=ls();function n(s,a){var l=-1,c=t(s)?Array(s.length):[];return e(s,function(u,f,p){c[++l]=a(u,f,p)}),c}return Tg=n,Tg}var Ag,DS;function bA(){if(DS)return Ag;DS=1;var e=Rd(),t=cs(),n=xA(),s=Mt();function a(l,c){var u=s(l)?e:n;return u(l,t(c,3))}return Ag=a,Ag}var Rg,qS;function jB(){if(qS)return Rg;qS=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 Rg=e,Rg}var Mg,FS;function EB(){if(FS)return Mg;FS=1;function e(t,n,s,a,l){return l(t,function(c,u,f){s=a?(a=!1,c):n(s,c,u,f)}),s}return Mg=e,Mg}var Ig,BS;function kA(){if(BS)return Ig;BS=1;var e=jB(),t=Ad(),n=cs(),s=EB(),a=Mt();function l(c,u,f){var p=a(c)?e:s,h=arguments.length<3;return p(c,n(u,4),f,h,t)}return Ig=l,Ig}var $g,zS;function CB(){if(zS)return $g;zS=1;var e=Ua(),t=Mt(),n=$r(),s="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==s}return $g=a,$g}var Og,US;function TB(){if(US)return Og;US=1;var e=gA(),t=e("length");return Og=t,Og}var Pg,WS;function AB(){if(WS)return Pg;WS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="\\u200d",u=RegExp("["+c+e+a+l+"]");function f(p){return u.test(p)}return Pg=f,Pg}var Lg,HS;function RB(){if(HS)return Lg;HS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="["+e+"]",u="["+a+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+f+")",h="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",S=p+"?",_="["+l+"]?",j="(?:"+v+"(?:"+[h,g,y].join("|")+")"+_+S+")*",x=_+S+j,N="(?:"+[h+u+"?",u,g,y,c].join("|")+")",E=RegExp(f+"(?="+f+")|"+N+x,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return Lg=C,Lg}var Dg,GS;function MB(){if(GS)return Dg;GS=1;var e=TB(),t=AB(),n=RB();function s(a){return t(a)?n(a):e(a)}return Dg=s,Dg}var qg,VS;function IB(){if(VS)return qg;VS=1;var e=Sx(),t=mi(),n=ls(),s=CB(),a=MB(),l="[object Map]",c="[object Set]";function u(f){if(f==null)return 0;if(n(f))return s(f)?a(f):f.length;var p=t(f);return p==l||p==c?f.size:e(f).length}return qg=u,qg}var Fg,YS;function $B(){if(YS)return Fg;YS=1;var e=kx(),t=tA(),n=Rx(),s=cs(),a=Td(),l=Mt(),c=pi(),u=Vl(),f=Vn(),p=Xl();function h(g,y,v){var S=l(g),_=S||c(g)||p(g);if(y=s(y,4),v==null){var j=g&&g.constructor;_?v=S?new j:[]:f(g)?v=u(j)?t(a(g)):{}:v={}}return(_?e:n)(g,function(x,N,E){return y(v,x,N,E)}),v}return Fg=h,Fg}var Bg,KS;function OB(){if(KS)return Bg;KS=1;var e=fi(),t=Kl(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(s&&l&&l[s])}return Bg=a,Bg}var zg,XS;function $x(){if(XS)return zg;XS=1;var e=Ex(),t=OB();function n(s,a,l,c,u){var f=-1,p=s.length;for(l||(l=t),u||(u=[]);++f<p;){var h=s[f];a>0&&l(h)?a>1?n(h,a-1,l,c,u):e(u,h):c||(u[u.length]=h)}return u}return zg=n,zg}var Ug,QS;function PB(){if(QS)return Ug;QS=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 Ug=e,Ug}var Wg,ZS;function _A(){if(ZS)return Wg;ZS=1;var e=PB(),t=Math.max;function n(s,a,l){return a=t(a===void 0?s.length-1:a,0),function(){for(var c=arguments,u=-1,f=t(c.length-a,0),p=Array(f);++u<f;)p[u]=c[a+u];u=-1;for(var h=Array(a+1);++u<a;)h[u]=c[u];return h[a]=l(p),e(s,this,h)}}return Wg=n,Wg}var Hg,JS;function LB(){if(JS)return Hg;JS=1;var e=Tx(),t=z2(),n=Ga(),s=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return Hg=s,Hg}var Gg,ej;function DB(){if(ej)return Gg;ej=1;var e=800,t=16,n=Date.now;function s(a){var l=0,c=0;return function(){var u=n(),f=t-(u-c);if(c=u,f>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return Gg=s,Gg}var Vg,tj;function NA(){if(tj)return Vg;tj=1;var e=LB(),t=DB(),n=t(e);return Vg=n,Vg}var Yg,nj;function $d(){if(nj)return Yg;nj=1;var e=Ga(),t=_A(),n=NA();function s(a,l){return n(t(a,l,e),a+"")}return Yg=s,Yg}var Kg,rj;function SA(){if(rj)return Kg;rj=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 Kg=e,Kg}var Xg,sj;function qB(){if(sj)return Xg;sj=1;function e(t){return t!==t}return Xg=e,Xg}var Qg,aj;function FB(){if(aj)return Qg;aj=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 Qg=e,Qg}var Zg,oj;function BB(){if(oj)return Zg;oj=1;var e=SA(),t=qB(),n=FB();function s(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return Zg=s,Zg}var Jg,ij;function zB(){if(ij)return Jg;ij=1;var e=BB();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return Jg=t,Jg}var ey,lj;function UB(){if(lj)return ey;lj=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 ey=e,ey}var ty,cj;function WB(){if(cj)return ty;cj=1;function e(){}return ty=e,ty}var ny,uj;function HB(){if(uj)return ny;uj=1;var e=Z2(),t=WB(),n=Mx(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(l){return new e(l)}:t;return ny=a,ny}var ry,dj;function GB(){if(dj)return ry;dj=1;var e=iA(),t=zB(),n=UB(),s=lA(),a=HB(),l=Mx(),c=200;function u(f,p,h){var g=-1,y=t,v=f.length,S=!0,_=[],j=_;if(h)S=!1,y=n;else if(v>=c){var x=p?null:a(f);if(x)return l(x);S=!1,y=s,j=new e}else j=p?[]:_;e:for(;++g<v;){var N=f[g],E=p?p(N):N;if(N=h||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,h)||(j!==_&&j.push(E),_.push(N))}return _}return ry=u,ry}var sy,hj;function jA(){if(hj)return sy;hj=1;var e=ls(),t=$r();function n(s){return t(s)&&e(s)}return sy=n,sy}var ay,fj;function VB(){if(fj)return ay;fj=1;var e=$x(),t=$d(),n=GB(),s=jA(),a=t(function(l){return n(e(l,1,s,!0))});return ay=a,ay}var oy,pj;function YB(){if(pj)return oy;pj=1;var e=Rd();function t(n,s){return e(s,function(a){return n[a]})}return oy=t,oy}var iy,mj;function EA(){if(mj)return iy;mj=1;var e=YB(),t=Xs();function n(s){return s==null?[]:e(s,t(s))}return iy=n,iy}var ly,gj;function Yn(){if(gj)return ly;gj=1;var e;if(typeof vx=="function")try{e={clone:tB(),constant:Tx(),each:oA(),filter:yA(),has:wA(),isArray:Mt(),isEmpty:SB(),isFunction:Vl(),isUndefined:vA(),keys:Xs(),map:bA(),reduce:kA(),size:IB(),transform:$B(),union:VB(),values:EA()}}catch{}return e||(e=window._),ly=e,ly}var cy,yj;function Ox(){if(yj)return cy;yj=1;var e=Yn();cy=a;var t="\0",n="\0",s="";function a(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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(h){return this._label=h,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._in[g])})},a.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._out[g])})},a.prototype.setNodes=function(h,g){var y=arguments,v=this;return e.each(h,function(S){y.length>1?v.setNode(S,g):v.setNode(S)}),this},a.prototype.setNode=function(h,g){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=g),this):(this._nodes[h]=arguments.length>1?g:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=n,this._children[h]={},this._children[n][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},a.prototype.node=function(h){return this._nodes[h]},a.prototype.hasNode=function(h){return e.has(this._nodes,h)},a.prototype.removeNode=function(h){var g=this;if(e.has(this._nodes,h)){var y=function(v){g.removeEdge(g._edgeObjs[v])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(v){g.setParent(v)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},a.prototype.setParent=function(h,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=n;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===h)throw new Error("Setting "+g+" as parent of "+h+" would create a cycle");this.setNode(g)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=g,this._children[g][h]=!0,this},a.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},a.prototype.parent=function(h){if(this._isCompound){var g=this._parent[h];if(g!==n)return g}},a.prototype.children=function(h){if(e.isUndefined(h)&&(h=n),this._isCompound){var g=this._children[h];if(g)return e.keys(g)}else{if(h===n)return this.nodes();if(this.hasNode(h))return[]}},a.prototype.predecessors=function(h){var g=this._preds[h];if(g)return e.keys(g)},a.prototype.successors=function(h){var g=this._sucs[h];if(g)return e.keys(g)},a.prototype.neighbors=function(h){var g=this.predecessors(h);if(g)return e.union(g,this.successors(h))},a.prototype.isLeaf=function(h){var g;return this.isDirected()?g=this.successors(h):g=this.neighbors(h),g.length===0},a.prototype.filterNodes=function(h){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,j){h(j)&&g.setNode(j,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var v={};function S(_){var j=y.parent(_);return j===void 0||g.hasNode(j)?(v[_]=j,j):j in v?v[j]:S(j)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,S(_))}),g},a.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(h,g){var y=this,v=arguments;return e.reduce(h,function(S,_){return v.length>1?y.setEdge(S,_,g):y.setEdge(S,_),_}),this},a.prototype.setEdge=function(){var h,g,y,v,S=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,g=_.w,y=_.name,arguments.length===2&&(v=arguments[1],S=!0)):(h=_,g=arguments[1],y=arguments[3],arguments.length>2&&(v=arguments[2],S=!0)),h=""+h,g=""+g,e.isUndefined(y)||(y=""+y);var j=u(this._isDirected,h,g,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(h),this.setNode(g),this._edgeLabels[j]=S?v:this._defaultEdgeLabelFn(h,g,y);var x=f(this._isDirected,h,g,y);return h=x.v,g=x.w,Object.freeze(x),this._edgeObjs[j]=x,l(this._preds[g],h),l(this._sucs[h],g),this._in[g][j]=x,this._out[h][j]=x,this._edgeCount++,this},a.prototype.edge=function(h,g,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,g,y);return this._edgeLabels[v]},a.prototype.hasEdge=function(h,g,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,g,y);return e.has(this._edgeLabels,v)},a.prototype.removeEdge=function(h,g,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,g,y),S=this._edgeObjs[v];return S&&(h=S.v,g=S.w,delete this._edgeLabels[v],delete this._edgeObjs[v],c(this._preds[g],h),c(this._sucs[h],g),delete this._in[g][v],delete this._out[h][v],this._edgeCount--),this},a.prototype.inEdges=function(h,g){var y=this._in[h];if(y){var v=e.values(y);return g?e.filter(v,function(S){return S.v===g}):v}},a.prototype.outEdges=function(h,g){var y=this._out[h];if(y){var v=e.values(y);return g?e.filter(v,function(S){return S.w===g}):v}},a.prototype.nodeEdges=function(h,g){var y=this.inEdges(h,g);if(y)return y.concat(this.outEdges(h,g))};function l(h,g){h[g]?h[g]++:h[g]=1}function c(h,g){--h[g]||delete h[g]}function u(h,g,y,v){var S=""+g,_=""+y;if(!h&&S>_){var j=S;S=_,_=j}return S+s+_+s+(e.isUndefined(v)?t:v)}function f(h,g,y,v){var S=""+g,_=""+y;if(!h&&S>_){var j=S;S=_,_=j}var x={v:S,w:_};return v&&(x.name=v),x}function p(h,g){return u(h,g.v,g.w,g.name)}return cy}var uy,wj;function KB(){return wj||(wj=1,uy="2.1.8"),uy}var dy,vj;function XB(){return vj||(vj=1,dy={Graph:Ox(),version:KB()}),dy}var hy,xj;function QB(){if(xj)return hy;xj=1;var e=Yn(),t=Ox();hy={write:n,read:l};function n(c){var u={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:s(c),edges:a(c)};return e.isUndefined(c.graph())||(u.value=e.clone(c.graph())),u}function s(c){return e.map(c.nodes(),function(u){var f=c.node(u),p=c.parent(u),h={v:u};return e.isUndefined(f)||(h.value=f),e.isUndefined(p)||(h.parent=p),h})}function a(c){return e.map(c.edges(),function(u){var f=c.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(f)||(p.value=f),p})}function l(c){var u=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(f){u.setNode(f.v,f.value),f.parent&&u.setParent(f.v,f.parent)}),e.each(c.edges,function(f){u.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),u}return hy}var fy,bj;function ZB(){if(bj)return fy;bj=1;var e=Yn();fy=t;function t(n){var s={},a=[],l;function c(u){e.has(s,u)||(s[u]=!0,l.push(u),e.each(n.successors(u),c),e.each(n.predecessors(u),c))}return e.each(n.nodes(),function(u){l=[],c(u),l.length&&a.push(l)}),a}return fy}var py,kj;function CA(){if(kj)return py;kj=1;var e=Yn();py=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],u=a[s];a[n]=u,a[s]=c,l[u.key]=n,l[c.key]=s},py}var my,_j;function TA(){if(_j)return my;_j=1;var e=Yn(),t=CA();my=s;var n=e.constant(1);function s(l,c,u,f){return a(l,String(c),u||n,f||function(p){return l.outEdges(p)})}function a(l,c,u,f){var p={},h=new t,g,y,v=function(S){var _=S.v!==g?S.v:S.w,j=p[_],x=u(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=g,h.decrease(_,N))};for(l.nodes().forEach(function(S){var _=S===c?0:Number.POSITIVE_INFINITY;p[S]={distance:_},h.add(S,_)});h.size()>0&&(g=h.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)f(g).forEach(v);return p}return my}var gy,Nj;function JB(){if(Nj)return gy;Nj=1;var e=TA(),t=Yn();gy=n;function n(s,a,l){return t.transform(s.nodes(),function(c,u){c[u]=e(s,u,a,l)},{})}return gy}var yy,Sj;function AA(){if(Sj)return yy;Sj=1;var e=Yn();yy=t;function t(n){var s=0,a=[],l={},c=[];function u(f){var p=l[f]={onStack:!0,lowlink:s,index:s++};if(a.push(f),n.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(u(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var h=[],g;do g=a.pop(),l[g].onStack=!1,h.push(g);while(f!==g);c.push(h)}}return n.nodes().forEach(function(f){e.has(l,f)||u(f)}),c}return yy}var wy,jj;function ez(){if(jj)return wy;jj=1;var e=Yn(),t=AA();wy=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 wy}var vy,Ej;function tz(){if(Ej)return vy;Ej=1;var e=Yn();vy=n;var t=e.constant(1);function n(a,l,c){return s(a,l||t,c||function(u){return a.outEdges(u)})}function s(a,l,c){var u={},f=a.nodes();return f.forEach(function(p){u[p]={},u[p][p]={distance:0},f.forEach(function(h){p!==h&&(u[p][h]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(h){var g=h.v===p?h.w:h.v,y=l(h);u[p][g]={distance:y,predecessor:p}})}),f.forEach(function(p){var h=u[p];f.forEach(function(g){var y=u[g];f.forEach(function(v){var S=y[p],_=h[v],j=y[v],x=S.distance+_.distance;x<j.distance&&(j.distance=x,j.predecessor=_.predecessor)})})}),u}return vy}var xy,Cj;function RA(){if(Cj)return xy;Cj=1;var e=Yn();xy=t,t.CycleException=n;function t(s){var a={},l={},c=[];function u(f){if(e.has(l,f))throw new n;e.has(a,f)||(l[f]=!0,a[f]=!0,e.each(s.predecessors(f),u),delete l[f],c.push(f))}if(e.each(s.sinks(),u),e.size(a)!==s.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,xy}var by,Tj;function nz(){if(Tj)return by;Tj=1;var e=RA();by=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return by}var ky,Aj;function MA(){if(Aj)return ky;Aj=1;var e=Yn();ky=t;function t(s,a,l){e.isArray(a)||(a=[a]);var c=(s.isDirected()?s.successors:s.neighbors).bind(s),u=[],f={};return e.each(a,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,l==="post",f,c,u)}),u}function n(s,a,l,c,u,f){e.has(c,a)||(c[a]=!0,l||f.push(a),e.each(u(a),function(p){n(s,p,l,c,u,f)}),l&&f.push(a))}return ky}var _y,Rj;function rz(){if(Rj)return _y;Rj=1;var e=MA();_y=t;function t(n,s){return e(n,s,"post")}return _y}var Ny,Mj;function sz(){if(Mj)return Ny;Mj=1;var e=MA();Ny=t;function t(n,s){return e(n,s,"pre")}return Ny}var Sy,Ij;function az(){if(Ij)return Sy;Ij=1;var e=Yn(),t=Ox(),n=CA();Sy=s;function s(a,l){var c=new t,u={},f=new n,p;function h(y){var v=y.v===p?y.w:y.v,S=f.priority(v);if(S!==void 0){var _=l(y);_<S&&(u[v]=p,f.decrease(v,_))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),f.decrease(a.nodes()[0],0);for(var g=!1;f.size()>0;){if(p=f.removeMin(),e.has(u,p))c.setEdge(p,u[p]);else{if(g)throw new Error("Input graph is not connected: "+a);g=!0}a.nodeEdges(p).forEach(h)}return c}return Sy}var jy,$j;function oz(){return $j||($j=1,jy={components:ZB(),dijkstra:TA(),dijkstraAll:JB(),findCycles:ez(),floydWarshall:tz(),isAcyclic:nz(),postorder:rz(),preorder:sz(),prim:az(),tarjan:AA(),topsort:RA()}),jy}var Ey,Oj;function iz(){if(Oj)return Ey;Oj=1;var e=XB();return Ey={Graph:e.Graph,json:QB(),alg:oz(),version:e.version},Ey}var Cy,Pj;function mr(){if(Pj)return Cy;Pj=1;var e;if(typeof vx=="function")try{e=iz()}catch{}return e||(e=window.graphlib),Cy=e,Cy}var Ty,Lj;function lz(){if(Lj)return Ty;Lj=1;var e=rA(),t=1,n=4;function s(a){return e(a,t|n)}return Ty=s,Ty}var Ay,Dj;function Od(){if(Dj)return Ay;Dj=1;var e=hi(),t=ls(),n=jd(),s=Vn();function a(l,c,u){if(!s(u))return!1;var f=typeof c;return(f=="number"?t(u)&&n(c,u.length):f=="string"&&c in u)?e(u[c],l):!1}return Ay=a,Ay}var Ry,qj;function cz(){if(qj)return Ry;qj=1;var e=$d(),t=hi(),n=Od(),s=Ha(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(u,f){u=Object(u);var p=-1,h=f.length,g=h>2?f[2]:void 0;for(g&&n(f[0],f[1],g)&&(h=1);++p<h;)for(var y=f[p],v=s(y),S=-1,_=v.length;++S<_;){var j=v[S],x=u[j];(x===void 0||t(x,a[j])&&!l.call(u,j))&&(u[j]=y[j])}return u});return Ry=c,Ry}var My,Fj;function uz(){if(Fj)return My;Fj=1;var e=cs(),t=ls(),n=Xs();function s(a){return function(l,c,u){var f=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(g){return p(f[g],g,f)}}var h=a(l,c,u);return h>-1?f[p?l[h]:h]:void 0}}return My=s,My}var Iy,Bj;function dz(){if(Bj)return Iy;Bj=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Iy=t,Iy}var $y,zj;function hz(){if(zj)return $y;zj=1;var e=dz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return $y=n,$y}var Oy,Uj;function fz(){if(Uj)return Oy;Uj=1;var e=hz(),t=Vn(),n=gi(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;function f(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=t(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=l.test(p);return g||c.test(p)?u(p.slice(2),g?2:8):a.test(p)?s:+p}return Oy=f,Oy}var Py,Wj;function IA(){if(Wj)return Py;Wj=1;var e=fz(),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 Py=s,Py}var Ly,Hj;function pz(){if(Hj)return Ly;Hj=1;var e=IA();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return Ly=t,Ly}var Dy,Gj;function mz(){if(Gj)return Dy;Gj=1;var e=SA(),t=cs(),n=pz(),s=Math.max;function a(l,c,u){var f=l==null?0:l.length;if(!f)return-1;var p=u==null?0:n(u);return p<0&&(p=s(f+p,0)),e(l,t(c,3),p)}return Dy=a,Dy}var qy,Vj;function gz(){if(Vj)return qy;Vj=1;var e=uz(),t=mz(),n=e(t);return qy=n,qy}var Fy,Yj;function $A(){if(Yj)return Fy;Yj=1;var e=$x();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Fy=t,Fy}var By,Kj;function yz(){if(Kj)return By;Kj=1;var e=Ax(),t=sA(),n=Ha();function s(a,l){return a==null?a:e(a,t(l),n)}return By=s,By}var zy,Xj;function wz(){if(Xj)return zy;Xj=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return zy=e,zy}var Uy,Qj;function vz(){if(Qj)return Uy;Qj=1;var e=Nd(),t=Rx(),n=cs();function s(a,l){var c={};return l=n(l,3),t(a,function(u,f,p){e(c,f,l(u,f,p))}),c}return Uy=s,Uy}var Wy,Zj;function Px(){if(Zj)return Wy;Zj=1;var e=gi();function t(n,s,a){for(var l=-1,c=n.length;++l<c;){var u=n[l],f=s(u);if(f!=null&&(p===void 0?f===f&&!e(f):a(f,p)))var p=f,h=u}return h}return Wy=t,Wy}var Hy,Jj;function xz(){if(Jj)return Hy;Jj=1;function e(t,n){return t>n}return Hy=e,Hy}var Gy,eE;function bz(){if(eE)return Gy;eE=1;var e=Px(),t=xz(),n=Ga();function s(a){return a&&a.length?e(a,n,t):void 0}return Gy=s,Gy}var Vy,tE;function OA(){if(tE)return Vy;tE=1;var e=Nd(),t=hi();function n(s,a,l){(l!==void 0&&!t(s[a],l)||l===void 0&&!(a in s))&&e(s,a,l)}return Vy=n,Vy}var Yy,nE;function kz(){if(nE)return Yy;nE=1;var e=Ua(),t=Td(),n=$r(),s="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,u=l.hasOwnProperty,f=c.call(Object);function p(h){if(!n(h)||e(h)!=s)return!1;var g=t(h);if(g===null)return!0;var y=u.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==f}return Yy=p,Yy}var Ky,rE;function PA(){if(rE)return Ky;rE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Ky=e,Ky}var Xy,sE;function _z(){if(sE)return Xy;sE=1;var e=Yl(),t=Ha();function n(s){return e(s,t(s))}return Xy=n,Xy}var Qy,aE;function Nz(){if(aE)return Qy;aE=1;var e=OA(),t=H2(),n=eA(),s=G2(),a=nA(),l=Kl(),c=Mt(),u=jA(),f=pi(),p=Vl(),h=Vn(),g=kz(),y=Xl(),v=PA(),S=_z();function _(j,x,N,E,C,R,I){var $=v(j,N),q=v(x,N),P=I.get(q);if(P){e(j,N,P);return}var M=R?R($,q,N+"",j,x,I):void 0,O=M===void 0;if(O){var V=c(q),X=!V&&f(q),A=!V&&!X&&y(q);M=q,V||X||A?c($)?M=$:u($)?M=s($):X?(O=!1,M=t(q,!0)):A?(O=!1,M=n(q,!0)):M=[]:g(q)||l(q)?(M=$,l($)?M=S($):(!h($)||p($))&&(M=a(q))):O=!1}O&&(I.set(q,M),C(M,q,E,R,I),I.delete(q)),e(j,N,M)}return Qy=_,Qy}var Zy,oE;function Sz(){if(oE)return Zy;oE=1;var e=_d(),t=OA(),n=Ax(),s=Nz(),a=Vn(),l=Ha(),c=PA();function u(f,p,h,g,y){f!==p&&n(p,function(v,S){if(y||(y=new e),a(v))s(f,p,S,h,u,g,y);else{var _=g?g(c(f,S),v,S+"",f,p,y):void 0;_===void 0&&(_=v),t(f,S,_)}},l)}return Zy=u,Zy}var Jy,iE;function jz(){if(iE)return Jy;iE=1;var e=$d(),t=Od();function n(s){return e(function(a,l){var c=-1,u=l.length,f=u>1?l[u-1]:void 0,p=u>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(u--,f):void 0,p&&t(l[0],l[1],p)&&(f=u<3?void 0:f,u=1),a=Object(a);++c<u;){var h=l[c];h&&s(a,h,c,f)}return a})}return Jy=n,Jy}var ew,lE;function Ez(){if(lE)return ew;lE=1;var e=Sz(),t=jz(),n=t(function(s,a,l){e(s,a,l)});return ew=n,ew}var tw,cE;function LA(){if(cE)return tw;cE=1;function e(t,n){return t<n}return tw=e,tw}var nw,uE;function Cz(){if(uE)return nw;uE=1;var e=Px(),t=LA(),n=Ga();function s(a){return a&&a.length?e(a,n,t):void 0}return nw=s,nw}var rw,dE;function Tz(){if(dE)return rw;dE=1;var e=Px(),t=cs(),n=LA();function s(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return rw=s,rw}var sw,hE;function Az(){if(hE)return sw;hE=1;var e=yr(),t=function(){return e.Date.now()};return sw=t,sw}var aw,fE;function Rz(){if(fE)return aw;fE=1;var e=Sd(),t=Md(),n=jd(),s=Vn(),a=Ql();function l(c,u,f,p){if(!s(c))return c;u=t(u,c);for(var h=-1,g=u.length,y=g-1,v=c;v!=null&&++h<g;){var S=a(u[h]),_=f;if(S==="__proto__"||S==="constructor"||S==="prototype")return c;if(h!=y){var j=v[S];_=p?p(j,S,v):void 0,_===void 0&&(_=s(j)?j:n(u[h+1])?[]:{})}e(v,S,_),v=v[S]}return c}return aw=l,aw}var ow,pE;function Mz(){if(pE)return ow;pE=1;var e=Id(),t=Rz(),n=Md();function s(a,l,c){for(var u=-1,f=l.length,p={};++u<f;){var h=l[u],g=e(a,h);c(g,h)&&t(p,n(h,a),g)}return p}return ow=s,ow}var iw,mE;function Iz(){if(mE)return iw;mE=1;var e=Mz(),t=mA();function n(s,a){return e(s,a,function(l,c){return t(s,c)})}return iw=n,iw}var lw,gE;function $z(){if(gE)return lw;gE=1;var e=$A(),t=_A(),n=NA();function s(a){return n(t(a,void 0,e),a+"")}return lw=s,lw}var cw,yE;function Oz(){if(yE)return cw;yE=1;var e=Iz(),t=$z(),n=t(function(s,a){return s==null?{}:e(s,a)});return cw=n,cw}var uw,wE;function Pz(){if(wE)return uw;wE=1;var e=Math.ceil,t=Math.max;function n(s,a,l,c){for(var u=-1,f=t(e((a-s)/(l||1)),0),p=Array(f);f--;)p[c?f:++u]=s,s+=l;return p}return uw=n,uw}var dw,vE;function Lz(){if(vE)return dw;vE=1;var e=Pz(),t=Od(),n=IA();function s(a){return function(l,c,u){return u&&typeof u!="number"&&t(l,c,u)&&(c=u=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),u=u===void 0?l<c?1:-1:n(u),e(l,c,u,a)}}return dw=s,dw}var hw,xE;function Dz(){if(xE)return hw;xE=1;var e=Lz(),t=e();return hw=t,hw}var fw,bE;function qz(){if(bE)return fw;bE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return fw=e,fw}var pw,kE;function Fz(){if(kE)return pw;kE=1;var e=gi();function t(n,s){if(n!==s){var a=n!==void 0,l=n===null,c=n===n,u=e(n),f=s!==void 0,p=s===null,h=s===s,g=e(s);if(!p&&!g&&!u&&n>s||u&&f&&h&&!p&&!g||l&&f&&h||!a&&h||!c)return 1;if(!l&&!u&&!g&&n<s||g&&a&&c&&!l&&!u||p&&a&&c||!f&&c||!h)return-1}return 0}return pw=t,pw}var mw,_E;function Bz(){if(_E)return mw;_E=1;var e=Fz();function t(n,s,a){for(var l=-1,c=n.criteria,u=s.criteria,f=c.length,p=a.length;++l<f;){var h=e(c[l],u[l]);if(h){if(l>=p)return h;var g=a[l];return h*(g=="desc"?-1:1)}}return n.index-s.index}return mw=t,mw}var gw,NE;function zz(){if(NE)return gw;NE=1;var e=Rd(),t=Id(),n=cs(),s=xA(),a=qz(),l=Ed(),c=Bz(),u=Ga(),f=Mt();function p(h,g,y){g.length?g=e(g,function(_){return f(_)?function(j){return t(j,_.length===1?_[0]:_)}:_}):g=[u];var v=-1;g=e(g,l(n));var S=s(h,function(_,j,x){var N=e(g,function(E){return E(_)});return{criteria:N,index:++v,value:_}});return a(S,function(_,j){return c(_,j,y)})}return gw=p,gw}var yw,SE;function Uz(){if(SE)return yw;SE=1;var e=$x(),t=zz(),n=$d(),s=Od(),a=n(function(l,c){if(l==null)return[];var u=c.length;return u>1&&s(l,c[0],c[1])?c=[]:u>2&&s(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return yw=a,yw}var ww,jE;function Wz(){if(jE)return ww;jE=1;var e=fA(),t=0;function n(s){var a=++t;return e(s)+a}return ww=n,ww}var vw,EE;function Hz(){if(EE)return vw;EE=1;function e(t,n,s){for(var a=-1,l=t.length,c=n.length,u={};++a<l;){var f=a<c?n[a]:void 0;s(u,t[a],f)}return u}return vw=e,vw}var xw,CE;function Gz(){if(CE)return xw;CE=1;var e=Sd(),t=Hz();function n(s,a){return t(s||[],a||[],e)}return xw=n,xw}var bw,TE;function xt(){if(TE)return bw;TE=1;var e;if(typeof vx=="function")try{e={cloneDeep:lz(),constant:Tx(),defaults:cz(),each:oA(),filter:yA(),find:gz(),flatten:$A(),forEach:aA(),forIn:yz(),has:wA(),isUndefined:vA(),last:wz(),map:bA(),mapValues:vz(),max:bz(),merge:Ez(),min:Cz(),minBy:Tz(),now:Az(),pick:Oz(),range:Dz(),reduce:kA(),sortBy:Uz(),uniqueId:Wz(),values:EA(),zipObject:Gz()}}catch{}return e||(e=window._),bw=e,bw}var kw,AE;function Vz(){if(AE)return kw;AE=1,kw=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 kw}var _w,RE;function Yz(){if(RE)return _w;RE=1;var e=xt(),t=mr().Graph,n=Vz();_w=a;var s=e.constant(1);function a(p,h){if(p.nodeCount()<=1)return[];var g=u(p,h||s),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(v){return p.outEdges(v.v,v.w)}),!0)}function l(p,h,g){for(var y=[],v=h[h.length-1],S=h[0],_;p.nodeCount();){for(;_=S.dequeue();)c(p,h,g,_);for(;_=v.dequeue();)c(p,h,g,_);if(p.nodeCount()){for(var j=h.length-2;j>0;--j)if(_=h[j].dequeue(),_){y=y.concat(c(p,h,g,_,!0));break}}}return y}function c(p,h,g,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,f(h,g,x)}),e.forEach(p.outEdges(y.v),function(_){var j=p.edge(_),x=_.w,N=p.node(x);N.in-=j,f(h,g,N)}),p.removeNode(y.v),S}function u(p,h){var g=new t,y=0,v=0;e.forEach(p.nodes(),function(j){g.setNode(j,{v:j,in:0,out:0})}),e.forEach(p.edges(),function(j){var x=g.edge(j.v,j.w)||0,N=h(j),E=x+N;g.setEdge(j.v,j.w,E),v=Math.max(v,g.node(j.v).out+=N),y=Math.max(y,g.node(j.w).in+=N)});var S=e.range(v+y+3).map(function(){return new n}),_=y+1;return e.forEach(g.nodes(),function(j){f(S,_,g.node(j))}),{graph:g,buckets:S,zeroIdx:_}}function f(p,h,g){g.out?g.in?p[g.out-g.in+h].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return _w}var Nw,ME;function Kz(){if(ME)return Nw;ME=1;var e=xt(),t=Yz();Nw={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,u(l)):s(l);e.forEach(c,function(f){var p=l.edge(f);l.removeEdge(f),p.forwardName=f.name,p.reversed=!0,l.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function u(f){return function(p){return f.edge(p).weight}}}function s(l){var c=[],u={},f={};function p(h){e.has(f,h)||(f[h]=!0,u[h]=!0,e.forEach(l.outEdges(h),function(g){e.has(u,g.w)?c.push(g):p(g.w)}),delete u[h])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var u=l.edge(c);if(u.reversed){l.removeEdge(c);var f=u.forwardName;delete u.reversed,delete u.forwardName,l.setEdge(c.w,c.v,u,f)}})}return Nw}var Sw,IE;function wn(){if(IE)return Sw;IE=1;var e=xt(),t=mr().Graph;Sw={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:u,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:g,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 u(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 q,P;return Math.abs(R)*I>Math.abs(C)*$?(R<0&&($=-$),q=$*C/R,P=$):(C<0&&(I=-I),q=I,P=I*R/C),{x:N+q,y:E+P}}function f(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 h(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 g(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 Sw}var jw,$E;function Xz(){if($E)return jw;$E=1;var e=xt(),t=wn();jw={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){s(l,c)})}function s(l,c){var u=c.v,f=l.node(u).rank,p=c.w,h=l.node(p).rank,g=c.name,y=l.edge(c),v=y.labelRank;if(h!==f+1){l.removeEdge(c);var S,_,j;for(j=0,++f;f<h;++j,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:c,rank:f},S=t.addDummyNode(l,"edge",_,"_d"),f===v&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(u,S,{weight:y.weight},g),j===0&&l.graph().dummyChains.push(S),u=S;l.setEdge(u,p,{weight:y.weight},g)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var u=l.node(c),f=u.edgeLabel,p;for(l.setEdge(u.edgeObj,f);u.dummy;)p=l.successors(c)[0],l.removeNode(c),f.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(f.x=u.x,f.y=u.y,f.width=u.width,f.height=u.height),c=p,u=l.node(c)})}return jw}var Ew,OE;function sd(){if(OE)return Ew;OE=1;var e=xt();Ew={longestPath:t,slack:n};function t(s){var a={};function l(c){var u=s.node(c);if(e.has(a,c))return u.rank;a[c]=!0;var f=e.min(e.map(s.outEdges(c),function(p){return l(p.w)-s.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),u.rank=f}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 Ew}var Cw,PE;function DA(){if(PE)return Cw;PE=1;var e=xt(),t=mr().Graph,n=sd().slack;Cw=s;function s(u){var f=new t({directed:!1}),p=u.nodes()[0],h=u.nodeCount();f.setNode(p,{});for(var g,y;a(f,u)<h;)g=l(f,u),y=f.hasNode(g.v)?n(u,g):-n(u,g),c(f,u,y);return f}function a(u,f){function p(h){e.forEach(f.nodeEdges(h),function(g){var y=g.v,v=h===y?g.w:y;!u.hasNode(v)&&!n(f,g)&&(u.setNode(v,{}),u.setEdge(h,v,{}),p(v))})}return e.forEach(u.nodes(),p),u.nodeCount()}function l(u,f){return e.minBy(f.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(f,p)})}function c(u,f,p){e.forEach(u.nodes(),function(h){f.node(h).rank+=p})}return Cw}var Tw,LE;function Qz(){if(LE)return Tw;LE=1;var e=xt(),t=DA(),n=sd().slack,s=sd().longestPath,a=mr().alg.preorder,l=mr().alg.postorder,c=wn().simplify;Tw=u,u.initLowLimValues=g,u.initCutValues=f,u.calcCutValue=h,u.leaveEdge=v,u.enterEdge=S,u.exchangeEdges=_;function u(E){E=c(E),s(E);var C=t(E);g(C),f(C,E);for(var R,I;R=v(C);)I=S(C,E,R),_(C,E,R,I)}function f(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=h(E,C,R)}function h(E,C,R){var I=E.node(R),$=I.parent,q=!0,P=C.edge(R,$),M=0;return P||(q=!1,P=C.edge($,R)),M=P.weight,e.forEach(C.nodeEdges(R),function(O){var V=O.v===R,X=V?O.w:O.v;if(X!==$){var A=V===q,Z=C.edge(O).weight;if(M+=A?Z:-Z,x(E,R,X)){var B=E.edge(R,X).cutvalue;M+=A?-B:B}}}),M}function g(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,$){var q=R,P=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))}),P.low=q,P.lim=R++,$?P.parent=$:delete P.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 q=E.node(I),P=E.node($),M=q,O=!1;q.lim>P.lim&&(M=P,O=!0);var V=e.filter(C.edges(),function(X){return O===N(E,E.node(X.v),M)&&O!==N(E,E.node(X.w),M)});return e.minBy(V,function(X){return n(C,X)})}function _(E,C,R,I){var $=R.v,q=R.w;E.removeEdge($,q),E.setEdge(I.v,I.w,{}),g(E),f(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 q=E.node($).parent,P=C.edge($,q),M=!1;P||(P=C.edge(q,$),M=!0),C.node($).rank=C.node(q).rank+(M?P.minlen:-P.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 Tw}var Aw,DE;function Zz(){if(DE)return Aw;DE=1;var e=sd(),t=e.longestPath,n=DA(),s=Qz();Aw=a;function a(f){switch(f.graph().ranker){case"network-simplex":u(f);break;case"tight-tree":c(f);break;case"longest-path":l(f);break;default:u(f)}}var l=t;function c(f){t(f),n(f)}function u(f){s(f)}return Aw}var Rw,qE;function Jz(){if(qE)return Rw;qE=1;var e=xt();Rw=t;function t(a){var l=s(a);e.forEach(a.graph().dummyChains,function(c){for(var u=a.node(c),f=u.edgeObj,p=n(a,l,f.v,f.w),h=p.path,g=p.lca,y=0,v=h[y],S=!0;c!==f.w;){if(u=a.node(c),S){for(;(v=h[y])!==g&&a.node(v).maxRank<u.rank;)y++;v===g&&(S=!1)}if(!S){for(;y<h.length-1&&a.node(v=h[y+1]).minRank<=u.rank;)y++;v=h[y]}a.setParent(c,v),c=a.successors(c)[0]}})}function n(a,l,c,u){var f=[],p=[],h=Math.min(l[c].low,l[u].low),g=Math.max(l[c].lim,l[u].lim),y,v;y=c;do y=a.parent(y),f.push(y);while(y&&(l[y].low>h||g>l[y].lim));for(v=y,y=u;(y=a.parent(y))!==v;)p.push(y);return{path:f.concat(p.reverse()),lca:v}}function s(a){var l={},c=0;function u(f){var p=c;e.forEach(a.children(f),u),l[f]={low:p,lim:c++}}return e.forEach(a.children(),u),l}return Rw}var Mw,FE;function eU(){if(FE)return Mw;FE=1;var e=xt(),t=wn();Mw={run:n,cleanup:c};function n(u){var f=t.addDummyNode(u,"root",{},"_root"),p=a(u),h=e.max(e.values(p))-1,g=2*h+1;u.graph().nestingRoot=f,e.forEach(u.edges(),function(v){u.edge(v).minlen*=g});var y=l(u)+1;e.forEach(u.children(),function(v){s(u,f,g,y,h,p,v)}),u.graph().nodeRankFactor=g}function s(u,f,p,h,g,y,v){var S=u.children(v);if(!S.length){v!==f&&u.setEdge(f,v,{weight:0,minlen:p});return}var _=t.addBorderNode(u,"_bt"),j=t.addBorderNode(u,"_bb"),x=u.node(v);u.setParent(_,v),x.borderTop=_,u.setParent(j,v),x.borderBottom=j,e.forEach(S,function(N){s(u,f,p,h,g,y,N);var E=u.node(N),C=E.borderTop?E.borderTop:N,R=E.borderBottom?E.borderBottom:N,I=E.borderTop?h:2*h,$=C!==R?1:g-y[v]+1;u.setEdge(_,C,{weight:I,minlen:$,nestingEdge:!0}),u.setEdge(R,j,{weight:I,minlen:$,nestingEdge:!0})}),u.parent(v)||u.setEdge(f,_,{weight:0,minlen:g+y[v]})}function a(u){var f={};function p(h,g){var y=u.children(h);y&&y.length&&e.forEach(y,function(v){p(v,g+1)}),f[h]=g}return e.forEach(u.children(),function(h){p(h,1)}),f}function l(u){return e.reduce(u.edges(),function(f,p){return f+u.edge(p).weight},0)}function c(u){var f=u.graph();u.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(u.edges(),function(p){var h=u.edge(p);h.nestingEdge&&u.removeEdge(p)})}return Mw}var Iw,BE;function tU(){if(BE)return Iw;BE=1;var e=xt(),t=wn();Iw=n;function n(a){function l(c){var u=a.children(c),f=a.node(c);if(u.length&&e.forEach(u,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,h=f.maxRank+1;p<h;++p)s(a,"borderLeft","_bl",c,f,p),s(a,"borderRight","_br",c,f,p)}}e.forEach(a.children(),l)}function s(a,l,c,u,f,p){var h={width:0,height:0,rank:p,borderType:l},g=f[l][p-1],y=t.addDummyNode(a,"border",h,c);f[l][p]=y,a.setParent(y,u),g&&a.setEdge(g,y,{weight:1})}return Iw}var $w,zE;function nU(){if(zE)return $w;zE=1;var e=xt();$w={adjust:t,undo:n};function t(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&s(p)}function n(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(p),(h==="lr"||h==="rl")&&(u(p),s(p))}function s(p){e.forEach(p.nodes(),function(h){a(p.node(h))}),e.forEach(p.edges(),function(h){a(p.edge(h))})}function a(p){var h=p.width;p.width=p.height,p.height=h}function l(p){e.forEach(p.nodes(),function(h){c(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,c),e.has(g,"y")&&c(g)})}function c(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(h){f(p.node(h))}),e.forEach(p.edges(),function(h){var g=p.edge(h);e.forEach(g.points,f),e.has(g,"x")&&f(g)})}function f(p){var h=p.x;p.x=p.y,p.y=h}return $w}var Ow,UE;function rU(){if(UE)return Ow;UE=1;var e=xt();Ow=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 u(p){if(!e.has(s,p)){s[p]=!0;var h=n.node(p);c[h.rank].push(p),e.forEach(n.successors(p),u)}}var f=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(f,u),c}return Ow}var Pw,WE;function sU(){if(WE)return Pw;WE=1;var e=xt();Pw=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})),u=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),f=1;f<l.length;)f<<=1;var p=2*f-1;f-=1;var h=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(u.forEach(function(y){var v=y.pos+f;h[v]+=y.weight;for(var S=0;v>0;)v%2&&(S+=h[v+1]),v=v-1>>1,h[v]+=y.weight;g+=y.weight*S})),g}return Pw}var Lw,HE;function aU(){if(HE)return Lw;HE=1;var e=xt();Lw=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(u,f){var p=n.edge(f),h=n.node(f.v);return{sum:u.sum+p.weight*h.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return Lw}var Dw,GE;function oU(){if(GE)return Dw;GE=1;var e=xt();Dw=t;function t(a,l){var c={};e.forEach(a,function(f,p){var h=c[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(h.barycenter=f.barycenter,h.weight=f.weight)}),e.forEach(l.edges(),function(f){var p=c[f.v],h=c[f.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(c[f.w]))});var u=e.filter(c,function(f){return!f.indegree});return n(u)}function n(a){var l=[];function c(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&s(p,h)}}function u(p){return function(h){h.in.push(p),--h.indegree===0&&a.push(h)}}for(;a.length;){var f=a.pop();l.push(f),e.forEach(f.in.reverse(),c(f)),e.forEach(f.out,u(f))}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,u=0;a.weight&&(c+=a.barycenter*a.weight,u+=a.weight),l.weight&&(c+=l.barycenter*l.weight,u+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/u,a.weight=u,a.i=Math.min(l.i,a.i),l.merged=!0}return Dw}var qw,VE;function iU(){if(VE)return qw;VE=1;var e=xt(),t=wn();qw=n;function n(l,c){var u=t.partition(l,function(_){return e.has(_,"barycenter")}),f=u.lhs,p=e.sortBy(u.rhs,function(_){return-_.i}),h=[],g=0,y=0,v=0;f.sort(a(!!c)),v=s(h,p,v),e.forEach(f,function(_){v+=_.vs.length,h.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,v=s(h,p,v)});var S={vs:e.flatten(h,!0)};return y&&(S.barycenter=g/y,S.weight=y),S}function s(l,c,u){for(var f;c.length&&(f=e.last(c)).i<=u;)c.pop(),l.push(f.vs),u++;return u}function a(l){return function(c,u){return c.barycenter<u.barycenter?-1:c.barycenter>u.barycenter?1:l?u.i-c.i:c.i-u.i}}return qw}var Fw,YE;function lU(){if(YE)return Fw;YE=1;var e=xt(),t=aU(),n=oU(),s=iU();Fw=a;function a(u,f,p,h){var g=u.children(f),y=u.node(f),v=y?y.borderLeft:void 0,S=y?y.borderRight:void 0,_={};v&&(g=e.filter(g,function(R){return R!==v&&R!==S}));var j=t(u,g);e.forEach(j,function(R){if(u.children(R.v).length){var I=a(u,R.v,p,h);_[R.v]=I,e.has(I,"barycenter")&&c(R,I)}});var x=n(j,p);l(x,_);var N=s(x,h);if(v&&(N.vs=e.flatten([v,N.vs,S],!0),u.predecessors(v).length)){var E=u.node(u.predecessors(v)[0]),C=u.node(u.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(u,f){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(h){return f[h]?f[h].vs:h}),!0)})}function c(u,f){e.isUndefined(u.barycenter)?(u.barycenter=f.barycenter,u.weight=f.weight):(u.barycenter=(u.barycenter*u.weight+f.barycenter*f.weight)/(u.weight+f.weight),u.weight+=f.weight)}return Fw}var Bw,KE;function cU(){if(KE)return Bw;KE=1;var e=xt(),t=mr().Graph;Bw=n;function n(a,l,c){var u=s(a),f=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var h=a.node(p),g=a.parent(p);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(f.setNode(p),f.setParent(p,g||u),e.forEach(a[c](p),function(y){var v=y.v===p?y.w:y.v,S=f.edge(v,p),_=e.isUndefined(S)?0:S.weight;f.setEdge(v,p,{weight:a.edge(y).weight+_})}),e.has(h,"minRank")&&f.setNode(p,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),f}function s(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return Bw}var zw,XE;function uU(){if(XE)return zw;XE=1;var e=xt();zw=t;function t(n,s,a){var l={},c;e.forEach(a,function(u){for(var f=n.parent(u),p,h;f;){if(p=n.parent(f),p?(h=l[p],l[p]=f):(h=c,c=f),h&&h!==f){s.setEdge(h,f);return}f=p}})}return zw}var Uw,QE;function dU(){if(QE)return Uw;QE=1;var e=xt(),t=rU(),n=sU(),s=lU(),a=cU(),l=uU(),c=mr().Graph,u=wn();Uw=f;function f(y){var v=u.maxRank(y),S=p(y,e.range(1,v+1),"inEdges"),_=p(y,e.range(v-1,-1,-1),"outEdges"),j=t(y);g(y,j);for(var x=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){h(E%2?S:_,E%4>=2),j=u.buildLayerMatrix(y);var R=n(y,j);R<x&&(C=0,N=e.cloneDeep(j),x=R)}g(y,N)}function p(y,v,S){return e.map(v,function(_){return a(y,_,S)})}function h(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 g(y,v){e.forEach(v,function(S){e.forEach(S,function(_,j){y.node(_).order=j})})}return Uw}var Ww,ZE;function hU(){if(ZE)return Ww;ZE=1;var e=xt(),t=mr().Graph,n=wn();Ww={positionX:S,findType1Conflicts:s,findType2Conflicts:a,addConflict:c,hasConflict:u,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:v};function s(x,N){var E={};function C(R,I){var $=0,q=0,P=R.length,M=e.last(I);return e.forEach(I,function(O,V){var X=l(x,O),A=X?x.node(X).order:P;(X||O===M)&&(e.forEach(I.slice(q,V+1),function(Z){e.forEach(x.predecessors(Z),function(B){var te=x.node(B),Q=te.order;(Q<$||A<Q)&&!(te.dummy&&x.node(Z).dummy)&&c(E,B,Z)})}),q=V+1,$=A)}),I}return e.reduce(N,C),E}function a(x,N){var E={};function C(I,$,q,P,M){var O;e.forEach(e.range($,q),function(V){O=I[V],x.node(O).dummy&&e.forEach(x.predecessors(O),function(X){var A=x.node(X);A.dummy&&(A.order<P||A.order>M)&&c(E,X,O)})})}function R(I,$){var q=-1,P,M=0;return e.forEach($,function(O,V){if(x.node(O).dummy==="border"){var X=x.predecessors(O);X.length&&(P=x.node(X[0]).order,C($,M,V,q,P),M=V,q=P)}C($,M,$.length,P,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 u(x,N,E){if(N>E){var C=N;N=E,E=C}return e.has(x[N],E)}function f(x,N,E,C){var R={},I={},$={};return e.forEach(N,function(q){e.forEach(q,function(P,M){R[P]=P,I[P]=P,$[P]=M})}),e.forEach(N,function(q){var P=-1;e.forEach(q,function(M){var O=C(M);if(O.length){O=e.sortBy(O,function(B){return $[B]});for(var V=(O.length-1)/2,X=Math.floor(V),A=Math.ceil(V);X<=A;++X){var Z=O[X];I[M]===M&&P<$[Z]&&!u(E,M,Z)&&(I[Z]=M,I[M]=R[M]=R[Z],P=$[Z])}}})}),{root:R,align:I}}function p(x,N,E,C,R){var I={},$=h(x,N,E,R),q=R?"borderLeft":"borderRight";function P(V,X){for(var A=$.nodes(),Z=A.pop(),B={};Z;)B[Z]?V(Z):(B[Z]=!0,A.push(Z),A=A.concat(X(Z))),Z=A.pop()}function M(V){I[V]=$.inEdges(V).reduce(function(X,A){return Math.max(X,I[A.v]+$.edge(A))},0)}function O(V){var X=$.outEdges(V).reduce(function(Z,B){return Math.min(Z,I[B.w]-$.edge(B))},Number.POSITIVE_INFINITY),A=x.node(V);X!==Number.POSITIVE_INFINITY&&A.borderType!==q&&(I[V]=Math.max(I[V],X))}return P(M,$.predecessors.bind($)),P(O,$.successors.bind($)),e.forEach(C,function(V){I[V]=I[E[V]]}),I}function h(x,N,E,C){var R=new t,I=x.graph(),$=_(I.nodesep,I.edgesep,C);return e.forEach(N,function(q){var P;e.forEach(q,function(M){var O=E[M];if(R.setNode(O),P){var V=E[P],X=R.edge(V,O);R.setEdge(V,O,Math.max($(x,M,P),X||0))}P=M})}),R}function g(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 q=j(x,$)/2;C=Math.max(I+q,C),R=Math.min(I-q,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 q=I+$,P=x[q],M;if(P!==N){var O=e.values(P);M=$==="l"?C-e.min(O):R-e.max(O),M&&(x[q]=e.mapValues(P,function(V){return V+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(q){q==="r"&&(R=e.map(R,function(V){return e.values(V).reverse()}));var P=($==="u"?x.predecessors:x.successors).bind(x),M=f(x,R,E,P),O=p(x,R,M.root,M.align,q==="r");q==="r"&&(O=e.mapValues(O,function(V){return-V})),C[$+q]=O})});var I=g(x,C);return y(C,I),v(C,x.graph().align)}function _(x,N,E){return function(C,R,I){var $=C.node(R),q=C.node(I),P=0,M;if(P+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":M=-$.width/2;break;case"r":M=$.width/2;break}if(M&&(P+=E?M:-M),M=0,P+=($.dummy?N:x)/2,P+=(q.dummy?N:x)/2,P+=q.width/2,e.has(q,"labelpos"))switch(q.labelpos.toLowerCase()){case"l":M=q.width/2;break;case"r":M=-q.width/2;break}return M&&(P+=E?M:-M),M=0,P}}function j(x,N){return x.node(N).width}return Ww}var Hw,JE;function fU(){if(JE)return Hw;JE=1;var e=xt(),t=wn(),n=hU().positionX;Hw=s;function s(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,u){l.node(u).x=c})}function a(l){var c=t.buildLayerMatrix(l),u=l.graph().ranksep,f=0;e.forEach(c,function(p){var h=e.max(e.map(p,function(g){return l.node(g).height}));e.forEach(p,function(g){l.node(g).y=f+h/2}),f+=h+u})}return Hw}var Gw,eC;function pU(){if(eC)return Gw;eC=1;var e=xt(),t=Kz(),n=Xz(),s=Zz(),a=wn().normalizeRanks,l=Jz(),c=wn().removeEmptyRanks,u=eU(),f=tU(),p=nU(),h=dU(),g=fU(),y=wn(),v=mr().Graph;Gw=S;function S(z,U){var J=U&&U.debugTiming?y.time:y.notime;J("layout",function(){var H=J(" buildLayoutGraph",function(){return P(z)});J(" runLayout",function(){_(H,J)}),J(" updateInputGraph",function(){j(z,H)})})}function _(z,U){U(" makeSpaceForEdgeLabels",function(){M(z)}),U(" removeSelfEdges",function(){D(z)}),U(" acyclic",function(){t.run(z)}),U(" nestingGraph.run",function(){u.run(z)}),U(" rank",function(){s(y.asNonCompoundGraph(z))}),U(" injectEdgeLabelProxies",function(){O(z)}),U(" removeEmptyRanks",function(){c(z)}),U(" nestingGraph.cleanup",function(){u.cleanup(z)}),U(" normalizeRanks",function(){a(z)}),U(" assignRankMinMax",function(){V(z)}),U(" removeEdgeLabelProxies",function(){X(z)}),U(" normalize.run",function(){n.run(z)}),U(" parentDummyChains",function(){l(z)}),U(" addBorderSegments",function(){f(z)}),U(" order",function(){h(z)}),U(" insertSelfEdges",function(){K(z)}),U(" adjustCoordinateSystem",function(){p.adjust(z)}),U(" position",function(){g(z)}),U(" positionSelfEdges",function(){L(z)}),U(" removeBorderNodes",function(){Q(z)}),U(" normalize.undo",function(){n.undo(z)}),U(" fixupEdgeLabelCoords",function(){B(z)}),U(" undoCoordinateSystem",function(){p.undo(z)}),U(" translateGraph",function(){A(z)}),U(" assignNodeIntersects",function(){Z(z)}),U(" reversePoints",function(){te(z)}),U(" acyclic.undo",function(){t.undo(z)})}function j(z,U){e.forEach(z.nodes(),function(J){var H=z.node(J),oe=U.node(J);H&&(H.x=oe.x,H.y=oe.y,U.children(J).length&&(H.width=oe.width,H.height=oe.height))}),e.forEach(z.edges(),function(J){var H=z.edge(J),oe=U.edge(J);H.points=oe.points,e.has(oe,"x")&&(H.x=oe.x,H.y=oe.y)}),z.graph().width=U.graph().width,z.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"},q=["labelpos"];function P(z){var U=new v({multigraph:!0,compound:!0}),J=de(z.graph());return U.setGraph(e.merge({},N,G(J,x),e.pick(J,E))),e.forEach(z.nodes(),function(H){var oe=de(z.node(H));U.setNode(H,e.defaults(G(oe,C),R)),U.setParent(H,z.parent(H))}),e.forEach(z.edges(),function(H){var oe=de(z.edge(H));U.setEdge(H,e.merge({},$,G(oe,I),e.pick(oe,q)))}),U}function M(z){var U=z.graph();U.ranksep/=2,e.forEach(z.edges(),function(J){var H=z.edge(J);H.minlen*=2,H.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?H.width+=H.labeloffset:H.height+=H.labeloffset)})}function O(z){e.forEach(z.edges(),function(U){var J=z.edge(U);if(J.width&&J.height){var H=z.node(U.v),oe=z.node(U.w),me={rank:(oe.rank-H.rank)/2+H.rank,e:U};y.addDummyNode(z,"edge-proxy",me,"_ep")}})}function V(z){var U=0;e.forEach(z.nodes(),function(J){var H=z.node(J);H.borderTop&&(H.minRank=z.node(H.borderTop).rank,H.maxRank=z.node(H.borderBottom).rank,U=e.max(U,H.maxRank))}),z.graph().maxRank=U}function X(z){e.forEach(z.nodes(),function(U){var J=z.node(U);J.dummy==="edge-proxy"&&(z.edge(J.e).labelRank=J.rank,z.removeNode(U))})}function A(z){var U=Number.POSITIVE_INFINITY,J=0,H=Number.POSITIVE_INFINITY,oe=0,me=z.graph(),ye=me.marginx||0,Ee=me.marginy||0;function Be(ce){var Ne=ce.x,ve=ce.y,Fe=ce.width,he=ce.height;U=Math.min(U,Ne-Fe/2),J=Math.max(J,Ne+Fe/2),H=Math.min(H,ve-he/2),oe=Math.max(oe,ve+he/2)}e.forEach(z.nodes(),function(ce){Be(z.node(ce))}),e.forEach(z.edges(),function(ce){var Ne=z.edge(ce);e.has(Ne,"x")&&Be(Ne)}),U-=ye,H-=Ee,e.forEach(z.nodes(),function(ce){var Ne=z.node(ce);Ne.x-=U,Ne.y-=H}),e.forEach(z.edges(),function(ce){var Ne=z.edge(ce);e.forEach(Ne.points,function(ve){ve.x-=U,ve.y-=H}),e.has(Ne,"x")&&(Ne.x-=U),e.has(Ne,"y")&&(Ne.y-=H)}),me.width=J-U+ye,me.height=oe-H+Ee}function Z(z){e.forEach(z.edges(),function(U){var J=z.edge(U),H=z.node(U.v),oe=z.node(U.w),me,ye;J.points?(me=J.points[0],ye=J.points[J.points.length-1]):(J.points=[],me=oe,ye=H),J.points.unshift(y.intersectRect(H,me)),J.points.push(y.intersectRect(oe,ye))})}function B(z){e.forEach(z.edges(),function(U){var J=z.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 te(z){e.forEach(z.edges(),function(U){var J=z.edge(U);J.reversed&&J.points.reverse()})}function Q(z){e.forEach(z.nodes(),function(U){if(z.children(U).length){var J=z.node(U),H=z.node(J.borderTop),oe=z.node(J.borderBottom),me=z.node(e.last(J.borderLeft)),ye=z.node(e.last(J.borderRight));J.width=Math.abs(ye.x-me.x),J.height=Math.abs(oe.y-H.y),J.x=me.x+J.width/2,J.y=H.y+J.height/2}}),e.forEach(z.nodes(),function(U){z.node(U).dummy==="border"&&z.removeNode(U)})}function D(z){e.forEach(z.edges(),function(U){if(U.v===U.w){var J=z.node(U.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:U,label:z.edge(U)}),z.removeEdge(U)}})}function K(z){var U=y.buildLayerMatrix(z);e.forEach(U,function(J){var H=0;e.forEach(J,function(oe,me){var ye=z.node(oe);ye.order=me+H,e.forEach(ye.selfEdges,function(Ee){y.addDummyNode(z,"selfedge",{width:Ee.label.width,height:Ee.label.height,rank:ye.rank,order:me+ ++H,e:Ee.e,label:Ee.label},"_se")}),delete ye.selfEdges})})}function L(z){e.forEach(z.nodes(),function(U){var J=z.node(U);if(J.dummy==="selfedge"){var H=z.node(J.e.v),oe=H.x+H.width/2,me=H.y,ye=J.x-oe,Ee=H.height/2;z.setEdge(J.e,J.label),z.removeNode(U),J.label.points=[{x:oe+2*ye/3,y:me-Ee},{x:oe+5*ye/6,y:me-Ee},{x:oe+ye,y:me},{x:oe+5*ye/6,y:me+Ee},{x:oe+2*ye/3,y:me+Ee}],J.label.x=J.x,J.label.y=J.y}})}function G(z,U){return e.mapValues(e.pick(z,U),Number)}function de(z){var U={};return e.forEach(z,function(J,H){U[H.toLowerCase()]=J}),U}return Gw}var Vw,tC;function mU(){if(tC)return Vw;tC=1;var e=xt(),t=wn(),n=mr().Graph;Vw={debugOrdering:s};function s(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(u){c.setNode(u,{label:u}),c.setParent(u,"layer"+a.node(u).rank)}),e.forEach(a.edges(),function(u){c.setEdge(u.v,u.w,{},u.name)}),e.forEach(l,function(u,f){var p="layer"+f;c.setNode(p,{rank:"same"}),e.reduce(u,function(h,g){return c.setEdge(h,g,{style:"invis"}),g})}),c}return Vw}var Yw,nC;function gU(){return nC||(nC=1,Yw="0.8.5"),Yw}var Kw,rC;function yU(){return rC||(rC=1,Kw={graphlib:mr(),layout:pU(),debug:mU(),util:{time:wn().time,notime:wn().notime},version:gU()}),Kw}var wU=yU();const sC=Pv(wU),ci=240,ad=130,ei=74,Pd=72,aC=ei+Pd;function vU(e,t){var s;let n=ci;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??ci);return n}const qA=420,xU=2;function $l(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function bU(e,t){return((t==null?void 0:t.get(e))??0)>0?qA:0}function kU(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Ol(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??ci)+bU(e,n),h:Math.max((s==null?void 0:s.height)??ad,kU(e,n))}}function _U(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function NU(e,t,n,s,a,l){const c=new sC.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(x=>!a.has(x)),f=new Set(u);for(const x of u){const{w:N,h:E}=Ol(x,s,l);c.setNode(x,{width:N,height:E})}for(const x of t)f.has(x.source)&&f.has(x.target)&&c.setEdge(x.source,x.target);sC.layout(c);const p=new Map;let h=1/0,g=1/0,y=-1/0,v=-1/0;for(const x of u){const N=c.node(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ci,R=(E==null?void 0:E.height)??ad,I=Ol(x,s,l),$=N.x-I.w/2,q=N.y-I.h/2;p.set(x,{x:$,y:q}),$<h&&(h=$),q<g&&(g=q),$+C>y&&(y=$+C),q+R>v&&(v=q+R)}if(Number.isFinite(h)&&Number.isFinite(g))for(const[x,N]of p)p.set(x,{x:N.x-h,y:N.y-g});const S=Number.isFinite(y)?y-h:0,_=Number.isFinite(v)?v-g: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)??ci,R=(E==null?void 0:E.height)??ad;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 SU(e,t,n={}){const s=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,u=new Map;for(const x of e){const N=$l(x),E=u.get(N);E?E.push(x.id):u.set(N,[x.id])}const p=Array.from(u.keys()).sort().map(x=>({sid:x,...NU(u.get(x),t,s,l,a,c)})),h=vU(e,l),g=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>g&&(N.push([]),E=0),N[N.length-1].push(C),E+=C.height+aC;return N},v=x=>x.reduce((N,E)=>Math.max(N,E.width),0)+qA;let S=y(n.availableWidth?xU:1);S.length>1&&S.reduce((N,E)=>N+v(E),0)+h*(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[q,P]of C)_.set(q,{x:P.x+j,y:P.y+E});let $=E+R;I&&I.maxY>$&&I.minX<j+N&&j<I.maxX&&($=I.maxY),E=$+aC}j+=N+h}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 jU(e,t,n,s,a){const c=ei+Pd,u=60,f=v=>Ol(v,s,a),p=new Map(e.map(v=>[v.id,$l(v)])),h=[],g=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 g){const{w:_,h:j}=f(v),x=p.get(v)??"_default";if(n.has(v)){h.push({x:S.x,y:S.y,w:_,h:j,sid:x});continue}let N=S.y;for(let E=0;E<h.length+1;E++){const C=h.find(R=>{const I=R.sid===x?24:u,$=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)),h.push({x:S.x,y:N,w:_,h:j,sid:x})}return y}function EU(e,t,n,s,a,l){const c=_=>Ol(_,s,l),u=_=>n.get(_)??t.get(_),f=new Map;for(const _ of e){if(!u(_.id))continue;const j=$l(_),x=f.get(j);x?x.push(_):f.set(j,[_])}const p=new Set;for(const[_,j]of f)j.every(x=>a.has(x.id)&&!n.has(x.id))&&p.add(_);const h=new Map,g=[];for(const _ of e){const j=u(_.id);if(!j)continue;const{w:x,h:N}=c(_.id),E=$l(_);p.has(E)?(h.get(E)??h.set(E,[]).get(E)).push(_):g.push({x:j.x,y:j.y,w:x,h:N})}if(h.size===0)return[];const y=ei+Pd,v=(_,j,x,N)=>g.some(E=>_<E.x+E.w+ei&&E.x<_+x+ei&&j<E.y+E.h+y&&E.y<j+N+y),S=[];for(const _ of[...h.keys()].sort()){const j=h.get(_);let x=1/0,N=1/0,E=-1/0,C=-1/0;for(const O of j){const V=u(O.id),{w:X,h:A}=c(O.id);x=Math.min(x,V.x),N=Math.min(N,V.y),E=Math.max(E,V.x+X),C=Math.max(C,V.y+A)}const R=E-x,I=C-N,$=[...new Set(g.map(O=>Math.round(O.x)))].sort((O,V)=>O-V),q=$.length?$:[x],P=[0,...g.map(O=>O.y+O.h+y)].sort((O,V)=>O-V);let M=null;e:for(const O of q)for(const V of P){if(V>=N)break;if(!v(O,V,R,I)){M={x:O,y:V};break e}}if(M){const O=M.x-x,V=M.y-N;for(const X of j){const A=u(X.id);t.set(X.id,{x:A.x+O,y:A.y+V})}S.push(_)}for(const O of j){const V=u(O.id),{w:X,h:A}=c(O.id);g.push({x:V.x,y:V.y,w:X,h:A})}}return S}function CU(e,t,n,s,a,l=!1,c){const p=ei+Pd+1,h=8,g=1.75,y=200,v=.7,S=.01,_=M=>Ol(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 O=$l(M),V=x.get(O);V?V.push(M):x.set(O,[M])}const N=[],E=new Set,C=new Set,R=a.size===0;for(const M of[...x.keys()].sort()){const O=x.get(M);let V=1/0,X=1/0,A=-1/0,Z=-1/0,B=!1;for(const K of O){const L=j(K.id),{w:G,h:de}=_(K.id);V=Math.min(V,L.x),X=Math.min(X,L.y),A=Math.max(A,L.x+G),Z=Math.max(Z,L.y+de),n.has(K.id)&&(B=!0)}const te=A-V,Q=Z-X;C.add(M);const D=a.get(M);D&&(te>D.w+h||Q>D.h+h)&&E.add(M),a.set(M,{w:te,h:Q}),N.push({sid:M,members:O.map(K=>K.id),x:V,y:X,w:te,h:Q,anchored:B,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 O=M+1;O<N.length;O++){const V=N[M],X=N[O];if(!(V.anchored&&X.anchored)&&Math.abs(V.x+V.w/2-(X.x+X.w/2))<(V.w+X.w)/2+61&&Math.abs(V.y+V.h/2-(X.y+X.h/2))<(V.h+X.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/(ci*ad));const $=new Map(N.map(M=>[M.sid,M.x])),q=new Map(N.map(M=>[M.sid,M.y]));for(let M=0;M<y;M++){const O=new Map,V=new Map;let X=0;for(let A=0;A<N.length;A++)for(let Z=A+1;Z<N.length;Z++){const B=N[A],te=N[Z];if(B.anchored&&te.anchored)continue;const Q=B.x+B.w/2,D=B.y+B.h/2,K=te.x+te.w/2,L=te.y+te.h/2,G=(B.w+te.w)/2+61-Math.abs(Q-K),de=(B.h+te.h)/2+p-Math.abs(D-L);if(G<=0||de<=0)continue;const z=(Ve,ge)=>!Ve.anchored&&!(ge<0&&Ve.x<=0),U=(Ve,ge)=>!Ve.anchored&&!(ge<0&&Ve.y<=0),J=(Ve,ge,Se)=>{const qe=Ve===ge,Ye=qe?B.sid<te.sid?-1:1:Math.sign(Ve-ge);return Se(B,Ye)||Se(te,-Ye)?Ye:qe&&(Se(B,-Ye)||Se(te,Ye))?-Ye:0},H=J(Q,K,z),oe=J(D,L,U),me=H!==0,ye=oe!==0;if(!me&&!ye)continue;const Ee=me&&(!ye||G*g<de),[Be,ce,Ne,ve]=Ee?[H,G,O,z]:[oe,de,V,U],Fe=ve(B,Be),he=ve(te,-Be),ke=B.mass,Ke=te.mass,pe=Fe?he?Ke/(ke+Ke):1:0,dt=he?Fe?ke/(ke+Ke):1:0,ot=ce*v;Ne.set(B.sid,(Ne.get(B.sid)??0)+Be*ot*pe),Ne.set(te.sid,(Ne.get(te.sid)??0)-Be*ot*dt),X+=ot}for(const A of N)A.anchored||(A.x=Math.max(0,A.x+(O.get(A.sid)??0)),A.y=Math.max(0,A.y+(V.get(A.sid)??0)));if(X<S)break}const P=[];for(const M of N){const O=M.x-$.get(M.sid),V=M.y-q.get(M.sid);if(!(Math.abs(O)<1&&Math.abs(V)<1)){for(const X of M.members){if(n.has(X))continue;const A=t.get(X);A&&t.set(X,{x:A.x+O,y:A.y+V})}P.push(M.sid)}}return P}const TU=600;function Mv(e,t){return!(e.exitAt!=null&&t-e.exitAt>TU||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function AU(e,t){const n=new Set;for(const s of e.agents.values())Mv(s,t)&&n.add(s.id);return n}function RU(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 MU(e,t,n=0){if(!e)return!1;for(const s of t)if(RU(e,s,n))return!0;return!1}const FA="sessionGroup";function IU(e,t){var s;if(e.type===FA)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const BA=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function oC(e){const t={};for(const n of BA)t[n]=e(n);return t}function $U(e){return t=>e[t]??""}function OU(e,t){return BA.every(n=>e[n]===t[n])}function PU(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 LU=1200,DU=1e3;function iC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<LU?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<DU}function Xw({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function qU(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 FU({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,qU(a,t,e))return!1;return s}const BU="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Qw="click for what's new";function zU(e){if(e.checkDisabled)return`${BU} · ${Qw}`;if(e.checking)return`Asking npm for the newest release… · ${Qw}`;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 · ${Qw}, and to check npm now`}function UU(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 WU(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 HU(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 Iv={kind:"assumed",claude:!0,codex:!0};function GU(e){if(!e||typeof e!="object")return Iv;const t=e.providers;if(!t||typeof t!="object")return Iv;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function od(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const lC=99;function VU(e){const t=Math.max(0,Math.floor(e));return t>lC?`${lC}+`:String(t)}const YU="Pause the canvas";function KU(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 — ${od(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)":`${od(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function XU(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 zA="paused · full",QU=(e,t)=>t>0?zA:e>0?`paused · ${VU(e)}`:"paused";function ZU(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:QU(e.held,t),widest:zA,title:t>0?`Connected — the pause is full at ${od(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${od(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 cC(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const JU={agent:sL,sessionGroup:bL},UA="react-flow__node";function uC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,UA))===!0}function eW(e){try{const t=document.querySelector(`.${UA}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const tW=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),nW=420,Ru=18,rW=200,sW=5*6e4,aW=6,oW=2*6e4,dC=400,Lx="agent-dag.layout",Dx="agent-dag.viewport",WA="agent-dag.summariesDismissed",HA="agent-dag.sessionListOpen",GA="agent-dag.detailOpen",VA="agent-dag.usagePanelOpen",YA="agent-dag.systemPanelOpen",hC="agent-dag.accountsPanelOpen",Zw="agent-dag.versionNoticeDismissed",fC="agent-dag.oldNameNoticeDismissed",iW=15*6e4,Jw={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:"},Mu="agent-dag.autoRestart",pC="agent-dag.bundleReloadedFor";function lW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(HA)==="1"}catch{return!1}}function cW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(HA,e?"1":"0")}catch{}}function uW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(GA)==="1"}catch{return!1}}function dW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(GA,e?"1":"0")}catch{}}function hW(){const e=di(VA);return e===null?!0:e==="1"}function fW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(VA,e?"1":"0")}catch{}}function pW(){return di(YA)==="1"}function mW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(YA,e?"1":"0")}catch{}}function gW(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(WA);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 mC(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(WA,JSON.stringify(n))}catch{}}function yW(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Lx);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 ev(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(Lx,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function wW(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Dx);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 vW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Dx,JSON.stringify(e))}catch{}}function gC(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Lx)}catch{}try{window.localStorage.removeItem(Dx)}catch{}}}function xW(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const h of e.agents.values())h.sessionId===t&&s.push(h);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(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},l=JSON.stringify(a,null,2),c=new Blob([l],{type:"application/json"}),u=URL.createObjectURL(c),f=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=u,f.download=`${Ut}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(u),1e3)}const $v={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Ov={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},KA=n2;function bW(e,t,n,s,a,l,c,u,f,p,h,g,y,v,S,_,j,x){const N=[],E=[];for(const M of e.agents.values()){if(!j.has(M.id))continue;const O=M.exitAt!=null,V=_!=null&&!_.has(M.id),X=[O?"rf-exiting":"",V?"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:X,...A?{width:A.width,height:A.height}:null}),M.parentId&&j.has(M.parentId)){const Z=nx(M.sessionId),B=O,te=S.size>0&&(S.has(M.id)||S.has(M.parentId)),Q=_!=null&&!_.has(M.id)&&!_.has(M.parentId),D=M.state==="active"?2:1.5,K=te?D+1.5:D,L=B?.2:Q?.12:1,G=["sess-edge",M.state==="active"?"sess-live":"sess-idle",B?"rf-edge-exiting":"",te?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||te)&&!B,type:"smoothstep",style:{"--session-hue":Z,strokeWidth:K,opacity:L,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:${_U(C)}`,I=N.filter(M=>mF(M.id,a,h,g));if(I.length>0||R!==v.current){if(I.length>0){const M=SU(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:s,lanes:C});for(const O of M)P2(O.id,h,g)&&yF(O.id,O.position,h,g);EU(N,h,a,l,new Set(I.map(O=>O.id)),C)}jU(N,h,a,l,C),v.current=R}const $=CU(N,h,a,l,c,!f||p,C);$.length>0&&u($),Su(h,e.agents),Su(g,e.agents),Su(a,e.agents),Su(l,hF(e.agents.values()));const q=[];let P=!1;for(const M of N){let O=a.get(M.id)??h.get(M.id);O||(O=gF(M.id,h,g),P=!0),q.push({...M,position:O})}return P&&(v.current=""),{nodes:q,edges:E}}function kW(){return i.jsx(ex,{children:i.jsx(_W,{})})}function _W(){var Fi,xa,Gr,wo;const e=Fl(),t=Rt(),n=b.useState(yv)[0],s=b.useRef(n),[,a]=b.useState(0),l=b.useCallback(()=>a(F=>F+1),[]),[c,u]=b.useState(()=>new Set),[f,p]=b.useState(null),[h,g]=b.useState(null),y=b.useCallback((F,W)=>{u(ae=>{if(!W)return new Set([F]);const ie=new Set(ae);return ie.has(F)?ie.delete(F):ie.add(F),ie}),p(ae=>W&&ae===F?ae:F)},[]),v=b.useCallback(()=>{u(new Set),p(null)},[]),[S,_]=b.useState(null),[j,x]=b.useState(null),N=b.useCallback(F=>x(F),[]),[E,C]=b.useState(!1),[R,I]=b.useState(!1),[$,q]=b.useState(!1),P=b.useState(gW)[0],[M,O]=b.useState(lW);b.useEffect(()=>{cW(M)},[M]);const[V,X]=b.useState(uW);b.useEffect(()=>{dW(V)},[V]);const[A,Z]=b.useState(hW);b.useEffect(()=>{fW(A)},[A]);const[B,te]=b.useState(pW);b.useEffect(()=>{mW(B)},[B]);const[Q,D]=b.useState(()=>{try{const F=window.localStorage.getItem(hC);return F===null?!0:F==="1"}catch{return!0}});b.useEffect(()=>{try{window.localStorage.setItem(hC,Q?"1":"0")}catch{}},[Q]);const[K,L]=b.useState(null);b.useEffect(()=>{let F=null;try{F=localStorage.getItem("agent-dag.sound")}catch{}L(F===null?!0:F==="on")},[]);const G=b.useCallback(()=>{L(F=>{var ae;const W=F!==!0;try{localStorage.setItem("agent-dag.sound",W?"on":"off")}catch{}return W&&((ae=ve.current)==null||ae.unlock()),W})},[]),de=b.useCallback(F=>{G()},[G]),z=b.useRef(de);z.current=de;const U=b.useRef(K);U.current=K;const[J,H]=b.useState(()=>Rq(di)),oe=b.useRef(J);oe.current=J;const me=b.useRef(null),ye=b.useCallback((F,W=!1)=>{var ae,ie;if((ae=ve.current)==null||ae.unlock(),me.current!==null&&clearTimeout(me.current),me.current=null,!W){(ie=ve.current)==null||ie.play(F,!0);return}me.current=setTimeout(()=>{var Ce;me.current=null,(Ce=ve.current)==null||Ce.play(F,!0)},jq)},[]),Ee=b.useCallback((F,W)=>{H(ae=>{const ie={level:Il(W.level??ae[F].level),figure:A2(F,W.figure??ae[F].figure)};try{localStorage.setItem(R2[F],String(ie.level)),localStorage.setItem(M2[F],ie.figure)}catch{}return{...ae,[F]:ie}}),ye(F,!0)},[ye]);b.useEffect(()=>()=>{me.current!==null&&clearTimeout(me.current)},[]);const[Be,ce]=b.useState(!1),Ne=b.useRef(null),ve=b.useRef(null),[Fe,he]=b.useState("locked");b.useEffect(()=>{const F=$q({enabled:()=>U.current===!0,prefs:()=>oe.current,onState:he});ve.current=F,he(F.state());const W=()=>F.unlock();return window.addEventListener("pointerdown",W,{once:!0,capture:!0}),window.addEventListener("keydown",W,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",W,{capture:!0}),window.removeEventListener("keydown",W,{capture:!0})}},[]);const[ke,Ke]=b.useState(!1),[pe,dt]=b.useState(null),[ot,Ve]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Zw)??""}catch{return""}}),[ge,Se]=b.useState(!1),qe=b.useRef(0),[Ye,it]=b.useState(!1),Je=b.useCallback((F=!1)=>(F&&(qe.current=Date.now(),it(!0)),fetch(F?"/api/version?refresh=1":"/api/version").then(W=>W.ok?W.json():null).then(W=>{W&&dt(W)}).catch(()=>{}).finally(()=>{F&&it(!1)})),[]),re=b.useCallback(()=>{Je(Date.now()-qe.current>=iW)},[Je]);b.useEffect(()=>{Je();const F=window.setInterval(re,5*6e4),W=()=>{document.visibilityState==="visible"&&re()};return document.addEventListener("visibilitychange",W),()=>{window.clearInterval(F),document.removeEventListener("visibilitychange",W)}},[Je,re]),b.useEffect(()=>{ke&&Je()},[ke,Je]),b.useEffect(()=>{const F=Uq();let W=null;const ae=ze=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:F,looking:ze}),keepalive:!0}).catch(()=>{})},ie=()=>{const ze=Bq(document);zq(W,ze)&&ae(ze),W=ze},Ce=()=>{W&&ae(!1),W=!1};ie();const Me=window.setInterval(ie,Fq);return window.addEventListener("focus",ie),window.addEventListener("blur",ie),document.addEventListener("visibilitychange",ie),window.addEventListener("pagehide",Ce),()=>{window.clearInterval(Me),window.removeEventListener("focus",ie),window.removeEventListener("blur",ie),document.removeEventListener("visibilitychange",ie),window.removeEventListener("pagehide",Ce),Ce()}},[]);const we=(pe==null?void 0:pe.notice)??null,[Le,Te]=b.useState(null),He=b.useRef(!1);b.useEffect(()=>{if(He.current)return;const F=Zq(),W=Jq(F),ae=nF({stored:W,running:(pe==null?void 0:pe.running)??null,notes:R1,remembers:eF(F)});if(ae.reason!=="no-version"){if(He.current=!0,ae.record&&tF(F,ae.record),ae.reason==="welcome"||ae.reason==="first-run"){q(!0);return}ae.show.length&&Te({entries:ae.show,since:W,firstRun:!1})}},[pe==null?void 0:pe.running]);const mt=(pe==null?void 0:pe.running)??"3.21.1",gt=b.useMemo(()=>I2(R1,null,mt),[mt]),Ae=b.useCallback(()=>{Te({entries:gt,since:null,firstRun:!1})},[gt]),[yt,bt]=b.useState(null),[lt,Rn]=b.useState(Iv);b.useEffect(()=>{let F=!1;return fetch("/api/health").then(W=>W.ok?W.json():null).then(W=>{F||(Rn(GU(W)),!(!W||typeof W.workspace!="string")&&bt(W.workspace))}).catch(()=>{}),()=>{F=!0}},[ke]);const vn=b.useRef(lt);vn.current=lt;const rn=we?`${we.kind}:${we.to}`:"",wr=we!=null&&ot!==rn,Va=b.useCallback(()=>{Ve("");try{window.localStorage.setItem(Zw,"")}catch{}},[]),Ya=b.useCallback(()=>{if(we){Ve(rn);try{window.localStorage.setItem(Zw,rn)}catch{}}},[we,rn]),[Ka,Qs]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(fC)??""}catch{return""}}),xn=pe!=null&&pe.invokedAs&&pe.invokedAs!==Ut?pe.invokedAs:null,Or=xn!=null&&Ka!==xn,Zs=b.useCallback(()=>{if(xn){Qs(xn);try{window.localStorage.setItem(fC,xn)}catch{}}},[xn]),It=((Fi=pe==null?void 0:pe.upgrade)==null?void 0:Fi.state)??"idle",us=aq(pe==null?void 0:pe.upgrade),Kn=b.useRef(!1),ds=b.useCallback(async()=>{if(hr(Kn.current||It==="running")){Kn.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Je(),Kn.current=!1}},[It,Je]);b.useEffect(()=>{if(It!=="running")return;const F=window.setInterval(Je,3e3);return()=>window.clearInterval(F)},[It,Je]);const hs=b.useCallback(async()=>{const F=pe==null?void 0:pe.command;!F||!await T2(F)||(Se(!0),window.setTimeout(()=>Se(!1),1600))},[pe==null?void 0:pe.command]),fs=b.useCallback(()=>{O(F=>(F||D(!1),!F))},[]),Xa=b.useCallback(()=>{D(F=>(F||O(!1),!F))},[]),[Qa,ps]=b.useState(!1),[Mn,Js]=b.useState(!1),[ea,yi]=b.useState(()=>{try{return Number(localStorage.getItem(O1))||0}catch{return 0}}),[ta,Za]=b.useState([]),[Pr,na]=b.useState(!1);b.useEffect(()=>{let F=!0;const W=()=>{fetch("/api/browser-watch?live=0").then(ie=>ie.ok?ie.json():null).then(ie=>{var Ce;!F||!(ie!=null&&ie.ok)||(Za(ie.episodes??[]),na(((Ce=ie.settings)==null?void 0:Ce.enabled)===!0))}).catch(()=>{})};W();const ae=setInterval(W,5*6e4);return()=>{F=!1,clearInterval(ae)}},[]);const[Ja,ms]=b.useState([]),ht=b.useRef(new Set),[gs,ys]=b.useState(null);b.useEffect(()=>{let F=!0,W=0;const ae=()=>{fetch("/api/lan").then(ie=>ie.ok?ie.json():null).then(ie=>F?(ie!=null&&ie.ok&&ms(x1(Array.isArray(ie.pending)?ie.pending:[],ie.aliases)),ie):null).catch(()=>null).then(ie=>{F&&(W=window.setTimeout(ae,(ie==null?void 0:ie.enabled)===!0?Cv:S2))})};return ae(),()=>{F=!1,window.clearTimeout(W)}},[]);const ra=b.useCallback(async(F,W)=>{if(!gs){ys(F);try{const ie=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:F,fp:W})})).json().catch(()=>null);ie&&Array.isArray(ie.pending)?ms(x1(ie.pending,ie.aliases)):ms(Ce=>Ce.filter(Me=>Me.fp!==W))}catch{}finally{ys(null)}}},[gs]),bn=b.useMemo(()=>HF(ta,ea).length,[ta,ea]),[eo,sa]=b.useState(0),Lr=b.useRef(null),[on,ws]=b.useState(!1),Ht=b.useRef(null),[Ld,Zl]=b.useState(0),kn=b.useState(()=>kF({protect:F=>u4(s.current,F)}))[0],[Dr,to]=b.useState(!1),qr=b.useCallback(()=>{const F=kn.paused&&kn.dropped>0,W=kn.setPaused(!kn.paused);F&&d4(s.current);for(const ae of W)s.current=Ck(s.current,ae);to(kn.paused)},[kn]),[Nt,Dd]=b.useState(Date.now()),[Xn,vs]=b.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Mu)!=="0"}catch{return!0}}),wi=b.useRef(!1),vi=b.useCallback(()=>{const F=!Xn;wi.current=!0;try{window.localStorage.removeItem(Mu)}catch{}vs(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:F})}).then(W=>W.ok?W.json():null).then(W=>{var ae;W!=null&&W.ok&&vs(((ae=W.prefs)==null?void 0:ae.autoUpdate)!==!1)}).catch(()=>{})},[Xn]),[ln,no]=b.useState(!1),[xi,rt]=b.useState("restart"),[bi,ki]=b.useState(null),vr=b.useRef(!1),_i=b.useRef(null),Ni=b.useRef(0),aa=b.useCallback(async F=>{if(!hr(vr.current))return;const W=(F==null?void 0:F.upgrade)===!0;vr.current=!0,_i.current=us;const ae=++Ni.current;rt(W?"npx":"restart"),no(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(we==null?void 0:we.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:W})})}catch{}window.setTimeout(()=>{if(Ni.current===ae&&vr.current){vr.current=!1,no(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},W?18e4:3e4)},[we==null?void 0:we.to,us]),oa=b.useRef(null);b.useEffect(()=>{const F=j1(s.current.agents.values())>0,W=uq({enabled:Xn,kind:we==null?void 0:we.kind,canRestart:(pe==null?void 0:pe.canRestart)===!0,noticeOpen:wr,visible:document.visibilityState==="visible",busy:F,idleSince:oa.current,now:Nt});oa.current=W.idleSince,W.restart&&aa()},[Xn,we==null?void 0:we.kind,pe==null?void 0:pe.canRestart,wr,Nt,aa]);const ia=j1(s.current.agents.values()),Qn=cq(ia),Zn=C2({enabled:Xn,kind:we==null?void 0:we.kind,canRestart:(pe==null?void 0:pe.canRestart)===!0,noticeOpen:wr,visible:document.visibilityState==="visible",busy:ia>0,idleSince:oa.current,now:Nt});b.useEffect(()=>{const F=pe==null?void 0:pe.running;let W=null,ae=null;try{W=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(pC)}catch{return}const ie=sq({bundle:"3.21.1",running:F,pending:W,lastTried:ae});if(ie==="reload"){try{window.sessionStorage.setItem(pC,F??"")}catch{return}window.location.reload();return}if(ie!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}vr.current=!1,no(!1),ki(F??null);const Ce=window.setTimeout(()=>ki(null),6e3);return()=>window.clearTimeout(Ce)},[pe==null?void 0:pe.running]),b.useEffect(()=>{if(ln&&oq({asked:_i.current,reported:us})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}vr.current=!1,no(!1)}},[ln,us]);const Jn=b.useState(()=>PU(yW()))[0],$t=b.useRef(Jn.pinned),xr=b.useRef(null),_n=b.useState(()=>wW())[0],[Si,Jl]=b.useState(()=>new Set),[er,ec]=b.useState(NF),[tr,ro]=b.useState(()=>oC(cC)),ji=b.useMemo(()=>$U(tr),[tr]),qd=b.useCallback(F=>IU(F,ji),[ji]),la=b.useMemo(()=>({background:tr["--panel"],border:`1px solid ${tr["--line"]}`,borderRadius:8}),[tr]),[xs,bs]=b.useState(!1);b.useEffect(()=>{document.documentElement.dataset.theme=er;try{window.localStorage.setItem(L2,er)}catch{}ro(F=>{const W=oC(cC);return OU(F,W)?F:W})},[er]);const In=b.useCallback((F,W)=>{if(Xw({durationMs:W,documentHidden:document.hidden})){e.setViewport(F,{duration:W});return}const{d3Zoom:ae,d3Selection:ie}=t.getState(),Ce=ie==null?void 0:ie.property("__zoom");if(ae&&ie&&Ce&&Ce.k>0&&F.zoom>0){ae.transform(ie,Ce.scale(F.zoom/Ce.k).translate((F.x-Ce.x)/F.zoom,(F.y-Ce.y)/F.zoom));return}e.setViewport(F,{duration:0})},[e,t]),ca=b.useRef(null);b.useEffect(()=>{if(!_n)return;const F=window.setTimeout(()=>{try{In(_n,0)}catch{}cn.current=Date.now()},60);return()=>window.clearTimeout(F)},[In,_n]);const tc=b.useRef(!0);b.useEffect(()=>{const F=new EventSource("/events"),W=xF(l,{now:()=>Date.now(),setTimeout:(ae,ie)=>window.setTimeout(ae,ie),clearTimeout:ae=>window.clearTimeout(ae)});return F.addEventListener("open",()=>{Ke(!0),bs(!0)}),F.addEventListener("error",()=>Ke(!1)),F.addEventListener("replay-end",()=>{tc.current=!1,W.flush()}),F.addEventListener("hook",ae=>{var ie;try{const Ce=JSON.parse(ae.data);if(!kn.accept(Ce))return;s.current=Ck(s.current,Ce);const Me=Ce.replay===!0||tc.current||Date.now()-Ce.receivedAt>3e4;Me?W.replay():W.live();const ze=Iq(Ce,Me);ze&&((ie=ve.current)==null||ie.play(ze))}catch{}}),()=>{F.close(),W.cancel()}},[l]),b.useEffect(()=>{const F=setInterval(()=>{const W=Date.now();Dd(W);let ae=h4(s.current,W,Ek);f4(s.current,W,Ek)&&(ae=!0),l4(s.current,W,rW,sW)&&(ae=!0),c4(s.current,W,aW,oW)&&(ae=!0),u(ie=>dF(ie,s.current.agents)),p(ie=>ie!=null&&!s.current.agents.has(ie)?null:ie),x(ie=>ie!=null&&!s.current.agents.has(ie)?null:ie),_(ie=>ie!=null&&!s.current.agents.has(ie)?null:ie),ae&&l()},250);return()=>clearInterval(F)},[l]);const ua=b.useRef(null),cn=b.useRef(0),Ei=420,Nn=b.useCallback((F=500)=>{try{const Me=document.querySelector(".canvas-wrap"),ze=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Me||ze.length===0)return;const et=Me.getBoundingClientRect(),st=e.getViewport();if(!Number.isFinite(st.zoom)||st.zoom<=0)return;const at=wt=>(wt-et.left-st.x)/st.zoom,Zt=wt=>(wt-et.top-st.y)/st.zoom,vo=ze.map(wt=>wt.getBoundingClientRect()),wc=Math.min(...vo.map(wt=>at(wt.left))),ba=Math.max(...vo.map(wt=>at(wt.right))),vc=Math.min(...vo.map(wt=>Zt(wt.top))),xc=Math.max(...vo.map(wt=>Zt(wt.bottom))),Bi=ba-wc,ct=xc-vc;if(!(Bi>0&&ct>0))return;const Vr=Math.max(.2,Math.min(1,(et.width-160)/(Bi+Ei)*.86,(et.height-160)/ct*.86)),Sr={x:80-wc*Vr,y:Math.max(80,(et.height-ct*Vr)/2)-vc*Vr,zoom:Vr};In(Sr,F),cn.current=Date.now(),ca.current=Xw({durationMs:F,documentHidden:document.hidden})?{target:Sr,until:Date.now()+F+60}:null,window.setTimeout(()=>{var wt;try{((wt=ca.current)==null?void 0:wt.target)===Sr&&(ca.current=null);const zi=e.getViewport();(Math.abs(zi.zoom-Vr)>.01||Math.abs(zi.x-Sr.x)>2)&&In(Sr,0)}catch{}},F+60)}catch{}},[e,In]);b.useEffect(()=>{const F=()=>{if(!document.hidden)return;const W=ca.current;if(ca.current=null,!(!W||Date.now()>W.until)){try{In(W.target,0)}catch{}cn.current=Date.now()}};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[In]);const $n=b.useRef(""),da=b.useRef(null),ha=b.useRef(0),fa=b.useCallback(()=>{ha.current=Date.now()},[]),ks=b.useRef(null),pa=b.useRef(0),so=b.useCallback(()=>{pa.current=Date.now()},[]),Qt=b.useCallback(F=>({hasSourceEvent:!!F,at:Date.now(),lastDeckFitAt:cn.current,lastCanvasInputAt:pa.current}),[]),br="agent-dag.autoFitDisabled",ao=b.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(br)==="1"}catch{return!1}})[0],On=b.useRef(ao),[nc,oo]=b.useState(ao),ma=b.useCallback(()=>{if(!On.current){On.current=!0,oo(!0);try{window.localStorage.setItem(br,"1")}catch{}}},[]),ga=b.useCallback(()=>{On.current=!1,oo(!1);try{window.localStorage.removeItem(br)}catch{}Nn(400)},[e,Nn]);b.useEffect(()=>{const F=setInterval(()=>{if(On.current||Date.now()-ha.current<800)return;const W=s.current,ae=Date.now(),ie=[];for(const Me of W.agents.values())Mv(Me,ae)&&ie.push({id:Me.id});if(ie.length===0)return;const Ce=[];for(const{id:Me}of ie){const ze=Fr.current.get(Me),et=$t.current.get(Me)??un.current.get(Me);!ze||!et||Ce.push({x:et.x,y:et.y,width:ze.width,height:ze.height})}FU({pane:ks.current,viewport:e.getViewport(),boxes:Ce})&&Nn(600)},1500);return()=>clearInterval(F)},[e]);const _s=b.useRef(!1),Fr=b.useRef(new Map),rc=b.useRef(0),Fd=b.useCallback(F=>{const W=Fr.current;let ae=!1;for(const ie of F.nodeInternals.values()){const Ce=ie.width,Me=ie.height;if(Ce==null||Me==null)continue;const ze=W.get(ie.id);ze?(Math.abs(ze.height-Me)>4||Math.abs(ze.width-Ce)>4)&&(W.set(ie.id,{width:Ce,height:Me}),ae=!0):(W.set(ie.id,{width:Ce,height:Me}),ae=!0)}return ae&&(rc.current+=1),rc.current},[]),sc=ut(Fd),[io,Bd]=b.useState(0);b.useEffect(()=>{let F=0;const W=()=>{const ie=Fr.current;let Ce=!1;for(const Me of document.querySelectorAll(".react-flow__node[data-id]")){const ze=Me.getAttribute("data-id");if(!ze)continue;const et=Me.offsetWidth,st=Me.offsetHeight;if(!et||!st)continue;const at=ie.get(ze);(!at||Math.abs(at.width-et)>4||Math.abs(at.height-st)>4)&&(ie.set(ze,{width:et,height:st}),Ce=!0)}Ce&&Bd(Me=>Me+1)};if(_s.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(W,32):F=requestAnimationFrame(W),()=>{cancelAnimationFrame(F),window.clearTimeout(ae)}});const un=b.useRef(Jn.positions),zd=b.useRef(new Set),Ci=b.useRef(""),Ns=b.useMemo(()=>{const F=[];for(const W of s.current.agents.values())Mv(W,Nt)&&F.push(W.id+(W.parentId?`>${W.parentId}`:""));return F.sort(),`${F.join("|")}#sv${sc}.${io}`},[s.current,s.current.revision,Nt,sc,io]),Ss=b.useRef(null);b.useEffect(()=>(Ss.current!=null&&window.clearTimeout(Ss.current),Ss.current=window.setTimeout(()=>{ev(un.current,$t.current)},1500),()=>{Ss.current!=null&&window.clearTimeout(Ss.current)}),[Ns]),b.useEffect(()=>{if($n.current===Ns)return;const F=$n.current;if($n.current=Ns,!F||On.current)return;Date.now()-cn.current>1200&&Nn(400),ua.current&&window.clearTimeout(ua.current),ua.current=window.setTimeout(()=>{On.current||Nn(500)},280)},[Ns,e,Nn]);const Ti=b.useMemo(()=>pF(s.current,c),[s.current,s.current.revision,c]),Ai=b.useMemo(()=>AU(s.current,Nt),[s.current,s.current.revision,Nt]),ac=b.useRef(null),[lo,co]=b.useState({w:0,h:0});b.useEffect(()=>{const F=ac.current;if(!F||typeof ResizeObserver>"u")return;const W=new ResizeObserver(ae=>{var Ce;const ie=(Ce=ae[0])==null?void 0:Ce.contentRect;ie&&(ks.current={width:ie.width,height:ie.height},co(Me=>Math.abs(Me.w-ie.width)>40||Math.abs(Me.h-ie.height)>40?{w:ie.width,h:ie.height}:Me))});return W.observe(F),ks.current={width:F.clientWidth,height:F.clientHeight},co({w:F.clientWidth,h:F.clientHeight}),()=>W.disconnect()},[]);const Ud=b.useCallback(F=>{var ae,ie;const W=F.target;!(W!=null&&W.closest)||W.closest(tW)!==F.currentTarget||(F.preventDefault(),(ie=(ae=document.activeElement)==null?void 0:ae.blur)==null||ie.call(ae))},[]),Wd=b.useRef(new Map),[oc,ic]=b.useState(!1);b.useEffect(()=>{const F=window.setTimeout(()=>ic(!0),2500);return()=>window.clearTimeout(F)},[]);const[Hd,Ri]=b.useState(!1),kr=b.useRef(null),[Mi,lc]=b.useState(!1),Gd=b.useCallback(()=>{kr.current&&(window.clearTimeout(kr.current),kr.current=null),Ri(!1)},[]),Vd=b.useCallback(F=>{F.length!==0&&queueMicrotask(()=>{Ri(!0),kr.current&&window.clearTimeout(kr.current),kr.current=window.setTimeout(()=>Ri(!1),nW+80)})},[]);b.useEffect(()=>()=>{kr.current&&window.clearTimeout(kr.current)},[]);const uo=lo.w>0?lo.w*.92:0,js=lo.h>0?lo.h:0,{nodes:_r,edges:cc}=b.useMemo(()=>bW(s.current,Nt,uo,js,$t.current,Fr.current,Wd.current,Vd,oc,Mi,un.current,zd.current,Ns,Ci,c,Ti,Ai,N),[s.current,s.current.revision,Nt,uo,js,oc,Mi,Ns,c,Ti,Ai,N,eo]),Ii=b.useMemo(()=>{const F=new Map;for(const ae of _r){const ie=ae.data;if(!(ie!=null&&ie.sessionId)||ie.exitAt!=null)continue;const Ce=ae.width,Me=ae.height;if(Ce==null||Me==null)continue;const ze=ae.position.x,et=ae.position.y,st=ze+Ce,at=et+Me,Zt=F.get(ie.sessionId);Zt?(Zt.minX=Math.min(Zt.minX,ze),Zt.minY=Math.min(Zt.minY,et),Zt.maxX=Math.max(Zt.maxX,st),Zt.maxY=Math.max(Zt.maxY,at)):F.set(ie.sessionId,{minX:ze,minY:et,maxX:st,maxY:at})}const W=[];for(const[ae,ie]of F){const Ce=ie.maxX-ie.minX+Ru*2,Me=ie.maxY-ie.minY+Ru*2;W.push({id:`group:${ae}`,type:FA,position:{x:ie.minX-Ru,y:ie.minY-Ru},data:{sessionId:ae,w:Ce,h:Me},width:Ce,height:Me,style:{width:Ce,height:Me},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return W},[_r,Nt]),uc=b.useMemo(()=>{const F=[...Ii,..._r],W=Ht.current;return!W||W.size===0?F:F.map(ae=>{const ie=W.get(ae.id);return ie?{...ae,position:ie}:ae})},[Ii,_r,Ld]),ya=b.useMemo(()=>{const F=new Set;for(const W of s.current.agents.values())for(const ae of W.tools)F.add(KA(ae.name));return Object.keys($v).filter(W=>F.has(W))},[s.current,s.current.revision]);b.useEffect(()=>{if(ya.length<=1){ws(!1);return}let F=0;const W=()=>{const ae=Lr.current;if(ae&&!document.hidden){const ie=ae.getBoundingClientRect(),Ce=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(ze=>ze.getBoundingClientRect()),Me=MU(ie,Ce,8);ws(ze=>ze===Me?ze:Me)}F=window.setTimeout(W,300)};return W(),()=>window.clearTimeout(F)},[ya.length]);const dc=b.useCallback(F=>{Jl(W=>{const ae=new Set(W);return ae.has(F)?ae.delete(F):ae.add(F),ae})},[]),Ct=f?s.current.agents.get(f):null,$i=h?Array.from(s.current.agents.values()).flatMap(F=>F.tools).find(F=>F.id===h)??null:null,hc=b.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=yv(),$t.current.clear(),Fr.current.clear(),un.current.clear(),Ci.current="",gC(),v(),l()},[l,v]),fc=b.useRef(E);fc.current=E;const Oi=b.useRef(R);Oi.current=R;const ho=b.useRef(!1);ho.current=$i!=null||Qa||j!=null||$||S!=null||Mn||R||Le!=null;const Nr=b.useCallback(F=>{const W=dq(F,{confirmOpen:fc.current,modalOpen:ho.current});W==="confirm"?C(!0):W==="clear"&&(C(!1),hc())},[hc]),Br=b.useCallback(()=>{$t.current.clear(),un.current.clear(),Ci.current="",gC(),l(),window.setTimeout(()=>Nn(500),80)},[l,e,Nn]),pc=b.useCallback(()=>Nn(500),[Nn]),zr=b.useRef(_r);zr.current=_r;const mc=b.useRef(f);mc.current=f;const fo=b.useCallback(F=>{const W=zr.current,ae=oF(W.map(Me=>({id:Me.id,x:Me.position.x,y:Me.position.y})),mc.current,F),ie=ae?W.find(Me=>Me.id===ae):void 0;if(!ie)return;const Ce=uC(document.activeElement);y(ie.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[ie]})}catch{}cn.current=Date.now(),Ce&&eW(ie.id)},30)},[y,e]),wa=b.useCallback(F=>{y(F,!1),window.setTimeout(()=>{try{const W=zr.current.find(ae=>ae.id===F);W&&e.fitView({padding:.3,duration:500,nodes:[W]}),cn.current=Date.now()}catch{}},60)},[y,e]);b.useEffect(()=>{const F=W=>{var et,st;const ae=W.target,ie={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(et=ae==null?void 0:ae.getAttribute)==null?void 0:et.call(ae,"role"),type:ae==null?void 0:ae.type};if(W.key==="Escape"){const at=B4({overlayOpen:Zu.depth()>0,typing:ox(ie)});at==="dismiss"?Zu.dismissTop():at==="blur"?ae==null||ae.blur():(uF(ie)&&(ae==null||ae.blur()),v());return}if(ax(W))return;const Ce=uC(ae)?(st=ae==null?void 0:ae.getAttribute)==null?void 0:st.call(ae,"data-id"):null,Me=Ce&&zr.current.some(at=>at.id===Ce)?Ce:null,ze=lF(W,Me);if(ze.kind==="activate"){W.preventDefault(),y(ze.nodeId,ze.additive);return}ze.kind!=="node"&&(ze.nodeId==null&&K4(ie)||X4({key:W.key,modalOpen:ho.current,sheetOpen:Oi.current})||(W.key===" "&&(W.preventDefault(),qr()),(W.key==="c"||W.key==="C")&&Nr("shortcut"),(W.key==="r"||W.key==="R")&&Br(),(W.key==="f"||W.key==="F")&&pc(),(W.key==="l"||W.key==="L")&&fs(),(W.key==="d"||W.key==="D")&&X(at=>!at),(W.key==="h"||W.key==="H")&&ps(at=>!at),(W.key==="u"||W.key==="U")&&Z(at=>!at),(W.key==="a"||W.key==="A")&&vn.current.claude&&Xa(),(W.key==="j"||W.key==="J")&&fo(1),(W.key==="k"||W.key==="K")&&fo(-1),(W.key==="t"||W.key==="T")&&ec(at=>at==="dark"?"light":"dark"),(W.key==="m"||W.key==="M")&&vn.current.claude&&U.current!==null&&z.current(W.shiftKey),W.key==="?"&&I(at=>!at)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Nr,Br,pc,v,y,fo,qr]);const po=s.current.agents.size,Gt=b.useMemo(()=>I4(s.current.agents.values()),[s.current,s.current.revision]),Pi=b.useMemo(()=>$4(s.current.agents.values()),[s.current,s.current.revision]),Li=b.useRef(null);b.useEffect(()=>{const F=SF({waiting:Gt.length,running:Pi,connected:ke}),W=Li.current;if(Li.current=F,(W==null?void 0:W.title)!==F.title&&(document.title=F.title),(W==null?void 0:W.icon)!==F.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=jF[F.icon])}},[Gt.length,Pi,ke]);const[Yd,Kd]=b.useState(""),gc=CF(Gt);b.useEffect(()=>{Kd(F=>TF(F,gc))},[gc]);const[mo,Xd]=b.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Ot,Ur]=b.useState(null),[va,go]=b.useState(!0),[yc,Di]=b.useState(!1);b.useEffect(()=>{let F=!0;return fetch("/api/prefs").then(W=>W.ok?W.json():null).then(W=>{var ae,ie,Ce;if(!(!F||!(W!=null&&W.ok))){if(!wi.current){let Me=!1;try{Me=window.localStorage.getItem(Mu)==="0",window.localStorage.removeItem(Mu)}catch{}Me&&((ae=W.prefs)==null?void 0:ae.autoUpdate)!==!1?(vs(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):vs(((ie=W.prefs)==null?void 0:ie.autoUpdate)!==!1)}go(((Ce=W.prefs)==null?void 0:Ce.notifications)!==!1),Di(W.notificationsVetoed===!0)}}).catch(()=>{}),()=>{F=!1}},[]);const yo=b.useRef(()=>{}),Qd=b.useCallback(()=>{const F=!va;go(F),F&&typeof Notification<"u"&&Notification.permission==="default"&&yo.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:F})}).then(W=>W.ok?W.json():null).then(W=>{var ae;W!=null&&W.ok&&(go(((ae=W.prefs)==null?void 0:ae.notifications)!==!1),Di(W.notificationsVetoed===!0))}).catch(()=>{})},[va]),Zd=typeof Notification<"u";b.useEffect(()=>{if(!Ot)return;const W=setTimeout(()=>Ur(null),Ot==="blocked"?8e3:4e3);return()=>clearTimeout(W)},[Ot]);const Wr=b.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(F=>{const W=F;Xd(W),W==="granted"?Ur("on"):W==="denied"&&Ur("blocked")})},[]);yo.current=Wr;const Es=b.useRef(new Set),Hr=b.useRef(null),qi=Gt.map(F=>md(F.id,F.waiting)).join("|");return b.useEffect(()=>{D4(Hr.current,mo)&&(Hr.current=mo,Es.current=Rk(Gt))},[mo]),b.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||Hr.current===null)return;const F=typeof document>"u"||!document.hidden,W=P4(Gt,Es.current,F,va);for(const ae of W)try{const ie=new Notification(ae.title,{body:ae.body,tag:ae.key});ie.onclick=()=>{window.focus(),wa(ae.sessionId),ie.close()}}catch{}Es.current=F?Rk(Gt):L4(Gt,W,Es.current)},[qi]),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:Ut}),we?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{Ae(),Va()},"aria-haspopup":"dialog","aria-label":WU({...we,open:wr}),title:we.kind==="restart"?`Running v${we.from}; v${we.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${we.from}; v${we.to} is on npm · click for what's new`,children:["v",we.from,i.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const F={running:mt,latest:pe==null?void 0:pe.latest,latestPending:pe==null?void 0:pe.latestPending,checkedAgo:pe!=null&&pe.checkedAt?_v(Nt-pe.checkedAt):null,checkDisabled:pe==null?void 0:pe.checkDisabled,checking:Ye};return i.jsxs("button",{type:"button",className:Ye?"v checking":"v",onClick:()=>{Ae(),Je(!0)},"aria-busy":Ye||void 0,"aria-haspopup":"dialog","aria-label":UU(F),title:zU(F),children:["v",F.running]})})()]}),i.jsx("span",{className:"status",children:(()=>{const F=ZU({connected:ke,paused:Dr,held:kn.size,dropped:kn.dropped});return F.resting?null:i.jsx("span",{className:`pill ${F.tone}`,title:F.title,children:i.jsxs("span",{className:"pill-box",children:[i.jsx("span",{className:"pill-widest","aria-hidden":!0,children:F.widest}),i.jsx("span",{className:"pill-label",children:F.label})]})})})()}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Yd}),Gt.length>0&&i.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>wa(Gt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
|
|
260
260
|
${Gt.map(F=>` ${F.label}: ${Rl(F.waiting)} (${_v(Nt-F.waiting.since)})`).join(`
|
|
261
261
|
`)}`,"aria-label":`${Gt.length} session${Gt.length===1?"":"s"} waiting for you`,children:[i.jsx("span",{className:"ap-pulse","aria-hidden":!0}),i.jsx("b",{children:Gt.length})," waiting"]}),Ot&&i.jsx("span",{className:Ot==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:Ot==="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:Ot==="on"?"notifications on":"notifications blocked"})]}),Ct&&(()=>{const F=Tn(Ct),W=Math.max(0,((Ct.endedAt??Nt)-Ct.startedAt)/1e3),ae=Ct.state==="active"?sx(F.total,W):null,ie=c.size-1;return i.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Ct.label}`,onClick:()=>{try{const Ce=_r.find(Me=>Me.id===Ct.id);Ce&&e.fitView({padding:.35,duration:500,nodes:[Ce]}),cn.current=Date.now()}catch{}},children:[i.jsx("span",{className:`state-pill state-${Ct.state}`,children:Ct.state==="active"?"live":Ct.state}),i.jsx("span",{className:"selected-label",children:Ct.label}),F.total>0&&i.jsxs("span",{className:"selected-cost",children:[Ze(F.total),ae?i.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):null]}),ie>0&&i.jsxs("span",{className:"selected-extra",children:["+",ie]}),i.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:Ce=>{Ce.stopPropagation(),v()},children:"×"})]})})(),i.jsxs("div",{className:"actions",children:[i.jsxs("div",{className:"action-run",children:[i.jsx("button",{className:"btn icon-btn",onClick:fs,title:`${M?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":M,"aria-controls":M?"session-list":void 0,children:"☰"}),i.jsx("button",{className:"btn icon-btn",onClick:()=>Z(F=>!F),title:`${A?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":A,"aria-controls":A?"usage-panel":void 0,children:"$"}),lt.claude&&i.jsx("button",{className:"btn icon-btn",onClick:Xa,title:`${Q?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":Q,"aria-controls":Q?"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:()=>te(F=>!F),title:`${B?"Hide":"Show"} this machine — cores, memory, temperature`,"aria-label":"Toggle machine detail","aria-expanded":B,"aria-controls":B?"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:()=>ps(F=>!F),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${bn>0?" has-findings":Pr?" watching":""}`,onClick:()=>Js(F=>!F),title:Pr?"Browser watch — watching; the deck is keeping its own copy":"Browser watch — not watching; reading the browser's history live","aria-label":`Browser watch, ${Pr?"watching":"not watching"}`+(bn>0?`, ${bn} 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"}),Pr||bn>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"})]}),bn>0&&i.jsx("span",{className:"bw-badge","aria-hidden":!0,children:bn})]})]}),i.jsxs("div",{className:"action-run",children:[lt.claude&&K!==null&&i.jsxs("div",{className:"sound-slot",children:[i.jsx("button",{ref:Ne,className:"btn icon-btn",onClick:()=>ce(F=>!F),...dr(!1),title:PF(lt,{on:K===!0,locked:Fe==="locked",prefs:J}),"aria-label":"Sound settings","aria-haspopup":"dialog","aria-expanded":Be,"aria-controls":Be?"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"}),K?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"})]})]})}),Be&&i.jsx(qq,{onClose:()=>ce(!1),soundOn:K===!0,onToggleSound:G,prefs:J,onLevel:(F,W)=>Ee(F,{level:W}),onFigure:(F,W)=>Ee(F,{figure:W}),onPreview:F=>ye(F),notifyOn:va,onToggleNotify:Qd,notifyVetoed:yc,notifyPermission:Zd?mo:"unsupported",onAskNotify:Wr,openerRef:Ne})]}),i.jsx("button",{className:"btn icon-btn",onClick:()=>ec(F=>F==="dark"?"light":"dark"),title:`Switch to ${er==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:er==="dark"?"☀":"☾"})]})]})]}),bi?i.jsxs("div",{className:"ver-banner done",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:["Restarted — now running v",bi,"."]}),i.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):xs&&!ke?i.jsxs("div",{className:"conn-banner",role:"alert",children:[i.jsx("span",{className:"conn-dot"}),ln?xi==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Ut}…`:(()=>{const F=XU({connected:ke,paused:Dr});return i.jsxs(i.Fragment,{children:[`Lost connection to the ${Ut} server. Reconnecting…`,F&&i.jsx("span",{className:"conn-sub",children:F})]})})()]}):wr&&we?i.jsxs("div",{className:`ver-banner ${we.kind}`,role:"status",children:[i.jsx("span",{className:`ver-dot${Zn==null?"":" armed"}`}),we.kind==="restart"?i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:["v",we.to," is installed — this deck still runs v",we.from,"."]}),pe!=null&&pe.canRestart?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"ver-act",onClick:()=>aa(),...dr(ln),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
|
|
262
262
|
|
package/dist/web/index.html
CHANGED
|
@@ -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-
|
|
43
|
+
<script type="module" crossorigin src="/assets/index-ByXJWM3T.js"></script>
|
|
44
44
|
<link rel="stylesheet" crossorigin href="/assets/index-BYMVIG6f.css">
|
|
45
45
|
</head>
|
|
46
46
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-dag",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.1",
|
|
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": {
|
package/src/server/index.mjs
CHANGED
|
@@ -3138,10 +3138,14 @@ function redactDeckToken(raw) {
|
|
|
3138
3138
|
* same freshness every other cross-deck setting has.
|
|
3139
3139
|
*/
|
|
3140
3140
|
let _prefs = { ...PREF_DEFAULTS };
|
|
3141
|
-
//
|
|
3142
|
-
//
|
|
3143
|
-
//
|
|
3144
|
-
|
|
3141
|
+
// Read at import, so `consider` has its answer from the first event. LAN sync
|
|
3142
|
+
// used to start from this same read, and it must not: bin/deck.js imports this
|
|
3143
|
+
// module to ASK whether a deck is already up, and a launcher that then attaches
|
|
3144
|
+
// and exits had already bound the beacon and the sync port on the way in —
|
|
3145
|
+
// which is the `lan sync (listen): EADDRINUSE` line a second `ccdeck` printed
|
|
3146
|
+
// above `deck already running`. The engine starts from the listen that
|
|
3147
|
+
// succeeds, in startServer, which is the only process that may hold a port.
|
|
3148
|
+
const _prefsRead = readPrefs().then(p => { _prefs = p; }).catch(() => {});
|
|
3145
3149
|
|
|
3146
3150
|
const blockNotifier = createBlockNotifier({
|
|
3147
3151
|
notify: osNotify,
|
|
@@ -5993,6 +5997,10 @@ export async function startServer({ port = 4317, host = "127.0.0.1", persist = n
|
|
|
5993
5997
|
if (codex) startCodexWatcher(workspace);
|
|
5994
5998
|
// Both timers are unref'd, so this never holds the process open.
|
|
5995
5999
|
startSystemMetrics();
|
|
6000
|
+
// LAN sync, from the prefs the import read — and only from here, so a
|
|
6001
|
+
// deck that had it on comes back with it on, and a launcher that only
|
|
6002
|
+
// asked the registry never binds a port it is about to walk away from.
|
|
6003
|
+
_prefsRead.then(() => applyLanPrefs()).catch(() => {});
|
|
5996
6004
|
// Auto-switch resumes only if the user previously turned it on; the
|
|
5997
6005
|
// module reads its own persisted flag and does nothing otherwise.
|
|
5998
6006
|
cswapAutoModule().then(m => m.initCswapAuto()).catch(() => {});
|