agent-dag 3.8.3 → 3.8.5

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.
@@ -75,7 +75,11 @@ Press H for the totals ccusage reads off the logs on disk, which do not forget.`
75
75
  last 5h: ${Rt(f.window5h.totalTokens)} tokens · ${f.window5h.sessionCount} session${f.window5h.sessionCount!==1?"s":""}`:""}`,children:[Rt(f.window7d.totalTokens)," tokens · ",f.window7d.sessionCount," session",f.window7d.sessionCount!==1?"s":""," (7d)"]})]}),M&&d.jsx("div",{className:"uh-range up-period",role:"group","aria-label":"Period",children:NT.map(re=>d.jsx("button",{type:"button","aria-pressed":E===re.key,className:"uh-range-btn",onClick:()=>C(re.key),children:re.label},re.key))}),$>0?d.jsxs(d.Fragment,{children:[J&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`up-total${H}`,title:M?void 0:_1,children:[d.jsx("span",{className:"up-total-value",children:Je(V)}),d.jsx("span",{className:"up-total-label",children:M?Q:pq})]}),U.showCostBar&&d.jsx(Ow,{cost:N})]}),d.jsxs("div",{className:`up-tokens-row${H}`,title:M?void 0:_1,children:[d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"in"}),Rt(Z)]}),d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"out"}),Rt(D)]}),U.cacheReadTokens>0&&d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"cache r"}),Rt(L)]}),U.cacheCreateTokens>0&&d.jsxs("span",{className:"up-tok",children:[d.jsx("span",{className:"up-k",children:"cache c"}),Rt(K)]}),!J&&d.jsx("span",{className:"up-tok up-scope",children:mq})]}),(M?G.length:se.length)>0&&d.jsxs("section",{className:`up-section${H}`,children:[d.jsx("h3",{className:"up-section-title",children:"By model"}),d.jsxs("table",{className:"up-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Model"}),d.jsx("th",{children:"Tokens"}),d.jsx("th",{children:"Cost"})]})}),d.jsx("tbody",{children:M?G.map(re=>d.jsxs("tr",{children:[d.jsx("td",{className:"up-model-name",title:re.model,children:Ls(re.model)}),d.jsx("td",{className:"up-num",children:Rt(re.tokens)}),re.cost>0?d.jsx("td",{className:"up-num up-cost-val",children:Je(re.cost)}):d.jsx("td",{className:"up-num up-unpriced",children:Ai})]},re.model)):se.map(re=>d.jsxs("tr",{children:[d.jsx("td",{className:"up-model-name",title:re.model===rh?"no model reported yet":re.model,children:re.model===rh?"unknown":Ls(re.model)}),d.jsx("td",{className:"up-num",children:Rt(re.inputTokens+re.outputTokens)}),re.priced?d.jsx("td",{className:"up-num up-cost-val",children:Je(re.cost.total)}):d.jsx("td",{className:"up-num up-unpriced",children:Ai})]},re.model))})]})]}),M&&Y.length===0&&R.tokens>0&&d.jsxs("section",{className:"up-section",children:[d.jsx("h3",{className:"up-section-title",children:"By session"}),d.jsxs("div",{className:"up-hint",children:["No session is dated ",Q," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(M?Y.length:he.length)>0&&d.jsxs("section",{className:`up-section${H}`,children:[d.jsxs("h3",{className:"up-section-title",children:["By session",M&&d.jsxs("span",{className:"up-section-age",title:`Sessions with activity ${Q}, each showing what that session has cost since it started.
76
76
  A session that began earlier brings its whole total with it, so these rows can add up to more than the figure above.`,children:["active ",Q]})]}),d.jsxs("div",{className:"up-sessions",children:[M&&Y.map(re=>{const pe=q.get(re.sessionId);return d.jsxs("div",{className:"up-session-row",children:[pe?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`sl-dot state-${pe}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:Au(pe)})]}):d.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),d.jsx("span",{className:`up-session-label${re.label?"":" up-session-id"}`,title:re.label?`${re.label}
77
77
  ${re.sessionId}`:re.sessionId,children:re.label??re.sessionId.slice(0,8)}),d.jsx("span",{className:"up-session-tokens",children:Rt(re.tokens)}),re.cost>0?d.jsx("span",{className:"up-session-cost",title:re.models.join(", ")||void 0,children:Je(re.cost)}):d.jsx("span",{className:"up-session-cost up-unpriced",children:Ai})]},re.sessionId)}),!M&&he.map(re=>d.jsxs("div",{className:"up-session-row",children:[d.jsx("span",{className:`sl-dot state-${re.state}`,"aria-hidden":!0}),d.jsx("span",{className:"vis-hidden",children:Au(re.state)}),d.jsx("span",{className:"up-session-label",children:re.label}),d.jsx("span",{className:"up-session-tokens",children:Rt(re.inputTokens+re.outputTokens)}),re.cost>0?d.jsxs("span",{className:"up-session-cost",title:re.unpricedTokens>0?`${Rt(re.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[Je(re.cost),re.unpricedTokens>0?"+":""]}):d.jsx("span",{className:"up-session-cost up-unpriced",children:Ai})]},re.sessionId))]})]}),me&&d.jsxs("div",{className:"up-hint",children:["“",Ai,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):d.jsx("div",{className:"up-empty",children:M?d.jsxs(d.Fragment,{children:["No usage ",Q,".",d.jsx("br",{}),"Try a longer period."]}):d.jsxs(d.Fragment,{children:["No usage data yet.",d.jsx("br",{}),"Start a Claude Code or Codex session."]})})]})}const Wq="1",T1="agent-dag.schema",Hq=["agent-dag.layout","agent-dag.viewport"];function Hu(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Gq(e,t=Wq){let n=null;try{n=e.getItem(T1)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const i of Hq)try{e.getItem(i)!==null&&(e.removeItem(i),s.push(i))}catch{}try{e.setItem(T1,t)}catch{}return s}const yt={l:30,r:6,t:6,b:2},Gu=104,Vq=64;function yo(e,t=100,n=Gu){const s=n-yt.t-yt.b;return yt.t+s*(1-Math.max(0,Math.min(t,e))/t)}function Yq(e,t,n,s=100,i=Gu){if(!e.length)return"";const a=e[e.length-1].t-e[0].t,l=p=>{const f=t-yt.l-yt.r;return yt.l+(a>0?f*(p-e[0].t)/a:f/2)};let u="",h=null;for(const p of e){const f=h&&p.t-h.t<=n*2?"L":"M";u+=`${f}${l(p.t).toFixed(1)} ${yo(p.v,s,i).toFixed(1)}`,h=p}return u}function Kq(e,t,n,s=100,i=Gu){if(e.length<2)return"";const a=i-yt.b,l=e[e.length-1].t-e[0].t,u=t-yt.l-yt.r,h=v=>yt.l+(l>0?u*(v-e[0].t)/l:u/2);let p="",f=[];const g=()=>{if(f.length>=2){let v=`M${h(f[0].t).toFixed(1)} ${a}`;for(const w of f)v+=`L${h(w.t).toFixed(1)} ${yo(w.v,s,i).toFixed(1)}`;p+=`${v}L${h(f[f.length-1].t).toFixed(1)} ${a}Z`}f=[]};for(const v of e)f.length&&v.t-f[f.length-1].t>n*2&&g(),f.push(v);return g(),p}function Xq(e){return e.length?{now:e[e.length-1].v,peak:e.reduce((t,n)=>Math.max(t,n.v),e[0].v)}:{now:null,peak:null}}function Qq(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function Zq(e,t,n=s=>cl(s)){const s=e.filter(l=>l.v>0);if(!e.length)return null;if(!s.length)return"never held back";const i=s.length*(t/6e4),a=s[s.length-1];return`held back for ${i===1?"1 minute":`${i} minutes`}, last at ${n(a.t)}`}function cl(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function IT(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<1)return"less than a minute";if(n<60)return`${n} minute${n===1?"":"s"}`;const s=Math.floor(n/60),i=n%60;return i?`${s}h ${i}m`:`${s}h`}function Jq({group:e,title:t,onClose:n}){const s=_n(n),[i,a]=S.useState(null);S.useEffect(()=>{let p=!0;const f=async()=>{try{const v=await fetch(`/api/system/history?group=${e}`);if(!v.ok)return;const w=await v.json();p&&(w!=null&&w.ok)&&a(w)}catch{}};f();const g=window.setInterval(f,2e4);return()=>{p=!1,window.clearInterval(g)}},[e]);const l=(i==null?void 0:i.series)??[],[u,h]=S.useMemo(()=>{let p=1/0,f=0;for(const g of l)g.points.length&&(p=Math.min(p,g.points[0].t),f=Math.max(f,g.points[g.points.length-1].t));return[Number.isFinite(p)?Math.max(p,(i==null?void 0:i.sinceMs)??0):(i==null?void 0:i.sinceMs)??0,f]},[l,i==null?void 0:i.sinceMs]);return mw.createPortal(d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:s,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),i&&u>0&&d.jsxs("span",{className:"hist-since",children:["since ",cl(u)," · ",IT(u,h||Date.now())]}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsx("div",{className:"hist-body",children:i==null?d.jsx("p",{className:"hist-empty",children:"Reading…"}):l.length===0?d.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):l.map(p=>d.jsx(e4,{series:p,stepMs:i.stepMs},p.label))})]})}),document.body)}function e4({series:e,stepMs:t}){const n=S.useRef(null),[s,i]=S.useState(560),[a,l]=S.useState(null);S.useEffect(()=>{const P=n.current;if(!P||typeof ResizeObserver>"u")return;const z=new ResizeObserver(([M])=>i(Math.max(160,M.contentRect.width)));return z.observe(P),()=>z.disconnect()},[]);const{points:u,unit:h,warnAt:p,critAt:f,label:g,top:v,restsAtZero:w}=e,N=w?Vq:Gu,{now:b,peak:k}=Xq(u),_=h==="C"?"°C":h,E=g==="Throttling"?Zq(u,t):null,C=a!=null?u[a]:null,j=u.length>1?u[u.length-1].t-u[0].t:0,I=P=>{const z=s-yt.l-yt.r;return yt.l+(j>0?z*(P-u[0].t)/j:z/2)},O=P=>{if(u.length<2)return;const z=P.currentTarget.getBoundingClientRect(),M=(P.clientX-z.left-yt.l)/Math.max(1,z.width-yt.l-yt.r),A=u[0].t+j*Math.max(0,Math.min(1,M));let q=0;for(let G=1;G<u.length;G++)Math.abs(u[G].t-A)<Math.abs(u[q].t-A)&&(q=G);l(q)};return d.jsxs("section",{className:"hist-series","aria-label":`${g} history`,children:[d.jsxs("div",{className:"hist-head",children:[d.jsx("span",{className:"hist-label",children:g}),d.jsxs("span",{className:"hist-stats",children:[b!=null&&d.jsxs(d.Fragment,{children:[d.jsx("b",{children:b}),d.jsxs("span",{children:[_," now"]})]}),k!=null&&d.jsxs(d.Fragment,{children:[d.jsx("b",{className:Qq(k,p,f),children:k}),d.jsxs("span",{children:[_," peak"]})]})]})]}),d.jsx("div",{className:"hist-plot",ref:n,children:d.jsxs("svg",{className:"hist-chart",width:"100%",height:N,viewBox:`0 0 ${s} ${N}`,preserveAspectRatio:"none",role:"img","aria-label":b==null?`${g}: nothing measured yet`:`${g}: ${b}${_} now, peak ${k}${_}, over ${IT(u[0].t,u[u.length-1].t)}`,onPointerMove:O,onPointerLeave:()=>l(null),children:[[["warn",p],["hot",f]].map(([P,z])=>z==null||z>v?null:d.jsxs("g",{children:[d.jsx("line",{className:`hist-rule ${P}`,x1:yt.l,x2:s-yt.r,y1:yo(z,v,N),y2:yo(z,v,N)}),d.jsx("text",{className:`hist-rule-tag ${P}`,x:2,y:yo(z,v,N)+3,children:z})]},P)),d.jsx("line",{className:"hist-floor",x1:yt.l,x2:s-yt.r,y1:N-yt.b,y2:N-yt.b}),d.jsx("path",{className:"hist-area",d:Kq(u,s,t,v,N)}),d.jsx("path",{className:"hist-line",d:Yq(u,s,t,v,N)}),u.length===1&&d.jsx("circle",{className:"hist-dot",cx:I(u[0].t),cy:yo(u[0].v,v,N),r:3}),C&&d.jsxs("g",{children:[d.jsx("line",{className:"hist-cross",x1:I(C.t),x2:I(C.t),y1:yt.t,y2:N-yt.b}),d.jsx("circle",{className:"hist-dot",cx:I(C.t),cy:yo(C.v,v,N),r:3})]})]})}),d.jsx("div",{className:"hist-axis",children:C?d.jsxs("span",{className:"hist-at",children:[cl(C.t)," — ",d.jsx("b",{children:C.v}),_]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.length?cl(u[0].t):""}),d.jsx("span",{children:u.length?cl(u[u.length-1].t):""})]})}),E&&d.jsx("div",{className:"hist-note",children:E})]})}function t4({procs:e,total:t,onClose:n}){const s=_n(n),[i,a]=S.useState(OT),l=Zv(e,i);return mw.createPortal(d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:s,className:"modal pl-modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:[d.jsxs("div",{className:"modal-head",children:[d.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),d.jsxs("span",{className:"pl-count",children:[l.length," of ",t," running"]}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),d.jsx("div",{className:"pl-body",children:l.length===0?d.jsx("p",{className:"pl-empty",children:"Could not read the process list on this platform."}):d.jsxs("table",{className:"sd-procs pl-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx(Di,{col:"cpu",label:"cpu",sort:i,onSort:a}),d.jsx(Di,{col:"mem",label:"mem",sort:i,onSort:a}),d.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),d.jsx(Di,{col:"name",label:"process",sort:i,onSort:a})]})}),d.jsx("tbody",{children:l.map(u=>d.jsxs("tr",{children:[d.jsx("td",{className:"sd-num",children:u.cpu==null?"—":u.cpu.toFixed(0)}),d.jsx("td",{className:"sd-num sd-dim",children:u.mem.toFixed(1)}),d.jsx("td",{className:"sd-num sd-dim pl-pid",children:u.pid}),d.jsx("td",{className:"pl-name",children:u.name})]},u.pid))})]})}),d.jsx("div",{className:"pl-foot",children:"The busiest by processor and by memory, refreshed every four seconds. Not every process on the machine."})]})}),document.body)}const n4=3e3,r4=4e3,sh=20,el=36,Ti=8,s4=8,OT={key:"cpu",dir:"desc",rank:"cpu"};function o4(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"?"asc":"desc",rank:t==="name"?e.rank:t}}function Zv(e,t){const n=t.dir==="asc"?1:-1,s=(i,a)=>{if(t.key==="name")return n*i.name.localeCompare(a.name,void 0,{sensitivity:"base"});const l=t.key==="cpu"?i.cpu:i.mem,u=t.key==="cpu"?a.cpu:a.mem;return l==null||u==null?l==null?u==null?0:1:-1:n*(l-u)};return[...e].sort((i,a)=>s(i,a)||(a.cpu??-1)-(i.cpu??-1)||a.mem-i.mem||i.pid-a.pid)}function i4(e,t,n=s4){const s=Zv(e,{key:t.rank,dir:"desc",rank:t.rank});return Zv(s.slice(0,n),t)}function a4(e,t){return e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function l4(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function c4(e,t,n=Date.now()){const s=Math.max(0,Math.min(100,100-e));return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${u4(t.lastMs,n)}`:"running at full speed, and never held back"}}function u4(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<2)return"just now";if(n<60)return`${n} minutes ago`;const s=Math.floor(n/60);return s===1?"an hour ago":`${s} hours ago`}const PT="agent-dag.systemPanelOpen";function d4(){return Hu(PT)==="1"}function f4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(PT,e?"1":"0")}catch{}}function vo(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function h4(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${s}m`:`${s}m`}function p4(){const[e,t]=S.useState(null),n=S.useRef(null);return S.useEffect(()=>{let s=!0;const i=async()=>{if(document.visibilityState!=="hidden")try{const h=await fetch("/api/system");if(!h.ok)return;const p=await h.json();s&&(p!=null&&p.ok)&&t(p)}catch{}},a=()=>{n.current==null&&(i(),n.current=window.setInterval(i,n4))},l=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},u=()=>{if(document.visibilityState==="hidden"){l();return}a(),i()};return a(),document.addEventListener("visibilitychange",u),()=>{s=!1,l(),document.removeEventListener("visibilitychange",u)}},[]),e}function m4(e){const[t,n]=S.useState(null);return S.useEffect(()=>{let s=!0;const i=async()=>{if(document.visibilityState!=="hidden")try{const l=await fetch("/api/system/processes");if(!l.ok)return;const u=await l.json();s&&(u!=null&&u.ok)&&n({procs:u.procs??[],total:u.total??0})}catch{}};i();const a=window.setInterval(i,r4);return()=>{s=!1,window.clearInterval(a)}},[e]),t}function g4({usageOpen:e=!1}){const t=p4(),[n,s]=S.useState(d4);S.useEffect(()=>{f4(n)},[n]);const i=S.useRef(null),a=S.useRef(null);if(S.useEffect(()=>{if(n)return qi.push(()=>{var _,E;const k=((_=a.current)==null?void 0:_.contains(document.activeElement))??!1;s(!1),k&&((E=i.current)==null||E.focus())},mT)},[n]),!t||t.cpu==null||!t.memory)return d.jsx("span",{className:"sysmeter idle",title:"Sampling this machine…",children:d.jsx("span",{className:"sm-box","aria-hidden":!0,children:d.jsxs("span",{className:"sm-graphic",children:[d.jsx("svg",{className:"sm-spark",width:el,height:Ti,viewBox:`0 0 ${el} ${Ti}`}),d.jsx("span",{className:"sm-ram"})]})})});const{cpu:l,cpuHistory:u,cores:h,memory:p,loadavg:f}=t,g=p.usedPct>=90,v=u.slice(-sh),w=sh-v.length,N=el/sh,b=[`CPU ${l.toFixed(0)}% of ${h} cores`,f?`load ${f[0]} · ${f[1]} · ${f[2]} (1m · 5m · 15m)`:null,`Memory ${vo(p.total-p.available)} of ${vo(p.total)} used`,"","Click for detail. This machine, not this session."].filter(k=>k!==null).join(`
78
- `);return d.jsxs("span",{className:"sysmeter-wrap",children:[d.jsxs("button",{type:"button",ref:i,className:"sysmeter",title:b,"aria-label":"Toggle machine detail","aria-expanded":n,"aria-controls":n?"system-panel":void 0,onClick:()=>s(k=>!k),children:[d.jsxs("span",{className:"sm-box","aria-hidden":!0,children:[d.jsxs("span",{className:"sm-graphic",children:[d.jsx("svg",{className:"sm-spark",width:el,height:Ti,viewBox:`0 0 ${el} ${Ti}`,children:v.map((k,_)=>{const E=w+_,C=Math.max(1,k/100*Ti),j=.32+.68*((_+1)/v.length);return d.jsx("rect",{x:E*N,y:Ti-C,width:Math.max(.8,N-.7),height:C,rx:.5,fill:"var(--accent)",opacity:j},E)})}),d.jsx("span",{className:"sm-ram",children:d.jsx("span",{className:`sm-ram-fill${g?" warn":""}`,style:{transform:`scaleX(${Math.max(2,p.usedPct)/100})`}})})]}),d.jsxs("span",{className:"sm-read",children:[d.jsx("b",{children:l.toFixed(0)}),d.jsx("i",{children:"·"}),d.jsx("b",{children:p.usedPct.toFixed(0)})]})]}),d.jsxs("span",{className:"sm-sr",children:["CPU ",l.toFixed(0)," percent, memory ",p.usedPct.toFixed(0)," percent used"]})]}),n&&d.jsx(y4,{sys:t,usageOpen:e,panelRef:a,onClose:()=>{var k;s(!1),(k=i.current)==null||k.focus()}})]})}function y4({sys:e,usageOpen:t,panelRef:n,onClose:s}){const i=m4(!0),{memory:a,swap:l,perCore:u,loadavg:h,cores:p,uptimeSec:f,platform:g,thermal:v}=e,w=a?a.total-a.available:0,N=g==="win32"?"Commit":"Swap",b=l&&l.total>0?l.used/l.total*100:0;return d.jsxs("aside",{ref:n,className:`sysdetail${t?" shifted":""}`,id:"system-panel","aria-label":"Machine detail",children:[d.jsxs("div",{className:"sd-head",children:[d.jsx("span",{className:"sd-title",children:"This machine"}),d.jsxs("span",{className:"sd-sub",children:["up ",h4(f)," · ",p," cores"]}),d.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),u&&u.length>0&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Cores",children:d.jsx(wu,{group:"cores",title:"Core history",action:"Show core history",label:"Cores",children:d.jsx("div",{className:"sd-cores",style:{"--n":u.length},children:u.map((k,_)=>d.jsx("span",{className:"sd-core",title:`core ${_+1}: ${k}%`,children:d.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,k)/100})`}})},_))})})}),d.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:d.jsxs(wu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a&&d.jsx(Mu,{label:"Physical",value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:vo(w)})," of ",vo(a.total)]}),pct:a.usedPct,tone:a.usedPct>=90?"warn":"calm",note:`${vo(a.available)} available`}),l&&l.total>0&&d.jsx(Mu,{label:N,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:vo(l.used)})," of ",vo(l.total)]}),pct:b,tone:b>=90?"warn":"calm",note:b>=50?"paging to disk":void 0})]})}),h&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Load average",children:d.jsxs(wu,{group:"load",title:"Load history",action:"Show load history",label:"Load average",children:[d.jsx("div",{className:"sd-load",children:h.map((k,_)=>d.jsxs("span",{className:`sd-load-item${k>p?" over":""}`,children:[d.jsx("b",{children:k.toFixed(2)}),d.jsx("span",{children:["1m","5m","15m"][_]})]},_))}),d.jsx("div",{className:"sd-note",children:h[0]>p?`${(h[0]/p).toFixed(1)}× more work queued than cores to run it`:`within ${p} cores`})]})}),d.jsx(v4,{thermal:v}),d.jsx(w4,{read:i})]})}function wu({group:e,title:t,action:n,label:s,children:i}){const[a,l]=S.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"sd-open",onClick:()=>l(!0),title:n,"aria-label":n,children:[d.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[s," ",d.jsx("i",{className:"sd-row-more",children:"›"})]}),i]}),a&&d.jsx(Jq,{group:e,title:t,onClose:()=>l(!1)})]})}function v4({thermal:e}){if(!e)return null;const t=e.throttle?c4(e.throttle.speedLimit,e.heldBack):null;return d.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:d.jsxs(wu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>d.jsx(Mu,{label:n.label,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius,tone:l4(n.celsius,n.warnAt,n.critAt)},n.label)),t&&d.jsx(Mu,{label:"Throttling",value:t.value,pct:t.pct,tone:t.tone,note:t.note})]})})}function w4({read:e}){const[t,n]=S.useState(OT),[s,i]=S.useState(!1),a=(e==null?void 0:e.procs)??null;return d.jsxs("div",{className:"sd-section",role:"group","aria-label":"Busiest processes",children:[d.jsxs("div",{className:"sd-hrow",children:[d.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Busiest processes"}),a!=null&&a.length>0&&d.jsxs("button",{type:"button",className:"sd-all",onClick:()=>i(!0),title:"Show every process the deck is watching","aria-label":"Show every process the deck is watching",children:["more ",d.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]})]}),s&&e&&d.jsx(t4,{procs:e.procs,total:e.total,onClose:()=>i(!1)}),a==null?d.jsx("div",{className:"sd-note",children:"reading…"}):a.length===0?d.jsx("div",{className:"sd-note",children:"Could not read the process list on this platform."}):d.jsxs("table",{className:"sd-procs",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx(Di,{col:"cpu",label:"cpu",sort:t,onSort:n}),d.jsx(Di,{col:"mem",label:"mem",sort:t,onSort:n}),d.jsx(Di,{col:"name",label:"process",sort:t,onSort:n})]})}),d.jsx("tbody",{children:i4(a,t).map(l=>d.jsxs("tr",{children:[d.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),d.jsx("td",{className:"sd-num sd-dim",children:l.mem.toFixed(1)}),d.jsx("td",{className:"sd-proc-name",title:`pid ${l.pid}`,children:l.name})]},l.pid))})]})]})}function Di({col:e,label:t,sort:n,onSort:s}){const i=a4(n,e);return d.jsx("th",{scope:"col","aria-sort":i,children:d.jsxs("button",{type:"button",className:"sd-sort",title:`Sort by ${t}`,onClick:()=>s(o4(n,e)),children:[t,d.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:i==="none"?"":i==="ascending"?"↑":"↓"})]})})}function Mu({label:e,value:t,pct:n,tone:s="calm",note:i}){return d.jsxs("div",{className:"sd-row",children:[d.jsxs("div",{className:"sd-row-head",children:[d.jsx("span",{className:"sd-row-label",children:e}),d.jsx("span",{className:"sd-row-val",children:t})]}),d.jsx("span",{className:"sd-track",children:d.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}})}),i&&d.jsx("div",{className:"sd-note",children:i})]})}const R1=18,x4=1100,Ri=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},b4=Array.from({length:R1},(e,t)=>{const n=-72+144*t/(R1-1)+(Ri(t,1)-.5)*9,s=(n-90)*(Math.PI/180),i=(54+32*Math.cos(n*Math.PI/180))*(.74+Ri(t,2)*.52);return{dx:Math.cos(s)*i,dy:Math.sin(s)*i,rot:(t%2?1:-1)*(100+Ri(t,3)*260),delay:Math.round(Ri(t,4)*90),dur:760+Math.round(Ri(t,5)*260),scale:.8+Ri(t,6)*.45,hue:t%4,round:t%3===0}});function A1({anchor:e}){var i;const[t,n]=S.useState(null),s=typeof window<"u"&&((i=window.matchMedia)==null?void 0:i.call(window,"(prefers-reduced-motion: reduce)").matches);return S.useEffect(()=>{if(s)return;const a=e.current;if(!a)return;const l=a.getBoundingClientRect();n({x:l.left+l.width/2,y:l.top+l.height/2});const u=window.setTimeout(()=>n(null),x4);return()=>window.clearTimeout(u)},[e,s]),s||!t?null:mw.createPortal(d.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:b4.map((a,l)=>d.jsx("span",{className:`confetti-bit${a.round?" round":""}`,"data-hue":a.hue,style:{"--dx":`${a.dx.toFixed(1)}px`,"--dy":`${a.dy.toFixed(1)}px`,"--rot":`${a.rot}deg`,"--s":a.scale.toFixed(2),animationDelay:`${a.delay}ms`,animationDuration:`${a.dur}ms, ${a.dur}ms`}},l))}),document.body)}const $T=new Set(["awaiting_url","awaiting_code","registering"]);function k4(e){return e!=null&&$T.has(e)}function LT(e){return e!=null&&e!=="done"&&!$T.has(e)}const _4="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",S4="the sign-in did not complete";function N4({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?_4:S4)}}const E4="done";function C4(){let e=!1;return{shouldAnnounce(t){return t!==E4?(e=!1,!1):e?!1:(e=!0,!0)}}}function Pw(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const j4={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck2:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${Bt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",unreadable_export:"claude-swap wrote something this deck could not read — try again, and upgrade it if this repeats",mixed_versions:"claude-swap changed format part-way through — try again",nothing_to_share:"none of those accounts could be exported",too_many:"that is more accounts than one share can carry",not_in_bundle:"that account is not in this share",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters, and cannot start with a dash",bad_email:"that does not look like an email address — it cannot contain spaces or start with a dash"},T4={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},R4=`claude-swap could not read the login keychain — start ${Bt} from a Terminal window rather than a background service`;function Jv(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Hi(e)))return R4;const n=Pw(T4,e==null?void 0:e.reason);return n||(e==null?void 0:e.reason)||t}function Hi(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const A4={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself so it is on this deck's PATH",bad_override:"AGENTS_DECK_CCUSAGE names a file that is not there — correct it to the full path of your ccusage, or unset it to let the deck find its own",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},M4="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function I4(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const O4="ccusage could not be started — the deck launched npx and Node could not load the npm script it points at. An older deck asked cmd.exe for a bare npx.cmd, which made the shim look for that script under the deck's working directory instead of beside itself; update the deck and reopen this modal",P4="ccusage could not be started — the copy npx fetched will not load: Node could not resolve a file inside it. That copy is in npx's own cache, which the deck never rewrites, so clear it with `npm cache clean --force` and reopen this modal",$4=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),L4=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,q4=/[\\/]_npx[\\/]/i,D4=`the copy of ccusage ${Bt} installed for itself`;function F4(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function z4(e,t){const n=B4(e,t),s=F4(e);switch(e==null?void 0:e.stage){case"npx":return s?`ccusage failed on both of its paths. The managed install failed first — ${s} — and the deck then fell back to npx, where ${tl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${tl(n)}`;case"managed":return`${D4} failed to run: ${tl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${tl(n)}`:`the ccusage this deck found on your PATH failed to run: ${tl(n)}`;default:return n}}const tl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function B4(e,t){const n=Hi(e);if($4(n)){if(q4.test(n))return P4;if(L4.test(n))return O4}if(I4(n))return M4;const s=Pw(A4,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Oi(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&LT(e.state))return e.error;const n=Pw(j4,e==null?void 0:e.reason);return n||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function U4(e,t,n){if(n<=0||Aw(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:s===-1?0:(s+1)%n};case"ArrowLeft":return{kind:"select",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function qT(e,t){const n=Math.round(e/1e3)-t;return n<=0?{text:"expired",tone:"gone"}:n<60?{text:`expires in ${n}s`,tone:"soon"}:{text:`expires in ${Math.round(n/60)}m`,tone:"ok"}}function W4(e){const t=new Map;for(const n of e){const s=(n.email??"").trim().toLowerCase();s&&t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=(n.email??"").trim(),i=n.alias||s||`account ${n.num}`,a=[];return n.alias&&s&&a.push(s),s&&(t.get(s.toLowerCase())??0)>1&&a.push(n.org||`slot ${n.num}`),{num:n.num,label:i,sub:a.length?a.join(" · "):null}})}function H4(e){return e<=0?"Nothing picked yet.":e===1?"1 account — its sign-in token will be on your clipboard.":`${e} accounts — ${e} sign-in tokens will be on your clipboard.`}function G4(e){switch(e){case"imported":return"imported";case"healed":return"dead token replaced";case"updated":return"updated";case"present":return"already here";default:return"not imported"}}function V4(e){const t=e.length;if(!t)return"Nothing to import.";const n=p=>e.filter(f=>f.state===p).length,s=[],i=n("imported");i&&s.push(`${i} of ${t} imported`);const a=n("healed");a&&s.push(`${a} had a dead token replaced`);const l=n("updated");l&&s.push(`${l} updated`);const u=n("present");u&&s.push(`${u} already here`);const h=n("failed");return h&&s.push(`${h} did not arrive`),`${s.join(", ")}.`}const Y4=1500,iu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],M1="aa-panel",I1=e=>`aa-tab-${e}`;async function nl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const ew=fe.forwardRef((e,t)=>d.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[d.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),d.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));ew.displayName="SuccessMark";function K4({onClose:e,onChanged:t}){const[n,s]=S.useState("login"),[i,a]=S.useState(null),[l,u]=S.useState(""),[h,p]=S.useState(""),[f,g]=S.useState(!1),[v,w]=S.useState(null),[N,b]=S.useState(null),[k,_]=S.useState(null),[E,C]=S.useState(null),j=S.useRef(""),I=S.useRef(!1),O=S.useRef(!1),P=S.useRef(null),z=S.useRef(null),M=S.useRef(null),A=S.useRef(null),q=S.useRef([]),G=S.useRef(!1),Y=S.useCallback(()=>{I.current&&nl({action:"login-cancel"}).catch(()=>{}),e()},[e]),R=_n(Y,{focusRef:M}),Q=S.useCallback(async()=>{if(!ar(O.current))return;O.current=!0,g(!0),w(null),I.current=!0;const L=await nl({action:"login"}).catch(()=>null);if(O.current=!1,g(!1),!(L!=null&&L.ok)){w(Oi(L,"could not start the sign-in"));return}a(L)},[]);S.useEffect(()=>{if(!k4(i==null?void 0:i.state))return;const L=window.setInterval(async()=>{try{const K=await fetch("/api/claude-accounts/login");K.ok&&a(await K.json())}catch{}},Y4);return()=>window.clearInterval(L)},[i]);const H=S.useRef(t);H.current=t;const ne=S.useState(C4)[0];S.useEffect(()=>{var L;(i==null?void 0:i.state)==="awaiting_code"&&((L=P.current)==null||L.focus()),ne.shouldAnnounce(i==null?void 0:i.state)&&H.current()},[i==null?void 0:i.state,ne]),S.useEffect(()=>{var L;n==="paste"&&!G.current&&((L=z.current)==null||L.focus()),G.current=!1},[n]);const X=S.useCallback(L=>{var se;const K=U4(L,iu.findIndex(he=>he.id===n),iu.length);K.kind!=="pass"&&(L.preventDefault(),G.current=!0,s(iu[K.index].id),(se=q.current[K.index])==null||se.focus())},[n]),U=S.useCallback(async()=>{var K;if(!ar(O.current))return;O.current=!0,g(!0),w(null);const L=await nl({action:"login-code",code:l}).catch(()=>null);if(O.current=!1,g(!1),!(L!=null&&L.ok)){w(Oi(L,"the code was not accepted")),L!=null&&L.state&&a(L),(K=P.current)==null||K.select();return}u(""),a(L)},[l,i]),J=S.useCallback(async()=>{if(!ar(O.current))return;O.current=!0,g(!0),w(null);const L=await nl({action:"import",blob:h}).catch(()=>null);if(O.current=!1,g(!1),!(L!=null&&L.ok)){w(Oi(L,"the import failed"));return}j.current=h,p(""),C(null),b(L.results??[]),t()},[h,t]),$=S.useCallback(async L=>{const K=`${L.email}|${L.org??""}`;if(!ar(O.current)||!j.current)return;O.current=!0,g(!0),_(K),C(null);const se=await nl({action:"import",blob:j.current,force:!0,only:{email:L.email,org:L.org??""}}).catch(()=>null);if(O.current=!1,g(!1),_(null),!(se!=null&&se.ok)){C({key:K,text:Oi(se,"that account could not be updated")});return}const he=(se.results??[])[0];he&&b(me=>me&&me.map(xe=>`${xe.email}|${xe.org??""}`===K?he:xe)),t()},[t]),V=(i==null?void 0:i.state)==="done"?i.account:null,Z=LT(i==null?void 0:i.state)||!!(v&&I.current&&!f),D=N4({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:v});return d.jsx("div",{className:"modal-backdrop",onClick:Y,role:"presentation",children:d.jsxs("div",{ref:R,className:"modal aa-modal",onClick:L=>L.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:X,children:iu.map((L,K)=>d.jsx("button",{type:"button",role:"tab",id:I1(L.id),ref:se=>{q.current[K]=se},"aria-selected":n===L.id,"aria-controls":M1,tabIndex:n===L.id?0:-1,className:`aa-tab${n===L.id?" on":""}`,onClick:()=>{G.current=!1,s(L.id)},children:L.label},L.id))})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:Y,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body aa-body",id:M1,role:"tabpanel","aria-labelledby":I1(n),children:n==="login"?V?d.jsxs("div",{className:"aa-done",children:[d.jsx(ew,{ref:A}),d.jsx(A1,{anchor:A}),d.jsx("h4",{children:V.added?`Account ${V.num} added`:"Credentials refreshed"}),d.jsxs("p",{className:"aa-note",children:[d.jsx("strong",{children:V.email}),V.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),d.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(i==null?void 0:i.state)==="awaiting_code"||(i==null?void 0:i.state)==="registering"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"1 · Approve in the browser"}),d.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),d.jsx("a",{className:"aa-link",href:i.url??"#",target:"_blank",rel:"noreferrer noopener",children:i.url})]}),d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),d.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:P,type:"text",value:l,onChange:L=>u(L.target.value),onKeyDown:L=>{L.key==="Enter"&&l.trim()&&!f&&U()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:i.state==="registering"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!l.trim()||i.state==="registering"),onClick:U,children:i.state==="registering"?"registering…":"Continue"})]}),(v||i.error)&&d.jsx("p",{className:"aa-err",children:v??i.error}),d.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):Z?d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:D.title}),d.jsx("p",{className:"aa-err",children:D.message}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{I.current=!1,a(null),w(null),Q()},children:"Try again"})]}):f||I.current?d.jsx("div",{className:"aa-step",children:d.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):d.jsxs("div",{className:"aa-step aa-primer",children:[d.jsx("h4",{children:"Sign in to Anthropic"}),d.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),d.jsx("div",{className:"aa-actions",children:d.jsx("button",{type:"button",ref:M,className:"btn primary",onClick:Q,children:"Open the sign-in page"})})]}):N?(()=>{const L=N.filter(K=>K.state==="imported").length;return d.jsxs("div",{className:"aa-done",children:[d.jsx(ew,{ref:A}),L>0&&d.jsx(A1,{anchor:A}),d.jsx("h4",{children:V4(N)}),N.length>0&&d.jsx("ul",{className:"aa-results",children:N.map(K=>{const se=`${K.email}|${K.org??""}`;return d.jsxs("li",{className:`aa-result ${K.state}`,children:[d.jsx("span",{className:"aa-result-who",children:K.email||(K.num?`slot ${K.num}`:"an account")}),d.jsx("span",{className:"aa-result-what",children:G4(K.state)}),K.state==="present"&&d.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":k===se,title:`Overwrite the stored login for ${K.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>$(K),children:k===se?"updating…":"update anyway"}),(E==null?void 0:E.key)===se&&d.jsx("span",{className:"aa-result-err",children:E.text})]},se)})}),d.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",d.jsx("strong",{children:" update anyway"}),"."]}),d.jsxs("div",{className:"aa-actions",children:[d.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{j.current="",C(null),b(null)},children:"Import another"})]})]})})():d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"Paste an account shared from another deck"}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:z,type:"text",value:h,onChange:L=>p(L.target.value),onKeyDown:L=>{L.key==="Enter"&&h.trim()&&!f&&J()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!h.trim()),onClick:J,children:f?"importing…":"Import"})]}),v&&d.jsx("p",{className:"aa-err",children:v}),d.jsxs("p",{className:"aa-note",children:["Use ",d.jsx("strong",{children:"share"})," on one account in the other deck, or ",d.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})})}async function X4(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Q4=1800;function Z4({accounts:e,onClose:t,copyText:n}){const[s,i]=S.useState([]),[a,l]=S.useState(null),[u,h]=S.useState(!1),[p,f]=S.useState(null),[g,v]=S.useState(!1),[w,N]=S.useState(()=>Math.floor(Date.now()/1e3)),b=S.useRef(null),k=S.useRef(!1),_=_n(t,{focusRef:b});S.useEffect(()=>{if(!a)return;N(Math.floor(Date.now()/1e3));const A=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(A)},[a]);const E=W4(e),C=e.filter(A=>!s.includes(A.num)).map(A=>A.num),j=C.length===e.length,I=A=>i(q=>q.includes(A)?q.filter(G=>G!==A):[...q,A]),O=S.useCallback(async()=>{if(!ar(k.current)||!C.length)return;k.current=!0,h(!0),f(null),v(!1);const A=await X4({action:"share",accounts:C}).catch(()=>null);if(k.current=!1,h(!1),!(A!=null&&A.ok)){f(Oi(A,"the share could not be made"));return}l({blob:A.blob,expiresAt:A.expiresAt,shared:A.shared??[],failed:A.failed??[]})},[e,C]),P=a?qT(a.expiresAt,w):null,z=(P==null?void 0:P.tone)==="gone",M=(a==null?void 0:a.shared.length)??0;return d.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:_,className:"modal sa-modal",onClick:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("h3",{children:"Share accounts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body sa-body",children:a?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:z?"This share has expired":M===1?"1 account, ready to paste":`${M} accounts, ready to paste`}),d.jsx("code",{className:`ap-share-blob${z?" sa-dead":""}`,children:a.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(z){l(null),O();return}await n(a.blob)&&(v(!0),window.setTimeout(()=>v(!1),Q4))},children:z?"make a new share":g?"copied":`copy ${M===1?"the share":"all "+M}`}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:M===1?"this is the password":`this is ${M} passwords`})," · ",d.jsx("span",{className:`ap-share-expiry ${P==null?void 0:P.tone}`,children:P==null?void 0:P.text})]})]}),a.failed.length>0&&d.jsxs("div",{className:"sa-failed",role:"alert",children:[d.jsx("p",{className:"sa-failed-head",children:a.failed.length===1?"One account is not in this bundle:":`${a.failed.length} accounts are not in this bundle:`}),d.jsx("ul",{className:"sa-list",children:a.failed.map(A=>{var G;const q=!!(A.email&&((G=A.detail)!=null&&G.includes(A.email)));return d.jsxs("li",{children:[!q&&d.jsx("span",{className:"sa-who",children:A.email||`account ${A.num}`}),d.jsx("span",{className:"sa-why",children:A.detail||"could not be exported"})]},`${A.num}-${A.email}`)})})]}),d.jsx("p",{className:"sa-note",children:z?d.jsx(d.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):d.jsxs(d.Fragment,{children:["Paste it into the other deck with ",d.jsx("strong",{children:"+"})," → ",d.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>{l(null),v(!1)},children:"Pick again"}),d.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:"Nothing to share"}),d.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",d.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),d.jsx("div",{className:"sa-actions",children:d.jsx("button",{type:"button",className:"btn primary",ref:b,onClick:t,children:"Close"})})]}):d.jsxs("div",{className:"sa-step",children:[d.jsxs("h4",{children:["Which accounts go to the other ",Bt,"?"]}),d.jsx("p",{className:`sa-count${C.length?"":" empty"}`,children:H4(C.length)}),d.jsx("ul",{className:"sa-list sa-pick",children:E.map(A=>d.jsx("li",{children:d.jsxs("label",{className:"sa-row",children:[d.jsx("input",{type:"checkbox",checked:C.includes(A.num),onChange:()=>I(A.num)}),d.jsx("span",{className:"sa-who",children:A.label}),A.sub&&d.jsx("span",{className:"sa-sub",children:A.sub})]})},A.num))}),p&&d.jsx("p",{className:"aa-err",children:p}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>i(j?e.map(A=>A.num):[]),children:j?"Clear all":"Select all"}),d.jsx("button",{type:"button",className:"btn primary",ref:b,...ir(u,!C.length),onClick:O,children:u?"making the share…":C.length===0?"Share":C.length===1?"Share 1 account":`Share ${C.length} accounts`})]})]})})]})})}function J4(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((i,a)=>i-a).map(i=>{const a=i===t?"here":n.has(i)?"swap":"free";return{slot:i,kind:a,label:a==="here"?`slot ${i}`:`slot ${i} · ${a}`}})}function eD(e,t,n){if(!(n!=null&&n.ok))return null;const s=Number.isInteger(n.to)?n.to:null;if(s==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const i=n.swapped===!0&&s!==t;return{menuFor:e.menuFor===t?s:i&&e.menuFor===s?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:i?{at:s,displaced:t}:null}}function tD(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function nD(e,t,n){var i;const s=((i=e.find(a=>a.slot===t))==null?void 0:i.kind)??"here";return s==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:s==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function rD(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:`Switch the active account out once it passes ${e}% of its limit.`}}function O1(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function P1(e){const t=e.filter(u=>!O1(u)),n=e.filter(u=>O1(u)),s=t.length?t:n,i=t.length?n:[],a=s.reduce((u,h)=>u&&u.pct>=h.pct?u:h,null);let l=null;for(const u of i)a&&u.pct<=a.pct||(!l||u.pct>l.pct)&&(l=u);return{shown:s,rest:i,fuller:l,peak:l??a}}function sD(e,t,n){return e<1?null:t?"fewer":n?`${n.label} ${Math.round(n.pct)}%`:`${e} more`}function oD(e,t,n,s){const i=e==null?"No usage has been collected for this account yet.":`${Math.round(e)}% left on ${t??"the window that runs out first"}, which is the one that runs out first.`,a=n===1?"the other window":`the other ${n} windows`;return`${i} ${s?"Hide":"Show"} ${a}.`}const iD="\0";function $w(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${iD}${n}`}function aD(e,t){const n=$w(t);return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function lD(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map($w)),s=e.filter(i=>n.has(i));return s.length===e.length?e:s}const cD=64;function uD(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const dD=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function $1(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function fD(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=Hi(t.body);return{text:Jv(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function L1(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}const q1=15e3,hD=8e3,oh=1800,pD=3e4,mD=[70,80,85,90,95];function D1(e,t){return jT(t-Math.floor(e/1e3))}function gD(e,t){if(!e)return"";const n=Math.floor(e/1e3)-t;return n<=0?" · due":n<60?` · next in ${n}s`:` · next in ${Math.round(n/60)}m`}function yD(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function F1({lane:e,nowSec:t}){const n=Math.min(100,Math.max(0,e.pct)),s=n>=90?"var(--err)":n>=70?"var(--warn)":"var(--accent)",i=e.resetAt?TT(e.resetAt,t):null;return d.jsxs("div",{className:"ap-lane",children:[d.jsx("span",{className:"ap-lane-label",children:e.label}),d.jsx("div",{className:"ap-lane-track",children:d.jsx("div",{className:"ap-lane-fill",style:{width:`${n===0?1.5:n}%`,background:s,opacity:n===0?.4:1}})}),d.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[n,"%"]}),d.jsx("span",{className:"ap-lane-reset",children:i?`resets ${i}`:""})]})}async function z1(e){var n;let t=!1;try{t=await Promise.race([((n=navigator.clipboard)==null?void 0:n.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{t=!1}if(t)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),t=document.execCommand("copy"),s.remove()}catch{t=!1}return t}function vD({onClose:e}){var Ge,it,ke,ct,It;const[t,n]=S.useState(null),[s,i]=S.useState(null),[a,l]=S.useState(null),[u,h]=S.useState(!1),[p,f]=S.useState(null),[g,v]=S.useState(()=>Math.floor(Date.now()/1e3)),w=S.useRef(null),[N,b]=S.useState(null),[k,_]=S.useState(!1),[E,C]=S.useState(""),[j,I]=S.useState(null),[O,P]=S.useState(null),[z,M]=S.useState(null),[A,q]=S.useState(!1),[G,Y]=S.useState(!1),[R,Q]=S.useState(null),[H,ne]=S.useState(null),[X,U]=S.useState(null),[J,$]=S.useState(null),[V,Z]=S.useState(!1),[D,L]=S.useState([]),K=S.useRef(null),se=S.useCallback(ae=>AT(K.current)?(K.current=ae,l(ae),!0):!1,[]),he=S.useCallback(()=>{K.current=null,l(null)},[]),me=(ae,Le=!1)=>{const ze=RT(a,ae);return{disabled:ze.disabled,"aria-busy":ze.busy||Le}},xe=S.useCallback(ae=>{window.requestAnimationFrame(()=>{var Le;if(Iq(((Le=document.activeElement)==null?void 0:Le.tagName)??null))for(const ze of Mq(ae)){const Ce=document.querySelector(ze);if(Ce){Ce.focus();return}}})},[]),Ee=S.useCallback(async(ae=!1)=>{ae&&h(!0);const Le=new AbortController,ze=window.setTimeout(()=>Le.abort(),pD);try{const[Ce,Ve]=await Promise.all([fetch(`/api/claude-accounts${ae?"?refresh=1":""}`,{signal:Le.signal}),fetch("/api/cswap-auto",{signal:Le.signal})]);if(Ce.ok){const rt=await Ce.json();n(rt),L(Te=>lD(Te,rt.accounts))}Ve.ok&&i(await Ve.json());const Ct=fD([await $1(Ce),await $1(Ve)]);f(rt=>L1(rt,Ct))}catch{f(Ce=>L1(Ce,dD))}finally{window.clearTimeout(ze),ae&&h(!1)}},[]),He=S.useCallback(async(ae,Le)=>{if(!se(Le))return null;f(null);try{const Ce=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)})).json().catch(()=>null);return Ce!=null&&Ce.ok||f({text:Jv(Ce,"command failed"),raw:Hi(Ce)}),Ce}catch{return f({text:"server unreachable"}),null}finally{he()}},[se,he]),Fe=S.useCallback(async(ae,Le)=>{if(!se(Le))return null;f(null);try{const Ce=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)})).json().catch(()=>null);return Ce!=null&&Ce.ok||f({text:Oi(Ce,"command failed")}),Ce}catch{return f({text:"server unreachable"}),null}finally{he()}},[se,he]);S.useEffect(()=>(Ee(!0),w.current=window.setInterval(()=>Ee(!1),q1),()=>{w.current!=null&&window.clearInterval(w.current)}),[Ee]),S.useEffect(()=>{const ae=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ae)},[]);const Ie=((Ge=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Ge.value)??"90",be=J??Ie,ue=rD(be,Ie),re=(it=t==null?void 0:t.accounts)==null?void 0:it.find(ae=>ae.active),pe=((ke=P1((re==null?void 0:re.lanes)??[]).peak)==null?void 0:ke.pct)??null,Oe=pe!=null&&pe>=Number(Ie)-15,nt=async ae=>{if(se(`switch-${ae}`)){f(null);try{const ze=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:ae})})).json().catch(()=>null);ze!=null&&ze.ok||f({text:Jv(ze,"the switch failed"),raw:Hi(ze)}),await Ee(!0)}catch{f({text:"server unreachable"})}finally{he(),xe(ae)}}},st=async(ae,Le)=>{const{commit:ze,alias:Ce}=uD(E,Le);if(ze){const Ve=await Fe({action:"alias",account:ae,alias:Ce},`alias-${ae}`);if(await Ee(!0),!(Ve!=null&&Ve.ok))return;C(Ce)}I(ae),window.setTimeout(()=>I(Ve=>Ve===ae?null:Ve),oh)},Xe=async(ae,Le)=>{const ze=await Fe({action:"move",account:ae,slot:Le},`move-${ae}`),Ce=eD({menuFor:N,shareFor:(z==null?void 0:z.num)??null},ae,ze);if(await Ee(!0),Ce){b(Ce.menuFor),P(Ce.confirmRemove),Ce.shareFor==null&&(M(null),Y(!1)),Q(Ce.swapNote);const Ve=Ce.swapNote;Ve&&window.setTimeout(()=>Q(Ct=>Ct===Ve?null:Ct),hD),ne(null),xe(Ce.menuFor)}return ze},Pe=async(ae,Le,ze)=>{if(ze.sends){const Ce=await Xe(ae,Le);if(!(Ce!=null&&Ce.ok))return}U(ae),window.setTimeout(()=>U(Ce=>Ce===ae?null:Ce),oh)},Ue=async(ae,Le)=>{if(Le.sends){const ze=await He({action:"setting",key:"autoswitch.threshold",value:ae},"threshold");if(await Ee(!0),!(ze!=null&&ze.ok))return;$(null)}Z(!0),window.setTimeout(()=>Z(!1),oh)};return d.jsxs("aside",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[d.jsxs("div",{className:"ap-header",children:[d.jsx("h2",{children:"Accounts"}),d.jsxs("div",{className:"ap-header-right",children:[d.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>_(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),(((ct=t==null?void 0:t.accounts)==null?void 0:ct.length)??0)>0&&d.jsx("button",{type:"button",className:"glyph-btn ap-share-set",onClick:()=>q(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${Bt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:"↗"}),d.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>Ee(!0),...me("reload",u),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:u?"…":"↻"}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),t==null?p?d.jsxs("div",{className:"ap-empty",role:"alert",children:[d.jsx("span",{title:p.raw||void 0,children:p.text}),d.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",q1/1e3," seconds."]}),d.jsx("button",{type:"button",className:"ap-fix",disabled:u,onClick:()=>Ee(!0),children:u?"trying…":"try again"})]}):d.jsx("div",{className:"ap-empty",children:"Checking…"}):t.ok?d.jsxs(d.Fragment,{children:[(It=t.accounts)==null?void 0:It.map(ae=>{const{shown:Le,rest:ze,fuller:Ce,peak:Ve}=P1(ae.lanes),Ct=D.includes($w(ae)),rt=sD(ze.length,Ct,Ce);return d.jsxs("div",{className:`ap-account${ae.active?" active":""}`,children:[d.jsxs("div",{className:"ap-account-head",children:[d.jsx("span",{className:"ap-num",children:ae.num}),ae.alias&&d.jsx("span",{className:"ap-alias",title:ae.alias,children:ae.alias}),d.jsx("span",{className:"ap-email",title:ae.email??void 0,children:ae.email}),d.jsx("button",{type:"button",id:`ap-more-${ae.num}`,className:`ap-more${N===ae.num?" on":""}`,"aria-label":`Manage account ${ae.num}`,"aria-expanded":N===ae.num,"aria-controls":N===ae.num?`ap-manage-${ae.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{b(N===ae.num?null:ae.num),C(ae.alias??""),P(null),M(null),Y(!1),Q(null),I(null),ne(null),U(null)},children:"⋯"}),ae.active&&d.jsx("span",{className:"ap-badge-active",children:"active"}),ae.disabled&&d.jsx("span",{className:"ap-badge-held",children:"held out"}),!ae.active&&!ae.disabled&&d.jsx("button",{type:"button",className:"ap-manage-btn ap-switch",...me(`switch-${ae.num}`),onClick:()=>nt(ae.num),title:`Switch to ${ae.alias??ae.email}`,children:a===`switch-${ae.num}`?"…":"switch"})]}),d.jsx("div",{className:"ap-lanes",id:`ap-lanes-${ae.num}`,children:Le.length?d.jsxs(d.Fragment,{children:[Le.map(Te=>d.jsx(F1,{lane:Te,nowSec:g},Te.id)),Ct&&ze.map(Te=>d.jsx(F1,{lane:Te,nowSec:g},Te.id))]}):d.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),d.jsxs("div",{className:"ap-meta",children:[ae.staleCopy&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-stale-copy",title:"The deck can still see this account — its live usage is being read — but claude-swap's own stored copy of the login was rejected, so these numbers stopped updating. Resume re-captures the copy from the login you already have.",children:"numbers paused"}),d.jsx("button",{type:"button",className:"ap-fix",...me("recapture"),onClick:async()=>{const Te=await Fe({action:"recapture"},"recapture");Te!=null&&Te.ok&&Ee(!0)},title:"Re-capture this account's stored credentials from the login you already have. No sign-in, no switch.",children:a==="recapture"?"resuming…":"resume"})]}),ae.error&&(()=>{const Te=yD(ae.error);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-err",title:Te.hint,children:Te.text}),Te.fixable&&d.jsx("button",{type:"button",className:"ap-fix",onClick:()=>_(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),rt&&d.jsx("button",{type:"button",className:"ap-lanes-more","aria-expanded":Ct,"aria-controls":`ap-lanes-${ae.num}`,title:oD(ae.headroom,(Ve==null?void 0:Ve.label)??null,ze.length,Ct),onClick:()=>L(Te=>aD(Te,ae)),children:rt}),(((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!ae.active||ae.disabled)&&d.jsx("button",{type:"button",className:"ap-rotate",...me(`rot-${ae.num}`),onClick:()=>He({action:"account",account:ae.num,enabled:ae.disabled},`rot-${ae.num}`).then(()=>Ee(!0)),title:ae.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:ae.disabled?"put back":"hold out"}),ae.fetchedAt?d.jsxs("span",{className:`ap-age${ae.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",D1(ae.fetchedAt,g),gD(ae.nextAt,g)]}):d.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),N===ae.num&&d.jsxs("div",{className:"ap-manage",id:`ap-manage-${ae.num}`,role:"group","aria-label":`Manage account ${ae.num}`,children:[d.jsxs("div",{className:"ap-manage-name",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${ae.num}`,children:"Alias"}),d.jsx("input",{id:`ap-alias-${ae.num}`,className:"ap-manage-input",type:"text",value:E,onChange:Te=>C(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&st(ae.num,ae.alias)},maxLength:cD,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`alias-${ae.num}`),onClick:()=>st(ae.num,ae.alias),title:"A short name to show instead of the email",children:j===ae.num?"saved":"save"})]}),(()=>{const Te=J4((t.accounts??[]).map(St=>St.num),ae.num),wt=tD(Te,H,ae.num),dt=nD(Te,wt,ae.num);return d.jsxs("div",{className:"ap-manage-slot",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${ae.num}`,children:"Slot"}),d.jsx("span",{className:"ap-field",children:d.jsx("select",{id:`ap-slot-${ae.num}`,value:String(wt),...me(`move-${ae.num}`),onChange:St=>ne(Number(St.target.value)),children:Te.map(St=>d.jsx("option",{value:St.slot,children:St.label},St.slot))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`move-${ae.num}`),title:dt.title,onClick:()=>Pe(ae.num,wt,dt),children:X===ae.num?dt.done:dt.label})]})})(),d.jsxs("div",{className:"ap-manage-acts",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ae.num}`),title:`Copy this account to another ${Bt}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:async()=>{Y(!1);const Te=await Fe({action:"share",account:ae.num},`share-${ae.num}`);Te!=null&&Te.ok&&M({num:ae.num,blob:Te.blob,expiresAt:Te.expiresAt})},children:"share"}),d.jsx("button",{type:"button",className:`ap-manage-btn danger${O===ae.num?" armed":""}`,...me(`rm-${ae.num}`),title:O===ae.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(O!==ae.num){P(ae.num),window.setTimeout(()=>P(Te=>Te===ae.num?null:Te),4e3);return}P(null),Fe({action:"remove",account:ae.num},`rm-${ae.num}`).then(()=>{b(null),Ee(!0),xe(null)})},children:O===ae.num?"confirm":"remove"})]}),(R==null?void 0:R.at)===ae.num&&(()=>{var dt;const Te=(dt=t.accounts)==null?void 0:dt.find(St=>St.num===R.displaced),wt=(Te==null?void 0:Te.alias)??(Te==null?void 0:Te.email)??"the account that was there";return d.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${R.at} was taken, so the two accounts traded places: ${wt} now holds slot ${R.displaced}.`,children:["swapped with slot ",R.displaced]})})(),(z==null?void 0:z.num)===ae.num&&(()=>{const Te=qT(z.expiresAt,g),wt=Te.tone==="gone";return d.jsxs("div",{className:`ap-share${wt?" expired":""}`,children:[d.jsx("code",{className:"ap-share-blob",children:z.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ae.num}`),onClick:async()=>{if(wt){Y(!1);const dt=await Fe({action:"share",account:ae.num},`share-${ae.num}`);dt!=null&&dt.ok&&M({num:ae.num,blob:dt.blob,expiresAt:dt.expiresAt});return}await z1(z.blob)&&(Y(!0),window.setTimeout(()=>Y(!1),1800))},children:wt?"make a new share":G?"copied":"copy"}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",d.jsx("span",{className:`ap-share-expiry ${Te.tone}`,children:Te.text})]})]})]})})()]})]},ae.num)}),(s==null?void 0:s.ok)&&d.jsxs("div",{className:"ap-auto",children:[d.jsxs("div",{className:"ap-auto-head",children:[d.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),d.jsxs("span",{className:"ap-auto-ctl",children:[pe!=null&&d.jsxs("span",{className:`ap-auto-now${Oe?" near":""}`,children:[Math.round(pe),"%"]}),d.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:d.jsx("select",{"aria-label":"Switch threshold",value:be,...me("threshold"),onChange:ae=>$(ae.target.value),children:mD.map(ae=>d.jsxs("option",{value:ae,children:[ae,"%"]},ae))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...me("threshold"),title:ue.title,onClick:()=>Ue(be,ue),children:V?ue.done:ue.label}),d.jsxs("button",{type:"button",className:`ap-auto-state${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,"aria-label":"Auto-switch",...me("enable"),onClick:()=>He({action:"enable",enabled:!s.enabled},"enable").then(()=>Ee(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[d.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&d.jsxs("p",{className:"ap-auto-note",children:[d.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",d.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&d.jsx("div",{className:"ap-auto-foot",children:d.jsxs("span",{className:"ap-auto-result",children:["checked ",D1(s.lastTick.at,g)]})})]}),p&&d.jsxs("div",{className:"ap-failure",role:"alert",children:[d.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),d.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),d.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"These numbers only update while this panel is open."})]}):d.jsx("div",{className:"ap-empty",children:t.reason==="no_cswap"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"claude-swap isn't installed."}),d.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),t.hint&&d.jsx("code",{className:"ap-cmd",children:t.hint}),d.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",d.jsx("strong",{children:"+"})," button above."]})]}):t.reason==="no_accounts"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"No accounts added yet."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",d.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Couldn't read the account store."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",t.reason?` (${t.reason})`:"","."]})]})}),k&&d.jsx(K4,{onClose:()=>_(!1),onChanged:()=>Ee(!0)}),A&&d.jsx(Z4,{accounts:((t==null?void 0:t.accounts)??[]).map(ae=>({num:ae.num,email:ae.email,alias:ae.alias,org:ae.org})),onClose:()=>q(!1),copyText:z1})]})}const wD=3e4;function xD({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function bD({bundle:e,running:t,pending:n,lastTried:s}){return t?xD({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function kD(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function _D({asked:e,reported:t}){return t?t!==e:!1}function SD(e){const t=e.thresholdMs??wD;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=t}}function ND(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function ED(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function CD(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function jD(e,t){const n=CD(e),s=n?`removes ${n} on the canvas`:null,i=u=>`This ${s?`${s} and ${u}`:u}`;if(!t)return{note:`${i("deletes the event log on disk")} — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.path)return{note:`${i("leaves nothing on disk — this deck keeps no event log")}. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.mine){const u=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,h=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{note:`${i(`leaves the event log alone: ${u}${h}`)}. Clearing here empties this canvas only — restart this deck and the log replays back onto it. Layout, pins and selection go with it.`,confirm:"Clear this canvas"}}if(t.decks<=1)return{note:`${i("deletes this deck's event log")} — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};const a=t.decks-1,l=a===1?"That deck keeps what is on its canvas until it restarts, and then it is gone there too.":"Those decks keep what is on their canvases until they restart, and then it is gone there too.";return{note:`${i(`deletes the event log ${a===1?"1 other running deck shares":`${a} other running decks share`} with this one`)} — every session recorded in it, not just the ones drawn here. ${l} This cannot be undone.`,confirm:"Clear everything"}}function TD({agentCount:e,onConfirm:t,onCancel:n}){const s=S.useRef(null),i=_n(n,{focusRef:s,layer:XL}),[a,l]=S.useState(null);S.useEffect(()=>{let p=!1;return fetch("/api/clear").then(f=>f.ok?f.json():null).then(f=>{p||l(ED(f))}).catch(()=>{}),()=>{p=!0}},[]);const{note:u,confirm:h}=jD(e,a);return d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:i,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"status-dot err","aria-hidden":!0}),d.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:u}),d.jsxs("div",{className:"cc-actions",children:[d.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),d.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const RD="One-key shortcuts run when nothing on the page has focus. A focused control keeps its own keys — this sheet included, which takes the keyboard while it is open — so Esc is the way back to the canvas.",AD=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function MD({onClose:e}){const t=_n(e);return d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:t,className:"modal key-help",onClick:n=>n.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:RD}),d.jsx("div",{className:"shortcuts",children:AD.map(n=>d.jsxs(S.Fragment,{children:[d.jsx("h3",{className:"kh-group",children:n.title}),n.rows.map(s=>d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:s.cap}),d.jsx("span",{children:s.action})]},`${n.title}:${s.cap}:${s.action}`))]},n.title))})]})]})})}const ID=["done","needs-input"],OD=[{id:"two",label:"Two notes",notes:[{at:0,hz:740,ms:90},{at:.085,hz:440,ms:150}]},{id:"arc",label:"Descent",notes:[{at:0,hz:988,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:440,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:740,ms:55},{at:.055,hz:740,ms:55},{at:.165,hz:440,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:988,ms:110},{at:0,hz:740,ms:110},{at:.1,hz:440,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:740,ms:120},{at:.11,hz:440,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:740,ms:55},{at:.06,hz:440,ms:90}]}],PD=[{id:"two",label:"Two notes",notes:[{at:0,hz:440,ms:90},{at:.085,hz:740,ms:150}]},{id:"arc",label:"Ascent",notes:[{at:0,hz:440,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:988,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:440,ms:55},{at:.055,hz:440,ms:55},{at:.165,hz:740,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:440,ms:110},{at:.1,hz:740,ms:170},{at:.1,hz:988,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:440,ms:120},{at:.11,hz:740,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:440,ms:55},{at:.06,hz:740,ms:90}]}],Lw={done:OD,"needs-input":PD},Gi="two";function tw(e,t){const n=Lw[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Gi)??n[0]}function DT(e,t){return Lw[e].some(s=>s.id===t)?t:Gi}tw("done",Gi).notes,tw("needs-input",Gi).notes;const B1=.04,$D=.24,FT=0,qw=100,nw=5,wl=50;function xl(e){if(!Number.isFinite(e))return wl;const t=Math.round(e/nw)*nw;return Math.min(qw,Math.max(FT,t))}function LD(e){if(e==null)return wl;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?xl(Number(t)):wl}function qD(e){const t=xl(e),n=B1+($D-B1)*(t/qw);return Math.round(n*1e4)/1e4}function DD(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(qD(e)*s*1e4)/1e4}const FD=160,zD="agent-dag.soundLevel.done",BD="agent-dag.soundLevel.needs-input",UD="agent-dag.soundFigure.done",WD="agent-dag.soundFigure.needs-input",zT={done:zD,"needs-input":BD},BT={done:UD,"needs-input":WD},rw={done:{level:wl,figure:Gi},"needs-input":{level:wl,figure:Gi}};function HD(e){const t=n=>({level:LD(e(zT[n])),figure:DT(n,e(BT[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const GD={Stop:"done",Notification:"needs-input"};function VD(e,t){var s;if(t)return null;const n=(s=e==null?void 0:e.payload)==null?void 0:s.hook_event_name;return typeof n!="string"?null:GD[n]??null}function YD(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,s=!1;const i=()=>e.enabled()?s&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",a=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,i())};function l(){var h;if(!(!t||s))try{n=n??new t,(h=n.resume)==null||h.call(n).then(a,()=>{}),s=!0,a()}catch{}}function u(h,p=!1){var N;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const f=(((N=e.prefs)==null?void 0:N.call(e))??rw)[h]??rw[h],g=tw(h,f.figure),v=DD(f.level,g),w=n.currentTime;for(const b of g.notes){const k=n.createOscillator(),_=n.createGain();k.type=g.type??"sine",k.frequency.value=b.hz;const E=w+b.at,C=E+b.ms/1e3;_.gain.setValueAtTime(1e-4,E),_.gain.exponentialRampToValueAtTime(v,E+.012),_.gain.exponentialRampToValueAtTime(1e-4,C),k.connect(_).connect(n.destination),k.start(E),k.stop(C+.02)}return!0}return{unlock:l,play:u,state:i,get context(){return n}}}const U1={done:"Turn finished","needs-input":"Claude is asking"},KD={done:"Every finished turn, on both CLIs.","needs-input":"Claude Code only — Codex has no such event."};function XD({onClose:e,soundOn:t,onToggleSound:n,prefs:s,onLevel:i,onFigure:a,onPreview:l,openerRef:u,notifyOn:h,onToggleNotify:p,notifyVetoed:f}){const g=_n(e),v=S.useRef(e);return v.current=e,S.useEffect(()=>{const w=N=>{var k,_;const b=N.target;b&&((k=g.current)!=null&&k.contains(b)||(_=u.current)!=null&&_.contains(b)||v.current())};return window.addEventListener("pointerdown",w,!0),()=>window.removeEventListener("pointerdown",w,!0)},[g,u]),d.jsxs("div",{ref:g,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[d.jsxs("button",{type:"button",className:"btn sm-switch",onClick:n,"aria-pressed":t,children:[d.jsx("span",{className:"sm-switch-label",children:"Sound"}),d.jsx("span",{className:"sm-switch-state",children:t?"on":"off"})]}),d.jsxs("button",{type:"button",className:"btn sm-switch",onClick:p,"aria-pressed":h,title:f?"Recorded for next time: this deck was started with AGENTS_DECK_NO_NOTIFY=1, which overrules the switch":"A system notification when a session blocks on you — from this page while it is behind something, and from the deck itself when no page is open",children:[d.jsx("span",{className:"sm-switch-label",children:"Notifications"}),d.jsx("span",{className:"sm-switch-state",children:f?"off — set at launch":h?"on":"off"})]}),ID.map(w=>{const N=s[w],b=`sm-level-${w}`,k=`sm-figure-${w}`;return d.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${w}`,children:[d.jsxs("div",{className:"sm-tone-head",children:[d.jsx("h3",{className:"sm-tone-name",id:`sm-name-${w}`,children:U1[w]}),d.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>l(w),"aria-label":`Hear the ${U1[w].toLowerCase()} tone`,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:d.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:b,children:"Volume"}),d.jsx("input",{id:b,type:"range",min:FT,max:qw,step:nw,value:N.level,onChange:_=>i(w,Number(_.target.value))}),d.jsxs("span",{className:"sm-read",children:[N.level,"%"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:k,children:"Sound"}),d.jsx("select",{id:k,className:"sm-select",value:N.figure,onChange:_=>a(w,_.target.value),children:Lw[w].map(_=>d.jsx("option",{value:_.id,children:_.label},_.id))})]}),d.jsx("p",{className:"sm-note",children:KD[w]})]},w)}),d.jsx("p",{className:"sm-foot",children:"M turns the sound on and off from anywhere."})]})}const QD={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all."],"3.8.3":[{title:"🪟 Windows: two settings files that could refuse to save",body:`On Windows a file cannot be moved into place while anything else has it open, and Defender and the search indexer open a file the instant it is written. The deck has had a retry for that for a long time, and two files written in the last few days were not using it: the notifications preference, and Browser Watch's episode archive.
78
+ `);return d.jsxs("span",{className:"sysmeter-wrap",children:[d.jsxs("button",{type:"button",ref:i,className:"sysmeter",title:b,"aria-label":"Toggle machine detail","aria-expanded":n,"aria-controls":n?"system-panel":void 0,onClick:()=>s(k=>!k),children:[d.jsxs("span",{className:"sm-box","aria-hidden":!0,children:[d.jsxs("span",{className:"sm-graphic",children:[d.jsx("svg",{className:"sm-spark",width:el,height:Ti,viewBox:`0 0 ${el} ${Ti}`,children:v.map((k,_)=>{const E=w+_,C=Math.max(1,k/100*Ti),j=.32+.68*((_+1)/v.length);return d.jsx("rect",{x:E*N,y:Ti-C,width:Math.max(.8,N-.7),height:C,rx:.5,fill:"var(--accent)",opacity:j},E)})}),d.jsx("span",{className:"sm-ram",children:d.jsx("span",{className:`sm-ram-fill${g?" warn":""}`,style:{transform:`scaleX(${Math.max(2,p.usedPct)/100})`}})})]}),d.jsxs("span",{className:"sm-read",children:[d.jsx("b",{children:l.toFixed(0)}),d.jsx("i",{children:"·"}),d.jsx("b",{children:p.usedPct.toFixed(0)})]})]}),d.jsxs("span",{className:"sm-sr",children:["CPU ",l.toFixed(0)," percent, memory ",p.usedPct.toFixed(0)," percent used"]})]}),n&&d.jsx(y4,{sys:t,usageOpen:e,panelRef:a,onClose:()=>{var k;s(!1),(k=i.current)==null||k.focus()}})]})}function y4({sys:e,usageOpen:t,panelRef:n,onClose:s}){const i=m4(!0),{memory:a,swap:l,perCore:u,loadavg:h,cores:p,uptimeSec:f,platform:g,thermal:v}=e,w=a?a.total-a.available:0,N=g==="win32"?"Commit":"Swap",b=l&&l.total>0?l.used/l.total*100:0;return d.jsxs("aside",{ref:n,className:`sysdetail${t?" shifted":""}`,id:"system-panel","aria-label":"Machine detail",children:[d.jsxs("div",{className:"sd-head",children:[d.jsx("span",{className:"sd-title",children:"This machine"}),d.jsxs("span",{className:"sd-sub",children:["up ",h4(f)," · ",p," cores"]}),d.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),u&&u.length>0&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Cores",children:d.jsx(wu,{group:"cores",title:"Core history",action:"Show core history",label:"Cores",children:d.jsx("div",{className:"sd-cores",style:{"--n":u.length},children:u.map((k,_)=>d.jsx("span",{className:"sd-core",title:`core ${_+1}: ${k}%`,children:d.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,k)/100})`}})},_))})})}),d.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:d.jsxs(wu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a&&d.jsx(Mu,{label:"Physical",value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:vo(w)})," of ",vo(a.total)]}),pct:a.usedPct,tone:a.usedPct>=90?"warn":"calm",note:`${vo(a.available)} available`}),l&&l.total>0&&d.jsx(Mu,{label:N,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:vo(l.used)})," of ",vo(l.total)]}),pct:b,tone:b>=90?"warn":"calm",note:b>=50?"paging to disk":void 0})]})}),h&&d.jsx("div",{className:"sd-section",role:"group","aria-label":"Load average",children:d.jsxs(wu,{group:"load",title:"Load history",action:"Show load history",label:"Load average",children:[d.jsx("div",{className:"sd-load",children:h.map((k,_)=>d.jsxs("span",{className:`sd-load-item${k>p?" over":""}`,children:[d.jsx("b",{children:k.toFixed(2)}),d.jsx("span",{children:["1m","5m","15m"][_]})]},_))}),d.jsx("div",{className:"sd-note",children:h[0]>p?`${(h[0]/p).toFixed(1)}× more work queued than cores to run it`:`within ${p} cores`})]})}),d.jsx(v4,{thermal:v}),d.jsx(w4,{read:i})]})}function wu({group:e,title:t,action:n,label:s,children:i}){const[a,l]=S.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"sd-open",onClick:()=>l(!0),title:n,"aria-label":n,children:[d.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[s," ",d.jsx("i",{className:"sd-row-more",children:"›"})]}),i]}),a&&d.jsx(Jq,{group:e,title:t,onClose:()=>l(!1)})]})}function v4({thermal:e}){if(!e)return null;const t=e.throttle?c4(e.throttle.speedLimit,e.heldBack):null;return d.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:d.jsxs(wu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>d.jsx(Mu,{label:n.label,value:d.jsxs(d.Fragment,{children:[d.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius,tone:l4(n.celsius,n.warnAt,n.critAt)},n.label)),t&&d.jsx(Mu,{label:"Throttling",value:t.value,pct:t.pct,tone:t.tone,note:t.note})]})})}function w4({read:e}){const[t,n]=S.useState(OT),[s,i]=S.useState(!1),a=(e==null?void 0:e.procs)??null;return d.jsxs("div",{className:"sd-section",role:"group","aria-label":"Busiest processes",children:[d.jsxs("div",{className:"sd-hrow",children:[d.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Busiest processes"}),a!=null&&a.length>0&&d.jsxs("button",{type:"button",className:"sd-all",onClick:()=>i(!0),title:"Show every process the deck is watching","aria-label":"Show every process the deck is watching",children:["more ",d.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]})]}),s&&e&&d.jsx(t4,{procs:e.procs,total:e.total,onClose:()=>i(!1)}),a==null?d.jsx("div",{className:"sd-note",children:"reading…"}):a.length===0?d.jsx("div",{className:"sd-note",children:"Could not read the process list on this platform."}):d.jsxs("table",{className:"sd-procs",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx(Di,{col:"cpu",label:"cpu",sort:t,onSort:n}),d.jsx(Di,{col:"mem",label:"mem",sort:t,onSort:n}),d.jsx(Di,{col:"name",label:"process",sort:t,onSort:n})]})}),d.jsx("tbody",{children:i4(a,t).map(l=>d.jsxs("tr",{children:[d.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),d.jsx("td",{className:"sd-num sd-dim",children:l.mem.toFixed(1)}),d.jsx("td",{className:"sd-proc-name",title:`pid ${l.pid}`,children:l.name})]},l.pid))})]})]})}function Di({col:e,label:t,sort:n,onSort:s}){const i=a4(n,e);return d.jsx("th",{scope:"col","aria-sort":i,children:d.jsxs("button",{type:"button",className:"sd-sort",title:`Sort by ${t}`,onClick:()=>s(o4(n,e)),children:[t,d.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:i==="none"?"":i==="ascending"?"↑":"↓"})]})})}function Mu({label:e,value:t,pct:n,tone:s="calm",note:i}){return d.jsxs("div",{className:"sd-row",children:[d.jsxs("div",{className:"sd-row-head",children:[d.jsx("span",{className:"sd-row-label",children:e}),d.jsx("span",{className:"sd-row-val",children:t})]}),d.jsx("span",{className:"sd-track",children:d.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}})}),i&&d.jsx("div",{className:"sd-note",children:i})]})}const R1=18,x4=1100,Ri=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},b4=Array.from({length:R1},(e,t)=>{const n=-72+144*t/(R1-1)+(Ri(t,1)-.5)*9,s=(n-90)*(Math.PI/180),i=(54+32*Math.cos(n*Math.PI/180))*(.74+Ri(t,2)*.52);return{dx:Math.cos(s)*i,dy:Math.sin(s)*i,rot:(t%2?1:-1)*(100+Ri(t,3)*260),delay:Math.round(Ri(t,4)*90),dur:760+Math.round(Ri(t,5)*260),scale:.8+Ri(t,6)*.45,hue:t%4,round:t%3===0}});function A1({anchor:e}){var i;const[t,n]=S.useState(null),s=typeof window<"u"&&((i=window.matchMedia)==null?void 0:i.call(window,"(prefers-reduced-motion: reduce)").matches);return S.useEffect(()=>{if(s)return;const a=e.current;if(!a)return;const l=a.getBoundingClientRect();n({x:l.left+l.width/2,y:l.top+l.height/2});const u=window.setTimeout(()=>n(null),x4);return()=>window.clearTimeout(u)},[e,s]),s||!t?null:mw.createPortal(d.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:b4.map((a,l)=>d.jsx("span",{className:`confetti-bit${a.round?" round":""}`,"data-hue":a.hue,style:{"--dx":`${a.dx.toFixed(1)}px`,"--dy":`${a.dy.toFixed(1)}px`,"--rot":`${a.rot}deg`,"--s":a.scale.toFixed(2),animationDelay:`${a.delay}ms`,animationDuration:`${a.dur}ms, ${a.dur}ms`}},l))}),document.body)}const $T=new Set(["awaiting_url","awaiting_code","registering"]);function k4(e){return e!=null&&$T.has(e)}function LT(e){return e!=null&&e!=="done"&&!$T.has(e)}const _4="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",S4="the sign-in did not complete";function N4({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?_4:S4)}}const E4="done";function C4(){let e=!1;return{shouldAnnounce(t){return t!==E4?(e=!1,!1):e?!1:(e=!0,!0)}}}function Pw(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const j4={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck2:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${Bt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",unreadable_export:"claude-swap wrote something this deck could not read — try again, and upgrade it if this repeats",mixed_versions:"claude-swap changed format part-way through — try again",nothing_to_share:"none of those accounts could be exported",too_many:"that is more accounts than one share can carry",not_in_bundle:"that account is not in this share",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters, and cannot start with a dash",bad_email:"that does not look like an email address — it cannot contain spaces or start with a dash"},T4={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},R4=`claude-swap could not read the login keychain — start ${Bt} from a Terminal window rather than a background service`;function Jv(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Hi(e)))return R4;const n=Pw(T4,e==null?void 0:e.reason);return n||(e==null?void 0:e.reason)||t}function Hi(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const A4={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself so it is on this deck's PATH",bad_override:"AGENTS_DECK_CCUSAGE names a file that is not there — correct it to the full path of your ccusage, or unset it to let the deck find its own",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},M4="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function I4(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const O4="ccusage could not be started — the deck launched npx and Node could not load the npm script it points at. An older deck asked cmd.exe for a bare npx.cmd, which made the shim look for that script under the deck's working directory instead of beside itself; update the deck and reopen this modal",P4="ccusage could not be started — the copy npx fetched will not load: Node could not resolve a file inside it. That copy is in npx's own cache, which the deck never rewrites, so clear it with `npm cache clean --force` and reopen this modal",$4=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),L4=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,q4=/[\\/]_npx[\\/]/i,D4=`the copy of ccusage ${Bt} installed for itself`;function F4(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function z4(e,t){const n=B4(e,t),s=F4(e);switch(e==null?void 0:e.stage){case"npx":return s?`ccusage failed on both of its paths. The managed install failed first — ${s} — and the deck then fell back to npx, where ${tl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${tl(n)}`;case"managed":return`${D4} failed to run: ${tl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${tl(n)}`:`the ccusage this deck found on your PATH failed to run: ${tl(n)}`;default:return n}}const tl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function B4(e,t){const n=Hi(e);if($4(n)){if(q4.test(n))return P4;if(L4.test(n))return O4}if(I4(n))return M4;const s=Pw(A4,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Oi(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&LT(e.state))return e.error;const n=Pw(j4,e==null?void 0:e.reason);return n||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function U4(e,t,n){if(n<=0||Aw(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:s===-1?0:(s+1)%n};case"ArrowLeft":return{kind:"select",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function qT(e,t){const n=Math.round(e/1e3)-t;return n<=0?{text:"expired",tone:"gone"}:n<60?{text:`expires in ${n}s`,tone:"soon"}:{text:`expires in ${Math.round(n/60)}m`,tone:"ok"}}function W4(e){const t=new Map;for(const n of e){const s=(n.email??"").trim().toLowerCase();s&&t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=(n.email??"").trim(),i=n.alias||s||`account ${n.num}`,a=[];return n.alias&&s&&a.push(s),s&&(t.get(s.toLowerCase())??0)>1&&a.push(n.org||`slot ${n.num}`),{num:n.num,label:i,sub:a.length?a.join(" · "):null}})}function H4(e){return e<=0?"Nothing picked yet.":e===1?"1 account — its sign-in token will be on your clipboard.":`${e} accounts — ${e} sign-in tokens will be on your clipboard.`}function G4(e){switch(e){case"imported":return"imported";case"healed":return"dead token replaced";case"updated":return"updated";case"present":return"already here";default:return"not imported"}}function V4(e){const t=e.length;if(!t)return"Nothing to import.";const n=p=>e.filter(f=>f.state===p).length,s=[],i=n("imported");i&&s.push(`${i} of ${t} imported`);const a=n("healed");a&&s.push(`${a} had a dead token replaced`);const l=n("updated");l&&s.push(`${l} updated`);const u=n("present");u&&s.push(`${u} already here`);const h=n("failed");return h&&s.push(`${h} did not arrive`),`${s.join(", ")}.`}const Y4=1500,iu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],M1="aa-panel",I1=e=>`aa-tab-${e}`;async function nl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const ew=fe.forwardRef((e,t)=>d.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[d.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),d.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));ew.displayName="SuccessMark";function K4({onClose:e,onChanged:t}){const[n,s]=S.useState("login"),[i,a]=S.useState(null),[l,u]=S.useState(""),[h,p]=S.useState(""),[f,g]=S.useState(!1),[v,w]=S.useState(null),[N,b]=S.useState(null),[k,_]=S.useState(null),[E,C]=S.useState(null),j=S.useRef(""),I=S.useRef(!1),O=S.useRef(!1),P=S.useRef(null),z=S.useRef(null),M=S.useRef(null),A=S.useRef(null),q=S.useRef([]),G=S.useRef(!1),Y=S.useCallback(()=>{I.current&&nl({action:"login-cancel"}).catch(()=>{}),e()},[e]),R=_n(Y,{focusRef:M}),Q=S.useCallback(async()=>{if(!ar(O.current))return;O.current=!0,g(!0),w(null),I.current=!0;const L=await nl({action:"login"}).catch(()=>null);if(O.current=!1,g(!1),!(L!=null&&L.ok)){w(Oi(L,"could not start the sign-in"));return}a(L)},[]);S.useEffect(()=>{if(!k4(i==null?void 0:i.state))return;const L=window.setInterval(async()=>{try{const K=await fetch("/api/claude-accounts/login");K.ok&&a(await K.json())}catch{}},Y4);return()=>window.clearInterval(L)},[i]);const H=S.useRef(t);H.current=t;const ne=S.useState(C4)[0];S.useEffect(()=>{var L;(i==null?void 0:i.state)==="awaiting_code"&&((L=P.current)==null||L.focus()),ne.shouldAnnounce(i==null?void 0:i.state)&&H.current()},[i==null?void 0:i.state,ne]),S.useEffect(()=>{var L;n==="paste"&&!G.current&&((L=z.current)==null||L.focus()),G.current=!1},[n]);const X=S.useCallback(L=>{var se;const K=U4(L,iu.findIndex(he=>he.id===n),iu.length);K.kind!=="pass"&&(L.preventDefault(),G.current=!0,s(iu[K.index].id),(se=q.current[K.index])==null||se.focus())},[n]),U=S.useCallback(async()=>{var K;if(!ar(O.current))return;O.current=!0,g(!0),w(null);const L=await nl({action:"login-code",code:l}).catch(()=>null);if(O.current=!1,g(!1),!(L!=null&&L.ok)){w(Oi(L,"the code was not accepted")),L!=null&&L.state&&a(L),(K=P.current)==null||K.select();return}u(""),a(L)},[l,i]),J=S.useCallback(async()=>{if(!ar(O.current))return;O.current=!0,g(!0),w(null);const L=await nl({action:"import",blob:h}).catch(()=>null);if(O.current=!1,g(!1),!(L!=null&&L.ok)){w(Oi(L,"the import failed"));return}j.current=h,p(""),C(null),b(L.results??[]),t()},[h,t]),$=S.useCallback(async L=>{const K=`${L.email}|${L.org??""}`;if(!ar(O.current)||!j.current)return;O.current=!0,g(!0),_(K),C(null);const se=await nl({action:"import",blob:j.current,force:!0,only:{email:L.email,org:L.org??""}}).catch(()=>null);if(O.current=!1,g(!1),_(null),!(se!=null&&se.ok)){C({key:K,text:Oi(se,"that account could not be updated")});return}const he=(se.results??[])[0];he&&b(me=>me&&me.map(xe=>`${xe.email}|${xe.org??""}`===K?he:xe)),t()},[t]),V=(i==null?void 0:i.state)==="done"?i.account:null,Z=LT(i==null?void 0:i.state)||!!(v&&I.current&&!f),D=N4({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:v});return d.jsx("div",{className:"modal-backdrop",onClick:Y,role:"presentation",children:d.jsxs("div",{ref:R,className:"modal aa-modal",onClick:L=>L.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:X,children:iu.map((L,K)=>d.jsx("button",{type:"button",role:"tab",id:I1(L.id),ref:se=>{q.current[K]=se},"aria-selected":n===L.id,"aria-controls":M1,tabIndex:n===L.id?0:-1,className:`aa-tab${n===L.id?" on":""}`,onClick:()=>{G.current=!1,s(L.id)},children:L.label},L.id))})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:Y,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body aa-body",id:M1,role:"tabpanel","aria-labelledby":I1(n),children:n==="login"?V?d.jsxs("div",{className:"aa-done",children:[d.jsx(ew,{ref:A}),d.jsx(A1,{anchor:A}),d.jsx("h4",{children:V.added?`Account ${V.num} added`:"Credentials refreshed"}),d.jsxs("p",{className:"aa-note",children:[d.jsx("strong",{children:V.email}),V.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),d.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(i==null?void 0:i.state)==="awaiting_code"||(i==null?void 0:i.state)==="registering"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"1 · Approve in the browser"}),d.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),d.jsx("a",{className:"aa-link",href:i.url??"#",target:"_blank",rel:"noreferrer noopener",children:i.url})]}),d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),d.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:P,type:"text",value:l,onChange:L=>u(L.target.value),onKeyDown:L=>{L.key==="Enter"&&l.trim()&&!f&&U()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:i.state==="registering"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!l.trim()||i.state==="registering"),onClick:U,children:i.state==="registering"?"registering…":"Continue"})]}),(v||i.error)&&d.jsx("p",{className:"aa-err",children:v??i.error}),d.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):Z?d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:D.title}),d.jsx("p",{className:"aa-err",children:D.message}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{I.current=!1,a(null),w(null),Q()},children:"Try again"})]}):f||I.current?d.jsx("div",{className:"aa-step",children:d.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):d.jsxs("div",{className:"aa-step aa-primer",children:[d.jsx("h4",{children:"Sign in to Anthropic"}),d.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),d.jsx("div",{className:"aa-actions",children:d.jsx("button",{type:"button",ref:M,className:"btn primary",onClick:Q,children:"Open the sign-in page"})})]}):N?(()=>{const L=N.filter(K=>K.state==="imported").length;return d.jsxs("div",{className:"aa-done",children:[d.jsx(ew,{ref:A}),L>0&&d.jsx(A1,{anchor:A}),d.jsx("h4",{children:V4(N)}),N.length>0&&d.jsx("ul",{className:"aa-results",children:N.map(K=>{const se=`${K.email}|${K.org??""}`;return d.jsxs("li",{className:`aa-result ${K.state}`,children:[d.jsx("span",{className:"aa-result-who",children:K.email||(K.num?`slot ${K.num}`:"an account")}),d.jsx("span",{className:"aa-result-what",children:G4(K.state)}),K.state==="present"&&d.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":k===se,title:`Overwrite the stored login for ${K.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>$(K),children:k===se?"updating…":"update anyway"}),(E==null?void 0:E.key)===se&&d.jsx("span",{className:"aa-result-err",children:E.text})]},se)})}),d.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",d.jsx("strong",{children:" update anyway"}),"."]}),d.jsxs("div",{className:"aa-actions",children:[d.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{j.current="",C(null),b(null)},children:"Import another"})]})]})})():d.jsxs("div",{className:"aa-step",children:[d.jsx("h4",{children:"Paste an account shared from another deck"}),d.jsxs("div",{className:"aa-field",children:[d.jsx("input",{ref:z,type:"text",value:h,onChange:L=>p(L.target.value),onKeyDown:L=>{L.key==="Enter"&&h.trim()&&!f&&J()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),d.jsx("button",{type:"button",className:"btn primary",...ir(f,!h.trim()),onClick:J,children:f?"importing…":"Import"})]}),v&&d.jsx("p",{className:"aa-err",children:v}),d.jsxs("p",{className:"aa-note",children:["Use ",d.jsx("strong",{children:"share"})," on one account in the other deck, or ",d.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})})}async function X4(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Q4=1800;function Z4({accounts:e,onClose:t,copyText:n}){const[s,i]=S.useState([]),[a,l]=S.useState(null),[u,h]=S.useState(!1),[p,f]=S.useState(null),[g,v]=S.useState(!1),[w,N]=S.useState(()=>Math.floor(Date.now()/1e3)),b=S.useRef(null),k=S.useRef(!1),_=_n(t,{focusRef:b});S.useEffect(()=>{if(!a)return;N(Math.floor(Date.now()/1e3));const A=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(A)},[a]);const E=W4(e),C=e.filter(A=>!s.includes(A.num)).map(A=>A.num),j=C.length===e.length,I=A=>i(q=>q.includes(A)?q.filter(G=>G!==A):[...q,A]),O=S.useCallback(async()=>{if(!ar(k.current)||!C.length)return;k.current=!0,h(!0),f(null),v(!1);const A=await X4({action:"share",accounts:C}).catch(()=>null);if(k.current=!1,h(!1),!(A!=null&&A.ok)){f(Oi(A,"the share could not be made"));return}l({blob:A.blob,expiresAt:A.expiresAt,shared:A.shared??[],failed:A.failed??[]})},[e,C]),P=a?qT(a.expiresAt,w):null,z=(P==null?void 0:P.tone)==="gone",M=(a==null?void 0:a.shared.length)??0;return d.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:d.jsxs("div",{ref:_,className:"modal sa-modal",onClick:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("h3",{children:"Share accounts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsx("section",{className:"modal-body sa-body",children:a?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:z?"This share has expired":M===1?"1 account, ready to paste":`${M} accounts, ready to paste`}),d.jsx("code",{className:`ap-share-blob${z?" sa-dead":""}`,children:a.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(z){l(null),O();return}await n(a.blob)&&(v(!0),window.setTimeout(()=>v(!1),Q4))},children:z?"make a new share":g?"copied":`copy ${M===1?"the share":"all "+M}`}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:M===1?"this is the password":`this is ${M} passwords`})," · ",d.jsx("span",{className:`ap-share-expiry ${P==null?void 0:P.tone}`,children:P==null?void 0:P.text})]})]}),a.failed.length>0&&d.jsxs("div",{className:"sa-failed",role:"alert",children:[d.jsx("p",{className:"sa-failed-head",children:a.failed.length===1?"One account is not in this bundle:":`${a.failed.length} accounts are not in this bundle:`}),d.jsx("ul",{className:"sa-list",children:a.failed.map(A=>{var G;const q=!!(A.email&&((G=A.detail)!=null&&G.includes(A.email)));return d.jsxs("li",{children:[!q&&d.jsx("span",{className:"sa-who",children:A.email||`account ${A.num}`}),d.jsx("span",{className:"sa-why",children:A.detail||"could not be exported"})]},`${A.num}-${A.email}`)})})]}),d.jsx("p",{className:"sa-note",children:z?d.jsx(d.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):d.jsxs(d.Fragment,{children:["Paste it into the other deck with ",d.jsx("strong",{children:"+"})," → ",d.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>{l(null),v(!1)},children:"Pick again"}),d.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?d.jsxs("div",{className:"sa-step",children:[d.jsx("h4",{children:"Nothing to share"}),d.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",d.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),d.jsx("div",{className:"sa-actions",children:d.jsx("button",{type:"button",className:"btn primary",ref:b,onClick:t,children:"Close"})})]}):d.jsxs("div",{className:"sa-step",children:[d.jsxs("h4",{children:["Which accounts go to the other ",Bt,"?"]}),d.jsx("p",{className:`sa-count${C.length?"":" empty"}`,children:H4(C.length)}),d.jsx("ul",{className:"sa-list sa-pick",children:E.map(A=>d.jsx("li",{children:d.jsxs("label",{className:"sa-row",children:[d.jsx("input",{type:"checkbox",checked:C.includes(A.num),onChange:()=>I(A.num)}),d.jsx("span",{className:"sa-who",children:A.label}),A.sub&&d.jsx("span",{className:"sa-sub",children:A.sub})]})},A.num))}),p&&d.jsx("p",{className:"aa-err",children:p}),d.jsxs("div",{className:"sa-actions",children:[d.jsx("button",{type:"button",className:"btn",onClick:()=>i(j?e.map(A=>A.num):[]),children:j?"Clear all":"Select all"}),d.jsx("button",{type:"button",className:"btn primary",ref:b,...ir(u,!C.length),onClick:O,children:u?"making the share…":C.length===0?"Share":C.length===1?"Share 1 account":`Share ${C.length} accounts`})]})]})})]})})}function J4(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((i,a)=>i-a).map(i=>{const a=i===t?"here":n.has(i)?"swap":"free";return{slot:i,kind:a,label:a==="here"?`slot ${i}`:`slot ${i} · ${a}`}})}function eD(e,t,n){if(!(n!=null&&n.ok))return null;const s=Number.isInteger(n.to)?n.to:null;if(s==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const i=n.swapped===!0&&s!==t;return{menuFor:e.menuFor===t?s:i&&e.menuFor===s?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:i?{at:s,displaced:t}:null}}function tD(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function nD(e,t,n){var i;const s=((i=e.find(a=>a.slot===t))==null?void 0:i.kind)??"here";return s==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:s==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function rD(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:`Switch the active account out once it passes ${e}% of its limit.`}}function O1(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function P1(e){const t=e.filter(u=>!O1(u)),n=e.filter(u=>O1(u)),s=t.length?t:n,i=t.length?n:[],a=s.reduce((u,h)=>u&&u.pct>=h.pct?u:h,null);let l=null;for(const u of i)a&&u.pct<=a.pct||(!l||u.pct>l.pct)&&(l=u);return{shown:s,rest:i,fuller:l,peak:l??a}}function sD(e,t,n){return e<1?null:t?"fewer":n?`${n.label} ${Math.round(n.pct)}%`:`${e} more`}function oD(e,t,n,s){const i=e==null?"No usage has been collected for this account yet.":`${Math.round(e)}% left on ${t??"the window that runs out first"}, which is the one that runs out first.`,a=n===1?"the other window":`the other ${n} windows`;return`${i} ${s?"Hide":"Show"} ${a}.`}const iD="\0";function $w(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${iD}${n}`}function aD(e,t){const n=$w(t);return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function lD(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map($w)),s=e.filter(i=>n.has(i));return s.length===e.length?e:s}const cD=64;function uD(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const dD=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function $1(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function fD(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=Hi(t.body);return{text:Jv(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function L1(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}const q1=15e3,hD=8e3,oh=1800,pD=3e4,mD=[70,80,85,90,95];function D1(e,t){return jT(t-Math.floor(e/1e3))}function gD(e,t){if(!e)return"";const n=Math.floor(e/1e3)-t;return n<=0?" · due":n<60?` · next in ${n}s`:` · next in ${Math.round(n/60)}m`}function yD(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function F1({lane:e,nowSec:t}){const n=Math.min(100,Math.max(0,e.pct)),s=n>=90?"var(--err)":n>=70?"var(--warn)":"var(--accent)",i=e.resetAt?TT(e.resetAt,t):null;return d.jsxs("div",{className:"ap-lane",children:[d.jsx("span",{className:"ap-lane-label",children:e.label}),d.jsx("div",{className:"ap-lane-track",children:d.jsx("div",{className:"ap-lane-fill",style:{width:`${n===0?1.5:n}%`,background:s,opacity:n===0?.4:1}})}),d.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[n,"%"]}),d.jsx("span",{className:"ap-lane-reset",children:i?`resets ${i}`:""})]})}async function z1(e){var n;let t=!1;try{t=await Promise.race([((n=navigator.clipboard)==null?void 0:n.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{t=!1}if(t)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),t=document.execCommand("copy"),s.remove()}catch{t=!1}return t}function vD({onClose:e}){var Ge,it,ke,ct,It;const[t,n]=S.useState(null),[s,i]=S.useState(null),[a,l]=S.useState(null),[u,h]=S.useState(!1),[p,f]=S.useState(null),[g,v]=S.useState(()=>Math.floor(Date.now()/1e3)),w=S.useRef(null),[N,b]=S.useState(null),[k,_]=S.useState(!1),[E,C]=S.useState(""),[j,I]=S.useState(null),[O,P]=S.useState(null),[z,M]=S.useState(null),[A,q]=S.useState(!1),[G,Y]=S.useState(!1),[R,Q]=S.useState(null),[H,ne]=S.useState(null),[X,U]=S.useState(null),[J,$]=S.useState(null),[V,Z]=S.useState(!1),[D,L]=S.useState([]),K=S.useRef(null),se=S.useCallback(ae=>AT(K.current)?(K.current=ae,l(ae),!0):!1,[]),he=S.useCallback(()=>{K.current=null,l(null)},[]),me=(ae,Le=!1)=>{const ze=RT(a,ae);return{disabled:ze.disabled,"aria-busy":ze.busy||Le}},xe=S.useCallback(ae=>{window.requestAnimationFrame(()=>{var Le;if(Iq(((Le=document.activeElement)==null?void 0:Le.tagName)??null))for(const ze of Mq(ae)){const Ce=document.querySelector(ze);if(Ce){Ce.focus();return}}})},[]),Ee=S.useCallback(async(ae=!1)=>{ae&&h(!0);const Le=new AbortController,ze=window.setTimeout(()=>Le.abort(),pD);try{const[Ce,Ve]=await Promise.all([fetch(`/api/claude-accounts${ae?"?refresh=1":""}`,{signal:Le.signal}),fetch("/api/cswap-auto",{signal:Le.signal})]);if(Ce.ok){const rt=await Ce.json();n(rt),L(Te=>lD(Te,rt.accounts))}Ve.ok&&i(await Ve.json());const Ct=fD([await $1(Ce),await $1(Ve)]);f(rt=>L1(rt,Ct))}catch{f(Ce=>L1(Ce,dD))}finally{window.clearTimeout(ze),ae&&h(!1)}},[]),He=S.useCallback(async(ae,Le)=>{if(!se(Le))return null;f(null);try{const Ce=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)})).json().catch(()=>null);return Ce!=null&&Ce.ok||f({text:Jv(Ce,"command failed"),raw:Hi(Ce)}),Ce}catch{return f({text:"server unreachable"}),null}finally{he()}},[se,he]),Fe=S.useCallback(async(ae,Le)=>{if(!se(Le))return null;f(null);try{const Ce=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)})).json().catch(()=>null);return Ce!=null&&Ce.ok||f({text:Oi(Ce,"command failed")}),Ce}catch{return f({text:"server unreachable"}),null}finally{he()}},[se,he]);S.useEffect(()=>(Ee(!0),w.current=window.setInterval(()=>Ee(!1),q1),()=>{w.current!=null&&window.clearInterval(w.current)}),[Ee]),S.useEffect(()=>{const ae=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ae)},[]);const Ie=((Ge=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Ge.value)??"90",be=J??Ie,ue=rD(be,Ie),re=(it=t==null?void 0:t.accounts)==null?void 0:it.find(ae=>ae.active),pe=((ke=P1((re==null?void 0:re.lanes)??[]).peak)==null?void 0:ke.pct)??null,Oe=pe!=null&&pe>=Number(Ie)-15,nt=async ae=>{if(se(`switch-${ae}`)){f(null);try{const ze=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:ae})})).json().catch(()=>null);ze!=null&&ze.ok||f({text:Jv(ze,"the switch failed"),raw:Hi(ze)}),await Ee(!0)}catch{f({text:"server unreachable"})}finally{he(),xe(ae)}}},st=async(ae,Le)=>{const{commit:ze,alias:Ce}=uD(E,Le);if(ze){const Ve=await Fe({action:"alias",account:ae,alias:Ce},`alias-${ae}`);if(await Ee(!0),!(Ve!=null&&Ve.ok))return;C(Ce)}I(ae),window.setTimeout(()=>I(Ve=>Ve===ae?null:Ve),oh)},Xe=async(ae,Le)=>{const ze=await Fe({action:"move",account:ae,slot:Le},`move-${ae}`),Ce=eD({menuFor:N,shareFor:(z==null?void 0:z.num)??null},ae,ze);if(await Ee(!0),Ce){b(Ce.menuFor),P(Ce.confirmRemove),Ce.shareFor==null&&(M(null),Y(!1)),Q(Ce.swapNote);const Ve=Ce.swapNote;Ve&&window.setTimeout(()=>Q(Ct=>Ct===Ve?null:Ct),hD),ne(null),xe(Ce.menuFor)}return ze},Pe=async(ae,Le,ze)=>{if(ze.sends){const Ce=await Xe(ae,Le);if(!(Ce!=null&&Ce.ok))return}U(ae),window.setTimeout(()=>U(Ce=>Ce===ae?null:Ce),oh)},Ue=async(ae,Le)=>{if(Le.sends){const ze=await He({action:"setting",key:"autoswitch.threshold",value:ae},"threshold");if(await Ee(!0),!(ze!=null&&ze.ok))return;$(null)}Z(!0),window.setTimeout(()=>Z(!1),oh)};return d.jsxs("aside",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[d.jsxs("div",{className:"ap-header",children:[d.jsx("h2",{children:"Accounts"}),d.jsxs("div",{className:"ap-header-right",children:[d.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>_(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),(((ct=t==null?void 0:t.accounts)==null?void 0:ct.length)??0)>0&&d.jsx("button",{type:"button",className:"glyph-btn ap-share-set",onClick:()=>q(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${Bt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:"↗"}),d.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>Ee(!0),...me("reload",u),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:u?"…":"↻"}),d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),t==null?p?d.jsxs("div",{className:"ap-empty",role:"alert",children:[d.jsx("span",{title:p.raw||void 0,children:p.text}),d.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",q1/1e3," seconds."]}),d.jsx("button",{type:"button",className:"ap-fix",disabled:u,onClick:()=>Ee(!0),children:u?"trying…":"try again"})]}):d.jsx("div",{className:"ap-empty",children:"Checking…"}):t.ok?d.jsxs(d.Fragment,{children:[(It=t.accounts)==null?void 0:It.map(ae=>{const{shown:Le,rest:ze,fuller:Ce,peak:Ve}=P1(ae.lanes),Ct=D.includes($w(ae)),rt=sD(ze.length,Ct,Ce);return d.jsxs("div",{className:`ap-account${ae.active?" active":""}`,children:[d.jsxs("div",{className:"ap-account-head",children:[d.jsx("span",{className:"ap-num",children:ae.num}),ae.alias&&d.jsx("span",{className:"ap-alias",title:ae.alias,children:ae.alias}),d.jsx("span",{className:"ap-email",title:ae.email??void 0,children:ae.email}),d.jsx("button",{type:"button",id:`ap-more-${ae.num}`,className:`ap-more${N===ae.num?" on":""}`,"aria-label":`Manage account ${ae.num}`,"aria-expanded":N===ae.num,"aria-controls":N===ae.num?`ap-manage-${ae.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{b(N===ae.num?null:ae.num),C(ae.alias??""),P(null),M(null),Y(!1),Q(null),I(null),ne(null),U(null)},children:"⋯"}),ae.active&&d.jsx("span",{className:"ap-badge-active",children:"active"}),ae.disabled&&d.jsx("span",{className:"ap-badge-held",children:"held out"}),!ae.active&&!ae.disabled&&d.jsx("button",{type:"button",className:"ap-manage-btn ap-switch",...me(`switch-${ae.num}`),onClick:()=>nt(ae.num),title:`Switch to ${ae.alias??ae.email}`,children:a===`switch-${ae.num}`?"…":"switch"})]}),d.jsx("div",{className:"ap-lanes",id:`ap-lanes-${ae.num}`,children:Le.length?d.jsxs(d.Fragment,{children:[Le.map(Te=>d.jsx(F1,{lane:Te,nowSec:g},Te.id)),Ct&&ze.map(Te=>d.jsx(F1,{lane:Te,nowSec:g},Te.id))]}):d.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),d.jsxs("div",{className:"ap-meta",children:[ae.staleCopy&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-stale-copy",title:"The deck can still see this account — its live usage is being read — but claude-swap's own stored copy of the login was rejected, so these numbers stopped updating. Resume re-captures the copy from the login you already have.",children:"numbers paused"}),d.jsx("button",{type:"button",className:"ap-fix",...me("recapture"),onClick:async()=>{const Te=await Fe({action:"recapture"},"recapture");Te!=null&&Te.ok&&Ee(!0)},title:"Re-capture this account's stored credentials from the login you already have. No sign-in, no switch.",children:a==="recapture"?"resuming…":"resume"})]}),ae.error&&(()=>{const Te=yD(ae.error);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ap-err",title:Te.hint,children:Te.text}),Te.fixable&&d.jsx("button",{type:"button",className:"ap-fix",onClick:()=>_(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),rt&&d.jsx("button",{type:"button",className:"ap-lanes-more","aria-expanded":Ct,"aria-controls":`ap-lanes-${ae.num}`,title:oD(ae.headroom,(Ve==null?void 0:Ve.label)??null,ze.length,Ct),onClick:()=>L(Te=>aD(Te,ae)),children:rt}),(((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!ae.active||ae.disabled)&&d.jsx("button",{type:"button",className:"ap-rotate",...me(`rot-${ae.num}`),onClick:()=>He({action:"account",account:ae.num,enabled:ae.disabled},`rot-${ae.num}`).then(()=>Ee(!0)),title:ae.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:ae.disabled?"put back":"hold out"}),ae.fetchedAt?d.jsxs("span",{className:`ap-age${ae.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",D1(ae.fetchedAt,g),gD(ae.nextAt,g)]}):d.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),N===ae.num&&d.jsxs("div",{className:"ap-manage",id:`ap-manage-${ae.num}`,role:"group","aria-label":`Manage account ${ae.num}`,children:[d.jsxs("div",{className:"ap-manage-name",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${ae.num}`,children:"Alias"}),d.jsx("input",{id:`ap-alias-${ae.num}`,className:"ap-manage-input",type:"text",value:E,onChange:Te=>C(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&st(ae.num,ae.alias)},maxLength:cD,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`alias-${ae.num}`),onClick:()=>st(ae.num,ae.alias),title:"A short name to show instead of the email",children:j===ae.num?"saved":"save"})]}),(()=>{const Te=J4((t.accounts??[]).map(St=>St.num),ae.num),wt=tD(Te,H,ae.num),dt=nD(Te,wt,ae.num);return d.jsxs("div",{className:"ap-manage-slot",children:[d.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${ae.num}`,children:"Slot"}),d.jsx("span",{className:"ap-field",children:d.jsx("select",{id:`ap-slot-${ae.num}`,value:String(wt),...me(`move-${ae.num}`),onChange:St=>ne(Number(St.target.value)),children:Te.map(St=>d.jsx("option",{value:St.slot,children:St.label},St.slot))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`move-${ae.num}`),title:dt.title,onClick:()=>Pe(ae.num,wt,dt),children:X===ae.num?dt.done:dt.label})]})})(),d.jsxs("div",{className:"ap-manage-acts",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ae.num}`),title:`Copy this account to another ${Bt}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:async()=>{Y(!1);const Te=await Fe({action:"share",account:ae.num},`share-${ae.num}`);Te!=null&&Te.ok&&M({num:ae.num,blob:Te.blob,expiresAt:Te.expiresAt})},children:"share"}),d.jsx("button",{type:"button",className:`ap-manage-btn danger${O===ae.num?" armed":""}`,...me(`rm-${ae.num}`),title:O===ae.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(O!==ae.num){P(ae.num),window.setTimeout(()=>P(Te=>Te===ae.num?null:Te),4e3);return}P(null),Fe({action:"remove",account:ae.num},`rm-${ae.num}`).then(()=>{b(null),Ee(!0),xe(null)})},children:O===ae.num?"confirm":"remove"})]}),(R==null?void 0:R.at)===ae.num&&(()=>{var dt;const Te=(dt=t.accounts)==null?void 0:dt.find(St=>St.num===R.displaced),wt=(Te==null?void 0:Te.alias)??(Te==null?void 0:Te.email)??"the account that was there";return d.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${R.at} was taken, so the two accounts traded places: ${wt} now holds slot ${R.displaced}.`,children:["swapped with slot ",R.displaced]})})(),(z==null?void 0:z.num)===ae.num&&(()=>{const Te=qT(z.expiresAt,g),wt=Te.tone==="gone";return d.jsxs("div",{className:`ap-share${wt?" expired":""}`,children:[d.jsx("code",{className:"ap-share-blob",children:z.blob}),d.jsxs("div",{className:"ap-share-foot",children:[d.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ae.num}`),onClick:async()=>{if(wt){Y(!1);const dt=await Fe({action:"share",account:ae.num},`share-${ae.num}`);dt!=null&&dt.ok&&M({num:ae.num,blob:dt.blob,expiresAt:dt.expiresAt});return}await z1(z.blob)&&(Y(!0),window.setTimeout(()=>Y(!1),1800))},children:wt?"make a new share":G?"copied":"copy"}),d.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[d.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",d.jsx("span",{className:`ap-share-expiry ${Te.tone}`,children:Te.text})]})]})]})})()]})]},ae.num)}),(s==null?void 0:s.ok)&&d.jsxs("div",{className:"ap-auto",children:[d.jsxs("div",{className:"ap-auto-head",children:[d.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),d.jsxs("span",{className:"ap-auto-ctl",children:[pe!=null&&d.jsxs("span",{className:`ap-auto-now${Oe?" near":""}`,children:[Math.round(pe),"%"]}),d.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:d.jsx("select",{"aria-label":"Switch threshold",value:be,...me("threshold"),onChange:ae=>$(ae.target.value),children:mD.map(ae=>d.jsxs("option",{value:ae,children:[ae,"%"]},ae))})}),d.jsx("button",{type:"button",className:"ap-manage-btn",...me("threshold"),title:ue.title,onClick:()=>Ue(be,ue),children:V?ue.done:ue.label}),d.jsxs("button",{type:"button",className:`ap-auto-state${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,"aria-label":"Auto-switch",...me("enable"),onClick:()=>He({action:"enable",enabled:!s.enabled},"enable").then(()=>Ee(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[d.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&d.jsxs("p",{className:"ap-auto-note",children:[d.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",d.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&d.jsx("div",{className:"ap-auto-foot",children:d.jsxs("span",{className:"ap-auto-result",children:["checked ",D1(s.lastTick.at,g)]})})]}),p&&d.jsxs("div",{className:"ap-failure",role:"alert",children:[d.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),d.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),d.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"These numbers only update while this panel is open."})]}):d.jsx("div",{className:"ap-empty",children:t.reason==="no_cswap"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"claude-swap isn't installed."}),d.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),t.hint&&d.jsx("code",{className:"ap-cmd",children:t.hint}),d.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",d.jsx("strong",{children:"+"})," button above."]})]}):t.reason==="no_accounts"?d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"No accounts added yet."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",d.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Couldn't read the account store."}),d.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",t.reason?` (${t.reason})`:"","."]})]})}),k&&d.jsx(K4,{onClose:()=>_(!1),onChanged:()=>Ee(!0)}),A&&d.jsx(Z4,{accounts:((t==null?void 0:t.accounts)??[]).map(ae=>({num:ae.num,email:ae.email,alias:ae.alias,org:ae.org})),onClose:()=>q(!1),copyText:z1})]})}const wD=3e4;function xD({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function bD({bundle:e,running:t,pending:n,lastTried:s}){return t?xD({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function kD(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function _D({asked:e,reported:t}){return t?t!==e:!1}function SD(e){const t=e.thresholdMs??wD;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=t}}function ND(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function ED(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function CD(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function jD(e,t){const n=CD(e),s=n?`removes ${n} on the canvas`:null,i=u=>`This ${s?`${s} and ${u}`:u}`;if(!t)return{note:`${i("deletes the event log on disk")} — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.path)return{note:`${i("leaves nothing on disk — this deck keeps no event log")}. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.mine){const u=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,h=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{note:`${i(`leaves the event log alone: ${u}${h}`)}. Clearing here empties this canvas only — restart this deck and the log replays back onto it. Layout, pins and selection go with it.`,confirm:"Clear this canvas"}}if(t.decks<=1)return{note:`${i("deletes this deck's event log")} — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};const a=t.decks-1,l=a===1?"That deck keeps what is on its canvas until it restarts, and then it is gone there too.":"Those decks keep what is on their canvases until they restart, and then it is gone there too.";return{note:`${i(`deletes the event log ${a===1?"1 other running deck shares":`${a} other running decks share`} with this one`)} — every session recorded in it, not just the ones drawn here. ${l} This cannot be undone.`,confirm:"Clear everything"}}function TD({agentCount:e,onConfirm:t,onCancel:n}){const s=S.useRef(null),i=_n(n,{focusRef:s,layer:XL}),[a,l]=S.useState(null);S.useEffect(()=>{let p=!1;return fetch("/api/clear").then(f=>f.ok?f.json():null).then(f=>{p||l(ED(f))}).catch(()=>{}),()=>{p=!0}},[]);const{note:u,confirm:h}=jD(e,a);return d.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:d.jsxs("div",{ref:i,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"status-dot err","aria-hidden":!0}),d.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:u}),d.jsxs("div",{className:"cc-actions",children:[d.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),d.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const RD="One-key shortcuts run when nothing on the page has focus. A focused control keeps its own keys — this sheet included, which takes the keyboard while it is open — so Esc is the way back to the canvas.",AD=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function MD({onClose:e}){const t=_n(e);return d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:t,className:"modal key-help",onClick:n=>n.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsx("div",{className:"modal-title",children:d.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),d.jsx("div",{className:"modal-actions",children:d.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),d.jsxs("section",{className:"modal-body",children:[d.jsx("p",{className:"modal-note",children:RD}),d.jsx("div",{className:"shortcuts",children:AD.map(n=>d.jsxs(S.Fragment,{children:[d.jsx("h3",{className:"kh-group",children:n.title}),n.rows.map(s=>d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:s.cap}),d.jsx("span",{children:s.action})]},`${n.title}:${s.cap}:${s.action}`))]},n.title))})]})]})})}const ID=["done","needs-input"],OD=[{id:"two",label:"Two notes",notes:[{at:0,hz:740,ms:90},{at:.085,hz:440,ms:150}]},{id:"arc",label:"Descent",notes:[{at:0,hz:988,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:440,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:740,ms:55},{at:.055,hz:740,ms:55},{at:.165,hz:440,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:988,ms:110},{at:0,hz:740,ms:110},{at:.1,hz:440,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:740,ms:120},{at:.11,hz:440,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:740,ms:55},{at:.06,hz:440,ms:90}]}],PD=[{id:"two",label:"Two notes",notes:[{at:0,hz:440,ms:90},{at:.085,hz:740,ms:150}]},{id:"arc",label:"Ascent",notes:[{at:0,hz:440,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:988,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:440,ms:55},{at:.055,hz:440,ms:55},{at:.165,hz:740,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:440,ms:110},{at:.1,hz:740,ms:170},{at:.1,hz:988,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:440,ms:120},{at:.11,hz:740,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:440,ms:55},{at:.06,hz:740,ms:90}]}],Lw={done:OD,"needs-input":PD},Gi="two";function tw(e,t){const n=Lw[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Gi)??n[0]}function DT(e,t){return Lw[e].some(s=>s.id===t)?t:Gi}tw("done",Gi).notes,tw("needs-input",Gi).notes;const B1=.04,$D=.24,FT=0,qw=100,nw=5,wl=50;function xl(e){if(!Number.isFinite(e))return wl;const t=Math.round(e/nw)*nw;return Math.min(qw,Math.max(FT,t))}function LD(e){if(e==null)return wl;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?xl(Number(t)):wl}function qD(e){const t=xl(e),n=B1+($D-B1)*(t/qw);return Math.round(n*1e4)/1e4}function DD(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(qD(e)*s*1e4)/1e4}const FD=160,zD="agent-dag.soundLevel.done",BD="agent-dag.soundLevel.needs-input",UD="agent-dag.soundFigure.done",WD="agent-dag.soundFigure.needs-input",zT={done:zD,"needs-input":BD},BT={done:UD,"needs-input":WD},rw={done:{level:wl,figure:Gi},"needs-input":{level:wl,figure:Gi}};function HD(e){const t=n=>({level:LD(e(zT[n])),figure:DT(n,e(BT[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const GD={Stop:"done",Notification:"needs-input"};function VD(e,t){var s;if(t)return null;const n=(s=e==null?void 0:e.payload)==null?void 0:s.hook_event_name;return typeof n!="string"?null:GD[n]??null}function YD(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,s=!1;const i=()=>e.enabled()?s&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",a=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,i())};function l(){var h;if(!(!t||s))try{n=n??new t,(h=n.resume)==null||h.call(n).then(a,()=>{}),s=!0,a()}catch{}}function u(h,p=!1){var N;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const f=(((N=e.prefs)==null?void 0:N.call(e))??rw)[h]??rw[h],g=tw(h,f.figure),v=DD(f.level,g),w=n.currentTime;for(const b of g.notes){const k=n.createOscillator(),_=n.createGain();k.type=g.type??"sine",k.frequency.value=b.hz;const E=w+b.at,C=E+b.ms/1e3;_.gain.setValueAtTime(1e-4,E),_.gain.exponentialRampToValueAtTime(v,E+.012),_.gain.exponentialRampToValueAtTime(1e-4,C),k.connect(_).connect(n.destination),k.start(E),k.stop(C+.02)}return!0}return{unlock:l,play:u,state:i,get context(){return n}}}const U1={done:"Turn finished","needs-input":"Claude is asking"},KD={done:"Every finished turn, on both CLIs.","needs-input":"Claude Code only — Codex has no such event."};function XD({onClose:e,soundOn:t,onToggleSound:n,prefs:s,onLevel:i,onFigure:a,onPreview:l,openerRef:u,notifyOn:h,onToggleNotify:p,notifyVetoed:f}){const g=_n(e),v=S.useRef(e);return v.current=e,S.useEffect(()=>{const w=N=>{var k,_;const b=N.target;b&&((k=g.current)!=null&&k.contains(b)||(_=u.current)!=null&&_.contains(b)||v.current())};return window.addEventListener("pointerdown",w,!0),()=>window.removeEventListener("pointerdown",w,!0)},[g,u]),d.jsxs("div",{ref:g,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[d.jsxs("button",{type:"button",className:"btn sm-switch",onClick:n,"aria-pressed":t,children:[d.jsx("span",{className:"sm-switch-label",children:"Sound"}),d.jsx("span",{className:"sm-switch-state",children:t?"on":"off"})]}),d.jsxs("button",{type:"button",className:"btn sm-switch",onClick:p,"aria-pressed":h,title:f?"Recorded for next time: this deck was started with AGENTS_DECK_NO_NOTIFY=1, which overrules the switch":"A system notification when a session blocks on you — from this page while it is behind something, and from the deck itself when no page is open",children:[d.jsx("span",{className:"sm-switch-label",children:"Notifications"}),d.jsx("span",{className:"sm-switch-state",children:f?"off — set at launch":h?"on":"off"})]}),ID.map(w=>{const N=s[w],b=`sm-level-${w}`,k=`sm-figure-${w}`;return d.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${w}`,children:[d.jsxs("div",{className:"sm-tone-head",children:[d.jsx("h3",{className:"sm-tone-name",id:`sm-name-${w}`,children:U1[w]}),d.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>l(w),"aria-label":`Hear the ${U1[w].toLowerCase()} tone`,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:d.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:b,children:"Volume"}),d.jsx("input",{id:b,type:"range",min:FT,max:qw,step:nw,value:N.level,onChange:_=>i(w,Number(_.target.value))}),d.jsxs("span",{className:"sm-read",children:[N.level,"%"]})]}),d.jsxs("div",{className:"sm-row",children:[d.jsx("label",{htmlFor:k,children:"Sound"}),d.jsx("select",{id:k,className:"sm-select",value:N.figure,onChange:_=>a(w,_.target.value),children:Lw[w].map(_=>d.jsx("option",{value:_.id,children:_.label},_.id))})]}),d.jsx("p",{className:"sm-note",children:KD[w]})]},w)}),d.jsx("p",{className:"sm-foot",children:"M turns the sound on and off from anywhere."})]})}const QD={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all."],"3.8.5":[{title:"⛔ Cancelling a sign-in no longer adds the account anyway",body:`Press Escape while adding a Claude account and the deck killed the sign-in — and then, sometimes, registered the account regardless, switched to it, and told you it had worked.
79
+
80
+ The deck asks the tools it runs whether they finished cleanly. A program that is well behaved about being cancelled tidies up and exits with a success code, and the deck was reading that as "it finished" rather than "I stopped it". \`claude auth login\` is exactly that kind of program.
81
+
82
+ A cancelled run now reports as cancelled. Everything that was not cancelled is unaffected.`}],"3.8.4":[{title:"🧷 Your own hooks can no longer be eaten by two decks starting together",body:'If you keep hooks of your own in `settings.json`, the deck parks them while it installs and puts them back afterwards. Two decks starting at the same moment could interleave inside that, and the loser wrote a version of the file computed before the restore — so your hook was gone from `settings.json` and gone from the park, which was its only other copy.\n\nThere was already a check for this, and it had a hole: if the last-moment re-read of the file failed, it read that as "nothing changed" and wrote anyway. A failed read is the one moment that check was most needed, because the usual reason a file cannot be read for a few milliseconds is that something else has just written it.\n\n`ccdeck --uninstall` had no such check at all and could overwrite a deck that was starting, then exit 0 saying it had succeeded. It has one now, and when it declines it says so and tells you to run it again rather than reporting that there was nothing to remove.'}],"3.8.3":[{title:"🪟 Windows: two settings files that could refuse to save",body:`On Windows a file cannot be moved into place while anything else has it open, and Defender and the search indexer open a file the instant it is written. The deck has had a retry for that for a long time, and two files written in the last few days were not using it: the notifications preference, and Browser Watch's episode archive.
79
83
 
80
84
  When it bit, the notifications switch silently did not stick, and Browser Watch answered an error and showed an empty panel. Both now retry the way everything else in the deck already did.
81
85
 
@@ -193,7 +197,7 @@ Both CLIs get the finish tone. The second tone — Claude is waiting for you —
193
197
 
194
198
  Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return l+u+h+`
195
199
 
196
- Click to set the volume and the sound of each tone, and to hear either one.`}function GT(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 i=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};i.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,i.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,i)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function U5(e){const t=GT([{agents:e}]);return t.length<2?null:t.map(n=>`${Fw(n.id)} ${Je(n.cost)}`).join(" · ")}function V1(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 W5(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function uu(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 H5=[7,14,30,90];function G5(e){const[t,n]=S.useState(null),[s,i]=S.useState(!1),a=S.useState($5)[0],l=S.useRef(!1),u=(h=!1)=>{if(h&&!ar(l.current))return;const p=a.begin();l.current=h;const f=e;i(!0);const v=`/api/ccusage?since=${Kv(f)}${h?"&refresh=1":""}`;fetch(v).then(w=>w.json()).then(w=>{p()&&n({range:f,resp:w})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(l.current=!1,i(!1))})};return S.useEffect(()=>(u(!1),()=>a.cancel()),[e]),{landed:t,loading:s,reload:()=>u(!0)}}function V5({onClose:e,providers:t}){var z;const[n,s]=S.useState(30),[i,a]=S.useState(null),{landed:l,loading:u,reload:h}=G5(n),p=S.useRef(null),f=_n(e,{focusRef:p}),g=L5({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((z=l.resp.days)==null?void 0:z.length)??0}}),v=g.phase==="chart"?l.resp.days??[]:[],w=S.useMemo(()=>v.reduce((M,A)=>Math.max(M,A.totalCost),0),[v]),N=S.useRef(null);S.useLayoutEffect(()=>{const M=N.current;M&&(M.scrollLeft=M.scrollWidth)},[v]);const{totalCost:b,totalTok:k,inOut:_,cacheRead:E,modelCosts:C}=S.useMemo(()=>{let M=0,A=0,q=0,G=0;const Y=new Map;for(const R of v){M+=R.totalCost,A+=R.totalTokens,q+=R.inputTokens+R.outputTokens,G+=R.cacheReadTokens;for(const Q of R.modelBreakdowns)Y.set(Q.modelName,(Y.get(Q.modelName)??0)+Q.cost)}return{totalCost:M,totalTok:A,inOut:q,cacheRead:G,modelCosts:Y}},[v]),j=S.useMemo(()=>Array.from(C.entries()).sort((M,A)=>A[1]-M[1]),[C]),I=S.useMemo(()=>GT(v),[v]),O=I.length>1,P=i?v.find(M=>M.period===i)??null:null;return d.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:f,className:"uh-modal",onClick:M=>M.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[d.jsxs("header",{className:"uh-head",children:[d.jsxs("div",{className:"uh-titlewrap",children:[d.jsx("div",{className:"uh-title",children:"Usage history"}),d.jsx("div",{className:"uh-sub",children:F5(t,I.map(M=>M.id))})]}),d.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:H5.map(M=>d.jsxs("button",{type:"button","aria-pressed":n===M,className:"uh-range-btn",onClick:()=>{s(M),a(null)},children:[M,"d"]},M))}),d.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...ir(u),title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),d.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.phase==="busy"?d.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):g.phase==="error"?d.jsxs("div",{className:"uh-status uh-err",title:Hi(l.resp)||void 0,children:[z4(l.resp,"ccusage did not report usage"),d.jsx("div",{children:d.jsx("button",{className:"btn uh-retry",onClick:h,...ir(u),children:u?"trying…":"Try again"})})]}):g.phase==="empty"?d.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):d.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[d.jsxs("div",{className:"uh-totals",children:[d.jsx(du,{label:"total cost",val:Je(b),accent:!0}),d.jsx(du,{label:"tokens",val:Rt(k)}),d.jsx(du,{label:"input+output",val:Rt(_)}),d.jsx(du,{label:"cache reads",val:Rt(E)})]}),O&&d.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[d.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:I.map(M=>d.jsx("span",{className:"uh-agent-seg",style:{width:`${b>0?M.cost/b*100:0}%`,background:V1(M.id)}},M.id))}),d.jsx("div",{className:"uh-agent-keys",children:I.map(M=>d.jsxs("span",{className:"uh-agent-key",title:`${M.id} · ${Rt(M.tokens)} tokens`,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:V1(M.id)}}),Fw(M.id),d.jsx("span",{className:"uh-agent-cost",children:Je(M.cost)}),d.jsx("span",{className:"uh-agent-share",children:W5(M.cost,b)})]},M.id))})]}),d.jsx("div",{ref:N,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:v.map(M=>{const A=w>0?M.totalCost/w*100:0,q=M.period===i,G=`${M.period}, ${Je(M.totalCost)}`;return d.jsxs("button",{className:`uh-bar-col${q?" sel":""}`,onClick:()=>a(q?null:M.period),"aria-pressed":q,"aria-label":G,title:`${M.period} · ${Je(M.totalCost)}`,style:{flexBasis:`${100/v.length}%`},children:[d.jsx("div",{className:"uh-bar",style:{height:`${Math.max(A,M.totalCost>0?2:0)}%`},children:M.modelBreakdowns.slice().sort((Y,R)=>R.cost-Y.cost).map(Y=>{const R=M.totalCost>0?Y.cost/M.totalCost*100:0;return d.jsx("div",{className:"uh-bar-seg",style:{height:`${R}%`,background:uu(Y.modelName)}},Y.modelName)})}),d.jsx("span",{className:"uh-bar-label",children:M.period.slice(5)})]},M.period)})}),d.jsx("div",{className:"uh-legend",children:j.map(([M,A])=>d.jsxs("span",{className:"uh-legend-item",title:M,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:uu(M)}}),Ls(M)," ",d.jsx("span",{className:"uh-legend-cost",children:Je(A)})]},M))}),P&&d.jsxs("div",{className:"uh-detail",children:[d.jsxs("div",{className:"uh-detail-head",children:[d.jsx("span",{className:"uh-detail-date",children:P.period}),d.jsx("span",{className:"uh-detail-cost",children:Je(P.totalCost)}),(()=>{var q,G;const A=U5(P.agents)??((G=(q=P.metadata)==null?void 0:q.agents)!=null&&G.length?P.metadata.agents.join(" · "):null);return A?d.jsx("span",{className:"uh-detail-agents",title:A,children:A}):null})()]}),d.jsxs("div",{className:"uh-detail-mini",children:[d.jsx(fu,{label:"input",val:Rt(P.inputTokens)}),d.jsx(fu,{label:"output",val:Rt(P.outputTokens)}),d.jsx(fu,{label:"cache write",val:Rt(P.cacheCreationTokens)}),d.jsx(fu,{label:"cache read",val:Rt(P.cacheReadTokens)})]}),d.jsx("div",{className:"uh-detail-models",children:P.modelBreakdowns.slice().sort((M,A)=>A.cost-M.cost).map(M=>{const A=P.totalCost>0?M.cost/P.totalCost*100:0;return d.jsxs("div",{className:"uh-model-row",title:M.modelName,children:[d.jsxs("span",{className:"uh-model-name",children:[d.jsx("span",{className:"uh-legend-dot",style:{background:uu(M.modelName)}}),d.jsx("span",{className:"uh-model-label",children:Ls(M.modelName)})]}),d.jsx("span",{className:"uh-model-bar",children:d.jsx("span",{className:"uh-model-bar-fill",style:{width:`${A}%`,background:uu(M.modelName)}})}),d.jsx("span",{className:"uh-model-cost",children:Je(M.cost)})]},M.modelName)})})]})]})]})})}function du({label:e,val:t,accent:n}){return d.jsxs("div",{className:"uh-stat",children:[d.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),d.jsx("span",{className:"uh-stat-label",children:e})]})}function fu({label:e,val:t}){return d.jsxs("div",{className:"uh-ministat",children:[d.jsx("span",{className:"uh-ministat-val",children:t}),d.jsx("span",{className:"uh-ministat-label",children:e})]})}function Y5(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(i=>{const a=i/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const Y1=1e4,K5=12e3;function X5({browsers:e,findings:t,watching:n,palette:s,now:i=()=>Date.now()}){const a=S.useRef(null),l=S.useRef(null);return l.current={browsers:e,findings:t,watching:n},S.useEffect(()=>{var w;const u=a.current;if(!u)return;const h=u.getContext("2d");if(!h)return;const p=((w=window.matchMedia)==null?void 0:w.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,g=!1;const v=()=>{var ne;if(g)return;const N=l.current;if(!N)return;const{browsers:b,findings:k,watching:_}=N,E=s["--accent"]||"#7dd3fc",C=s["--line"]||"#1f2229",j=s["--text-dim"]||"#6e727c",I=Y5(s["--bg"]),O=I?42:26,P=I?.85:.65,z=i(),M=Math.min(window.devicePixelRatio||1,2),A=u.clientWidth,q=u.clientHeight;(u.width!==A*M||u.height!==q*M)&&(u.width=A*M,u.height=q*M),h.setTransform(M,0,0,M,0,0),h.clearRect(0,0,A,q);const G=A/2,Y=q/2,R=Math.min(A,q)/2-6;h.strokeStyle=C,h.lineWidth=1,h.globalAlpha=I?1:.9;for(const X of[.4,.7,1])h.beginPath(),h.arc(G,Y,R*X,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(G-R,Y),h.lineTo(G+R,Y),h.moveTo(G,Y-R),h.lineTo(G,Y+R),h.stroke(),h.globalAlpha=1;const H=(_&&!p?z%Y1/Y1:0)*Math.PI*2-Math.PI/2;if(_){const X=(ne=h.createConicGradient)==null?void 0:ne.call(h,H-.85,G,Y);X&&(X.addColorStop(0,"transparent"),X.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${E} ${O}%, transparent)`),X.addColorStop(1,"transparent"),h.fillStyle=X,h.beginPath(),h.moveTo(G,Y),h.arc(G,Y,R,H-.85,H),h.closePath(),h.fill()),h.strokeStyle=E,h.globalAlpha=P,h.beginPath(),h.moveTo(G,Y),h.lineTo(G+Math.cos(H)*R,Y+Math.sin(H)*R),h.stroke(),h.globalAlpha=1}b.forEach((X,U)=>{const J=U/Math.max(b.length,1)*Math.PI*2-Math.PI/2,$=X.lastReadMs===null?1:Math.min(1,(z-X.lastReadMs)/12e4),V=R*(.42+$*.5),Z=G+Math.cos(J)*V,D=Y+Math.sin(J)*V,L=Math.abs((H-J+Math.PI*3)%(Math.PI*2)-Math.PI),K=_?Math.max(0,1-L/.55):0;h.beginPath(),h.arc(Z,D,3+K*1.6,0,Math.PI*2),h.fillStyle=X.running?E:j,h.globalAlpha=X.running?.55+K*.45:.35,h.fill(),h.globalAlpha=1});for(const X of k){const U=(z-X.atMs)/K5;if(U<0||U>1)continue;const $=Math.max(0,b.findIndex(D=>D.key===X.browser))/Math.max(b.length,1)*Math.PI*2-Math.PI/2,V=G+Math.cos($)*R*.6,Z=Y+Math.sin($)*R*.6;h.beginPath(),h.arc(V,Z,4+U*22,0,Math.PI*2),h.strokeStyle=E,h.globalAlpha=(1-U)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(v)};return v(),()=>{g=!0,cancelAnimationFrame(f)}},[i,s]),d.jsx("canvas",{ref:a,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const K1="agent-dag.browserWatch.seenMs";function Q5(e,t){return e.filter(n=>n.startMs>t)}function Z5(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function J5(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 VT(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function X1(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 eF(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,i)=>s+i.programVisits,0)}))}function tF(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 nF(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],i=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(i>0?`, and ${i} more`:"")+". The watch continues on the profiles it can read."}}const n=VT(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 rF(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 sF(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function Q1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function oF({onClose:e,onSeen:t,onWatching:n,palette:s}){const i=_n(e),[a,l]=S.useState(null),[u,h]=S.useState(null),[p,f]=S.useState(!1),g=S.useRef(!1),[v,w]=S.useState(null),[N,b]=S.useState(null),[k,_]=S.useState(!1),[E,C]=S.useState(!1),[j,I]=S.useState(!1),[O,P]=S.useState(!1),[z,M]=S.useState(!1),[A,q]=S.useState(!1),[G,Y]=S.useState(()=>Date.now());S.useEffect(()=>{const Z=setInterval(()=>Y(Date.now()),1e3);return()=>clearInterval(Z)},[]);const R=S.useCallback(async Z=>{var D;if(!(Z&&!ar(g.current))){g.current=Z,f(!0);try{const L=await fetch(`/api/browser-watch${Z?"?refresh=1":""}`);if(!L.ok)throw new Error(`the deck answered ${L.status}`);const K=await L.json();l(K),w(se=>{var he;return se===null?((he=K==null?void 0:K.settings)==null?void 0:he.quietMinutes)??15:se}),n(((D=K==null?void 0:K.settings)==null?void 0:D.enabled)===!0),h(null)}catch(L){h(L instanceof Error?L.message:String(L))}finally{g.current=!1,f(!1)}}},[n]);S.useEffect(()=>{R(!1)},[R]),S.useEffect(()=>{const Z=setInterval(()=>{R(!1)},1e4);return()=>clearInterval(Z)},[R]);const Q=S.useCallback(async Z=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:Z.host,startMs:Z.startMs})})}finally{await R(!1)}},[R]),H=S.useCallback(async Z=>{_(!0);try{const D=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Z)});if(!D.ok)throw new Error(`the deck answered ${D.status}`);await R(!1)}catch(D){h(D instanceof Error?D.message:String(D))}finally{_(!1)}},[R]);S.useEffect(()=>()=>t(Date.now()),[t]);const ne=S.useMemo(()=>{const Z=[];for(const D of(a==null?void 0:a.episodes)??[]){const L=sF(D.startMs),K=Z[Z.length-1];K&&K.label===L?K.episodes.push(D):Z.push({label:L,episodes:[D]})}return Z},[a]),X=VT(a==null?void 0:a.browsers),U=((a==null?void 0:a.browsers)??[]).filter(Z=>!(Z.installed&&Z.profiles>0)),J=a?nF(a):null,$=X.reduce((Z,D)=>Z+D.profiles,0),V=a?Z5(a.coverage.lastHumanMs,a.coverage.quietMs,G):null;return d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:i,className:"modal bw-modal",onClick:Z=>Z.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),d.jsx("span",{className:"modal-tool-id",children:a?`${$} ${$===1?"profile":"profiles"} · local only`:"local only"})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("button",{className:"glyph-btn",onClick:()=>void R(!0),...ir(p),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:p?"…":"↻"}),d.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("div",{className:"modal-body bw-body",children:[!a&&!u&&d.jsxs("div",{className:"bw-loading",children:[d.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),d.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),u&&d.jsx("div",{className:"bw-state",children:d.jsxs("div",{className:"bw-row err",children:[d.jsx("span",{className:"bw-dot","aria-hidden":!0}),d.jsx("span",{className:"bw-row-label",children:"Could not read"}),d.jsx("span",{className:"bw-row-detail",children:u})]})}),a&&J&&d.jsx("p",{className:`bw-trouble ${J.kind}`,role:"status",children:J.text}),a&&d.jsxs("div",{className:"bw-work",children:[d.jsxs("aside",{className:"bw-side",children:[d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",d.jsx("button",{className:"bw-help",onClick:()=>P(Z=>!Z),"aria-expanded":O,"aria-label":"What the sweep and the dots mean",children:"?"})]}),d.jsxs("div",{className:"bw-glance",children:[d.jsx(X5,{browsers:X.map(Z=>{var D;return{key:Z.key,name:Z.name,running:Z.running,lastReadMs:((D=a.profiles.find(L=>L.browser===Z.key))==null?void 0:D.lastWrittenMs)??null}}),findings:a.episodes.slice(0,6).map(Z=>({browser:Z.browser??null,atMs:Z.endMs})),watching:a.settings.enabled,palette:s}),d.jsx("ul",{className:"bw-counts",children:eF(X,a.profiles).map(Z=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-count-n",children:Z.visits.toLocaleString("en-US")}),d.jsx("span",{className:"bw-count-of",children:Z.name})]},Z.key))})]}),d.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),a.coverage.checkedMs>0&&d.jsxs("p",{className:"bw-since",children:["Last checked ",tF(a.coverage.checkedMs,G),a.coverage.checks>0&&d.jsxs(d.Fragment,{children:[" · ",a.coverage.checks.toLocaleString("en-US")," ",a.coverage.checks===1?"check":"checks"]})]}),V!==null&&d.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",J5(V)]}),O&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Sweep"}),d.jsx("dd",{children:"one poll of every watched profile"}),d.jsx("dt",{children:"Dot"}),d.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),d.jsx("dt",{children:"Ring"}),d.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",d.jsx("button",{className:"bw-help",onClick:()=>M(Z=>!Z),"aria-expanded":z,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),z&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Running"}),d.jsx("dd",{children:"the browser has a process on this machine right now"}),d.jsx("dt",{children:"Connected"}),d.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"})]}),d.jsx("ul",{className:"bw-profiles",children:X.map(Z=>d.jsxs("li",{children:[d.jsx("span",{className:`bw-prof-dot${Z.running?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-prof-name",children:Z.name}),d.jsx("span",{className:"bw-prof-state",children:Z.running?"running":"idle"}),Z.running&&Z.relay.state==="live"&&d.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},Z.key))}),U.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>q(Z=>!Z),"aria-expanded":A,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:A?"▾":"▸"})," ",U.length," not watched"]}),A&&d.jsxs("p",{className:"bw-rest",children:[U.map(Z=>Z.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})]}),d.jsxs("div",{className:"bw-main",children:[d.jsxs("section",{className:"bw-findings",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",a.episodes.length>0&&d.jsxs("span",{className:"bw-feed-count",children:[a.episodes.length," ",a.episodes.length===1?"episode":"episodes"]})]}),d.jsx("div",{className:"bw-eps",children:ne.length===0?d.jsxs("div",{className:"bw-empty",children:[d.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),d.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",a.settings.quietMinutes," ",a.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."]}),!a.settings.enabled&&d.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."})]}):ne.map(Z=>d.jsxs("div",{className:"bw-day",children:[d.jsx("h4",{className:"bw-sec-head",children:Z.label}),Z.episodes.map(D=>{const L=`${D.host}-${D.startMs}`,K=N===L;return d.jsxs("div",{className:`bw-ep${K?" open":""}`,children:[d.jsxs("div",{className:"bw-ep-row",children:[d.jsxs("button",{className:"bw-ep-head",onClick:()=>b(K?null:L),"aria-expanded":K,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:K?"▾":"▸"}),d.jsx("span",{className:"bw-ep-host",children:D.host}),d.jsxs("span",{className:"bw-ep-meta",children:[rF(D),Q1(D)&&d.jsxs(d.Fragment,{children:[" · ",Q1(D)]})]}),d.jsxs("span",{className:"bw-ep-count",children:[D.count," ",D.count===1?"page":"pages"]})]}),d.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Q(D),"aria-label":`Dismiss ${D.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),K&&d.jsx("ul",{className:"bw-urls",children:D.urls.map((se,he)=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-url-time",children:new Date(se.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),d.jsx("span",{className:"bw-url",children:se.url})]},`${se.url}-${se.timeMs}-${he}`))})]},L)})]},Z.label))})]}),d.jsxs("section",{className:"bw-feed",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",d.jsxs("span",{className:"bw-feed-count",children:[a.log.length," ",a.log.length===1?"event":"events"]})]}),d.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."}),d.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:a.log.length===0?d.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):a.log.map(Z=>d.jsxs("div",{className:`bw-log-line ${Z.level}${Z.parts?"":" sys"}`,children:[d.jsx("span",{className:"bw-log-time",children:new Date(Z.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),Z.parts?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"bw-log-browser",children:Z.parts.browser}),d.jsx("span",{className:"bw-log-profile",title:Z.parts.profile,children:Z.parts.profile}),d.jsxs("span",{className:"bw-log-value",children:[Z.parts.value,Z.parts.flagged>0&&d.jsxs("span",{className:"bw-log-flag",children:[" · ",Z.parts.flagged," flagged"]})]})]}):d.jsx("span",{className:"bw-log-sys",children:Z.text})]},`${Z.atMs}-${Z.level}-${Z.text}`))})]})]})]}),a&&E&&d.jsxs("div",{className:"bw-settings",children:[d.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:[d.jsx("span",{children:"Nobody browsing for"}),d.jsxs("select",{value:v??a.settings.quietMinutes,onChange:Z=>{w(Number(Z.target.value)),H({quietMinutes:Number(Z.target.value)})},children:[d.jsx("option",{value:1,children:"1 min"}),d.jsx("option",{value:5,children:"5 min"}),d.jsx("option",{value:15,children:"15 min"}),d.jsx("option",{value:30,children:"30 min"}),d.jsx("option",{value:60,children:"60 min"})]})]}),d.jsxs("label",{children:[d.jsx("span",{children:"When it finds one"}),d.jsx("select",{value:a.settings.reaction,onChange:Z=>void H({reaction:Z.target.value}),disabled:!a.settings.enabled,title:a.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(a.reactions??["notify"]).map(Z=>d.jsx("option",{value:Z,children:Z==="notify"?"notify me":Z==="close-tab"?"close the tab":"quit the browser"},Z))})]}),d.jsxs("div",{className:"bw-settings-note",children:[d.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. ",d.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),d.jsxs("button",{className:"bw-why",onClick:()=>I(Z=>!Z),"aria-expanded":j,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:j?"▾":"▸"})," What Browser Watch can access"]}),j&&d.jsxs("dl",{className:"bw-access",children:[d.jsx("dt",{children:"Reads"}),d.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(a.coverage.startedMs).toLocaleString(),"."]}),d.jsx("dt",{children:"Keeps"}),d.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",d.jsx("code",{className:"bw-path",children:a.coverage.logPath}),", with every address written in full so you can check it yourself."]}),d.jsx("dt",{children:"Sends"}),d.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."}),d.jsx("dt",{children:"Never reads"}),d.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),a&&d.jsxs("footer",{className:"bw-status",children:[d.jsx("span",{className:`bw-mode-dot${a.settings.enabled?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-mode-word",children:X1(a,k).word},X1(a,k).kind),d.jsx("span",{className:"bw-status-text",children:a.coverage.archived===0?a.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${a.coverage.archived} ${a.coverage.archived===1?"episode":"episodes"} on disk`}),d.jsx("button",{className:`glyph-btn bw-gear${E?" on":""}`,onClick:()=>C(Z=>!Z),"aria-expanded":E,"aria-label":"Settings",title:"Settings",children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[d.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),d.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"})]})}),d.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[d.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),d.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":a.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void H({enabled:!a.settings.enabled}),title:a.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:d.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function zw(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 ih,Z1;function iF(){if(Z1)return ih;Z1=1;function e(){this.__data__=[],this.size=0}return ih=e,ih}var ah,J1;function Qi(){if(J1)return ah;J1=1;function e(t,n){return t===n||t!==t&&n!==n}return ah=e,ah}var lh,ek;function Vu(){if(ek)return lh;ek=1;var e=Qi();function t(n,s){for(var i=n.length;i--;)if(e(n[i][0],s))return i;return-1}return lh=t,lh}var ch,tk;function aF(){if(tk)return ch;tk=1;var e=Vu(),t=Array.prototype,n=t.splice;function s(i){var a=this.__data__,l=e(a,i);if(l<0)return!1;var u=a.length-1;return l==u?a.pop():n.call(a,l,1),--this.size,!0}return ch=s,ch}var uh,nk;function lF(){if(nk)return uh;nk=1;var e=Vu();function t(n){var s=this.__data__,i=e(s,n);return i<0?void 0:s[i][1]}return uh=t,uh}var dh,rk;function cF(){if(rk)return dh;rk=1;var e=Vu();function t(n){return e(this.__data__,n)>-1}return dh=t,dh}var fh,sk;function uF(){if(sk)return fh;sk=1;var e=Vu();function t(n,s){var i=this.__data__,a=e(i,n);return a<0?(++this.size,i.push([n,s])):i[a][1]=s,this}return fh=t,fh}var hh,ok;function Yu(){if(ok)return hh;ok=1;var e=iF(),t=aF(),n=lF(),s=cF(),i=uF();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=i,hh=a,hh}var ph,ik;function dF(){if(ik)return ph;ik=1;var e=Yu();function t(){this.__data__=new e,this.size=0}return ph=t,ph}var mh,ak;function fF(){if(ak)return mh;ak=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return mh=e,mh}var gh,lk;function hF(){if(lk)return gh;lk=1;function e(t){return this.__data__.get(t)}return gh=e,gh}var yh,ck;function pF(){if(ck)return yh;ck=1;function e(t){return this.__data__.has(t)}return yh=e,yh}var vh,uk;function YT(){if(uk)return vh;uk=1;var e=typeof Vc=="object"&&Vc&&Vc.Object===Object&&Vc;return vh=e,vh}var wh,dk;function dr(){if(dk)return wh;dk=1;var e=YT(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return wh=n,wh}var xh,fk;function Zi(){if(fk)return xh;fk=1;var e=dr(),t=e.Symbol;return xh=t,xh}var bh,hk;function mF(){if(hk)return bh;hk=1;var e=Zi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,i=e?e.toStringTag:void 0;function a(l){var u=n.call(l,i),h=l[i];try{l[i]=void 0;var p=!0}catch{}var f=s.call(l);return p&&(u?l[i]=h:delete l[i]),f}return bh=a,bh}var kh,pk;function gF(){if(pk)return kh;pk=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return kh=n,kh}var _h,mk;function No(){if(mk)return _h;mk=1;var e=Zi(),t=mF(),n=gF(),s="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function l(u){return u==null?u===void 0?i:s:a&&a in Object(u)?t(u):n(u)}return _h=l,_h}var Sh,gk;function qn(){if(gk)return Sh;gk=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Sh=e,Sh}var Nh,yk;function Ol(){if(yk)return Nh;yk=1;var e=No(),t=qn(),n="[object AsyncFunction]",s="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function l(u){if(!t(u))return!1;var h=e(u);return h==s||h==i||h==n||h==a}return Nh=l,Nh}var Eh,vk;function yF(){if(vk)return Eh;vk=1;var e=dr(),t=e["__core-js_shared__"];return Eh=t,Eh}var Ch,wk;function vF(){if(wk)return Ch;wk=1;var e=yF(),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 Ch=n,Ch}var jh,xk;function KT(){if(xk)return jh;xk=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 jh=n,jh}var Th,bk;function wF(){if(bk)return Th;bk=1;var e=Ol(),t=vF(),n=qn(),s=KT(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,h=l.toString,p=u.hasOwnProperty,f=RegExp("^"+h.call(p).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(v){if(!n(v)||t(v))return!1;var w=e(v)?f:a;return w.test(s(v))}return Th=g,Th}var Rh,kk;function xF(){if(kk)return Rh;kk=1;function e(t,n){return t==null?void 0:t[n]}return Rh=e,Rh}var Ah,_k;function Eo(){if(_k)return Ah;_k=1;var e=wF(),t=xF();function n(s,i){var a=t(s,i);return e(a)?a:void 0}return Ah=n,Ah}var Mh,Sk;function Bw(){if(Sk)return Mh;Sk=1;var e=Eo(),t=dr(),n=e(t,"Map");return Mh=n,Mh}var Ih,Nk;function Ku(){if(Nk)return Ih;Nk=1;var e=Eo(),t=e(Object,"create");return Ih=t,Ih}var Oh,Ek;function bF(){if(Ek)return Oh;Ek=1;var e=Ku();function t(){this.__data__=e?e(null):{},this.size=0}return Oh=t,Oh}var Ph,Ck;function kF(){if(Ck)return Ph;Ck=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Ph=e,Ph}var $h,jk;function _F(){if(jk)return $h;jk=1;var e=Ku(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function i(a){var l=this.__data__;if(e){var u=l[a];return u===t?void 0:u}return s.call(l,a)?l[a]:void 0}return $h=i,$h}var Lh,Tk;function SF(){if(Tk)return Lh;Tk=1;var e=Ku(),t=Object.prototype,n=t.hasOwnProperty;function s(i){var a=this.__data__;return e?a[i]!==void 0:n.call(a,i)}return Lh=s,Lh}var qh,Rk;function NF(){if(Rk)return qh;Rk=1;var e=Ku(),t="__lodash_hash_undefined__";function n(s,i){var a=this.__data__;return this.size+=this.has(s)?0:1,a[s]=e&&i===void 0?t:i,this}return qh=n,qh}var Dh,Ak;function EF(){if(Ak)return Dh;Ak=1;var e=bF(),t=kF(),n=_F(),s=SF(),i=NF();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=i,Dh=a,Dh}var Fh,Mk;function CF(){if(Mk)return Fh;Mk=1;var e=EF(),t=Yu(),n=Bw();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Fh=s,Fh}var zh,Ik;function jF(){if(Ik)return zh;Ik=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return zh=e,zh}var Bh,Ok;function Xu(){if(Ok)return Bh;Ok=1;var e=jF();function t(n,s){var i=n.__data__;return e(s)?i[typeof s=="string"?"string":"hash"]:i.map}return Bh=t,Bh}var Uh,Pk;function TF(){if(Pk)return Uh;Pk=1;var e=Xu();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return Uh=t,Uh}var Wh,$k;function RF(){if($k)return Wh;$k=1;var e=Xu();function t(n){return e(this,n).get(n)}return Wh=t,Wh}var Hh,Lk;function AF(){if(Lk)return Hh;Lk=1;var e=Xu();function t(n){return e(this,n).has(n)}return Hh=t,Hh}var Gh,qk;function MF(){if(qk)return Gh;qk=1;var e=Xu();function t(n,s){var i=e(this,n),a=i.size;return i.set(n,s),this.size+=i.size==a?0:1,this}return Gh=t,Gh}var Vh,Dk;function Uw(){if(Dk)return Vh;Dk=1;var e=CF(),t=TF(),n=RF(),s=AF(),i=MF();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=i,Vh=a,Vh}var Yh,Fk;function IF(){if(Fk)return Yh;Fk=1;var e=Yu(),t=Bw(),n=Uw(),s=200;function i(a,l){var u=this.__data__;if(u instanceof e){var h=u.__data__;if(!t||h.length<s-1)return h.push([a,l]),this.size=++u.size,this;u=this.__data__=new n(h)}return u.set(a,l),this.size=u.size,this}return Yh=i,Yh}var Kh,zk;function Qu(){if(zk)return Kh;zk=1;var e=Yu(),t=dF(),n=fF(),s=hF(),i=pF(),a=IF();function l(u){var h=this.__data__=new e(u);this.size=h.size}return l.prototype.clear=t,l.prototype.delete=n,l.prototype.get=s,l.prototype.has=i,l.prototype.set=a,Kh=l,Kh}var Xh,Bk;function Ww(){if(Bk)return Xh;Bk=1;function e(t,n){for(var s=-1,i=t==null?0:t.length;++s<i&&n(t[s],s,t)!==!1;);return t}return Xh=e,Xh}var Qh,Uk;function XT(){if(Uk)return Qh;Uk=1;var e=Eo(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Qh=t,Qh}var Zh,Wk;function Zu(){if(Wk)return Zh;Wk=1;var e=XT();function t(n,s,i){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:i,writable:!0}):n[s]=i}return Zh=t,Zh}var Jh,Hk;function Ju(){if(Hk)return Jh;Hk=1;var e=Zu(),t=Qi(),n=Object.prototype,s=n.hasOwnProperty;function i(a,l,u){var h=a[l];(!(s.call(a,l)&&t(h,u))||u===void 0&&!(l in a))&&e(a,l,u)}return Jh=i,Jh}var ep,Gk;function Pl(){if(Gk)return ep;Gk=1;var e=Ju(),t=Zu();function n(s,i,a,l){var u=!a;a||(a={});for(var h=-1,p=i.length;++h<p;){var f=i[h],g=l?l(a[f],s[f],f,a,s):void 0;g===void 0&&(g=s[f]),u?t(a,f,g):e(a,f,g)}return a}return ep=n,ep}var tp,Vk;function OF(){if(Vk)return tp;Vk=1;function e(t,n){for(var s=-1,i=Array(t);++s<t;)i[s]=n(s);return i}return tp=e,tp}var np,Yk;function jr(){if(Yk)return np;Yk=1;function e(t){return t!=null&&typeof t=="object"}return np=e,np}var rp,Kk;function PF(){if(Kk)return rp;Kk=1;var e=No(),t=jr(),n="[object Arguments]";function s(i){return t(i)&&e(i)==n}return rp=s,rp}var sp,Xk;function $l(){if(Xk)return sp;Xk=1;var e=PF(),t=jr(),n=Object.prototype,s=n.hasOwnProperty,i=n.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(l){return t(l)&&s.call(l,"callee")&&!i.call(l,"callee")};return sp=a,sp}var op,Qk;function Mt(){if(Qk)return op;Qk=1;var e=Array.isArray;return op=e,op}var ol={exports:{}},ip,Zk;function $F(){if(Zk)return ip;Zk=1;function e(){return!1}return ip=e,ip}ol.exports;var Jk;function Ji(){return Jk||(Jk=1,(function(e,t){var n=dr(),s=$F(),i=t&&!t.nodeType&&t,a=i&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===i,u=l?n.Buffer:void 0,h=u?u.isBuffer:void 0,p=h||s;e.exports=p})(ol,ol.exports)),ol.exports}var ap,e_;function ed(){if(e_)return ap;e_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,i){var a=typeof s;return i=i??e,!!i&&(a=="number"||a!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<i}return ap=n,ap}var lp,t_;function Hw(){if(t_)return lp;t_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return lp=t,lp}var cp,n_;function LF(){if(n_)return cp;n_=1;var e=No(),t=Hw(),n=jr(),s="[object Arguments]",i="[object Array]",a="[object Boolean]",l="[object Date]",u="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",g="[object Object]",v="[object RegExp]",w="[object Set]",N="[object String]",b="[object WeakMap]",k="[object ArrayBuffer]",_="[object DataView]",E="[object Float32Array]",C="[object Float64Array]",j="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",P="[object Uint8Array]",z="[object Uint8ClampedArray]",M="[object Uint16Array]",A="[object Uint32Array]",q={};q[E]=q[C]=q[j]=q[I]=q[O]=q[P]=q[z]=q[M]=q[A]=!0,q[s]=q[i]=q[k]=q[a]=q[_]=q[l]=q[u]=q[h]=q[p]=q[f]=q[g]=q[v]=q[w]=q[N]=q[b]=!1;function G(Y){return n(Y)&&t(Y.length)&&!!q[e(Y)]}return cp=G,cp}var up,r_;function td(){if(r_)return up;r_=1;function e(t){return function(n){return t(n)}}return up=e,up}var il={exports:{}};il.exports;var s_;function Gw(){return s_||(s_=1,(function(e,t){var n=YT(),s=t&&!t.nodeType&&t,i=s&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===s,l=a&&n.process,u=(function(){try{var h=i&&i.require&&i.require("util").types;return h||l&&l.binding&&l.binding("util")}catch{}})();e.exports=u})(il,il.exports)),il.exports}var dp,o_;function Ll(){if(o_)return dp;o_=1;var e=LF(),t=td(),n=Gw(),s=n&&n.isTypedArray,i=s?t(s):e;return dp=i,dp}var fp,i_;function QT(){if(i_)return fp;i_=1;var e=OF(),t=$l(),n=Mt(),s=Ji(),i=ed(),a=Ll(),l=Object.prototype,u=l.hasOwnProperty;function h(p,f){var g=n(p),v=!g&&t(p),w=!g&&!v&&s(p),N=!g&&!v&&!w&&a(p),b=g||v||w||N,k=b?e(p.length,String):[],_=k.length;for(var E in p)(f||u.call(p,E))&&!(b&&(E=="length"||w&&(E=="offset"||E=="parent")||N&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||i(E,_)))&&k.push(E);return k}return fp=h,fp}var hp,a_;function nd(){if(a_)return hp;a_=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,i=typeof s=="function"&&s.prototype||e;return n===i}return hp=t,hp}var pp,l_;function ZT(){if(l_)return pp;l_=1;function e(t,n){return function(s){return t(n(s))}}return pp=e,pp}var mp,c_;function qF(){if(c_)return mp;c_=1;var e=ZT(),t=e(Object.keys,Object);return mp=t,mp}var gp,u_;function Vw(){if(u_)return gp;u_=1;var e=nd(),t=qF(),n=Object.prototype,s=n.hasOwnProperty;function i(a){if(!e(a))return t(a);var l=[];for(var u in Object(a))s.call(a,u)&&u!="constructor"&&l.push(u);return l}return gp=i,gp}var yp,d_;function es(){if(d_)return yp;d_=1;var e=Ol(),t=Hw();function n(s){return s!=null&&t(s.length)&&!e(s)}return yp=n,yp}var vp,f_;function qs(){if(f_)return vp;f_=1;var e=QT(),t=Vw(),n=es();function s(i){return n(i)?e(i):t(i)}return vp=s,vp}var wp,h_;function DF(){if(h_)return wp;h_=1;var e=Pl(),t=qs();function n(s,i){return s&&e(i,t(i),s)}return wp=n,wp}var xp,p_;function FF(){if(p_)return xp;p_=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return xp=e,xp}var bp,m_;function zF(){if(m_)return bp;m_=1;var e=qn(),t=nd(),n=FF(),s=Object.prototype,i=s.hasOwnProperty;function a(l){if(!e(l))return n(l);var u=t(l),h=[];for(var p in l)p=="constructor"&&(u||!i.call(l,p))||h.push(p);return h}return bp=a,bp}var kp,g_;function Co(){if(g_)return kp;g_=1;var e=QT(),t=zF(),n=es();function s(i){return n(i)?e(i,!0):t(i)}return kp=s,kp}var _p,y_;function BF(){if(y_)return _p;y_=1;var e=Pl(),t=Co();function n(s,i){return s&&e(i,t(i),s)}return _p=n,_p}var al={exports:{}};al.exports;var v_;function JT(){return v_||(v_=1,(function(e,t){var n=dr(),s=t&&!t.nodeType&&t,i=s&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===s,l=a?n.Buffer:void 0,u=l?l.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var g=p.length,v=u?u(g):new p.constructor(g);return p.copy(v),v}e.exports=h})(al,al.exports)),al.exports}var Sp,w_;function eR(){if(w_)return Sp;w_=1;function e(t,n){var s=-1,i=t.length;for(n||(n=Array(i));++s<i;)n[s]=t[s];return n}return Sp=e,Sp}var Np,x_;function tR(){if(x_)return Np;x_=1;function e(t,n){for(var s=-1,i=t==null?0:t.length,a=0,l=[];++s<i;){var u=t[s];n(u,s,t)&&(l[a++]=u)}return l}return Np=e,Np}var Ep,b_;function nR(){if(b_)return Ep;b_=1;function e(){return[]}return Ep=e,Ep}var Cp,k_;function Yw(){if(k_)return Cp;k_=1;var e=tR(),t=nR(),n=Object.prototype,s=n.propertyIsEnumerable,i=Object.getOwnPropertySymbols,a=i?function(l){return l==null?[]:(l=Object(l),e(i(l),function(u){return s.call(l,u)}))}:t;return Cp=a,Cp}var jp,__;function UF(){if(__)return jp;__=1;var e=Pl(),t=Yw();function n(s,i){return e(s,t(s),i)}return jp=n,jp}var Tp,S_;function Kw(){if(S_)return Tp;S_=1;function e(t,n){for(var s=-1,i=n.length,a=t.length;++s<i;)t[a+s]=n[s];return t}return Tp=e,Tp}var Rp,N_;function rd(){if(N_)return Rp;N_=1;var e=ZT(),t=e(Object.getPrototypeOf,Object);return Rp=t,Rp}var Ap,E_;function rR(){if(E_)return Ap;E_=1;var e=Kw(),t=rd(),n=Yw(),s=nR(),i=Object.getOwnPropertySymbols,a=i?function(l){for(var u=[];l;)e(u,n(l)),l=t(l);return u}:s;return Ap=a,Ap}var Mp,C_;function WF(){if(C_)return Mp;C_=1;var e=Pl(),t=rR();function n(s,i){return e(s,t(s),i)}return Mp=n,Mp}var Ip,j_;function sR(){if(j_)return Ip;j_=1;var e=Kw(),t=Mt();function n(s,i,a){var l=i(s);return t(s)?l:e(l,a(s))}return Ip=n,Ip}var Op,T_;function oR(){if(T_)return Op;T_=1;var e=sR(),t=Yw(),n=qs();function s(i){return e(i,n,t)}return Op=s,Op}var Pp,R_;function HF(){if(R_)return Pp;R_=1;var e=sR(),t=rR(),n=Co();function s(i){return e(i,n,t)}return Pp=s,Pp}var $p,A_;function GF(){if(A_)return $p;A_=1;var e=Eo(),t=dr(),n=e(t,"DataView");return $p=n,$p}var Lp,M_;function VF(){if(M_)return Lp;M_=1;var e=Eo(),t=dr(),n=e(t,"Promise");return Lp=n,Lp}var qp,I_;function iR(){if(I_)return qp;I_=1;var e=Eo(),t=dr(),n=e(t,"Set");return qp=n,qp}var Dp,O_;function YF(){if(O_)return Dp;O_=1;var e=Eo(),t=dr(),n=e(t,"WeakMap");return Dp=n,Dp}var Fp,P_;function ea(){if(P_)return Fp;P_=1;var e=GF(),t=Bw(),n=VF(),s=iR(),i=YF(),a=No(),l=KT(),u="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",g="[object WeakMap]",v="[object DataView]",w=l(e),N=l(t),b=l(n),k=l(s),_=l(i),E=a;return(e&&E(new e(new ArrayBuffer(1)))!=v||t&&E(new t)!=u||n&&E(n.resolve())!=p||s&&E(new s)!=f||i&&E(new i)!=g)&&(E=function(C){var j=a(C),I=j==h?C.constructor:void 0,O=I?l(I):"";if(O)switch(O){case w:return v;case N:return u;case b:return p;case k:return f;case _:return g}return j}),Fp=E,Fp}var zp,$_;function KF(){if($_)return zp;$_=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var i=s.length,a=new s.constructor(i);return i&&typeof s[0]=="string"&&t.call(s,"index")&&(a.index=s.index,a.input=s.input),a}return zp=n,zp}var Bp,L_;function aR(){if(L_)return Bp;L_=1;var e=dr(),t=e.Uint8Array;return Bp=t,Bp}var Up,q_;function Xw(){if(q_)return Up;q_=1;var e=aR();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return Up=t,Up}var Wp,D_;function XF(){if(D_)return Wp;D_=1;var e=Xw();function t(n,s){var i=s?e(n.buffer):n.buffer;return new n.constructor(i,n.byteOffset,n.byteLength)}return Wp=t,Wp}var Hp,F_;function QF(){if(F_)return Hp;F_=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return Hp=t,Hp}var Gp,z_;function ZF(){if(z_)return Gp;z_=1;var e=Zi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(i){return n?Object(n.call(i)):{}}return Gp=s,Gp}var Vp,B_;function lR(){if(B_)return Vp;B_=1;var e=Xw();function t(n,s){var i=s?e(n.buffer):n.buffer;return new n.constructor(i,n.byteOffset,n.length)}return Vp=t,Vp}var Yp,U_;function JF(){if(U_)return Yp;U_=1;var e=Xw(),t=XF(),n=QF(),s=ZF(),i=lR(),a="[object Boolean]",l="[object Date]",u="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",g="[object String]",v="[object Symbol]",w="[object ArrayBuffer]",N="[object DataView]",b="[object Float32Array]",k="[object Float64Array]",_="[object Int8Array]",E="[object Int16Array]",C="[object Int32Array]",j="[object Uint8Array]",I="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]";function z(M,A,q){var G=M.constructor;switch(A){case w:return e(M);case a:case l:return new G(+M);case N:return t(M,q);case b:case k:case _:case E:case C:case j:case I:case O:case P:return i(M,q);case u:return new G;case h:case g:return new G(M);case p:return n(M);case f:return new G;case v:return s(M)}}return Yp=z,Yp}var Kp,W_;function cR(){if(W_)return Kp;W_=1;var e=qn(),t=Object.create,n=(function(){function s(){}return function(i){if(!e(i))return{};if(t)return t(i);s.prototype=i;var a=new s;return s.prototype=void 0,a}})();return Kp=n,Kp}var Xp,H_;function uR(){if(H_)return Xp;H_=1;var e=cR(),t=rd(),n=nd();function s(i){return typeof i.constructor=="function"&&!n(i)?e(t(i)):{}}return Xp=s,Xp}var Qp,G_;function e6(){if(G_)return Qp;G_=1;var e=ea(),t=jr(),n="[object Map]";function s(i){return t(i)&&e(i)==n}return Qp=s,Qp}var Zp,V_;function t6(){if(V_)return Zp;V_=1;var e=e6(),t=td(),n=Gw(),s=n&&n.isMap,i=s?t(s):e;return Zp=i,Zp}var Jp,Y_;function n6(){if(Y_)return Jp;Y_=1;var e=ea(),t=jr(),n="[object Set]";function s(i){return t(i)&&e(i)==n}return Jp=s,Jp}var em,K_;function r6(){if(K_)return em;K_=1;var e=n6(),t=td(),n=Gw(),s=n&&n.isSet,i=s?t(s):e;return em=i,em}var tm,X_;function dR(){if(X_)return tm;X_=1;var e=Qu(),t=Ww(),n=Ju(),s=DF(),i=BF(),a=JT(),l=eR(),u=UF(),h=WF(),p=oR(),f=HF(),g=ea(),v=KF(),w=JF(),N=uR(),b=Mt(),k=Ji(),_=t6(),E=qn(),C=r6(),j=qs(),I=Co(),O=1,P=2,z=4,M="[object Arguments]",A="[object Array]",q="[object Boolean]",G="[object Date]",Y="[object Error]",R="[object Function]",Q="[object GeneratorFunction]",H="[object Map]",ne="[object Number]",X="[object Object]",U="[object RegExp]",J="[object Set]",$="[object String]",V="[object Symbol]",Z="[object WeakMap]",D="[object ArrayBuffer]",L="[object DataView]",K="[object Float32Array]",se="[object Float64Array]",he="[object Int8Array]",me="[object Int16Array]",xe="[object Int32Array]",Ee="[object Uint8Array]",He="[object Uint8ClampedArray]",Fe="[object Uint16Array]",Ie="[object Uint32Array]",be={};be[M]=be[A]=be[D]=be[L]=be[q]=be[G]=be[K]=be[se]=be[he]=be[me]=be[xe]=be[H]=be[ne]=be[X]=be[U]=be[J]=be[$]=be[V]=be[Ee]=be[He]=be[Fe]=be[Ie]=!0,be[Y]=be[R]=be[Z]=!1;function ue(re,pe,Oe,nt,st,Xe){var Pe,Ue=pe&O,Ge=pe&P,it=pe&z;if(Oe&&(Pe=st?Oe(re,nt,st,Xe):Oe(re)),Pe!==void 0)return Pe;if(!E(re))return re;var ke=b(re);if(ke){if(Pe=v(re),!Ue)return l(re,Pe)}else{var ct=g(re),It=ct==R||ct==Q;if(k(re))return a(re,Ue);if(ct==X||ct==M||It&&!st){if(Pe=Ge||It?{}:N(re),!Ue)return Ge?h(re,i(Pe,re)):u(re,s(Pe,re))}else{if(!be[ct])return st?re:{};Pe=w(re,ct,Ue)}}Xe||(Xe=new e);var ae=Xe.get(re);if(ae)return ae;Xe.set(re,Pe),C(re)?re.forEach(function(Ce){Pe.add(ue(Ce,pe,Oe,Ce,re,Xe))}):_(re)&&re.forEach(function(Ce,Ve){Pe.set(Ve,ue(Ce,pe,Oe,Ve,re,Xe))});var Le=it?Ge?f:p:Ge?I:j,ze=ke?void 0:Le(re);return t(ze||re,function(Ce,Ve){ze&&(Ve=Ce,Ce=re[Ve]),n(Pe,Ve,ue(Ce,pe,Oe,Ve,re,Xe))}),Pe}return tm=ue,tm}var nm,Q_;function s6(){if(Q_)return nm;Q_=1;var e=dR(),t=4;function n(s){return e(s,t)}return nm=n,nm}var rm,Z_;function Qw(){if(Z_)return rm;Z_=1;function e(t){return function(){return t}}return rm=e,rm}var sm,J_;function o6(){if(J_)return sm;J_=1;function e(t){return function(n,s,i){for(var a=-1,l=Object(n),u=i(n),h=u.length;h--;){var p=u[t?h:++a];if(s(l[p],p,l)===!1)break}return n}}return sm=e,sm}var om,eS;function Zw(){if(eS)return om;eS=1;var e=o6(),t=e();return om=t,om}var im,tS;function Jw(){if(tS)return im;tS=1;var e=Zw(),t=qs();function n(s,i){return s&&e(s,i,t)}return im=n,im}var am,nS;function i6(){if(nS)return am;nS=1;var e=es();function t(n,s){return function(i,a){if(i==null)return i;if(!e(i))return n(i,a);for(var l=i.length,u=s?l:-1,h=Object(i);(s?u--:++u<l)&&a(h[u],u,h)!==!1;);return i}}return am=t,am}var lm,rS;function sd(){if(rS)return lm;rS=1;var e=Jw(),t=i6(),n=t(e);return lm=n,lm}var cm,sS;function jo(){if(sS)return cm;sS=1;function e(t){return t}return cm=e,cm}var um,oS;function fR(){if(oS)return um;oS=1;var e=jo();function t(n){return typeof n=="function"?n:e}return um=t,um}var dm,iS;function hR(){if(iS)return dm;iS=1;var e=Ww(),t=sd(),n=fR(),s=Mt();function i(a,l){var u=s(a)?e:t;return u(a,n(l))}return dm=i,dm}var fm,aS;function pR(){return aS||(aS=1,fm=hR()),fm}var hm,lS;function a6(){if(lS)return hm;lS=1;var e=sd();function t(n,s){var i=[];return e(n,function(a,l,u){s(a,l,u)&&i.push(a)}),i}return hm=t,hm}var pm,cS;function l6(){if(cS)return pm;cS=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return pm=t,pm}var mm,uS;function c6(){if(uS)return mm;uS=1;function e(t){return this.__data__.has(t)}return mm=e,mm}var gm,dS;function mR(){if(dS)return gm;dS=1;var e=Uw(),t=l6(),n=c6();function s(i){var a=-1,l=i==null?0:i.length;for(this.__data__=new e;++a<l;)this.add(i[a])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,gm=s,gm}var ym,fS;function u6(){if(fS)return ym;fS=1;function e(t,n){for(var s=-1,i=t==null?0:t.length;++s<i;)if(n(t[s],s,t))return!0;return!1}return ym=e,ym}var vm,hS;function gR(){if(hS)return vm;hS=1;function e(t,n){return t.has(n)}return vm=e,vm}var wm,pS;function yR(){if(pS)return wm;pS=1;var e=mR(),t=u6(),n=gR(),s=1,i=2;function a(l,u,h,p,f,g){var v=h&s,w=l.length,N=u.length;if(w!=N&&!(v&&N>w))return!1;var b=g.get(l),k=g.get(u);if(b&&k)return b==u&&k==l;var _=-1,E=!0,C=h&i?new e:void 0;for(g.set(l,u),g.set(u,l);++_<w;){var j=l[_],I=u[_];if(p)var O=v?p(I,j,_,u,l,g):p(j,I,_,l,u,g);if(O!==void 0){if(O)continue;E=!1;break}if(C){if(!t(u,function(P,z){if(!n(C,z)&&(j===P||f(j,P,h,p,g)))return C.push(z)})){E=!1;break}}else if(!(j===I||f(j,I,h,p,g))){E=!1;break}}return g.delete(l),g.delete(u),E}return wm=a,wm}var xm,mS;function d6(){if(mS)return xm;mS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(i,a){s[++n]=[a,i]}),s}return xm=e,xm}var bm,gS;function e0(){if(gS)return bm;gS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(i){s[++n]=i}),s}return bm=e,bm}var km,yS;function f6(){if(yS)return km;yS=1;var e=Zi(),t=aR(),n=Qi(),s=yR(),i=d6(),a=e0(),l=1,u=2,h="[object Boolean]",p="[object Date]",f="[object Error]",g="[object Map]",v="[object Number]",w="[object RegExp]",N="[object Set]",b="[object String]",k="[object Symbol]",_="[object ArrayBuffer]",E="[object DataView]",C=e?e.prototype:void 0,j=C?C.valueOf:void 0;function I(O,P,z,M,A,q,G){switch(z){case E:if(O.byteLength!=P.byteLength||O.byteOffset!=P.byteOffset)return!1;O=O.buffer,P=P.buffer;case _:return!(O.byteLength!=P.byteLength||!q(new t(O),new t(P)));case h:case p:case v:return n(+O,+P);case f:return O.name==P.name&&O.message==P.message;case w:case b:return O==P+"";case g:var Y=i;case N:var R=M&l;if(Y||(Y=a),O.size!=P.size&&!R)return!1;var Q=G.get(O);if(Q)return Q==P;M|=u,G.set(O,P);var H=s(Y(O),Y(P),M,A,q,G);return G.delete(O),H;case k:if(j)return j.call(O)==j.call(P)}return!1}return km=I,km}var _m,vS;function h6(){if(vS)return _m;vS=1;var e=oR(),t=1,n=Object.prototype,s=n.hasOwnProperty;function i(a,l,u,h,p,f){var g=u&t,v=e(a),w=v.length,N=e(l),b=N.length;if(w!=b&&!g)return!1;for(var k=w;k--;){var _=v[k];if(!(g?_ in l:s.call(l,_)))return!1}var E=f.get(a),C=f.get(l);if(E&&C)return E==l&&C==a;var j=!0;f.set(a,l),f.set(l,a);for(var I=g;++k<w;){_=v[k];var O=a[_],P=l[_];if(h)var z=g?h(P,O,_,l,a,f):h(O,P,_,a,l,f);if(!(z===void 0?O===P||p(O,P,u,h,f):z)){j=!1;break}I||(I=_=="constructor")}if(j&&!I){var M=a.constructor,A=l.constructor;M!=A&&"constructor"in a&&"constructor"in l&&!(typeof M=="function"&&M instanceof M&&typeof A=="function"&&A instanceof A)&&(j=!1)}return f.delete(a),f.delete(l),j}return _m=i,_m}var Sm,wS;function p6(){if(wS)return Sm;wS=1;var e=Qu(),t=yR(),n=f6(),s=h6(),i=ea(),a=Mt(),l=Ji(),u=Ll(),h=1,p="[object Arguments]",f="[object Array]",g="[object Object]",v=Object.prototype,w=v.hasOwnProperty;function N(b,k,_,E,C,j){var I=a(b),O=a(k),P=I?f:i(b),z=O?f:i(k);P=P==p?g:P,z=z==p?g:z;var M=P==g,A=z==g,q=P==z;if(q&&l(b)){if(!l(k))return!1;I=!0,M=!1}if(q&&!M)return j||(j=new e),I||u(b)?t(b,k,_,E,C,j):n(b,k,P,_,E,C,j);if(!(_&h)){var G=M&&w.call(b,"__wrapped__"),Y=A&&w.call(k,"__wrapped__");if(G||Y){var R=G?b.value():b,Q=Y?k.value():k;return j||(j=new e),C(R,Q,_,E,j)}}return q?(j||(j=new e),s(b,k,_,E,C,j)):!1}return Sm=N,Sm}var Nm,xS;function vR(){if(xS)return Nm;xS=1;var e=p6(),t=jr();function n(s,i,a,l,u){return s===i?!0:s==null||i==null||!t(s)&&!t(i)?s!==s&&i!==i:e(s,i,a,l,n,u)}return Nm=n,Nm}var Em,bS;function m6(){if(bS)return Em;bS=1;var e=Qu(),t=vR(),n=1,s=2;function i(a,l,u,h){var p=u.length,f=p,g=!h;if(a==null)return!f;for(a=Object(a);p--;){var v=u[p];if(g&&v[2]?v[1]!==a[v[0]]:!(v[0]in a))return!1}for(;++p<f;){v=u[p];var w=v[0],N=a[w],b=v[1];if(g&&v[2]){if(N===void 0&&!(w in a))return!1}else{var k=new e;if(h)var _=h(N,b,w,a,l,k);if(!(_===void 0?t(b,N,n|s,h,k):_))return!1}}return!0}return Em=i,Em}var Cm,kS;function wR(){if(kS)return Cm;kS=1;var e=qn();function t(n){return n===n&&!e(n)}return Cm=t,Cm}var jm,_S;function g6(){if(_S)return jm;_S=1;var e=wR(),t=qs();function n(s){for(var i=t(s),a=i.length;a--;){var l=i[a],u=s[l];i[a]=[l,u,e(u)]}return i}return jm=n,jm}var Tm,SS;function xR(){if(SS)return Tm;SS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return Tm=e,Tm}var Rm,NS;function y6(){if(NS)return Rm;NS=1;var e=m6(),t=g6(),n=xR();function s(i){var a=t(i);return a.length==1&&a[0][2]?n(a[0][0],a[0][1]):function(l){return l===i||e(l,i,a)}}return Rm=s,Rm}var Am,ES;function ta(){if(ES)return Am;ES=1;var e=No(),t=jr(),n="[object Symbol]";function s(i){return typeof i=="symbol"||t(i)&&e(i)==n}return Am=s,Am}var Mm,CS;function t0(){if(CS)return Mm;CS=1;var e=Mt(),t=ta(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function i(a,l){if(e(a))return!1;var u=typeof a;return u=="number"||u=="symbol"||u=="boolean"||a==null||t(a)?!0:s.test(a)||!n.test(a)||l!=null&&a in Object(l)}return Mm=i,Mm}var Im,jS;function v6(){if(jS)return Im;jS=1;var e=Uw(),t="Expected a function";function n(s,i){if(typeof s!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var l=arguments,u=i?i.apply(this,l):l[0],h=a.cache;if(h.has(u))return h.get(u);var p=s.apply(this,l);return a.cache=h.set(u,p)||h,p};return a.cache=new(n.Cache||e),a}return n.Cache=e,Im=n,Im}var Om,TS;function w6(){if(TS)return Om;TS=1;var e=v6(),t=500;function n(s){var i=e(s,function(l){return a.size===t&&a.clear(),l}),a=i.cache;return i}return Om=n,Om}var Pm,RS;function x6(){if(RS)return Pm;RS=1;var e=w6(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(l,u,h,p){a.push(h?p.replace(n,"$1"):u||l)}),a});return Pm=s,Pm}var $m,AS;function od(){if(AS)return $m;AS=1;function e(t,n){for(var s=-1,i=t==null?0:t.length,a=Array(i);++s<i;)a[s]=n(t[s],s,t);return a}return $m=e,$m}var Lm,MS;function b6(){if(MS)return Lm;MS=1;var e=Zi(),t=od(),n=Mt(),s=ta(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function l(u){if(typeof u=="string")return u;if(n(u))return t(u,l)+"";if(s(u))return a?a.call(u):"";var h=u+"";return h=="0"&&1/u==-1/0?"-0":h}return Lm=l,Lm}var qm,IS;function bR(){if(IS)return qm;IS=1;var e=b6();function t(n){return n==null?"":e(n)}return qm=t,qm}var Dm,OS;function id(){if(OS)return Dm;OS=1;var e=Mt(),t=t0(),n=x6(),s=bR();function i(a,l){return e(a)?a:t(a,l)?[a]:n(s(a))}return Dm=i,Dm}var Fm,PS;function ql(){if(PS)return Fm;PS=1;var e=ta();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return Fm=t,Fm}var zm,$S;function ad(){if($S)return zm;$S=1;var e=id(),t=ql();function n(s,i){i=e(i,s);for(var a=0,l=i.length;s!=null&&a<l;)s=s[t(i[a++])];return a&&a==l?s:void 0}return zm=n,zm}var Bm,LS;function k6(){if(LS)return Bm;LS=1;var e=ad();function t(n,s,i){var a=n==null?void 0:e(n,s);return a===void 0?i:a}return Bm=t,Bm}var Um,qS;function _6(){if(qS)return Um;qS=1;function e(t,n){return t!=null&&n in Object(t)}return Um=e,Um}var Wm,DS;function kR(){if(DS)return Wm;DS=1;var e=id(),t=$l(),n=Mt(),s=ed(),i=Hw(),a=ql();function l(u,h,p){h=e(h,u);for(var f=-1,g=h.length,v=!1;++f<g;){var w=a(h[f]);if(!(v=u!=null&&p(u,w)))break;u=u[w]}return v||++f!=g?v:(g=u==null?0:u.length,!!g&&i(g)&&s(w,g)&&(n(u)||t(u)))}return Wm=l,Wm}var Hm,FS;function _R(){if(FS)return Hm;FS=1;var e=_6(),t=kR();function n(s,i){return s!=null&&t(s,i,e)}return Hm=n,Hm}var Gm,zS;function S6(){if(zS)return Gm;zS=1;var e=vR(),t=k6(),n=_R(),s=t0(),i=wR(),a=xR(),l=ql(),u=1,h=2;function p(f,g){return s(f)&&i(g)?a(l(f),g):function(v){var w=t(v,f);return w===void 0&&w===g?n(v,f):e(g,w,u|h)}}return Gm=p,Gm}var Vm,BS;function SR(){if(BS)return Vm;BS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Vm=e,Vm}var Ym,US;function N6(){if(US)return Ym;US=1;var e=ad();function t(n){return function(s){return e(s,n)}}return Ym=t,Ym}var Km,WS;function E6(){if(WS)return Km;WS=1;var e=SR(),t=N6(),n=t0(),s=ql();function i(a){return n(a)?e(s(a)):t(a)}return Km=i,Km}var Xm,HS;function ts(){if(HS)return Xm;HS=1;var e=y6(),t=S6(),n=jo(),s=Mt(),i=E6();function a(l){return typeof l=="function"?l:l==null?n:typeof l=="object"?s(l)?t(l[0],l[1]):e(l):i(l)}return Xm=a,Xm}var Qm,GS;function NR(){if(GS)return Qm;GS=1;var e=tR(),t=a6(),n=ts(),s=Mt();function i(a,l){var u=s(a)?e:t;return u(a,n(l,3))}return Qm=i,Qm}var Zm,VS;function C6(){if(VS)return Zm;VS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,i){return s!=null&&t.call(s,i)}return Zm=n,Zm}var Jm,YS;function ER(){if(YS)return Jm;YS=1;var e=C6(),t=kR();function n(s,i){return s!=null&&t(s,i,e)}return Jm=n,Jm}var eg,KS;function j6(){if(KS)return eg;KS=1;var e=Vw(),t=ea(),n=$l(),s=Mt(),i=es(),a=Ji(),l=nd(),u=Ll(),h="[object Map]",p="[object Set]",f=Object.prototype,g=f.hasOwnProperty;function v(w){if(w==null)return!0;if(i(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||a(w)||u(w)||n(w)))return!w.length;var N=t(w);if(N==h||N==p)return!w.size;if(l(w))return!e(w).length;for(var b in w)if(g.call(w,b))return!1;return!0}return eg=v,eg}var tg,XS;function CR(){if(XS)return tg;XS=1;function e(t){return t===void 0}return tg=e,tg}var ng,QS;function jR(){if(QS)return ng;QS=1;var e=sd(),t=es();function n(s,i){var a=-1,l=t(s)?Array(s.length):[];return e(s,function(u,h,p){l[++a]=i(u,h,p)}),l}return ng=n,ng}var rg,ZS;function TR(){if(ZS)return rg;ZS=1;var e=od(),t=ts(),n=jR(),s=Mt();function i(a,l){var u=s(a)?e:n;return u(a,t(l,3))}return rg=i,rg}var sg,JS;function T6(){if(JS)return sg;JS=1;function e(t,n,s,i){var a=-1,l=t==null?0:t.length;for(i&&l&&(s=t[++a]);++a<l;)s=n(s,t[a],a,t);return s}return sg=e,sg}var og,eN;function R6(){if(eN)return og;eN=1;function e(t,n,s,i,a){return a(t,function(l,u,h){s=i?(i=!1,l):n(s,l,u,h)}),s}return og=e,og}var ig,tN;function RR(){if(tN)return ig;tN=1;var e=T6(),t=sd(),n=ts(),s=R6(),i=Mt();function a(l,u,h){var p=i(l)?e:s,f=arguments.length<3;return p(l,n(u,4),h,f,t)}return ig=a,ig}var ag,nN;function A6(){if(nN)return ag;nN=1;var e=No(),t=Mt(),n=jr(),s="[object String]";function i(a){return typeof a=="string"||!t(a)&&n(a)&&e(a)==s}return ag=i,ag}var lg,rN;function M6(){if(rN)return lg;rN=1;var e=SR(),t=e("length");return lg=t,lg}var cg,sN;function I6(){if(sN)return cg;sN=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",i=t+n+s,a="\\ufe0e\\ufe0f",l="\\u200d",u=RegExp("["+l+e+i+a+"]");function h(p){return u.test(p)}return cg=h,cg}var ug,oN;function O6(){if(oN)return ug;oN=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",i=t+n+s,a="\\ufe0e\\ufe0f",l="["+e+"]",u="["+i+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+h+")",f="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",v="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",N=p+"?",b="["+a+"]?",k="(?:"+w+"(?:"+[f,g,v].join("|")+")"+b+N+")*",_=b+N+k,E="(?:"+[f+u+"?",u,g,v,l].join("|")+")",C=RegExp(h+"(?="+h+")|"+E+_,"g");function j(I){for(var O=C.lastIndex=0;C.test(I);)++O;return O}return ug=j,ug}var dg,iN;function P6(){if(iN)return dg;iN=1;var e=M6(),t=I6(),n=O6();function s(i){return t(i)?n(i):e(i)}return dg=s,dg}var fg,aN;function $6(){if(aN)return fg;aN=1;var e=Vw(),t=ea(),n=es(),s=A6(),i=P6(),a="[object Map]",l="[object Set]";function u(h){if(h==null)return 0;if(n(h))return s(h)?i(h):h.length;var p=t(h);return p==a||p==l?h.size:e(h).length}return fg=u,fg}var hg,lN;function L6(){if(lN)return hg;lN=1;var e=Ww(),t=cR(),n=Jw(),s=ts(),i=rd(),a=Mt(),l=Ji(),u=Ol(),h=qn(),p=Ll();function f(g,v,w){var N=a(g),b=N||l(g)||p(g);if(v=s(v,4),w==null){var k=g&&g.constructor;b?w=N?new k:[]:h(g)?w=u(k)?t(i(g)):{}:w={}}return(b?e:n)(g,function(_,E,C){return v(w,_,E,C)}),w}return hg=f,hg}var pg,cN;function q6(){if(cN)return pg;cN=1;var e=Zi(),t=$l(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function i(a){return n(a)||t(a)||!!(s&&a&&a[s])}return pg=i,pg}var mg,uN;function n0(){if(uN)return mg;uN=1;var e=Kw(),t=q6();function n(s,i,a,l,u){var h=-1,p=s.length;for(a||(a=t),u||(u=[]);++h<p;){var f=s[h];i>0&&a(f)?i>1?n(f,i-1,a,l,u):e(u,f):l||(u[u.length]=f)}return u}return mg=n,mg}var gg,dN;function D6(){if(dN)return gg;dN=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 gg=e,gg}var yg,fN;function AR(){if(fN)return yg;fN=1;var e=D6(),t=Math.max;function n(s,i,a){return i=t(i===void 0?s.length-1:i,0),function(){for(var l=arguments,u=-1,h=t(l.length-i,0),p=Array(h);++u<h;)p[u]=l[i+u];u=-1;for(var f=Array(i+1);++u<i;)f[u]=l[u];return f[i]=a(p),e(s,this,f)}}return yg=n,yg}var vg,hN;function F6(){if(hN)return vg;hN=1;var e=Qw(),t=XT(),n=jo(),s=t?function(i,a){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:n;return vg=s,vg}var wg,pN;function z6(){if(pN)return wg;pN=1;var e=800,t=16,n=Date.now;function s(i){var a=0,l=0;return function(){var u=n(),h=t-(u-l);if(l=u,h>0){if(++a>=e)return arguments[0]}else a=0;return i.apply(void 0,arguments)}}return wg=s,wg}var xg,mN;function MR(){if(mN)return xg;mN=1;var e=F6(),t=z6(),n=t(e);return xg=n,xg}var bg,gN;function ld(){if(gN)return bg;gN=1;var e=jo(),t=AR(),n=MR();function s(i,a){return n(t(i,a,e),i+"")}return bg=s,bg}var kg,yN;function IR(){if(yN)return kg;yN=1;function e(t,n,s,i){for(var a=t.length,l=s+(i?1:-1);i?l--:++l<a;)if(n(t[l],l,t))return l;return-1}return kg=e,kg}var _g,vN;function B6(){if(vN)return _g;vN=1;function e(t){return t!==t}return _g=e,_g}var Sg,wN;function U6(){if(wN)return Sg;wN=1;function e(t,n,s){for(var i=s-1,a=t.length;++i<a;)if(t[i]===n)return i;return-1}return Sg=e,Sg}var Ng,xN;function W6(){if(xN)return Ng;xN=1;var e=IR(),t=B6(),n=U6();function s(i,a,l){return a===a?n(i,a,l):e(i,t,l)}return Ng=s,Ng}var Eg,bN;function H6(){if(bN)return Eg;bN=1;var e=W6();function t(n,s){var i=n==null?0:n.length;return!!i&&e(n,s,0)>-1}return Eg=t,Eg}var Cg,kN;function G6(){if(kN)return Cg;kN=1;function e(t,n,s){for(var i=-1,a=t==null?0:t.length;++i<a;)if(s(n,t[i]))return!0;return!1}return Cg=e,Cg}var jg,_N;function V6(){if(_N)return jg;_N=1;function e(){}return jg=e,jg}var Tg,SN;function Y6(){if(SN)return Tg;SN=1;var e=iR(),t=V6(),n=e0(),s=1/0,i=e&&1/n(new e([,-0]))[1]==s?function(a){return new e(a)}:t;return Tg=i,Tg}var Rg,NN;function K6(){if(NN)return Rg;NN=1;var e=mR(),t=H6(),n=G6(),s=gR(),i=Y6(),a=e0(),l=200;function u(h,p,f){var g=-1,v=t,w=h.length,N=!0,b=[],k=b;if(f)N=!1,v=n;else if(w>=l){var _=p?null:i(h);if(_)return a(_);N=!1,v=s,k=new e}else k=p?[]:b;e:for(;++g<w;){var E=h[g],C=p?p(E):E;if(E=f||E!==0?E:0,N&&C===C){for(var j=k.length;j--;)if(k[j]===C)continue e;p&&k.push(C),b.push(E)}else v(k,C,f)||(k!==b&&k.push(C),b.push(E))}return b}return Rg=u,Rg}var Ag,EN;function OR(){if(EN)return Ag;EN=1;var e=es(),t=jr();function n(s){return t(s)&&e(s)}return Ag=n,Ag}var Mg,CN;function X6(){if(CN)return Mg;CN=1;var e=n0(),t=ld(),n=K6(),s=OR(),i=t(function(a){return n(e(a,1,s,!0))});return Mg=i,Mg}var Ig,jN;function Q6(){if(jN)return Ig;jN=1;var e=od();function t(n,s){return e(s,function(i){return n[i]})}return Ig=t,Ig}var Og,TN;function PR(){if(TN)return Og;TN=1;var e=Q6(),t=qs();function n(s){return s==null?[]:e(s,t(s))}return Og=n,Og}var Pg,RN;function Dn(){if(RN)return Pg;RN=1;var e;if(typeof zw=="function")try{e={clone:s6(),constant:Qw(),each:pR(),filter:NR(),has:ER(),isArray:Mt(),isEmpty:j6(),isFunction:Ol(),isUndefined:CR(),keys:qs(),map:TR(),reduce:RR(),size:$6(),transform:L6(),union:X6(),values:PR()}}catch{}return e||(e=window._),Pg=e,Pg}var $g,AN;function r0(){if(AN)return $g;AN=1;var e=Dn();$g=i;var t="\0",n="\0",s="";function i(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(f){return this._label=f,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._in[g])})},i.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._out[g])})},i.prototype.setNodes=function(f,g){var v=arguments,w=this;return e.each(f,function(N){v.length>1?w.setNode(N,g):w.setNode(N)}),this},i.prototype.setNode=function(f,g){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=g),this):(this._nodes[f]=arguments.length>1?g:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},i.prototype.node=function(f){return this._nodes[f]},i.prototype.hasNode=function(f){return e.has(this._nodes,f)},i.prototype.removeNode=function(f){var g=this;if(e.has(this._nodes,f)){var v=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(w){g.setParent(w)}),delete this._children[f]),e.each(e.keys(this._in[f]),v),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),v),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},i.prototype.setParent=function(f,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 v=g;!e.isUndefined(v);v=this.parent(v))if(v===f)throw new Error("Setting "+g+" as parent of "+f+" would create a cycle");this.setNode(g)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=g,this._children[g][f]=!0,this},i.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},i.prototype.parent=function(f){if(this._isCompound){var g=this._parent[f];if(g!==n)return g}},i.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var g=this._children[f];if(g)return e.keys(g)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},i.prototype.predecessors=function(f){var g=this._preds[f];if(g)return e.keys(g)},i.prototype.successors=function(f){var g=this._sucs[f];if(g)return e.keys(g)},i.prototype.neighbors=function(f){var g=this.predecessors(f);if(g)return e.union(g,this.successors(f))},i.prototype.isLeaf=function(f){var g;return this.isDirected()?g=this.successors(f):g=this.neighbors(f),g.length===0},i.prototype.filterNodes=function(f){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var v=this;e.each(this._nodes,function(b,k){f(k)&&g.setNode(k,b)}),e.each(this._edgeObjs,function(b){g.hasNode(b.v)&&g.hasNode(b.w)&&g.setEdge(b,v.edge(b))});var w={};function N(b){var k=v.parent(b);return k===void 0||g.hasNode(k)?(w[b]=k,k):k in w?w[k]:N(k)}return this._isCompound&&e.each(g.nodes(),function(b){g.setParent(b,N(b))}),g},i.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(f,g){var v=this,w=arguments;return e.reduce(f,function(N,b){return w.length>1?v.setEdge(N,b,g):v.setEdge(N,b),b}),this},i.prototype.setEdge=function(){var f,g,v,w,N=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,g=b.w,v=b.name,arguments.length===2&&(w=arguments[1],N=!0)):(f=b,g=arguments[1],v=arguments[3],arguments.length>2&&(w=arguments[2],N=!0)),f=""+f,g=""+g,e.isUndefined(v)||(v=""+v);var k=u(this._isDirected,f,g,v);if(e.has(this._edgeLabels,k))return N&&(this._edgeLabels[k]=w),this;if(!e.isUndefined(v)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(g),this._edgeLabels[k]=N?w:this._defaultEdgeLabelFn(f,g,v);var _=h(this._isDirected,f,g,v);return f=_.v,g=_.w,Object.freeze(_),this._edgeObjs[k]=_,a(this._preds[g],f),a(this._sucs[f],g),this._in[g][k]=_,this._out[f][k]=_,this._edgeCount++,this},i.prototype.edge=function(f,g,v){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,v);return this._edgeLabels[w]},i.prototype.hasEdge=function(f,g,v){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,v);return e.has(this._edgeLabels,w)},i.prototype.removeEdge=function(f,g,v){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,v),N=this._edgeObjs[w];return N&&(f=N.v,g=N.w,delete this._edgeLabels[w],delete this._edgeObjs[w],l(this._preds[g],f),l(this._sucs[f],g),delete this._in[g][w],delete this._out[f][w],this._edgeCount--),this},i.prototype.inEdges=function(f,g){var v=this._in[f];if(v){var w=e.values(v);return g?e.filter(w,function(N){return N.v===g}):w}},i.prototype.outEdges=function(f,g){var v=this._out[f];if(v){var w=e.values(v);return g?e.filter(w,function(N){return N.w===g}):w}},i.prototype.nodeEdges=function(f,g){var v=this.inEdges(f,g);if(v)return v.concat(this.outEdges(f,g))};function a(f,g){f[g]?f[g]++:f[g]=1}function l(f,g){--f[g]||delete f[g]}function u(f,g,v,w){var N=""+g,b=""+v;if(!f&&N>b){var k=N;N=b,b=k}return N+s+b+s+(e.isUndefined(w)?t:w)}function h(f,g,v,w){var N=""+g,b=""+v;if(!f&&N>b){var k=N;N=b,b=k}var _={v:N,w:b};return w&&(_.name=w),_}function p(f,g){return u(f,g.v,g.w,g.name)}return $g}var Lg,MN;function Z6(){return MN||(MN=1,Lg="2.1.8"),Lg}var qg,IN;function J6(){return IN||(IN=1,qg={Graph:r0(),version:Z6()}),qg}var Dg,ON;function ez(){if(ON)return Dg;ON=1;var e=Dn(),t=r0();Dg={write:n,read:a};function n(l){var u={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:s(l),edges:i(l)};return e.isUndefined(l.graph())||(u.value=e.clone(l.graph())),u}function s(l){return e.map(l.nodes(),function(u){var h=l.node(u),p=l.parent(u),f={v:u};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function i(l){return e.map(l.edges(),function(u){var h=l.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(h)||(p.value=h),p})}function a(l){var u=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(h){u.setNode(h.v,h.value),h.parent&&u.setParent(h.v,h.parent)}),e.each(l.edges,function(h){u.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),u}return Dg}var Fg,PN;function tz(){if(PN)return Fg;PN=1;var e=Dn();Fg=t;function t(n){var s={},i=[],a;function l(u){e.has(s,u)||(s[u]=!0,a.push(u),e.each(n.successors(u),l),e.each(n.predecessors(u),l))}return e.each(n.nodes(),function(u){a=[],l(u),a.length&&i.push(a)}),i}return Fg}var zg,$N;function $R(){if($N)return zg;$N=1;var e=Dn();zg=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 i=this._keyIndices;if(n=String(n),!e.has(i,n)){var a=this._arr,l=a.length;return i[n]=l,a.push({key:n,priority:s}),this._decrease(l),!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 i=this._keyIndices[n];if(s>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+s);this._arr[i].priority=s,this._decrease(i)},t.prototype._heapify=function(n){var s=this._arr,i=2*n,a=i+1,l=n;i<s.length&&(l=s[i].priority<s[l].priority?i:l,a<s.length&&(l=s[a].priority<s[l].priority?a:l),l!==n&&(this._swap(n,l),this._heapify(l)))},t.prototype._decrease=function(n){for(var s=this._arr,i=s[n].priority,a;n!==0&&(a=n>>1,!(s[a].priority<i));)this._swap(n,a),n=a},t.prototype._swap=function(n,s){var i=this._arr,a=this._keyIndices,l=i[n],u=i[s];i[n]=u,i[s]=l,a[u.key]=n,a[l.key]=s},zg}var Bg,LN;function LR(){if(LN)return Bg;LN=1;var e=Dn(),t=$R();Bg=s;var n=e.constant(1);function s(a,l,u,h){return i(a,String(l),u||n,h||function(p){return a.outEdges(p)})}function i(a,l,u,h){var p={},f=new t,g,v,w=function(N){var b=N.v!==g?N.v:N.w,k=p[b],_=u(N),E=v.distance+_;if(_<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+_);E<k.distance&&(k.distance=E,k.predecessor=g,f.decrease(b,E))};for(a.nodes().forEach(function(N){var b=N===l?0:Number.POSITIVE_INFINITY;p[N]={distance:b},f.add(N,b)});f.size()>0&&(g=f.removeMin(),v=p[g],v.distance!==Number.POSITIVE_INFINITY);)h(g).forEach(w);return p}return Bg}var Ug,qN;function nz(){if(qN)return Ug;qN=1;var e=LR(),t=Dn();Ug=n;function n(s,i,a){return t.transform(s.nodes(),function(l,u){l[u]=e(s,u,i,a)},{})}return Ug}var Wg,DN;function qR(){if(DN)return Wg;DN=1;var e=Dn();Wg=t;function t(n){var s=0,i=[],a={},l=[];function u(h){var p=a[h]={onStack:!0,lowlink:s,index:s++};if(i.push(h),n.successors(h).forEach(function(v){e.has(a,v)?a[v].onStack&&(p.lowlink=Math.min(p.lowlink,a[v].index)):(u(v),p.lowlink=Math.min(p.lowlink,a[v].lowlink))}),p.lowlink===p.index){var f=[],g;do g=i.pop(),a[g].onStack=!1,f.push(g);while(h!==g);l.push(f)}}return n.nodes().forEach(function(h){e.has(a,h)||u(h)}),l}return Wg}var Hg,FN;function rz(){if(FN)return Hg;FN=1;var e=Dn(),t=qR();Hg=n;function n(s){return e.filter(t(s),function(i){return i.length>1||i.length===1&&s.hasEdge(i[0],i[0])})}return Hg}var Gg,zN;function sz(){if(zN)return Gg;zN=1;var e=Dn();Gg=n;var t=e.constant(1);function n(i,a,l){return s(i,a||t,l||function(u){return i.outEdges(u)})}function s(i,a,l){var u={},h=i.nodes();return h.forEach(function(p){u[p]={},u[p][p]={distance:0},h.forEach(function(f){p!==f&&(u[p][f]={distance:Number.POSITIVE_INFINITY})}),l(p).forEach(function(f){var g=f.v===p?f.w:f.v,v=a(f);u[p][g]={distance:v,predecessor:p}})}),h.forEach(function(p){var f=u[p];h.forEach(function(g){var v=u[g];h.forEach(function(w){var N=v[p],b=f[w],k=v[w],_=N.distance+b.distance;_<k.distance&&(k.distance=_,k.predecessor=b.predecessor)})})}),u}return Gg}var Vg,BN;function DR(){if(BN)return Vg;BN=1;var e=Dn();Vg=t,t.CycleException=n;function t(s){var i={},a={},l=[];function u(h){if(e.has(a,h))throw new n;e.has(i,h)||(a[h]=!0,i[h]=!0,e.each(s.predecessors(h),u),delete a[h],l.push(h))}if(e.each(s.sinks(),u),e.size(i)!==s.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,Vg}var Yg,UN;function oz(){if(UN)return Yg;UN=1;var e=DR();Yg=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Yg}var Kg,WN;function FR(){if(WN)return Kg;WN=1;var e=Dn();Kg=t;function t(s,i,a){e.isArray(i)||(i=[i]);var l=(s.isDirected()?s.successors:s.neighbors).bind(s),u=[],h={};return e.each(i,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,a==="post",h,l,u)}),u}function n(s,i,a,l,u,h){e.has(l,i)||(l[i]=!0,a||h.push(i),e.each(u(i),function(p){n(s,p,a,l,u,h)}),a&&h.push(i))}return Kg}var Xg,HN;function iz(){if(HN)return Xg;HN=1;var e=FR();Xg=t;function t(n,s){return e(n,s,"post")}return Xg}var Qg,GN;function az(){if(GN)return Qg;GN=1;var e=FR();Qg=t;function t(n,s){return e(n,s,"pre")}return Qg}var Zg,VN;function lz(){if(VN)return Zg;VN=1;var e=Dn(),t=r0(),n=$R();Zg=s;function s(i,a){var l=new t,u={},h=new n,p;function f(v){var w=v.v===p?v.w:v.v,N=h.priority(w);if(N!==void 0){var b=a(v);b<N&&(u[w]=p,h.decrease(w,b))}}if(i.nodeCount()===0)return l;e.each(i.nodes(),function(v){h.add(v,Number.POSITIVE_INFINITY),l.setNode(v)}),h.decrease(i.nodes()[0],0);for(var g=!1;h.size()>0;){if(p=h.removeMin(),e.has(u,p))l.setEdge(p,u[p]);else{if(g)throw new Error("Input graph is not connected: "+i);g=!0}i.nodeEdges(p).forEach(f)}return l}return Zg}var Jg,YN;function cz(){return YN||(YN=1,Jg={components:tz(),dijkstra:LR(),dijkstraAll:nz(),findCycles:rz(),floydWarshall:sz(),isAcyclic:oz(),postorder:iz(),preorder:az(),prim:lz(),tarjan:qR(),topsort:DR()}),Jg}var ey,KN;function uz(){if(KN)return ey;KN=1;var e=J6();return ey={Graph:e.Graph,json:ez(),alg:cz(),version:e.version},ey}var ty,XN;function cr(){if(XN)return ty;XN=1;var e;if(typeof zw=="function")try{e=uz()}catch{}return e||(e=window.graphlib),ty=e,ty}var ny,QN;function dz(){if(QN)return ny;QN=1;var e=dR(),t=1,n=4;function s(i){return e(i,t|n)}return ny=s,ny}var ry,ZN;function cd(){if(ZN)return ry;ZN=1;var e=Qi(),t=es(),n=ed(),s=qn();function i(a,l,u){if(!s(u))return!1;var h=typeof l;return(h=="number"?t(u)&&n(l,u.length):h=="string"&&l in u)?e(u[l],a):!1}return ry=i,ry}var sy,JN;function fz(){if(JN)return sy;JN=1;var e=ld(),t=Qi(),n=cd(),s=Co(),i=Object.prototype,a=i.hasOwnProperty,l=e(function(u,h){u=Object(u);var p=-1,f=h.length,g=f>2?h[2]:void 0;for(g&&n(h[0],h[1],g)&&(f=1);++p<f;)for(var v=h[p],w=s(v),N=-1,b=w.length;++N<b;){var k=w[N],_=u[k];(_===void 0||t(_,i[k])&&!a.call(u,k))&&(u[k]=v[k])}return u});return sy=l,sy}var oy,eE;function hz(){if(eE)return oy;eE=1;var e=ts(),t=es(),n=qs();function s(i){return function(a,l,u){var h=Object(a);if(!t(a)){var p=e(l,3);a=n(a),l=function(g){return p(h[g],g,h)}}var f=i(a,l,u);return f>-1?h[p?a[f]:f]:void 0}}return oy=s,oy}var iy,tE;function pz(){if(tE)return iy;tE=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 ay,nE;function mz(){if(nE)return ay;nE=1;var e=pz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return ay=n,ay}var ly,rE;function gz(){if(rE)return ly;rE=1;var e=mz(),t=qn(),n=ta(),s=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=a.test(p);return g||l.test(p)?u(p.slice(2),g?2:8):i.test(p)?s:+p}return ly=h,ly}var cy,sE;function zR(){if(sE)return cy;sE=1;var e=gz(),t=1/0,n=17976931348623157e292;function s(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var a=i<0?-1:1;return a*n}return i===i?i:0}return cy=s,cy}var uy,oE;function yz(){if(oE)return uy;oE=1;var e=zR();function t(n){var s=e(n),i=s%1;return s===s?i?s-i:s:0}return uy=t,uy}var dy,iE;function vz(){if(iE)return dy;iE=1;var e=IR(),t=ts(),n=yz(),s=Math.max;function i(a,l,u){var h=a==null?0:a.length;if(!h)return-1;var p=u==null?0:n(u);return p<0&&(p=s(h+p,0)),e(a,t(l,3),p)}return dy=i,dy}var fy,aE;function wz(){if(aE)return fy;aE=1;var e=hz(),t=vz(),n=e(t);return fy=n,fy}var hy,lE;function BR(){if(lE)return hy;lE=1;var e=n0();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return hy=t,hy}var py,cE;function xz(){if(cE)return py;cE=1;var e=Zw(),t=fR(),n=Co();function s(i,a){return i==null?i:e(i,t(a),n)}return py=s,py}var my,uE;function bz(){if(uE)return my;uE=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return my=e,my}var gy,dE;function kz(){if(dE)return gy;dE=1;var e=Zu(),t=Jw(),n=ts();function s(i,a){var l={};return a=n(a,3),t(i,function(u,h,p){e(l,h,a(u,h,p))}),l}return gy=s,gy}var yy,fE;function s0(){if(fE)return yy;fE=1;var e=ta();function t(n,s,i){for(var a=-1,l=n.length;++a<l;){var u=n[a],h=s(u);if(h!=null&&(p===void 0?h===h&&!e(h):i(h,p)))var p=h,f=u}return f}return yy=t,yy}var vy,hE;function _z(){if(hE)return vy;hE=1;function e(t,n){return t>n}return vy=e,vy}var wy,pE;function Sz(){if(pE)return wy;pE=1;var e=s0(),t=_z(),n=jo();function s(i){return i&&i.length?e(i,n,t):void 0}return wy=s,wy}var xy,mE;function UR(){if(mE)return xy;mE=1;var e=Zu(),t=Qi();function n(s,i,a){(a!==void 0&&!t(s[i],a)||a===void 0&&!(i in s))&&e(s,i,a)}return xy=n,xy}var by,gE;function Nz(){if(gE)return by;gE=1;var e=No(),t=rd(),n=jr(),s="[object Object]",i=Function.prototype,a=Object.prototype,l=i.toString,u=a.hasOwnProperty,h=l.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var g=t(f);if(g===null)return!0;var v=u.call(g,"constructor")&&g.constructor;return typeof v=="function"&&v instanceof v&&l.call(v)==h}return by=p,by}var ky,yE;function WR(){if(yE)return ky;yE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return ky=e,ky}var _y,vE;function Ez(){if(vE)return _y;vE=1;var e=Pl(),t=Co();function n(s){return e(s,t(s))}return _y=n,_y}var Sy,wE;function Cz(){if(wE)return Sy;wE=1;var e=UR(),t=JT(),n=lR(),s=eR(),i=uR(),a=$l(),l=Mt(),u=OR(),h=Ji(),p=Ol(),f=qn(),g=Nz(),v=Ll(),w=WR(),N=Ez();function b(k,_,E,C,j,I,O){var P=w(k,E),z=w(_,E),M=O.get(z);if(M){e(k,E,M);return}var A=I?I(P,z,E+"",k,_,O):void 0,q=A===void 0;if(q){var G=l(z),Y=!G&&h(z),R=!G&&!Y&&v(z);A=z,G||Y||R?l(P)?A=P:u(P)?A=s(P):Y?(q=!1,A=t(z,!0)):R?(q=!1,A=n(z,!0)):A=[]:g(z)||a(z)?(A=P,a(P)?A=N(P):(!f(P)||p(P))&&(A=i(z))):q=!1}q&&(O.set(z,A),j(A,z,C,I,O),O.delete(z)),e(k,E,A)}return Sy=b,Sy}var Ny,xE;function jz(){if(xE)return Ny;xE=1;var e=Qu(),t=UR(),n=Zw(),s=Cz(),i=qn(),a=Co(),l=WR();function u(h,p,f,g,v){h!==p&&n(p,function(w,N){if(v||(v=new e),i(w))s(h,p,N,f,u,g,v);else{var b=g?g(l(h,N),w,N+"",h,p,v):void 0;b===void 0&&(b=w),t(h,N,b)}},a)}return Ny=u,Ny}var Ey,bE;function Tz(){if(bE)return Ey;bE=1;var e=ld(),t=cd();function n(s){return e(function(i,a){var l=-1,u=a.length,h=u>1?a[u-1]:void 0,p=u>2?a[2]:void 0;for(h=s.length>3&&typeof h=="function"?(u--,h):void 0,p&&t(a[0],a[1],p)&&(h=u<3?void 0:h,u=1),i=Object(i);++l<u;){var f=a[l];f&&s(i,f,l,h)}return i})}return Ey=n,Ey}var Cy,kE;function Rz(){if(kE)return Cy;kE=1;var e=jz(),t=Tz(),n=t(function(s,i,a){e(s,i,a)});return Cy=n,Cy}var jy,_E;function HR(){if(_E)return jy;_E=1;function e(t,n){return t<n}return jy=e,jy}var Ty,SE;function Az(){if(SE)return Ty;SE=1;var e=s0(),t=HR(),n=jo();function s(i){return i&&i.length?e(i,n,t):void 0}return Ty=s,Ty}var Ry,NE;function Mz(){if(NE)return Ry;NE=1;var e=s0(),t=ts(),n=HR();function s(i,a){return i&&i.length?e(i,t(a,2),n):void 0}return Ry=s,Ry}var Ay,EE;function Iz(){if(EE)return Ay;EE=1;var e=dr(),t=function(){return e.Date.now()};return Ay=t,Ay}var My,CE;function Oz(){if(CE)return My;CE=1;var e=Ju(),t=id(),n=ed(),s=qn(),i=ql();function a(l,u,h,p){if(!s(l))return l;u=t(u,l);for(var f=-1,g=u.length,v=g-1,w=l;w!=null&&++f<g;){var N=i(u[f]),b=h;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(f!=v){var k=w[N];b=p?p(k,N,w):void 0,b===void 0&&(b=s(k)?k:n(u[f+1])?[]:{})}e(w,N,b),w=w[N]}return l}return My=a,My}var Iy,jE;function Pz(){if(jE)return Iy;jE=1;var e=ad(),t=Oz(),n=id();function s(i,a,l){for(var u=-1,h=a.length,p={};++u<h;){var f=a[u],g=e(i,f);l(g,f)&&t(p,n(f,i),g)}return p}return Iy=s,Iy}var Oy,TE;function $z(){if(TE)return Oy;TE=1;var e=Pz(),t=_R();function n(s,i){return e(s,i,function(a,l){return t(s,l)})}return Oy=n,Oy}var Py,RE;function Lz(){if(RE)return Py;RE=1;var e=BR(),t=AR(),n=MR();function s(i){return n(t(i,void 0,e),i+"")}return Py=s,Py}var $y,AE;function qz(){if(AE)return $y;AE=1;var e=$z(),t=Lz(),n=t(function(s,i){return s==null?{}:e(s,i)});return $y=n,$y}var Ly,ME;function Dz(){if(ME)return Ly;ME=1;var e=Math.ceil,t=Math.max;function n(s,i,a,l){for(var u=-1,h=t(e((i-s)/(a||1)),0),p=Array(h);h--;)p[l?h:++u]=s,s+=a;return p}return Ly=n,Ly}var qy,IE;function Fz(){if(IE)return qy;IE=1;var e=Dz(),t=cd(),n=zR();function s(i){return function(a,l,u){return u&&typeof u!="number"&&t(a,l,u)&&(l=u=void 0),a=n(a),l===void 0?(l=a,a=0):l=n(l),u=u===void 0?a<l?1:-1:n(u),e(a,l,u,i)}}return qy=s,qy}var Dy,OE;function zz(){if(OE)return Dy;OE=1;var e=Fz(),t=e();return Dy=t,Dy}var Fy,PE;function Bz(){if(PE)return Fy;PE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return Fy=e,Fy}var zy,$E;function Uz(){if($E)return zy;$E=1;var e=ta();function t(n,s){if(n!==s){var i=n!==void 0,a=n===null,l=n===n,u=e(n),h=s!==void 0,p=s===null,f=s===s,g=e(s);if(!p&&!g&&!u&&n>s||u&&h&&f&&!p&&!g||a&&h&&f||!i&&f||!l)return 1;if(!a&&!u&&!g&&n<s||g&&i&&l&&!a&&!u||p&&i&&l||!h&&l||!f)return-1}return 0}return zy=t,zy}var By,LE;function Wz(){if(LE)return By;LE=1;var e=Uz();function t(n,s,i){for(var a=-1,l=n.criteria,u=s.criteria,h=l.length,p=i.length;++a<h;){var f=e(l[a],u[a]);if(f){if(a>=p)return f;var g=i[a];return f*(g=="desc"?-1:1)}}return n.index-s.index}return By=t,By}var Uy,qE;function Hz(){if(qE)return Uy;qE=1;var e=od(),t=ad(),n=ts(),s=jR(),i=Bz(),a=td(),l=Wz(),u=jo(),h=Mt();function p(f,g,v){g.length?g=e(g,function(b){return h(b)?function(k){return t(k,b.length===1?b[0]:b)}:b}):g=[u];var w=-1;g=e(g,a(n));var N=s(f,function(b,k,_){var E=e(g,function(C){return C(b)});return{criteria:E,index:++w,value:b}});return i(N,function(b,k){return l(b,k,v)})}return Uy=p,Uy}var Wy,DE;function Gz(){if(DE)return Wy;DE=1;var e=n0(),t=Hz(),n=ld(),s=cd(),i=n(function(a,l){if(a==null)return[];var u=l.length;return u>1&&s(a,l[0],l[1])?l=[]:u>2&&s(l[0],l[1],l[2])&&(l=[l[0]]),t(a,e(l,1),[])});return Wy=i,Wy}var Hy,FE;function Vz(){if(FE)return Hy;FE=1;var e=bR(),t=0;function n(s){var i=++t;return e(s)+i}return Hy=n,Hy}var Gy,zE;function Yz(){if(zE)return Gy;zE=1;function e(t,n,s){for(var i=-1,a=t.length,l=n.length,u={};++i<a;){var h=i<l?n[i]:void 0;s(u,t[i],h)}return u}return Gy=e,Gy}var Vy,BE;function Kz(){if(BE)return Vy;BE=1;var e=Ju(),t=Yz();function n(s,i){return t(s||[],i||[],e)}return Vy=n,Vy}var Yy,UE;function vt(){if(UE)return Yy;UE=1;var e;if(typeof zw=="function")try{e={cloneDeep:dz(),constant:Qw(),defaults:fz(),each:pR(),filter:NR(),find:wz(),flatten:BR(),forEach:hR(),forIn:xz(),has:ER(),isUndefined:CR(),last:bz(),map:TR(),mapValues:kz(),max:Sz(),merge:Rz(),min:Az(),minBy:Mz(),now:Iz(),pick:qz(),range:zz(),reduce:RR(),sortBy:Gz(),uniqueId:Vz(),values:PR(),zipObject:Kz()}}catch{}return e||(e=window._),Yy=e,Yy}var Ky,WE;function Xz(){if(WE)return Ky;WE=1,Ky=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,i=s._prev;if(i!==s)return t(i),i},e.prototype.enqueue=function(s){var i=this._sentinel;s._prev&&s._next&&t(s),s._next=i._next,i._next._prev=s,i._next=s,s._prev=i},e.prototype.toString=function(){for(var s=[],i=this._sentinel,a=i._prev;a!==i;)s.push(JSON.stringify(a,n)),a=a._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,i){if(s!=="_next"&&s!=="_prev")return i}return Ky}var Xy,HE;function Qz(){if(HE)return Xy;HE=1;var e=vt(),t=cr().Graph,n=Xz();Xy=i;var s=e.constant(1);function i(p,f){if(p.nodeCount()<=1)return[];var g=u(p,f||s),v=a(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(v,function(w){return p.outEdges(w.v,w.w)}),!0)}function a(p,f,g){for(var v=[],w=f[f.length-1],N=f[0],b;p.nodeCount();){for(;b=N.dequeue();)l(p,f,g,b);for(;b=w.dequeue();)l(p,f,g,b);if(p.nodeCount()){for(var k=f.length-2;k>0;--k)if(b=f[k].dequeue(),b){v=v.concat(l(p,f,g,b,!0));break}}}return v}function l(p,f,g,v,w){var N=w?[]:void 0;return e.forEach(p.inEdges(v.v),function(b){var k=p.edge(b),_=p.node(b.v);w&&N.push({v:b.v,w:b.w}),_.out-=k,h(f,g,_)}),e.forEach(p.outEdges(v.v),function(b){var k=p.edge(b),_=b.w,E=p.node(_);E.in-=k,h(f,g,E)}),p.removeNode(v.v),N}function u(p,f){var g=new t,v=0,w=0;e.forEach(p.nodes(),function(k){g.setNode(k,{v:k,in:0,out:0})}),e.forEach(p.edges(),function(k){var _=g.edge(k.v,k.w)||0,E=f(k),C=_+E;g.setEdge(k.v,k.w,C),w=Math.max(w,g.node(k.v).out+=E),v=Math.max(v,g.node(k.w).in+=E)});var N=e.range(w+v+3).map(function(){return new n}),b=v+1;return e.forEach(g.nodes(),function(k){h(N,b,g.node(k))}),{graph:g,buckets:N,zeroIdx:b}}function h(p,f,g){g.out?g.in?p[g.out-g.in+f].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Xy}var Qy,GE;function Zz(){if(GE)return Qy;GE=1;var e=vt(),t=Qz();Qy={run:n,undo:i};function n(a){var l=a.graph().acyclicer==="greedy"?t(a,u(a)):s(a);e.forEach(l,function(h){var p=a.edge(h);a.removeEdge(h),p.forwardName=h.name,p.reversed=!0,a.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function u(h){return function(p){return h.edge(p).weight}}}function s(a){var l=[],u={},h={};function p(f){e.has(h,f)||(h[f]=!0,u[f]=!0,e.forEach(a.outEdges(f),function(g){e.has(u,g.w)?l.push(g):p(g.w)}),delete u[f])}return e.forEach(a.nodes(),p),l}function i(a){e.forEach(a.edges(),function(l){var u=a.edge(l);if(u.reversed){a.removeEdge(l);var h=u.forwardName;delete u.reversed,delete u.forwardName,a.setEdge(l.w,l.v,u,h)}})}return Qy}var Zy,VE;function fn(){if(VE)return Zy;VE=1;var e=vt(),t=cr().Graph;Zy={addDummyNode:n,simplify:s,asNonCompoundGraph:i,successorWeights:a,predecessorWeights:l,intersectRect:u,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:g,maxRank:v,partition:w,time:N,notime:b};function n(k,_,E,C){var j;do j=e.uniqueId(C);while(k.hasNode(j));return E.dummy=_,k.setNode(j,E),j}function s(k){var _=new t().setGraph(k.graph());return e.forEach(k.nodes(),function(E){_.setNode(E,k.node(E))}),e.forEach(k.edges(),function(E){var C=_.edge(E.v,E.w)||{weight:0,minlen:1},j=k.edge(E);_.setEdge(E.v,E.w,{weight:C.weight+j.weight,minlen:Math.max(C.minlen,j.minlen)})}),_}function i(k){var _=new t({multigraph:k.isMultigraph()}).setGraph(k.graph());return e.forEach(k.nodes(),function(E){k.children(E).length||_.setNode(E,k.node(E))}),e.forEach(k.edges(),function(E){_.setEdge(E,k.edge(E))}),_}function a(k){var _=e.map(k.nodes(),function(E){var C={};return e.forEach(k.outEdges(E),function(j){C[j.w]=(C[j.w]||0)+k.edge(j).weight}),C});return e.zipObject(k.nodes(),_)}function l(k){var _=e.map(k.nodes(),function(E){var C={};return e.forEach(k.inEdges(E),function(j){C[j.v]=(C[j.v]||0)+k.edge(j).weight}),C});return e.zipObject(k.nodes(),_)}function u(k,_){var E=k.x,C=k.y,j=_.x-E,I=_.y-C,O=k.width/2,P=k.height/2;if(!j&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var z,M;return Math.abs(I)*O>Math.abs(j)*P?(I<0&&(P=-P),z=P*j/I,M=P):(j<0&&(O=-O),z=O,M=O*I/j),{x:E+z,y:C+M}}function h(k){var _=e.map(e.range(v(k)+1),function(){return[]});return e.forEach(k.nodes(),function(E){var C=k.node(E),j=C.rank;e.isUndefined(j)||(_[j][C.order]=E)}),_}function p(k){var _=e.min(e.map(k.nodes(),function(E){return k.node(E).rank}));e.forEach(k.nodes(),function(E){var C=k.node(E);e.has(C,"rank")&&(C.rank-=_)})}function f(k){var _=e.min(e.map(k.nodes(),function(I){return k.node(I).rank})),E=[];e.forEach(k.nodes(),function(I){var O=k.node(I).rank-_;E[O]||(E[O]=[]),E[O].push(I)});var C=0,j=k.graph().nodeRankFactor;e.forEach(E,function(I,O){e.isUndefined(I)&&O%j!==0?--C:C&&e.forEach(I,function(P){k.node(P).rank+=C})})}function g(k,_,E,C){var j={width:0,height:0};return arguments.length>=4&&(j.rank=E,j.order=C),n(k,"border",j,_)}function v(k){return e.max(e.map(k.nodes(),function(_){var E=k.node(_).rank;if(!e.isUndefined(E))return E}))}function w(k,_){var E={lhs:[],rhs:[]};return e.forEach(k,function(C){_(C)?E.lhs.push(C):E.rhs.push(C)}),E}function N(k,_){var E=e.now();try{return _()}finally{console.log(k+" time: "+(e.now()-E)+"ms")}}function b(k,_){return _()}return Zy}var Jy,YE;function Jz(){if(YE)return Jy;YE=1;var e=vt(),t=fn();Jy={run:n,undo:i};function n(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(l){s(a,l)})}function s(a,l){var u=l.v,h=a.node(u).rank,p=l.w,f=a.node(p).rank,g=l.name,v=a.edge(l),w=v.labelRank;if(f!==h+1){a.removeEdge(l);var N,b,k;for(k=0,++h;h<f;++k,++h)v.points=[],b={width:0,height:0,edgeLabel:v,edgeObj:l,rank:h},N=t.addDummyNode(a,"edge",b,"_d"),h===w&&(b.width=v.width,b.height=v.height,b.dummy="edge-label",b.labelpos=v.labelpos),a.setEdge(u,N,{weight:v.weight},g),k===0&&a.graph().dummyChains.push(N),u=N;a.setEdge(u,p,{weight:v.weight},g)}}function i(a){e.forEach(a.graph().dummyChains,function(l){var u=a.node(l),h=u.edgeLabel,p;for(a.setEdge(u.edgeObj,h);u.dummy;)p=a.successors(l)[0],a.removeNode(l),h.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(h.x=u.x,h.y=u.y,h.width=u.width,h.height=u.height),l=p,u=a.node(l)})}return Jy}var ev,KE;function Iu(){if(KE)return ev;KE=1;var e=vt();ev={longestPath:t,slack:n};function t(s){var i={};function a(l){var u=s.node(l);if(e.has(i,l))return u.rank;i[l]=!0;var h=e.min(e.map(s.outEdges(l),function(p){return a(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),u.rank=h}e.forEach(s.sources(),a)}function n(s,i){return s.node(i.w).rank-s.node(i.v).rank-s.edge(i).minlen}return ev}var tv,XE;function GR(){if(XE)return tv;XE=1;var e=vt(),t=cr().Graph,n=Iu().slack;tv=s;function s(u){var h=new t({directed:!1}),p=u.nodes()[0],f=u.nodeCount();h.setNode(p,{});for(var g,v;i(h,u)<f;)g=a(h,u),v=h.hasNode(g.v)?n(u,g):-n(u,g),l(h,u,v);return h}function i(u,h){function p(f){e.forEach(h.nodeEdges(f),function(g){var v=g.v,w=f===v?g.w:v;!u.hasNode(w)&&!n(h,g)&&(u.setNode(w,{}),u.setEdge(f,w,{}),p(w))})}return e.forEach(u.nodes(),p),u.nodeCount()}function a(u,h){return e.minBy(h.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(h,p)})}function l(u,h,p){e.forEach(u.nodes(),function(f){h.node(f).rank+=p})}return tv}var nv,QE;function eB(){if(QE)return nv;QE=1;var e=vt(),t=GR(),n=Iu().slack,s=Iu().longestPath,i=cr().alg.preorder,a=cr().alg.postorder,l=fn().simplify;nv=u,u.initLowLimValues=g,u.initCutValues=h,u.calcCutValue=f,u.leaveEdge=w,u.enterEdge=N,u.exchangeEdges=b;function u(C){C=l(C),s(C);var j=t(C);g(j),h(j,C);for(var I,O;I=w(j);)O=N(j,C,I),b(j,C,I,O)}function h(C,j){var I=a(C,C.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(O){p(C,j,O)})}function p(C,j,I){var O=C.node(I),P=O.parent;C.edge(I,P).cutvalue=f(C,j,I)}function f(C,j,I){var O=C.node(I),P=O.parent,z=!0,M=j.edge(I,P),A=0;return M||(z=!1,M=j.edge(P,I)),A=M.weight,e.forEach(j.nodeEdges(I),function(q){var G=q.v===I,Y=G?q.w:q.v;if(Y!==P){var R=G===z,Q=j.edge(q).weight;if(A+=R?Q:-Q,_(C,I,Y)){var H=C.edge(I,Y).cutvalue;A+=R?-H:H}}}),A}function g(C,j){arguments.length<2&&(j=C.nodes()[0]),v(C,{},1,j)}function v(C,j,I,O,P){var z=I,M=C.node(O);return j[O]=!0,e.forEach(C.neighbors(O),function(A){e.has(j,A)||(I=v(C,j,I,A,O))}),M.low=z,M.lim=I++,P?M.parent=P:delete M.parent,I}function w(C){return e.find(C.edges(),function(j){return C.edge(j).cutvalue<0})}function N(C,j,I){var O=I.v,P=I.w;j.hasEdge(O,P)||(O=I.w,P=I.v);var z=C.node(O),M=C.node(P),A=z,q=!1;z.lim>M.lim&&(A=M,q=!0);var G=e.filter(j.edges(),function(Y){return q===E(C,C.node(Y.v),A)&&q!==E(C,C.node(Y.w),A)});return e.minBy(G,function(Y){return n(j,Y)})}function b(C,j,I,O){var P=I.v,z=I.w;C.removeEdge(P,z),C.setEdge(O.v,O.w,{}),g(C),h(C,j),k(C,j)}function k(C,j){var I=e.find(C.nodes(),function(P){return!j.node(P).parent}),O=i(C,I);O=O.slice(1),e.forEach(O,function(P){var z=C.node(P).parent,M=j.edge(P,z),A=!1;M||(M=j.edge(z,P),A=!0),j.node(P).rank=j.node(z).rank+(A?M.minlen:-M.minlen)})}function _(C,j,I){return C.hasEdge(j,I)}function E(C,j,I){return I.low<=j.lim&&j.lim<=I.lim}return nv}var rv,ZE;function tB(){if(ZE)return rv;ZE=1;var e=Iu(),t=e.longestPath,n=GR(),s=eB();rv=i;function i(h){switch(h.graph().ranker){case"network-simplex":u(h);break;case"tight-tree":l(h);break;case"longest-path":a(h);break;default:u(h)}}var a=t;function l(h){t(h),n(h)}function u(h){s(h)}return rv}var sv,JE;function nB(){if(JE)return sv;JE=1;var e=vt();sv=t;function t(i){var a=s(i);e.forEach(i.graph().dummyChains,function(l){for(var u=i.node(l),h=u.edgeObj,p=n(i,a,h.v,h.w),f=p.path,g=p.lca,v=0,w=f[v],N=!0;l!==h.w;){if(u=i.node(l),N){for(;(w=f[v])!==g&&i.node(w).maxRank<u.rank;)v++;w===g&&(N=!1)}if(!N){for(;v<f.length-1&&i.node(w=f[v+1]).minRank<=u.rank;)v++;w=f[v]}i.setParent(l,w),l=i.successors(l)[0]}})}function n(i,a,l,u){var h=[],p=[],f=Math.min(a[l].low,a[u].low),g=Math.max(a[l].lim,a[u].lim),v,w;v=l;do v=i.parent(v),h.push(v);while(v&&(a[v].low>f||g>a[v].lim));for(w=v,v=u;(v=i.parent(v))!==w;)p.push(v);return{path:h.concat(p.reverse()),lca:w}}function s(i){var a={},l=0;function u(h){var p=l;e.forEach(i.children(h),u),a[h]={low:p,lim:l++}}return e.forEach(i.children(),u),a}return sv}var ov,eC;function rB(){if(eC)return ov;eC=1;var e=vt(),t=fn();ov={run:n,cleanup:l};function n(u){var h=t.addDummyNode(u,"root",{},"_root"),p=i(u),f=e.max(e.values(p))-1,g=2*f+1;u.graph().nestingRoot=h,e.forEach(u.edges(),function(w){u.edge(w).minlen*=g});var v=a(u)+1;e.forEach(u.children(),function(w){s(u,h,g,v,f,p,w)}),u.graph().nodeRankFactor=g}function s(u,h,p,f,g,v,w){var N=u.children(w);if(!N.length){w!==h&&u.setEdge(h,w,{weight:0,minlen:p});return}var b=t.addBorderNode(u,"_bt"),k=t.addBorderNode(u,"_bb"),_=u.node(w);u.setParent(b,w),_.borderTop=b,u.setParent(k,w),_.borderBottom=k,e.forEach(N,function(E){s(u,h,p,f,g,v,E);var C=u.node(E),j=C.borderTop?C.borderTop:E,I=C.borderBottom?C.borderBottom:E,O=C.borderTop?f:2*f,P=j!==I?1:g-v[w]+1;u.setEdge(b,j,{weight:O,minlen:P,nestingEdge:!0}),u.setEdge(I,k,{weight:O,minlen:P,nestingEdge:!0})}),u.parent(w)||u.setEdge(h,b,{weight:0,minlen:g+v[w]})}function i(u){var h={};function p(f,g){var v=u.children(f);v&&v.length&&e.forEach(v,function(w){p(w,g+1)}),h[f]=g}return e.forEach(u.children(),function(f){p(f,1)}),h}function a(u){return e.reduce(u.edges(),function(h,p){return h+u.edge(p).weight},0)}function l(u){var h=u.graph();u.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(u.edges(),function(p){var f=u.edge(p);f.nestingEdge&&u.removeEdge(p)})}return ov}var iv,tC;function sB(){if(tC)return iv;tC=1;var e=vt(),t=fn();iv=n;function n(i){function a(l){var u=i.children(l),h=i.node(l);if(u.length&&e.forEach(u,a),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(i,"borderLeft","_bl",l,h,p),s(i,"borderRight","_br",l,h,p)}}e.forEach(i.children(),a)}function s(i,a,l,u,h,p){var f={width:0,height:0,rank:p,borderType:a},g=h[a][p-1],v=t.addDummyNode(i,"border",f,l);h[a][p]=v,i.setParent(v,u),g&&i.setEdge(g,v,{weight:1})}return iv}var av,nC;function oB(){if(nC)return av;nC=1;var e=vt();av={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&a(p),(f==="lr"||f==="rl")&&(u(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){i(p.node(f))}),e.forEach(p.edges(),function(f){i(p.edge(f))})}function i(p){var f=p.width;p.width=p.height,p.height=f}function a(p){e.forEach(p.nodes(),function(f){l(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,l),e.has(g,"y")&&l(g)})}function l(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,h),e.has(g,"x")&&h(g)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return av}var lv,rC;function iB(){if(rC)return lv;rC=1;var e=vt();lv=t;function t(n){var s={},i=e.filter(n.nodes(),function(p){return!n.children(p).length}),a=e.max(e.map(i,function(p){return n.node(p).rank})),l=e.map(e.range(a+1),function(){return[]});function u(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);l[f.rank].push(p),e.forEach(n.successors(p),u)}}var h=e.sortBy(i,function(p){return n.node(p).rank});return e.forEach(h,u),l}return lv}var cv,sC;function aB(){if(sC)return cv;sC=1;var e=vt();cv=t;function t(s,i){for(var a=0,l=1;l<i.length;++l)a+=n(s,i[l-1],i[l]);return a}function n(s,i,a){for(var l=e.zipObject(a,e.map(a,function(v,w){return w})),u=e.flatten(e.map(i,function(v){return e.sortBy(e.map(s.outEdges(v),function(w){return{pos:l[w.w],weight:s.edge(w).weight}}),"pos")}),!0),h=1;h<a.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(u.forEach(function(v){var w=v.pos+h;f[w]+=v.weight;for(var N=0;w>0;)w%2&&(N+=f[w+1]),w=w-1>>1,f[w]+=v.weight;g+=v.weight*N})),g}return cv}var uv,oC;function lB(){if(oC)return uv;oC=1;var e=vt();uv=t;function t(n,s){return e.map(s,function(i){var a=n.inEdges(i);if(a.length){var l=e.reduce(a,function(u,h){var p=n.edge(h),f=n.node(h.v);return{sum:u.sum+p.weight*f.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:i,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:i}})}return uv}var dv,iC;function cB(){if(iC)return dv;iC=1;var e=vt();dv=t;function t(i,a){var l={};e.forEach(i,function(h,p){var f=l[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(a.edges(),function(h){var p=l[h.v],f=l[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(l[h.w]))});var u=e.filter(l,function(h){return!h.indegree});return n(u)}function n(i){var a=[];function l(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function u(p){return function(f){f.in.push(p),--f.indegree===0&&i.push(f)}}for(;i.length;){var h=i.pop();a.push(h),e.forEach(h.in.reverse(),l(h)),e.forEach(h.out,u(h))}return e.map(e.filter(a,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(i,a){var l=0,u=0;i.weight&&(l+=i.barycenter*i.weight,u+=i.weight),a.weight&&(l+=a.barycenter*a.weight,u+=a.weight),i.vs=a.vs.concat(i.vs),i.barycenter=l/u,i.weight=u,i.i=Math.min(a.i,i.i),a.merged=!0}return dv}var fv,aC;function uB(){if(aC)return fv;aC=1;var e=vt(),t=fn();fv=n;function n(a,l){var u=t.partition(a,function(b){return e.has(b,"barycenter")}),h=u.lhs,p=e.sortBy(u.rhs,function(b){return-b.i}),f=[],g=0,v=0,w=0;h.sort(i(!!l)),w=s(f,p,w),e.forEach(h,function(b){w+=b.vs.length,f.push(b.vs),g+=b.barycenter*b.weight,v+=b.weight,w=s(f,p,w)});var N={vs:e.flatten(f,!0)};return v&&(N.barycenter=g/v,N.weight=v),N}function s(a,l,u){for(var h;l.length&&(h=e.last(l)).i<=u;)l.pop(),a.push(h.vs),u++;return u}function i(a){return function(l,u){return l.barycenter<u.barycenter?-1:l.barycenter>u.barycenter?1:a?u.i-l.i:l.i-u.i}}return fv}var hv,lC;function dB(){if(lC)return hv;lC=1;var e=vt(),t=lB(),n=cB(),s=uB();hv=i;function i(u,h,p,f){var g=u.children(h),v=u.node(h),w=v?v.borderLeft:void 0,N=v?v.borderRight:void 0,b={};w&&(g=e.filter(g,function(I){return I!==w&&I!==N}));var k=t(u,g);e.forEach(k,function(I){if(u.children(I.v).length){var O=i(u,I.v,p,f);b[I.v]=O,e.has(O,"barycenter")&&l(I,O)}});var _=n(k,p);a(_,b);var E=s(_,f);if(w&&(E.vs=e.flatten([w,E.vs,N],!0),u.predecessors(w).length)){var C=u.node(u.predecessors(w)[0]),j=u.node(u.predecessors(N)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+C.order+j.order)/(E.weight+2),E.weight+=2}return E}function a(u,h){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function l(u,h){e.isUndefined(u.barycenter)?(u.barycenter=h.barycenter,u.weight=h.weight):(u.barycenter=(u.barycenter*u.weight+h.barycenter*h.weight)/(u.weight+h.weight),u.weight+=h.weight)}return hv}var pv,cC;function fB(){if(cC)return pv;cC=1;var e=vt(),t=cr().Graph;pv=n;function n(i,a,l){var u=s(i),h=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return i.node(p)});return e.forEach(i.nodes(),function(p){var f=i.node(p),g=i.parent(p);(f.rank===a||f.minRank<=a&&a<=f.maxRank)&&(h.setNode(p),h.setParent(p,g||u),e.forEach(i[l](p),function(v){var w=v.v===p?v.w:v.v,N=h.edge(w,p),b=e.isUndefined(N)?0:N.weight;h.setEdge(w,p,{weight:i.edge(v).weight+b})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[a],borderRight:f.borderRight[a]}))}),h}function s(i){for(var a;i.hasNode(a=e.uniqueId("_root")););return a}return pv}var mv,uC;function hB(){if(uC)return mv;uC=1;var e=vt();mv=t;function t(n,s,i){var a={},l;e.forEach(i,function(u){for(var h=n.parent(u),p,f;h;){if(p=n.parent(h),p?(f=a[p],a[p]=h):(f=l,l=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return mv}var gv,dC;function pB(){if(dC)return gv;dC=1;var e=vt(),t=iB(),n=aB(),s=dB(),i=fB(),a=hB(),l=cr().Graph,u=fn();gv=h;function h(v){var w=u.maxRank(v),N=p(v,e.range(1,w+1),"inEdges"),b=p(v,e.range(w-1,-1,-1),"outEdges"),k=t(v);g(v,k);for(var _=Number.POSITIVE_INFINITY,E,C=0,j=0;j<4;++C,++j){f(C%2?N:b,C%4>=2),k=u.buildLayerMatrix(v);var I=n(v,k);I<_&&(j=0,E=e.cloneDeep(k),_=I)}g(v,E)}function p(v,w,N){return e.map(w,function(b){return i(v,b,N)})}function f(v,w){var N=new l;e.forEach(v,function(b){var k=b.graph().root,_=s(b,k,N,w);e.forEach(_.vs,function(E,C){b.node(E).order=C}),a(b,N,_.vs)})}function g(v,w){e.forEach(w,function(N){e.forEach(N,function(b,k){v.node(b).order=k})})}return gv}var yv,fC;function mB(){if(fC)return yv;fC=1;var e=vt(),t=cr().Graph,n=fn();yv={positionX:N,findType1Conflicts:s,findType2Conflicts:i,addConflict:l,hasConflict:u,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:v,findSmallestWidthAlignment:g,balance:w};function s(_,E){var C={};function j(I,O){var P=0,z=0,M=I.length,A=e.last(O);return e.forEach(O,function(q,G){var Y=a(_,q),R=Y?_.node(Y).order:M;(Y||q===A)&&(e.forEach(O.slice(z,G+1),function(Q){e.forEach(_.predecessors(Q),function(H){var ne=_.node(H),X=ne.order;(X<P||R<X)&&!(ne.dummy&&_.node(Q).dummy)&&l(C,H,Q)})}),z=G+1,P=R)}),O}return e.reduce(E,j),C}function i(_,E){var C={};function j(O,P,z,M,A){var q;e.forEach(e.range(P,z),function(G){q=O[G],_.node(q).dummy&&e.forEach(_.predecessors(q),function(Y){var R=_.node(Y);R.dummy&&(R.order<M||R.order>A)&&l(C,Y,q)})})}function I(O,P){var z=-1,M,A=0;return e.forEach(P,function(q,G){if(_.node(q).dummy==="border"){var Y=_.predecessors(q);Y.length&&(M=_.node(Y[0]).order,j(P,A,G,z,M),A=G,z=M)}j(P,A,P.length,M,O.length)}),P}return e.reduce(E,I),C}function a(_,E){if(_.node(E).dummy)return e.find(_.predecessors(E),function(C){return _.node(C).dummy})}function l(_,E,C){if(E>C){var j=E;E=C,C=j}var I=_[E];I||(_[E]=I={}),I[C]=!0}function u(_,E,C){if(E>C){var j=E;E=C,C=j}return e.has(_[E],C)}function h(_,E,C,j){var I={},O={},P={};return e.forEach(E,function(z){e.forEach(z,function(M,A){I[M]=M,O[M]=M,P[M]=A})}),e.forEach(E,function(z){var M=-1;e.forEach(z,function(A){var q=j(A);if(q.length){q=e.sortBy(q,function(H){return P[H]});for(var G=(q.length-1)/2,Y=Math.floor(G),R=Math.ceil(G);Y<=R;++Y){var Q=q[Y];O[A]===A&&M<P[Q]&&!u(C,A,Q)&&(O[Q]=A,O[A]=I[A]=I[Q],M=P[Q])}}})}),{root:I,align:O}}function p(_,E,C,j,I){var O={},P=f(_,E,C,I),z=I?"borderLeft":"borderRight";function M(G,Y){for(var R=P.nodes(),Q=R.pop(),H={};Q;)H[Q]?G(Q):(H[Q]=!0,R.push(Q),R=R.concat(Y(Q))),Q=R.pop()}function A(G){O[G]=P.inEdges(G).reduce(function(Y,R){return Math.max(Y,O[R.v]+P.edge(R))},0)}function q(G){var Y=P.outEdges(G).reduce(function(Q,H){return Math.min(Q,O[H.w]-P.edge(H))},Number.POSITIVE_INFINITY),R=_.node(G);Y!==Number.POSITIVE_INFINITY&&R.borderType!==z&&(O[G]=Math.max(O[G],Y))}return M(A,P.predecessors.bind(P)),M(q,P.successors.bind(P)),e.forEach(j,function(G){O[G]=O[C[G]]}),O}function f(_,E,C,j){var I=new t,O=_.graph(),P=b(O.nodesep,O.edgesep,j);return e.forEach(E,function(z){var M;e.forEach(z,function(A){var q=C[A];if(I.setNode(q),M){var G=C[M],Y=I.edge(G,q);I.setEdge(G,q,Math.max(P(_,A,M),Y||0))}M=A})}),I}function g(_,E){return e.minBy(e.values(E),function(C){var j=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(C,function(O,P){var z=k(_,P)/2;j=Math.max(O+z,j),I=Math.min(O-z,I)}),j-I})}function v(_,E){var C=e.values(E),j=e.min(C),I=e.max(C);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(P){var z=O+P,M=_[z],A;if(M!==E){var q=e.values(M);A=P==="l"?j-e.min(q):I-e.max(q),A&&(_[z]=e.mapValues(M,function(G){return G+A}))}})})}function w(_,E){return e.mapValues(_.ul,function(C,j){if(E)return _[E.toLowerCase()][j];var I=e.sortBy(e.map(_,j));return(I[1]+I[2])/2})}function N(_){var E=n.buildLayerMatrix(_),C=e.merge(s(_,E),i(_,E)),j={},I;e.forEach(["u","d"],function(P){I=P==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(I=e.map(I,function(G){return e.values(G).reverse()}));var M=(P==="u"?_.predecessors:_.successors).bind(_),A=h(_,I,C,M),q=p(_,I,A.root,A.align,z==="r");z==="r"&&(q=e.mapValues(q,function(G){return-G})),j[P+z]=q})});var O=g(_,j);return v(j,O),w(j,_.graph().align)}function b(_,E,C){return function(j,I,O){var P=j.node(I),z=j.node(O),M=0,A;if(M+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":A=-P.width/2;break;case"r":A=P.width/2;break}if(A&&(M+=C?A:-A),A=0,M+=(P.dummy?E:_)/2,M+=(z.dummy?E:_)/2,M+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":A=z.width/2;break;case"r":A=-z.width/2;break}return A&&(M+=C?A:-A),A=0,M}}function k(_,E){return _.node(E).width}return yv}var vv,hC;function gB(){if(hC)return vv;hC=1;var e=vt(),t=fn(),n=mB().positionX;vv=s;function s(a){a=t.asNonCompoundGraph(a),i(a),e.forEach(n(a),function(l,u){a.node(u).x=l})}function i(a){var l=t.buildLayerMatrix(a),u=a.graph().ranksep,h=0;e.forEach(l,function(p){var f=e.max(e.map(p,function(g){return a.node(g).height}));e.forEach(p,function(g){a.node(g).y=h+f/2}),h+=f+u})}return vv}var wv,pC;function yB(){if(pC)return wv;pC=1;var e=vt(),t=Zz(),n=Jz(),s=tB(),i=fn().normalizeRanks,a=nB(),l=fn().removeEmptyRanks,u=rB(),h=sB(),p=oB(),f=pB(),g=gB(),v=fn(),w=cr().Graph;wv=N;function N(D,L){var K=L&&L.debugTiming?v.time:v.notime;K("layout",function(){var se=K(" buildLayoutGraph",function(){return M(D)});K(" runLayout",function(){b(se,K)}),K(" updateInputGraph",function(){k(D,se)})})}function b(D,L){L(" makeSpaceForEdgeLabels",function(){A(D)}),L(" removeSelfEdges",function(){U(D)}),L(" acyclic",function(){t.run(D)}),L(" nestingGraph.run",function(){u.run(D)}),L(" rank",function(){s(v.asNonCompoundGraph(D))}),L(" injectEdgeLabelProxies",function(){q(D)}),L(" removeEmptyRanks",function(){l(D)}),L(" nestingGraph.cleanup",function(){u.cleanup(D)}),L(" normalizeRanks",function(){i(D)}),L(" assignRankMinMax",function(){G(D)}),L(" removeEdgeLabelProxies",function(){Y(D)}),L(" normalize.run",function(){n.run(D)}),L(" parentDummyChains",function(){a(D)}),L(" addBorderSegments",function(){h(D)}),L(" order",function(){f(D)}),L(" insertSelfEdges",function(){J(D)}),L(" adjustCoordinateSystem",function(){p.adjust(D)}),L(" position",function(){g(D)}),L(" positionSelfEdges",function(){$(D)}),L(" removeBorderNodes",function(){X(D)}),L(" normalize.undo",function(){n.undo(D)}),L(" fixupEdgeLabelCoords",function(){H(D)}),L(" undoCoordinateSystem",function(){p.undo(D)}),L(" translateGraph",function(){R(D)}),L(" assignNodeIntersects",function(){Q(D)}),L(" reversePoints",function(){ne(D)}),L(" acyclic.undo",function(){t.undo(D)})}function k(D,L){e.forEach(D.nodes(),function(K){var se=D.node(K),he=L.node(K);se&&(se.x=he.x,se.y=he.y,L.children(K).length&&(se.width=he.width,se.height=he.height))}),e.forEach(D.edges(),function(K){var se=D.edge(K),he=L.edge(K);se.points=he.points,e.has(he,"x")&&(se.x=he.x,se.y=he.y)}),D.graph().width=L.graph().width,D.graph().height=L.graph().height}var _=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},C=["acyclicer","ranker","rankdir","align"],j=["width","height"],I={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function M(D){var L=new w({multigraph:!0,compound:!0}),K=Z(D.graph());return L.setGraph(e.merge({},E,V(K,_),e.pick(K,C))),e.forEach(D.nodes(),function(se){var he=Z(D.node(se));L.setNode(se,e.defaults(V(he,j),I)),L.setParent(se,D.parent(se))}),e.forEach(D.edges(),function(se){var he=Z(D.edge(se));L.setEdge(se,e.merge({},P,V(he,O),e.pick(he,z)))}),L}function A(D){var L=D.graph();L.ranksep/=2,e.forEach(D.edges(),function(K){var se=D.edge(K);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(L.rankdir==="TB"||L.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function q(D){e.forEach(D.edges(),function(L){var K=D.edge(L);if(K.width&&K.height){var se=D.node(L.v),he=D.node(L.w),me={rank:(he.rank-se.rank)/2+se.rank,e:L};v.addDummyNode(D,"edge-proxy",me,"_ep")}})}function G(D){var L=0;e.forEach(D.nodes(),function(K){var se=D.node(K);se.borderTop&&(se.minRank=D.node(se.borderTop).rank,se.maxRank=D.node(se.borderBottom).rank,L=e.max(L,se.maxRank))}),D.graph().maxRank=L}function Y(D){e.forEach(D.nodes(),function(L){var K=D.node(L);K.dummy==="edge-proxy"&&(D.edge(K.e).labelRank=K.rank,D.removeNode(L))})}function R(D){var L=Number.POSITIVE_INFINITY,K=0,se=Number.POSITIVE_INFINITY,he=0,me=D.graph(),xe=me.marginx||0,Ee=me.marginy||0;function He(Fe){var Ie=Fe.x,be=Fe.y,ue=Fe.width,re=Fe.height;L=Math.min(L,Ie-ue/2),K=Math.max(K,Ie+ue/2),se=Math.min(se,be-re/2),he=Math.max(he,be+re/2)}e.forEach(D.nodes(),function(Fe){He(D.node(Fe))}),e.forEach(D.edges(),function(Fe){var Ie=D.edge(Fe);e.has(Ie,"x")&&He(Ie)}),L-=xe,se-=Ee,e.forEach(D.nodes(),function(Fe){var Ie=D.node(Fe);Ie.x-=L,Ie.y-=se}),e.forEach(D.edges(),function(Fe){var Ie=D.edge(Fe);e.forEach(Ie.points,function(be){be.x-=L,be.y-=se}),e.has(Ie,"x")&&(Ie.x-=L),e.has(Ie,"y")&&(Ie.y-=se)}),me.width=K-L+xe,me.height=he-se+Ee}function Q(D){e.forEach(D.edges(),function(L){var K=D.edge(L),se=D.node(L.v),he=D.node(L.w),me,xe;K.points?(me=K.points[0],xe=K.points[K.points.length-1]):(K.points=[],me=he,xe=se),K.points.unshift(v.intersectRect(se,me)),K.points.push(v.intersectRect(he,xe))})}function H(D){e.forEach(D.edges(),function(L){var K=D.edge(L);if(e.has(K,"x"))switch((K.labelpos==="l"||K.labelpos==="r")&&(K.width-=K.labeloffset),K.labelpos){case"l":K.x-=K.width/2+K.labeloffset;break;case"r":K.x+=K.width/2+K.labeloffset;break}})}function ne(D){e.forEach(D.edges(),function(L){var K=D.edge(L);K.reversed&&K.points.reverse()})}function X(D){e.forEach(D.nodes(),function(L){if(D.children(L).length){var K=D.node(L),se=D.node(K.borderTop),he=D.node(K.borderBottom),me=D.node(e.last(K.borderLeft)),xe=D.node(e.last(K.borderRight));K.width=Math.abs(xe.x-me.x),K.height=Math.abs(he.y-se.y),K.x=me.x+K.width/2,K.y=se.y+K.height/2}}),e.forEach(D.nodes(),function(L){D.node(L).dummy==="border"&&D.removeNode(L)})}function U(D){e.forEach(D.edges(),function(L){if(L.v===L.w){var K=D.node(L.v);K.selfEdges||(K.selfEdges=[]),K.selfEdges.push({e:L,label:D.edge(L)}),D.removeEdge(L)}})}function J(D){var L=v.buildLayerMatrix(D);e.forEach(L,function(K){var se=0;e.forEach(K,function(he,me){var xe=D.node(he);xe.order=me+se,e.forEach(xe.selfEdges,function(Ee){v.addDummyNode(D,"selfedge",{width:Ee.label.width,height:Ee.label.height,rank:xe.rank,order:me+ ++se,e:Ee.e,label:Ee.label},"_se")}),delete xe.selfEdges})})}function $(D){e.forEach(D.nodes(),function(L){var K=D.node(L);if(K.dummy==="selfedge"){var se=D.node(K.e.v),he=se.x+se.width/2,me=se.y,xe=K.x-he,Ee=se.height/2;D.setEdge(K.e,K.label),D.removeNode(L),K.label.points=[{x:he+2*xe/3,y:me-Ee},{x:he+5*xe/6,y:me-Ee},{x:he+xe,y:me},{x:he+5*xe/6,y:me+Ee},{x:he+2*xe/3,y:me+Ee}],K.label.x=K.x,K.label.y=K.y}})}function V(D,L){return e.mapValues(e.pick(D,L),Number)}function Z(D){var L={};return e.forEach(D,function(K,se){L[se.toLowerCase()]=K}),L}return wv}var xv,mC;function vB(){if(mC)return xv;mC=1;var e=vt(),t=fn(),n=cr().Graph;xv={debugOrdering:s};function s(i){var a=t.buildLayerMatrix(i),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(i.nodes(),function(u){l.setNode(u,{label:u}),l.setParent(u,"layer"+i.node(u).rank)}),e.forEach(i.edges(),function(u){l.setEdge(u.v,u.w,{},u.name)}),e.forEach(a,function(u,h){var p="layer"+h;l.setNode(p,{rank:"same"}),e.reduce(u,function(f,g){return l.setEdge(f,g,{style:"invis"}),g})}),l}return xv}var bv,gC;function wB(){return gC||(gC=1,bv="0.8.5"),bv}var kv,yC;function xB(){return yC||(yC=1,kv={graphlib:cr(),layout:yB(),debug:vB(),util:{time:fn().time,notime:fn().notime},version:wB()}),kv}var bB=xB();const vC=lw(bB),Ki=240,Ou=130,Fi=74,ud=72,wC=Fi+ud;function kB(e,t){var s;let n=Ki;for(const i of e)n=Math.max(n,((s=t.get(i.id))==null?void 0:s.width)??Ki);return n}const VR=420,_B=2;function bl(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function SB(e,t){return((t==null?void 0:t.get(e))??0)>0?VR:0}function NB(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function kl(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??Ki)+SB(e,n),h:Math.max((s==null?void 0:s.height)??Ou,NB(e,n))}}function EB(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function CB(e,t,n,s,i,a){const l=new vC.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(_=>!i.has(_)),h=new Set(u);for(const _ of u){const{w:E,h:C}=kl(_,s,a);l.setNode(_,{width:E,height:C})}for(const _ of t)h.has(_.source)&&h.has(_.target)&&l.setEdge(_.source,_.target);vC.layout(l);const p=new Map;let f=1/0,g=1/0,v=-1/0,w=-1/0;for(const _ of u){const E=l.node(_);if(!E)continue;const C=s.get(_),j=(C==null?void 0:C.width)??Ki,I=(C==null?void 0:C.height)??Ou,O=kl(_,s,a),P=E.x-O.w/2,z=E.y-O.h/2;p.set(_,{x:P,y:z}),P<f&&(f=P),z<g&&(g=z),P+j>v&&(v=P+j),z+I>w&&(w=z+I)}if(Number.isFinite(f)&&Number.isFinite(g))for(const[_,E]of p)p.set(_,{x:E.x-f,y:E.y-g});const N=Number.isFinite(v)?v-f:0,b=Number.isFinite(w)?w-g:0;let k=null;for(const _ of e){const E=i.get(_);if(!E)continue;const C=s.get(_),j=(C==null?void 0:C.width)??Ki,I=(C==null?void 0:C.height)??Ou;k=k===null?{minX:E.x,minY:E.y,maxX:E.x+j,maxY:E.y+I}:{minX:Math.min(k.minX,E.x),minY:Math.min(k.minY,E.y),maxX:Math.max(k.maxX,E.x+j),maxY:Math.max(k.maxY,E.y+I)}}return{positions:p,width:N,height:b,pinnedBox:k}}function jB(e,t,n={}){const s=n.direction??"LR",i=n.pinned??new Map,a=n.measured??new Map,l=n.lanes,u=new Map;for(const _ of e){const E=bl(_),C=u.get(E);C?C.push(_.id):u.set(E,[_.id])}const p=Array.from(u.keys()).sort().map(_=>({sid:_,...CB(u.get(_),t,s,a,i,l)})),f=kB(e,a),g=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,v=_=>{const E=[[]];let C=0;for(const j of p)E.length<_&&C>0&&C+j.height>g&&(E.push([]),C=0),E[E.length-1].push(j),C+=j.height+wC;return E},w=_=>_.reduce((E,C)=>Math.max(E,C.width),0)+VR;let N=v(n.availableWidth?_B:1);N.length>1&&N.reduce((E,C)=>E+w(C),0)+f*(N.length-1)>(n.availableWidth??0)&&(N=v(1));const b=new Map;let k=0;for(const _ of N){const E=w(_);let C=0;for(const{positions:j,height:I,pinnedBox:O}of _){for(const[z,M]of j)b.set(z,{x:M.x+k,y:M.y+C});let P=C+I;O&&O.maxY>P&&O.minX<k+E&&k<O.maxX&&(P=O.maxY),C=P+wC}k+=E+f}return e.map(_=>{const E=i.get(_.id);if(E)return{..._,position:E};const C=b.get(_.id);return C?{..._,position:C}:_})}function TB(e,t,n,s,i){const l=Fi+ud,u=60,h=w=>kl(w,s,i),p=new Map(e.map(w=>[w.id,bl(w)])),f=[],g=e.map(w=>({id:w.id,pos:n.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,N)=>w.pos.y-N.pos.y||w.pos.x-N.pos.x||w.id.localeCompare(N.id)),v=[];for(const{id:w,pos:N}of g){const{w:b,h:k}=h(w),_=p.get(w)??"_default";if(n.has(w)){f.push({x:N.x,y:N.y,w:b,h:k,sid:_});continue}let E=N.y;for(let C=0;C<f.length+1;C++){const j=f.find(I=>{const O=I.sid===_?24:u,P=I.sid===_?24:l;return N.x<I.x+I.w+O&&I.x<N.x+b+O&&E<I.y+I.h+P&&I.y<E+k+P});if(!j)break;E=j.y+j.h+(j.sid===_?24:l)}E!==N.y&&(t.set(w,{x:N.x,y:E}),v.push(w)),f.push({x:N.x,y:E,w:b,h:k,sid:_})}return v}function RB(e,t,n,s,i,a){const l=b=>kl(b,s,a),u=b=>n.get(b)??t.get(b),h=new Map;for(const b of e){if(!u(b.id))continue;const k=bl(b),_=h.get(k);_?_.push(b):h.set(k,[b])}const p=new Set;for(const[b,k]of h)k.every(_=>i.has(_.id)&&!n.has(_.id))&&p.add(b);const f=new Map,g=[];for(const b of e){const k=u(b.id);if(!k)continue;const{w:_,h:E}=l(b.id),C=bl(b);p.has(C)?(f.get(C)??f.set(C,[]).get(C)).push(b):g.push({x:k.x,y:k.y,w:_,h:E})}if(f.size===0)return[];const v=Fi+ud,w=(b,k,_,E)=>g.some(C=>b<C.x+C.w+Fi&&C.x<b+_+Fi&&k<C.y+C.h+v&&C.y<k+E+v),N=[];for(const b of[...f.keys()].sort()){const k=f.get(b);let _=1/0,E=1/0,C=-1/0,j=-1/0;for(const q of k){const G=u(q.id),{w:Y,h:R}=l(q.id);_=Math.min(_,G.x),E=Math.min(E,G.y),C=Math.max(C,G.x+Y),j=Math.max(j,G.y+R)}const I=C-_,O=j-E,P=[...new Set(g.map(q=>Math.round(q.x)))].sort((q,G)=>q-G),z=P.length?P:[_],M=[0,...g.map(q=>q.y+q.h+v)].sort((q,G)=>q-G);let A=null;e:for(const q of z)for(const G of M){if(G>=E)break;if(!w(q,G,I,O)){A={x:q,y:G};break e}}if(A){const q=A.x-_,G=A.y-E;for(const Y of k){const R=u(Y.id);t.set(Y.id,{x:R.x+q,y:R.y+G})}N.push(b)}for(const q of k){const G=u(q.id),{w:Y,h:R}=l(q.id);g.push({x:G.x,y:G.y,w:Y,h:R})}}return N}function AB(e,t,n,s,i,a=!1,l){const p=Fi+ud+1,f=8,g=1.75,v=200,w=.7,N=.01,b=A=>kl(A,s,l),k=A=>n.get(A)??t.get(A),_=new Map;for(const A of e){if(!k(A.id))continue;const q=bl(A),G=_.get(q);G?G.push(A):_.set(q,[A])}const E=[],C=new Set,j=new Set,I=i.size===0;for(const A of[..._.keys()].sort()){const q=_.get(A);let G=1/0,Y=1/0,R=-1/0,Q=-1/0,H=!1;for(const J of q){const $=k(J.id),{w:V,h:Z}=b(J.id);G=Math.min(G,$.x),Y=Math.min(Y,$.y),R=Math.max(R,$.x+V),Q=Math.max(Q,$.y+Z),n.has(J.id)&&(H=!0)}const ne=R-G,X=Q-Y;j.add(A);const U=i.get(A);U&&(ne>U.w+f||X>U.h+f)&&C.add(A),i.set(A,{w:ne,h:X}),E.push({sid:A,members:q.map(J=>J.id),x:G,y:Y,w:ne,h:X,anchored:H,mass:1})}for(const A of[...i.keys()])j.has(A)||i.delete(A);if(a||I)return[];let O=!1;for(let A=0;A<E.length&&!O;A++)for(let q=A+1;q<E.length;q++){const G=E[A],Y=E[q];if(!(G.anchored&&Y.anchored)&&Math.abs(G.x+G.w/2-(Y.x+Y.w/2))<(G.w+Y.w)/2+61&&Math.abs(G.y+G.h/2-(Y.y+Y.h/2))<(G.h+Y.h)/2+p){O=!0;break}}if(C.size===0&&!O)return[];if(C.size>0)for(const A of E)C.has(A.sid)&&(A.mass=8);else for(const A of E)A.mass=Math.max(1,A.w*A.h/(Ki*Ou));const P=new Map(E.map(A=>[A.sid,A.x])),z=new Map(E.map(A=>[A.sid,A.y]));for(let A=0;A<v;A++){const q=new Map,G=new Map;let Y=0;for(let R=0;R<E.length;R++)for(let Q=R+1;Q<E.length;Q++){const H=E[R],ne=E[Q];if(H.anchored&&ne.anchored)continue;const X=H.x+H.w/2,U=H.y+H.h/2,J=ne.x+ne.w/2,$=ne.y+ne.h/2,V=(H.w+ne.w)/2+61-Math.abs(X-J),Z=(H.h+ne.h)/2+p-Math.abs(U-$);if(V<=0||Z<=0)continue;const D=(Pe,Ue)=>!Pe.anchored&&!(Ue<0&&Pe.x<=0),L=(Pe,Ue)=>!Pe.anchored&&!(Ue<0&&Pe.y<=0),K=(Pe,Ue,Ge)=>{const it=Pe===Ue,ke=it?H.sid<ne.sid?-1:1:Math.sign(Pe-Ue);return Ge(H,ke)||Ge(ne,-ke)?ke:it&&(Ge(H,-ke)||Ge(ne,ke))?-ke:0},se=K(X,J,D),he=K(U,$,L),me=se!==0,xe=he!==0;if(!me&&!xe)continue;const Ee=me&&(!xe||V*g<Z),[He,Fe,Ie,be]=Ee?[se,V,q,D]:[he,Z,G,L],ue=be(H,He),re=be(ne,-He),pe=H.mass,Oe=ne.mass,nt=ue?re?Oe/(pe+Oe):1:0,st=re?ue?pe/(pe+Oe):1:0,Xe=Fe*w;Ie.set(H.sid,(Ie.get(H.sid)??0)+He*Xe*nt),Ie.set(ne.sid,(Ie.get(ne.sid)??0)-He*Xe*st),Y+=Xe}for(const R of E)R.anchored||(R.x=Math.max(0,R.x+(q.get(R.sid)??0)),R.y=Math.max(0,R.y+(G.get(R.sid)??0)));if(Y<N)break}const M=[];for(const A of E){const q=A.x-P.get(A.sid),G=A.y-z.get(A.sid);if(!(Math.abs(q)<1&&Math.abs(G)<1)){for(const Y of A.members){if(n.has(Y))continue;const R=t.get(Y);R&&t.set(Y,{x:R.x+q,y:R.y+G})}M.push(A.sid)}}return M}const MB=600;function sw(e,t){return!(e.exitAt!=null&&t-e.exitAt>MB||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function IB(e,t){const n=new Set;for(const s of e.agents.values())sw(s,t)&&n.add(s.id);return n}function OB(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 PB(e,t,n=0){if(!e)return!1;for(const s of t)if(OB(e,s,n))return!0;return!1}const YR="sessionGroup";function $B(e,t){var s;if(e.type===YR)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const KR=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function xC(e){const t={};for(const n of KR)t[n]=e(n);return t}function LB(e){return t=>e[t]??""}function qB(e,t){return KR.every(n=>e[n]===t[n])}function DB(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[i,a]of e.positions)n.set(i,a),t.has(i)&&s.set(i,a);return{positions:n,pinned:s}}const FB=1200,zB=1e3;function bC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<FB?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<zB}function _v({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function BB(e,t,n){const s=e.x*t.zoom+t.x,i=e.y*t.zoom+t.y,a=(e.x+e.width)*t.zoom+t.x,l=(e.y+e.height)*t.zoom+t.y;return a>0&&s<n.width&&l>0&&i<n.height}function UB({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 i of n)if(s=!0,BB(i,t,e))return!1;return s}const WB="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Sv="click for what's new";function HB(e){if(e.checkDisabled)return`${WB} · ${Sv}`;if(e.checking)return`Asking npm for the newest release… · ${Sv}`;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 · ${Sv}, and to check npm now`}function GB(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 VB(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 YB(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 ow={kind:"assumed",claude:!0,codex:!0};function KB(e){if(!e||typeof e!="object")return ow;const t=e.providers;if(!t||typeof t!="object")return ow;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Pu(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const kC=99;function XB(e){const t=Math.max(0,Math.floor(e));return t>kC?`${kC}+`:String(t)}const QB="Pause the canvas";function ZB(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 — ${Pu(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)":`${Pu(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function JB(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 XR="paused · full",e8=(e,t)=>t>0?XR:e>0?`paused · ${XB(e)}`:"paused";function t8(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:e8(e.held,t),widest:XR,title:t>0?`Connected — the pause is full at ${Pu(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${Pu(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 _C(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const n8={agent:m3,sessionGroup:M3},QR="react-flow__node";function SC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,QR))===!0}function r8(e){try{const t=document.querySelector(`.${QR}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const s8=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),o8=420,hu=18,i8=200,a8=5*6e4,l8=6,c8=2*6e4,NC=400,o0="agent-dag.layout",i0="agent-dag.viewport",ZR="agent-dag.summariesDismissed",JR="agent-dag.sessionListOpen",eA="agent-dag.detailOpen",tA="agent-dag.usagePanelOpen",EC="agent-dag.accountsPanelOpen",Nv="agent-dag.versionNoticeDismissed",CC="agent-dag.oldNameNoticeDismissed",u8=15*6e4,Ev={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:"},jC="agent-dag.autoRestart",TC="agent-dag.bundleReloadedFor";function d8(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(JR)==="1"}catch{return!1}}function f8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(JR,e?"1":"0")}catch{}}function h8(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eA)==="1"}catch{return!1}}function p8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eA,e?"1":"0")}catch{}}function m8(){const e=Hu(tA);return e===null?!0:e==="1"}function g8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tA,e?"1":"0")}catch{}}function y8(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(ZR);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 RC(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(ZR,JSON.stringify(n))}catch{}}function v8(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(o0);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const i=Object.entries(n).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number");return{positions:i,pins:i.map(([a])=>a)}}return{positions:Object.entries(n.positions??{}).filter(([,i])=>i&&typeof i.x=="number"&&typeof i.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function Cv(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,i]of e)n[s]=i;for(const[s,i]of t)n[s]=i;window.localStorage.setItem(o0,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function w8(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(i0);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 x8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(i0,JSON.stringify(e))}catch{}}function AC(){if(!(typeof window>"u")){try{window.localStorage.removeItem(o0)}catch{}try{window.localStorage.removeItem(i0)}catch{}}}function b8(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const i={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(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}))}))},a=JSON.stringify(i,null,2),l=new Blob([a],{type:"application/json"}),u=URL.createObjectURL(l),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=u,h.download=`${Bt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(u),1e3)}const iw={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},aw={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},nA=vT;function k8(e,t,n,s,i,a,l,u,h,p,f,g,v,w,N,b,k,_){const E=[],C=[];for(const A of e.agents.values()){if(!k.has(A.id))continue;const q=A.exitAt!=null,G=b!=null&&!b.has(A.id),Y=[q?"rf-exiting":"",G?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,R=a.get(A.id);if(E.push({id:A.id,type:"agent",position:{x:0,y:0},data:{...A,now:t,onOpenContext:_},className:Y,...R?{width:R.width,height:R.height}:null}),A.parentId&&k.has(A.parentId)){const Q=jw(A.sessionId),H=q,ne=N.size>0&&(N.has(A.id)||N.has(A.parentId)),X=b!=null&&!b.has(A.id)&&!b.has(A.parentId),U=A.state==="active"?2:1.5,J=ne?U+1.5:U,$=H?.2:X?.12:1,V=["sess-edge",A.state==="active"?"sess-live":"sess-idle",H?"rf-edge-exiting":"",ne?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${A.parentId}->${A.id}`,source:A.parentId,target:A.id,animated:(A.state==="active"||ne)&&!H,type:"smoothstep",style:{"--session-hue":Q,strokeWidth:J,opacity:$,transition:"var(--edge-transition)"},className:V})}}const j=new Map;for(const A of e.agents.values())A.tools.length>0&&j.set(A.id,Math.min(4,A.tools.length));const I=`${v}#lanes:${EB(j)}`,O=E.filter(A=>b5(A.id,i,f,g));if(O.length>0||I!==w.current){if(O.length>0){const A=jB(E,C,{direction:"LR",pinned:i,measured:a,availableWidth:n,availableHeight:s,lanes:j});for(const q of A)WT(q.id,f,g)&&_5(q.id,q.position,f,g);RB(E,f,i,a,new Set(O.map(q=>q.id)),j)}TB(E,f,i,a,j),w.current=I}const P=AB(E,f,i,a,l,!h||p,j);P.length>0&&u(P),au(f,e.agents),au(g,e.agents),au(i,e.agents),au(a,v5(e.agents.values()));const z=[];let M=!1;for(const A of E){let q=i.get(A.id)??f.get(A.id);q||(q=k5(A.id,f,g),M=!0),z.push({...A,position:q})}return M&&(w.current=""),{nodes:z,edges:C}}function _8(){return d.jsx(Ew,{children:d.jsx(S8,{})})}function S8(){var ps,ka,_a,Sa;const e=Cl(),t=At(),n=S.useState(Wv)[0],s=S.useRef(n),[,i]=S.useState(0),a=S.useCallback(()=>i(F=>F+1),[]),[l,u]=S.useState(()=>new Set),[h,p]=S.useState(null),[f,g]=S.useState(null),v=S.useCallback((F,B)=>{u(le=>{if(!B)return new Set([F]);const de=new Set(le);return de.has(F)?de.delete(F):de.add(F),de}),p(le=>B&&le===F?le:F)},[]),w=S.useCallback(()=>{u(new Set),p(null)},[]),[N,b]=S.useState(null),[k,_]=S.useState(null),E=S.useCallback(F=>_(F),[]),[C,j]=S.useState(!1),[I,O]=S.useState(!1),P=S.useState(y8)[0],[z,M]=S.useState(d8);S.useEffect(()=>{f8(z)},[z]);const[A,q]=S.useState(h8);S.useEffect(()=>{p8(A)},[A]);const[G,Y]=S.useState(m8);S.useEffect(()=>{g8(G)},[G]);const[R,Q]=S.useState(()=>{try{const F=window.localStorage.getItem(EC);return F===null?!0:F==="1"}catch{return!0}});S.useEffect(()=>{try{window.localStorage.setItem(EC,R?"1":"0")}catch{}},[R]);const[H,ne]=S.useState(null);S.useEffect(()=>{let F=null;try{F=localStorage.getItem("agent-dag.sound")}catch{}ne(F===null?!0:F==="on")},[]);const X=S.useCallback(()=>{ne(F=>{var le;const B=F!==!0;try{localStorage.setItem("agent-dag.sound",B?"on":"off")}catch{}return B&&((le=Ee.current)==null||le.unlock()),B})},[]),U=S.useCallback(F=>{X()},[X]),J=S.useRef(U);J.current=U;const $=S.useRef(H);$.current=H;const[V,Z]=S.useState(()=>HD(Hu)),D=S.useRef(V);D.current=V;const L=S.useRef(null),K=S.useCallback((F,B=!1)=>{var le,de;if((le=Ee.current)==null||le.unlock(),L.current!==null&&clearTimeout(L.current),L.current=null,!B){(de=Ee.current)==null||de.play(F,!0);return}L.current=setTimeout(()=>{var _e;L.current=null,(_e=Ee.current)==null||_e.play(F,!0)},FD)},[]),se=S.useCallback((F,B)=>{Z(le=>{const de={level:xl(B.level??le[F].level),figure:DT(F,B.figure??le[F].figure)};try{localStorage.setItem(zT[F],String(de.level)),localStorage.setItem(BT[F],de.figure)}catch{}return{...le,[F]:de}}),K(F,!0)},[K]);S.useEffect(()=>()=>{L.current!==null&&clearTimeout(L.current)},[]);const[he,me]=S.useState(!1),xe=S.useRef(null),Ee=S.useRef(null),[He,Fe]=S.useState("locked");S.useEffect(()=>{const F=YD({enabled:()=>$.current===!0,prefs:()=>D.current,onState:Fe});Ee.current=F,Fe(F.state());const B=()=>F.unlock();return window.addEventListener("pointerdown",B,{once:!0,capture:!0}),window.addEventListener("keydown",B,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",B,{capture:!0}),window.removeEventListener("keydown",B,{capture:!0})}},[]);const[Ie,be]=S.useState(!1),[ue,re]=S.useState(null),[pe,Oe]=S.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Nv)??""}catch{return""}}),[nt,st]=S.useState(!1),Xe=S.useRef(0),[Pe,Ue]=S.useState(!1),Ge=S.useCallback((F=!1)=>(F&&(Xe.current=Date.now(),Ue(!0)),fetch(F?"/api/version?refresh=1":"/api/version").then(B=>B.ok?B.json():null).then(B=>{B&&re(B)}).catch(()=>{}).finally(()=>{F&&Ue(!1)})),[]),it=S.useCallback(()=>{Ge(Date.now()-Xe.current>=u8)},[Ge]);S.useEffect(()=>{Ge();const F=window.setInterval(it,5*6e4),B=()=>{document.visibilityState==="visible"&&it()};return document.addEventListener("visibilitychange",B),()=>{window.clearInterval(F),document.removeEventListener("visibilitychange",B)}},[Ge,it]),S.useEffect(()=>{Ie&&Ge()},[Ie,Ge]);const ke=(ue==null?void 0:ue.notice)??null,[ct,It]=S.useState(null),ae=S.useRef(!1);S.useEffect(()=>{if(ae.current)return;const F=o5(),B=i5(F),le=c5({stored:B,running:(ue==null?void 0:ue.running)??null,notes:H1,remembers:a5(F)});le.reason!=="no-version"&&(ae.current=!0,le.record&&l5(F,le.record),le.show.length&&It({entries:le.show,since:B,firstRun:le.reason==="welcome"}))},[ue==null?void 0:ue.running]);const Le=(ue==null?void 0:ue.running)??"3.8.3",ze=S.useMemo(()=>UT(H1,null,Le),[Le]),Ce=S.useCallback(()=>{It({entries:ze,since:null,firstRun:!1})},[ze]),[Ve,Ct]=S.useState(null),[rt,Te]=S.useState(ow);S.useEffect(()=>{let F=!1;return fetch("/api/health").then(B=>B.ok?B.json():null).then(B=>{F||(Te(KB(B)),!(!B||typeof B.workspace!="string")&&Ct(B.workspace))}).catch(()=>{}),()=>{F=!0}},[Ie]);const wt=S.useRef(rt);wt.current=rt;const dt=ke?`${ke.kind}:${ke.to}`:"",St=ke!=null&&pe!==dt,Sn=S.useCallback(()=>{Oe("");try{window.localStorage.setItem(Nv,"")}catch{}},[]),Fn=S.useCallback(()=>{if(ke){Oe(dt);try{window.localStorage.setItem(Nv,dt)}catch{}}},[ke,dt]),[Nn,To]=S.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(CC)??""}catch{return""}}),hn=ue!=null&&ue.invokedAs&&ue.invokedAs!==Bt?ue.invokedAs:null,Ro=hn!=null&&Nn!==hn,Ao=S.useCallback(()=>{if(hn){To(hn);try{window.localStorage.setItem(CC,hn)}catch{}}},[hn]),Ut=((ps=ue==null?void 0:ue.upgrade)==null?void 0:ps.state)??"idle",Tr=kD(ue==null?void 0:ue.upgrade),zn=S.useRef(!1),Ds=S.useCallback(async()=>{if(ar(zn.current||Ut==="running")){zn.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Ge(),zn.current=!1}},[Ut,Ge]);S.useEffect(()=>{if(Ut!=="running")return;const F=window.setInterval(Ge,3e3);return()=>window.clearInterval(F)},[Ut,Ge]);const Rr=S.useCallback(async()=>{var le;const F=ue==null?void 0:ue.command;if(!F)return;let B=!1;try{B=await Promise.race([((le=navigator.clipboard)==null?void 0:le.writeText(F).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{B=!1}if(!B)try{const de=document.createElement("textarea");de.value=F,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),B=document.execCommand("copy"),de.remove()}catch{B=!1}B&&(st(!0),window.setTimeout(()=>st(!1),1600))},[ue==null?void 0:ue.command]),na=S.useCallback(()=>{M(F=>(F||Q(!1),!F))},[]),fr=S.useCallback(()=>{Q(F=>(F||M(!1),!F))},[]),[Ar,hr]=S.useState(!1),[ns,Mo]=S.useState(!1),[Io,Oo]=S.useState(()=>{try{return Number(localStorage.getItem(K1))||0}catch{return 0}}),[En,Po]=S.useState([]),[Mr,$o]=S.useState(!1);S.useEffect(()=>{let F=!0;const B=()=>{fetch("/api/browser-watch?live=0").then(de=>de.ok?de.json():null).then(de=>{var _e;!F||!(de!=null&&de.ok)||(Po(de.episodes??[]),$o(((_e=de.settings)==null?void 0:_e.enabled)===!0))}).catch(()=>{})};B();const le=setInterval(B,5*6e4);return()=>{F=!1,clearInterval(le)}},[]);const Bn=S.useMemo(()=>Q5(En,Io).length,[En,Io]),[Lo,Fs]=S.useState(0),zs=S.useRef(null),[qo,Do]=S.useState(!1),at=S.useRef(null),[ra,rs]=S.useState(0),Vt=S.useState(()=>j5({protect:F=>xL(s.current,F)}))[0],[Un,Fo]=S.useState(!1),ss=S.useCallback(()=>{const F=Vt.paused&&Vt.dropped>0,B=Vt.setPaused(!Vt.paused);F&&bL(s.current);for(const le of B)s.current=e1(s.current,le);Fo(Vt.paused)},[Vt]),[xt,rn]=S.useState(Date.now()),[Wn,pn]=S.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(jC)!=="0"}catch{return!0}}),dd=S.useCallback(()=>{pn(F=>{const B=!F;try{window.localStorage.setItem(jC,B?"1":"0")}catch{}return B})},[]),[Ir,zo]=S.useState(!1),[Bo,Uo]=S.useState("restart"),[os,Bs]=S.useState(null),is=S.useRef(!1),Dl=S.useRef(null),Wo=S.useRef(0),Us=S.useCallback(async F=>{if(!ar(is.current))return;const B=(F==null?void 0:F.upgrade)===!0;is.current=!0,Dl.current=Tr;const le=++Wo.current;Uo(B?"npx":"restart"),zo(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ke==null?void 0:ke.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:B})})}catch{}window.setTimeout(()=>{if(Wo.current===le&&is.current){is.current=!1,zo(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},B?18e4:3e4)},[ke==null?void 0:ke.to,Tr]),Ho=S.useRef(null);S.useEffect(()=>{let F=!1;for(const le of s.current.agents.values())if(le.state==="active"){F=!0;break}const B=SD({enabled:Wn,kind:ke==null?void 0:ke.kind,canRestart:(ue==null?void 0:ue.canRestart)===!0,busy:F,idleSince:Ho.current,now:xt});Ho.current=B.idleSince,B.restart&&Us()},[Wn,ke==null?void 0:ke.kind,ue==null?void 0:ue.canRestart,xt,Us]),S.useEffect(()=>{const F=ue==null?void 0:ue.running;let B=null,le=null;try{B=window.sessionStorage.getItem("agent-dag.restartPending"),le=window.sessionStorage.getItem(TC)}catch{return}const de=bD({bundle:"3.8.3",running:F,pending:B,lastTried:le});if(de==="reload"){try{window.sessionStorage.setItem(TC,F??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}is.current=!1,zo(!1),Bs(F??null);const _e=window.setTimeout(()=>Bs(null),6e3);return()=>window.clearTimeout(_e)},[ue==null?void 0:ue.running]),S.useEffect(()=>{if(Ir&&_D({asked:Dl.current,reported:Tr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}is.current=!1,zo(!1)}},[Ir,Tr]);const as=S.useState(()=>DB(v8()))[0],Zt=S.useRef(as.pinned),ls=S.useRef(null),Qe=S.useState(()=>w8())[0],[sa,Fl]=S.useState(()=>new Set),[Or,oa]=S.useState(R5),[Hn,zl]=S.useState(()=>xC(_C)),Go=S.useMemo(()=>LB(Hn),[Hn]),Vo=S.useCallback(F=>$B(F,Go),[Go]),pr=S.useMemo(()=>({background:Hn["--panel"],border:`1px solid ${Hn["--line"]}`,borderRadius:8}),[Hn]),[Gn,mr]=S.useState(!1);S.useEffect(()=>{document.documentElement.dataset.theme=Or;try{window.localStorage.setItem(HT,Or)}catch{}zl(F=>{const B=xC(_C);return qB(F,B)?F:B})},[Or]);const mn=S.useCallback((F,B)=>{if(_v({durationMs:B,documentHidden:document.hidden})){e.setViewport(F,{duration:B});return}const{d3Zoom:le,d3Selection:de}=t.getState(),_e=de==null?void 0:de.property("__zoom");if(le&&de&&_e&&_e.k>0&&F.zoom>0){le.transform(de,_e.scale(F.zoom/_e.k).translate((F.x-_e.x)/F.zoom,(F.y-_e.y)/F.zoom));return}e.setViewport(F,{duration:0})},[e,t]),Vn=S.useRef(null);S.useEffect(()=>{if(!Qe)return;const F=window.setTimeout(()=>{try{mn(Qe,0)}catch{}Kn.current=Date.now()},60);return()=>window.clearTimeout(F)},[mn,Qe]);const Yn=S.useRef(!0);S.useEffect(()=>{const F=new EventSource("/events"),B=E5(a,{now:()=>Date.now(),setTimeout:(le,de)=>window.setTimeout(le,de),clearTimeout:le=>window.clearTimeout(le)});return F.addEventListener("open",()=>{be(!0),mr(!0)}),F.addEventListener("error",()=>be(!1)),F.addEventListener("replay-end",()=>{Yn.current=!1,B.flush()}),F.addEventListener("hook",le=>{var de;try{const _e=JSON.parse(le.data);if(!Vt.accept(_e))return;s.current=e1(s.current,_e);const Re=_e.replay===!0||Yn.current||Date.now()-_e.receivedAt>3e4;Re?B.replay():B.live();const Be=VD(_e,Re);Be&&((de=Ee.current)==null||de.play(Be))}catch{}}),()=>{F.close(),B.cancel()}},[a]),S.useEffect(()=>{const F=setInterval(()=>{const B=Date.now();rn(B);let le=kL(s.current,B,Jb);_L(s.current,B,Jb)&&(le=!0),vL(s.current,B,i8,a8)&&(le=!0),wL(s.current,B,l8,c8)&&(le=!0),u(de=>y5(de,s.current.agents)),p(de=>de!=null&&!s.current.agents.has(de)?null:de),_(de=>de!=null&&!s.current.agents.has(de)?null:de),b(de=>de!=null&&!s.current.agents.has(de)?null:de),le&&a()},250);return()=>clearInterval(F)},[a]);const ia=S.useRef(null),Kn=S.useRef(0),Ws=420,Cn=S.useCallback((F=500)=>{try{const Re=document.querySelector(".canvas-wrap"),Be=Array.from(document.querySelectorAll(".react-flow__node")).filter(ut=>ut.offsetWidth>0);if(!Re||Be.length===0)return;const Ze=Re.getBoundingClientRect(),ht=e.getViewport();if(!Number.isFinite(ht.zoom)||ht.zoom<=0)return;const ot=ut=>(ut-Ze.left-ht.x)/ht.zoom,Pt=ut=>(ut-Ze.top-ht.y)/ht.zoom,ms=Be.map(ut=>ut.getBoundingClientRect()),Na=Math.min(...ms.map(ut=>ot(ut.left))),si=Math.max(...ms.map(ut=>ot(ut.right))),Ea=Math.min(...ms.map(ut=>Pt(ut.top))),rc=Math.max(...ms.map(ut=>Pt(ut.bottom))),Ca=si-Na,oi=rc-Ea;if(!(Ca>0&&oi>0))return;const gs=Math.max(.2,Math.min(1,(Ze.width-160)/(Ca+Ws)*.86,(Ze.height-160)/oi*.86)),ys={x:80-Na*gs,y:Math.max(80,(Ze.height-oi*gs)/2)-Ea*gs,zoom:gs};mn(ys,F),Kn.current=Date.now(),Vn.current=_v({durationMs:F,documentHidden:document.hidden})?{target:ys,until:Date.now()+F+60}:null,window.setTimeout(()=>{var ut;try{((ut=Vn.current)==null?void 0:ut.target)===ys&&(Vn.current=null);const ii=e.getViewport();(Math.abs(ii.zoom-gs)>.01||Math.abs(ii.x-ys.x)>2)&&mn(ys,0)}catch{}},F+60)}catch{}},[e,mn]);S.useEffect(()=>{const F=()=>{if(!document.hidden)return;const B=Vn.current;if(Vn.current=null,!(!B||Date.now()>B.until)){try{mn(B.target,0)}catch{}Kn.current=Date.now()}};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[mn]);const Yo=S.useRef(""),cs=S.useRef(null),aa=S.useRef(0),Ko=S.useCallback(()=>{aa.current=Date.now()},[]),Pr=S.useRef(null),us=S.useRef(0),gr=S.useCallback(()=>{us.current=Date.now()},[]),Hs=S.useCallback(F=>({hasSourceEvent:!!F,at:Date.now(),lastDeckFitAt:Kn.current,lastCanvasInputAt:us.current}),[]),la="agent-dag.autoFitDisabled",Bl=S.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(la)==="1"}catch{return!1}})[0],yr=S.useRef(Bl),[Gs,Xo]=S.useState(Bl),Qo=S.useCallback(()=>{if(!yr.current){yr.current=!0,Xo(!0);try{window.localStorage.setItem(la,"1")}catch{}}},[]),vr=S.useCallback(()=>{yr.current=!1,Xo(!1);try{window.localStorage.removeItem(la)}catch{}Cn(400)},[e,Cn]);S.useEffect(()=>{const F=setInterval(()=>{if(yr.current||Date.now()-aa.current<800)return;const B=s.current,le=Date.now(),de=[];for(const Re of B.agents.values())sw(Re,le)&&de.push({id:Re.id});if(de.length===0)return;const _e=[];for(const{id:Re}of de){const Be=Xn.current.get(Re),Ze=Zt.current.get(Re)??Ot.current.get(Re);!Be||!Ze||_e.push({x:Ze.x,y:Ze.y,width:Be.width,height:Be.height})}UB({pane:Pr.current,viewport:e.getViewport(),boxes:_e})&&Cn(600)},1500);return()=>clearInterval(F)},[e]);const Vs=S.useRef(!1),Xn=S.useRef(new Map),ca=S.useRef(0),Zo=S.useCallback(F=>{const B=Xn.current;let le=!1;for(const de of F.nodeInternals.values()){const _e=de.width,Re=de.height;if(_e==null||Re==null)continue;const Be=B.get(de.id);Be?(Math.abs(Be.height-Re)>4||Math.abs(Be.width-_e)>4)&&(B.set(de.id,{width:_e,height:Re}),le=!0):(B.set(de.id,{width:_e,height:Re}),le=!0)}return le&&(ca.current+=1),ca.current},[]),Ys=lt(Zo),[ua,Jt]=S.useState(0);S.useEffect(()=>{let F=0;const B=()=>{const de=Xn.current;let _e=!1;for(const Re of document.querySelectorAll(".react-flow__node[data-id]")){const Be=Re.getAttribute("data-id");if(!Be)continue;const Ze=Re.offsetWidth,ht=Re.offsetHeight;if(!Ze||!ht)continue;const ot=de.get(Be);(!ot||Math.abs(ot.width-Ze)>4||Math.abs(ot.height-ht)>4)&&(de.set(Be,{width:Ze,height:ht}),_e=!0)}_e&&Jt(Re=>Re+1)};if(Vs.current)return;let le=0;return document.visibilityState==="hidden"?le=window.setTimeout(B,32):F=requestAnimationFrame(B),()=>{cancelAnimationFrame(F),window.clearTimeout(le)}});const Ot=S.useRef(as.positions),da=S.useRef(new Set),$r=S.useRef(""),ds=S.useMemo(()=>{const F=[];for(const B of s.current.agents.values())sw(B,xt)&&F.push(B.id+(B.parentId?`>${B.parentId}`:""));return F.sort(),`${F.join("|")}#sv${Ys}.${ua}`},[s.current,s.current.revision,xt,Ys,ua]),Lr=S.useRef(null);S.useEffect(()=>(Lr.current!=null&&window.clearTimeout(Lr.current),Lr.current=window.setTimeout(()=>{Cv(Ot.current,Zt.current)},1500),()=>{Lr.current!=null&&window.clearTimeout(Lr.current)}),[ds]),S.useEffect(()=>{if(Yo.current===ds)return;const F=Yo.current;if(Yo.current=ds,!F||yr.current)return;Date.now()-Kn.current>1200&&Cn(400),ia.current&&window.clearTimeout(ia.current),ia.current=window.setTimeout(()=>{yr.current||Cn(500)},280)},[ds,e,Cn]);const Ks=S.useMemo(()=>x5(s.current,l),[s.current,s.current.revision,l]),qr=S.useMemo(()=>IB(s.current,xt),[s.current,s.current.revision,xt]),Xs=S.useRef(null),[Qs,Ul]=S.useState({w:0,h:0});S.useEffect(()=>{const F=Xs.current;if(!F||typeof ResizeObserver>"u")return;const B=new ResizeObserver(le=>{var _e;const de=(_e=le[0])==null?void 0:_e.contentRect;de&&(Pr.current={width:de.width,height:de.height},Ul(Re=>Math.abs(Re.w-de.width)>40||Math.abs(Re.h-de.height)>40?{w:de.width,h:de.height}:Re))});return B.observe(F),Pr.current={width:F.clientWidth,height:F.clientHeight},Ul({w:F.clientWidth,h:F.clientHeight}),()=>B.disconnect()},[]);const fd=S.useCallback(F=>{var le,de;const B=F.target;!(B!=null&&B.closest)||B.closest(s8)!==F.currentTarget||(F.preventDefault(),(de=(le=document.activeElement)==null?void 0:le.blur)==null||de.call(le))},[]),hd=S.useRef(new Map),[Jo,pd]=S.useState(!1);S.useEffect(()=>{const F=window.setTimeout(()=>pd(!0),2500);return()=>window.clearTimeout(F)},[]);const[md,fa]=S.useState(!1),wr=S.useRef(null),[ha,pa]=S.useState(!1),gd=S.useCallback(()=>{wr.current&&(window.clearTimeout(wr.current),wr.current=null),fa(!1)},[]),yd=S.useCallback(F=>{F.length!==0&&queueMicrotask(()=>{fa(!0),wr.current&&window.clearTimeout(wr.current),wr.current=window.setTimeout(()=>fa(!1),o8+80)})},[]);S.useEffect(()=>()=>{wr.current&&window.clearTimeout(wr.current)},[]);const Wl=Qs.w>0?Qs.w*.92:0,Hl=Qs.h>0?Qs.h:0,{nodes:jn,edges:vd}=S.useMemo(()=>k8(s.current,xt,Wl,Hl,Zt.current,Xn.current,hd.current,yd,Jo,ha,Ot.current,da.current,ds,$r,l,Ks,qr,E),[s.current,s.current.revision,xt,Wl,Hl,Jo,ha,ds,l,Ks,qr,E,Lo]),Gl=S.useMemo(()=>{const F=new Map;for(const le of jn){const de=le.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const _e=le.width,Re=le.height;if(_e==null||Re==null)continue;const Be=le.position.x,Ze=le.position.y,ht=Be+_e,ot=Ze+Re,Pt=F.get(de.sessionId);Pt?(Pt.minX=Math.min(Pt.minX,Be),Pt.minY=Math.min(Pt.minY,Ze),Pt.maxX=Math.max(Pt.maxX,ht),Pt.maxY=Math.max(Pt.maxY,ot)):F.set(de.sessionId,{minX:Be,minY:Ze,maxX:ht,maxY:ot})}const B=[];for(const[le,de]of F){const _e=de.maxX-de.minX+hu*2,Re=de.maxY-de.minY+hu*2;B.push({id:`group:${le}`,type:YR,position:{x:de.minX-hu,y:de.minY-hu},data:{sessionId:le,w:_e,h:Re},width:_e,height:Re,style:{width:_e,height:Re},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return B},[jn,xt]),wd=S.useMemo(()=>{const F=[...Gl,...jn],B=at.current;return!B||B.size===0?F:F.map(le=>{const de=B.get(le.id);return de?{...le,position:de}:le})},[Gl,jn,ra]),Zs=S.useMemo(()=>{const F=new Set;for(const B of s.current.agents.values())for(const le of B.tools)F.add(nA(le.name));return Object.keys(iw).filter(B=>F.has(B))},[s.current,s.current.revision]);S.useEffect(()=>{if(Zs.length<=1){Do(!1);return}let F=0;const B=()=>{const le=zs.current;if(le&&!document.hidden){const de=le.getBoundingClientRect(),_e=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Be=>Be.getBoundingClientRect()),Re=PB(de,_e,8);Do(Be=>Be===Re?Be:Re)}F=window.setTimeout(B,300)};return B(),()=>window.clearTimeout(F)},[Zs.length]);const xd=S.useCallback(F=>{Fl(B=>{const le=new Set(B);return le.has(F)?le.delete(F):le.add(F),le})},[]),en=h?s.current.agents.get(h):null,ma=f?Array.from(s.current.agents.values()).flatMap(F=>F.tools).find(F=>F.id===f)??null:null,Vl=S.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=Wv(),Zt.current.clear(),Xn.current.clear(),Ot.current.clear(),$r.current="",AC(),w(),a()},[a,w]),Yl=S.useRef(C);Yl.current=C;const Kl=S.useRef(I);Kl.current=I;const ga=S.useRef(!1);ga.current=ma!=null||Ar||k!=null||N!=null||ns||I||ct!=null;const fs=S.useCallback(F=>{const B=ND(F,{confirmOpen:Yl.current,modalOpen:ga.current});B==="confirm"?j(!0):B==="clear"&&(j(!1),Vl())},[Vl]),Dr=S.useCallback(()=>{Zt.current.clear(),Ot.current.clear(),$r.current="",AC(),a(),window.setTimeout(()=>Cn(500),80)},[a,e,Cn]),Xl=S.useCallback(()=>Cn(500),[Cn]),Js=S.useRef(jn);Js.current=jn;const ya=S.useRef(h);ya.current=h;const ei=S.useCallback(F=>{const B=Js.current,le=f5(B.map(Re=>({id:Re.id,x:Re.position.x,y:Re.position.y})),ya.current,F),de=le?B.find(Re=>Re.id===le):void 0;if(!de)return;const _e=SC(document.activeElement);v(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}Kn.current=Date.now(),_e&&r8(de.id)},30)},[v,e]),ti=S.useCallback(F=>{v(F,!1),window.setTimeout(()=>{try{const B=Js.current.find(le=>le.id===F);B&&e.fitView({padding:.3,duration:500,nodes:[B]}),Kn.current=Date.now()}catch{}},60)},[v,e]);S.useEffect(()=>{const F=B=>{var Ze,ht;const le=B.target,de={tagName:le==null?void 0:le.tagName,isContentEditable:le==null?void 0:le.isContentEditable,role:(Ze=le==null?void 0:le.getAttribute)==null?void 0:Ze.call(le,"role"),type:le==null?void 0:le.type};if(B.key==="Escape"){const ot=ZL({overlayOpen:qi.depth()>0,panelOnTop:qi.topIsPanel(),typing:Mw(de)});ot==="dismiss"?qi.dismissTop():ot==="blur"?le==null||le.blur():(g5(de)&&(le==null||le.blur()),w());return}if(Aw(B))return;const _e=SC(le)?(ht=le==null?void 0:le.getAttribute)==null?void 0:ht.call(le,"data-id"):null,Re=_e&&Js.current.some(ot=>ot.id===_e)?_e:null,Be=p5(B,Re);if(Be.kind==="activate"){B.preventDefault(),v(Be.nodeId,Be.additive);return}Be.kind!=="node"&&(Be.nodeId==null&&i3(de)||a3({key:B.key,modalOpen:ga.current,sheetOpen:Kl.current})||(B.key===" "&&(B.preventDefault(),ss()),(B.key==="c"||B.key==="C")&&fs("shortcut"),(B.key==="r"||B.key==="R")&&Dr(),(B.key==="f"||B.key==="F")&&Xl(),(B.key==="l"||B.key==="L")&&na(),(B.key==="h"||B.key==="H")&&hr(ot=>!ot),(B.key==="u"||B.key==="U")&&Y(ot=>!ot),(B.key==="a"||B.key==="A")&&wt.current.claude&&fr(),(B.key==="j"||B.key==="J")&&ei(1),(B.key==="k"||B.key==="K")&&ei(-1),(B.key==="t"||B.key==="T")&&oa(ot=>ot==="dark"?"light":"dark"),(B.key==="m"||B.key==="M")&&wt.current.claude&&$.current!==null&&J.current(B.shiftKey),B.key==="?"&&O(ot=>!ot)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[fs,Dr,Xl,w,v,ei,ss]);const ni=s.current.agents.size,bt=S.useMemo(()=>UL(s.current.agents.values()),[s.current,s.current.revision]),Ql=S.useMemo(()=>WL(s.current.agents.values()),[s.current,s.current.revision]),Zl=S.useRef(null);S.useEffect(()=>{const F=A5({waiting:bt.length,running:Ql,connected:Ie}),B=Zl.current;if(Zl.current=F,(B==null?void 0:B.title)!==F.title&&(document.title=F.title),(B==null?void 0:B.icon)!==F.icon){const le=document.querySelector('link[rel="icon"]');le&&(le.href=M5[F.icon])}},[bt.length,Ql,Ie]);const[bd,Jl]=S.useState(""),va=O5(bt);S.useEffect(()=>{Jl(F=>P5(F,va))},[va]);const[xr,eo]=S.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Fr,hs]=S.useState(null),[kd,ec]=S.useState(!1),[Qn,to]=S.useState(!0),[tc,wa]=S.useState(!1);S.useEffect(()=>{let F=!0;return fetch("/api/prefs").then(B=>B.ok?B.json():null).then(B=>{var le;!F||!(B!=null&&B.ok)||(to(((le=B.prefs)==null?void 0:le.notifications)!==!1),wa(B.notificationsVetoed===!0))}).catch(()=>{}),()=>{F=!1}},[]);const nc=S.useCallback(()=>{const F=!Qn;to(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:F})}).then(B=>B.ok?B.json():null).then(B=>{var le;B!=null&&B.ok&&(to(((le=B.prefs)==null?void 0:le.notifications)!==!1),wa(B.notificationsVetoed===!0))}).catch(()=>{})},[Qn]),xa=KL(xr,typeof Notification<"u");S.useEffect(()=>{xa&&Qn&&bt.length>0&&ec(!0)},[xa,Qn,bt.length]),S.useEffect(()=>{if(!Fr)return;const B=setTimeout(()=>hs(null),Fr==="blocked"?8e3:4e3);return()=>clearTimeout(B)},[Fr]);const _d=S.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(F=>{const B=F;eo(B),B==="granted"?hs("on"):B==="denied"&&hs("blocked")})},[]),ri=S.useRef(new Set),ba=S.useRef(null),gn=bt.map(F=>Wu(F.id,F.waiting)).join("|");return S.useEffect(()=>{YL(ba.current,xr)&&(ba.current=xr,ri.current=r1(bt))},[xr]),S.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||ba.current===null)return;const F=typeof document>"u"||!document.hidden,B=GL(bt,ri.current,F,Qn);for(const le of B)try{const de=new Notification(le.title,{body:le.body,tag:le.key});de.onclick=()=>{window.focus(),ti(le.sessionId),de.close()}}catch{}ri.current=F?r1(bt):VL(bt,B,ri.current)},[gn]),d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),d.jsxs("header",{className:"topbar",children:[d.jsxs("div",{className:"readout",children:[d.jsxs("div",{className:"brand",children:[d.jsx("span",{className:"logo"}),d.jsx("h1",{children:Bt}),ke?d.jsxs("button",{type:"button",className:"v stale",onClick:()=>{Ce(),Sn()},"aria-haspopup":"dialog","aria-label":VB({...ke,open:St}),title:ke.kind==="restart"?`Running v${ke.from}; v${ke.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${ke.from}; v${ke.to} is on npm · click for what's new`,children:["v",ke.from,d.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const F={running:Le,latest:ue==null?void 0:ue.latest,latestPending:ue==null?void 0:ue.latestPending,checkedAgo:ue!=null&&ue.checkedAt?Xv(xt-ue.checkedAt):null,checkDisabled:ue==null?void 0:ue.checkDisabled,checking:Pe};return d.jsxs("button",{type:"button",className:Pe?"v checking":"v",onClick:()=>{Ce(),Ge(!0)},"aria-busy":Pe||void 0,"aria-haspopup":"dialog","aria-label":GB(F),title:HB(F),children:["v",F.running]})})()]}),d.jsxs("span",{className:"status",children:[(()=>{const F=t8({connected:Ie,paused:Un,held:Vt.size,dropped:Vt.dropped});return F.resting?null:d.jsx("span",{className:`pill ${F.tone}`,title:F.title,children:d.jsxs("span",{className:"pill-box",children:[d.jsx("span",{className:"pill-widest","aria-hidden":!0,children:F.widest}),d.jsx("span",{className:"pill-label",children:F.label})]})})})(),d.jsx(g4,{usageOpen:G})]}),d.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:bd}),bt.length>0&&d.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>ti(bt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
200
+ Click to set the volume and the sound of each tone, and to hear either one.`}function GT(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 i=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};i.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,i.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,i)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function U5(e){const t=GT([{agents:e}]);return t.length<2?null:t.map(n=>`${Fw(n.id)} ${Je(n.cost)}`).join(" · ")}function V1(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 W5(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function uu(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 H5=[7,14,30,90];function G5(e){const[t,n]=S.useState(null),[s,i]=S.useState(!1),a=S.useState($5)[0],l=S.useRef(!1),u=(h=!1)=>{if(h&&!ar(l.current))return;const p=a.begin();l.current=h;const f=e;i(!0);const v=`/api/ccusage?since=${Kv(f)}${h?"&refresh=1":""}`;fetch(v).then(w=>w.json()).then(w=>{p()&&n({range:f,resp:w})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(l.current=!1,i(!1))})};return S.useEffect(()=>(u(!1),()=>a.cancel()),[e]),{landed:t,loading:s,reload:()=>u(!0)}}function V5({onClose:e,providers:t}){var z;const[n,s]=S.useState(30),[i,a]=S.useState(null),{landed:l,loading:u,reload:h}=G5(n),p=S.useRef(null),f=_n(e,{focusRef:p}),g=L5({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((z=l.resp.days)==null?void 0:z.length)??0}}),v=g.phase==="chart"?l.resp.days??[]:[],w=S.useMemo(()=>v.reduce((M,A)=>Math.max(M,A.totalCost),0),[v]),N=S.useRef(null);S.useLayoutEffect(()=>{const M=N.current;M&&(M.scrollLeft=M.scrollWidth)},[v]);const{totalCost:b,totalTok:k,inOut:_,cacheRead:E,modelCosts:C}=S.useMemo(()=>{let M=0,A=0,q=0,G=0;const Y=new Map;for(const R of v){M+=R.totalCost,A+=R.totalTokens,q+=R.inputTokens+R.outputTokens,G+=R.cacheReadTokens;for(const Q of R.modelBreakdowns)Y.set(Q.modelName,(Y.get(Q.modelName)??0)+Q.cost)}return{totalCost:M,totalTok:A,inOut:q,cacheRead:G,modelCosts:Y}},[v]),j=S.useMemo(()=>Array.from(C.entries()).sort((M,A)=>A[1]-M[1]),[C]),I=S.useMemo(()=>GT(v),[v]),O=I.length>1,P=i?v.find(M=>M.period===i)??null:null;return d.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:f,className:"uh-modal",onClick:M=>M.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[d.jsxs("header",{className:"uh-head",children:[d.jsxs("div",{className:"uh-titlewrap",children:[d.jsx("div",{className:"uh-title",children:"Usage history"}),d.jsx("div",{className:"uh-sub",children:F5(t,I.map(M=>M.id))})]}),d.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:H5.map(M=>d.jsxs("button",{type:"button","aria-pressed":n===M,className:"uh-range-btn",onClick:()=>{s(M),a(null)},children:[M,"d"]},M))}),d.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...ir(u),title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),d.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.phase==="busy"?d.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):g.phase==="error"?d.jsxs("div",{className:"uh-status uh-err",title:Hi(l.resp)||void 0,children:[z4(l.resp,"ccusage did not report usage"),d.jsx("div",{children:d.jsx("button",{className:"btn uh-retry",onClick:h,...ir(u),children:u?"trying…":"Try again"})})]}):g.phase==="empty"?d.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):d.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[d.jsxs("div",{className:"uh-totals",children:[d.jsx(du,{label:"total cost",val:Je(b),accent:!0}),d.jsx(du,{label:"tokens",val:Rt(k)}),d.jsx(du,{label:"input+output",val:Rt(_)}),d.jsx(du,{label:"cache reads",val:Rt(E)})]}),O&&d.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[d.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:I.map(M=>d.jsx("span",{className:"uh-agent-seg",style:{width:`${b>0?M.cost/b*100:0}%`,background:V1(M.id)}},M.id))}),d.jsx("div",{className:"uh-agent-keys",children:I.map(M=>d.jsxs("span",{className:"uh-agent-key",title:`${M.id} · ${Rt(M.tokens)} tokens`,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:V1(M.id)}}),Fw(M.id),d.jsx("span",{className:"uh-agent-cost",children:Je(M.cost)}),d.jsx("span",{className:"uh-agent-share",children:W5(M.cost,b)})]},M.id))})]}),d.jsx("div",{ref:N,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:v.map(M=>{const A=w>0?M.totalCost/w*100:0,q=M.period===i,G=`${M.period}, ${Je(M.totalCost)}`;return d.jsxs("button",{className:`uh-bar-col${q?" sel":""}`,onClick:()=>a(q?null:M.period),"aria-pressed":q,"aria-label":G,title:`${M.period} · ${Je(M.totalCost)}`,style:{flexBasis:`${100/v.length}%`},children:[d.jsx("div",{className:"uh-bar",style:{height:`${Math.max(A,M.totalCost>0?2:0)}%`},children:M.modelBreakdowns.slice().sort((Y,R)=>R.cost-Y.cost).map(Y=>{const R=M.totalCost>0?Y.cost/M.totalCost*100:0;return d.jsx("div",{className:"uh-bar-seg",style:{height:`${R}%`,background:uu(Y.modelName)}},Y.modelName)})}),d.jsx("span",{className:"uh-bar-label",children:M.period.slice(5)})]},M.period)})}),d.jsx("div",{className:"uh-legend",children:j.map(([M,A])=>d.jsxs("span",{className:"uh-legend-item",title:M,children:[d.jsx("span",{className:"uh-legend-dot",style:{background:uu(M)}}),Ls(M)," ",d.jsx("span",{className:"uh-legend-cost",children:Je(A)})]},M))}),P&&d.jsxs("div",{className:"uh-detail",children:[d.jsxs("div",{className:"uh-detail-head",children:[d.jsx("span",{className:"uh-detail-date",children:P.period}),d.jsx("span",{className:"uh-detail-cost",children:Je(P.totalCost)}),(()=>{var q,G;const A=U5(P.agents)??((G=(q=P.metadata)==null?void 0:q.agents)!=null&&G.length?P.metadata.agents.join(" · "):null);return A?d.jsx("span",{className:"uh-detail-agents",title:A,children:A}):null})()]}),d.jsxs("div",{className:"uh-detail-mini",children:[d.jsx(fu,{label:"input",val:Rt(P.inputTokens)}),d.jsx(fu,{label:"output",val:Rt(P.outputTokens)}),d.jsx(fu,{label:"cache write",val:Rt(P.cacheCreationTokens)}),d.jsx(fu,{label:"cache read",val:Rt(P.cacheReadTokens)})]}),d.jsx("div",{className:"uh-detail-models",children:P.modelBreakdowns.slice().sort((M,A)=>A.cost-M.cost).map(M=>{const A=P.totalCost>0?M.cost/P.totalCost*100:0;return d.jsxs("div",{className:"uh-model-row",title:M.modelName,children:[d.jsxs("span",{className:"uh-model-name",children:[d.jsx("span",{className:"uh-legend-dot",style:{background:uu(M.modelName)}}),d.jsx("span",{className:"uh-model-label",children:Ls(M.modelName)})]}),d.jsx("span",{className:"uh-model-bar",children:d.jsx("span",{className:"uh-model-bar-fill",style:{width:`${A}%`,background:uu(M.modelName)}})}),d.jsx("span",{className:"uh-model-cost",children:Je(M.cost)})]},M.modelName)})})]})]})]})})}function du({label:e,val:t,accent:n}){return d.jsxs("div",{className:"uh-stat",children:[d.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),d.jsx("span",{className:"uh-stat-label",children:e})]})}function fu({label:e,val:t}){return d.jsxs("div",{className:"uh-ministat",children:[d.jsx("span",{className:"uh-ministat-val",children:t}),d.jsx("span",{className:"uh-ministat-label",children:e})]})}function Y5(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(i=>{const a=i/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const Y1=1e4,K5=12e3;function X5({browsers:e,findings:t,watching:n,palette:s,now:i=()=>Date.now()}){const a=S.useRef(null),l=S.useRef(null);return l.current={browsers:e,findings:t,watching:n},S.useEffect(()=>{var w;const u=a.current;if(!u)return;const h=u.getContext("2d");if(!h)return;const p=((w=window.matchMedia)==null?void 0:w.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,g=!1;const v=()=>{var ne;if(g)return;const N=l.current;if(!N)return;const{browsers:b,findings:k,watching:_}=N,E=s["--accent"]||"#7dd3fc",C=s["--line"]||"#1f2229",j=s["--text-dim"]||"#6e727c",I=Y5(s["--bg"]),O=I?42:26,P=I?.85:.65,z=i(),M=Math.min(window.devicePixelRatio||1,2),A=u.clientWidth,q=u.clientHeight;(u.width!==A*M||u.height!==q*M)&&(u.width=A*M,u.height=q*M),h.setTransform(M,0,0,M,0,0),h.clearRect(0,0,A,q);const G=A/2,Y=q/2,R=Math.min(A,q)/2-6;h.strokeStyle=C,h.lineWidth=1,h.globalAlpha=I?1:.9;for(const X of[.4,.7,1])h.beginPath(),h.arc(G,Y,R*X,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(G-R,Y),h.lineTo(G+R,Y),h.moveTo(G,Y-R),h.lineTo(G,Y+R),h.stroke(),h.globalAlpha=1;const H=(_&&!p?z%Y1/Y1:0)*Math.PI*2-Math.PI/2;if(_){const X=(ne=h.createConicGradient)==null?void 0:ne.call(h,H-.85,G,Y);X&&(X.addColorStop(0,"transparent"),X.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${E} ${O}%, transparent)`),X.addColorStop(1,"transparent"),h.fillStyle=X,h.beginPath(),h.moveTo(G,Y),h.arc(G,Y,R,H-.85,H),h.closePath(),h.fill()),h.strokeStyle=E,h.globalAlpha=P,h.beginPath(),h.moveTo(G,Y),h.lineTo(G+Math.cos(H)*R,Y+Math.sin(H)*R),h.stroke(),h.globalAlpha=1}b.forEach((X,U)=>{const J=U/Math.max(b.length,1)*Math.PI*2-Math.PI/2,$=X.lastReadMs===null?1:Math.min(1,(z-X.lastReadMs)/12e4),V=R*(.42+$*.5),Z=G+Math.cos(J)*V,D=Y+Math.sin(J)*V,L=Math.abs((H-J+Math.PI*3)%(Math.PI*2)-Math.PI),K=_?Math.max(0,1-L/.55):0;h.beginPath(),h.arc(Z,D,3+K*1.6,0,Math.PI*2),h.fillStyle=X.running?E:j,h.globalAlpha=X.running?.55+K*.45:.35,h.fill(),h.globalAlpha=1});for(const X of k){const U=(z-X.atMs)/K5;if(U<0||U>1)continue;const $=Math.max(0,b.findIndex(D=>D.key===X.browser))/Math.max(b.length,1)*Math.PI*2-Math.PI/2,V=G+Math.cos($)*R*.6,Z=Y+Math.sin($)*R*.6;h.beginPath(),h.arc(V,Z,4+U*22,0,Math.PI*2),h.strokeStyle=E,h.globalAlpha=(1-U)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(v)};return v(),()=>{g=!0,cancelAnimationFrame(f)}},[i,s]),d.jsx("canvas",{ref:a,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const K1="agent-dag.browserWatch.seenMs";function Q5(e,t){return e.filter(n=>n.startMs>t)}function Z5(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function J5(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 VT(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function X1(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 eF(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,i)=>s+i.programVisits,0)}))}function tF(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 nF(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],i=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(i>0?`, and ${i} more`:"")+". The watch continues on the profiles it can read."}}const n=VT(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 rF(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 sF(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function Q1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function oF({onClose:e,onSeen:t,onWatching:n,palette:s}){const i=_n(e),[a,l]=S.useState(null),[u,h]=S.useState(null),[p,f]=S.useState(!1),g=S.useRef(!1),[v,w]=S.useState(null),[N,b]=S.useState(null),[k,_]=S.useState(!1),[E,C]=S.useState(!1),[j,I]=S.useState(!1),[O,P]=S.useState(!1),[z,M]=S.useState(!1),[A,q]=S.useState(!1),[G,Y]=S.useState(()=>Date.now());S.useEffect(()=>{const Z=setInterval(()=>Y(Date.now()),1e3);return()=>clearInterval(Z)},[]);const R=S.useCallback(async Z=>{var D;if(!(Z&&!ar(g.current))){g.current=Z,f(!0);try{const L=await fetch(`/api/browser-watch${Z?"?refresh=1":""}`);if(!L.ok)throw new Error(`the deck answered ${L.status}`);const K=await L.json();l(K),w(se=>{var he;return se===null?((he=K==null?void 0:K.settings)==null?void 0:he.quietMinutes)??15:se}),n(((D=K==null?void 0:K.settings)==null?void 0:D.enabled)===!0),h(null)}catch(L){h(L instanceof Error?L.message:String(L))}finally{g.current=!1,f(!1)}}},[n]);S.useEffect(()=>{R(!1)},[R]),S.useEffect(()=>{const Z=setInterval(()=>{R(!1)},1e4);return()=>clearInterval(Z)},[R]);const Q=S.useCallback(async Z=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:Z.host,startMs:Z.startMs})})}finally{await R(!1)}},[R]),H=S.useCallback(async Z=>{_(!0);try{const D=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Z)});if(!D.ok)throw new Error(`the deck answered ${D.status}`);await R(!1)}catch(D){h(D instanceof Error?D.message:String(D))}finally{_(!1)}},[R]);S.useEffect(()=>()=>t(Date.now()),[t]);const ne=S.useMemo(()=>{const Z=[];for(const D of(a==null?void 0:a.episodes)??[]){const L=sF(D.startMs),K=Z[Z.length-1];K&&K.label===L?K.episodes.push(D):Z.push({label:L,episodes:[D]})}return Z},[a]),X=VT(a==null?void 0:a.browsers),U=((a==null?void 0:a.browsers)??[]).filter(Z=>!(Z.installed&&Z.profiles>0)),J=a?nF(a):null,$=X.reduce((Z,D)=>Z+D.profiles,0),V=a?Z5(a.coverage.lastHumanMs,a.coverage.quietMs,G):null;return d.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:d.jsxs("div",{ref:i,className:"modal bw-modal",onClick:Z=>Z.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[d.jsxs("header",{className:"modal-head",children:[d.jsxs("div",{className:"modal-title",children:[d.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),d.jsx("span",{className:"modal-tool-id",children:a?`${$} ${$===1?"profile":"profiles"} · local only`:"local only"})]}),d.jsxs("div",{className:"modal-actions",children:[d.jsx("button",{className:"glyph-btn",onClick:()=>void R(!0),...ir(p),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:p?"…":"↻"}),d.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),d.jsxs("div",{className:"modal-body bw-body",children:[!a&&!u&&d.jsxs("div",{className:"bw-loading",children:[d.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),d.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),u&&d.jsx("div",{className:"bw-state",children:d.jsxs("div",{className:"bw-row err",children:[d.jsx("span",{className:"bw-dot","aria-hidden":!0}),d.jsx("span",{className:"bw-row-label",children:"Could not read"}),d.jsx("span",{className:"bw-row-detail",children:u})]})}),a&&J&&d.jsx("p",{className:`bw-trouble ${J.kind}`,role:"status",children:J.text}),a&&d.jsxs("div",{className:"bw-work",children:[d.jsxs("aside",{className:"bw-side",children:[d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",d.jsx("button",{className:"bw-help",onClick:()=>P(Z=>!Z),"aria-expanded":O,"aria-label":"What the sweep and the dots mean",children:"?"})]}),d.jsxs("div",{className:"bw-glance",children:[d.jsx(X5,{browsers:X.map(Z=>{var D;return{key:Z.key,name:Z.name,running:Z.running,lastReadMs:((D=a.profiles.find(L=>L.browser===Z.key))==null?void 0:D.lastWrittenMs)??null}}),findings:a.episodes.slice(0,6).map(Z=>({browser:Z.browser??null,atMs:Z.endMs})),watching:a.settings.enabled,palette:s}),d.jsx("ul",{className:"bw-counts",children:eF(X,a.profiles).map(Z=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-count-n",children:Z.visits.toLocaleString("en-US")}),d.jsx("span",{className:"bw-count-of",children:Z.name})]},Z.key))})]}),d.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),a.coverage.checkedMs>0&&d.jsxs("p",{className:"bw-since",children:["Last checked ",tF(a.coverage.checkedMs,G),a.coverage.checks>0&&d.jsxs(d.Fragment,{children:[" · ",a.coverage.checks.toLocaleString("en-US")," ",a.coverage.checks===1?"check":"checks"]})]}),V!==null&&d.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",J5(V)]}),O&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Sweep"}),d.jsx("dd",{children:"one poll of every watched profile"}),d.jsx("dt",{children:"Dot"}),d.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),d.jsx("dt",{children:"Ring"}),d.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),d.jsxs("section",{className:"bw-sec",children:[d.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",d.jsx("button",{className:"bw-help",onClick:()=>M(Z=>!Z),"aria-expanded":z,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),z&&d.jsxs("dl",{className:"bw-key",children:[d.jsx("dt",{children:"Running"}),d.jsx("dd",{children:"the browser has a process on this machine right now"}),d.jsx("dt",{children:"Connected"}),d.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"})]}),d.jsx("ul",{className:"bw-profiles",children:X.map(Z=>d.jsxs("li",{children:[d.jsx("span",{className:`bw-prof-dot${Z.running?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-prof-name",children:Z.name}),d.jsx("span",{className:"bw-prof-state",children:Z.running?"running":"idle"}),Z.running&&Z.relay.state==="live"&&d.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},Z.key))}),U.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>q(Z=>!Z),"aria-expanded":A,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:A?"▾":"▸"})," ",U.length," not watched"]}),A&&d.jsxs("p",{className:"bw-rest",children:[U.map(Z=>Z.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})]}),d.jsxs("div",{className:"bw-main",children:[d.jsxs("section",{className:"bw-findings",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",a.episodes.length>0&&d.jsxs("span",{className:"bw-feed-count",children:[a.episodes.length," ",a.episodes.length===1?"episode":"episodes"]})]}),d.jsx("div",{className:"bw-eps",children:ne.length===0?d.jsxs("div",{className:"bw-empty",children:[d.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),d.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",a.settings.quietMinutes," ",a.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."]}),!a.settings.enabled&&d.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."})]}):ne.map(Z=>d.jsxs("div",{className:"bw-day",children:[d.jsx("h4",{className:"bw-sec-head",children:Z.label}),Z.episodes.map(D=>{const L=`${D.host}-${D.startMs}`,K=N===L;return d.jsxs("div",{className:`bw-ep${K?" open":""}`,children:[d.jsxs("div",{className:"bw-ep-row",children:[d.jsxs("button",{className:"bw-ep-head",onClick:()=>b(K?null:L),"aria-expanded":K,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:K?"▾":"▸"}),d.jsx("span",{className:"bw-ep-host",children:D.host}),d.jsxs("span",{className:"bw-ep-meta",children:[rF(D),Q1(D)&&d.jsxs(d.Fragment,{children:[" · ",Q1(D)]})]}),d.jsxs("span",{className:"bw-ep-count",children:[D.count," ",D.count===1?"page":"pages"]})]}),d.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Q(D),"aria-label":`Dismiss ${D.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),K&&d.jsx("ul",{className:"bw-urls",children:D.urls.map((se,he)=>d.jsxs("li",{children:[d.jsx("span",{className:"bw-url-time",children:new Date(se.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),d.jsx("span",{className:"bw-url",children:se.url})]},`${se.url}-${se.timeMs}-${he}`))})]},L)})]},Z.label))})]}),d.jsxs("section",{className:"bw-feed",children:[d.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",d.jsxs("span",{className:"bw-feed-count",children:[a.log.length," ",a.log.length===1?"event":"events"]})]}),d.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."}),d.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:a.log.length===0?d.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):a.log.map(Z=>d.jsxs("div",{className:`bw-log-line ${Z.level}${Z.parts?"":" sys"}`,children:[d.jsx("span",{className:"bw-log-time",children:new Date(Z.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),Z.parts?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"bw-log-browser",children:Z.parts.browser}),d.jsx("span",{className:"bw-log-profile",title:Z.parts.profile,children:Z.parts.profile}),d.jsxs("span",{className:"bw-log-value",children:[Z.parts.value,Z.parts.flagged>0&&d.jsxs("span",{className:"bw-log-flag",children:[" · ",Z.parts.flagged," flagged"]})]})]}):d.jsx("span",{className:"bw-log-sys",children:Z.text})]},`${Z.atMs}-${Z.level}-${Z.text}`))})]})]})]}),a&&E&&d.jsxs("div",{className:"bw-settings",children:[d.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:[d.jsx("span",{children:"Nobody browsing for"}),d.jsxs("select",{value:v??a.settings.quietMinutes,onChange:Z=>{w(Number(Z.target.value)),H({quietMinutes:Number(Z.target.value)})},children:[d.jsx("option",{value:1,children:"1 min"}),d.jsx("option",{value:5,children:"5 min"}),d.jsx("option",{value:15,children:"15 min"}),d.jsx("option",{value:30,children:"30 min"}),d.jsx("option",{value:60,children:"60 min"})]})]}),d.jsxs("label",{children:[d.jsx("span",{children:"When it finds one"}),d.jsx("select",{value:a.settings.reaction,onChange:Z=>void H({reaction:Z.target.value}),disabled:!a.settings.enabled,title:a.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(a.reactions??["notify"]).map(Z=>d.jsx("option",{value:Z,children:Z==="notify"?"notify me":Z==="close-tab"?"close the tab":"quit the browser"},Z))})]}),d.jsxs("div",{className:"bw-settings-note",children:[d.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. ",d.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),d.jsxs("button",{className:"bw-why",onClick:()=>I(Z=>!Z),"aria-expanded":j,children:[d.jsx("span",{className:"bw-chev","aria-hidden":!0,children:j?"▾":"▸"})," What Browser Watch can access"]}),j&&d.jsxs("dl",{className:"bw-access",children:[d.jsx("dt",{children:"Reads"}),d.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(a.coverage.startedMs).toLocaleString(),"."]}),d.jsx("dt",{children:"Keeps"}),d.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",d.jsx("code",{className:"bw-path",children:a.coverage.logPath}),", with every address written in full so you can check it yourself."]}),d.jsx("dt",{children:"Sends"}),d.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."}),d.jsx("dt",{children:"Never reads"}),d.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),a&&d.jsxs("footer",{className:"bw-status",children:[d.jsx("span",{className:`bw-mode-dot${a.settings.enabled?" on":""}`,"aria-hidden":!0}),d.jsx("span",{className:"bw-mode-word",children:X1(a,k).word},X1(a,k).kind),d.jsx("span",{className:"bw-status-text",children:a.coverage.archived===0?a.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${a.coverage.archived} ${a.coverage.archived===1?"episode":"episodes"} on disk`}),d.jsx("button",{className:`glyph-btn bw-gear${E?" on":""}`,onClick:()=>C(Z=>!Z),"aria-expanded":E,"aria-label":"Settings",title:"Settings",children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[d.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),d.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"})]})}),d.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[d.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),d.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":a.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void H({enabled:!a.settings.enabled}),title:a.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:d.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function zw(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 ih,Z1;function iF(){if(Z1)return ih;Z1=1;function e(){this.__data__=[],this.size=0}return ih=e,ih}var ah,J1;function Qi(){if(J1)return ah;J1=1;function e(t,n){return t===n||t!==t&&n!==n}return ah=e,ah}var lh,ek;function Vu(){if(ek)return lh;ek=1;var e=Qi();function t(n,s){for(var i=n.length;i--;)if(e(n[i][0],s))return i;return-1}return lh=t,lh}var ch,tk;function aF(){if(tk)return ch;tk=1;var e=Vu(),t=Array.prototype,n=t.splice;function s(i){var a=this.__data__,l=e(a,i);if(l<0)return!1;var u=a.length-1;return l==u?a.pop():n.call(a,l,1),--this.size,!0}return ch=s,ch}var uh,nk;function lF(){if(nk)return uh;nk=1;var e=Vu();function t(n){var s=this.__data__,i=e(s,n);return i<0?void 0:s[i][1]}return uh=t,uh}var dh,rk;function cF(){if(rk)return dh;rk=1;var e=Vu();function t(n){return e(this.__data__,n)>-1}return dh=t,dh}var fh,sk;function uF(){if(sk)return fh;sk=1;var e=Vu();function t(n,s){var i=this.__data__,a=e(i,n);return a<0?(++this.size,i.push([n,s])):i[a][1]=s,this}return fh=t,fh}var hh,ok;function Yu(){if(ok)return hh;ok=1;var e=iF(),t=aF(),n=lF(),s=cF(),i=uF();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=i,hh=a,hh}var ph,ik;function dF(){if(ik)return ph;ik=1;var e=Yu();function t(){this.__data__=new e,this.size=0}return ph=t,ph}var mh,ak;function fF(){if(ak)return mh;ak=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return mh=e,mh}var gh,lk;function hF(){if(lk)return gh;lk=1;function e(t){return this.__data__.get(t)}return gh=e,gh}var yh,ck;function pF(){if(ck)return yh;ck=1;function e(t){return this.__data__.has(t)}return yh=e,yh}var vh,uk;function YT(){if(uk)return vh;uk=1;var e=typeof Vc=="object"&&Vc&&Vc.Object===Object&&Vc;return vh=e,vh}var wh,dk;function dr(){if(dk)return wh;dk=1;var e=YT(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return wh=n,wh}var xh,fk;function Zi(){if(fk)return xh;fk=1;var e=dr(),t=e.Symbol;return xh=t,xh}var bh,hk;function mF(){if(hk)return bh;hk=1;var e=Zi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,i=e?e.toStringTag:void 0;function a(l){var u=n.call(l,i),h=l[i];try{l[i]=void 0;var p=!0}catch{}var f=s.call(l);return p&&(u?l[i]=h:delete l[i]),f}return bh=a,bh}var kh,pk;function gF(){if(pk)return kh;pk=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return kh=n,kh}var _h,mk;function No(){if(mk)return _h;mk=1;var e=Zi(),t=mF(),n=gF(),s="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function l(u){return u==null?u===void 0?i:s:a&&a in Object(u)?t(u):n(u)}return _h=l,_h}var Sh,gk;function qn(){if(gk)return Sh;gk=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Sh=e,Sh}var Nh,yk;function Ol(){if(yk)return Nh;yk=1;var e=No(),t=qn(),n="[object AsyncFunction]",s="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function l(u){if(!t(u))return!1;var h=e(u);return h==s||h==i||h==n||h==a}return Nh=l,Nh}var Eh,vk;function yF(){if(vk)return Eh;vk=1;var e=dr(),t=e["__core-js_shared__"];return Eh=t,Eh}var Ch,wk;function vF(){if(wk)return Ch;wk=1;var e=yF(),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 Ch=n,Ch}var jh,xk;function KT(){if(xk)return jh;xk=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 jh=n,jh}var Th,bk;function wF(){if(bk)return Th;bk=1;var e=Ol(),t=vF(),n=qn(),s=KT(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,h=l.toString,p=u.hasOwnProperty,f=RegExp("^"+h.call(p).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(v){if(!n(v)||t(v))return!1;var w=e(v)?f:a;return w.test(s(v))}return Th=g,Th}var Rh,kk;function xF(){if(kk)return Rh;kk=1;function e(t,n){return t==null?void 0:t[n]}return Rh=e,Rh}var Ah,_k;function Eo(){if(_k)return Ah;_k=1;var e=wF(),t=xF();function n(s,i){var a=t(s,i);return e(a)?a:void 0}return Ah=n,Ah}var Mh,Sk;function Bw(){if(Sk)return Mh;Sk=1;var e=Eo(),t=dr(),n=e(t,"Map");return Mh=n,Mh}var Ih,Nk;function Ku(){if(Nk)return Ih;Nk=1;var e=Eo(),t=e(Object,"create");return Ih=t,Ih}var Oh,Ek;function bF(){if(Ek)return Oh;Ek=1;var e=Ku();function t(){this.__data__=e?e(null):{},this.size=0}return Oh=t,Oh}var Ph,Ck;function kF(){if(Ck)return Ph;Ck=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Ph=e,Ph}var $h,jk;function _F(){if(jk)return $h;jk=1;var e=Ku(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function i(a){var l=this.__data__;if(e){var u=l[a];return u===t?void 0:u}return s.call(l,a)?l[a]:void 0}return $h=i,$h}var Lh,Tk;function SF(){if(Tk)return Lh;Tk=1;var e=Ku(),t=Object.prototype,n=t.hasOwnProperty;function s(i){var a=this.__data__;return e?a[i]!==void 0:n.call(a,i)}return Lh=s,Lh}var qh,Rk;function NF(){if(Rk)return qh;Rk=1;var e=Ku(),t="__lodash_hash_undefined__";function n(s,i){var a=this.__data__;return this.size+=this.has(s)?0:1,a[s]=e&&i===void 0?t:i,this}return qh=n,qh}var Dh,Ak;function EF(){if(Ak)return Dh;Ak=1;var e=bF(),t=kF(),n=_F(),s=SF(),i=NF();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=i,Dh=a,Dh}var Fh,Mk;function CF(){if(Mk)return Fh;Mk=1;var e=EF(),t=Yu(),n=Bw();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Fh=s,Fh}var zh,Ik;function jF(){if(Ik)return zh;Ik=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return zh=e,zh}var Bh,Ok;function Xu(){if(Ok)return Bh;Ok=1;var e=jF();function t(n,s){var i=n.__data__;return e(s)?i[typeof s=="string"?"string":"hash"]:i.map}return Bh=t,Bh}var Uh,Pk;function TF(){if(Pk)return Uh;Pk=1;var e=Xu();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return Uh=t,Uh}var Wh,$k;function RF(){if($k)return Wh;$k=1;var e=Xu();function t(n){return e(this,n).get(n)}return Wh=t,Wh}var Hh,Lk;function AF(){if(Lk)return Hh;Lk=1;var e=Xu();function t(n){return e(this,n).has(n)}return Hh=t,Hh}var Gh,qk;function MF(){if(qk)return Gh;qk=1;var e=Xu();function t(n,s){var i=e(this,n),a=i.size;return i.set(n,s),this.size+=i.size==a?0:1,this}return Gh=t,Gh}var Vh,Dk;function Uw(){if(Dk)return Vh;Dk=1;var e=CF(),t=TF(),n=RF(),s=AF(),i=MF();function a(l){var u=-1,h=l==null?0:l.length;for(this.clear();++u<h;){var p=l[u];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=i,Vh=a,Vh}var Yh,Fk;function IF(){if(Fk)return Yh;Fk=1;var e=Yu(),t=Bw(),n=Uw(),s=200;function i(a,l){var u=this.__data__;if(u instanceof e){var h=u.__data__;if(!t||h.length<s-1)return h.push([a,l]),this.size=++u.size,this;u=this.__data__=new n(h)}return u.set(a,l),this.size=u.size,this}return Yh=i,Yh}var Kh,zk;function Qu(){if(zk)return Kh;zk=1;var e=Yu(),t=dF(),n=fF(),s=hF(),i=pF(),a=IF();function l(u){var h=this.__data__=new e(u);this.size=h.size}return l.prototype.clear=t,l.prototype.delete=n,l.prototype.get=s,l.prototype.has=i,l.prototype.set=a,Kh=l,Kh}var Xh,Bk;function Ww(){if(Bk)return Xh;Bk=1;function e(t,n){for(var s=-1,i=t==null?0:t.length;++s<i&&n(t[s],s,t)!==!1;);return t}return Xh=e,Xh}var Qh,Uk;function XT(){if(Uk)return Qh;Uk=1;var e=Eo(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Qh=t,Qh}var Zh,Wk;function Zu(){if(Wk)return Zh;Wk=1;var e=XT();function t(n,s,i){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:i,writable:!0}):n[s]=i}return Zh=t,Zh}var Jh,Hk;function Ju(){if(Hk)return Jh;Hk=1;var e=Zu(),t=Qi(),n=Object.prototype,s=n.hasOwnProperty;function i(a,l,u){var h=a[l];(!(s.call(a,l)&&t(h,u))||u===void 0&&!(l in a))&&e(a,l,u)}return Jh=i,Jh}var ep,Gk;function Pl(){if(Gk)return ep;Gk=1;var e=Ju(),t=Zu();function n(s,i,a,l){var u=!a;a||(a={});for(var h=-1,p=i.length;++h<p;){var f=i[h],g=l?l(a[f],s[f],f,a,s):void 0;g===void 0&&(g=s[f]),u?t(a,f,g):e(a,f,g)}return a}return ep=n,ep}var tp,Vk;function OF(){if(Vk)return tp;Vk=1;function e(t,n){for(var s=-1,i=Array(t);++s<t;)i[s]=n(s);return i}return tp=e,tp}var np,Yk;function jr(){if(Yk)return np;Yk=1;function e(t){return t!=null&&typeof t=="object"}return np=e,np}var rp,Kk;function PF(){if(Kk)return rp;Kk=1;var e=No(),t=jr(),n="[object Arguments]";function s(i){return t(i)&&e(i)==n}return rp=s,rp}var sp,Xk;function $l(){if(Xk)return sp;Xk=1;var e=PF(),t=jr(),n=Object.prototype,s=n.hasOwnProperty,i=n.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(l){return t(l)&&s.call(l,"callee")&&!i.call(l,"callee")};return sp=a,sp}var op,Qk;function Mt(){if(Qk)return op;Qk=1;var e=Array.isArray;return op=e,op}var ol={exports:{}},ip,Zk;function $F(){if(Zk)return ip;Zk=1;function e(){return!1}return ip=e,ip}ol.exports;var Jk;function Ji(){return Jk||(Jk=1,(function(e,t){var n=dr(),s=$F(),i=t&&!t.nodeType&&t,a=i&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===i,u=l?n.Buffer:void 0,h=u?u.isBuffer:void 0,p=h||s;e.exports=p})(ol,ol.exports)),ol.exports}var ap,e_;function ed(){if(e_)return ap;e_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,i){var a=typeof s;return i=i??e,!!i&&(a=="number"||a!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<i}return ap=n,ap}var lp,t_;function Hw(){if(t_)return lp;t_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return lp=t,lp}var cp,n_;function LF(){if(n_)return cp;n_=1;var e=No(),t=Hw(),n=jr(),s="[object Arguments]",i="[object Array]",a="[object Boolean]",l="[object Date]",u="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",g="[object Object]",v="[object RegExp]",w="[object Set]",N="[object String]",b="[object WeakMap]",k="[object ArrayBuffer]",_="[object DataView]",E="[object Float32Array]",C="[object Float64Array]",j="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",P="[object Uint8Array]",z="[object Uint8ClampedArray]",M="[object Uint16Array]",A="[object Uint32Array]",q={};q[E]=q[C]=q[j]=q[I]=q[O]=q[P]=q[z]=q[M]=q[A]=!0,q[s]=q[i]=q[k]=q[a]=q[_]=q[l]=q[u]=q[h]=q[p]=q[f]=q[g]=q[v]=q[w]=q[N]=q[b]=!1;function G(Y){return n(Y)&&t(Y.length)&&!!q[e(Y)]}return cp=G,cp}var up,r_;function td(){if(r_)return up;r_=1;function e(t){return function(n){return t(n)}}return up=e,up}var il={exports:{}};il.exports;var s_;function Gw(){return s_||(s_=1,(function(e,t){var n=YT(),s=t&&!t.nodeType&&t,i=s&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===s,l=a&&n.process,u=(function(){try{var h=i&&i.require&&i.require("util").types;return h||l&&l.binding&&l.binding("util")}catch{}})();e.exports=u})(il,il.exports)),il.exports}var dp,o_;function Ll(){if(o_)return dp;o_=1;var e=LF(),t=td(),n=Gw(),s=n&&n.isTypedArray,i=s?t(s):e;return dp=i,dp}var fp,i_;function QT(){if(i_)return fp;i_=1;var e=OF(),t=$l(),n=Mt(),s=Ji(),i=ed(),a=Ll(),l=Object.prototype,u=l.hasOwnProperty;function h(p,f){var g=n(p),v=!g&&t(p),w=!g&&!v&&s(p),N=!g&&!v&&!w&&a(p),b=g||v||w||N,k=b?e(p.length,String):[],_=k.length;for(var E in p)(f||u.call(p,E))&&!(b&&(E=="length"||w&&(E=="offset"||E=="parent")||N&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||i(E,_)))&&k.push(E);return k}return fp=h,fp}var hp,a_;function nd(){if(a_)return hp;a_=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,i=typeof s=="function"&&s.prototype||e;return n===i}return hp=t,hp}var pp,l_;function ZT(){if(l_)return pp;l_=1;function e(t,n){return function(s){return t(n(s))}}return pp=e,pp}var mp,c_;function qF(){if(c_)return mp;c_=1;var e=ZT(),t=e(Object.keys,Object);return mp=t,mp}var gp,u_;function Vw(){if(u_)return gp;u_=1;var e=nd(),t=qF(),n=Object.prototype,s=n.hasOwnProperty;function i(a){if(!e(a))return t(a);var l=[];for(var u in Object(a))s.call(a,u)&&u!="constructor"&&l.push(u);return l}return gp=i,gp}var yp,d_;function es(){if(d_)return yp;d_=1;var e=Ol(),t=Hw();function n(s){return s!=null&&t(s.length)&&!e(s)}return yp=n,yp}var vp,f_;function qs(){if(f_)return vp;f_=1;var e=QT(),t=Vw(),n=es();function s(i){return n(i)?e(i):t(i)}return vp=s,vp}var wp,h_;function DF(){if(h_)return wp;h_=1;var e=Pl(),t=qs();function n(s,i){return s&&e(i,t(i),s)}return wp=n,wp}var xp,p_;function FF(){if(p_)return xp;p_=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return xp=e,xp}var bp,m_;function zF(){if(m_)return bp;m_=1;var e=qn(),t=nd(),n=FF(),s=Object.prototype,i=s.hasOwnProperty;function a(l){if(!e(l))return n(l);var u=t(l),h=[];for(var p in l)p=="constructor"&&(u||!i.call(l,p))||h.push(p);return h}return bp=a,bp}var kp,g_;function Co(){if(g_)return kp;g_=1;var e=QT(),t=zF(),n=es();function s(i){return n(i)?e(i,!0):t(i)}return kp=s,kp}var _p,y_;function BF(){if(y_)return _p;y_=1;var e=Pl(),t=Co();function n(s,i){return s&&e(i,t(i),s)}return _p=n,_p}var al={exports:{}};al.exports;var v_;function JT(){return v_||(v_=1,(function(e,t){var n=dr(),s=t&&!t.nodeType&&t,i=s&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===s,l=a?n.Buffer:void 0,u=l?l.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var g=p.length,v=u?u(g):new p.constructor(g);return p.copy(v),v}e.exports=h})(al,al.exports)),al.exports}var Sp,w_;function eR(){if(w_)return Sp;w_=1;function e(t,n){var s=-1,i=t.length;for(n||(n=Array(i));++s<i;)n[s]=t[s];return n}return Sp=e,Sp}var Np,x_;function tR(){if(x_)return Np;x_=1;function e(t,n){for(var s=-1,i=t==null?0:t.length,a=0,l=[];++s<i;){var u=t[s];n(u,s,t)&&(l[a++]=u)}return l}return Np=e,Np}var Ep,b_;function nR(){if(b_)return Ep;b_=1;function e(){return[]}return Ep=e,Ep}var Cp,k_;function Yw(){if(k_)return Cp;k_=1;var e=tR(),t=nR(),n=Object.prototype,s=n.propertyIsEnumerable,i=Object.getOwnPropertySymbols,a=i?function(l){return l==null?[]:(l=Object(l),e(i(l),function(u){return s.call(l,u)}))}:t;return Cp=a,Cp}var jp,__;function UF(){if(__)return jp;__=1;var e=Pl(),t=Yw();function n(s,i){return e(s,t(s),i)}return jp=n,jp}var Tp,S_;function Kw(){if(S_)return Tp;S_=1;function e(t,n){for(var s=-1,i=n.length,a=t.length;++s<i;)t[a+s]=n[s];return t}return Tp=e,Tp}var Rp,N_;function rd(){if(N_)return Rp;N_=1;var e=ZT(),t=e(Object.getPrototypeOf,Object);return Rp=t,Rp}var Ap,E_;function rR(){if(E_)return Ap;E_=1;var e=Kw(),t=rd(),n=Yw(),s=nR(),i=Object.getOwnPropertySymbols,a=i?function(l){for(var u=[];l;)e(u,n(l)),l=t(l);return u}:s;return Ap=a,Ap}var Mp,C_;function WF(){if(C_)return Mp;C_=1;var e=Pl(),t=rR();function n(s,i){return e(s,t(s),i)}return Mp=n,Mp}var Ip,j_;function sR(){if(j_)return Ip;j_=1;var e=Kw(),t=Mt();function n(s,i,a){var l=i(s);return t(s)?l:e(l,a(s))}return Ip=n,Ip}var Op,T_;function oR(){if(T_)return Op;T_=1;var e=sR(),t=Yw(),n=qs();function s(i){return e(i,n,t)}return Op=s,Op}var Pp,R_;function HF(){if(R_)return Pp;R_=1;var e=sR(),t=rR(),n=Co();function s(i){return e(i,n,t)}return Pp=s,Pp}var $p,A_;function GF(){if(A_)return $p;A_=1;var e=Eo(),t=dr(),n=e(t,"DataView");return $p=n,$p}var Lp,M_;function VF(){if(M_)return Lp;M_=1;var e=Eo(),t=dr(),n=e(t,"Promise");return Lp=n,Lp}var qp,I_;function iR(){if(I_)return qp;I_=1;var e=Eo(),t=dr(),n=e(t,"Set");return qp=n,qp}var Dp,O_;function YF(){if(O_)return Dp;O_=1;var e=Eo(),t=dr(),n=e(t,"WeakMap");return Dp=n,Dp}var Fp,P_;function ea(){if(P_)return Fp;P_=1;var e=GF(),t=Bw(),n=VF(),s=iR(),i=YF(),a=No(),l=KT(),u="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",g="[object WeakMap]",v="[object DataView]",w=l(e),N=l(t),b=l(n),k=l(s),_=l(i),E=a;return(e&&E(new e(new ArrayBuffer(1)))!=v||t&&E(new t)!=u||n&&E(n.resolve())!=p||s&&E(new s)!=f||i&&E(new i)!=g)&&(E=function(C){var j=a(C),I=j==h?C.constructor:void 0,O=I?l(I):"";if(O)switch(O){case w:return v;case N:return u;case b:return p;case k:return f;case _:return g}return j}),Fp=E,Fp}var zp,$_;function KF(){if($_)return zp;$_=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var i=s.length,a=new s.constructor(i);return i&&typeof s[0]=="string"&&t.call(s,"index")&&(a.index=s.index,a.input=s.input),a}return zp=n,zp}var Bp,L_;function aR(){if(L_)return Bp;L_=1;var e=dr(),t=e.Uint8Array;return Bp=t,Bp}var Up,q_;function Xw(){if(q_)return Up;q_=1;var e=aR();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return Up=t,Up}var Wp,D_;function XF(){if(D_)return Wp;D_=1;var e=Xw();function t(n,s){var i=s?e(n.buffer):n.buffer;return new n.constructor(i,n.byteOffset,n.byteLength)}return Wp=t,Wp}var Hp,F_;function QF(){if(F_)return Hp;F_=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return Hp=t,Hp}var Gp,z_;function ZF(){if(z_)return Gp;z_=1;var e=Zi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(i){return n?Object(n.call(i)):{}}return Gp=s,Gp}var Vp,B_;function lR(){if(B_)return Vp;B_=1;var e=Xw();function t(n,s){var i=s?e(n.buffer):n.buffer;return new n.constructor(i,n.byteOffset,n.length)}return Vp=t,Vp}var Yp,U_;function JF(){if(U_)return Yp;U_=1;var e=Xw(),t=XF(),n=QF(),s=ZF(),i=lR(),a="[object Boolean]",l="[object Date]",u="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",g="[object String]",v="[object Symbol]",w="[object ArrayBuffer]",N="[object DataView]",b="[object Float32Array]",k="[object Float64Array]",_="[object Int8Array]",E="[object Int16Array]",C="[object Int32Array]",j="[object Uint8Array]",I="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]";function z(M,A,q){var G=M.constructor;switch(A){case w:return e(M);case a:case l:return new G(+M);case N:return t(M,q);case b:case k:case _:case E:case C:case j:case I:case O:case P:return i(M,q);case u:return new G;case h:case g:return new G(M);case p:return n(M);case f:return new G;case v:return s(M)}}return Yp=z,Yp}var Kp,W_;function cR(){if(W_)return Kp;W_=1;var e=qn(),t=Object.create,n=(function(){function s(){}return function(i){if(!e(i))return{};if(t)return t(i);s.prototype=i;var a=new s;return s.prototype=void 0,a}})();return Kp=n,Kp}var Xp,H_;function uR(){if(H_)return Xp;H_=1;var e=cR(),t=rd(),n=nd();function s(i){return typeof i.constructor=="function"&&!n(i)?e(t(i)):{}}return Xp=s,Xp}var Qp,G_;function e6(){if(G_)return Qp;G_=1;var e=ea(),t=jr(),n="[object Map]";function s(i){return t(i)&&e(i)==n}return Qp=s,Qp}var Zp,V_;function t6(){if(V_)return Zp;V_=1;var e=e6(),t=td(),n=Gw(),s=n&&n.isMap,i=s?t(s):e;return Zp=i,Zp}var Jp,Y_;function n6(){if(Y_)return Jp;Y_=1;var e=ea(),t=jr(),n="[object Set]";function s(i){return t(i)&&e(i)==n}return Jp=s,Jp}var em,K_;function r6(){if(K_)return em;K_=1;var e=n6(),t=td(),n=Gw(),s=n&&n.isSet,i=s?t(s):e;return em=i,em}var tm,X_;function dR(){if(X_)return tm;X_=1;var e=Qu(),t=Ww(),n=Ju(),s=DF(),i=BF(),a=JT(),l=eR(),u=UF(),h=WF(),p=oR(),f=HF(),g=ea(),v=KF(),w=JF(),N=uR(),b=Mt(),k=Ji(),_=t6(),E=qn(),C=r6(),j=qs(),I=Co(),O=1,P=2,z=4,M="[object Arguments]",A="[object Array]",q="[object Boolean]",G="[object Date]",Y="[object Error]",R="[object Function]",Q="[object GeneratorFunction]",H="[object Map]",ne="[object Number]",X="[object Object]",U="[object RegExp]",J="[object Set]",$="[object String]",V="[object Symbol]",Z="[object WeakMap]",D="[object ArrayBuffer]",L="[object DataView]",K="[object Float32Array]",se="[object Float64Array]",he="[object Int8Array]",me="[object Int16Array]",xe="[object Int32Array]",Ee="[object Uint8Array]",He="[object Uint8ClampedArray]",Fe="[object Uint16Array]",Ie="[object Uint32Array]",be={};be[M]=be[A]=be[D]=be[L]=be[q]=be[G]=be[K]=be[se]=be[he]=be[me]=be[xe]=be[H]=be[ne]=be[X]=be[U]=be[J]=be[$]=be[V]=be[Ee]=be[He]=be[Fe]=be[Ie]=!0,be[Y]=be[R]=be[Z]=!1;function ue(re,pe,Oe,nt,st,Xe){var Pe,Ue=pe&O,Ge=pe&P,it=pe&z;if(Oe&&(Pe=st?Oe(re,nt,st,Xe):Oe(re)),Pe!==void 0)return Pe;if(!E(re))return re;var ke=b(re);if(ke){if(Pe=v(re),!Ue)return l(re,Pe)}else{var ct=g(re),It=ct==R||ct==Q;if(k(re))return a(re,Ue);if(ct==X||ct==M||It&&!st){if(Pe=Ge||It?{}:N(re),!Ue)return Ge?h(re,i(Pe,re)):u(re,s(Pe,re))}else{if(!be[ct])return st?re:{};Pe=w(re,ct,Ue)}}Xe||(Xe=new e);var ae=Xe.get(re);if(ae)return ae;Xe.set(re,Pe),C(re)?re.forEach(function(Ce){Pe.add(ue(Ce,pe,Oe,Ce,re,Xe))}):_(re)&&re.forEach(function(Ce,Ve){Pe.set(Ve,ue(Ce,pe,Oe,Ve,re,Xe))});var Le=it?Ge?f:p:Ge?I:j,ze=ke?void 0:Le(re);return t(ze||re,function(Ce,Ve){ze&&(Ve=Ce,Ce=re[Ve]),n(Pe,Ve,ue(Ce,pe,Oe,Ve,re,Xe))}),Pe}return tm=ue,tm}var nm,Q_;function s6(){if(Q_)return nm;Q_=1;var e=dR(),t=4;function n(s){return e(s,t)}return nm=n,nm}var rm,Z_;function Qw(){if(Z_)return rm;Z_=1;function e(t){return function(){return t}}return rm=e,rm}var sm,J_;function o6(){if(J_)return sm;J_=1;function e(t){return function(n,s,i){for(var a=-1,l=Object(n),u=i(n),h=u.length;h--;){var p=u[t?h:++a];if(s(l[p],p,l)===!1)break}return n}}return sm=e,sm}var om,eS;function Zw(){if(eS)return om;eS=1;var e=o6(),t=e();return om=t,om}var im,tS;function Jw(){if(tS)return im;tS=1;var e=Zw(),t=qs();function n(s,i){return s&&e(s,i,t)}return im=n,im}var am,nS;function i6(){if(nS)return am;nS=1;var e=es();function t(n,s){return function(i,a){if(i==null)return i;if(!e(i))return n(i,a);for(var l=i.length,u=s?l:-1,h=Object(i);(s?u--:++u<l)&&a(h[u],u,h)!==!1;);return i}}return am=t,am}var lm,rS;function sd(){if(rS)return lm;rS=1;var e=Jw(),t=i6(),n=t(e);return lm=n,lm}var cm,sS;function jo(){if(sS)return cm;sS=1;function e(t){return t}return cm=e,cm}var um,oS;function fR(){if(oS)return um;oS=1;var e=jo();function t(n){return typeof n=="function"?n:e}return um=t,um}var dm,iS;function hR(){if(iS)return dm;iS=1;var e=Ww(),t=sd(),n=fR(),s=Mt();function i(a,l){var u=s(a)?e:t;return u(a,n(l))}return dm=i,dm}var fm,aS;function pR(){return aS||(aS=1,fm=hR()),fm}var hm,lS;function a6(){if(lS)return hm;lS=1;var e=sd();function t(n,s){var i=[];return e(n,function(a,l,u){s(a,l,u)&&i.push(a)}),i}return hm=t,hm}var pm,cS;function l6(){if(cS)return pm;cS=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return pm=t,pm}var mm,uS;function c6(){if(uS)return mm;uS=1;function e(t){return this.__data__.has(t)}return mm=e,mm}var gm,dS;function mR(){if(dS)return gm;dS=1;var e=Uw(),t=l6(),n=c6();function s(i){var a=-1,l=i==null?0:i.length;for(this.__data__=new e;++a<l;)this.add(i[a])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,gm=s,gm}var ym,fS;function u6(){if(fS)return ym;fS=1;function e(t,n){for(var s=-1,i=t==null?0:t.length;++s<i;)if(n(t[s],s,t))return!0;return!1}return ym=e,ym}var vm,hS;function gR(){if(hS)return vm;hS=1;function e(t,n){return t.has(n)}return vm=e,vm}var wm,pS;function yR(){if(pS)return wm;pS=1;var e=mR(),t=u6(),n=gR(),s=1,i=2;function a(l,u,h,p,f,g){var v=h&s,w=l.length,N=u.length;if(w!=N&&!(v&&N>w))return!1;var b=g.get(l),k=g.get(u);if(b&&k)return b==u&&k==l;var _=-1,E=!0,C=h&i?new e:void 0;for(g.set(l,u),g.set(u,l);++_<w;){var j=l[_],I=u[_];if(p)var O=v?p(I,j,_,u,l,g):p(j,I,_,l,u,g);if(O!==void 0){if(O)continue;E=!1;break}if(C){if(!t(u,function(P,z){if(!n(C,z)&&(j===P||f(j,P,h,p,g)))return C.push(z)})){E=!1;break}}else if(!(j===I||f(j,I,h,p,g))){E=!1;break}}return g.delete(l),g.delete(u),E}return wm=a,wm}var xm,mS;function d6(){if(mS)return xm;mS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(i,a){s[++n]=[a,i]}),s}return xm=e,xm}var bm,gS;function e0(){if(gS)return bm;gS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(i){s[++n]=i}),s}return bm=e,bm}var km,yS;function f6(){if(yS)return km;yS=1;var e=Zi(),t=aR(),n=Qi(),s=yR(),i=d6(),a=e0(),l=1,u=2,h="[object Boolean]",p="[object Date]",f="[object Error]",g="[object Map]",v="[object Number]",w="[object RegExp]",N="[object Set]",b="[object String]",k="[object Symbol]",_="[object ArrayBuffer]",E="[object DataView]",C=e?e.prototype:void 0,j=C?C.valueOf:void 0;function I(O,P,z,M,A,q,G){switch(z){case E:if(O.byteLength!=P.byteLength||O.byteOffset!=P.byteOffset)return!1;O=O.buffer,P=P.buffer;case _:return!(O.byteLength!=P.byteLength||!q(new t(O),new t(P)));case h:case p:case v:return n(+O,+P);case f:return O.name==P.name&&O.message==P.message;case w:case b:return O==P+"";case g:var Y=i;case N:var R=M&l;if(Y||(Y=a),O.size!=P.size&&!R)return!1;var Q=G.get(O);if(Q)return Q==P;M|=u,G.set(O,P);var H=s(Y(O),Y(P),M,A,q,G);return G.delete(O),H;case k:if(j)return j.call(O)==j.call(P)}return!1}return km=I,km}var _m,vS;function h6(){if(vS)return _m;vS=1;var e=oR(),t=1,n=Object.prototype,s=n.hasOwnProperty;function i(a,l,u,h,p,f){var g=u&t,v=e(a),w=v.length,N=e(l),b=N.length;if(w!=b&&!g)return!1;for(var k=w;k--;){var _=v[k];if(!(g?_ in l:s.call(l,_)))return!1}var E=f.get(a),C=f.get(l);if(E&&C)return E==l&&C==a;var j=!0;f.set(a,l),f.set(l,a);for(var I=g;++k<w;){_=v[k];var O=a[_],P=l[_];if(h)var z=g?h(P,O,_,l,a,f):h(O,P,_,a,l,f);if(!(z===void 0?O===P||p(O,P,u,h,f):z)){j=!1;break}I||(I=_=="constructor")}if(j&&!I){var M=a.constructor,A=l.constructor;M!=A&&"constructor"in a&&"constructor"in l&&!(typeof M=="function"&&M instanceof M&&typeof A=="function"&&A instanceof A)&&(j=!1)}return f.delete(a),f.delete(l),j}return _m=i,_m}var Sm,wS;function p6(){if(wS)return Sm;wS=1;var e=Qu(),t=yR(),n=f6(),s=h6(),i=ea(),a=Mt(),l=Ji(),u=Ll(),h=1,p="[object Arguments]",f="[object Array]",g="[object Object]",v=Object.prototype,w=v.hasOwnProperty;function N(b,k,_,E,C,j){var I=a(b),O=a(k),P=I?f:i(b),z=O?f:i(k);P=P==p?g:P,z=z==p?g:z;var M=P==g,A=z==g,q=P==z;if(q&&l(b)){if(!l(k))return!1;I=!0,M=!1}if(q&&!M)return j||(j=new e),I||u(b)?t(b,k,_,E,C,j):n(b,k,P,_,E,C,j);if(!(_&h)){var G=M&&w.call(b,"__wrapped__"),Y=A&&w.call(k,"__wrapped__");if(G||Y){var R=G?b.value():b,Q=Y?k.value():k;return j||(j=new e),C(R,Q,_,E,j)}}return q?(j||(j=new e),s(b,k,_,E,C,j)):!1}return Sm=N,Sm}var Nm,xS;function vR(){if(xS)return Nm;xS=1;var e=p6(),t=jr();function n(s,i,a,l,u){return s===i?!0:s==null||i==null||!t(s)&&!t(i)?s!==s&&i!==i:e(s,i,a,l,n,u)}return Nm=n,Nm}var Em,bS;function m6(){if(bS)return Em;bS=1;var e=Qu(),t=vR(),n=1,s=2;function i(a,l,u,h){var p=u.length,f=p,g=!h;if(a==null)return!f;for(a=Object(a);p--;){var v=u[p];if(g&&v[2]?v[1]!==a[v[0]]:!(v[0]in a))return!1}for(;++p<f;){v=u[p];var w=v[0],N=a[w],b=v[1];if(g&&v[2]){if(N===void 0&&!(w in a))return!1}else{var k=new e;if(h)var _=h(N,b,w,a,l,k);if(!(_===void 0?t(b,N,n|s,h,k):_))return!1}}return!0}return Em=i,Em}var Cm,kS;function wR(){if(kS)return Cm;kS=1;var e=qn();function t(n){return n===n&&!e(n)}return Cm=t,Cm}var jm,_S;function g6(){if(_S)return jm;_S=1;var e=wR(),t=qs();function n(s){for(var i=t(s),a=i.length;a--;){var l=i[a],u=s[l];i[a]=[l,u,e(u)]}return i}return jm=n,jm}var Tm,SS;function xR(){if(SS)return Tm;SS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return Tm=e,Tm}var Rm,NS;function y6(){if(NS)return Rm;NS=1;var e=m6(),t=g6(),n=xR();function s(i){var a=t(i);return a.length==1&&a[0][2]?n(a[0][0],a[0][1]):function(l){return l===i||e(l,i,a)}}return Rm=s,Rm}var Am,ES;function ta(){if(ES)return Am;ES=1;var e=No(),t=jr(),n="[object Symbol]";function s(i){return typeof i=="symbol"||t(i)&&e(i)==n}return Am=s,Am}var Mm,CS;function t0(){if(CS)return Mm;CS=1;var e=Mt(),t=ta(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function i(a,l){if(e(a))return!1;var u=typeof a;return u=="number"||u=="symbol"||u=="boolean"||a==null||t(a)?!0:s.test(a)||!n.test(a)||l!=null&&a in Object(l)}return Mm=i,Mm}var Im,jS;function v6(){if(jS)return Im;jS=1;var e=Uw(),t="Expected a function";function n(s,i){if(typeof s!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var l=arguments,u=i?i.apply(this,l):l[0],h=a.cache;if(h.has(u))return h.get(u);var p=s.apply(this,l);return a.cache=h.set(u,p)||h,p};return a.cache=new(n.Cache||e),a}return n.Cache=e,Im=n,Im}var Om,TS;function w6(){if(TS)return Om;TS=1;var e=v6(),t=500;function n(s){var i=e(s,function(l){return a.size===t&&a.clear(),l}),a=i.cache;return i}return Om=n,Om}var Pm,RS;function x6(){if(RS)return Pm;RS=1;var e=w6(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(l,u,h,p){a.push(h?p.replace(n,"$1"):u||l)}),a});return Pm=s,Pm}var $m,AS;function od(){if(AS)return $m;AS=1;function e(t,n){for(var s=-1,i=t==null?0:t.length,a=Array(i);++s<i;)a[s]=n(t[s],s,t);return a}return $m=e,$m}var Lm,MS;function b6(){if(MS)return Lm;MS=1;var e=Zi(),t=od(),n=Mt(),s=ta(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function l(u){if(typeof u=="string")return u;if(n(u))return t(u,l)+"";if(s(u))return a?a.call(u):"";var h=u+"";return h=="0"&&1/u==-1/0?"-0":h}return Lm=l,Lm}var qm,IS;function bR(){if(IS)return qm;IS=1;var e=b6();function t(n){return n==null?"":e(n)}return qm=t,qm}var Dm,OS;function id(){if(OS)return Dm;OS=1;var e=Mt(),t=t0(),n=x6(),s=bR();function i(a,l){return e(a)?a:t(a,l)?[a]:n(s(a))}return Dm=i,Dm}var Fm,PS;function ql(){if(PS)return Fm;PS=1;var e=ta();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return Fm=t,Fm}var zm,$S;function ad(){if($S)return zm;$S=1;var e=id(),t=ql();function n(s,i){i=e(i,s);for(var a=0,l=i.length;s!=null&&a<l;)s=s[t(i[a++])];return a&&a==l?s:void 0}return zm=n,zm}var Bm,LS;function k6(){if(LS)return Bm;LS=1;var e=ad();function t(n,s,i){var a=n==null?void 0:e(n,s);return a===void 0?i:a}return Bm=t,Bm}var Um,qS;function _6(){if(qS)return Um;qS=1;function e(t,n){return t!=null&&n in Object(t)}return Um=e,Um}var Wm,DS;function kR(){if(DS)return Wm;DS=1;var e=id(),t=$l(),n=Mt(),s=ed(),i=Hw(),a=ql();function l(u,h,p){h=e(h,u);for(var f=-1,g=h.length,v=!1;++f<g;){var w=a(h[f]);if(!(v=u!=null&&p(u,w)))break;u=u[w]}return v||++f!=g?v:(g=u==null?0:u.length,!!g&&i(g)&&s(w,g)&&(n(u)||t(u)))}return Wm=l,Wm}var Hm,FS;function _R(){if(FS)return Hm;FS=1;var e=_6(),t=kR();function n(s,i){return s!=null&&t(s,i,e)}return Hm=n,Hm}var Gm,zS;function S6(){if(zS)return Gm;zS=1;var e=vR(),t=k6(),n=_R(),s=t0(),i=wR(),a=xR(),l=ql(),u=1,h=2;function p(f,g){return s(f)&&i(g)?a(l(f),g):function(v){var w=t(v,f);return w===void 0&&w===g?n(v,f):e(g,w,u|h)}}return Gm=p,Gm}var Vm,BS;function SR(){if(BS)return Vm;BS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Vm=e,Vm}var Ym,US;function N6(){if(US)return Ym;US=1;var e=ad();function t(n){return function(s){return e(s,n)}}return Ym=t,Ym}var Km,WS;function E6(){if(WS)return Km;WS=1;var e=SR(),t=N6(),n=t0(),s=ql();function i(a){return n(a)?e(s(a)):t(a)}return Km=i,Km}var Xm,HS;function ts(){if(HS)return Xm;HS=1;var e=y6(),t=S6(),n=jo(),s=Mt(),i=E6();function a(l){return typeof l=="function"?l:l==null?n:typeof l=="object"?s(l)?t(l[0],l[1]):e(l):i(l)}return Xm=a,Xm}var Qm,GS;function NR(){if(GS)return Qm;GS=1;var e=tR(),t=a6(),n=ts(),s=Mt();function i(a,l){var u=s(a)?e:t;return u(a,n(l,3))}return Qm=i,Qm}var Zm,VS;function C6(){if(VS)return Zm;VS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,i){return s!=null&&t.call(s,i)}return Zm=n,Zm}var Jm,YS;function ER(){if(YS)return Jm;YS=1;var e=C6(),t=kR();function n(s,i){return s!=null&&t(s,i,e)}return Jm=n,Jm}var eg,KS;function j6(){if(KS)return eg;KS=1;var e=Vw(),t=ea(),n=$l(),s=Mt(),i=es(),a=Ji(),l=nd(),u=Ll(),h="[object Map]",p="[object Set]",f=Object.prototype,g=f.hasOwnProperty;function v(w){if(w==null)return!0;if(i(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||a(w)||u(w)||n(w)))return!w.length;var N=t(w);if(N==h||N==p)return!w.size;if(l(w))return!e(w).length;for(var b in w)if(g.call(w,b))return!1;return!0}return eg=v,eg}var tg,XS;function CR(){if(XS)return tg;XS=1;function e(t){return t===void 0}return tg=e,tg}var ng,QS;function jR(){if(QS)return ng;QS=1;var e=sd(),t=es();function n(s,i){var a=-1,l=t(s)?Array(s.length):[];return e(s,function(u,h,p){l[++a]=i(u,h,p)}),l}return ng=n,ng}var rg,ZS;function TR(){if(ZS)return rg;ZS=1;var e=od(),t=ts(),n=jR(),s=Mt();function i(a,l){var u=s(a)?e:n;return u(a,t(l,3))}return rg=i,rg}var sg,JS;function T6(){if(JS)return sg;JS=1;function e(t,n,s,i){var a=-1,l=t==null?0:t.length;for(i&&l&&(s=t[++a]);++a<l;)s=n(s,t[a],a,t);return s}return sg=e,sg}var og,eN;function R6(){if(eN)return og;eN=1;function e(t,n,s,i,a){return a(t,function(l,u,h){s=i?(i=!1,l):n(s,l,u,h)}),s}return og=e,og}var ig,tN;function RR(){if(tN)return ig;tN=1;var e=T6(),t=sd(),n=ts(),s=R6(),i=Mt();function a(l,u,h){var p=i(l)?e:s,f=arguments.length<3;return p(l,n(u,4),h,f,t)}return ig=a,ig}var ag,nN;function A6(){if(nN)return ag;nN=1;var e=No(),t=Mt(),n=jr(),s="[object String]";function i(a){return typeof a=="string"||!t(a)&&n(a)&&e(a)==s}return ag=i,ag}var lg,rN;function M6(){if(rN)return lg;rN=1;var e=SR(),t=e("length");return lg=t,lg}var cg,sN;function I6(){if(sN)return cg;sN=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",i=t+n+s,a="\\ufe0e\\ufe0f",l="\\u200d",u=RegExp("["+l+e+i+a+"]");function h(p){return u.test(p)}return cg=h,cg}var ug,oN;function O6(){if(oN)return ug;oN=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",i=t+n+s,a="\\ufe0e\\ufe0f",l="["+e+"]",u="["+i+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+h+")",f="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",v="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",N=p+"?",b="["+a+"]?",k="(?:"+w+"(?:"+[f,g,v].join("|")+")"+b+N+")*",_=b+N+k,E="(?:"+[f+u+"?",u,g,v,l].join("|")+")",C=RegExp(h+"(?="+h+")|"+E+_,"g");function j(I){for(var O=C.lastIndex=0;C.test(I);)++O;return O}return ug=j,ug}var dg,iN;function P6(){if(iN)return dg;iN=1;var e=M6(),t=I6(),n=O6();function s(i){return t(i)?n(i):e(i)}return dg=s,dg}var fg,aN;function $6(){if(aN)return fg;aN=1;var e=Vw(),t=ea(),n=es(),s=A6(),i=P6(),a="[object Map]",l="[object Set]";function u(h){if(h==null)return 0;if(n(h))return s(h)?i(h):h.length;var p=t(h);return p==a||p==l?h.size:e(h).length}return fg=u,fg}var hg,lN;function L6(){if(lN)return hg;lN=1;var e=Ww(),t=cR(),n=Jw(),s=ts(),i=rd(),a=Mt(),l=Ji(),u=Ol(),h=qn(),p=Ll();function f(g,v,w){var N=a(g),b=N||l(g)||p(g);if(v=s(v,4),w==null){var k=g&&g.constructor;b?w=N?new k:[]:h(g)?w=u(k)?t(i(g)):{}:w={}}return(b?e:n)(g,function(_,E,C){return v(w,_,E,C)}),w}return hg=f,hg}var pg,cN;function q6(){if(cN)return pg;cN=1;var e=Zi(),t=$l(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function i(a){return n(a)||t(a)||!!(s&&a&&a[s])}return pg=i,pg}var mg,uN;function n0(){if(uN)return mg;uN=1;var e=Kw(),t=q6();function n(s,i,a,l,u){var h=-1,p=s.length;for(a||(a=t),u||(u=[]);++h<p;){var f=s[h];i>0&&a(f)?i>1?n(f,i-1,a,l,u):e(u,f):l||(u[u.length]=f)}return u}return mg=n,mg}var gg,dN;function D6(){if(dN)return gg;dN=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 gg=e,gg}var yg,fN;function AR(){if(fN)return yg;fN=1;var e=D6(),t=Math.max;function n(s,i,a){return i=t(i===void 0?s.length-1:i,0),function(){for(var l=arguments,u=-1,h=t(l.length-i,0),p=Array(h);++u<h;)p[u]=l[i+u];u=-1;for(var f=Array(i+1);++u<i;)f[u]=l[u];return f[i]=a(p),e(s,this,f)}}return yg=n,yg}var vg,hN;function F6(){if(hN)return vg;hN=1;var e=Qw(),t=XT(),n=jo(),s=t?function(i,a){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:n;return vg=s,vg}var wg,pN;function z6(){if(pN)return wg;pN=1;var e=800,t=16,n=Date.now;function s(i){var a=0,l=0;return function(){var u=n(),h=t-(u-l);if(l=u,h>0){if(++a>=e)return arguments[0]}else a=0;return i.apply(void 0,arguments)}}return wg=s,wg}var xg,mN;function MR(){if(mN)return xg;mN=1;var e=F6(),t=z6(),n=t(e);return xg=n,xg}var bg,gN;function ld(){if(gN)return bg;gN=1;var e=jo(),t=AR(),n=MR();function s(i,a){return n(t(i,a,e),i+"")}return bg=s,bg}var kg,yN;function IR(){if(yN)return kg;yN=1;function e(t,n,s,i){for(var a=t.length,l=s+(i?1:-1);i?l--:++l<a;)if(n(t[l],l,t))return l;return-1}return kg=e,kg}var _g,vN;function B6(){if(vN)return _g;vN=1;function e(t){return t!==t}return _g=e,_g}var Sg,wN;function U6(){if(wN)return Sg;wN=1;function e(t,n,s){for(var i=s-1,a=t.length;++i<a;)if(t[i]===n)return i;return-1}return Sg=e,Sg}var Ng,xN;function W6(){if(xN)return Ng;xN=1;var e=IR(),t=B6(),n=U6();function s(i,a,l){return a===a?n(i,a,l):e(i,t,l)}return Ng=s,Ng}var Eg,bN;function H6(){if(bN)return Eg;bN=1;var e=W6();function t(n,s){var i=n==null?0:n.length;return!!i&&e(n,s,0)>-1}return Eg=t,Eg}var Cg,kN;function G6(){if(kN)return Cg;kN=1;function e(t,n,s){for(var i=-1,a=t==null?0:t.length;++i<a;)if(s(n,t[i]))return!0;return!1}return Cg=e,Cg}var jg,_N;function V6(){if(_N)return jg;_N=1;function e(){}return jg=e,jg}var Tg,SN;function Y6(){if(SN)return Tg;SN=1;var e=iR(),t=V6(),n=e0(),s=1/0,i=e&&1/n(new e([,-0]))[1]==s?function(a){return new e(a)}:t;return Tg=i,Tg}var Rg,NN;function K6(){if(NN)return Rg;NN=1;var e=mR(),t=H6(),n=G6(),s=gR(),i=Y6(),a=e0(),l=200;function u(h,p,f){var g=-1,v=t,w=h.length,N=!0,b=[],k=b;if(f)N=!1,v=n;else if(w>=l){var _=p?null:i(h);if(_)return a(_);N=!1,v=s,k=new e}else k=p?[]:b;e:for(;++g<w;){var E=h[g],C=p?p(E):E;if(E=f||E!==0?E:0,N&&C===C){for(var j=k.length;j--;)if(k[j]===C)continue e;p&&k.push(C),b.push(E)}else v(k,C,f)||(k!==b&&k.push(C),b.push(E))}return b}return Rg=u,Rg}var Ag,EN;function OR(){if(EN)return Ag;EN=1;var e=es(),t=jr();function n(s){return t(s)&&e(s)}return Ag=n,Ag}var Mg,CN;function X6(){if(CN)return Mg;CN=1;var e=n0(),t=ld(),n=K6(),s=OR(),i=t(function(a){return n(e(a,1,s,!0))});return Mg=i,Mg}var Ig,jN;function Q6(){if(jN)return Ig;jN=1;var e=od();function t(n,s){return e(s,function(i){return n[i]})}return Ig=t,Ig}var Og,TN;function PR(){if(TN)return Og;TN=1;var e=Q6(),t=qs();function n(s){return s==null?[]:e(s,t(s))}return Og=n,Og}var Pg,RN;function Dn(){if(RN)return Pg;RN=1;var e;if(typeof zw=="function")try{e={clone:s6(),constant:Qw(),each:pR(),filter:NR(),has:ER(),isArray:Mt(),isEmpty:j6(),isFunction:Ol(),isUndefined:CR(),keys:qs(),map:TR(),reduce:RR(),size:$6(),transform:L6(),union:X6(),values:PR()}}catch{}return e||(e=window._),Pg=e,Pg}var $g,AN;function r0(){if(AN)return $g;AN=1;var e=Dn();$g=i;var t="\0",n="\0",s="";function i(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(f){return this._label=f,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._in[g])})},i.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._out[g])})},i.prototype.setNodes=function(f,g){var v=arguments,w=this;return e.each(f,function(N){v.length>1?w.setNode(N,g):w.setNode(N)}),this},i.prototype.setNode=function(f,g){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=g),this):(this._nodes[f]=arguments.length>1?g:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},i.prototype.node=function(f){return this._nodes[f]},i.prototype.hasNode=function(f){return e.has(this._nodes,f)},i.prototype.removeNode=function(f){var g=this;if(e.has(this._nodes,f)){var v=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(w){g.setParent(w)}),delete this._children[f]),e.each(e.keys(this._in[f]),v),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),v),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},i.prototype.setParent=function(f,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 v=g;!e.isUndefined(v);v=this.parent(v))if(v===f)throw new Error("Setting "+g+" as parent of "+f+" would create a cycle");this.setNode(g)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=g,this._children[g][f]=!0,this},i.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},i.prototype.parent=function(f){if(this._isCompound){var g=this._parent[f];if(g!==n)return g}},i.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var g=this._children[f];if(g)return e.keys(g)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},i.prototype.predecessors=function(f){var g=this._preds[f];if(g)return e.keys(g)},i.prototype.successors=function(f){var g=this._sucs[f];if(g)return e.keys(g)},i.prototype.neighbors=function(f){var g=this.predecessors(f);if(g)return e.union(g,this.successors(f))},i.prototype.isLeaf=function(f){var g;return this.isDirected()?g=this.successors(f):g=this.neighbors(f),g.length===0},i.prototype.filterNodes=function(f){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var v=this;e.each(this._nodes,function(b,k){f(k)&&g.setNode(k,b)}),e.each(this._edgeObjs,function(b){g.hasNode(b.v)&&g.hasNode(b.w)&&g.setEdge(b,v.edge(b))});var w={};function N(b){var k=v.parent(b);return k===void 0||g.hasNode(k)?(w[b]=k,k):k in w?w[k]:N(k)}return this._isCompound&&e.each(g.nodes(),function(b){g.setParent(b,N(b))}),g},i.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(f,g){var v=this,w=arguments;return e.reduce(f,function(N,b){return w.length>1?v.setEdge(N,b,g):v.setEdge(N,b),b}),this},i.prototype.setEdge=function(){var f,g,v,w,N=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,g=b.w,v=b.name,arguments.length===2&&(w=arguments[1],N=!0)):(f=b,g=arguments[1],v=arguments[3],arguments.length>2&&(w=arguments[2],N=!0)),f=""+f,g=""+g,e.isUndefined(v)||(v=""+v);var k=u(this._isDirected,f,g,v);if(e.has(this._edgeLabels,k))return N&&(this._edgeLabels[k]=w),this;if(!e.isUndefined(v)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(g),this._edgeLabels[k]=N?w:this._defaultEdgeLabelFn(f,g,v);var _=h(this._isDirected,f,g,v);return f=_.v,g=_.w,Object.freeze(_),this._edgeObjs[k]=_,a(this._preds[g],f),a(this._sucs[f],g),this._in[g][k]=_,this._out[f][k]=_,this._edgeCount++,this},i.prototype.edge=function(f,g,v){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,v);return this._edgeLabels[w]},i.prototype.hasEdge=function(f,g,v){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,v);return e.has(this._edgeLabels,w)},i.prototype.removeEdge=function(f,g,v){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,f,g,v),N=this._edgeObjs[w];return N&&(f=N.v,g=N.w,delete this._edgeLabels[w],delete this._edgeObjs[w],l(this._preds[g],f),l(this._sucs[f],g),delete this._in[g][w],delete this._out[f][w],this._edgeCount--),this},i.prototype.inEdges=function(f,g){var v=this._in[f];if(v){var w=e.values(v);return g?e.filter(w,function(N){return N.v===g}):w}},i.prototype.outEdges=function(f,g){var v=this._out[f];if(v){var w=e.values(v);return g?e.filter(w,function(N){return N.w===g}):w}},i.prototype.nodeEdges=function(f,g){var v=this.inEdges(f,g);if(v)return v.concat(this.outEdges(f,g))};function a(f,g){f[g]?f[g]++:f[g]=1}function l(f,g){--f[g]||delete f[g]}function u(f,g,v,w){var N=""+g,b=""+v;if(!f&&N>b){var k=N;N=b,b=k}return N+s+b+s+(e.isUndefined(w)?t:w)}function h(f,g,v,w){var N=""+g,b=""+v;if(!f&&N>b){var k=N;N=b,b=k}var _={v:N,w:b};return w&&(_.name=w),_}function p(f,g){return u(f,g.v,g.w,g.name)}return $g}var Lg,MN;function Z6(){return MN||(MN=1,Lg="2.1.8"),Lg}var qg,IN;function J6(){return IN||(IN=1,qg={Graph:r0(),version:Z6()}),qg}var Dg,ON;function ez(){if(ON)return Dg;ON=1;var e=Dn(),t=r0();Dg={write:n,read:a};function n(l){var u={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:s(l),edges:i(l)};return e.isUndefined(l.graph())||(u.value=e.clone(l.graph())),u}function s(l){return e.map(l.nodes(),function(u){var h=l.node(u),p=l.parent(u),f={v:u};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function i(l){return e.map(l.edges(),function(u){var h=l.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(h)||(p.value=h),p})}function a(l){var u=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(h){u.setNode(h.v,h.value),h.parent&&u.setParent(h.v,h.parent)}),e.each(l.edges,function(h){u.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),u}return Dg}var Fg,PN;function tz(){if(PN)return Fg;PN=1;var e=Dn();Fg=t;function t(n){var s={},i=[],a;function l(u){e.has(s,u)||(s[u]=!0,a.push(u),e.each(n.successors(u),l),e.each(n.predecessors(u),l))}return e.each(n.nodes(),function(u){a=[],l(u),a.length&&i.push(a)}),i}return Fg}var zg,$N;function $R(){if($N)return zg;$N=1;var e=Dn();zg=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 i=this._keyIndices;if(n=String(n),!e.has(i,n)){var a=this._arr,l=a.length;return i[n]=l,a.push({key:n,priority:s}),this._decrease(l),!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 i=this._keyIndices[n];if(s>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+s);this._arr[i].priority=s,this._decrease(i)},t.prototype._heapify=function(n){var s=this._arr,i=2*n,a=i+1,l=n;i<s.length&&(l=s[i].priority<s[l].priority?i:l,a<s.length&&(l=s[a].priority<s[l].priority?a:l),l!==n&&(this._swap(n,l),this._heapify(l)))},t.prototype._decrease=function(n){for(var s=this._arr,i=s[n].priority,a;n!==0&&(a=n>>1,!(s[a].priority<i));)this._swap(n,a),n=a},t.prototype._swap=function(n,s){var i=this._arr,a=this._keyIndices,l=i[n],u=i[s];i[n]=u,i[s]=l,a[u.key]=n,a[l.key]=s},zg}var Bg,LN;function LR(){if(LN)return Bg;LN=1;var e=Dn(),t=$R();Bg=s;var n=e.constant(1);function s(a,l,u,h){return i(a,String(l),u||n,h||function(p){return a.outEdges(p)})}function i(a,l,u,h){var p={},f=new t,g,v,w=function(N){var b=N.v!==g?N.v:N.w,k=p[b],_=u(N),E=v.distance+_;if(_<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+_);E<k.distance&&(k.distance=E,k.predecessor=g,f.decrease(b,E))};for(a.nodes().forEach(function(N){var b=N===l?0:Number.POSITIVE_INFINITY;p[N]={distance:b},f.add(N,b)});f.size()>0&&(g=f.removeMin(),v=p[g],v.distance!==Number.POSITIVE_INFINITY);)h(g).forEach(w);return p}return Bg}var Ug,qN;function nz(){if(qN)return Ug;qN=1;var e=LR(),t=Dn();Ug=n;function n(s,i,a){return t.transform(s.nodes(),function(l,u){l[u]=e(s,u,i,a)},{})}return Ug}var Wg,DN;function qR(){if(DN)return Wg;DN=1;var e=Dn();Wg=t;function t(n){var s=0,i=[],a={},l=[];function u(h){var p=a[h]={onStack:!0,lowlink:s,index:s++};if(i.push(h),n.successors(h).forEach(function(v){e.has(a,v)?a[v].onStack&&(p.lowlink=Math.min(p.lowlink,a[v].index)):(u(v),p.lowlink=Math.min(p.lowlink,a[v].lowlink))}),p.lowlink===p.index){var f=[],g;do g=i.pop(),a[g].onStack=!1,f.push(g);while(h!==g);l.push(f)}}return n.nodes().forEach(function(h){e.has(a,h)||u(h)}),l}return Wg}var Hg,FN;function rz(){if(FN)return Hg;FN=1;var e=Dn(),t=qR();Hg=n;function n(s){return e.filter(t(s),function(i){return i.length>1||i.length===1&&s.hasEdge(i[0],i[0])})}return Hg}var Gg,zN;function sz(){if(zN)return Gg;zN=1;var e=Dn();Gg=n;var t=e.constant(1);function n(i,a,l){return s(i,a||t,l||function(u){return i.outEdges(u)})}function s(i,a,l){var u={},h=i.nodes();return h.forEach(function(p){u[p]={},u[p][p]={distance:0},h.forEach(function(f){p!==f&&(u[p][f]={distance:Number.POSITIVE_INFINITY})}),l(p).forEach(function(f){var g=f.v===p?f.w:f.v,v=a(f);u[p][g]={distance:v,predecessor:p}})}),h.forEach(function(p){var f=u[p];h.forEach(function(g){var v=u[g];h.forEach(function(w){var N=v[p],b=f[w],k=v[w],_=N.distance+b.distance;_<k.distance&&(k.distance=_,k.predecessor=b.predecessor)})})}),u}return Gg}var Vg,BN;function DR(){if(BN)return Vg;BN=1;var e=Dn();Vg=t,t.CycleException=n;function t(s){var i={},a={},l=[];function u(h){if(e.has(a,h))throw new n;e.has(i,h)||(a[h]=!0,i[h]=!0,e.each(s.predecessors(h),u),delete a[h],l.push(h))}if(e.each(s.sinks(),u),e.size(i)!==s.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,Vg}var Yg,UN;function oz(){if(UN)return Yg;UN=1;var e=DR();Yg=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Yg}var Kg,WN;function FR(){if(WN)return Kg;WN=1;var e=Dn();Kg=t;function t(s,i,a){e.isArray(i)||(i=[i]);var l=(s.isDirected()?s.successors:s.neighbors).bind(s),u=[],h={};return e.each(i,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,a==="post",h,l,u)}),u}function n(s,i,a,l,u,h){e.has(l,i)||(l[i]=!0,a||h.push(i),e.each(u(i),function(p){n(s,p,a,l,u,h)}),a&&h.push(i))}return Kg}var Xg,HN;function iz(){if(HN)return Xg;HN=1;var e=FR();Xg=t;function t(n,s){return e(n,s,"post")}return Xg}var Qg,GN;function az(){if(GN)return Qg;GN=1;var e=FR();Qg=t;function t(n,s){return e(n,s,"pre")}return Qg}var Zg,VN;function lz(){if(VN)return Zg;VN=1;var e=Dn(),t=r0(),n=$R();Zg=s;function s(i,a){var l=new t,u={},h=new n,p;function f(v){var w=v.v===p?v.w:v.v,N=h.priority(w);if(N!==void 0){var b=a(v);b<N&&(u[w]=p,h.decrease(w,b))}}if(i.nodeCount()===0)return l;e.each(i.nodes(),function(v){h.add(v,Number.POSITIVE_INFINITY),l.setNode(v)}),h.decrease(i.nodes()[0],0);for(var g=!1;h.size()>0;){if(p=h.removeMin(),e.has(u,p))l.setEdge(p,u[p]);else{if(g)throw new Error("Input graph is not connected: "+i);g=!0}i.nodeEdges(p).forEach(f)}return l}return Zg}var Jg,YN;function cz(){return YN||(YN=1,Jg={components:tz(),dijkstra:LR(),dijkstraAll:nz(),findCycles:rz(),floydWarshall:sz(),isAcyclic:oz(),postorder:iz(),preorder:az(),prim:lz(),tarjan:qR(),topsort:DR()}),Jg}var ey,KN;function uz(){if(KN)return ey;KN=1;var e=J6();return ey={Graph:e.Graph,json:ez(),alg:cz(),version:e.version},ey}var ty,XN;function cr(){if(XN)return ty;XN=1;var e;if(typeof zw=="function")try{e=uz()}catch{}return e||(e=window.graphlib),ty=e,ty}var ny,QN;function dz(){if(QN)return ny;QN=1;var e=dR(),t=1,n=4;function s(i){return e(i,t|n)}return ny=s,ny}var ry,ZN;function cd(){if(ZN)return ry;ZN=1;var e=Qi(),t=es(),n=ed(),s=qn();function i(a,l,u){if(!s(u))return!1;var h=typeof l;return(h=="number"?t(u)&&n(l,u.length):h=="string"&&l in u)?e(u[l],a):!1}return ry=i,ry}var sy,JN;function fz(){if(JN)return sy;JN=1;var e=ld(),t=Qi(),n=cd(),s=Co(),i=Object.prototype,a=i.hasOwnProperty,l=e(function(u,h){u=Object(u);var p=-1,f=h.length,g=f>2?h[2]:void 0;for(g&&n(h[0],h[1],g)&&(f=1);++p<f;)for(var v=h[p],w=s(v),N=-1,b=w.length;++N<b;){var k=w[N],_=u[k];(_===void 0||t(_,i[k])&&!a.call(u,k))&&(u[k]=v[k])}return u});return sy=l,sy}var oy,eE;function hz(){if(eE)return oy;eE=1;var e=ts(),t=es(),n=qs();function s(i){return function(a,l,u){var h=Object(a);if(!t(a)){var p=e(l,3);a=n(a),l=function(g){return p(h[g],g,h)}}var f=i(a,l,u);return f>-1?h[p?a[f]:f]:void 0}}return oy=s,oy}var iy,tE;function pz(){if(tE)return iy;tE=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 ay,nE;function mz(){if(nE)return ay;nE=1;var e=pz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return ay=n,ay}var ly,rE;function gz(){if(rE)return ly;rE=1;var e=mz(),t=qn(),n=ta(),s=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=a.test(p);return g||l.test(p)?u(p.slice(2),g?2:8):i.test(p)?s:+p}return ly=h,ly}var cy,sE;function zR(){if(sE)return cy;sE=1;var e=gz(),t=1/0,n=17976931348623157e292;function s(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var a=i<0?-1:1;return a*n}return i===i?i:0}return cy=s,cy}var uy,oE;function yz(){if(oE)return uy;oE=1;var e=zR();function t(n){var s=e(n),i=s%1;return s===s?i?s-i:s:0}return uy=t,uy}var dy,iE;function vz(){if(iE)return dy;iE=1;var e=IR(),t=ts(),n=yz(),s=Math.max;function i(a,l,u){var h=a==null?0:a.length;if(!h)return-1;var p=u==null?0:n(u);return p<0&&(p=s(h+p,0)),e(a,t(l,3),p)}return dy=i,dy}var fy,aE;function wz(){if(aE)return fy;aE=1;var e=hz(),t=vz(),n=e(t);return fy=n,fy}var hy,lE;function BR(){if(lE)return hy;lE=1;var e=n0();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return hy=t,hy}var py,cE;function xz(){if(cE)return py;cE=1;var e=Zw(),t=fR(),n=Co();function s(i,a){return i==null?i:e(i,t(a),n)}return py=s,py}var my,uE;function bz(){if(uE)return my;uE=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return my=e,my}var gy,dE;function kz(){if(dE)return gy;dE=1;var e=Zu(),t=Jw(),n=ts();function s(i,a){var l={};return a=n(a,3),t(i,function(u,h,p){e(l,h,a(u,h,p))}),l}return gy=s,gy}var yy,fE;function s0(){if(fE)return yy;fE=1;var e=ta();function t(n,s,i){for(var a=-1,l=n.length;++a<l;){var u=n[a],h=s(u);if(h!=null&&(p===void 0?h===h&&!e(h):i(h,p)))var p=h,f=u}return f}return yy=t,yy}var vy,hE;function _z(){if(hE)return vy;hE=1;function e(t,n){return t>n}return vy=e,vy}var wy,pE;function Sz(){if(pE)return wy;pE=1;var e=s0(),t=_z(),n=jo();function s(i){return i&&i.length?e(i,n,t):void 0}return wy=s,wy}var xy,mE;function UR(){if(mE)return xy;mE=1;var e=Zu(),t=Qi();function n(s,i,a){(a!==void 0&&!t(s[i],a)||a===void 0&&!(i in s))&&e(s,i,a)}return xy=n,xy}var by,gE;function Nz(){if(gE)return by;gE=1;var e=No(),t=rd(),n=jr(),s="[object Object]",i=Function.prototype,a=Object.prototype,l=i.toString,u=a.hasOwnProperty,h=l.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var g=t(f);if(g===null)return!0;var v=u.call(g,"constructor")&&g.constructor;return typeof v=="function"&&v instanceof v&&l.call(v)==h}return by=p,by}var ky,yE;function WR(){if(yE)return ky;yE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return ky=e,ky}var _y,vE;function Ez(){if(vE)return _y;vE=1;var e=Pl(),t=Co();function n(s){return e(s,t(s))}return _y=n,_y}var Sy,wE;function Cz(){if(wE)return Sy;wE=1;var e=UR(),t=JT(),n=lR(),s=eR(),i=uR(),a=$l(),l=Mt(),u=OR(),h=Ji(),p=Ol(),f=qn(),g=Nz(),v=Ll(),w=WR(),N=Ez();function b(k,_,E,C,j,I,O){var P=w(k,E),z=w(_,E),M=O.get(z);if(M){e(k,E,M);return}var A=I?I(P,z,E+"",k,_,O):void 0,q=A===void 0;if(q){var G=l(z),Y=!G&&h(z),R=!G&&!Y&&v(z);A=z,G||Y||R?l(P)?A=P:u(P)?A=s(P):Y?(q=!1,A=t(z,!0)):R?(q=!1,A=n(z,!0)):A=[]:g(z)||a(z)?(A=P,a(P)?A=N(P):(!f(P)||p(P))&&(A=i(z))):q=!1}q&&(O.set(z,A),j(A,z,C,I,O),O.delete(z)),e(k,E,A)}return Sy=b,Sy}var Ny,xE;function jz(){if(xE)return Ny;xE=1;var e=Qu(),t=UR(),n=Zw(),s=Cz(),i=qn(),a=Co(),l=WR();function u(h,p,f,g,v){h!==p&&n(p,function(w,N){if(v||(v=new e),i(w))s(h,p,N,f,u,g,v);else{var b=g?g(l(h,N),w,N+"",h,p,v):void 0;b===void 0&&(b=w),t(h,N,b)}},a)}return Ny=u,Ny}var Ey,bE;function Tz(){if(bE)return Ey;bE=1;var e=ld(),t=cd();function n(s){return e(function(i,a){var l=-1,u=a.length,h=u>1?a[u-1]:void 0,p=u>2?a[2]:void 0;for(h=s.length>3&&typeof h=="function"?(u--,h):void 0,p&&t(a[0],a[1],p)&&(h=u<3?void 0:h,u=1),i=Object(i);++l<u;){var f=a[l];f&&s(i,f,l,h)}return i})}return Ey=n,Ey}var Cy,kE;function Rz(){if(kE)return Cy;kE=1;var e=jz(),t=Tz(),n=t(function(s,i,a){e(s,i,a)});return Cy=n,Cy}var jy,_E;function HR(){if(_E)return jy;_E=1;function e(t,n){return t<n}return jy=e,jy}var Ty,SE;function Az(){if(SE)return Ty;SE=1;var e=s0(),t=HR(),n=jo();function s(i){return i&&i.length?e(i,n,t):void 0}return Ty=s,Ty}var Ry,NE;function Mz(){if(NE)return Ry;NE=1;var e=s0(),t=ts(),n=HR();function s(i,a){return i&&i.length?e(i,t(a,2),n):void 0}return Ry=s,Ry}var Ay,EE;function Iz(){if(EE)return Ay;EE=1;var e=dr(),t=function(){return e.Date.now()};return Ay=t,Ay}var My,CE;function Oz(){if(CE)return My;CE=1;var e=Ju(),t=id(),n=ed(),s=qn(),i=ql();function a(l,u,h,p){if(!s(l))return l;u=t(u,l);for(var f=-1,g=u.length,v=g-1,w=l;w!=null&&++f<g;){var N=i(u[f]),b=h;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(f!=v){var k=w[N];b=p?p(k,N,w):void 0,b===void 0&&(b=s(k)?k:n(u[f+1])?[]:{})}e(w,N,b),w=w[N]}return l}return My=a,My}var Iy,jE;function Pz(){if(jE)return Iy;jE=1;var e=ad(),t=Oz(),n=id();function s(i,a,l){for(var u=-1,h=a.length,p={};++u<h;){var f=a[u],g=e(i,f);l(g,f)&&t(p,n(f,i),g)}return p}return Iy=s,Iy}var Oy,TE;function $z(){if(TE)return Oy;TE=1;var e=Pz(),t=_R();function n(s,i){return e(s,i,function(a,l){return t(s,l)})}return Oy=n,Oy}var Py,RE;function Lz(){if(RE)return Py;RE=1;var e=BR(),t=AR(),n=MR();function s(i){return n(t(i,void 0,e),i+"")}return Py=s,Py}var $y,AE;function qz(){if(AE)return $y;AE=1;var e=$z(),t=Lz(),n=t(function(s,i){return s==null?{}:e(s,i)});return $y=n,$y}var Ly,ME;function Dz(){if(ME)return Ly;ME=1;var e=Math.ceil,t=Math.max;function n(s,i,a,l){for(var u=-1,h=t(e((i-s)/(a||1)),0),p=Array(h);h--;)p[l?h:++u]=s,s+=a;return p}return Ly=n,Ly}var qy,IE;function Fz(){if(IE)return qy;IE=1;var e=Dz(),t=cd(),n=zR();function s(i){return function(a,l,u){return u&&typeof u!="number"&&t(a,l,u)&&(l=u=void 0),a=n(a),l===void 0?(l=a,a=0):l=n(l),u=u===void 0?a<l?1:-1:n(u),e(a,l,u,i)}}return qy=s,qy}var Dy,OE;function zz(){if(OE)return Dy;OE=1;var e=Fz(),t=e();return Dy=t,Dy}var Fy,PE;function Bz(){if(PE)return Fy;PE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return Fy=e,Fy}var zy,$E;function Uz(){if($E)return zy;$E=1;var e=ta();function t(n,s){if(n!==s){var i=n!==void 0,a=n===null,l=n===n,u=e(n),h=s!==void 0,p=s===null,f=s===s,g=e(s);if(!p&&!g&&!u&&n>s||u&&h&&f&&!p&&!g||a&&h&&f||!i&&f||!l)return 1;if(!a&&!u&&!g&&n<s||g&&i&&l&&!a&&!u||p&&i&&l||!h&&l||!f)return-1}return 0}return zy=t,zy}var By,LE;function Wz(){if(LE)return By;LE=1;var e=Uz();function t(n,s,i){for(var a=-1,l=n.criteria,u=s.criteria,h=l.length,p=i.length;++a<h;){var f=e(l[a],u[a]);if(f){if(a>=p)return f;var g=i[a];return f*(g=="desc"?-1:1)}}return n.index-s.index}return By=t,By}var Uy,qE;function Hz(){if(qE)return Uy;qE=1;var e=od(),t=ad(),n=ts(),s=jR(),i=Bz(),a=td(),l=Wz(),u=jo(),h=Mt();function p(f,g,v){g.length?g=e(g,function(b){return h(b)?function(k){return t(k,b.length===1?b[0]:b)}:b}):g=[u];var w=-1;g=e(g,a(n));var N=s(f,function(b,k,_){var E=e(g,function(C){return C(b)});return{criteria:E,index:++w,value:b}});return i(N,function(b,k){return l(b,k,v)})}return Uy=p,Uy}var Wy,DE;function Gz(){if(DE)return Wy;DE=1;var e=n0(),t=Hz(),n=ld(),s=cd(),i=n(function(a,l){if(a==null)return[];var u=l.length;return u>1&&s(a,l[0],l[1])?l=[]:u>2&&s(l[0],l[1],l[2])&&(l=[l[0]]),t(a,e(l,1),[])});return Wy=i,Wy}var Hy,FE;function Vz(){if(FE)return Hy;FE=1;var e=bR(),t=0;function n(s){var i=++t;return e(s)+i}return Hy=n,Hy}var Gy,zE;function Yz(){if(zE)return Gy;zE=1;function e(t,n,s){for(var i=-1,a=t.length,l=n.length,u={};++i<a;){var h=i<l?n[i]:void 0;s(u,t[i],h)}return u}return Gy=e,Gy}var Vy,BE;function Kz(){if(BE)return Vy;BE=1;var e=Ju(),t=Yz();function n(s,i){return t(s||[],i||[],e)}return Vy=n,Vy}var Yy,UE;function vt(){if(UE)return Yy;UE=1;var e;if(typeof zw=="function")try{e={cloneDeep:dz(),constant:Qw(),defaults:fz(),each:pR(),filter:NR(),find:wz(),flatten:BR(),forEach:hR(),forIn:xz(),has:ER(),isUndefined:CR(),last:bz(),map:TR(),mapValues:kz(),max:Sz(),merge:Rz(),min:Az(),minBy:Mz(),now:Iz(),pick:qz(),range:zz(),reduce:RR(),sortBy:Gz(),uniqueId:Vz(),values:PR(),zipObject:Kz()}}catch{}return e||(e=window._),Yy=e,Yy}var Ky,WE;function Xz(){if(WE)return Ky;WE=1,Ky=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,i=s._prev;if(i!==s)return t(i),i},e.prototype.enqueue=function(s){var i=this._sentinel;s._prev&&s._next&&t(s),s._next=i._next,i._next._prev=s,i._next=s,s._prev=i},e.prototype.toString=function(){for(var s=[],i=this._sentinel,a=i._prev;a!==i;)s.push(JSON.stringify(a,n)),a=a._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,i){if(s!=="_next"&&s!=="_prev")return i}return Ky}var Xy,HE;function Qz(){if(HE)return Xy;HE=1;var e=vt(),t=cr().Graph,n=Xz();Xy=i;var s=e.constant(1);function i(p,f){if(p.nodeCount()<=1)return[];var g=u(p,f||s),v=a(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(v,function(w){return p.outEdges(w.v,w.w)}),!0)}function a(p,f,g){for(var v=[],w=f[f.length-1],N=f[0],b;p.nodeCount();){for(;b=N.dequeue();)l(p,f,g,b);for(;b=w.dequeue();)l(p,f,g,b);if(p.nodeCount()){for(var k=f.length-2;k>0;--k)if(b=f[k].dequeue(),b){v=v.concat(l(p,f,g,b,!0));break}}}return v}function l(p,f,g,v,w){var N=w?[]:void 0;return e.forEach(p.inEdges(v.v),function(b){var k=p.edge(b),_=p.node(b.v);w&&N.push({v:b.v,w:b.w}),_.out-=k,h(f,g,_)}),e.forEach(p.outEdges(v.v),function(b){var k=p.edge(b),_=b.w,E=p.node(_);E.in-=k,h(f,g,E)}),p.removeNode(v.v),N}function u(p,f){var g=new t,v=0,w=0;e.forEach(p.nodes(),function(k){g.setNode(k,{v:k,in:0,out:0})}),e.forEach(p.edges(),function(k){var _=g.edge(k.v,k.w)||0,E=f(k),C=_+E;g.setEdge(k.v,k.w,C),w=Math.max(w,g.node(k.v).out+=E),v=Math.max(v,g.node(k.w).in+=E)});var N=e.range(w+v+3).map(function(){return new n}),b=v+1;return e.forEach(g.nodes(),function(k){h(N,b,g.node(k))}),{graph:g,buckets:N,zeroIdx:b}}function h(p,f,g){g.out?g.in?p[g.out-g.in+f].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Xy}var Qy,GE;function Zz(){if(GE)return Qy;GE=1;var e=vt(),t=Qz();Qy={run:n,undo:i};function n(a){var l=a.graph().acyclicer==="greedy"?t(a,u(a)):s(a);e.forEach(l,function(h){var p=a.edge(h);a.removeEdge(h),p.forwardName=h.name,p.reversed=!0,a.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function u(h){return function(p){return h.edge(p).weight}}}function s(a){var l=[],u={},h={};function p(f){e.has(h,f)||(h[f]=!0,u[f]=!0,e.forEach(a.outEdges(f),function(g){e.has(u,g.w)?l.push(g):p(g.w)}),delete u[f])}return e.forEach(a.nodes(),p),l}function i(a){e.forEach(a.edges(),function(l){var u=a.edge(l);if(u.reversed){a.removeEdge(l);var h=u.forwardName;delete u.reversed,delete u.forwardName,a.setEdge(l.w,l.v,u,h)}})}return Qy}var Zy,VE;function fn(){if(VE)return Zy;VE=1;var e=vt(),t=cr().Graph;Zy={addDummyNode:n,simplify:s,asNonCompoundGraph:i,successorWeights:a,predecessorWeights:l,intersectRect:u,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:g,maxRank:v,partition:w,time:N,notime:b};function n(k,_,E,C){var j;do j=e.uniqueId(C);while(k.hasNode(j));return E.dummy=_,k.setNode(j,E),j}function s(k){var _=new t().setGraph(k.graph());return e.forEach(k.nodes(),function(E){_.setNode(E,k.node(E))}),e.forEach(k.edges(),function(E){var C=_.edge(E.v,E.w)||{weight:0,minlen:1},j=k.edge(E);_.setEdge(E.v,E.w,{weight:C.weight+j.weight,minlen:Math.max(C.minlen,j.minlen)})}),_}function i(k){var _=new t({multigraph:k.isMultigraph()}).setGraph(k.graph());return e.forEach(k.nodes(),function(E){k.children(E).length||_.setNode(E,k.node(E))}),e.forEach(k.edges(),function(E){_.setEdge(E,k.edge(E))}),_}function a(k){var _=e.map(k.nodes(),function(E){var C={};return e.forEach(k.outEdges(E),function(j){C[j.w]=(C[j.w]||0)+k.edge(j).weight}),C});return e.zipObject(k.nodes(),_)}function l(k){var _=e.map(k.nodes(),function(E){var C={};return e.forEach(k.inEdges(E),function(j){C[j.v]=(C[j.v]||0)+k.edge(j).weight}),C});return e.zipObject(k.nodes(),_)}function u(k,_){var E=k.x,C=k.y,j=_.x-E,I=_.y-C,O=k.width/2,P=k.height/2;if(!j&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var z,M;return Math.abs(I)*O>Math.abs(j)*P?(I<0&&(P=-P),z=P*j/I,M=P):(j<0&&(O=-O),z=O,M=O*I/j),{x:E+z,y:C+M}}function h(k){var _=e.map(e.range(v(k)+1),function(){return[]});return e.forEach(k.nodes(),function(E){var C=k.node(E),j=C.rank;e.isUndefined(j)||(_[j][C.order]=E)}),_}function p(k){var _=e.min(e.map(k.nodes(),function(E){return k.node(E).rank}));e.forEach(k.nodes(),function(E){var C=k.node(E);e.has(C,"rank")&&(C.rank-=_)})}function f(k){var _=e.min(e.map(k.nodes(),function(I){return k.node(I).rank})),E=[];e.forEach(k.nodes(),function(I){var O=k.node(I).rank-_;E[O]||(E[O]=[]),E[O].push(I)});var C=0,j=k.graph().nodeRankFactor;e.forEach(E,function(I,O){e.isUndefined(I)&&O%j!==0?--C:C&&e.forEach(I,function(P){k.node(P).rank+=C})})}function g(k,_,E,C){var j={width:0,height:0};return arguments.length>=4&&(j.rank=E,j.order=C),n(k,"border",j,_)}function v(k){return e.max(e.map(k.nodes(),function(_){var E=k.node(_).rank;if(!e.isUndefined(E))return E}))}function w(k,_){var E={lhs:[],rhs:[]};return e.forEach(k,function(C){_(C)?E.lhs.push(C):E.rhs.push(C)}),E}function N(k,_){var E=e.now();try{return _()}finally{console.log(k+" time: "+(e.now()-E)+"ms")}}function b(k,_){return _()}return Zy}var Jy,YE;function Jz(){if(YE)return Jy;YE=1;var e=vt(),t=fn();Jy={run:n,undo:i};function n(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(l){s(a,l)})}function s(a,l){var u=l.v,h=a.node(u).rank,p=l.w,f=a.node(p).rank,g=l.name,v=a.edge(l),w=v.labelRank;if(f!==h+1){a.removeEdge(l);var N,b,k;for(k=0,++h;h<f;++k,++h)v.points=[],b={width:0,height:0,edgeLabel:v,edgeObj:l,rank:h},N=t.addDummyNode(a,"edge",b,"_d"),h===w&&(b.width=v.width,b.height=v.height,b.dummy="edge-label",b.labelpos=v.labelpos),a.setEdge(u,N,{weight:v.weight},g),k===0&&a.graph().dummyChains.push(N),u=N;a.setEdge(u,p,{weight:v.weight},g)}}function i(a){e.forEach(a.graph().dummyChains,function(l){var u=a.node(l),h=u.edgeLabel,p;for(a.setEdge(u.edgeObj,h);u.dummy;)p=a.successors(l)[0],a.removeNode(l),h.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(h.x=u.x,h.y=u.y,h.width=u.width,h.height=u.height),l=p,u=a.node(l)})}return Jy}var ev,KE;function Iu(){if(KE)return ev;KE=1;var e=vt();ev={longestPath:t,slack:n};function t(s){var i={};function a(l){var u=s.node(l);if(e.has(i,l))return u.rank;i[l]=!0;var h=e.min(e.map(s.outEdges(l),function(p){return a(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),u.rank=h}e.forEach(s.sources(),a)}function n(s,i){return s.node(i.w).rank-s.node(i.v).rank-s.edge(i).minlen}return ev}var tv,XE;function GR(){if(XE)return tv;XE=1;var e=vt(),t=cr().Graph,n=Iu().slack;tv=s;function s(u){var h=new t({directed:!1}),p=u.nodes()[0],f=u.nodeCount();h.setNode(p,{});for(var g,v;i(h,u)<f;)g=a(h,u),v=h.hasNode(g.v)?n(u,g):-n(u,g),l(h,u,v);return h}function i(u,h){function p(f){e.forEach(h.nodeEdges(f),function(g){var v=g.v,w=f===v?g.w:v;!u.hasNode(w)&&!n(h,g)&&(u.setNode(w,{}),u.setEdge(f,w,{}),p(w))})}return e.forEach(u.nodes(),p),u.nodeCount()}function a(u,h){return e.minBy(h.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(h,p)})}function l(u,h,p){e.forEach(u.nodes(),function(f){h.node(f).rank+=p})}return tv}var nv,QE;function eB(){if(QE)return nv;QE=1;var e=vt(),t=GR(),n=Iu().slack,s=Iu().longestPath,i=cr().alg.preorder,a=cr().alg.postorder,l=fn().simplify;nv=u,u.initLowLimValues=g,u.initCutValues=h,u.calcCutValue=f,u.leaveEdge=w,u.enterEdge=N,u.exchangeEdges=b;function u(C){C=l(C),s(C);var j=t(C);g(j),h(j,C);for(var I,O;I=w(j);)O=N(j,C,I),b(j,C,I,O)}function h(C,j){var I=a(C,C.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(O){p(C,j,O)})}function p(C,j,I){var O=C.node(I),P=O.parent;C.edge(I,P).cutvalue=f(C,j,I)}function f(C,j,I){var O=C.node(I),P=O.parent,z=!0,M=j.edge(I,P),A=0;return M||(z=!1,M=j.edge(P,I)),A=M.weight,e.forEach(j.nodeEdges(I),function(q){var G=q.v===I,Y=G?q.w:q.v;if(Y!==P){var R=G===z,Q=j.edge(q).weight;if(A+=R?Q:-Q,_(C,I,Y)){var H=C.edge(I,Y).cutvalue;A+=R?-H:H}}}),A}function g(C,j){arguments.length<2&&(j=C.nodes()[0]),v(C,{},1,j)}function v(C,j,I,O,P){var z=I,M=C.node(O);return j[O]=!0,e.forEach(C.neighbors(O),function(A){e.has(j,A)||(I=v(C,j,I,A,O))}),M.low=z,M.lim=I++,P?M.parent=P:delete M.parent,I}function w(C){return e.find(C.edges(),function(j){return C.edge(j).cutvalue<0})}function N(C,j,I){var O=I.v,P=I.w;j.hasEdge(O,P)||(O=I.w,P=I.v);var z=C.node(O),M=C.node(P),A=z,q=!1;z.lim>M.lim&&(A=M,q=!0);var G=e.filter(j.edges(),function(Y){return q===E(C,C.node(Y.v),A)&&q!==E(C,C.node(Y.w),A)});return e.minBy(G,function(Y){return n(j,Y)})}function b(C,j,I,O){var P=I.v,z=I.w;C.removeEdge(P,z),C.setEdge(O.v,O.w,{}),g(C),h(C,j),k(C,j)}function k(C,j){var I=e.find(C.nodes(),function(P){return!j.node(P).parent}),O=i(C,I);O=O.slice(1),e.forEach(O,function(P){var z=C.node(P).parent,M=j.edge(P,z),A=!1;M||(M=j.edge(z,P),A=!0),j.node(P).rank=j.node(z).rank+(A?M.minlen:-M.minlen)})}function _(C,j,I){return C.hasEdge(j,I)}function E(C,j,I){return I.low<=j.lim&&j.lim<=I.lim}return nv}var rv,ZE;function tB(){if(ZE)return rv;ZE=1;var e=Iu(),t=e.longestPath,n=GR(),s=eB();rv=i;function i(h){switch(h.graph().ranker){case"network-simplex":u(h);break;case"tight-tree":l(h);break;case"longest-path":a(h);break;default:u(h)}}var a=t;function l(h){t(h),n(h)}function u(h){s(h)}return rv}var sv,JE;function nB(){if(JE)return sv;JE=1;var e=vt();sv=t;function t(i){var a=s(i);e.forEach(i.graph().dummyChains,function(l){for(var u=i.node(l),h=u.edgeObj,p=n(i,a,h.v,h.w),f=p.path,g=p.lca,v=0,w=f[v],N=!0;l!==h.w;){if(u=i.node(l),N){for(;(w=f[v])!==g&&i.node(w).maxRank<u.rank;)v++;w===g&&(N=!1)}if(!N){for(;v<f.length-1&&i.node(w=f[v+1]).minRank<=u.rank;)v++;w=f[v]}i.setParent(l,w),l=i.successors(l)[0]}})}function n(i,a,l,u){var h=[],p=[],f=Math.min(a[l].low,a[u].low),g=Math.max(a[l].lim,a[u].lim),v,w;v=l;do v=i.parent(v),h.push(v);while(v&&(a[v].low>f||g>a[v].lim));for(w=v,v=u;(v=i.parent(v))!==w;)p.push(v);return{path:h.concat(p.reverse()),lca:w}}function s(i){var a={},l=0;function u(h){var p=l;e.forEach(i.children(h),u),a[h]={low:p,lim:l++}}return e.forEach(i.children(),u),a}return sv}var ov,eC;function rB(){if(eC)return ov;eC=1;var e=vt(),t=fn();ov={run:n,cleanup:l};function n(u){var h=t.addDummyNode(u,"root",{},"_root"),p=i(u),f=e.max(e.values(p))-1,g=2*f+1;u.graph().nestingRoot=h,e.forEach(u.edges(),function(w){u.edge(w).minlen*=g});var v=a(u)+1;e.forEach(u.children(),function(w){s(u,h,g,v,f,p,w)}),u.graph().nodeRankFactor=g}function s(u,h,p,f,g,v,w){var N=u.children(w);if(!N.length){w!==h&&u.setEdge(h,w,{weight:0,minlen:p});return}var b=t.addBorderNode(u,"_bt"),k=t.addBorderNode(u,"_bb"),_=u.node(w);u.setParent(b,w),_.borderTop=b,u.setParent(k,w),_.borderBottom=k,e.forEach(N,function(E){s(u,h,p,f,g,v,E);var C=u.node(E),j=C.borderTop?C.borderTop:E,I=C.borderBottom?C.borderBottom:E,O=C.borderTop?f:2*f,P=j!==I?1:g-v[w]+1;u.setEdge(b,j,{weight:O,minlen:P,nestingEdge:!0}),u.setEdge(I,k,{weight:O,minlen:P,nestingEdge:!0})}),u.parent(w)||u.setEdge(h,b,{weight:0,minlen:g+v[w]})}function i(u){var h={};function p(f,g){var v=u.children(f);v&&v.length&&e.forEach(v,function(w){p(w,g+1)}),h[f]=g}return e.forEach(u.children(),function(f){p(f,1)}),h}function a(u){return e.reduce(u.edges(),function(h,p){return h+u.edge(p).weight},0)}function l(u){var h=u.graph();u.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(u.edges(),function(p){var f=u.edge(p);f.nestingEdge&&u.removeEdge(p)})}return ov}var iv,tC;function sB(){if(tC)return iv;tC=1;var e=vt(),t=fn();iv=n;function n(i){function a(l){var u=i.children(l),h=i.node(l);if(u.length&&e.forEach(u,a),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(i,"borderLeft","_bl",l,h,p),s(i,"borderRight","_br",l,h,p)}}e.forEach(i.children(),a)}function s(i,a,l,u,h,p){var f={width:0,height:0,rank:p,borderType:a},g=h[a][p-1],v=t.addDummyNode(i,"border",f,l);h[a][p]=v,i.setParent(v,u),g&&i.setEdge(g,v,{weight:1})}return iv}var av,nC;function oB(){if(nC)return av;nC=1;var e=vt();av={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&a(p),(f==="lr"||f==="rl")&&(u(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){i(p.node(f))}),e.forEach(p.edges(),function(f){i(p.edge(f))})}function i(p){var f=p.width;p.width=p.height,p.height=f}function a(p){e.forEach(p.nodes(),function(f){l(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,l),e.has(g,"y")&&l(g)})}function l(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var g=p.edge(f);e.forEach(g.points,h),e.has(g,"x")&&h(g)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return av}var lv,rC;function iB(){if(rC)return lv;rC=1;var e=vt();lv=t;function t(n){var s={},i=e.filter(n.nodes(),function(p){return!n.children(p).length}),a=e.max(e.map(i,function(p){return n.node(p).rank})),l=e.map(e.range(a+1),function(){return[]});function u(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);l[f.rank].push(p),e.forEach(n.successors(p),u)}}var h=e.sortBy(i,function(p){return n.node(p).rank});return e.forEach(h,u),l}return lv}var cv,sC;function aB(){if(sC)return cv;sC=1;var e=vt();cv=t;function t(s,i){for(var a=0,l=1;l<i.length;++l)a+=n(s,i[l-1],i[l]);return a}function n(s,i,a){for(var l=e.zipObject(a,e.map(a,function(v,w){return w})),u=e.flatten(e.map(i,function(v){return e.sortBy(e.map(s.outEdges(v),function(w){return{pos:l[w.w],weight:s.edge(w).weight}}),"pos")}),!0),h=1;h<a.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(u.forEach(function(v){var w=v.pos+h;f[w]+=v.weight;for(var N=0;w>0;)w%2&&(N+=f[w+1]),w=w-1>>1,f[w]+=v.weight;g+=v.weight*N})),g}return cv}var uv,oC;function lB(){if(oC)return uv;oC=1;var e=vt();uv=t;function t(n,s){return e.map(s,function(i){var a=n.inEdges(i);if(a.length){var l=e.reduce(a,function(u,h){var p=n.edge(h),f=n.node(h.v);return{sum:u.sum+p.weight*f.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:i,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:i}})}return uv}var dv,iC;function cB(){if(iC)return dv;iC=1;var e=vt();dv=t;function t(i,a){var l={};e.forEach(i,function(h,p){var f=l[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(a.edges(),function(h){var p=l[h.v],f=l[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(l[h.w]))});var u=e.filter(l,function(h){return!h.indegree});return n(u)}function n(i){var a=[];function l(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function u(p){return function(f){f.in.push(p),--f.indegree===0&&i.push(f)}}for(;i.length;){var h=i.pop();a.push(h),e.forEach(h.in.reverse(),l(h)),e.forEach(h.out,u(h))}return e.map(e.filter(a,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(i,a){var l=0,u=0;i.weight&&(l+=i.barycenter*i.weight,u+=i.weight),a.weight&&(l+=a.barycenter*a.weight,u+=a.weight),i.vs=a.vs.concat(i.vs),i.barycenter=l/u,i.weight=u,i.i=Math.min(a.i,i.i),a.merged=!0}return dv}var fv,aC;function uB(){if(aC)return fv;aC=1;var e=vt(),t=fn();fv=n;function n(a,l){var u=t.partition(a,function(b){return e.has(b,"barycenter")}),h=u.lhs,p=e.sortBy(u.rhs,function(b){return-b.i}),f=[],g=0,v=0,w=0;h.sort(i(!!l)),w=s(f,p,w),e.forEach(h,function(b){w+=b.vs.length,f.push(b.vs),g+=b.barycenter*b.weight,v+=b.weight,w=s(f,p,w)});var N={vs:e.flatten(f,!0)};return v&&(N.barycenter=g/v,N.weight=v),N}function s(a,l,u){for(var h;l.length&&(h=e.last(l)).i<=u;)l.pop(),a.push(h.vs),u++;return u}function i(a){return function(l,u){return l.barycenter<u.barycenter?-1:l.barycenter>u.barycenter?1:a?u.i-l.i:l.i-u.i}}return fv}var hv,lC;function dB(){if(lC)return hv;lC=1;var e=vt(),t=lB(),n=cB(),s=uB();hv=i;function i(u,h,p,f){var g=u.children(h),v=u.node(h),w=v?v.borderLeft:void 0,N=v?v.borderRight:void 0,b={};w&&(g=e.filter(g,function(I){return I!==w&&I!==N}));var k=t(u,g);e.forEach(k,function(I){if(u.children(I.v).length){var O=i(u,I.v,p,f);b[I.v]=O,e.has(O,"barycenter")&&l(I,O)}});var _=n(k,p);a(_,b);var E=s(_,f);if(w&&(E.vs=e.flatten([w,E.vs,N],!0),u.predecessors(w).length)){var C=u.node(u.predecessors(w)[0]),j=u.node(u.predecessors(N)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+C.order+j.order)/(E.weight+2),E.weight+=2}return E}function a(u,h){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function l(u,h){e.isUndefined(u.barycenter)?(u.barycenter=h.barycenter,u.weight=h.weight):(u.barycenter=(u.barycenter*u.weight+h.barycenter*h.weight)/(u.weight+h.weight),u.weight+=h.weight)}return hv}var pv,cC;function fB(){if(cC)return pv;cC=1;var e=vt(),t=cr().Graph;pv=n;function n(i,a,l){var u=s(i),h=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return i.node(p)});return e.forEach(i.nodes(),function(p){var f=i.node(p),g=i.parent(p);(f.rank===a||f.minRank<=a&&a<=f.maxRank)&&(h.setNode(p),h.setParent(p,g||u),e.forEach(i[l](p),function(v){var w=v.v===p?v.w:v.v,N=h.edge(w,p),b=e.isUndefined(N)?0:N.weight;h.setEdge(w,p,{weight:i.edge(v).weight+b})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[a],borderRight:f.borderRight[a]}))}),h}function s(i){for(var a;i.hasNode(a=e.uniqueId("_root")););return a}return pv}var mv,uC;function hB(){if(uC)return mv;uC=1;var e=vt();mv=t;function t(n,s,i){var a={},l;e.forEach(i,function(u){for(var h=n.parent(u),p,f;h;){if(p=n.parent(h),p?(f=a[p],a[p]=h):(f=l,l=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return mv}var gv,dC;function pB(){if(dC)return gv;dC=1;var e=vt(),t=iB(),n=aB(),s=dB(),i=fB(),a=hB(),l=cr().Graph,u=fn();gv=h;function h(v){var w=u.maxRank(v),N=p(v,e.range(1,w+1),"inEdges"),b=p(v,e.range(w-1,-1,-1),"outEdges"),k=t(v);g(v,k);for(var _=Number.POSITIVE_INFINITY,E,C=0,j=0;j<4;++C,++j){f(C%2?N:b,C%4>=2),k=u.buildLayerMatrix(v);var I=n(v,k);I<_&&(j=0,E=e.cloneDeep(k),_=I)}g(v,E)}function p(v,w,N){return e.map(w,function(b){return i(v,b,N)})}function f(v,w){var N=new l;e.forEach(v,function(b){var k=b.graph().root,_=s(b,k,N,w);e.forEach(_.vs,function(E,C){b.node(E).order=C}),a(b,N,_.vs)})}function g(v,w){e.forEach(w,function(N){e.forEach(N,function(b,k){v.node(b).order=k})})}return gv}var yv,fC;function mB(){if(fC)return yv;fC=1;var e=vt(),t=cr().Graph,n=fn();yv={positionX:N,findType1Conflicts:s,findType2Conflicts:i,addConflict:l,hasConflict:u,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:v,findSmallestWidthAlignment:g,balance:w};function s(_,E){var C={};function j(I,O){var P=0,z=0,M=I.length,A=e.last(O);return e.forEach(O,function(q,G){var Y=a(_,q),R=Y?_.node(Y).order:M;(Y||q===A)&&(e.forEach(O.slice(z,G+1),function(Q){e.forEach(_.predecessors(Q),function(H){var ne=_.node(H),X=ne.order;(X<P||R<X)&&!(ne.dummy&&_.node(Q).dummy)&&l(C,H,Q)})}),z=G+1,P=R)}),O}return e.reduce(E,j),C}function i(_,E){var C={};function j(O,P,z,M,A){var q;e.forEach(e.range(P,z),function(G){q=O[G],_.node(q).dummy&&e.forEach(_.predecessors(q),function(Y){var R=_.node(Y);R.dummy&&(R.order<M||R.order>A)&&l(C,Y,q)})})}function I(O,P){var z=-1,M,A=0;return e.forEach(P,function(q,G){if(_.node(q).dummy==="border"){var Y=_.predecessors(q);Y.length&&(M=_.node(Y[0]).order,j(P,A,G,z,M),A=G,z=M)}j(P,A,P.length,M,O.length)}),P}return e.reduce(E,I),C}function a(_,E){if(_.node(E).dummy)return e.find(_.predecessors(E),function(C){return _.node(C).dummy})}function l(_,E,C){if(E>C){var j=E;E=C,C=j}var I=_[E];I||(_[E]=I={}),I[C]=!0}function u(_,E,C){if(E>C){var j=E;E=C,C=j}return e.has(_[E],C)}function h(_,E,C,j){var I={},O={},P={};return e.forEach(E,function(z){e.forEach(z,function(M,A){I[M]=M,O[M]=M,P[M]=A})}),e.forEach(E,function(z){var M=-1;e.forEach(z,function(A){var q=j(A);if(q.length){q=e.sortBy(q,function(H){return P[H]});for(var G=(q.length-1)/2,Y=Math.floor(G),R=Math.ceil(G);Y<=R;++Y){var Q=q[Y];O[A]===A&&M<P[Q]&&!u(C,A,Q)&&(O[Q]=A,O[A]=I[A]=I[Q],M=P[Q])}}})}),{root:I,align:O}}function p(_,E,C,j,I){var O={},P=f(_,E,C,I),z=I?"borderLeft":"borderRight";function M(G,Y){for(var R=P.nodes(),Q=R.pop(),H={};Q;)H[Q]?G(Q):(H[Q]=!0,R.push(Q),R=R.concat(Y(Q))),Q=R.pop()}function A(G){O[G]=P.inEdges(G).reduce(function(Y,R){return Math.max(Y,O[R.v]+P.edge(R))},0)}function q(G){var Y=P.outEdges(G).reduce(function(Q,H){return Math.min(Q,O[H.w]-P.edge(H))},Number.POSITIVE_INFINITY),R=_.node(G);Y!==Number.POSITIVE_INFINITY&&R.borderType!==z&&(O[G]=Math.max(O[G],Y))}return M(A,P.predecessors.bind(P)),M(q,P.successors.bind(P)),e.forEach(j,function(G){O[G]=O[C[G]]}),O}function f(_,E,C,j){var I=new t,O=_.graph(),P=b(O.nodesep,O.edgesep,j);return e.forEach(E,function(z){var M;e.forEach(z,function(A){var q=C[A];if(I.setNode(q),M){var G=C[M],Y=I.edge(G,q);I.setEdge(G,q,Math.max(P(_,A,M),Y||0))}M=A})}),I}function g(_,E){return e.minBy(e.values(E),function(C){var j=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(C,function(O,P){var z=k(_,P)/2;j=Math.max(O+z,j),I=Math.min(O-z,I)}),j-I})}function v(_,E){var C=e.values(E),j=e.min(C),I=e.max(C);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(P){var z=O+P,M=_[z],A;if(M!==E){var q=e.values(M);A=P==="l"?j-e.min(q):I-e.max(q),A&&(_[z]=e.mapValues(M,function(G){return G+A}))}})})}function w(_,E){return e.mapValues(_.ul,function(C,j){if(E)return _[E.toLowerCase()][j];var I=e.sortBy(e.map(_,j));return(I[1]+I[2])/2})}function N(_){var E=n.buildLayerMatrix(_),C=e.merge(s(_,E),i(_,E)),j={},I;e.forEach(["u","d"],function(P){I=P==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(I=e.map(I,function(G){return e.values(G).reverse()}));var M=(P==="u"?_.predecessors:_.successors).bind(_),A=h(_,I,C,M),q=p(_,I,A.root,A.align,z==="r");z==="r"&&(q=e.mapValues(q,function(G){return-G})),j[P+z]=q})});var O=g(_,j);return v(j,O),w(j,_.graph().align)}function b(_,E,C){return function(j,I,O){var P=j.node(I),z=j.node(O),M=0,A;if(M+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":A=-P.width/2;break;case"r":A=P.width/2;break}if(A&&(M+=C?A:-A),A=0,M+=(P.dummy?E:_)/2,M+=(z.dummy?E:_)/2,M+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":A=z.width/2;break;case"r":A=-z.width/2;break}return A&&(M+=C?A:-A),A=0,M}}function k(_,E){return _.node(E).width}return yv}var vv,hC;function gB(){if(hC)return vv;hC=1;var e=vt(),t=fn(),n=mB().positionX;vv=s;function s(a){a=t.asNonCompoundGraph(a),i(a),e.forEach(n(a),function(l,u){a.node(u).x=l})}function i(a){var l=t.buildLayerMatrix(a),u=a.graph().ranksep,h=0;e.forEach(l,function(p){var f=e.max(e.map(p,function(g){return a.node(g).height}));e.forEach(p,function(g){a.node(g).y=h+f/2}),h+=f+u})}return vv}var wv,pC;function yB(){if(pC)return wv;pC=1;var e=vt(),t=Zz(),n=Jz(),s=tB(),i=fn().normalizeRanks,a=nB(),l=fn().removeEmptyRanks,u=rB(),h=sB(),p=oB(),f=pB(),g=gB(),v=fn(),w=cr().Graph;wv=N;function N(D,L){var K=L&&L.debugTiming?v.time:v.notime;K("layout",function(){var se=K(" buildLayoutGraph",function(){return M(D)});K(" runLayout",function(){b(se,K)}),K(" updateInputGraph",function(){k(D,se)})})}function b(D,L){L(" makeSpaceForEdgeLabels",function(){A(D)}),L(" removeSelfEdges",function(){U(D)}),L(" acyclic",function(){t.run(D)}),L(" nestingGraph.run",function(){u.run(D)}),L(" rank",function(){s(v.asNonCompoundGraph(D))}),L(" injectEdgeLabelProxies",function(){q(D)}),L(" removeEmptyRanks",function(){l(D)}),L(" nestingGraph.cleanup",function(){u.cleanup(D)}),L(" normalizeRanks",function(){i(D)}),L(" assignRankMinMax",function(){G(D)}),L(" removeEdgeLabelProxies",function(){Y(D)}),L(" normalize.run",function(){n.run(D)}),L(" parentDummyChains",function(){a(D)}),L(" addBorderSegments",function(){h(D)}),L(" order",function(){f(D)}),L(" insertSelfEdges",function(){J(D)}),L(" adjustCoordinateSystem",function(){p.adjust(D)}),L(" position",function(){g(D)}),L(" positionSelfEdges",function(){$(D)}),L(" removeBorderNodes",function(){X(D)}),L(" normalize.undo",function(){n.undo(D)}),L(" fixupEdgeLabelCoords",function(){H(D)}),L(" undoCoordinateSystem",function(){p.undo(D)}),L(" translateGraph",function(){R(D)}),L(" assignNodeIntersects",function(){Q(D)}),L(" reversePoints",function(){ne(D)}),L(" acyclic.undo",function(){t.undo(D)})}function k(D,L){e.forEach(D.nodes(),function(K){var se=D.node(K),he=L.node(K);se&&(se.x=he.x,se.y=he.y,L.children(K).length&&(se.width=he.width,se.height=he.height))}),e.forEach(D.edges(),function(K){var se=D.edge(K),he=L.edge(K);se.points=he.points,e.has(he,"x")&&(se.x=he.x,se.y=he.y)}),D.graph().width=L.graph().width,D.graph().height=L.graph().height}var _=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},C=["acyclicer","ranker","rankdir","align"],j=["width","height"],I={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function M(D){var L=new w({multigraph:!0,compound:!0}),K=Z(D.graph());return L.setGraph(e.merge({},E,V(K,_),e.pick(K,C))),e.forEach(D.nodes(),function(se){var he=Z(D.node(se));L.setNode(se,e.defaults(V(he,j),I)),L.setParent(se,D.parent(se))}),e.forEach(D.edges(),function(se){var he=Z(D.edge(se));L.setEdge(se,e.merge({},P,V(he,O),e.pick(he,z)))}),L}function A(D){var L=D.graph();L.ranksep/=2,e.forEach(D.edges(),function(K){var se=D.edge(K);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(L.rankdir==="TB"||L.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function q(D){e.forEach(D.edges(),function(L){var K=D.edge(L);if(K.width&&K.height){var se=D.node(L.v),he=D.node(L.w),me={rank:(he.rank-se.rank)/2+se.rank,e:L};v.addDummyNode(D,"edge-proxy",me,"_ep")}})}function G(D){var L=0;e.forEach(D.nodes(),function(K){var se=D.node(K);se.borderTop&&(se.minRank=D.node(se.borderTop).rank,se.maxRank=D.node(se.borderBottom).rank,L=e.max(L,se.maxRank))}),D.graph().maxRank=L}function Y(D){e.forEach(D.nodes(),function(L){var K=D.node(L);K.dummy==="edge-proxy"&&(D.edge(K.e).labelRank=K.rank,D.removeNode(L))})}function R(D){var L=Number.POSITIVE_INFINITY,K=0,se=Number.POSITIVE_INFINITY,he=0,me=D.graph(),xe=me.marginx||0,Ee=me.marginy||0;function He(Fe){var Ie=Fe.x,be=Fe.y,ue=Fe.width,re=Fe.height;L=Math.min(L,Ie-ue/2),K=Math.max(K,Ie+ue/2),se=Math.min(se,be-re/2),he=Math.max(he,be+re/2)}e.forEach(D.nodes(),function(Fe){He(D.node(Fe))}),e.forEach(D.edges(),function(Fe){var Ie=D.edge(Fe);e.has(Ie,"x")&&He(Ie)}),L-=xe,se-=Ee,e.forEach(D.nodes(),function(Fe){var Ie=D.node(Fe);Ie.x-=L,Ie.y-=se}),e.forEach(D.edges(),function(Fe){var Ie=D.edge(Fe);e.forEach(Ie.points,function(be){be.x-=L,be.y-=se}),e.has(Ie,"x")&&(Ie.x-=L),e.has(Ie,"y")&&(Ie.y-=se)}),me.width=K-L+xe,me.height=he-se+Ee}function Q(D){e.forEach(D.edges(),function(L){var K=D.edge(L),se=D.node(L.v),he=D.node(L.w),me,xe;K.points?(me=K.points[0],xe=K.points[K.points.length-1]):(K.points=[],me=he,xe=se),K.points.unshift(v.intersectRect(se,me)),K.points.push(v.intersectRect(he,xe))})}function H(D){e.forEach(D.edges(),function(L){var K=D.edge(L);if(e.has(K,"x"))switch((K.labelpos==="l"||K.labelpos==="r")&&(K.width-=K.labeloffset),K.labelpos){case"l":K.x-=K.width/2+K.labeloffset;break;case"r":K.x+=K.width/2+K.labeloffset;break}})}function ne(D){e.forEach(D.edges(),function(L){var K=D.edge(L);K.reversed&&K.points.reverse()})}function X(D){e.forEach(D.nodes(),function(L){if(D.children(L).length){var K=D.node(L),se=D.node(K.borderTop),he=D.node(K.borderBottom),me=D.node(e.last(K.borderLeft)),xe=D.node(e.last(K.borderRight));K.width=Math.abs(xe.x-me.x),K.height=Math.abs(he.y-se.y),K.x=me.x+K.width/2,K.y=se.y+K.height/2}}),e.forEach(D.nodes(),function(L){D.node(L).dummy==="border"&&D.removeNode(L)})}function U(D){e.forEach(D.edges(),function(L){if(L.v===L.w){var K=D.node(L.v);K.selfEdges||(K.selfEdges=[]),K.selfEdges.push({e:L,label:D.edge(L)}),D.removeEdge(L)}})}function J(D){var L=v.buildLayerMatrix(D);e.forEach(L,function(K){var se=0;e.forEach(K,function(he,me){var xe=D.node(he);xe.order=me+se,e.forEach(xe.selfEdges,function(Ee){v.addDummyNode(D,"selfedge",{width:Ee.label.width,height:Ee.label.height,rank:xe.rank,order:me+ ++se,e:Ee.e,label:Ee.label},"_se")}),delete xe.selfEdges})})}function $(D){e.forEach(D.nodes(),function(L){var K=D.node(L);if(K.dummy==="selfedge"){var se=D.node(K.e.v),he=se.x+se.width/2,me=se.y,xe=K.x-he,Ee=se.height/2;D.setEdge(K.e,K.label),D.removeNode(L),K.label.points=[{x:he+2*xe/3,y:me-Ee},{x:he+5*xe/6,y:me-Ee},{x:he+xe,y:me},{x:he+5*xe/6,y:me+Ee},{x:he+2*xe/3,y:me+Ee}],K.label.x=K.x,K.label.y=K.y}})}function V(D,L){return e.mapValues(e.pick(D,L),Number)}function Z(D){var L={};return e.forEach(D,function(K,se){L[se.toLowerCase()]=K}),L}return wv}var xv,mC;function vB(){if(mC)return xv;mC=1;var e=vt(),t=fn(),n=cr().Graph;xv={debugOrdering:s};function s(i){var a=t.buildLayerMatrix(i),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(i.nodes(),function(u){l.setNode(u,{label:u}),l.setParent(u,"layer"+i.node(u).rank)}),e.forEach(i.edges(),function(u){l.setEdge(u.v,u.w,{},u.name)}),e.forEach(a,function(u,h){var p="layer"+h;l.setNode(p,{rank:"same"}),e.reduce(u,function(f,g){return l.setEdge(f,g,{style:"invis"}),g})}),l}return xv}var bv,gC;function wB(){return gC||(gC=1,bv="0.8.5"),bv}var kv,yC;function xB(){return yC||(yC=1,kv={graphlib:cr(),layout:yB(),debug:vB(),util:{time:fn().time,notime:fn().notime},version:wB()}),kv}var bB=xB();const vC=lw(bB),Ki=240,Ou=130,Fi=74,ud=72,wC=Fi+ud;function kB(e,t){var s;let n=Ki;for(const i of e)n=Math.max(n,((s=t.get(i.id))==null?void 0:s.width)??Ki);return n}const VR=420,_B=2;function bl(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function SB(e,t){return((t==null?void 0:t.get(e))??0)>0?VR:0}function NB(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function kl(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??Ki)+SB(e,n),h:Math.max((s==null?void 0:s.height)??Ou,NB(e,n))}}function EB(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function CB(e,t,n,s,i,a){const l=new vC.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(_=>!i.has(_)),h=new Set(u);for(const _ of u){const{w:E,h:C}=kl(_,s,a);l.setNode(_,{width:E,height:C})}for(const _ of t)h.has(_.source)&&h.has(_.target)&&l.setEdge(_.source,_.target);vC.layout(l);const p=new Map;let f=1/0,g=1/0,v=-1/0,w=-1/0;for(const _ of u){const E=l.node(_);if(!E)continue;const C=s.get(_),j=(C==null?void 0:C.width)??Ki,I=(C==null?void 0:C.height)??Ou,O=kl(_,s,a),P=E.x-O.w/2,z=E.y-O.h/2;p.set(_,{x:P,y:z}),P<f&&(f=P),z<g&&(g=z),P+j>v&&(v=P+j),z+I>w&&(w=z+I)}if(Number.isFinite(f)&&Number.isFinite(g))for(const[_,E]of p)p.set(_,{x:E.x-f,y:E.y-g});const N=Number.isFinite(v)?v-f:0,b=Number.isFinite(w)?w-g:0;let k=null;for(const _ of e){const E=i.get(_);if(!E)continue;const C=s.get(_),j=(C==null?void 0:C.width)??Ki,I=(C==null?void 0:C.height)??Ou;k=k===null?{minX:E.x,minY:E.y,maxX:E.x+j,maxY:E.y+I}:{minX:Math.min(k.minX,E.x),minY:Math.min(k.minY,E.y),maxX:Math.max(k.maxX,E.x+j),maxY:Math.max(k.maxY,E.y+I)}}return{positions:p,width:N,height:b,pinnedBox:k}}function jB(e,t,n={}){const s=n.direction??"LR",i=n.pinned??new Map,a=n.measured??new Map,l=n.lanes,u=new Map;for(const _ of e){const E=bl(_),C=u.get(E);C?C.push(_.id):u.set(E,[_.id])}const p=Array.from(u.keys()).sort().map(_=>({sid:_,...CB(u.get(_),t,s,a,i,l)})),f=kB(e,a),g=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,v=_=>{const E=[[]];let C=0;for(const j of p)E.length<_&&C>0&&C+j.height>g&&(E.push([]),C=0),E[E.length-1].push(j),C+=j.height+wC;return E},w=_=>_.reduce((E,C)=>Math.max(E,C.width),0)+VR;let N=v(n.availableWidth?_B:1);N.length>1&&N.reduce((E,C)=>E+w(C),0)+f*(N.length-1)>(n.availableWidth??0)&&(N=v(1));const b=new Map;let k=0;for(const _ of N){const E=w(_);let C=0;for(const{positions:j,height:I,pinnedBox:O}of _){for(const[z,M]of j)b.set(z,{x:M.x+k,y:M.y+C});let P=C+I;O&&O.maxY>P&&O.minX<k+E&&k<O.maxX&&(P=O.maxY),C=P+wC}k+=E+f}return e.map(_=>{const E=i.get(_.id);if(E)return{..._,position:E};const C=b.get(_.id);return C?{..._,position:C}:_})}function TB(e,t,n,s,i){const l=Fi+ud,u=60,h=w=>kl(w,s,i),p=new Map(e.map(w=>[w.id,bl(w)])),f=[],g=e.map(w=>({id:w.id,pos:n.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,N)=>w.pos.y-N.pos.y||w.pos.x-N.pos.x||w.id.localeCompare(N.id)),v=[];for(const{id:w,pos:N}of g){const{w:b,h:k}=h(w),_=p.get(w)??"_default";if(n.has(w)){f.push({x:N.x,y:N.y,w:b,h:k,sid:_});continue}let E=N.y;for(let C=0;C<f.length+1;C++){const j=f.find(I=>{const O=I.sid===_?24:u,P=I.sid===_?24:l;return N.x<I.x+I.w+O&&I.x<N.x+b+O&&E<I.y+I.h+P&&I.y<E+k+P});if(!j)break;E=j.y+j.h+(j.sid===_?24:l)}E!==N.y&&(t.set(w,{x:N.x,y:E}),v.push(w)),f.push({x:N.x,y:E,w:b,h:k,sid:_})}return v}function RB(e,t,n,s,i,a){const l=b=>kl(b,s,a),u=b=>n.get(b)??t.get(b),h=new Map;for(const b of e){if(!u(b.id))continue;const k=bl(b),_=h.get(k);_?_.push(b):h.set(k,[b])}const p=new Set;for(const[b,k]of h)k.every(_=>i.has(_.id)&&!n.has(_.id))&&p.add(b);const f=new Map,g=[];for(const b of e){const k=u(b.id);if(!k)continue;const{w:_,h:E}=l(b.id),C=bl(b);p.has(C)?(f.get(C)??f.set(C,[]).get(C)).push(b):g.push({x:k.x,y:k.y,w:_,h:E})}if(f.size===0)return[];const v=Fi+ud,w=(b,k,_,E)=>g.some(C=>b<C.x+C.w+Fi&&C.x<b+_+Fi&&k<C.y+C.h+v&&C.y<k+E+v),N=[];for(const b of[...f.keys()].sort()){const k=f.get(b);let _=1/0,E=1/0,C=-1/0,j=-1/0;for(const q of k){const G=u(q.id),{w:Y,h:R}=l(q.id);_=Math.min(_,G.x),E=Math.min(E,G.y),C=Math.max(C,G.x+Y),j=Math.max(j,G.y+R)}const I=C-_,O=j-E,P=[...new Set(g.map(q=>Math.round(q.x)))].sort((q,G)=>q-G),z=P.length?P:[_],M=[0,...g.map(q=>q.y+q.h+v)].sort((q,G)=>q-G);let A=null;e:for(const q of z)for(const G of M){if(G>=E)break;if(!w(q,G,I,O)){A={x:q,y:G};break e}}if(A){const q=A.x-_,G=A.y-E;for(const Y of k){const R=u(Y.id);t.set(Y.id,{x:R.x+q,y:R.y+G})}N.push(b)}for(const q of k){const G=u(q.id),{w:Y,h:R}=l(q.id);g.push({x:G.x,y:G.y,w:Y,h:R})}}return N}function AB(e,t,n,s,i,a=!1,l){const p=Fi+ud+1,f=8,g=1.75,v=200,w=.7,N=.01,b=A=>kl(A,s,l),k=A=>n.get(A)??t.get(A),_=new Map;for(const A of e){if(!k(A.id))continue;const q=bl(A),G=_.get(q);G?G.push(A):_.set(q,[A])}const E=[],C=new Set,j=new Set,I=i.size===0;for(const A of[..._.keys()].sort()){const q=_.get(A);let G=1/0,Y=1/0,R=-1/0,Q=-1/0,H=!1;for(const J of q){const $=k(J.id),{w:V,h:Z}=b(J.id);G=Math.min(G,$.x),Y=Math.min(Y,$.y),R=Math.max(R,$.x+V),Q=Math.max(Q,$.y+Z),n.has(J.id)&&(H=!0)}const ne=R-G,X=Q-Y;j.add(A);const U=i.get(A);U&&(ne>U.w+f||X>U.h+f)&&C.add(A),i.set(A,{w:ne,h:X}),E.push({sid:A,members:q.map(J=>J.id),x:G,y:Y,w:ne,h:X,anchored:H,mass:1})}for(const A of[...i.keys()])j.has(A)||i.delete(A);if(a||I)return[];let O=!1;for(let A=0;A<E.length&&!O;A++)for(let q=A+1;q<E.length;q++){const G=E[A],Y=E[q];if(!(G.anchored&&Y.anchored)&&Math.abs(G.x+G.w/2-(Y.x+Y.w/2))<(G.w+Y.w)/2+61&&Math.abs(G.y+G.h/2-(Y.y+Y.h/2))<(G.h+Y.h)/2+p){O=!0;break}}if(C.size===0&&!O)return[];if(C.size>0)for(const A of E)C.has(A.sid)&&(A.mass=8);else for(const A of E)A.mass=Math.max(1,A.w*A.h/(Ki*Ou));const P=new Map(E.map(A=>[A.sid,A.x])),z=new Map(E.map(A=>[A.sid,A.y]));for(let A=0;A<v;A++){const q=new Map,G=new Map;let Y=0;for(let R=0;R<E.length;R++)for(let Q=R+1;Q<E.length;Q++){const H=E[R],ne=E[Q];if(H.anchored&&ne.anchored)continue;const X=H.x+H.w/2,U=H.y+H.h/2,J=ne.x+ne.w/2,$=ne.y+ne.h/2,V=(H.w+ne.w)/2+61-Math.abs(X-J),Z=(H.h+ne.h)/2+p-Math.abs(U-$);if(V<=0||Z<=0)continue;const D=(Pe,Ue)=>!Pe.anchored&&!(Ue<0&&Pe.x<=0),L=(Pe,Ue)=>!Pe.anchored&&!(Ue<0&&Pe.y<=0),K=(Pe,Ue,Ge)=>{const it=Pe===Ue,ke=it?H.sid<ne.sid?-1:1:Math.sign(Pe-Ue);return Ge(H,ke)||Ge(ne,-ke)?ke:it&&(Ge(H,-ke)||Ge(ne,ke))?-ke:0},se=K(X,J,D),he=K(U,$,L),me=se!==0,xe=he!==0;if(!me&&!xe)continue;const Ee=me&&(!xe||V*g<Z),[He,Fe,Ie,be]=Ee?[se,V,q,D]:[he,Z,G,L],ue=be(H,He),re=be(ne,-He),pe=H.mass,Oe=ne.mass,nt=ue?re?Oe/(pe+Oe):1:0,st=re?ue?pe/(pe+Oe):1:0,Xe=Fe*w;Ie.set(H.sid,(Ie.get(H.sid)??0)+He*Xe*nt),Ie.set(ne.sid,(Ie.get(ne.sid)??0)-He*Xe*st),Y+=Xe}for(const R of E)R.anchored||(R.x=Math.max(0,R.x+(q.get(R.sid)??0)),R.y=Math.max(0,R.y+(G.get(R.sid)??0)));if(Y<N)break}const M=[];for(const A of E){const q=A.x-P.get(A.sid),G=A.y-z.get(A.sid);if(!(Math.abs(q)<1&&Math.abs(G)<1)){for(const Y of A.members){if(n.has(Y))continue;const R=t.get(Y);R&&t.set(Y,{x:R.x+q,y:R.y+G})}M.push(A.sid)}}return M}const MB=600;function sw(e,t){return!(e.exitAt!=null&&t-e.exitAt>MB||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function IB(e,t){const n=new Set;for(const s of e.agents.values())sw(s,t)&&n.add(s.id);return n}function OB(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 PB(e,t,n=0){if(!e)return!1;for(const s of t)if(OB(e,s,n))return!0;return!1}const YR="sessionGroup";function $B(e,t){var s;if(e.type===YR)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const KR=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function xC(e){const t={};for(const n of KR)t[n]=e(n);return t}function LB(e){return t=>e[t]??""}function qB(e,t){return KR.every(n=>e[n]===t[n])}function DB(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[i,a]of e.positions)n.set(i,a),t.has(i)&&s.set(i,a);return{positions:n,pinned:s}}const FB=1200,zB=1e3;function bC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<FB?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<zB}function _v({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function BB(e,t,n){const s=e.x*t.zoom+t.x,i=e.y*t.zoom+t.y,a=(e.x+e.width)*t.zoom+t.x,l=(e.y+e.height)*t.zoom+t.y;return a>0&&s<n.width&&l>0&&i<n.height}function UB({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 i of n)if(s=!0,BB(i,t,e))return!1;return s}const WB="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Sv="click for what's new";function HB(e){if(e.checkDisabled)return`${WB} · ${Sv}`;if(e.checking)return`Asking npm for the newest release… · ${Sv}`;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 · ${Sv}, and to check npm now`}function GB(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 VB(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 YB(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 ow={kind:"assumed",claude:!0,codex:!0};function KB(e){if(!e||typeof e!="object")return ow;const t=e.providers;if(!t||typeof t!="object")return ow;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Pu(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const kC=99;function XB(e){const t=Math.max(0,Math.floor(e));return t>kC?`${kC}+`:String(t)}const QB="Pause the canvas";function ZB(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 — ${Pu(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)":`${Pu(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function JB(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 XR="paused · full",e8=(e,t)=>t>0?XR:e>0?`paused · ${XB(e)}`:"paused";function t8(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:e8(e.held,t),widest:XR,title:t>0?`Connected — the pause is full at ${Pu(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${Pu(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 _C(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const n8={agent:m3,sessionGroup:M3},QR="react-flow__node";function SC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,QR))===!0}function r8(e){try{const t=document.querySelector(`.${QR}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const s8=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),o8=420,hu=18,i8=200,a8=5*6e4,l8=6,c8=2*6e4,NC=400,o0="agent-dag.layout",i0="agent-dag.viewport",ZR="agent-dag.summariesDismissed",JR="agent-dag.sessionListOpen",eA="agent-dag.detailOpen",tA="agent-dag.usagePanelOpen",EC="agent-dag.accountsPanelOpen",Nv="agent-dag.versionNoticeDismissed",CC="agent-dag.oldNameNoticeDismissed",u8=15*6e4,Ev={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:"},jC="agent-dag.autoRestart",TC="agent-dag.bundleReloadedFor";function d8(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(JR)==="1"}catch{return!1}}function f8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(JR,e?"1":"0")}catch{}}function h8(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eA)==="1"}catch{return!1}}function p8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eA,e?"1":"0")}catch{}}function m8(){const e=Hu(tA);return e===null?!0:e==="1"}function g8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tA,e?"1":"0")}catch{}}function y8(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(ZR);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 RC(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(ZR,JSON.stringify(n))}catch{}}function v8(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(o0);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const i=Object.entries(n).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number");return{positions:i,pins:i.map(([a])=>a)}}return{positions:Object.entries(n.positions??{}).filter(([,i])=>i&&typeof i.x=="number"&&typeof i.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function Cv(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,i]of e)n[s]=i;for(const[s,i]of t)n[s]=i;window.localStorage.setItem(o0,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function w8(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(i0);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 x8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(i0,JSON.stringify(e))}catch{}}function AC(){if(!(typeof window>"u")){try{window.localStorage.removeItem(o0)}catch{}try{window.localStorage.removeItem(i0)}catch{}}}function b8(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const i={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(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}))}))},a=JSON.stringify(i,null,2),l=new Blob([a],{type:"application/json"}),u=URL.createObjectURL(l),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=u,h.download=`${Bt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(u),1e3)}const iw={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},aw={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},nA=vT;function k8(e,t,n,s,i,a,l,u,h,p,f,g,v,w,N,b,k,_){const E=[],C=[];for(const A of e.agents.values()){if(!k.has(A.id))continue;const q=A.exitAt!=null,G=b!=null&&!b.has(A.id),Y=[q?"rf-exiting":"",G?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,R=a.get(A.id);if(E.push({id:A.id,type:"agent",position:{x:0,y:0},data:{...A,now:t,onOpenContext:_},className:Y,...R?{width:R.width,height:R.height}:null}),A.parentId&&k.has(A.parentId)){const Q=jw(A.sessionId),H=q,ne=N.size>0&&(N.has(A.id)||N.has(A.parentId)),X=b!=null&&!b.has(A.id)&&!b.has(A.parentId),U=A.state==="active"?2:1.5,J=ne?U+1.5:U,$=H?.2:X?.12:1,V=["sess-edge",A.state==="active"?"sess-live":"sess-idle",H?"rf-edge-exiting":"",ne?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${A.parentId}->${A.id}`,source:A.parentId,target:A.id,animated:(A.state==="active"||ne)&&!H,type:"smoothstep",style:{"--session-hue":Q,strokeWidth:J,opacity:$,transition:"var(--edge-transition)"},className:V})}}const j=new Map;for(const A of e.agents.values())A.tools.length>0&&j.set(A.id,Math.min(4,A.tools.length));const I=`${v}#lanes:${EB(j)}`,O=E.filter(A=>b5(A.id,i,f,g));if(O.length>0||I!==w.current){if(O.length>0){const A=jB(E,C,{direction:"LR",pinned:i,measured:a,availableWidth:n,availableHeight:s,lanes:j});for(const q of A)WT(q.id,f,g)&&_5(q.id,q.position,f,g);RB(E,f,i,a,new Set(O.map(q=>q.id)),j)}TB(E,f,i,a,j),w.current=I}const P=AB(E,f,i,a,l,!h||p,j);P.length>0&&u(P),au(f,e.agents),au(g,e.agents),au(i,e.agents),au(a,v5(e.agents.values()));const z=[];let M=!1;for(const A of E){let q=i.get(A.id)??f.get(A.id);q||(q=k5(A.id,f,g),M=!0),z.push({...A,position:q})}return M&&(w.current=""),{nodes:z,edges:C}}function _8(){return d.jsx(Ew,{children:d.jsx(S8,{})})}function S8(){var ps,ka,_a,Sa;const e=Cl(),t=At(),n=S.useState(Wv)[0],s=S.useRef(n),[,i]=S.useState(0),a=S.useCallback(()=>i(F=>F+1),[]),[l,u]=S.useState(()=>new Set),[h,p]=S.useState(null),[f,g]=S.useState(null),v=S.useCallback((F,B)=>{u(le=>{if(!B)return new Set([F]);const de=new Set(le);return de.has(F)?de.delete(F):de.add(F),de}),p(le=>B&&le===F?le:F)},[]),w=S.useCallback(()=>{u(new Set),p(null)},[]),[N,b]=S.useState(null),[k,_]=S.useState(null),E=S.useCallback(F=>_(F),[]),[C,j]=S.useState(!1),[I,O]=S.useState(!1),P=S.useState(y8)[0],[z,M]=S.useState(d8);S.useEffect(()=>{f8(z)},[z]);const[A,q]=S.useState(h8);S.useEffect(()=>{p8(A)},[A]);const[G,Y]=S.useState(m8);S.useEffect(()=>{g8(G)},[G]);const[R,Q]=S.useState(()=>{try{const F=window.localStorage.getItem(EC);return F===null?!0:F==="1"}catch{return!0}});S.useEffect(()=>{try{window.localStorage.setItem(EC,R?"1":"0")}catch{}},[R]);const[H,ne]=S.useState(null);S.useEffect(()=>{let F=null;try{F=localStorage.getItem("agent-dag.sound")}catch{}ne(F===null?!0:F==="on")},[]);const X=S.useCallback(()=>{ne(F=>{var le;const B=F!==!0;try{localStorage.setItem("agent-dag.sound",B?"on":"off")}catch{}return B&&((le=Ee.current)==null||le.unlock()),B})},[]),U=S.useCallback(F=>{X()},[X]),J=S.useRef(U);J.current=U;const $=S.useRef(H);$.current=H;const[V,Z]=S.useState(()=>HD(Hu)),D=S.useRef(V);D.current=V;const L=S.useRef(null),K=S.useCallback((F,B=!1)=>{var le,de;if((le=Ee.current)==null||le.unlock(),L.current!==null&&clearTimeout(L.current),L.current=null,!B){(de=Ee.current)==null||de.play(F,!0);return}L.current=setTimeout(()=>{var _e;L.current=null,(_e=Ee.current)==null||_e.play(F,!0)},FD)},[]),se=S.useCallback((F,B)=>{Z(le=>{const de={level:xl(B.level??le[F].level),figure:DT(F,B.figure??le[F].figure)};try{localStorage.setItem(zT[F],String(de.level)),localStorage.setItem(BT[F],de.figure)}catch{}return{...le,[F]:de}}),K(F,!0)},[K]);S.useEffect(()=>()=>{L.current!==null&&clearTimeout(L.current)},[]);const[he,me]=S.useState(!1),xe=S.useRef(null),Ee=S.useRef(null),[He,Fe]=S.useState("locked");S.useEffect(()=>{const F=YD({enabled:()=>$.current===!0,prefs:()=>D.current,onState:Fe});Ee.current=F,Fe(F.state());const B=()=>F.unlock();return window.addEventListener("pointerdown",B,{once:!0,capture:!0}),window.addEventListener("keydown",B,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",B,{capture:!0}),window.removeEventListener("keydown",B,{capture:!0})}},[]);const[Ie,be]=S.useState(!1),[ue,re]=S.useState(null),[pe,Oe]=S.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Nv)??""}catch{return""}}),[nt,st]=S.useState(!1),Xe=S.useRef(0),[Pe,Ue]=S.useState(!1),Ge=S.useCallback((F=!1)=>(F&&(Xe.current=Date.now(),Ue(!0)),fetch(F?"/api/version?refresh=1":"/api/version").then(B=>B.ok?B.json():null).then(B=>{B&&re(B)}).catch(()=>{}).finally(()=>{F&&Ue(!1)})),[]),it=S.useCallback(()=>{Ge(Date.now()-Xe.current>=u8)},[Ge]);S.useEffect(()=>{Ge();const F=window.setInterval(it,5*6e4),B=()=>{document.visibilityState==="visible"&&it()};return document.addEventListener("visibilitychange",B),()=>{window.clearInterval(F),document.removeEventListener("visibilitychange",B)}},[Ge,it]),S.useEffect(()=>{Ie&&Ge()},[Ie,Ge]);const ke=(ue==null?void 0:ue.notice)??null,[ct,It]=S.useState(null),ae=S.useRef(!1);S.useEffect(()=>{if(ae.current)return;const F=o5(),B=i5(F),le=c5({stored:B,running:(ue==null?void 0:ue.running)??null,notes:H1,remembers:a5(F)});le.reason!=="no-version"&&(ae.current=!0,le.record&&l5(F,le.record),le.show.length&&It({entries:le.show,since:B,firstRun:le.reason==="welcome"}))},[ue==null?void 0:ue.running]);const Le=(ue==null?void 0:ue.running)??"3.8.5",ze=S.useMemo(()=>UT(H1,null,Le),[Le]),Ce=S.useCallback(()=>{It({entries:ze,since:null,firstRun:!1})},[ze]),[Ve,Ct]=S.useState(null),[rt,Te]=S.useState(ow);S.useEffect(()=>{let F=!1;return fetch("/api/health").then(B=>B.ok?B.json():null).then(B=>{F||(Te(KB(B)),!(!B||typeof B.workspace!="string")&&Ct(B.workspace))}).catch(()=>{}),()=>{F=!0}},[Ie]);const wt=S.useRef(rt);wt.current=rt;const dt=ke?`${ke.kind}:${ke.to}`:"",St=ke!=null&&pe!==dt,Sn=S.useCallback(()=>{Oe("");try{window.localStorage.setItem(Nv,"")}catch{}},[]),Fn=S.useCallback(()=>{if(ke){Oe(dt);try{window.localStorage.setItem(Nv,dt)}catch{}}},[ke,dt]),[Nn,To]=S.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(CC)??""}catch{return""}}),hn=ue!=null&&ue.invokedAs&&ue.invokedAs!==Bt?ue.invokedAs:null,Ro=hn!=null&&Nn!==hn,Ao=S.useCallback(()=>{if(hn){To(hn);try{window.localStorage.setItem(CC,hn)}catch{}}},[hn]),Ut=((ps=ue==null?void 0:ue.upgrade)==null?void 0:ps.state)??"idle",Tr=kD(ue==null?void 0:ue.upgrade),zn=S.useRef(!1),Ds=S.useCallback(async()=>{if(ar(zn.current||Ut==="running")){zn.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Ge(),zn.current=!1}},[Ut,Ge]);S.useEffect(()=>{if(Ut!=="running")return;const F=window.setInterval(Ge,3e3);return()=>window.clearInterval(F)},[Ut,Ge]);const Rr=S.useCallback(async()=>{var le;const F=ue==null?void 0:ue.command;if(!F)return;let B=!1;try{B=await Promise.race([((le=navigator.clipboard)==null?void 0:le.writeText(F).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{B=!1}if(!B)try{const de=document.createElement("textarea");de.value=F,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),B=document.execCommand("copy"),de.remove()}catch{B=!1}B&&(st(!0),window.setTimeout(()=>st(!1),1600))},[ue==null?void 0:ue.command]),na=S.useCallback(()=>{M(F=>(F||Q(!1),!F))},[]),fr=S.useCallback(()=>{Q(F=>(F||M(!1),!F))},[]),[Ar,hr]=S.useState(!1),[ns,Mo]=S.useState(!1),[Io,Oo]=S.useState(()=>{try{return Number(localStorage.getItem(K1))||0}catch{return 0}}),[En,Po]=S.useState([]),[Mr,$o]=S.useState(!1);S.useEffect(()=>{let F=!0;const B=()=>{fetch("/api/browser-watch?live=0").then(de=>de.ok?de.json():null).then(de=>{var _e;!F||!(de!=null&&de.ok)||(Po(de.episodes??[]),$o(((_e=de.settings)==null?void 0:_e.enabled)===!0))}).catch(()=>{})};B();const le=setInterval(B,5*6e4);return()=>{F=!1,clearInterval(le)}},[]);const Bn=S.useMemo(()=>Q5(En,Io).length,[En,Io]),[Lo,Fs]=S.useState(0),zs=S.useRef(null),[qo,Do]=S.useState(!1),at=S.useRef(null),[ra,rs]=S.useState(0),Vt=S.useState(()=>j5({protect:F=>xL(s.current,F)}))[0],[Un,Fo]=S.useState(!1),ss=S.useCallback(()=>{const F=Vt.paused&&Vt.dropped>0,B=Vt.setPaused(!Vt.paused);F&&bL(s.current);for(const le of B)s.current=e1(s.current,le);Fo(Vt.paused)},[Vt]),[xt,rn]=S.useState(Date.now()),[Wn,pn]=S.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(jC)!=="0"}catch{return!0}}),dd=S.useCallback(()=>{pn(F=>{const B=!F;try{window.localStorage.setItem(jC,B?"1":"0")}catch{}return B})},[]),[Ir,zo]=S.useState(!1),[Bo,Uo]=S.useState("restart"),[os,Bs]=S.useState(null),is=S.useRef(!1),Dl=S.useRef(null),Wo=S.useRef(0),Us=S.useCallback(async F=>{if(!ar(is.current))return;const B=(F==null?void 0:F.upgrade)===!0;is.current=!0,Dl.current=Tr;const le=++Wo.current;Uo(B?"npx":"restart"),zo(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ke==null?void 0:ke.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:B})})}catch{}window.setTimeout(()=>{if(Wo.current===le&&is.current){is.current=!1,zo(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},B?18e4:3e4)},[ke==null?void 0:ke.to,Tr]),Ho=S.useRef(null);S.useEffect(()=>{let F=!1;for(const le of s.current.agents.values())if(le.state==="active"){F=!0;break}const B=SD({enabled:Wn,kind:ke==null?void 0:ke.kind,canRestart:(ue==null?void 0:ue.canRestart)===!0,busy:F,idleSince:Ho.current,now:xt});Ho.current=B.idleSince,B.restart&&Us()},[Wn,ke==null?void 0:ke.kind,ue==null?void 0:ue.canRestart,xt,Us]),S.useEffect(()=>{const F=ue==null?void 0:ue.running;let B=null,le=null;try{B=window.sessionStorage.getItem("agent-dag.restartPending"),le=window.sessionStorage.getItem(TC)}catch{return}const de=bD({bundle:"3.8.5",running:F,pending:B,lastTried:le});if(de==="reload"){try{window.sessionStorage.setItem(TC,F??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}is.current=!1,zo(!1),Bs(F??null);const _e=window.setTimeout(()=>Bs(null),6e3);return()=>window.clearTimeout(_e)},[ue==null?void 0:ue.running]),S.useEffect(()=>{if(Ir&&_D({asked:Dl.current,reported:Tr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}is.current=!1,zo(!1)}},[Ir,Tr]);const as=S.useState(()=>DB(v8()))[0],Zt=S.useRef(as.pinned),ls=S.useRef(null),Qe=S.useState(()=>w8())[0],[sa,Fl]=S.useState(()=>new Set),[Or,oa]=S.useState(R5),[Hn,zl]=S.useState(()=>xC(_C)),Go=S.useMemo(()=>LB(Hn),[Hn]),Vo=S.useCallback(F=>$B(F,Go),[Go]),pr=S.useMemo(()=>({background:Hn["--panel"],border:`1px solid ${Hn["--line"]}`,borderRadius:8}),[Hn]),[Gn,mr]=S.useState(!1);S.useEffect(()=>{document.documentElement.dataset.theme=Or;try{window.localStorage.setItem(HT,Or)}catch{}zl(F=>{const B=xC(_C);return qB(F,B)?F:B})},[Or]);const mn=S.useCallback((F,B)=>{if(_v({durationMs:B,documentHidden:document.hidden})){e.setViewport(F,{duration:B});return}const{d3Zoom:le,d3Selection:de}=t.getState(),_e=de==null?void 0:de.property("__zoom");if(le&&de&&_e&&_e.k>0&&F.zoom>0){le.transform(de,_e.scale(F.zoom/_e.k).translate((F.x-_e.x)/F.zoom,(F.y-_e.y)/F.zoom));return}e.setViewport(F,{duration:0})},[e,t]),Vn=S.useRef(null);S.useEffect(()=>{if(!Qe)return;const F=window.setTimeout(()=>{try{mn(Qe,0)}catch{}Kn.current=Date.now()},60);return()=>window.clearTimeout(F)},[mn,Qe]);const Yn=S.useRef(!0);S.useEffect(()=>{const F=new EventSource("/events"),B=E5(a,{now:()=>Date.now(),setTimeout:(le,de)=>window.setTimeout(le,de),clearTimeout:le=>window.clearTimeout(le)});return F.addEventListener("open",()=>{be(!0),mr(!0)}),F.addEventListener("error",()=>be(!1)),F.addEventListener("replay-end",()=>{Yn.current=!1,B.flush()}),F.addEventListener("hook",le=>{var de;try{const _e=JSON.parse(le.data);if(!Vt.accept(_e))return;s.current=e1(s.current,_e);const Re=_e.replay===!0||Yn.current||Date.now()-_e.receivedAt>3e4;Re?B.replay():B.live();const Be=VD(_e,Re);Be&&((de=Ee.current)==null||de.play(Be))}catch{}}),()=>{F.close(),B.cancel()}},[a]),S.useEffect(()=>{const F=setInterval(()=>{const B=Date.now();rn(B);let le=kL(s.current,B,Jb);_L(s.current,B,Jb)&&(le=!0),vL(s.current,B,i8,a8)&&(le=!0),wL(s.current,B,l8,c8)&&(le=!0),u(de=>y5(de,s.current.agents)),p(de=>de!=null&&!s.current.agents.has(de)?null:de),_(de=>de!=null&&!s.current.agents.has(de)?null:de),b(de=>de!=null&&!s.current.agents.has(de)?null:de),le&&a()},250);return()=>clearInterval(F)},[a]);const ia=S.useRef(null),Kn=S.useRef(0),Ws=420,Cn=S.useCallback((F=500)=>{try{const Re=document.querySelector(".canvas-wrap"),Be=Array.from(document.querySelectorAll(".react-flow__node")).filter(ut=>ut.offsetWidth>0);if(!Re||Be.length===0)return;const Ze=Re.getBoundingClientRect(),ht=e.getViewport();if(!Number.isFinite(ht.zoom)||ht.zoom<=0)return;const ot=ut=>(ut-Ze.left-ht.x)/ht.zoom,Pt=ut=>(ut-Ze.top-ht.y)/ht.zoom,ms=Be.map(ut=>ut.getBoundingClientRect()),Na=Math.min(...ms.map(ut=>ot(ut.left))),si=Math.max(...ms.map(ut=>ot(ut.right))),Ea=Math.min(...ms.map(ut=>Pt(ut.top))),rc=Math.max(...ms.map(ut=>Pt(ut.bottom))),Ca=si-Na,oi=rc-Ea;if(!(Ca>0&&oi>0))return;const gs=Math.max(.2,Math.min(1,(Ze.width-160)/(Ca+Ws)*.86,(Ze.height-160)/oi*.86)),ys={x:80-Na*gs,y:Math.max(80,(Ze.height-oi*gs)/2)-Ea*gs,zoom:gs};mn(ys,F),Kn.current=Date.now(),Vn.current=_v({durationMs:F,documentHidden:document.hidden})?{target:ys,until:Date.now()+F+60}:null,window.setTimeout(()=>{var ut;try{((ut=Vn.current)==null?void 0:ut.target)===ys&&(Vn.current=null);const ii=e.getViewport();(Math.abs(ii.zoom-gs)>.01||Math.abs(ii.x-ys.x)>2)&&mn(ys,0)}catch{}},F+60)}catch{}},[e,mn]);S.useEffect(()=>{const F=()=>{if(!document.hidden)return;const B=Vn.current;if(Vn.current=null,!(!B||Date.now()>B.until)){try{mn(B.target,0)}catch{}Kn.current=Date.now()}};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[mn]);const Yo=S.useRef(""),cs=S.useRef(null),aa=S.useRef(0),Ko=S.useCallback(()=>{aa.current=Date.now()},[]),Pr=S.useRef(null),us=S.useRef(0),gr=S.useCallback(()=>{us.current=Date.now()},[]),Hs=S.useCallback(F=>({hasSourceEvent:!!F,at:Date.now(),lastDeckFitAt:Kn.current,lastCanvasInputAt:us.current}),[]),la="agent-dag.autoFitDisabled",Bl=S.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(la)==="1"}catch{return!1}})[0],yr=S.useRef(Bl),[Gs,Xo]=S.useState(Bl),Qo=S.useCallback(()=>{if(!yr.current){yr.current=!0,Xo(!0);try{window.localStorage.setItem(la,"1")}catch{}}},[]),vr=S.useCallback(()=>{yr.current=!1,Xo(!1);try{window.localStorage.removeItem(la)}catch{}Cn(400)},[e,Cn]);S.useEffect(()=>{const F=setInterval(()=>{if(yr.current||Date.now()-aa.current<800)return;const B=s.current,le=Date.now(),de=[];for(const Re of B.agents.values())sw(Re,le)&&de.push({id:Re.id});if(de.length===0)return;const _e=[];for(const{id:Re}of de){const Be=Xn.current.get(Re),Ze=Zt.current.get(Re)??Ot.current.get(Re);!Be||!Ze||_e.push({x:Ze.x,y:Ze.y,width:Be.width,height:Be.height})}UB({pane:Pr.current,viewport:e.getViewport(),boxes:_e})&&Cn(600)},1500);return()=>clearInterval(F)},[e]);const Vs=S.useRef(!1),Xn=S.useRef(new Map),ca=S.useRef(0),Zo=S.useCallback(F=>{const B=Xn.current;let le=!1;for(const de of F.nodeInternals.values()){const _e=de.width,Re=de.height;if(_e==null||Re==null)continue;const Be=B.get(de.id);Be?(Math.abs(Be.height-Re)>4||Math.abs(Be.width-_e)>4)&&(B.set(de.id,{width:_e,height:Re}),le=!0):(B.set(de.id,{width:_e,height:Re}),le=!0)}return le&&(ca.current+=1),ca.current},[]),Ys=lt(Zo),[ua,Jt]=S.useState(0);S.useEffect(()=>{let F=0;const B=()=>{const de=Xn.current;let _e=!1;for(const Re of document.querySelectorAll(".react-flow__node[data-id]")){const Be=Re.getAttribute("data-id");if(!Be)continue;const Ze=Re.offsetWidth,ht=Re.offsetHeight;if(!Ze||!ht)continue;const ot=de.get(Be);(!ot||Math.abs(ot.width-Ze)>4||Math.abs(ot.height-ht)>4)&&(de.set(Be,{width:Ze,height:ht}),_e=!0)}_e&&Jt(Re=>Re+1)};if(Vs.current)return;let le=0;return document.visibilityState==="hidden"?le=window.setTimeout(B,32):F=requestAnimationFrame(B),()=>{cancelAnimationFrame(F),window.clearTimeout(le)}});const Ot=S.useRef(as.positions),da=S.useRef(new Set),$r=S.useRef(""),ds=S.useMemo(()=>{const F=[];for(const B of s.current.agents.values())sw(B,xt)&&F.push(B.id+(B.parentId?`>${B.parentId}`:""));return F.sort(),`${F.join("|")}#sv${Ys}.${ua}`},[s.current,s.current.revision,xt,Ys,ua]),Lr=S.useRef(null);S.useEffect(()=>(Lr.current!=null&&window.clearTimeout(Lr.current),Lr.current=window.setTimeout(()=>{Cv(Ot.current,Zt.current)},1500),()=>{Lr.current!=null&&window.clearTimeout(Lr.current)}),[ds]),S.useEffect(()=>{if(Yo.current===ds)return;const F=Yo.current;if(Yo.current=ds,!F||yr.current)return;Date.now()-Kn.current>1200&&Cn(400),ia.current&&window.clearTimeout(ia.current),ia.current=window.setTimeout(()=>{yr.current||Cn(500)},280)},[ds,e,Cn]);const Ks=S.useMemo(()=>x5(s.current,l),[s.current,s.current.revision,l]),qr=S.useMemo(()=>IB(s.current,xt),[s.current,s.current.revision,xt]),Xs=S.useRef(null),[Qs,Ul]=S.useState({w:0,h:0});S.useEffect(()=>{const F=Xs.current;if(!F||typeof ResizeObserver>"u")return;const B=new ResizeObserver(le=>{var _e;const de=(_e=le[0])==null?void 0:_e.contentRect;de&&(Pr.current={width:de.width,height:de.height},Ul(Re=>Math.abs(Re.w-de.width)>40||Math.abs(Re.h-de.height)>40?{w:de.width,h:de.height}:Re))});return B.observe(F),Pr.current={width:F.clientWidth,height:F.clientHeight},Ul({w:F.clientWidth,h:F.clientHeight}),()=>B.disconnect()},[]);const fd=S.useCallback(F=>{var le,de;const B=F.target;!(B!=null&&B.closest)||B.closest(s8)!==F.currentTarget||(F.preventDefault(),(de=(le=document.activeElement)==null?void 0:le.blur)==null||de.call(le))},[]),hd=S.useRef(new Map),[Jo,pd]=S.useState(!1);S.useEffect(()=>{const F=window.setTimeout(()=>pd(!0),2500);return()=>window.clearTimeout(F)},[]);const[md,fa]=S.useState(!1),wr=S.useRef(null),[ha,pa]=S.useState(!1),gd=S.useCallback(()=>{wr.current&&(window.clearTimeout(wr.current),wr.current=null),fa(!1)},[]),yd=S.useCallback(F=>{F.length!==0&&queueMicrotask(()=>{fa(!0),wr.current&&window.clearTimeout(wr.current),wr.current=window.setTimeout(()=>fa(!1),o8+80)})},[]);S.useEffect(()=>()=>{wr.current&&window.clearTimeout(wr.current)},[]);const Wl=Qs.w>0?Qs.w*.92:0,Hl=Qs.h>0?Qs.h:0,{nodes:jn,edges:vd}=S.useMemo(()=>k8(s.current,xt,Wl,Hl,Zt.current,Xn.current,hd.current,yd,Jo,ha,Ot.current,da.current,ds,$r,l,Ks,qr,E),[s.current,s.current.revision,xt,Wl,Hl,Jo,ha,ds,l,Ks,qr,E,Lo]),Gl=S.useMemo(()=>{const F=new Map;for(const le of jn){const de=le.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const _e=le.width,Re=le.height;if(_e==null||Re==null)continue;const Be=le.position.x,Ze=le.position.y,ht=Be+_e,ot=Ze+Re,Pt=F.get(de.sessionId);Pt?(Pt.minX=Math.min(Pt.minX,Be),Pt.minY=Math.min(Pt.minY,Ze),Pt.maxX=Math.max(Pt.maxX,ht),Pt.maxY=Math.max(Pt.maxY,ot)):F.set(de.sessionId,{minX:Be,minY:Ze,maxX:ht,maxY:ot})}const B=[];for(const[le,de]of F){const _e=de.maxX-de.minX+hu*2,Re=de.maxY-de.minY+hu*2;B.push({id:`group:${le}`,type:YR,position:{x:de.minX-hu,y:de.minY-hu},data:{sessionId:le,w:_e,h:Re},width:_e,height:Re,style:{width:_e,height:Re},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return B},[jn,xt]),wd=S.useMemo(()=>{const F=[...Gl,...jn],B=at.current;return!B||B.size===0?F:F.map(le=>{const de=B.get(le.id);return de?{...le,position:de}:le})},[Gl,jn,ra]),Zs=S.useMemo(()=>{const F=new Set;for(const B of s.current.agents.values())for(const le of B.tools)F.add(nA(le.name));return Object.keys(iw).filter(B=>F.has(B))},[s.current,s.current.revision]);S.useEffect(()=>{if(Zs.length<=1){Do(!1);return}let F=0;const B=()=>{const le=zs.current;if(le&&!document.hidden){const de=le.getBoundingClientRect(),_e=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Be=>Be.getBoundingClientRect()),Re=PB(de,_e,8);Do(Be=>Be===Re?Be:Re)}F=window.setTimeout(B,300)};return B(),()=>window.clearTimeout(F)},[Zs.length]);const xd=S.useCallback(F=>{Fl(B=>{const le=new Set(B);return le.has(F)?le.delete(F):le.add(F),le})},[]),en=h?s.current.agents.get(h):null,ma=f?Array.from(s.current.agents.values()).flatMap(F=>F.tools).find(F=>F.id===f)??null:null,Vl=S.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=Wv(),Zt.current.clear(),Xn.current.clear(),Ot.current.clear(),$r.current="",AC(),w(),a()},[a,w]),Yl=S.useRef(C);Yl.current=C;const Kl=S.useRef(I);Kl.current=I;const ga=S.useRef(!1);ga.current=ma!=null||Ar||k!=null||N!=null||ns||I||ct!=null;const fs=S.useCallback(F=>{const B=ND(F,{confirmOpen:Yl.current,modalOpen:ga.current});B==="confirm"?j(!0):B==="clear"&&(j(!1),Vl())},[Vl]),Dr=S.useCallback(()=>{Zt.current.clear(),Ot.current.clear(),$r.current="",AC(),a(),window.setTimeout(()=>Cn(500),80)},[a,e,Cn]),Xl=S.useCallback(()=>Cn(500),[Cn]),Js=S.useRef(jn);Js.current=jn;const ya=S.useRef(h);ya.current=h;const ei=S.useCallback(F=>{const B=Js.current,le=f5(B.map(Re=>({id:Re.id,x:Re.position.x,y:Re.position.y})),ya.current,F),de=le?B.find(Re=>Re.id===le):void 0;if(!de)return;const _e=SC(document.activeElement);v(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}Kn.current=Date.now(),_e&&r8(de.id)},30)},[v,e]),ti=S.useCallback(F=>{v(F,!1),window.setTimeout(()=>{try{const B=Js.current.find(le=>le.id===F);B&&e.fitView({padding:.3,duration:500,nodes:[B]}),Kn.current=Date.now()}catch{}},60)},[v,e]);S.useEffect(()=>{const F=B=>{var Ze,ht;const le=B.target,de={tagName:le==null?void 0:le.tagName,isContentEditable:le==null?void 0:le.isContentEditable,role:(Ze=le==null?void 0:le.getAttribute)==null?void 0:Ze.call(le,"role"),type:le==null?void 0:le.type};if(B.key==="Escape"){const ot=ZL({overlayOpen:qi.depth()>0,panelOnTop:qi.topIsPanel(),typing:Mw(de)});ot==="dismiss"?qi.dismissTop():ot==="blur"?le==null||le.blur():(g5(de)&&(le==null||le.blur()),w());return}if(Aw(B))return;const _e=SC(le)?(ht=le==null?void 0:le.getAttribute)==null?void 0:ht.call(le,"data-id"):null,Re=_e&&Js.current.some(ot=>ot.id===_e)?_e:null,Be=p5(B,Re);if(Be.kind==="activate"){B.preventDefault(),v(Be.nodeId,Be.additive);return}Be.kind!=="node"&&(Be.nodeId==null&&i3(de)||a3({key:B.key,modalOpen:ga.current,sheetOpen:Kl.current})||(B.key===" "&&(B.preventDefault(),ss()),(B.key==="c"||B.key==="C")&&fs("shortcut"),(B.key==="r"||B.key==="R")&&Dr(),(B.key==="f"||B.key==="F")&&Xl(),(B.key==="l"||B.key==="L")&&na(),(B.key==="h"||B.key==="H")&&hr(ot=>!ot),(B.key==="u"||B.key==="U")&&Y(ot=>!ot),(B.key==="a"||B.key==="A")&&wt.current.claude&&fr(),(B.key==="j"||B.key==="J")&&ei(1),(B.key==="k"||B.key==="K")&&ei(-1),(B.key==="t"||B.key==="T")&&oa(ot=>ot==="dark"?"light":"dark"),(B.key==="m"||B.key==="M")&&wt.current.claude&&$.current!==null&&J.current(B.shiftKey),B.key==="?"&&O(ot=>!ot)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[fs,Dr,Xl,w,v,ei,ss]);const ni=s.current.agents.size,bt=S.useMemo(()=>UL(s.current.agents.values()),[s.current,s.current.revision]),Ql=S.useMemo(()=>WL(s.current.agents.values()),[s.current,s.current.revision]),Zl=S.useRef(null);S.useEffect(()=>{const F=A5({waiting:bt.length,running:Ql,connected:Ie}),B=Zl.current;if(Zl.current=F,(B==null?void 0:B.title)!==F.title&&(document.title=F.title),(B==null?void 0:B.icon)!==F.icon){const le=document.querySelector('link[rel="icon"]');le&&(le.href=M5[F.icon])}},[bt.length,Ql,Ie]);const[bd,Jl]=S.useState(""),va=O5(bt);S.useEffect(()=>{Jl(F=>P5(F,va))},[va]);const[xr,eo]=S.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Fr,hs]=S.useState(null),[kd,ec]=S.useState(!1),[Qn,to]=S.useState(!0),[tc,wa]=S.useState(!1);S.useEffect(()=>{let F=!0;return fetch("/api/prefs").then(B=>B.ok?B.json():null).then(B=>{var le;!F||!(B!=null&&B.ok)||(to(((le=B.prefs)==null?void 0:le.notifications)!==!1),wa(B.notificationsVetoed===!0))}).catch(()=>{}),()=>{F=!1}},[]);const nc=S.useCallback(()=>{const F=!Qn;to(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:F})}).then(B=>B.ok?B.json():null).then(B=>{var le;B!=null&&B.ok&&(to(((le=B.prefs)==null?void 0:le.notifications)!==!1),wa(B.notificationsVetoed===!0))}).catch(()=>{})},[Qn]),xa=KL(xr,typeof Notification<"u");S.useEffect(()=>{xa&&Qn&&bt.length>0&&ec(!0)},[xa,Qn,bt.length]),S.useEffect(()=>{if(!Fr)return;const B=setTimeout(()=>hs(null),Fr==="blocked"?8e3:4e3);return()=>clearTimeout(B)},[Fr]);const _d=S.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(F=>{const B=F;eo(B),B==="granted"?hs("on"):B==="denied"&&hs("blocked")})},[]),ri=S.useRef(new Set),ba=S.useRef(null),gn=bt.map(F=>Wu(F.id,F.waiting)).join("|");return S.useEffect(()=>{YL(ba.current,xr)&&(ba.current=xr,ri.current=r1(bt))},[xr]),S.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||ba.current===null)return;const F=typeof document>"u"||!document.hidden,B=GL(bt,ri.current,F,Qn);for(const le of B)try{const de=new Notification(le.title,{body:le.body,tag:le.key});de.onclick=()=>{window.focus(),ti(le.sessionId),de.close()}}catch{}ri.current=F?r1(bt):VL(bt,B,ri.current)},[gn]),d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),d.jsxs("header",{className:"topbar",children:[d.jsxs("div",{className:"readout",children:[d.jsxs("div",{className:"brand",children:[d.jsx("span",{className:"logo"}),d.jsx("h1",{children:Bt}),ke?d.jsxs("button",{type:"button",className:"v stale",onClick:()=>{Ce(),Sn()},"aria-haspopup":"dialog","aria-label":VB({...ke,open:St}),title:ke.kind==="restart"?`Running v${ke.from}; v${ke.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${ke.from}; v${ke.to} is on npm · click for what's new`,children:["v",ke.from,d.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const F={running:Le,latest:ue==null?void 0:ue.latest,latestPending:ue==null?void 0:ue.latestPending,checkedAgo:ue!=null&&ue.checkedAt?Xv(xt-ue.checkedAt):null,checkDisabled:ue==null?void 0:ue.checkDisabled,checking:Pe};return d.jsxs("button",{type:"button",className:Pe?"v checking":"v",onClick:()=>{Ce(),Ge(!0)},"aria-busy":Pe||void 0,"aria-haspopup":"dialog","aria-label":GB(F),title:HB(F),children:["v",F.running]})})()]}),d.jsxs("span",{className:"status",children:[(()=>{const F=t8({connected:Ie,paused:Un,held:Vt.size,dropped:Vt.dropped});return F.resting?null:d.jsx("span",{className:`pill ${F.tone}`,title:F.title,children:d.jsxs("span",{className:"pill-box",children:[d.jsx("span",{className:"pill-widest","aria-hidden":!0,children:F.widest}),d.jsx("span",{className:"pill-label",children:F.label})]})})})(),d.jsx(g4,{usageOpen:G})]}),d.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:bd}),bt.length>0&&d.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>ti(bt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
197
201
  ${bt.map(F=>` ${F.label}: ${vl(F.waiting)} (${Xv(xt-F.waiting.since)})`).join(`
198
202
  `)}`,"aria-label":`${bt.length} session${bt.length===1?"":"s"} waiting for you`,children:[d.jsx("span",{className:"ap-pulse","aria-hidden":!0}),d.jsx("b",{children:bt.length})," waiting"]}),kd&&xa&&Qn&&d.jsx("button",{type:"button",className:"notify-ask",onClick:_d,title:"Get a system notification when a session blocks on you, so the deck can reach you with this tab in the background",children:"notify me"}),Fr&&d.jsx("span",{className:Fr==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:Fr==="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:Fr==="on"?"notifications on":"notifications blocked"})]}),en&&(()=>{const F=bn(en),B=Math.max(0,((en.endedAt??xt)-en.startedAt)/1e3),le=en.state==="active"?Rw(F.total,B):null,de=l.size-1;return d.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${en.label}`,onClick:()=>{try{const _e=jn.find(Re=>Re.id===en.id);_e&&e.fitView({padding:.35,duration:500,nodes:[_e]}),Kn.current=Date.now()}catch{}},children:[d.jsx("span",{className:`state-pill state-${en.state}`,children:en.state==="active"?"live":en.state}),d.jsx("span",{className:"selected-label",children:en.label}),F.total>0&&d.jsxs("span",{className:"selected-cost",children:[Je(F.total),le?d.jsxs("span",{className:"selected-rate",children:[" · ",le]}):null]}),de>0&&d.jsxs("span",{className:"selected-extra",children:["+",de]}),d.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:_e=>{_e.stopPropagation(),w()},children:"×"})]})})(),d.jsxs("div",{className:"actions",children:[d.jsxs("div",{className:"action-run",children:[d.jsx("button",{className:"btn icon-btn",onClick:()=>Y(F=>!F),title:`${G?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":G,"aria-controls":G?"usage-panel":void 0,children:"$"}),rt.claude&&d.jsx("button",{className:"btn icon-btn",onClick:fr,title:`${R?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":R,"aria-controls":R?"accounts-panel":void 0,children:d.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:[d.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),d.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),d.jsx("button",{className:"btn icon-btn",onClick:()=>hr(F=>!F),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[d.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),d.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),d.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),d.jsxs("button",{className:`btn icon-btn bw-btn${Bn>0?" has-findings":Mr?" watching":""}`,onClick:()=>Mo(F=>!F),title:Mr?"Browser watch — watching; the deck is keeping its own copy":"Browser watch — not watching; reading the browser's history live","aria-label":`Browser watch, ${Mr?"watching":"not watching"}`+(Bn>0?`, ${Bn} unread`:""),"aria-haspopup":"dialog",children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:[d.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"}),Mr||Bn>0?d.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):d.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),Bn>0&&d.jsx("span",{className:"bw-badge","aria-hidden":!0,children:Bn})]})]}),d.jsxs("div",{className:"action-run",children:[rt.claude&&H!==null&&d.jsxs("div",{className:"sound-slot",children:[d.jsx("button",{ref:xe,className:"btn icon-btn",onClick:()=>me(F=>!F),...ir(!1),title:B5(rt,{on:H===!0,locked:He==="locked",prefs:V}),"aria-label":"Sound settings","aria-haspopup":"dialog","aria-expanded":he,"aria-controls":he?"sound-menu":void 0,children:d.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:[d.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),H?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),d.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M10 5.6l2.6 2.8"}),d.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),he&&d.jsx(XD,{onClose:()=>me(!1),soundOn:H===!0,onToggleSound:X,prefs:V,onLevel:(F,B)=>se(F,{level:B}),onFigure:(F,B)=>se(F,{figure:B}),onPreview:F=>K(F),notifyOn:Qn,onToggleNotify:nc,notifyVetoed:tc,openerRef:xe})]}),d.jsx("button",{className:"btn icon-btn",onClick:()=>oa(F=>F==="dark"?"light":"dark"),title:`Switch to ${Or==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:Or==="dark"?"☀":"☾"})]})]})]}),os?d.jsxs("div",{className:"ver-banner done",role:"status",children:[d.jsx("span",{className:"ver-dot"}),d.jsxs("strong",{children:["Restarted — now running v",os,"."]}),d.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):Gn&&!Ie?d.jsxs("div",{className:"conn-banner",role:"alert",children:[d.jsx("span",{className:"conn-dot"}),Ir?Bo==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Bt}…`:(()=>{const F=JB({connected:Ie,paused:Un});return d.jsxs(d.Fragment,{children:[`Lost connection to the ${Bt} server. Reconnecting…`,F&&d.jsx("span",{className:"conn-sub",children:F})]})})()]}):St&&ke?d.jsxs("div",{className:`ver-banner ${ke.kind}`,role:"status",children:[d.jsx("span",{className:"ver-dot"}),ke.kind==="restart"?d.jsxs(d.Fragment,{children:[d.jsxs("strong",{children:["v",ke.to," is installed — this deck still runs v",ke.from,"."]}),ue!=null&&ue.canRestart?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"ver-act",onClick:()=>Us(),...ir(Ir),title:"Stop this process and bring it back on the same port. The canvas replays from the event log.",children:Ir?"restarting…":"Restart now"}),d.jsxs("button",{type:"button",className:`ver-auto${Wn?" on":""}`,role:"switch","aria-checked":Wn,onClick:dd,title:Wn?"Restarts on its own once nothing has been running for 30 seconds. Click to require a click instead.":"Only restarts when you click. Click to let it restart itself while idle.",children:[d.jsx("i",{"aria-hidden":!0}),"auto when idle"]})]}):d.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):d.jsxs(d.Fragment,{children:[d.jsxs("strong",{children:[Bt," v",ke.to," is out — you are on v",ke.from,"."]}),(ue==null?void 0:ue.upgradeMode)==="install"&&Ut!=="failed"&&d.jsx("button",{type:"button",className:"ver-act",onClick:Ds,...ir(Ut==="running",Ut==="done"),title:`Runs ${((ka=ue==null?void 0:ue.upgrade)==null?void 0:ka.command)??(ue==null?void 0:ue.command)??"npm i -g"} here, then restarts once nothing is running.`,children:Ut==="running"?"installing…":Ut==="done"?"installed":"Update now"}),(ue==null?void 0:ue.upgradeMode)==="npx"&&(ue==null?void 0:ue.canRestart)&&d.jsx("button",{type:"button",className:"ver-act",onClick:()=>Us({upgrade:!0}),...ir(Ir),title:`Runs ${ue==null?void 0:ue.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Ir?"fetching…":Ut==="failed"?"Retry update":"Update & restart"}),Ut==="failed"?d.jsxs("span",{className:"ver-sub fail",title:((_a=ue==null?void 0:ue.upgrade)==null?void 0:_a.error)??"",children:[(ue==null?void 0:ue.upgradeMode)==="npx"?"update failed":"install failed",": ",((Sa=ue==null?void 0:ue.upgrade)==null?void 0:Sa.error)??"unknown error"," — run it yourself:"]}):(ue==null?void 0:ue.upgradeMode)==="npx"?d.jsx("span",{className:"ver-sub",children:ue!=null&&ue.canRestart?"npx cannot upgrade in place, so the deck re-runs:":Ev.npx}):ue!=null&&ue.upgradeBlocked?d.jsx("span",{className:"ver-sub",children:Object.hasOwn(Ev,ue.upgradeBlocked)?Ev[ue.upgradeBlocked]:"cannot install from here"}):null,d.jsxs("button",{type:"button",className:"ver-cmd",onClick:Rr,title:"Copy to clipboard",children:[d.jsx("code",{children:ue==null?void 0:ue.command}),d.jsx("span",{className:"ver-cmd-hint",children:nt?"copied":"copy"})]})]}),d.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Fn,children:"×"})]}):Ro&&hn?d.jsxs("div",{className:"ver-banner",role:"status",children:[d.jsx("span",{className:"ver-dot"}),d.jsxs("strong",{children:[hn," still works — the deck is called ",Bt," now."]}),ue!=null&&ue.renameFix?d.jsx("span",{className:"ver-sub",children:ue.renameFix}):null,d.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Ao,children:"×"})]}):null,G&&d.jsx(Uq,{state:s.current,now:xt,providers:rt,onClose:()=>Y(!1)}),R&&rt.claude&&d.jsx(vD,{onClose:()=>Q(!1)}),z&&d.jsx(wq,{state:s.current,now:xt,selectedIds:l,onSelect:ti,onClose:()=>M(!1)}),d.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${md?" bubbling":""}${ha?" dragging-any":""}`,ref:Xs,onMouseDownCapture:fd,onPointerDownCapture:gr,onPointerUpCapture:gr,onWheelCapture:gr,children:[ni===0&&d.jsx(N8,{live:Ie,everConnected:Gn,providers:rt}),Zs.length>1&&d.jsx("div",{ref:zs,className:`cat-filter-bar${qo?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:Zs.map(F=>{const B=sa.has(F);return d.jsxs("button",{type:"button",className:`cat-filter${B?" off":""}`,onClick:()=>xd(F),"aria-pressed":!B,title:`${B?"Show":"Hide"} ${aw[F]} tools`,children:[d.jsx("span",{className:"cat-emoji",children:iw[F]}),d.jsx("span",{className:"cat-name",children:aw[F]})]},F)})}),d.jsxs(Xj,{nodes:wd,edges:vd,nodeTypes:n8,fitView:!Qe,fitViewOptions:{padding:.25,duration:_v({durationMs:NC,documentHidden:document.hidden})?NC:0},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,onNodeClick:(F,B)=>{if(B.type==="sessionGroup"){w();return}v(B.id,F.shiftKey)},onPaneClick:()=>w(),onMoveStart:F=>{bC(Hs(F))&&Qo()},onMove:(F,B)=>{Ko(),bC(Hs(F))&&Qo(),cs.current&&window.clearTimeout(cs.current),cs.current=window.setTimeout(()=>x8(B),250)},onNodeDragStart:(F,B)=>{var le;if(gd(),Vs.current=!0,at.current=new Map,pa(!0),Ko(),Qo(),B.type==="sessionGroup"){const de=(le=B.data)==null?void 0:le.sessionId,_e=new Map;if(de)for(const Re of jn){const Be=Re.data;(Be==null?void 0:Be.sessionId)===de&&_e.set(Re.id,{x:Re.position.x,y:Re.position.y})}ls.current={start:{x:B.position.x,y:B.position.y},members:_e};return}Zt.current.set(B.id,{x:B.position.x,y:B.position.y})},onNodeDrag:(F,B)=>{var le;if(Ko(),B.type==="sessionGroup"){const de=ls.current;if(!de)return;const _e=B.position.x-de.start.x,Re=B.position.y-de.start.y;for(const[Ze,ht]of de.members){const ot={x:ht.x+_e,y:ht.y+Re};Zt.current.set(Ze,ot),Ot.current.set(Ze,ot)}const Be=at.current;if(Be){for(const[Ze,ht]of de.members)Be.set(Ze,{x:ht.x+_e,y:ht.y+Re});Be.set(B.id,{x:B.position.x,y:B.position.y})}rs(Ze=>Ze+1);return}Zt.current.set(B.id,{x:B.position.x,y:B.position.y}),Ot.current.set(B.id,{x:B.position.x,y:B.position.y}),(le=at.current)==null||le.set(B.id,{x:B.position.x,y:B.position.y}),rs(de=>de+1)},onNodeDragStop:(F,B)=>{if(Ko(),Vs.current=!1,at.current=null,pa(!1),Fs(le=>le+1),B.type==="sessionGroup"){const le=ls.current;if(le){const de=B.position.x-le.start.x,_e=B.position.y-le.start.y;for(const[Re,Be]of le.members){const Ze={x:Be.x+de,y:Be.y+_e};Zt.current.set(Re,Ze),Ot.current.set(Re,Ze)}}ls.current=null,Cv(Ot.current,Zt.current),Fs(de=>de+1);return}Zt.current.set(B.id,{x:B.position.x,y:B.position.y}),Ot.current.set(B.id,{x:B.position.x,y:B.position.y}),Cv(Ot.current,Zt.current)},children:[d.jsx(nL,{gap:28,size:1,color:Hn["--grid-line"]}),d.jsx(R3,{}),d.jsx(dq,{agents:s.current.agents,visibleAgentIds:qr,positions:Ot.current,pinned:Zt.current,measured:Xn.current,spotlight:Ks,hiddenCategories:sa,now:xt,onOpenTool:g}),d.jsxs(X$,{showInteractive:!1,children:[d.jsx(Nr,{onClick:vr,title:Gs?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:Gs?{color:"var(--accent)"}:void 0,children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),d.jsx(Nr,{onClick:ss,title:ZB({paused:Un,held:Vt.size,dropped:Vt.dropped}),"aria-label":QB,"aria-pressed":Un,children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:d.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),d.jsx(Nr,{onClick:Dr,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),d.jsx(Nr,{onClick:()=>fs("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),d.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),d.jsx(Nr,{onClick:()=>O(F=>!F),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[d.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),d.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]}),d.jsx(U$,{zoomable:!0,pannable:!0,nodeColor:Vo,nodeStrokeWidth:2,maskColor:Hn["--minimap-mask"],style:pr})]})]}),A?d.jsxs("aside",{className:"detail","aria-label":"Detail",children:[d.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>q(!1),children:"×"}),en?d.jsx(j8,{agent:en,now:xt,onOpenTool:g,onShowSummary:F=>{P.has(F)&&(P.delete(F),RC(P)),b(F)},onExportSession:F=>b8(s.current,F)}):d.jsx(C8,{count:ni,workspace:Ve})]}):d.jsx("button",{type:"button",className:"detail-reopen",title:"Show detail panel","aria-label":"Show detail panel",onClick:()=>q(!0),children:"‹"}),ma&&d.jsx(b3,{tool:ma,onClose:()=>g(null)}),Ar&&d.jsx(V5,{providers:rt,onClose:()=>hr(!1)}),ns&&d.jsx(oF,{onClose:()=>Mo(!1),onSeen:F=>{Oo(F);try{localStorage.setItem(K1,String(F))}catch{}},onWatching:$o,palette:Hn}),k&&(()=>{const F=s.current.agents.get(k);return F?d.jsx(h3,{agent:F,onClose:()=>_(null)}):null})(),N&&d.jsx(gq,{state:s.current,sessionId:N,onClose:()=>{P.add(N),RC(P),b(null)}}),ct&&d.jsx(u5,{entries:ct.entries,since:ct.since,firstRun:ct.firstRun,running:Le,onClose:()=>It(null)}),I&&d.jsx(MD,{onClose:()=>O(!1)}),C&&d.jsx(TD,{agentCount:ni,onConfirm:()=>fs("confirmation"),onCancel:()=>j(!1)})]})}function N8({live:e,everConnected:t,providers:n}){const s=!e;return d.jsxs("div",{className:"empty-hero",children:[d.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[d.jsx("div",{className:"core"}),d.jsxs("div",{className:"orbit r1",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]}),d.jsxs("div",{className:"orbit r2",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]}),d.jsxs("div",{className:"orbit r3",children:[d.jsx("span",{className:"dot"}),d.jsx("span",{className:"dot b"})]})]}),s?d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),d.jsxs("p",{children:["The browser cannot reach ",d.jsx("code",{children:"/events"}),". Check that",d.jsx("code",{children:Bt})," is still running in your terminal, then this page will resume automatically."]})]}):E8(n)]})}function E8(e){return d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Waiting for Claude Code or Codex"}),d.jsxs("p",{children:["Run ",d.jsx("code",{children:"claude"})," or ",d.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),d.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",d.jsx("code",{children:Bt})," is running."]}),z5(e).map(t=>d.jsx("p",{className:"hint-row",children:t.spans.map((n,s)=>n.code?d.jsx("code",{children:n.text},s):d.jsx("span",{children:n.text},s))},t.provider))]})}function C8({count:e,workspace:t}){const n=YB(t);return d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Detail"}),e===0?d.jsxs("div",{className:"hint",children:[n.lead,n.workspace!==null&&d.jsxs(d.Fragment,{children:[" ",d.jsx("code",{children:n.workspace}),n.tail]})]}):d.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),d.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),d.jsxs("div",{className:"shortcuts",children:[d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"?"}),d.jsx("span",{children:"all shortcuts"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"drag"}),d.jsx("span",{children:"move a node"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"tab"}),d.jsx("span",{children:"reach the cards"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"enter"}),d.jsx("span",{children:"select the focused card"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"space"}),d.jsx("span",{children:"pause / resume"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"J"}),d.jsx("span",{children:"next agent"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"K"}),d.jsx("span",{children:"previous agent"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"R"}),d.jsx("span",{children:"re-arrange"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"F"}),d.jsx("span",{children:"fit view"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"L"}),d.jsx("span",{children:"session list"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"H"}),d.jsx("span",{children:"usage history"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"U"}),d.jsx("span",{children:"usage panel"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"C"}),d.jsx("span",{children:"clear canvas"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"T"}),d.jsx("span",{children:"toggle theme"})]}),d.jsxs("div",{className:"sc",children:[d.jsx("kbd",{children:"Esc"}),d.jsx("span",{children:"deselect, release focus"})]})]})]})}function j8({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:i}){const a=Ru(e.startedAt,e.endedAt,t),l=bn(e),u=l.total>0,h=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const N of e.tools){const b=nA(N.name);p.set(b,(p.get(b)??0)+1)}const f=e.tools.filter(N=>N.ok===!1).length,g=e.tools.filter(N=>!N.endedAt).length,v=Array.from(p.entries()).sort((N,b)=>b[1]-N[1]),w=p.has("mcp")?iq(e.tools.map(N=>N.name)):null;return d.jsxs(d.Fragment,{children:[d.jsxs("header",{className:"detail-hero",children:[d.jsxs("div",{className:"hero-line",children:[d.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),d.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),d.jsxs("div",{className:"hero-meta",children:[d.jsx("span",{className:"hero-meta-item",children:e.kind}),d.jsx("span",{className:"hero-sep",children:"·"}),d.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:a}),e.model&&(()=>{const N=dT(e);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"hero-sep",children:"·"}),d.jsxs("span",{className:"model-chip","data-family":Uu(e.model),title:N.length>0?`${e.model}
199
203
  spend on this panel also covers: