ccdeck 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/AccountBridge-CmB2ClCh.js +1 -0
- package/dist/web/assets/{AccountSection-crq1VjX0.js → AccountSection-C0_ISsSw.js} +1 -1
- package/dist/web/assets/{BrowserWatchModal-CoXeeb2o.js → BrowserWatchModal-C4G5G12x.js} +1 -1
- package/dist/web/assets/{FeedbackConversations-BDjrxpxf.js → FeedbackConversations-Bqqn0VaM.js} +1 -1
- package/dist/web/assets/{IntegrationModal-4Z8_QVBa.js → IntegrationModal-CKgtTF3f.js} +1 -1
- package/dist/web/assets/{IntegrationSkeleton-DHuH_POu.js → IntegrationSkeleton-WE6DOfez.js} +1 -1
- package/dist/web/assets/{RadioPanel-Dw3zruRE.js → RadioPanel-j_p9qx4L.js} +1 -1
- package/dist/web/assets/{StageShell-Dn1RGcsF.js → StageShell-Bl0ddeiL.js} +3 -3
- package/dist/web/assets/{TrafficRadar--OAIaujE.js → TrafficRadar-CTGz345C.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-D1hw3AaJ.js → UsageHistoryModal-C2IDurbk.js} +1 -1
- package/dist/web/assets/{app-DiIDGQPy.js → app-CdRq5GPP.js} +10 -10
- package/dist/web/assets/{index-BXBkLnYy.js → index-pIus964m.js} +1 -1
- package/dist/web/assets/{inspector-status-pane-DP7kOBus.js → inspector-status-pane-BY6DHEeo.js} +1 -1
- package/dist/web/assets/{screens-CqpMhDCL.js → screens-BMLZR8WS.js} +1 -1
- package/dist/web/assets/{stage-board-0PYMffFC.js → stage-board-6RJd7VXM.js} +1 -1
- package/dist/web/assets/{use-account-DskceWF8.js → use-account-t_qL6ab-.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/release-notes.json +7 -0
- package/src/server/pro-engine-terminal.mjs +22 -2
- package/dist/web/assets/AccountBridge-BWSoT0Lr.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/inspector-status-pane-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/inspector-status-pane-BY6DHEeo.js","assets/stage-board-6RJd7VXM.js","assets/IntegrationModal-CKgtTF3f.js","assets/IntegrationSkeleton-WE6DOfez.js","assets/FeedbackConversations-Bqqn0VaM.js","assets/use-account-t_qL6ab-.js","assets/AccountSection-C0_ISsSw.js","assets/StageShell-Bl0ddeiL.js","assets/AccountBridge-CmB2ClCh.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var _J=Object.defineProperty;var LJ=(e,t,n)=>t in e?_J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ss=(e,t,n)=>LJ(e,typeof t!="symbol"?t+"":t,n);var lf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var hy={exports:{}},Bh={},py={exports:{}},It={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -119,7 +119,7 @@ ${e.detail?t("board.continue.tooltip.copyWhy",{detail:e.detail}):t("board.contin
|
|
|
119
119
|
${e.sessionTitle}`:e.sessionTitle:e.cwd,f=e.kind==="root"?Wl(e):null,b=f?f.title:e.label,v=f&&e.twin?Nu(e.startedAt,e.twin):null,w=f!=null&&f.task?{face:f.task,tooltip:E1(e)}:null,T=(F=e.spawnCall)==null?void 0:F.description,y=rce(e),x=fde(e.tools),C=m.useRef(null),A=m.useRef(null),[E,R]=m.useState(0),[,z]=m.useState(0),I=e.usage.inputTokens+e.usage.outputTokens,_={tokens:I>0,inflight:c>0},D=O4(_).length,L=mce(E,_),P=I>0&&!L.has("tokens"),O=h&&!!e.onOpenContext&&i.jsx(Rle,{currentContextTokens:u,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)},"context"),j=[y?`${y.kind}:${y.kind==="spent"?Ut(y.total)+(y.floor?"+":""):""}`:"",x.join(","),c,Yt(I),e.childCount,e.synthetic?1:0,O?Math.round(S1(e).pct):""].join("|");return aP(()=>{R(0)},[j]),aP(()=>{const U=C.current;if(!U||E>=D)return;const H=U.scrollWidth-U.clientWidth;R($=>gce($,{overflow:H,max:D}))}),m.useEffect(()=>{var W;const U=C.current;if(!U||typeof ResizeObserver>"u")return;let H=U.clientWidth,$=((W=A.current)==null?void 0:W.offsetWidth)??0;const Y=new ResizeObserver(()=>{var te;const G=U.clientWidth,Q=((te=A.current)==null?void 0:te.offsetWidth)??0,J=H;H=G;const X=Q!==$;$=Q,!(G===J&&!X)&&$t.flushSync(()=>{R(K=>fce(K,{from:J,to:G})),X&&z(K=>K+1)})});return Y.observe(U),A.current&&Y.observe(A.current),()=>Y.disconnect()},[]),i.jsxs("div",{className:r,"data-alarm":o.tone==="waiting"?"":void 0,children:[t&&i.jsx(Tl,{type:"target",position:xt.Left,style:{background:"transparent",border:"none"}}),i.jsxs("div",{className:"head",children:[i.jsxs("div",{className:"title",children:[i.jsx("span",{className:"label",title:p,children:b}),e.provider==="codex"&&i.jsx("span",{className:"provider-word",children:C1("codex")}),e.restoredFromLog&&i.jsx("span",{className:"synth-tag",title:e.provider==="claude"?n("board.node.restoredRegistry"):n("board.node.restoredLog"),children:n("board.node.restored")}),e.synthetic&&i.jsx("span",{className:"synth-tag",title:n("board.node.synthesised"),children:"?"})]}),i.jsx("div",{className:"head-right",children:i.jsx(Yde,{state:o,under:d1(s)})})]}),e.kind==="root"&&(w||v)&&i.jsxs("div",{className:"task-line",title:w==null?void 0:w.tooltip,children:[v&&i.jsx("span",{className:"twin-start",title:n("board.node.started",{time:v}),children:v}),v&&w?" · ":"",w==null?void 0:w.face]}),!(e.kind==="root"&&(w||v))&&xu(e,n)!=="session"&&i.jsx("div",{className:"task-line",title:T?`${T}
|
|
120
120
|
${ML(e,n)}`:ML(e,n),children:T||`${xu(e,n)}${e.cwdBasename?` · ${e.cwdBasename}`:""}`}),e.kind==="root"&&e.stopFailure&&i.jsx(Zde,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&i.jsx(Bde,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&i.jsx(Xde,{waiting:e.waiting}),(()=>{const U=L4(e);return U?i.jsxs("div",{className:"approval-blind-row",title:U.detail,children:[i.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),i.jsx("span",{className:"approval-blind-said",children:U.label})]}):null})(),(()=>{const U=yo(e.plan);return U&&e.plan?i.jsx(Gde,{plan:U,items:e.plan.items}):null})(),i.jsxs("div",{className:"foot",ref:C,children:[x.length>0&&i.jsx("span",{className:"foot-tools",title:[x.map(U=>Wb(U,n)).join(" · "),n("board.toolCount",{count:e.toolCount})+(l>0?n("board.listSep")+n("board.failedCount",{n:l}):"")].join(`
|
|
121
121
|
`),children:x.map(U=>i.jsx(Ze,{name:mde[U]},U))}),Kde([(y==null?void 0:y.kind)==="unpriced"&&i.jsx(tP,{className:"cost-unpriced",tip:y.tip,children:n("insights.cost.notPriced")},"cost"),(y==null?void 0:y.kind)==="spent"&&i.jsx(tP,{className:"cost-meta",tip:y.tip,children:i.jsxs("b",{children:[Ut(y.total),y.floor?"+":""]})},"cost"),i.jsxs("span",{className:"time",ref:A,title:e.synthetic?n("board.node.joinedLate",{time:new Date(e.startedAt).toLocaleTimeString(a)}):n("board.node.started",{time:new Date(e.startedAt).toLocaleTimeString(a)}),children:[e.synthetic?"≥ ":"",i.jsx($de,{start:e.startedAt,end:e.endedAt})]},"time"),c>0&&!L.has("inflight")&&i.jsxs("span",{className:"inflight-meta",children:[i.jsx("b",{children:c})," ",n("board.meta.inflight")]},"inflight"),P&&i.jsxs("span",{className:"tokens-meta",title:`${n("board.meta.tokensTitle",{input:e.usage.inputTokens,output:e.usage.outputTokens,cacheR:e.usage.cacheReadTokens,cacheC:e.usage.cacheCreateTokens})}${(e.usage.reasoningOutputTokens??0)>0?` ${n("board.meta.reasoning",{n:e.usage.reasoningOutputTokens??0})}`:""}`,children:[i.jsx("b",{children:Yt(e.usage.inputTokens+e.usage.outputTokens)})," ",n("board.meta.tok")]},"tokens"),!P&&O]),P&&O,e.childCount>0&&i.jsx("span",{className:"foot-end",children:i.jsxs("span",{className:"spawn-badge",title:Cce(e.childCount,n),children:[e.childCount,i.jsx(Ze,{name:"agents"})]})})]}),i.jsx(Vde,{data:e,task:ode(e)}),t&&i.jsx(Tl,{type:"source",position:xt.Right,style:{background:"transparent",border:"none"}})]})}const Hde=m.memo(Wde);function Gde({plan:e,items:t}){const n=se();return i.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:Kk(t),children:[i.jsx("span",{className:"plan-meter","aria-hidden":!0,style:{"--plan-done":e.done/e.total}}),i.jsxs("span",{className:"plan-count",children:[e.done,"/",e.total]}),i.jsx("span",{className:"plan-step",children:e.allDone||!e.current?n("board.state.done"):i.jsxs(i.Fragment,{children:[e.next&&i.jsx("span",{className:"plan-next",children:n("board.plan.next")}),e.current]})})]})}function Vde({data:e,task:t}){const n=se(),a=e.kind==="root"&&bs(e.waiting),s=Eg(e,n),o=e.kind==="root"&&e.twin?Nu(e.startedAt,e.twin):null;return i.jsx("div",{className:"lod-face","data-kind":e.kind,"data-alarm":a?"":void 0,"aria-hidden":!0,children:i.jsxs("div",{className:"lod-line","data-status":s.tone,children:[s.mark==="alert"?i.jsx(ic,{}):i.jsx(yi,{kind:s.mark}),t&&i.jsx("span",{className:"lod-name",children:t}),o&&i.jsx("span",{className:"lod-start",children:o}),i.jsx("span",{className:"lod-state",children:s.word})]})})}function Kde(e){const t=[];for(const n of e)n&&(t.length>0&&t.push(i.jsx("span",{className:"foot-sep","aria-hidden":!0,children:"·"},`sep-${t.length}`)),t.push(n));return t}function $de({start:e,end:t}){const n=xo(1e3);return i.jsx(i.Fragment,{children:Cu(e,t,n)})}const Jde={active:"working",waiting:"waiting",done:"done",partial:"partial",err:"error",ready:"idle"};function Yde({state:e,under:t}){const n=se();return i.jsxs("span",{className:"state-line","data-tone":e.tone,children:[i.jsx(Ys,{name:Jde[e.tone],className:"state-mark",kind:e.mark==="alert"?t:e.mark}),e.tone==="partial"?i.jsxs("span",{className:"state-word",children:[i.jsx("span",{className:"state-done",children:n("board.card.stateDone")})," · ",i.jsx("span",{className:"state-failed",children:e.word})]}):i.jsx("span",{className:"state-word",children:e.word})]})}function Zde({data:e,stop:t}){const n=se();return i.jsxs("div",{className:"stop-row",title:gre(t,e.job!=null,n),"data-kind":t.kind,children:[i.jsx("span",{className:"stop-said",children:w4(t,n)}),i.jsx(Fde,{data:e})]})}function Xde({waiting:e}){const t=se(),n=xo(1e3),a=Al(e,t),s=e.kind==="asked"?void 0:e.tool,o=[a,F4(e,a,t),t("board.node.blockedFor",{time:Cu(e.since,void 0,n)})].filter(Boolean).join(`
|
|
122
|
-
`);return i.jsx("div",{className:"waiting-row",title:o,children:i.jsx("span",{className:`waiting-said${s?" mono":""}`,children:s?s.preview?`${s.name} · ${s.preview}`:s.name:Hj(e,t)})})}const P1="agent-dag.single-key-shortcuts";function L5(e){return e!=="0"}function O1(e){return e.length===1}function Qde(e,t){return!t&&O1(e)}function bo(e,t,n){return n?`${e} (${t})`:e}let kl=null;const kp=new Set;function P5(){for(const e of kp)e()}function Zj(){return kl===null&&(kl=L5(gt(P1))),kl}function O5(e){kl!==e&&(kl=e,yt(P1,e?"1":"0"),P5())}function sP(e){if(e.key!==P1)return;const t=L5(e.newValue);t!==kl&&(kl=t,P5())}function eue(e){var t;return kp.add(e),kp.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",sP)),()=>{var n;kp.delete(e),kp.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",sP))}}function sa(){return m.useSyncExternalStore(eue,Zj,Zj)}function tue(e){return`${Math.round(e*100)}%`}function M5(e,t,n){if(n<=0||tv(e))return{kind:"pass"};const a=t>=0&&t<n?t:-1;switch(e.key){case"ArrowDown":return{kind:"focus",index:a===-1?0:(a+1)%n};case"ArrowUp":return{kind:"focus",index:a===-1?n-1:(a-1+n)%n};case"Home":return{kind:"focus",index:0};case"End":return{kind:"focus",index:n-1};default:return{kind:"pass"}}}function nue(e,t,n){const a=e.key==="ArrowRight"?"ArrowDown":e.key==="ArrowLeft"?"ArrowUp":e.key;return M5({...e,key:a},t,n)}const Vs=4,An=8;function cv(e,t,n){const a=n.width-An-(e.right+Vs),s=e.left-Vs-An,o=t.width<=a||a>=s?"right":"left",r=o==="right"?e.right+Vs:e.left-Vs-t.width,c=n.height-An*2,l=t.height<=c,u=l?t.height:Math.max(0,c),h=Math.max(An,Math.min(e.top,n.height-An-u)),p=Math.max(An,Math.min(r,n.width-An-t.width));return{top:h,left:p,side:o,maxHeight:l?null:u}}function aue(e,t,n,a=0){const s=n.width-An-e.right-Vs,o=e.left-Vs-An;if(t.width<=Math.max(s,o))return cv(e,t,n);const r=Math.max(0,Math.min(e.top-Vs,n.height-An)-An);if(r<=0||r<Math.min(t.height,a))return null;const c=Math.min(t.height,r);return{side:"above",top:Math.max(An,Math.min(e.top-Vs,n.height-An)-c),left:Math.max(An,Math.min(e.right-t.width,n.width-An-t.width)),maxHeight:c<t.height?c:null}}function I5(e,t,n,a="end",s=!1){const o=n.height-An-(e.bottom+Vs),r=e.top-Vs-An,c=t.height<=o||o>=r?"below":"above",l=s?n.height-An*2:c==="below"?o:r,u=t.height<=l,h=u?t.height:Math.max(0,l),p=c==="below"?e.bottom+Vs:e.top-Vs-h,f=s?Math.min(p,n.height-An-h):p,b=a==="start"?e.left:e.right-t.width,v=Math.max(An,Math.min(b,n.width-An-t.width));return{top:Math.max(An,f),left:v,side:c,maxHeight:u?null:h}}function sue(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function iue(e,t,n){const a=m.useRef(t);a.current=t;const s=m.useRef(n);s.current=n,m.useEffect(()=>{const o=r=>{sue(r.target,e.current,a.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const D5='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function iP(e){return e?Array.from(e.querySelectorAll(D5)).filter(t=>!t.disabled):[]}function Rs({anchorId:e,boundaryId:t,portalRootId:n,id:a,className:s,role:o,labelledBy:r,start:c="first",focusRef:l,fallbackFocus:u,onClose:h,align:p="end",overAnchor:f=!1,children:b}){const v=m.useRef(h);v.current=h;const w=m.useRef(u);w.current=u;const T=Zt(()=>{var E;(E=document.getElementById(e))==null||E.focus(),v.current()},{popover:!0,focusRef:l}),y=m.useCallback(()=>{var L,P,O;const E=T.current;if(!E)return;const R=document.getElementById(e);if(!R){v.current();return}if(R.getClientRects().length===0){E.contains(document.activeElement)&&((P=(L=w.current)==null?void 0:L.call(w))==null||P.focus()),v.current();return}const z=R.getBoundingClientRect(),I=t?(O=document.getElementById(t))==null?void 0:O.getBoundingClientRect():null;if(I&&(z.bottom<=I.top||z.top>=I.bottom)){E.contains(document.activeElement)&&R.focus({preventScroll:!0}),v.current();return}const _=E.scrollTop;E.style.maxHeight="";const D=I5(z,{width:E.offsetWidth,height:E.offsetHeight},{width:window.innerWidth,height:window.innerHeight},p,f);E.style.top=`${D.top}px`,E.style.left=`${D.left}px`,E.style.maxHeight=D.maxHeight==null?"":`${D.maxHeight}px`,_&&(E.scrollTop=_),E.dataset.side=D.side},[e,t,T,p,f]);m.useLayoutEffect(()=>{y()}),m.useEffect(()=>{var R;if(typeof ResizeObserver>"u")return;const E=new ResizeObserver(y);for(const z of Array.from(((R=T.current)==null?void 0:R.children)??[]))E.observe(z);return()=>E.disconnect()},[y,T]),m.useEffect(()=>{const E=R=>{var z;(z=T.current)!=null&&z.contains(R.target)||y()};return window.addEventListener("scroll",E,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",y)}},[y,T]),iue(T,()=>document.getElementById(e),h),m.useEffect(()=>{var R;if(o!=="menu")return;const E=iP(T.current);(R=c==="last"?E[E.length-1]:E[0])==null||R.focus()},[]);const x=E=>{var R;if(o==="menu"&&E.key==="Tab"){E.stopPropagation(),(R=document.getElementById(e))==null||R.focus(),E.shiftKey&&E.preventDefault(),v.current();return}if(o==="menu"){const z=iP(T.current),I=M5(E,z.indexOf(document.activeElement),z.length);I.kind==="focus"&&(E.preventDefault(),z[I.index].focus())}E.key.length===1&&E.stopPropagation()},C=E=>{E.target.closest("button, input, select, textarea, code")||E.preventDefault()},A=E=>{if(o!=="menu"||E.pointerType==="touch")return;const R=E.target.closest(D5);R&&!R.disabled&&document.activeElement!==R&&R.focus({preventScroll:!0})};return $t.createPortal(i.jsx("div",{ref:T,id:a,className:`anchored-popover${s?` ${s}`:""}`,role:o,"aria-labelledby":r,onKeyDown:x,onMouseDown:C,onPointerMove:A,children:b}),(n?document.getElementById(n):null)??document.body)}function _g(e){return i.jsxs("span",{className:"cbx",children:[i.jsx("input",{type:"checkbox",...e}),i.jsx("svg",{className:"cbx-tick",viewBox:"0 0 14 14","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"M3.5 7.5 6 10l4.5-5.5",pathLength:"1"})})]})}function oue({headId:e,presentCats:t,hiddenCats:n,toggleCat:a}){const s=se(),o=()=>{for(const r of n)a(r)};return i.jsxs("div",{role:"group","aria-labelledby":e,className:"cat-tools-group",children:[i.jsx("div",{id:e,className:"cat-tools-head",children:s("board.detail.toolCalls")}),t.map(r=>{const c=n.has(r);return i.jsxs("label",{className:`ap-menu-item cat-tools-item cat-${r}${c?" off":""}`,children:[i.jsx(_g,{role:"menuitemcheckbox",checked:!c,onChange:()=>a(r),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a(r))}}),i.jsx("span",{className:"cat-dot","aria-hidden":"true"}),i.jsx("span",{className:"cat-name",children:Wb(r,s)})]},r)}),n.size>0&&i.jsx("div",{role:"separator",className:"ap-menu-sep"}),n.size>0&&i.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item cat-tools-all",onClick:r=>{var c,l;document.activeElement===r.currentTarget&&((l=(c=r.currentTarget.parentElement)==null?void 0:c.querySelector("input"))==null||l.focus({preventScroll:!0})),o()},children:s("board.cat.showAll")})]})}function lu({children:e,label:t}){return t?i.jsxs(i.Fragment,{children:[i.jsx("kbd",{className:"kbd","aria-hidden":!0,children:e}),i.jsx("span",{className:"kbd-spoken",children:t})]}):i.jsx("kbd",{className:"kbd",children:e})}const rue=e=>e.transform[2]>=e.maxZoom,cue=e=>e.transform[2]<=e.minZoom,lue=e=>tue(e.transform[2]),oP=1.2,due=[],uue=new Set;function hue(e,t){return e.length>1||t.size>0}function pue(e,t){return e.some(n=>t.has(n))}function gue({autoFitDisabled:e,enableAutoFitAndRefit:t,handleRelayout:n,requestClear:a,setKeyHelpOpen:s,zoomBy:o,zoomReset:r,onTerminal:c,presentCats:l=due,hiddenCats:u=uue,toggleCat:h}){const p=se(),f=Wt(rue),b=Wt(cue);return Tg()?c?i.jsx(gL,{position:"bottom-right",showInteractive:!1,showFitView:!1,showZoom:!1,children:i.jsx(fue,{onTerminal:c})}):null:i.jsxs(gL,{position:"bottom-right",showInteractive:!1,showFitView:!1,showZoom:!1,children:[i.jsx(Ci,{onClick:()=>{b||o(1/oP)},title:p("board.controls.zoomOut"),"aria-label":p("board.controls.zoomOut"),"aria-disabled":b||void 0,children:i.jsx(Ze,{name:"minus"})}),i.jsx(bue,{zoomReset:r}),i.jsx(Ci,{onClick:()=>{f||o(oP)},title:p("board.controls.zoomIn"),"aria-label":p("board.controls.zoomIn"),"aria-disabled":f||void 0,children:i.jsx(Ze,{name:"plus"})}),i.jsx("span",{className:"react-flow__controls-divider","aria-hidden":!0}),i.jsx(Ci,{onClick:t,title:p(e?"board.controls.recenterOn":"board.controls.recenterAuto"),"aria-label":p("board.controls.recenter"),"data-nudge":e?"":void 0,children:i.jsx(Ze,{name:"recenter"})}),i.jsx(mue,{handleRelayout:n,requestClear:a,setKeyHelpOpen:s,onTerminal:c,presentCats:l,hiddenCats:u,toggleCat:h})]})}const $h="canvas-more",rP="canvas-more-menu";function Af({label:e,keyCap:t,onPick:n}){const s=sa()?t:void 0;return i.jsxs("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:n,"aria-keyshortcuts":s,children:[i.jsx("span",{className:"canvas-more-word",children:e}),s&&i.jsx("span",{className:"canvas-more-key","aria-hidden":!0,children:i.jsx(lu,{children:s})})]})}function mue({handleRelayout:e,requestClear:t,setKeyHelpOpen:n,onTerminal:a,presentCats:s,hiddenCats:o,toggleCat:r}){const c=se(),l=sa(),u=m.useId(),[h,p]=m.useState(null),f=h!==null,b=r&&hue(s,o)?r:null,v=b!=null&&pue(s,o),w=c(v?"board.controls.moreFiltered":"accounts.row.more"),T=y=>()=>{var x;(x=document.getElementById($h))==null||x.focus(),p(null),y()};return i.jsxs(i.Fragment,{children:[i.jsxs(Ci,{id:$h,className:"canvas-more",title:w,"aria-label":w,"aria-haspopup":"menu","aria-expanded":f,"aria-controls":f?rP:void 0,onKeyDown:y=>{y.key!=="ArrowDown"&&y.key!=="ArrowUp"||(y.preventDefault(),p(y.key==="ArrowUp"?"last":"first"))},onClick:()=>p(f?null:"first"),children:[i.jsx(Ze,{name:"more"}),v&&i.jsx("span",{className:"canvas-more-dot","aria-hidden":!0})]}),f&&i.jsxs(Rs,{anchorId:$h,id:rP,className:"ap-pop canvas-more-pop",role:"menu",labelledBy:$h,start:h,onClose:()=>p(null),children:[i.jsx(Af,{label:c("board.controls.arrangeLabel"),keyCap:"R",onPick:T(e)}),i.jsx(Af,{label:c("board.quick.action.clear"),keyCap:"C",onPick:T(()=>t("button"))}),i.jsx("div",{role:"separator",className:"ap-menu-sep"}),a&&i.jsx(Af,{label:c("board.controls.openPanel"),onPick:T(()=>a(document.getElementById($h)))}),i.jsx(Af,{label:c(l?"board.controls.keys":"board.controls.keysOff"),keyCap:"?",onPick:T(()=>n(y=>!y))}),b&&i.jsxs(i.Fragment,{children:[i.jsx("div",{role:"separator",className:"ap-menu-sep"}),i.jsx(oue,{headId:u,presentCats:s,hiddenCats:o,toggleCat:b})]})]})]})}function fue({onTerminal:e}){const t=se();return i.jsx(Ci,{onClick:n=>e(n.currentTarget),title:t("board.controls.openPanelTip"),"aria-label":t("board.controls.openPanel"),children:i.jsx(Ze,{name:"terminal"})})}function bue({zoomReset:e}){const t=se(),n=Wt(lue);return i.jsx(Ci,{"data-zoom-level":"",onClick:e,title:t("board.controls.zoomReset"),"aria-label":t("board.controls.zoomLabel",{level:n}),children:n})}const cP="agent-dag.fm-custom-stations",lP="agent-dag.fm-muted",Xj="custom:",kue=/^UC[A-Za-z0-9_-]{22}$/,vue=/^[A-Za-z0-9_-]{11}$/,F5=/^[A-Za-z0-9_-]{1,80}$/,wue=/\.(mp3|aac|ogg)$/i,yue=/\.m3u8$/i,xue=2048,B5=80;function Au(e){return`${Xj}${e}`}function lv(e){if(!e.startsWith(Xj))return null;const t=e.slice(Xj.length);return F5.test(t)?t:null}function dP(e){return lv(e)??e}function M1(e){var r,c;const t=e.trim();if(t.length>xue)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const a=n.toString(),s=n.hostname.toLowerCase();if(s==="youtube.com"||s==="www.youtube.com"||s==="m.youtube.com"){if(n.port)return null;const l=(r=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:r[1];if(l&&kue.test(l))return{kind:"youtube-channel",url:a,channel:l};const u=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(u&&/^[A-Za-z0-9._-]{1,64}$/.test(u))return{kind:"youtube-handle",url:a,handle:u};if(n.pathname==="/watch"){const h=n.searchParams.get("v")??"";if(vue.test(h))return{kind:"youtube-video",url:a,video:h}}return null}return yue.test(n.pathname)?{kind:"direct-audio",url:a,format:"hls"}:wue.test(n.pathname)?{kind:"direct-audio",url:a,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:a,format:"audio"}}function Cue(e){return e==="1"}function Sue(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,a=[];for(const s of t){if(!s||typeof s!="object")continue;const o=typeof s.id=="string"?s.id:"",r=typeof s.name=="string"?s.name.trim():"",c=typeof s.url=="string"?s.url.trim():"",l=M1(c);if(!F5.test(o)||n.has(o)||!r||r.length>B5||!l)continue;n.add(o);const u=U5(s.radio);a.push({id:o,name:r,url:l.url,...u?{radio:u}:{}})}return a}function Tue(e,t,n){const a=lv(e??"");return a&&t.some(s=>s.id===a)?Au(a):n(e)}function Nue(e,t){return e===Au(t)?"claude-fm":e}function U5(e){if(!e||typeof e!="object")return null;const t=e,n=(s,o)=>typeof t[s]=="string"?t[s].slice(0,o):"",a=(s,o)=>typeof t[s]=="number"&&Number.isFinite(t[s])&&Math.abs(t[s])<=o?t[s]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:a("lat",90),lon:a("lon",180)}}const Qj="https://www.youtube-nocookie.com";function Aue(e,t,n){const a=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Qj}/embed/${n?encodeURIComponent(n):"live_stream"}?${a.toString()}`}function Od(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function jue(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const Eue=[1],Rue=[0,2],zue=[2,5,100,101,150,153];function que(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:a}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const s=typeof a=="number"?a:Number(a==null?void 0:a.errorCode);return Number.isFinite(s)?{kind:"error",code:s}:null}if(n==="onStateChange"||n==="infoDelivery"){const s=typeof a=="number"?a:a==null?void 0:a.playerState;return typeof s!="number"||!Number.isFinite(s)?null:Eue.includes(s)?{kind:"playing",playing:!0}:s===3?{kind:"buffering"}:Rue.includes(s)?{kind:"playing",playing:!1}:null}return null}const Jh=new Set;let uP="";function hP(e){const t=new Date().toISOString().slice(0,10);if(t!==uP&&(Jh.clear(),uP=t),!Jh.has(e)){Jh.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Jh.delete(e)}catch{Jh.delete(e)}}}const pP=864e5,_ue=6e4;function na(e,t=!0){m.useEffect(()=>{if(!t)return;hP(e);let n;const a=()=>{n=setTimeout(()=>{hP(e),a()},pP-Date.now()%pP+_ue)};return a(),()=>clearTimeout(n)},[e,t])}const Lue={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function Pue({fetchImpl:e,enabled:t=!0,volume:n,muted:a,source:s,playRequest:o,customStation:r,onAvailabilityChange:c}){var O;const[l,u]=m.useState(null),[h,p]=m.useState(!1),[f,b]=m.useState(!1),[v,w]=m.useState(!1),[T,y]=m.useState(!1);na("claude-fm",v);const x=m.useRef(o),C=m.useRef(null),A=m.useRef(null),E=m.useRef(void 0),R=m.useRef(null),z=m.useCallback(()=>{var M;clearTimeout(E.current),(M=A.current)==null||M.destroy(),A.current=null;const j=C.current;j&&(j.pause(),j.removeAttribute("src"),j.load(),C.current=null)},[]),I=m.useCallback(j=>{var M,F;(F=(M=R.current)==null?void 0:M.contentWindow)==null||F.postMessage(j,Qj)},[]),_=m.useRef(n);_.current=n;const D=m.useRef(a);D.current=a;const L=m.useCallback((j,M,F)=>{z();const U=new Audio;U.preload="none",U.volume=_.current/100,U.muted=D.current,C.current=U,b(!0),w(!1),y(!1);let H=!1;const $=()=>C.current===U,Y=()=>{clearTimeout(E.current),z(),b(!1),w(!1),y(!1)},W=()=>{$()&&(Y(),p(!0),c==null||c(F,!0))},G=J=>{if($()&&!(J instanceof DOMException&&J.name==="AbortError")){if(J instanceof DOMException&&J.name==="NotAllowedError"){Y();return}W()}};E.current=setTimeout(()=>{$()&&!H&&W()},15e3),U.addEventListener("playing",()=>{$()&&(clearTimeout(E.current),H=!0,w(!0),y(!1),c==null||c(F,!1))});const Q=()=>{$()&&(w(!1),y(H),clearTimeout(E.current),E.current=setTimeout(()=>{$()&&W()},15e3))};U.addEventListener("waiting",Q),U.addEventListener("stalled",Q),U.addEventListener("ended",()=>{$()&&Y()}),U.addEventListener("error",W,{once:!0}),M&&!U.canPlayType("application/vnd.apple.mpegurl")?Xs(async()=>{const{default:J}=await import("./hls-BFpXDghs.js");return{default:J}},[]).then(({default:J})=>{if(!$())return;if(!J.isSupported()){W();return}const X=new J;A.current=X,X.on(J.Events.ERROR,(te,K)=>{K.fatal&&W()}),X.on(J.Events.MEDIA_ATTACHED,()=>X.loadSource(j)),X.on(J.Events.MANIFEST_PARSED,()=>{U.play().catch(G)}),X.attachMedia(U)},W):(U.src=j,U.play().catch(G))},[c,z]);m.useEffect(()=>{f&&(I(Od("setVolume",[n])),I(Od(a?"mute":"unMute")),C.current&&(C.current.volume=n/100,C.current.muted=a))},[n,a,f,I]),m.useEffect(()=>{var Y;let j=!0;const M=e??fetch,F=x.current!==o;if(x.current=o,u(null),p(!1),y(!1),b(F),w(!1),z(),!t){b(!1),w(!1);return}const U=r&&Au(r.id)===s?M1(r.url):null;if(U){if(U.kind==="direct-audio"){const W=U.format==="hls"||((Y=r==null?void 0:r.radio)==null?void 0:Y.hls)===!0;return u({live:!0,channel:"",audio:U.url,hls:W}),c==null||c(s,!1),F&&L(U.url,W,s),()=>{j=!1}}return M(`/api/fm-station?url=${encodeURIComponent(U.url)}`).then(W=>W.ok?W.json():null).then(W=>{j&&(W!=null&&W.channel||W!=null&&W.video?(u({live:!0,channel:W.channel??"",video:W.video??void 0}),c==null||c(s,!1)):(p(!0),b(!1),w(!1),y(!1),c==null||c(s,!0)))}).catch(()=>{j&&(p(!0),b(!1),w(!1),y(!1),c==null||c(s,!0))}),()=>{j=!1}}if(lv(s))return p(!0),c==null||c(s,!0),()=>{j=!1};const H=s,$=Lue[H];if($)M($).then(W=>W.ok?W.json():null).then(W=>{j&&(W!=null&&W.video&&u({live:!0,channel:"",video:W.video}),W!=null&&W.video||(p(!0),b(!1),w(!1)),c==null||c(s,!(W!=null&&W.video)))}).catch(()=>{j&&(p(!0),b(!1),w(!1),c==null||c(s,!0))});else if(H!=="claude-fm"){const W=H.replace("lofi-","");M(`/api/lofi-girl?station=${encodeURIComponent(W)}`).then(G=>G.ok?G.json():null).then(G=>{j&&(G!=null&&G.video&&u({live:!0,channel:"",video:G.video}),G!=null&&G.video||(p(!0),b(!1),w(!1)),c==null||c(s,!(G!=null&&G.video)))}).catch(()=>{j&&(p(!0),b(!1),w(!1),c==null||c(s,!0))})}else M("/api/claude-fm").then(W=>W.ok?W.json():null).then(W=>{if(!j)return;const G=!!(W!=null&&W.live&&(W!=null&&W.channel));G&&u({live:!0,channel:W.channel}),G||(p(!0),b(!1),w(!1)),c==null||c(s,!G)}).catch(()=>{j&&(p(!0),b(!1),w(!1),c==null||c(s,!0))});return()=>{j=!1}},[r==null?void 0:r.id,r==null?void 0:r.url,(O=r==null?void 0:r.radio)==null?void 0:O.hls,t,e,c,o,s,L,z]),m.useEffect(()=>()=>z(),[z]),m.useEffect(()=>{if(!f||l!=null&&l.audio)return;let j;const M=()=>{clearTimeout(j),j=void 0,b(!1),w(!1),y(!1),p(!0),c==null||c(s,!0)},F=()=>{j??=setTimeout(M,15e3)};F();const U=H=>{var Y;if(H.origin!==Qj||H.source!==((Y=R.current)==null?void 0:Y.contentWindow))return;const $=que(H.data);if($){if($.kind==="ready"){I(Od("setVolume",[_.current])),I(Od(D.current?"mute":"unMute")),I(Od("playVideo"));return}if($.kind==="blocked"){clearTimeout(j),j=void 0,b(!1),w(!1),y(!1);return}if($.kind==="buffering"){w(!1),y(!0),F();return}if($.kind==="playing"){clearTimeout(j),j=void 0,w($.playing),y(!1),$.playing||b(!1);return}zue.includes($.code)&&M()}};return window.addEventListener("message",U),()=>{clearTimeout(j),window.removeEventListener("message",U)}},[f,l==null?void 0:l.audio,o,c,I,s]);const P=m.useCallback(()=>{if(l){if(l.audio){if(f){z(),b(!1),w(!1),y(!1);return}L(l.audio,l.hls===!0,s);return}if(!f){b(!0),w(!1),y(!1);return}I(Od("pauseVideo")),b(!1),w(!1),y(!1)}},[l,f,v,s,I,L,z]);return m.useMemo(()=>({probe:l,dead:h,armed:f,playing:v,buffering:T,frame:R,say:I,press:P}),[l,h,f,v,T,I,P])}const gP="agent-dag.radio-favorites",mP="agent-dag.radio-recent",fP="agent-dag.radio-catalogue";function Oue(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const a=n,s=typeof a.id=="string"?a.id:"",o=typeof a.name=="string"?a.name.trim().slice(0,80):"",r=typeof a.url=="string"?M1(a.url):null,c=U5(a.radio??a);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(s)||!o||!c||!r||r.kind!=="direct-audio"||t.has(s)?[]:(t.add(s),[{id:s,name:o,url:r.url,radio:c}])})}function bP(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function Mue(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function d4e(e,t,n=Math.random){const a=e.filter(s=>s.id!==t);return a.length?a[Math.min(a.length-1,Math.floor(Math.max(0,n())*a.length))]:null}function u4e(e,t,n){if(!e.length)return null;const a=e.findIndex(o=>o.id===t),s=e[a<0?n===1?0:e.length-1:(a+n+e.length)%e.length];return s.id===t?null:s}function W5(e,t,n){const a=e.findIndex(s=>s.id===t);for(let s=1;s<=e.length;s++){const o=e[(a+s)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function h4e(e,t){if(!e.length)return null;const n=[...e].sort((s,o)=>s.id.localeCompare(o.id));let a=0;for(const s of t)a=Math.imul(a,31)+s.charCodeAt(0)>>>0;return n[a%n.length]}function p4e(e,t,n,a,s){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!a||e.radio.tags.toLowerCase().includes(a.toLowerCase()))&&(!s||e.radio.language.toLowerCase().includes(s.toLowerCase()))}function Iue(){const[e,t]=m.useState(()=>bP(gt(gP))),[n,a]=m.useState(()=>bP(gt(mP))),[s,o]=m.useState(()=>{try{return Oue(JSON.parse(gt(fP)??"[]"))}catch{return[]}});m.useEffect(()=>{yt(gP,JSON.stringify(e))},[e]),m.useEffect(()=>{yt(mP,JSON.stringify(n))},[n]);const r=m.useCallback(u=>a(h=>Mue(h,u)),[]),c=m.useCallback(u=>t(h=>h.includes(u)?h.filter(p=>p!==u):[...h,u].slice(-100)),[]),l=m.useCallback(u=>{o(u),yt(fP,JSON.stringify(u))},[]);return{favorites:e,recent:n,catalogue:s,remember:r,toggleFavorite:c,updateCatalogue:l}}function Due(e,t,n,a){const s=W5(e,t,n);if(!s)return()=>{};const o=setTimeout(()=>{n.add(t),a(s)},1e3);return()=>clearTimeout(o)}const dv=148,kP=6e3,Fue=16e3,H5=46,Jr=34;function Bue(e,t,n=dv){let a=-Math.round(t()*n);if(Math.abs(a-e)<Jr){const s=e-Jr>=-n?-Jr:Jr;a=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:a,ms:Math.round(Math.abs(a-e)*H5)}}function Uue(e){return Math.round(kP+e()*(Fue-kP))}const vP=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function Wue(e){const t=vP.reduce((a,s)=>a+s.weight,0);let n=e()*t;for(const a of vP)if(n-=a.weight,n<0)return a.kind;return"stroll"}const Hue=720,Gue=260,Vue=620,Kue=220,wP=520,G5=1600,yP=7e3,$ue=15e3,xP=6e3,Jue=14e3;function Yh(e,t,n=dv){let a=-Math.round(t()*n);if(Math.abs(a-e)<Jr){const s=e-Jr>=-n?-Jr:Jr;a=Math.max(-n,Math.min(0,Math.round(e+s)))}return a}const Kn=(e,t)=>Math.round(Math.abs(t-e)*H5),Yue=120,jf=0;function Zue(e,t){const n=a=>({kind:"litter",at:t,...a});return[{x:t,prop:n({}),act:"walk",ms:Kn(e,t)},{x:t,prop:n({}),act:"stoop",ms:Hue},{x:jf,prop:n({held:!0}),act:"carry",ms:Kn(t,jf)},{x:jf,prop:n({held:!0}),act:"windup",ms:Gue},{x:jf,prop:n({held:!0,leaving:!0}),act:"toss",ms:Vue}]}function Xue(e,t){const n=t>e?1:-1,a=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:a,prop:s(),act:"walk",ms:Kn(e,a)},{x:a,prop:s(),act:"windup",ms:Kue,facing:n>0?"right":"left"},{x:a,prop:s({leaving:!0}),act:"kick",ms:wP,facing:n>0?"right":"left"},{x:a,prop:s({leaving:!0}),act:"stand",ms:G5-wP}]}const V5=640;function Que(e,t,n){const a=Math.max(-70,Math.min(-20,t)),s={x:a,prop:null,facing:"left"};return[{x:a,prop:null,act:"walk",ms:Kn(e,a)},{...s,act:"sit",ms:600},{...s,act:"cast",ms:900},{...s,act:"fish",ms:6e3+Math.round(n()*4e3)},{...s,act:"reel",ms:1200},{...s,act:"stow",ms:500},{...s,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Kn(a,0)}]}function ehe(e,t,n){const a=Math.max(-110,Math.min(-30,t)),s={x:a,prop:null};return[{...s,act:"walk",ms:Kn(e,a)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:V5*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Kn(a,0)}]}function the(e,t,n){return[{x:t,prop:null,act:"walk",ms:Kn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(xP+n()*(Jue-xP))},{x:t,prop:null,act:"stand",ms:400}]}function nhe(e,t,n){t=Math.max(-110,Math.min(0,t));const a=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Kn(e,t)},{x:t,prop:a(),act:"watch",ms:Math.round(yP+n()*($ue-yP))},{x:t,prop:a(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Dy(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const ahe=1500,she=e=>Math.round(1e3*Math.sqrt(2*e/ahe)),ihe=115,ohe=e=>Math.round(e/ihe*1e3),rhe=620,che=200,lhe=760,dhe=600,uhe=240;function hhe(e,t,n){const s=-(t.ledgeSpan??dv),o=she(t.ledgeH),r=ohe(t.ledgeH),c=n(),l=n(),u=-Math.round(c*t.floorSpan),h=-Math.round(l*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Kn(e,s)},{x:s,act:"peer",prop:null,ms:rhe},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:che,place:"floor"},{x:u,act:"walk",prop:null,ms:Kn(s,u),place:"floor",floorFrac:c},{x:h,act:"walk",prop:null,ms:Kn(u,h),place:"floor",floorFrac:l},{x:s,act:"walk",prop:null,ms:Kn(h,s),place:"floor"},...t.ledgeH<=phe?[{x:s,act:"mount",prop:null,ms:K5}]:[{x:s,act:"lasso",prop:null,ms:lhe,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:dhe,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:uhe,place:"floor"},{x:s,act:"climb",prop:null,ms:r},{x:s,act:"pull-up",prop:null,ms:480}]]}const phe=42;function ghe(e,t,n){const a=(n==null?void 0:n.ledgeSpan)??dv;switch(Wue(t)){case"tidy":return Zue(e,Yh(e,t,a));case"kick":return Xue(e,Yh(e,t,a));case"sit":return the(e,Yh(e,t,a),t);case"watch":return nhe(e,Yh(e,t,a),t);case"fish":if(!n||!(n.ledgeH>0))break;return Que(e,-a,t);case"skip":return ehe(e,Yh(e,t,a),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return hhe(e,n,t)}}const o=Bue(e,t,a);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const mhe=420;function fhe(e,t,n){const a=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(mhe,Math.max(0,a))}const K5=260,bhe=200;function khe(e,t,n){const a=(h,p=Kn(e,h))=>({x:h,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[a(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[a(t)];const r=t>e,c=r?n.left:n.right,l=r?n.right:n.left,u={place:"floor",riser:n.height,prop:null};return[a(c,Kn(e,c)),{...u,x:c,act:"mount",ms:K5},{...u,x:l,act:"walk",ms:Kn(c,l)},{x:l,prop:null,act:"dismount",ms:bhe,place:"floor"},{x:t,prop:null,act:"walk",ms:Kn(l,t),place:"floor"}]}const $5=["bob","sway","groove"],CP=9e3,vhe=16e3,J5=1e3,whe=.08;function yhe(e,t){const n=$5.filter(o=>o!==e),a=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*whe;return{dance:a,beatMs:Math.round(J5*(1+s))}}function xhe(e){return Math.round(CP+e()*(vhe-CP))}const I1=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],SP=18,Che=I1.length,Y5="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",Z5="M12 9H14V6H13V3H11V2H9V4H12Z",D1=new Set(["a","c","p"]);function pc(e=I1){const t=[];return e.forEach((n,a)=>{let s=0;for(;s<n.length;){const o=n[s];if(o==="."){s+=1;continue}let r=1;for(;s+r<n.length&&n[s+r]===o;)r+=1;t.push({x:s,y:a,w:r,cell:o}),s+=r}}),t}const She=[".xx.","xxxx",".xx."],The=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],Nhe=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],Fy={litter:She,ball:The,scope:Nhe},Ahe=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],jhe=3,Ehe=-1,e0=11,TP=9;function NP(e){let t=null,n=null,a=0,s=0,o=!1;const r=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const u=n;n=null,u==null||u()},a))},l=()=>{e.hidden&&t!==null?(a=Math.max(0,a-(performance.now()-s)),r()):e.hidden||c()};return e.addEventListener("visibilitychange",l),{schedule(u,h){o||(r(),n=u,a=Math.max(0,h),c())},dispose(){o=!0,r(),n=null,e.removeEventListener("visibilitychange",l)}}}const Rhe=typeof window>"u"?m.useEffect:m.useLayoutEffect,AP=54,zhe=8,jP=12;function qhe(e,t){if(!(t.width>=AP))return null;const n=Math.round(Math.max(AP,Math.min(ml.width,t.width-ml.width-zhe)));return{right:Math.round(e-t.left-n),width:n}}const _he=(e,t)=>e===t||!!e&&!!t&&e.right===t.right&&e.width===t.width;function Lhe(e,t){const[n,a]=m.useState(null);return Rhe(()=>{var u;const s=t?(u=e.current)==null?void 0:u.parentElement:null;if(!s){a(null);return}let o=null;const r=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>c()),c=()=>{const h=s.querySelector(".react-flow__controls");h!==o&&(o&&(r==null||r.unobserve(o)),o=h,o&&(r==null||r.observe(o)));const p=h?qhe(s.getBoundingClientRect().right,h.getBoundingClientRect()):null;a(f=>_he(f,p)?f:p)},l=typeof MutationObserver>"u"?null:new MutationObserver(c);return r==null||r.observe(s),l==null||l.observe(s,{childList:!0}),c(),()=>{r==null||r.disconnect(),l==null||l.disconnect()}},[e,t]),n}function Phe(e,t,n){const[a,s]=m.useState(0),[o,r]=m.useState(0),[c,l]=m.useState(null),[u,h]=m.useState(null),[p,f]=m.useState({x:0,drop:0}),[b,v]=m.useState("ledge"),[w,T]=m.useState("left"),[y,x]=m.useState(0),C=m.useRef(null),[A,E]=m.useState(()=>document.hidden);m.useEffect(()=>{const P=new Set,O=()=>{var j;if(document.hidden){for(const M of((j=C.current)==null?void 0:j.getAnimations({subtree:!0}))??[])if(M.playState==="running"||M.pending){const F=M.currentTime;M.pause(),F!==null&&(M.currentTime=F),P.add(M)}}else{for(const M of P)M.playState==="paused"&&M.play();P.clear()}E(document.hidden)};return O(),document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},[e,t]);const[R,z]=m.useState(null),[I,_]=m.useState(J5),[D,L]=m.useState(()=>{var P;return((P=window.matchMedia)==null?void 0:P.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return m.useEffect(()=>{var j;const P=(j=window.matchMedia)==null?void 0:j.call(window,"(prefers-reduced-motion: reduce)");if(!P)return;const O=()=>L(P.matches);return O(),P.addEventListener("change",O),()=>P.removeEventListener("change",O)},[]),m.useEffect(()=>{var K;if(!e||t||D)return;const P=NP(document);let O=0;s(V=>O=V);let j=null,M=0,F=0;const U=V=>{var be,ie;const[ee,...de]=V;if(!ee){j=null,l(null),h(null),J();return}l(ee.act),h(ee.prop),v(ee.place??"ledge"),x(ee.riser??0);const he=O,me=G(ee);if(ee.act==="kick"){const ne=(ie=(be=C.current)==null?void 0:be.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ie.getBoundingClientRect();ne&&f({x:fhe(ne.x,Dy(ee,he,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-ne.y+24)})}F=ee.act==="walk"?Math.max(Kn(he,me),Yue):ee.ms,ee.act==="carry"&&(F=Kn(he,me)),r(F),T(ne=>Dy({...ee,x:me},he,ne)),s(me),O=me,j=ee,M=Date.now(),P.schedule(()=>U(de),F)},H=()=>{var ke,Se;const V=C.current,ee=V==null?void 0:V.querySelector(".fm-sprite"),de=V==null?void 0:V.parentElement;if(!V||!ee||!de)return null;const he=V.getBoundingClientRect(),me=de.getBoundingClientRect();let be=me.right-me.width+jP;const ie=(Se=(ke=de.querySelector)==null?void 0:ke.call(de,".react-flow__minimap"))==null?void 0:Se.getBoundingClientRect();ie&&ie.right<=he.right&&ie.bottom>he.bottom-ee.offsetHeight&&(be=Math.max(be,ie.right+jP));const ne=he.right-be-ee.offsetWidth;return ne>0?ne:null},$=()=>{const V=C.current,ee=V==null?void 0:V.querySelector(".fm-sprite");return!V||!ee?0:Math.max(0,V.getBoundingClientRect().width-ee.offsetWidth)},Y=()=>{const V=C.current,ee=V==null?void 0:V.querySelector(".fm-walker"),de=H();if(!V||!ee||de==null)return;const he=V.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(he>0)return{ledgeH:he,floorSpan:de,ledgeSpan:$()}},W=()=>{const V=C.current,ee=document.querySelector(".canvas-notices");if(!V||!ee)return null;const de=V.getBoundingClientRect(),he=ee.getBoundingClientRect();if(he.width<=0||he.height<=0)return null;const me=de.bottom-he.top;return me>0?{left:he.left-de.right,right:he.right-de.right,height:me}:null},G=V=>{const ee=(V.place??"ledge")==="floor",de=ee?H()??$():$(),he=ee&&V.floorFrac!=null?-Math.round(V.floorFrac*de):V.x;return Math.max(-de,Math.min(0,he))},Q=()=>{if(!j)return;const V=G(j);V!==O&&(r(Math.max(0,M+F-Date.now())),T(ee=>Dy({...j,x:V},O,ee)),s(V),O=V)},J=()=>{P.schedule(()=>{const V=ghe(O,Math.random,Y()),ee=V.some(me=>me.place==="floor")?W():null;let de=O;const he=V.flatMap(me=>{const be=de;if(de=me.x,!(me.place==="floor"&&me.act==="walk"))return[me];const ie=khe(be,me.x,ee),ne=ie.length-1;return me.floorFrac==null?ie:ie.map((ke,Se)=>Se===ne?{...ke,floorFrac:me.floorFrac}:ke)});U(he)},Uue(Math.random))},X=(K=C.current)==null?void 0:K.parentElement,te=typeof ResizeObserver>"u"?null:new ResizeObserver(Q);return X&&te&&te.observe(X),J(),()=>{P.dispose(),te==null||te.disconnect(),v("ledge"),s(V=>Math.max(-$(),Math.min(0,V))),r(0),l(null),h(null),x(0)}},[e,t,D]),m.useEffect(()=>{if(!n||D){z(null);return}const P=NP(document),O=j=>{const M=yhe(j,Math.random);z(M.dance),_(M.beatMs),P.schedule(()=>O(M.dance),xhe(Math.random))};return O(null),()=>P.dispose()},[n,D]),{scene:C,suspended:A,x:a,walkMs:o,act:c,prop:u,ballFlight:p,place:b,facing:w,riser:y,dance:R,beatMs:I}}const By={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Xb=pc().filter(e=>!D1.has(e.cell)),Ohe=pc().filter(e=>D1.has(e.cell)),EP=Xb.filter(e=>e.cell==="e"),Mhe=pc(Ahe),Ihe=Xb.filter(e=>e.y<e0&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),Dhe={left:Xb.filter(e=>e.y>=e0&&e.x<TP),right:Xb.filter(e=>e.y>=e0&&e.x>=TP)},Fhe=m.memo(function({act:t,facing:n}){return i.jsxs("svg",{viewBox:`0 0 ${SP} ${Che}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("g",{className:"fm-gear",children:i.jsx("g",{className:"fm-gear-motion",children:Ohe.map(a=>i.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:By[a.cell]},`g${a.y}-${a.x}`))})}),i.jsxs("g",{className:"fm-body",children:[EP.map(a=>i.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:"var(--accent)"},`eye-bed-${a.x}`)),Ihe.map(a=>i.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:By[a.cell]},`b${a.y}-${a.x}`)),i.jsxs("g",{className:"fm-arms",children:[i.jsx("rect",{x:4,y:8,width:2,height:2}),i.jsx("rect",{x:12,y:8,width:1,height:2}),i.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),EP.map(a=>i.jsx("rect",{x:a.x-(a.x>=SP/2?1:0)+(n==="right"?1:0),y:a.y,width:a.w,height:1,className:"fm-eye"},`eye-${a.x}`))]}),i.jsx("g",{className:"fm-hat",children:Mhe.map(a=>i.jsx("rect",{x:jhe+a.x,y:Ehe+a.y,width:a.w,height:1,className:a.cell==="k"?"fm-hatband":void 0},`h${a.y}-${a.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&i.jsxs("g",{className:"fm-grip",children:[i.jsx("path",{className:"fm-grip-left",d:Y5}),i.jsx("path",{className:"fm-grip-right",d:Z5})]}),(t==="land"||t==="dismount")&&i.jsxs("g",{className:"fm-crouch-legs",children:[i.jsx("path",{d:"M6 11H8V13H6Z"}),i.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&i.jsxs("g",{className:"fm-seated-legs",children:[i.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),i.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(a=>i.jsx("g",{className:"fm-leg","data-side":a,children:Dhe[a].map(s=>i.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:By[s.cell]},`${a}${s.y}-${s.x}`))},a))]})}),Bhe=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],Uhe=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],Qi={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},Whe={p:"fm-pad"},og=pc(Bhe),Hhe=pc(Uhe);function t0(e,t,n){return e.map(a=>({...a,x:Math.max(t,a.x),w:Math.max(0,Math.min(n,a.x+a.w)-Math.max(t,a.x))})).filter(a=>a.w>0)}const Ghe=t0(og.filter(e=>e.y>=8),12,18),Vhe=og.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),RP=og.filter(e=>e.cell==="e"),Khe={left:t0(og.filter(e=>e.y>=11),0,9),right:t0(og.filter(e=>e.y>=11),9,12)},$he=m.memo(function({act:t,facing:n}){const a=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return i.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[i.jsx("g",{className:"fm-body","data-part":"tail",children:Ghe.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Qi[r.cell]},`t${r.y}-${r.x}`))}),i.jsx("g",{className:"fm-gear",children:i.jsx("g",{className:"fm-gear-motion",children:Hhe.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Whe[r.cell]},`g${r.y}-${r.x}`))})}),i.jsxs("g",{className:"fm-body",children:[Vhe.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Qi[r.cell]},`b${r.y}-${r.x}`)),RP.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Qi.f},`bed${r.x}`)),i.jsxs("g",{className:"fm-arms",fill:Qi.f,children:[i.jsx("rect",{x:4,y:8,width:2,height:2}),i.jsx("rect",{x:12,y:8,width:1,height:2})]}),RP.map(r=>i.jsx("rect",{x:r.x+(n==="right"?1:0)-(r.x>=9?1:0),y:r.y,width:r.w,height:1,className:"fm-eye",style:{fill:Qi.n}},`e${r.x}`))]}),a&&i.jsxs("g",{className:"fm-grip",style:{fill:Qi.f},children:[i.jsx("path",{className:"fm-grip-left",d:Y5}),i.jsx("path",{className:"fm-grip-right",d:Z5})]}),s&&i.jsxs("g",{className:"fm-crouch-legs",style:{fill:Qi.f},children:[i.jsx("path",{d:"M6 11H8V13H6Z"}),i.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&i.jsxs("g",{className:"fm-seated-legs",style:{fill:Qi.f},children:[i.jsx("path",{className:"fm-seated-far",style:{fill:Qi.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),i.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>i.jsx("g",{className:"fm-leg","data-side":r,children:Khe[r].map(c=>i.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:Qi[c.cell]},`${c.y}-${c.x}`))},r))]})}),Jhe=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Ko={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},Yhe={p:"fm-pad"},Qb=pc(Jhe),Zhe=pc(I1).filter(e=>D1.has(e.cell)),zP=Qb.filter(e=>e.cell==="e"),Xhe=Qb.filter(e=>e.y<12&&e.cell!=="e"),Qhe={left:Qb.filter(e=>e.y>=12&&e.x<9),right:Qb.filter(e=>e.y>=12&&e.x>=9)},epe=m.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",a=t==="land"||t==="dismount",s=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return i.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[i.jsx("g",{className:"fm-gear",children:i.jsx("g",{className:"fm-gear-motion",children:Zhe.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:Yhe[o.cell]},`g${o.y}-${o.x}`))})}),i.jsxs("g",{className:"fm-body",children:[Xhe.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Ko[o.cell]},`b${o.y}-${o.x}`)),zP.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Ko.w},`bed${o.x}`)),i.jsxs("g",{className:"fm-arms",fill:Ko.d,children:[i.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),i.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),zP.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Ko.e}},`e${o.x}`))]}),n&&i.jsxs("g",{className:"fm-grip",style:{fill:Ko.h},children:[i.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),i.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),a&&i.jsxs("g",{className:"fm-crouch-legs",style:{fill:Ko.b},children:[i.jsx("path",{d:"M5 12H8V13H5Z"}),i.jsx("path",{d:"M10 12H13V13H10Z"})]}),s&&i.jsxs("g",{className:"fm-seated-legs",style:{fill:Ko.b},children:[i.jsx("path",{className:"fm-seated-far",style:{fill:Ko.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),i.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>i.jsx("g",{className:"fm-leg","data-side":o,children:Qhe[o].map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ko.b},`${r.y}-${r.x}`))},o))]})});function X5({character:e,act:t,facing:n}){return e==="penguin"?i.jsx(epe,{act:t,facing:n}):e==="fox"?i.jsx($he,{act:t,facing:n}):i.jsx(Fhe,{act:t,facing:n})}const tpe={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function Q5(e,t,n=S){return t&&Au(t.id)===e?t.name:lv(e)?n("radio.fm.custom"):tpe[e]}function Uy(e,t){var a;const n=((a=e[0])==null?void 0:a.length)??0;return i.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:pc(e).map(s=>i.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const qP={litter:Uy(Fy.litter,"litter"),ball:Uy(Fy.ball,"ball"),scope:Uy(Fy.scope,"scope")};function npe(e,t=S){try{return new URL(e).host}catch{return t("radio.fm.server")}}const ape=m.memo(function({player:t,source:n,customStation:a,character:s="deck"}){const o=se(),{probe:r,dead:c,playing:l,press:u}=t,{scene:h,suspended:p,x:f,walkMs:b,act:v,prop:w,ballFlight:T,place:y,facing:x,riser:C,dance:A,beatMs:E}=Phe(r,c,l),R=Lhe(h,!!r&&!c);if(!r||c)return null;const z=Q5(n,a,o),I=r.audio?npe(r.audio,o):"YouTube";return i.jsxs("div",{ref:h,className:"fm","data-suspended":p?"":void 0,"data-place":y,"data-ledge":R?"bar":void 0,style:{"--fm-beat":`${E}ms`,"--fm-right":R?`${R.right}px`:void 0,"--fm-ledge-w":R?`${R.width}px`:void 0},children:[w&&!w.held&&i.jsx("div",{className:"fm-prop","data-prop":w.kind,"data-leaving":w.leaving?"":void 0,style:{"--fm-prop-x":`${w.at}px`,"--fm-roll-to":`${T.x}px`,"--fm-ball-drop":`${T.drop}px`,"--fm-ball-flight-ms":`${G5}ms`,"--fm-ball-turn":x==="right"?"1080deg":"-1080deg"},children:qP[w.kind]}),(v==="lasso"||v==="rope-throw"||v==="rope-catch"||v==="climb"||v==="pull-up")&&i.jsxs("div",{className:"fm-rope","data-act":v,style:{"--fm-rope-x":`${f}px`,"--fm-rope-ms":`${b}ms`},children:[i.jsx("div",{className:"fm-rope-line"}),i.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),i.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),i.jsxs("div",{className:"fm-walker","data-act":v??void 0,"data-place":y,"data-facing":x,style:{"--fm-x":`${f}px`,"--fm-walk-ms":`${b}ms`,"--fm-riser":`${C}px`,"--fm-skip-beat":`${V5}ms`},children:[(w==null?void 0:w.held)&&i.jsx("div",{className:"fm-held","data-prop":w.kind,"data-toss":w.leaving?"":void 0,children:qP[w.kind]}),["cast","fish","reel","stow"].includes(v)&&i.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsxs("g",{children:[i.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),i.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),i.jsxs("g",{className:"fm-fishing-line",children:[i.jsx("path",{d:"M8 2V18"}),i.jsxs("g",{className:"fm-float",children:[i.jsx("rect",{x:"7",y:"17",width:"3",height:"2"}),i.jsx("rect",{x:"8",y:"16",width:"1",height:"1"})]})]}),i.jsx("path",{className:"fm-ripple",d:"M3 20H6M10 20H14M5 22H12"})]}),["skip-ready","skip","skip-rest"].includes(v)&&i.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),i.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),i.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),i.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),i.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),i.jsx("button",{type:"button",className:"fm-sprite","data-playing":l?"":void 0,"data-dance":l?A??$5[0]:void 0,onClick:u,title:l?o("radio.fm.stop",{label:z}):o("radio.fm.playTitle",{label:z,from:I}),"aria-label":l?o("radio.fm.stop",{label:z}):o("radio.fm.play",{label:z}),children:i.jsx(X5,{character:s,act:v,facing:x})})]})]})});function spe({player:e,label:t}){const{probe:n,armed:a,frame:s,say:o}=e;return n?i.jsx(i.Fragment,{children:a&&!n.audio&&(n.channel||n.video)&&i.jsx("iframe",{ref:s,className:"fm-frame",title:t,src:Aue(n.channel,window.location.origin,n.video),onLoad:()=>o(jue()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const ipe={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6",headphones:"M4 14v-3a8 8 0 0 1 16 0v3 M4 12h3v8H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 1-2 M20 12h-3v8h2a2 2 0 0 0 2-2v-4a2 2 0 0 0-1-2",book:"M12 6v15 M12 6C9 4 6 3 3 4v15c3-1 6 0 9 2 3-2 6-3 9-2V4c-3-1-6 0-9 2",gamepad:"M8 7h8c3 0 4 2 5 8 1 5-2 6-5 2H8c-3 4-6 3-5-2 1-6 2-8 5-8z M6 11h4 M8 9v4 M16 10h.01 M18 13h.01",sunset:"M3 17h18 M5 21h14 M7 17a5 5 0 0 1 10 0 M12 3v3 M4 8l2 2 M20 8l-2 2",moon:"M20 14A9 9 0 0 1 10 3a9 9 0 1 0 10 11z",cassette:"M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z M7 8h10v5H7z M7 20l2-4h6l2 4 M9 10.5h.01 M15 10.5h.01",palm:"M12 8c2 4 3 8 2 13 M12 8C8 3 4 4 2 8c4-1 7-1 10 0 M12 8c1-6 6-7 10-2-4-1-7 0-10 2 M12 8c-5 0-7 3-7 7 2-3 4-5 7-7 M12 8c4 0 7 3 7 7-2-3-4-5-7-7 M10 21h8",coffee:"M4 8h12v8a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4z M16 9h2a3 3 0 0 1 0 6h-2 M7 3v2 M11 3v2 M3 22h15",check:"M5 12l4 4L19 6",filters:"M4 6h4 M12 6h8 M4 12h10 M18 12h2 M4 18h2 M10 18h10 M8 4v4 M14 10v4 M6 16v4"};function ope({name:e}){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:ipe[e]})})}function rpe({opening:e=!1}){const t=se(),[n,a]=m.useState(()=>document.hidden);return m.useEffect(()=>{const s=()=>a(document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),i.jsxs("div",{className:"radio-tuning",role:"status","data-paused":n||void 0,children:[i.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsxs("g",{className:"radio-tuning-tower",children:[i.jsx("circle",{cx:"40",cy:"24",r:"4"}),i.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),i.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),i.jsxs("g",{className:"radio-tuning-send",children:[i.jsx("path",{d:"M75 26q7 8 0 16"}),i.jsx("path",{d:"M102 26q7 8 0 16"}),i.jsx("path",{d:"M129 26q7 8 0 16"})]}),i.jsxs("g",{className:"radio-tuning-receiver",children:[i.jsx("path",{d:"M165 49l30-22"}),i.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),i.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),i.jsx("circle",{cx:"202",cy:"65",r:"7"}),i.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),i.jsx("strong",{children:t(e?"radio.loading.opening":"radio.loading.tuning")}),i.jsx("span",{children:t(e?"radio.loading.ready":"radio.loading.finding")})]})}function cpe({onClose:e}){const t=se(),[n]=m.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),a=Zt(e);return i.jsxs("div",{ref:a,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":t("radio.loading.opening"),"data-keyboard-interaction":n||void 0,onKeyDown:ule,children:[i.jsx("button",{type:"button",className:"icon-btn","aria-label":t("radio.close"),onClick:e,children:i.jsx(ope,{name:"close"})}),i.jsx(rpe,{opening:!0})]})}const lpe=m.lazy(()=>Xs(()=>import("./RadioPanel-Dw3zruRE.js"),[]));function eG({fm:e,characterEnabled:t,character:n,open:a,onClose:s}){const[o,r]=m.useState(!1),c=se(),[l,u]=m.useState("connecting"),h=c(`radio.disabled.${l}`),p=Iue(),[f,b]=m.useState(null),v=m.useRef(new Set);m.useEffect(()=>{const _=new AbortController;return fetch("/api/music-config",{signal:_.signal}).then(D=>D.ok?D.json():null).then(D=>{_.signal.aborted||(r((D==null?void 0:D.enabled)===!0),u(D?"off":"unreachable"))}).catch(()=>{_.signal.aborted||u("unreachable")}),()=>_.abort()},[a]);const w=e.customFmStations.find(_=>Au(_.id)===e.fmSource),T=w!=null&&w.radio?w:void 0,y=Pue({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),x=Q5(e.fmSource,w,c),C=o&&T&&y.dead&&e.fmPlayRequest>0?W5(f??p.catalogue,T.id,v.current):null,{remember:A}=p,E=(w==null?void 0:w.id)??e.fmSource;m.useEffect(()=>{y.playing&&A(E)},[E,y.playing,A]);const R=s,z=tn(s),I=m.useCallback((_,D=!1)=>{var j;if(!o)return;D||v.current.clear();const L=Au(_.id),P=L===e.fmSource;if(P&&y.armed&&!y.dead){y.press();return}const O=P&&!!w&&(w.url!==_.url||((j=w.radio)==null?void 0:j.hls)!==_.radio.hls);e.addFmStation(_,!0),P&&!y.dead&&!O?y.press():e.pickFmSource(L,O),fetch(`/api/radio-click?id=${encodeURIComponent(_.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,y.armed,y.dead,y.press]);return m.useEffect(()=>{y.playing&&!y.dead&&v.current.clear()},[y.playing,y.dead]),m.useEffect(()=>{if(!(!o||!T||!y.dead||e.fmPlayRequest===0))return Due(f??p.catalogue,T.id,v.current,_=>I(_,!0))},[o,T==null?void 0:T.id,y.dead,e.fmPlayRequest,f,p.catalogue,I]),i.jsxs(i.Fragment,{children:[t&&i.jsx(ape,{character:n,player:y,source:e.fmSource,customStation:w}),i.jsx(spe,{player:y,label:x}),i.jsx(Ft,{when:a,children:()=>$t.createPortal(i.jsx(s5,{scrim:z,className:"radio-backdrop",children:i.jsx(m.Suspense,{fallback:i.jsx(cpe,{onClose:R}),children:i.jsx(lpe,{fm:e,player:y,library:p,selected:T,label:x,enabled:o,disabledReason:h,autoNext:C==null?void 0:C.name,onPick:I,onQueueChange:b,onClose:R})})}),document.body)})]})}function dpe(){return i.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[i.jsx("path",{d:"M3.3 3.3l5.4 5.4M8.7 3.3l-5.4 5.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",fill:"none"}),i.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function n0({recap:e}){return e?i.jsx(dpe,{}):i.jsx("svg",{className:"recap-glyph note-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:i.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"currentColor"})})}function upe({data:e}){const t=se(),n=xo(3e4),a=e.note,s=e.plan??null,o=(a==null?void 0:a.kind)==="recap",r=Yb((a==null?void 0:a.at)??(s==null?void 0:s.at)??n,n),c=`${o?"recap-note":`recap-note is-status status-${(a==null?void 0:a.kind)??"plan"}`}${s?" has-plan":""}`,l=o||!a?void 0:av(a),u=yo(s),h=a?Su(a.kind):`${t("board.detail.plan").toLowerCase()} ${u?`${u.done}/${u.total}`:""}`.trim();return i.jsxs("div",{className:c,role:"note","aria-label":o?t("board.node.recapLabel"):t("board.node.noteLabel",{tag:h}),"aria-description":l,children:[i.jsxs("div",{className:"recap-note-head",title:l,children:[i.jsxs("span",{className:"recap-note-mark",children:[i.jsx(n0,{recap:o}),h]}),i.jsx("span",{className:"recap-note-age",title:r.title,children:r.label}),i.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":t(o?"board.node.hideRecap":a?"board.node.hideNote":"board.node.hidePlan"),title:t("board.note.hideTitle"),onClick:p=>{p.stopPropagation(),Gle(e.noteKey)},children:i.jsx(Ze,{name:"close"})})]}),a&&i.jsx("p",{className:"recap-note-text",title:vre(a.text,l),children:a.text}),(a==null?void 0:a.reply)&&i.jsx("p",{className:"recap-note-reply",title:t("board.list.reply",{reply:a.reply}),children:t("board.list.reply",{reply:a.reply})}),s&&i.jsx(_P,{plan:s,head:a!=null}),i.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[i.jsxs("div",{className:"lod-id",children:[i.jsxs("span",{className:"recap-note-mark",children:[i.jsx(n0,{recap:o}),h]}),i.jsx("span",{className:"recap-face-age",children:r.label})]}),a&&i.jsx("p",{className:"recap-face-text",children:a.text}),s&&i.jsx(_P,{plan:s,head:a!=null,face:!0})]}),i.jsx(Tl,{type:"source",position:xt.Right,style:{background:"transparent",border:"none"}})]})}const hpe={completed:"board.state.done",in_progress:"board.detail.now",pending:"board.detail.todo"};function _P({plan:e,head:t,face:n=!1}){const a=se(),s=yo(e);if(!s)return null;const o=ure(e.items);return i.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:Kk(e.items),children:[t&&i.jsxs("div",{className:"recap-note-plan-head",children:[a("board.detail.plan")," ",i.jsxs("span",{className:"recap-note-plan-count",children:[s.done,"/",s.total,s.allDone?` · ${a("board.state.done")}`:""]})]}),!s.allDone&&i.jsxs("ol",{className:"plan-list",children:[o.shown.map((r,c)=>i.jsxs("li",{className:"plan-item","data-status":r.status,children:[i.jsx("span",{className:"plan-mark","aria-hidden":!0}),!n&&i.jsxs("span",{className:"vis-hidden",children:[a(hpe[r.status]),a("board.detail.colon")]}),i.jsx("span",{className:"plan-text",children:r.status==="in_progress"&&r.active?r.active:r.text}),r.status==="in_progress"&&i.jsx("span",{className:"plan-now","aria-hidden":!0,children:a("board.detail.now")})]},r.id??`${c}:${r.text}`)),(o.before>0||o.after>0)&&i.jsx("li",{className:"recap-note-plan-more",children:[o.before>0?a("board.note.earlier",{n:o.before}):null,o.after>0?a("board.note.more",{n:o.after}):null].filter(Boolean).join(" · ")})]})]})}function ppe({sourceX:e,sourceY:t,targetX:n,targetY:a,sourcePosition:s,targetPosition:o,style:r}){const[c]=GE({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:a,targetPosition:o,curvature:.35});return i.jsxs("g",{className:"recap-tie",style:r,children:[i.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),i.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),i.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),i.jsx("circle",{className:"recap-tie-end",cx:n,cy:a,r:3.5})]})}function tG(e,t=S){const n=[e.tipWorkspace,e.planLine?t("board.cluster.plan",{plan:e.planLine}):void 0,e.tipRest||void 0].filter(Boolean).join(du),a=e.startedAt!=null&&e.idTail?`${f5(e.startedAt,e.idTail,Date.now(),t)}
|
|
122
|
+
`);return i.jsx("div",{className:"waiting-row",title:o,children:i.jsx("span",{className:`waiting-said${s?" mono":""}`,children:s?s.preview?`${s.name} · ${s.preview}`:s.name:Hj(e,t)})})}const P1="agent-dag.single-key-shortcuts";function L5(e){return e!=="0"}function O1(e){return e.length===1}function Qde(e,t){return!t&&O1(e)}function bo(e,t,n){return n?`${e} (${t})`:e}let kl=null;const kp=new Set;function P5(){for(const e of kp)e()}function Zj(){return kl===null&&(kl=L5(gt(P1))),kl}function O5(e){kl!==e&&(kl=e,yt(P1,e?"1":"0"),P5())}function sP(e){if(e.key!==P1)return;const t=L5(e.newValue);t!==kl&&(kl=t,P5())}function eue(e){var t;return kp.add(e),kp.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",sP)),()=>{var n;kp.delete(e),kp.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",sP))}}function sa(){return m.useSyncExternalStore(eue,Zj,Zj)}function tue(e){return`${Math.round(e*100)}%`}function M5(e,t,n){if(n<=0||tv(e))return{kind:"pass"};const a=t>=0&&t<n?t:-1;switch(e.key){case"ArrowDown":return{kind:"focus",index:a===-1?0:(a+1)%n};case"ArrowUp":return{kind:"focus",index:a===-1?n-1:(a-1+n)%n};case"Home":return{kind:"focus",index:0};case"End":return{kind:"focus",index:n-1};default:return{kind:"pass"}}}function nue(e,t,n){const a=e.key==="ArrowRight"?"ArrowDown":e.key==="ArrowLeft"?"ArrowUp":e.key;return M5({...e,key:a},t,n)}const Vs=4,An=8;function cv(e,t,n){const a=n.width-An-(e.right+Vs),s=e.left-Vs-An,o=t.width<=a||a>=s?"right":"left",r=o==="right"?e.right+Vs:e.left-Vs-t.width,c=n.height-An*2,l=t.height<=c,u=l?t.height:Math.max(0,c),h=Math.max(An,Math.min(e.top,n.height-An-u)),p=Math.max(An,Math.min(r,n.width-An-t.width));return{top:h,left:p,side:o,maxHeight:l?null:u}}function aue(e,t,n,a=0){const s=n.width-An-e.right-Vs,o=e.left-Vs-An;if(t.width<=Math.max(s,o))return cv(e,t,n);const r=Math.max(0,Math.min(e.top-Vs,n.height-An)-An);if(r<=0||r<Math.min(t.height,a))return null;const c=Math.min(t.height,r);return{side:"above",top:Math.max(An,Math.min(e.top-Vs,n.height-An)-c),left:Math.max(An,Math.min(e.right-t.width,n.width-An-t.width)),maxHeight:c<t.height?c:null}}function I5(e,t,n,a="end",s=!1){const o=n.height-An-(e.bottom+Vs),r=e.top-Vs-An,c=t.height<=o||o>=r?"below":"above",l=s?n.height-An*2:c==="below"?o:r,u=t.height<=l,h=u?t.height:Math.max(0,l),p=c==="below"?e.bottom+Vs:e.top-Vs-h,f=s?Math.min(p,n.height-An-h):p,b=a==="start"?e.left:e.right-t.width,v=Math.max(An,Math.min(b,n.width-An-t.width));return{top:Math.max(An,f),left:v,side:c,maxHeight:u?null:h}}function sue(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function iue(e,t,n){const a=m.useRef(t);a.current=t;const s=m.useRef(n);s.current=n,m.useEffect(()=>{const o=r=>{sue(r.target,e.current,a.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const D5='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function iP(e){return e?Array.from(e.querySelectorAll(D5)).filter(t=>!t.disabled):[]}function Rs({anchorId:e,boundaryId:t,portalRootId:n,id:a,className:s,role:o,labelledBy:r,start:c="first",focusRef:l,fallbackFocus:u,onClose:h,align:p="end",overAnchor:f=!1,children:b}){const v=m.useRef(h);v.current=h;const w=m.useRef(u);w.current=u;const T=Zt(()=>{var E;(E=document.getElementById(e))==null||E.focus(),v.current()},{popover:!0,focusRef:l}),y=m.useCallback(()=>{var L,P,O;const E=T.current;if(!E)return;const R=document.getElementById(e);if(!R){v.current();return}if(R.getClientRects().length===0){E.contains(document.activeElement)&&((P=(L=w.current)==null?void 0:L.call(w))==null||P.focus()),v.current();return}const z=R.getBoundingClientRect(),I=t?(O=document.getElementById(t))==null?void 0:O.getBoundingClientRect():null;if(I&&(z.bottom<=I.top||z.top>=I.bottom)){E.contains(document.activeElement)&&R.focus({preventScroll:!0}),v.current();return}const _=E.scrollTop;E.style.maxHeight="";const D=I5(z,{width:E.offsetWidth,height:E.offsetHeight},{width:window.innerWidth,height:window.innerHeight},p,f);E.style.top=`${D.top}px`,E.style.left=`${D.left}px`,E.style.maxHeight=D.maxHeight==null?"":`${D.maxHeight}px`,_&&(E.scrollTop=_),E.dataset.side=D.side},[e,t,T,p,f]);m.useLayoutEffect(()=>{y()}),m.useEffect(()=>{var R;if(typeof ResizeObserver>"u")return;const E=new ResizeObserver(y);for(const z of Array.from(((R=T.current)==null?void 0:R.children)??[]))E.observe(z);return()=>E.disconnect()},[y,T]),m.useEffect(()=>{const E=R=>{var z;(z=T.current)!=null&&z.contains(R.target)||y()};return window.addEventListener("scroll",E,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",y)}},[y,T]),iue(T,()=>document.getElementById(e),h),m.useEffect(()=>{var R;if(o!=="menu")return;const E=iP(T.current);(R=c==="last"?E[E.length-1]:E[0])==null||R.focus()},[]);const x=E=>{var R;if(o==="menu"&&E.key==="Tab"){E.stopPropagation(),(R=document.getElementById(e))==null||R.focus(),E.shiftKey&&E.preventDefault(),v.current();return}if(o==="menu"){const z=iP(T.current),I=M5(E,z.indexOf(document.activeElement),z.length);I.kind==="focus"&&(E.preventDefault(),z[I.index].focus())}E.key.length===1&&E.stopPropagation()},C=E=>{E.target.closest("button, input, select, textarea, code")||E.preventDefault()},A=E=>{if(o!=="menu"||E.pointerType==="touch")return;const R=E.target.closest(D5);R&&!R.disabled&&document.activeElement!==R&&R.focus({preventScroll:!0})};return $t.createPortal(i.jsx("div",{ref:T,id:a,className:`anchored-popover${s?` ${s}`:""}`,role:o,"aria-labelledby":r,onKeyDown:x,onMouseDown:C,onPointerMove:A,children:b}),(n?document.getElementById(n):null)??document.body)}function _g(e){return i.jsxs("span",{className:"cbx",children:[i.jsx("input",{type:"checkbox",...e}),i.jsx("svg",{className:"cbx-tick",viewBox:"0 0 14 14","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"M3.5 7.5 6 10l4.5-5.5",pathLength:"1"})})]})}function oue({headId:e,presentCats:t,hiddenCats:n,toggleCat:a}){const s=se(),o=()=>{for(const r of n)a(r)};return i.jsxs("div",{role:"group","aria-labelledby":e,className:"cat-tools-group",children:[i.jsx("div",{id:e,className:"cat-tools-head",children:s("board.detail.toolCalls")}),t.map(r=>{const c=n.has(r);return i.jsxs("label",{className:`ap-menu-item cat-tools-item cat-${r}${c?" off":""}`,children:[i.jsx(_g,{role:"menuitemcheckbox",checked:!c,onChange:()=>a(r),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a(r))}}),i.jsx("span",{className:"cat-dot","aria-hidden":"true"}),i.jsx("span",{className:"cat-name",children:Wb(r,s)})]},r)}),n.size>0&&i.jsx("div",{role:"separator",className:"ap-menu-sep"}),n.size>0&&i.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item cat-tools-all",onClick:r=>{var c,l;document.activeElement===r.currentTarget&&((l=(c=r.currentTarget.parentElement)==null?void 0:c.querySelector("input"))==null||l.focus({preventScroll:!0})),o()},children:s("board.cat.showAll")})]})}function lu({children:e,label:t}){return t?i.jsxs(i.Fragment,{children:[i.jsx("kbd",{className:"kbd","aria-hidden":!0,children:e}),i.jsx("span",{className:"kbd-spoken",children:t})]}):i.jsx("kbd",{className:"kbd",children:e})}const rue=e=>e.transform[2]>=e.maxZoom,cue=e=>e.transform[2]<=e.minZoom,lue=e=>tue(e.transform[2]),oP=1.2,due=[],uue=new Set;function hue(e,t){return e.length>1||t.size>0}function pue(e,t){return e.some(n=>t.has(n))}function gue({autoFitDisabled:e,enableAutoFitAndRefit:t,handleRelayout:n,requestClear:a,setKeyHelpOpen:s,zoomBy:o,zoomReset:r,onTerminal:c,presentCats:l=due,hiddenCats:u=uue,toggleCat:h}){const p=se(),f=Wt(rue),b=Wt(cue);return Tg()?c?i.jsx(gL,{position:"bottom-right",showInteractive:!1,showFitView:!1,showZoom:!1,children:i.jsx(fue,{onTerminal:c})}):null:i.jsxs(gL,{position:"bottom-right",showInteractive:!1,showFitView:!1,showZoom:!1,children:[i.jsx(Ci,{onClick:()=>{b||o(1/oP)},title:p("board.controls.zoomOut"),"aria-label":p("board.controls.zoomOut"),"aria-disabled":b||void 0,children:i.jsx(Ze,{name:"minus"})}),i.jsx(bue,{zoomReset:r}),i.jsx(Ci,{onClick:()=>{f||o(oP)},title:p("board.controls.zoomIn"),"aria-label":p("board.controls.zoomIn"),"aria-disabled":f||void 0,children:i.jsx(Ze,{name:"plus"})}),i.jsx("span",{className:"react-flow__controls-divider","aria-hidden":!0}),i.jsx(Ci,{onClick:t,title:p(e?"board.controls.recenterOn":"board.controls.recenterAuto"),"aria-label":p("board.controls.recenter"),"data-nudge":e?"":void 0,children:i.jsx(Ze,{name:"recenter"})}),i.jsx(mue,{handleRelayout:n,requestClear:a,setKeyHelpOpen:s,onTerminal:c,presentCats:l,hiddenCats:u,toggleCat:h})]})}const $h="canvas-more",rP="canvas-more-menu";function Af({label:e,keyCap:t,onPick:n}){const s=sa()?t:void 0;return i.jsxs("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:n,"aria-keyshortcuts":s,children:[i.jsx("span",{className:"canvas-more-word",children:e}),s&&i.jsx("span",{className:"canvas-more-key","aria-hidden":!0,children:i.jsx(lu,{children:s})})]})}function mue({handleRelayout:e,requestClear:t,setKeyHelpOpen:n,onTerminal:a,presentCats:s,hiddenCats:o,toggleCat:r}){const c=se(),l=sa(),u=m.useId(),[h,p]=m.useState(null),f=h!==null,b=r&&hue(s,o)?r:null,v=b!=null&&pue(s,o),w=c(v?"board.controls.moreFiltered":"accounts.row.more"),T=y=>()=>{var x;(x=document.getElementById($h))==null||x.focus(),p(null),y()};return i.jsxs(i.Fragment,{children:[i.jsxs(Ci,{id:$h,className:"canvas-more",title:w,"aria-label":w,"aria-haspopup":"menu","aria-expanded":f,"aria-controls":f?rP:void 0,onKeyDown:y=>{y.key!=="ArrowDown"&&y.key!=="ArrowUp"||(y.preventDefault(),p(y.key==="ArrowUp"?"last":"first"))},onClick:()=>p(f?null:"first"),children:[i.jsx(Ze,{name:"more"}),v&&i.jsx("span",{className:"canvas-more-dot","aria-hidden":!0})]}),f&&i.jsxs(Rs,{anchorId:$h,id:rP,className:"ap-pop canvas-more-pop",role:"menu",labelledBy:$h,start:h,onClose:()=>p(null),children:[i.jsx(Af,{label:c("board.controls.arrangeLabel"),keyCap:"R",onPick:T(e)}),i.jsx(Af,{label:c("board.quick.action.clear"),keyCap:"C",onPick:T(()=>t("button"))}),i.jsx("div",{role:"separator",className:"ap-menu-sep"}),a&&i.jsx(Af,{label:c("board.controls.openPanel"),onPick:T(()=>a(document.getElementById($h)))}),i.jsx(Af,{label:c(l?"board.controls.keys":"board.controls.keysOff"),keyCap:"?",onPick:T(()=>n(y=>!y))}),b&&i.jsxs(i.Fragment,{children:[i.jsx("div",{role:"separator",className:"ap-menu-sep"}),i.jsx(oue,{headId:u,presentCats:s,hiddenCats:o,toggleCat:b})]})]})]})}function fue({onTerminal:e}){const t=se();return i.jsx(Ci,{onClick:n=>e(n.currentTarget),title:t("board.controls.openPanelTip"),"aria-label":t("board.controls.openPanel"),children:i.jsx(Ze,{name:"terminal"})})}function bue({zoomReset:e}){const t=se(),n=Wt(lue);return i.jsx(Ci,{"data-zoom-level":"",onClick:e,title:t("board.controls.zoomReset"),"aria-label":t("board.controls.zoomLabel",{level:n}),children:n})}const cP="agent-dag.fm-custom-stations",lP="agent-dag.fm-muted",Xj="custom:",kue=/^UC[A-Za-z0-9_-]{22}$/,vue=/^[A-Za-z0-9_-]{11}$/,F5=/^[A-Za-z0-9_-]{1,80}$/,wue=/\.(mp3|aac|ogg)$/i,yue=/\.m3u8$/i,xue=2048,B5=80;function Au(e){return`${Xj}${e}`}function lv(e){if(!e.startsWith(Xj))return null;const t=e.slice(Xj.length);return F5.test(t)?t:null}function dP(e){return lv(e)??e}function M1(e){var r,c;const t=e.trim();if(t.length>xue)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const a=n.toString(),s=n.hostname.toLowerCase();if(s==="youtube.com"||s==="www.youtube.com"||s==="m.youtube.com"){if(n.port)return null;const l=(r=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:r[1];if(l&&kue.test(l))return{kind:"youtube-channel",url:a,channel:l};const u=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(u&&/^[A-Za-z0-9._-]{1,64}$/.test(u))return{kind:"youtube-handle",url:a,handle:u};if(n.pathname==="/watch"){const h=n.searchParams.get("v")??"";if(vue.test(h))return{kind:"youtube-video",url:a,video:h}}return null}return yue.test(n.pathname)?{kind:"direct-audio",url:a,format:"hls"}:wue.test(n.pathname)?{kind:"direct-audio",url:a,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:a,format:"audio"}}function Cue(e){return e==="1"}function Sue(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,a=[];for(const s of t){if(!s||typeof s!="object")continue;const o=typeof s.id=="string"?s.id:"",r=typeof s.name=="string"?s.name.trim():"",c=typeof s.url=="string"?s.url.trim():"",l=M1(c);if(!F5.test(o)||n.has(o)||!r||r.length>B5||!l)continue;n.add(o);const u=U5(s.radio);a.push({id:o,name:r,url:l.url,...u?{radio:u}:{}})}return a}function Tue(e,t,n){const a=lv(e??"");return a&&t.some(s=>s.id===a)?Au(a):n(e)}function Nue(e,t){return e===Au(t)?"claude-fm":e}function U5(e){if(!e||typeof e!="object")return null;const t=e,n=(s,o)=>typeof t[s]=="string"?t[s].slice(0,o):"",a=(s,o)=>typeof t[s]=="number"&&Number.isFinite(t[s])&&Math.abs(t[s])<=o?t[s]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:a("lat",90),lon:a("lon",180)}}const Qj="https://www.youtube-nocookie.com";function Aue(e,t,n){const a=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Qj}/embed/${n?encodeURIComponent(n):"live_stream"}?${a.toString()}`}function Od(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function jue(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const Eue=[1],Rue=[0,2],zue=[2,5,100,101,150,153];function que(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:a}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const s=typeof a=="number"?a:Number(a==null?void 0:a.errorCode);return Number.isFinite(s)?{kind:"error",code:s}:null}if(n==="onStateChange"||n==="infoDelivery"){const s=typeof a=="number"?a:a==null?void 0:a.playerState;return typeof s!="number"||!Number.isFinite(s)?null:Eue.includes(s)?{kind:"playing",playing:!0}:s===3?{kind:"buffering"}:Rue.includes(s)?{kind:"playing",playing:!1}:null}return null}const Jh=new Set;let uP="";function hP(e){const t=new Date().toISOString().slice(0,10);if(t!==uP&&(Jh.clear(),uP=t),!Jh.has(e)){Jh.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Jh.delete(e)}catch{Jh.delete(e)}}}const pP=864e5,_ue=6e4;function na(e,t=!0){m.useEffect(()=>{if(!t)return;hP(e);let n;const a=()=>{n=setTimeout(()=>{hP(e),a()},pP-Date.now()%pP+_ue)};return a(),()=>clearTimeout(n)},[e,t])}const Lue={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function Pue({fetchImpl:e,enabled:t=!0,volume:n,muted:a,source:s,playRequest:o,customStation:r,onAvailabilityChange:c}){var O;const[l,u]=m.useState(null),[h,p]=m.useState(!1),[f,b]=m.useState(!1),[v,w]=m.useState(!1),[T,y]=m.useState(!1);na("claude-fm",v);const x=m.useRef(o),C=m.useRef(null),A=m.useRef(null),E=m.useRef(void 0),R=m.useRef(null),z=m.useCallback(()=>{var M;clearTimeout(E.current),(M=A.current)==null||M.destroy(),A.current=null;const j=C.current;j&&(j.pause(),j.removeAttribute("src"),j.load(),C.current=null)},[]),I=m.useCallback(j=>{var M,F;(F=(M=R.current)==null?void 0:M.contentWindow)==null||F.postMessage(j,Qj)},[]),_=m.useRef(n);_.current=n;const D=m.useRef(a);D.current=a;const L=m.useCallback((j,M,F)=>{z();const U=new Audio;U.preload="none",U.volume=_.current/100,U.muted=D.current,C.current=U,b(!0),w(!1),y(!1);let H=!1;const $=()=>C.current===U,Y=()=>{clearTimeout(E.current),z(),b(!1),w(!1),y(!1)},W=()=>{$()&&(Y(),p(!0),c==null||c(F,!0))},G=J=>{if($()&&!(J instanceof DOMException&&J.name==="AbortError")){if(J instanceof DOMException&&J.name==="NotAllowedError"){Y();return}W()}};E.current=setTimeout(()=>{$()&&!H&&W()},15e3),U.addEventListener("playing",()=>{$()&&(clearTimeout(E.current),H=!0,w(!0),y(!1),c==null||c(F,!1))});const Q=()=>{$()&&(w(!1),y(H),clearTimeout(E.current),E.current=setTimeout(()=>{$()&&W()},15e3))};U.addEventListener("waiting",Q),U.addEventListener("stalled",Q),U.addEventListener("ended",()=>{$()&&Y()}),U.addEventListener("error",W,{once:!0}),M&&!U.canPlayType("application/vnd.apple.mpegurl")?Xs(async()=>{const{default:J}=await import("./hls-BFpXDghs.js");return{default:J}},[]).then(({default:J})=>{if(!$())return;if(!J.isSupported()){W();return}const X=new J;A.current=X,X.on(J.Events.ERROR,(te,K)=>{K.fatal&&W()}),X.on(J.Events.MEDIA_ATTACHED,()=>X.loadSource(j)),X.on(J.Events.MANIFEST_PARSED,()=>{U.play().catch(G)}),X.attachMedia(U)},W):(U.src=j,U.play().catch(G))},[c,z]);m.useEffect(()=>{f&&(I(Od("setVolume",[n])),I(Od(a?"mute":"unMute")),C.current&&(C.current.volume=n/100,C.current.muted=a))},[n,a,f,I]),m.useEffect(()=>{var Y;let j=!0;const M=e??fetch,F=x.current!==o;if(x.current=o,u(null),p(!1),y(!1),b(F),w(!1),z(),!t){b(!1),w(!1);return}const U=r&&Au(r.id)===s?M1(r.url):null;if(U){if(U.kind==="direct-audio"){const W=U.format==="hls"||((Y=r==null?void 0:r.radio)==null?void 0:Y.hls)===!0;return u({live:!0,channel:"",audio:U.url,hls:W}),c==null||c(s,!1),F&&L(U.url,W,s),()=>{j=!1}}return M(`/api/fm-station?url=${encodeURIComponent(U.url)}`).then(W=>W.ok?W.json():null).then(W=>{j&&(W!=null&&W.channel||W!=null&&W.video?(u({live:!0,channel:W.channel??"",video:W.video??void 0}),c==null||c(s,!1)):(p(!0),b(!1),w(!1),y(!1),c==null||c(s,!0)))}).catch(()=>{j&&(p(!0),b(!1),w(!1),y(!1),c==null||c(s,!0))}),()=>{j=!1}}if(lv(s))return p(!0),c==null||c(s,!0),()=>{j=!1};const H=s,$=Lue[H];if($)M($).then(W=>W.ok?W.json():null).then(W=>{j&&(W!=null&&W.video&&u({live:!0,channel:"",video:W.video}),W!=null&&W.video||(p(!0),b(!1),w(!1)),c==null||c(s,!(W!=null&&W.video)))}).catch(()=>{j&&(p(!0),b(!1),w(!1),c==null||c(s,!0))});else if(H!=="claude-fm"){const W=H.replace("lofi-","");M(`/api/lofi-girl?station=${encodeURIComponent(W)}`).then(G=>G.ok?G.json():null).then(G=>{j&&(G!=null&&G.video&&u({live:!0,channel:"",video:G.video}),G!=null&&G.video||(p(!0),b(!1),w(!1)),c==null||c(s,!(G!=null&&G.video)))}).catch(()=>{j&&(p(!0),b(!1),w(!1),c==null||c(s,!0))})}else M("/api/claude-fm").then(W=>W.ok?W.json():null).then(W=>{if(!j)return;const G=!!(W!=null&&W.live&&(W!=null&&W.channel));G&&u({live:!0,channel:W.channel}),G||(p(!0),b(!1),w(!1)),c==null||c(s,!G)}).catch(()=>{j&&(p(!0),b(!1),w(!1),c==null||c(s,!0))});return()=>{j=!1}},[r==null?void 0:r.id,r==null?void 0:r.url,(O=r==null?void 0:r.radio)==null?void 0:O.hls,t,e,c,o,s,L,z]),m.useEffect(()=>()=>z(),[z]),m.useEffect(()=>{if(!f||l!=null&&l.audio)return;let j;const M=()=>{clearTimeout(j),j=void 0,b(!1),w(!1),y(!1),p(!0),c==null||c(s,!0)},F=()=>{j??=setTimeout(M,15e3)};F();const U=H=>{var Y;if(H.origin!==Qj||H.source!==((Y=R.current)==null?void 0:Y.contentWindow))return;const $=que(H.data);if($){if($.kind==="ready"){I(Od("setVolume",[_.current])),I(Od(D.current?"mute":"unMute")),I(Od("playVideo"));return}if($.kind==="blocked"){clearTimeout(j),j=void 0,b(!1),w(!1),y(!1);return}if($.kind==="buffering"){w(!1),y(!0),F();return}if($.kind==="playing"){clearTimeout(j),j=void 0,w($.playing),y(!1),$.playing||b(!1);return}zue.includes($.code)&&M()}};return window.addEventListener("message",U),()=>{clearTimeout(j),window.removeEventListener("message",U)}},[f,l==null?void 0:l.audio,o,c,I,s]);const P=m.useCallback(()=>{if(l){if(l.audio){if(f){z(),b(!1),w(!1),y(!1);return}L(l.audio,l.hls===!0,s);return}if(!f){b(!0),w(!1),y(!1);return}I(Od("pauseVideo")),b(!1),w(!1),y(!1)}},[l,f,v,s,I,L,z]);return m.useMemo(()=>({probe:l,dead:h,armed:f,playing:v,buffering:T,frame:R,say:I,press:P}),[l,h,f,v,T,I,P])}const gP="agent-dag.radio-favorites",mP="agent-dag.radio-recent",fP="agent-dag.radio-catalogue";function Oue(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const a=n,s=typeof a.id=="string"?a.id:"",o=typeof a.name=="string"?a.name.trim().slice(0,80):"",r=typeof a.url=="string"?M1(a.url):null,c=U5(a.radio??a);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(s)||!o||!c||!r||r.kind!=="direct-audio"||t.has(s)?[]:(t.add(s),[{id:s,name:o,url:r.url,radio:c}])})}function bP(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function Mue(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function d4e(e,t,n=Math.random){const a=e.filter(s=>s.id!==t);return a.length?a[Math.min(a.length-1,Math.floor(Math.max(0,n())*a.length))]:null}function u4e(e,t,n){if(!e.length)return null;const a=e.findIndex(o=>o.id===t),s=e[a<0?n===1?0:e.length-1:(a+n+e.length)%e.length];return s.id===t?null:s}function W5(e,t,n){const a=e.findIndex(s=>s.id===t);for(let s=1;s<=e.length;s++){const o=e[(a+s)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function h4e(e,t){if(!e.length)return null;const n=[...e].sort((s,o)=>s.id.localeCompare(o.id));let a=0;for(const s of t)a=Math.imul(a,31)+s.charCodeAt(0)>>>0;return n[a%n.length]}function p4e(e,t,n,a,s){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!a||e.radio.tags.toLowerCase().includes(a.toLowerCase()))&&(!s||e.radio.language.toLowerCase().includes(s.toLowerCase()))}function Iue(){const[e,t]=m.useState(()=>bP(gt(gP))),[n,a]=m.useState(()=>bP(gt(mP))),[s,o]=m.useState(()=>{try{return Oue(JSON.parse(gt(fP)??"[]"))}catch{return[]}});m.useEffect(()=>{yt(gP,JSON.stringify(e))},[e]),m.useEffect(()=>{yt(mP,JSON.stringify(n))},[n]);const r=m.useCallback(u=>a(h=>Mue(h,u)),[]),c=m.useCallback(u=>t(h=>h.includes(u)?h.filter(p=>p!==u):[...h,u].slice(-100)),[]),l=m.useCallback(u=>{o(u),yt(fP,JSON.stringify(u))},[]);return{favorites:e,recent:n,catalogue:s,remember:r,toggleFavorite:c,updateCatalogue:l}}function Due(e,t,n,a){const s=W5(e,t,n);if(!s)return()=>{};const o=setTimeout(()=>{n.add(t),a(s)},1e3);return()=>clearTimeout(o)}const dv=148,kP=6e3,Fue=16e3,H5=46,Jr=34;function Bue(e,t,n=dv){let a=-Math.round(t()*n);if(Math.abs(a-e)<Jr){const s=e-Jr>=-n?-Jr:Jr;a=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:a,ms:Math.round(Math.abs(a-e)*H5)}}function Uue(e){return Math.round(kP+e()*(Fue-kP))}const vP=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function Wue(e){const t=vP.reduce((a,s)=>a+s.weight,0);let n=e()*t;for(const a of vP)if(n-=a.weight,n<0)return a.kind;return"stroll"}const Hue=720,Gue=260,Vue=620,Kue=220,wP=520,G5=1600,yP=7e3,$ue=15e3,xP=6e3,Jue=14e3;function Yh(e,t,n=dv){let a=-Math.round(t()*n);if(Math.abs(a-e)<Jr){const s=e-Jr>=-n?-Jr:Jr;a=Math.max(-n,Math.min(0,Math.round(e+s)))}return a}const Kn=(e,t)=>Math.round(Math.abs(t-e)*H5),Yue=120,jf=0;function Zue(e,t){const n=a=>({kind:"litter",at:t,...a});return[{x:t,prop:n({}),act:"walk",ms:Kn(e,t)},{x:t,prop:n({}),act:"stoop",ms:Hue},{x:jf,prop:n({held:!0}),act:"carry",ms:Kn(t,jf)},{x:jf,prop:n({held:!0}),act:"windup",ms:Gue},{x:jf,prop:n({held:!0,leaving:!0}),act:"toss",ms:Vue}]}function Xue(e,t){const n=t>e?1:-1,a=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:a,prop:s(),act:"walk",ms:Kn(e,a)},{x:a,prop:s(),act:"windup",ms:Kue,facing:n>0?"right":"left"},{x:a,prop:s({leaving:!0}),act:"kick",ms:wP,facing:n>0?"right":"left"},{x:a,prop:s({leaving:!0}),act:"stand",ms:G5-wP}]}const V5=640;function Que(e,t,n){const a=Math.max(-70,Math.min(-20,t)),s={x:a,prop:null,facing:"left"};return[{x:a,prop:null,act:"walk",ms:Kn(e,a)},{...s,act:"sit",ms:600},{...s,act:"cast",ms:900},{...s,act:"fish",ms:6e3+Math.round(n()*4e3)},{...s,act:"reel",ms:1200},{...s,act:"stow",ms:500},{...s,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Kn(a,0)}]}function ehe(e,t,n){const a=Math.max(-110,Math.min(-30,t)),s={x:a,prop:null};return[{...s,act:"walk",ms:Kn(e,a)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:V5*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Kn(a,0)}]}function the(e,t,n){return[{x:t,prop:null,act:"walk",ms:Kn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(xP+n()*(Jue-xP))},{x:t,prop:null,act:"stand",ms:400}]}function nhe(e,t,n){t=Math.max(-110,Math.min(0,t));const a=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Kn(e,t)},{x:t,prop:a(),act:"watch",ms:Math.round(yP+n()*($ue-yP))},{x:t,prop:a(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Dy(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const ahe=1500,she=e=>Math.round(1e3*Math.sqrt(2*e/ahe)),ihe=115,ohe=e=>Math.round(e/ihe*1e3),rhe=620,che=200,lhe=760,dhe=600,uhe=240;function hhe(e,t,n){const s=-(t.ledgeSpan??dv),o=she(t.ledgeH),r=ohe(t.ledgeH),c=n(),l=n(),u=-Math.round(c*t.floorSpan),h=-Math.round(l*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Kn(e,s)},{x:s,act:"peer",prop:null,ms:rhe},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:che,place:"floor"},{x:u,act:"walk",prop:null,ms:Kn(s,u),place:"floor",floorFrac:c},{x:h,act:"walk",prop:null,ms:Kn(u,h),place:"floor",floorFrac:l},{x:s,act:"walk",prop:null,ms:Kn(h,s),place:"floor"},...t.ledgeH<=phe?[{x:s,act:"mount",prop:null,ms:K5}]:[{x:s,act:"lasso",prop:null,ms:lhe,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:dhe,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:uhe,place:"floor"},{x:s,act:"climb",prop:null,ms:r},{x:s,act:"pull-up",prop:null,ms:480}]]}const phe=42;function ghe(e,t,n){const a=(n==null?void 0:n.ledgeSpan)??dv;switch(Wue(t)){case"tidy":return Zue(e,Yh(e,t,a));case"kick":return Xue(e,Yh(e,t,a));case"sit":return the(e,Yh(e,t,a),t);case"watch":return nhe(e,Yh(e,t,a),t);case"fish":if(!n||!(n.ledgeH>0))break;return Que(e,-a,t);case"skip":return ehe(e,Yh(e,t,a),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return hhe(e,n,t)}}const o=Bue(e,t,a);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const mhe=420;function fhe(e,t,n){const a=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(mhe,Math.max(0,a))}const K5=260,bhe=200;function khe(e,t,n){const a=(h,p=Kn(e,h))=>({x:h,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[a(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[a(t)];const r=t>e,c=r?n.left:n.right,l=r?n.right:n.left,u={place:"floor",riser:n.height,prop:null};return[a(c,Kn(e,c)),{...u,x:c,act:"mount",ms:K5},{...u,x:l,act:"walk",ms:Kn(c,l)},{x:l,prop:null,act:"dismount",ms:bhe,place:"floor"},{x:t,prop:null,act:"walk",ms:Kn(l,t),place:"floor"}]}const $5=["bob","sway","groove"],CP=9e3,vhe=16e3,J5=1e3,whe=.08;function yhe(e,t){const n=$5.filter(o=>o!==e),a=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*whe;return{dance:a,beatMs:Math.round(J5*(1+s))}}function xhe(e){return Math.round(CP+e()*(vhe-CP))}const I1=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],SP=18,Che=I1.length,Y5="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",Z5="M12 9H14V6H13V3H11V2H9V4H12Z",D1=new Set(["a","c","p"]);function pc(e=I1){const t=[];return e.forEach((n,a)=>{let s=0;for(;s<n.length;){const o=n[s];if(o==="."){s+=1;continue}let r=1;for(;s+r<n.length&&n[s+r]===o;)r+=1;t.push({x:s,y:a,w:r,cell:o}),s+=r}}),t}const She=[".xx.","xxxx",".xx."],The=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],Nhe=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],Fy={litter:She,ball:The,scope:Nhe},Ahe=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],jhe=3,Ehe=-1,e0=11,TP=9;function NP(e){let t=null,n=null,a=0,s=0,o=!1;const r=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const u=n;n=null,u==null||u()},a))},l=()=>{e.hidden&&t!==null?(a=Math.max(0,a-(performance.now()-s)),r()):e.hidden||c()};return e.addEventListener("visibilitychange",l),{schedule(u,h){o||(r(),n=u,a=Math.max(0,h),c())},dispose(){o=!0,r(),n=null,e.removeEventListener("visibilitychange",l)}}}const Rhe=typeof window>"u"?m.useEffect:m.useLayoutEffect,AP=54,zhe=8,jP=12;function qhe(e,t){if(!(t.width>=AP))return null;const n=Math.round(Math.max(AP,Math.min(ml.width,t.width-ml.width-zhe)));return{right:Math.round(e-t.left-n),width:n}}const _he=(e,t)=>e===t||!!e&&!!t&&e.right===t.right&&e.width===t.width;function Lhe(e,t){const[n,a]=m.useState(null);return Rhe(()=>{var u;const s=t?(u=e.current)==null?void 0:u.parentElement:null;if(!s){a(null);return}let o=null;const r=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>c()),c=()=>{const h=s.querySelector(".react-flow__controls");h!==o&&(o&&(r==null||r.unobserve(o)),o=h,o&&(r==null||r.observe(o)));const p=h?qhe(s.getBoundingClientRect().right,h.getBoundingClientRect()):null;a(f=>_he(f,p)?f:p)},l=typeof MutationObserver>"u"?null:new MutationObserver(c);return r==null||r.observe(s),l==null||l.observe(s,{childList:!0}),c(),()=>{r==null||r.disconnect(),l==null||l.disconnect()}},[e,t]),n}function Phe(e,t,n){const[a,s]=m.useState(0),[o,r]=m.useState(0),[c,l]=m.useState(null),[u,h]=m.useState(null),[p,f]=m.useState({x:0,drop:0}),[b,v]=m.useState("ledge"),[w,T]=m.useState("left"),[y,x]=m.useState(0),C=m.useRef(null),[A,E]=m.useState(()=>document.hidden);m.useEffect(()=>{const P=new Set,O=()=>{var j;if(document.hidden){for(const M of((j=C.current)==null?void 0:j.getAnimations({subtree:!0}))??[])if(M.playState==="running"||M.pending){const F=M.currentTime;M.pause(),F!==null&&(M.currentTime=F),P.add(M)}}else{for(const M of P)M.playState==="paused"&&M.play();P.clear()}E(document.hidden)};return O(),document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},[e,t]);const[R,z]=m.useState(null),[I,_]=m.useState(J5),[D,L]=m.useState(()=>{var P;return((P=window.matchMedia)==null?void 0:P.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return m.useEffect(()=>{var j;const P=(j=window.matchMedia)==null?void 0:j.call(window,"(prefers-reduced-motion: reduce)");if(!P)return;const O=()=>L(P.matches);return O(),P.addEventListener("change",O),()=>P.removeEventListener("change",O)},[]),m.useEffect(()=>{var K;if(!e||t||D)return;const P=NP(document);let O=0;s(V=>O=V);let j=null,M=0,F=0;const U=V=>{var be,ie;const[ee,...de]=V;if(!ee){j=null,l(null),h(null),J();return}l(ee.act),h(ee.prop),v(ee.place??"ledge"),x(ee.riser??0);const he=O,me=G(ee);if(ee.act==="kick"){const ne=(ie=(be=C.current)==null?void 0:be.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ie.getBoundingClientRect();ne&&f({x:fhe(ne.x,Dy(ee,he,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-ne.y+24)})}F=ee.act==="walk"?Math.max(Kn(he,me),Yue):ee.ms,ee.act==="carry"&&(F=Kn(he,me)),r(F),T(ne=>Dy({...ee,x:me},he,ne)),s(me),O=me,j=ee,M=Date.now(),P.schedule(()=>U(de),F)},H=()=>{var ke,Se;const V=C.current,ee=V==null?void 0:V.querySelector(".fm-sprite"),de=V==null?void 0:V.parentElement;if(!V||!ee||!de)return null;const he=V.getBoundingClientRect(),me=de.getBoundingClientRect();let be=me.right-me.width+jP;const ie=(Se=(ke=de.querySelector)==null?void 0:ke.call(de,".react-flow__minimap"))==null?void 0:Se.getBoundingClientRect();ie&&ie.right<=he.right&&ie.bottom>he.bottom-ee.offsetHeight&&(be=Math.max(be,ie.right+jP));const ne=he.right-be-ee.offsetWidth;return ne>0?ne:null},$=()=>{const V=C.current,ee=V==null?void 0:V.querySelector(".fm-sprite");return!V||!ee?0:Math.max(0,V.getBoundingClientRect().width-ee.offsetWidth)},Y=()=>{const V=C.current,ee=V==null?void 0:V.querySelector(".fm-walker"),de=H();if(!V||!ee||de==null)return;const he=V.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(he>0)return{ledgeH:he,floorSpan:de,ledgeSpan:$()}},W=()=>{const V=C.current,ee=document.querySelector(".canvas-notices");if(!V||!ee)return null;const de=V.getBoundingClientRect(),he=ee.getBoundingClientRect();if(he.width<=0||he.height<=0)return null;const me=de.bottom-he.top;return me>0?{left:he.left-de.right,right:he.right-de.right,height:me}:null},G=V=>{const ee=(V.place??"ledge")==="floor",de=ee?H()??$():$(),he=ee&&V.floorFrac!=null?-Math.round(V.floorFrac*de):V.x;return Math.max(-de,Math.min(0,he))},Q=()=>{if(!j)return;const V=G(j);V!==O&&(r(Math.max(0,M+F-Date.now())),T(ee=>Dy({...j,x:V},O,ee)),s(V),O=V)},J=()=>{P.schedule(()=>{const V=ghe(O,Math.random,Y()),ee=V.some(me=>me.place==="floor")?W():null;let de=O;const he=V.flatMap(me=>{const be=de;if(de=me.x,!(me.place==="floor"&&me.act==="walk"))return[me];const ie=khe(be,me.x,ee),ne=ie.length-1;return me.floorFrac==null?ie:ie.map((ke,Se)=>Se===ne?{...ke,floorFrac:me.floorFrac}:ke)});U(he)},Uue(Math.random))},X=(K=C.current)==null?void 0:K.parentElement,te=typeof ResizeObserver>"u"?null:new ResizeObserver(Q);return X&&te&&te.observe(X),J(),()=>{P.dispose(),te==null||te.disconnect(),v("ledge"),s(V=>Math.max(-$(),Math.min(0,V))),r(0),l(null),h(null),x(0)}},[e,t,D]),m.useEffect(()=>{if(!n||D){z(null);return}const P=NP(document),O=j=>{const M=yhe(j,Math.random);z(M.dance),_(M.beatMs),P.schedule(()=>O(M.dance),xhe(Math.random))};return O(null),()=>P.dispose()},[n,D]),{scene:C,suspended:A,x:a,walkMs:o,act:c,prop:u,ballFlight:p,place:b,facing:w,riser:y,dance:R,beatMs:I}}const By={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Xb=pc().filter(e=>!D1.has(e.cell)),Ohe=pc().filter(e=>D1.has(e.cell)),EP=Xb.filter(e=>e.cell==="e"),Mhe=pc(Ahe),Ihe=Xb.filter(e=>e.y<e0&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),Dhe={left:Xb.filter(e=>e.y>=e0&&e.x<TP),right:Xb.filter(e=>e.y>=e0&&e.x>=TP)},Fhe=m.memo(function({act:t,facing:n}){return i.jsxs("svg",{viewBox:`0 0 ${SP} ${Che}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("g",{className:"fm-gear",children:i.jsx("g",{className:"fm-gear-motion",children:Ohe.map(a=>i.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:By[a.cell]},`g${a.y}-${a.x}`))})}),i.jsxs("g",{className:"fm-body",children:[EP.map(a=>i.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:"var(--accent)"},`eye-bed-${a.x}`)),Ihe.map(a=>i.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:By[a.cell]},`b${a.y}-${a.x}`)),i.jsxs("g",{className:"fm-arms",children:[i.jsx("rect",{x:4,y:8,width:2,height:2}),i.jsx("rect",{x:12,y:8,width:1,height:2}),i.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),EP.map(a=>i.jsx("rect",{x:a.x-(a.x>=SP/2?1:0)+(n==="right"?1:0),y:a.y,width:a.w,height:1,className:"fm-eye"},`eye-${a.x}`))]}),i.jsx("g",{className:"fm-hat",children:Mhe.map(a=>i.jsx("rect",{x:jhe+a.x,y:Ehe+a.y,width:a.w,height:1,className:a.cell==="k"?"fm-hatband":void 0},`h${a.y}-${a.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&i.jsxs("g",{className:"fm-grip",children:[i.jsx("path",{className:"fm-grip-left",d:Y5}),i.jsx("path",{className:"fm-grip-right",d:Z5})]}),(t==="land"||t==="dismount")&&i.jsxs("g",{className:"fm-crouch-legs",children:[i.jsx("path",{d:"M6 11H8V13H6Z"}),i.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&i.jsxs("g",{className:"fm-seated-legs",children:[i.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),i.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(a=>i.jsx("g",{className:"fm-leg","data-side":a,children:Dhe[a].map(s=>i.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:By[s.cell]},`${a}${s.y}-${s.x}`))},a))]})}),Bhe=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],Uhe=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],Qi={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},Whe={p:"fm-pad"},og=pc(Bhe),Hhe=pc(Uhe);function t0(e,t,n){return e.map(a=>({...a,x:Math.max(t,a.x),w:Math.max(0,Math.min(n,a.x+a.w)-Math.max(t,a.x))})).filter(a=>a.w>0)}const Ghe=t0(og.filter(e=>e.y>=8),12,18),Vhe=og.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),RP=og.filter(e=>e.cell==="e"),Khe={left:t0(og.filter(e=>e.y>=11),0,9),right:t0(og.filter(e=>e.y>=11),9,12)},$he=m.memo(function({act:t,facing:n}){const a=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return i.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[i.jsx("g",{className:"fm-body","data-part":"tail",children:Ghe.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Qi[r.cell]},`t${r.y}-${r.x}`))}),i.jsx("g",{className:"fm-gear",children:i.jsx("g",{className:"fm-gear-motion",children:Hhe.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Whe[r.cell]},`g${r.y}-${r.x}`))})}),i.jsxs("g",{className:"fm-body",children:[Vhe.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Qi[r.cell]},`b${r.y}-${r.x}`)),RP.map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Qi.f},`bed${r.x}`)),i.jsxs("g",{className:"fm-arms",fill:Qi.f,children:[i.jsx("rect",{x:4,y:8,width:2,height:2}),i.jsx("rect",{x:12,y:8,width:1,height:2})]}),RP.map(r=>i.jsx("rect",{x:r.x+(n==="right"?1:0)-(r.x>=9?1:0),y:r.y,width:r.w,height:1,className:"fm-eye",style:{fill:Qi.n}},`e${r.x}`))]}),a&&i.jsxs("g",{className:"fm-grip",style:{fill:Qi.f},children:[i.jsx("path",{className:"fm-grip-left",d:Y5}),i.jsx("path",{className:"fm-grip-right",d:Z5})]}),s&&i.jsxs("g",{className:"fm-crouch-legs",style:{fill:Qi.f},children:[i.jsx("path",{d:"M6 11H8V13H6Z"}),i.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&i.jsxs("g",{className:"fm-seated-legs",style:{fill:Qi.f},children:[i.jsx("path",{className:"fm-seated-far",style:{fill:Qi.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),i.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>i.jsx("g",{className:"fm-leg","data-side":r,children:Khe[r].map(c=>i.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:Qi[c.cell]},`${c.y}-${c.x}`))},r))]})}),Jhe=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Ko={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},Yhe={p:"fm-pad"},Qb=pc(Jhe),Zhe=pc(I1).filter(e=>D1.has(e.cell)),zP=Qb.filter(e=>e.cell==="e"),Xhe=Qb.filter(e=>e.y<12&&e.cell!=="e"),Qhe={left:Qb.filter(e=>e.y>=12&&e.x<9),right:Qb.filter(e=>e.y>=12&&e.x>=9)},epe=m.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",a=t==="land"||t==="dismount",s=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return i.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[i.jsx("g",{className:"fm-gear",children:i.jsx("g",{className:"fm-gear-motion",children:Zhe.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:Yhe[o.cell]},`g${o.y}-${o.x}`))})}),i.jsxs("g",{className:"fm-body",children:[Xhe.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Ko[o.cell]},`b${o.y}-${o.x}`)),zP.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Ko.w},`bed${o.x}`)),i.jsxs("g",{className:"fm-arms",fill:Ko.d,children:[i.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),i.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),zP.map(o=>i.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Ko.e}},`e${o.x}`))]}),n&&i.jsxs("g",{className:"fm-grip",style:{fill:Ko.h},children:[i.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),i.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),a&&i.jsxs("g",{className:"fm-crouch-legs",style:{fill:Ko.b},children:[i.jsx("path",{d:"M5 12H8V13H5Z"}),i.jsx("path",{d:"M10 12H13V13H10Z"})]}),s&&i.jsxs("g",{className:"fm-seated-legs",style:{fill:Ko.b},children:[i.jsx("path",{className:"fm-seated-far",style:{fill:Ko.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),i.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>i.jsx("g",{className:"fm-leg","data-side":o,children:Qhe[o].map(r=>i.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ko.b},`${r.y}-${r.x}`))},o))]})});function X5({character:e,act:t,facing:n}){return e==="penguin"?i.jsx(epe,{act:t,facing:n}):e==="fox"?i.jsx($he,{act:t,facing:n}):i.jsx(Fhe,{act:t,facing:n})}const tpe={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function Q5(e,t,n=S){return t&&Au(t.id)===e?t.name:lv(e)?n("radio.fm.custom"):tpe[e]}function Uy(e,t){var a;const n=((a=e[0])==null?void 0:a.length)??0;return i.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:pc(e).map(s=>i.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const qP={litter:Uy(Fy.litter,"litter"),ball:Uy(Fy.ball,"ball"),scope:Uy(Fy.scope,"scope")};function npe(e,t=S){try{return new URL(e).host}catch{return t("radio.fm.server")}}const ape=m.memo(function({player:t,source:n,customStation:a,character:s="deck"}){const o=se(),{probe:r,dead:c,playing:l,press:u}=t,{scene:h,suspended:p,x:f,walkMs:b,act:v,prop:w,ballFlight:T,place:y,facing:x,riser:C,dance:A,beatMs:E}=Phe(r,c,l),R=Lhe(h,!!r&&!c);if(!r||c)return null;const z=Q5(n,a,o),I=r.audio?npe(r.audio,o):"YouTube";return i.jsxs("div",{ref:h,className:"fm","data-suspended":p?"":void 0,"data-place":y,"data-ledge":R?"bar":void 0,style:{"--fm-beat":`${E}ms`,"--fm-right":R?`${R.right}px`:void 0,"--fm-ledge-w":R?`${R.width}px`:void 0},children:[w&&!w.held&&i.jsx("div",{className:"fm-prop","data-prop":w.kind,"data-leaving":w.leaving?"":void 0,style:{"--fm-prop-x":`${w.at}px`,"--fm-roll-to":`${T.x}px`,"--fm-ball-drop":`${T.drop}px`,"--fm-ball-flight-ms":`${G5}ms`,"--fm-ball-turn":x==="right"?"1080deg":"-1080deg"},children:qP[w.kind]}),(v==="lasso"||v==="rope-throw"||v==="rope-catch"||v==="climb"||v==="pull-up")&&i.jsxs("div",{className:"fm-rope","data-act":v,style:{"--fm-rope-x":`${f}px`,"--fm-rope-ms":`${b}ms`},children:[i.jsx("div",{className:"fm-rope-line"}),i.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),i.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),i.jsxs("div",{className:"fm-walker","data-act":v??void 0,"data-place":y,"data-facing":x,style:{"--fm-x":`${f}px`,"--fm-walk-ms":`${b}ms`,"--fm-riser":`${C}px`,"--fm-skip-beat":`${V5}ms`},children:[(w==null?void 0:w.held)&&i.jsx("div",{className:"fm-held","data-prop":w.kind,"data-toss":w.leaving?"":void 0,children:qP[w.kind]}),["cast","fish","reel","stow"].includes(v)&&i.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsxs("g",{children:[i.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),i.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),i.jsxs("g",{className:"fm-fishing-line",children:[i.jsx("path",{d:"M8 2V18"}),i.jsxs("g",{className:"fm-float",children:[i.jsx("rect",{x:"7",y:"17",width:"3",height:"2"}),i.jsx("rect",{x:"8",y:"16",width:"1",height:"1"})]})]}),i.jsx("path",{className:"fm-ripple",d:"M3 20H6M10 20H14M5 22H12"})]}),["skip-ready","skip","skip-rest"].includes(v)&&i.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[i.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),i.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),i.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),i.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),i.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),i.jsx("button",{type:"button",className:"fm-sprite","data-playing":l?"":void 0,"data-dance":l?A??$5[0]:void 0,onClick:u,title:l?o("radio.fm.stop",{label:z}):o("radio.fm.playTitle",{label:z,from:I}),"aria-label":l?o("radio.fm.stop",{label:z}):o("radio.fm.play",{label:z}),children:i.jsx(X5,{character:s,act:v,facing:x})})]})]})});function spe({player:e,label:t}){const{probe:n,armed:a,frame:s,say:o}=e;return n?i.jsx(i.Fragment,{children:a&&!n.audio&&(n.channel||n.video)&&i.jsx("iframe",{ref:s,className:"fm-frame",title:t,src:Aue(n.channel,window.location.origin,n.video),onLoad:()=>o(jue()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const ipe={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6",headphones:"M4 14v-3a8 8 0 0 1 16 0v3 M4 12h3v8H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 1-2 M20 12h-3v8h2a2 2 0 0 0 2-2v-4a2 2 0 0 0-1-2",book:"M12 6v15 M12 6C9 4 6 3 3 4v15c3-1 6 0 9 2 3-2 6-3 9-2V4c-3-1-6 0-9 2",gamepad:"M8 7h8c3 0 4 2 5 8 1 5-2 6-5 2H8c-3 4-6 3-5-2 1-6 2-8 5-8z M6 11h4 M8 9v4 M16 10h.01 M18 13h.01",sunset:"M3 17h18 M5 21h14 M7 17a5 5 0 0 1 10 0 M12 3v3 M4 8l2 2 M20 8l-2 2",moon:"M20 14A9 9 0 0 1 10 3a9 9 0 1 0 10 11z",cassette:"M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z M7 8h10v5H7z M7 20l2-4h6l2 4 M9 10.5h.01 M15 10.5h.01",palm:"M12 8c2 4 3 8 2 13 M12 8C8 3 4 4 2 8c4-1 7-1 10 0 M12 8c1-6 6-7 10-2-4-1-7 0-10 2 M12 8c-5 0-7 3-7 7 2-3 4-5 7-7 M12 8c4 0 7 3 7 7-2-3-4-5-7-7 M10 21h8",coffee:"M4 8h12v8a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4z M16 9h2a3 3 0 0 1 0 6h-2 M7 3v2 M11 3v2 M3 22h15",check:"M5 12l4 4L19 6",filters:"M4 6h4 M12 6h8 M4 12h10 M18 12h2 M4 18h2 M10 18h10 M8 4v4 M14 10v4 M6 16v4"};function ope({name:e}){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:ipe[e]})})}function rpe({opening:e=!1}){const t=se(),[n,a]=m.useState(()=>document.hidden);return m.useEffect(()=>{const s=()=>a(document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),i.jsxs("div",{className:"radio-tuning",role:"status","data-paused":n||void 0,children:[i.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsxs("g",{className:"radio-tuning-tower",children:[i.jsx("circle",{cx:"40",cy:"24",r:"4"}),i.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),i.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),i.jsxs("g",{className:"radio-tuning-send",children:[i.jsx("path",{d:"M75 26q7 8 0 16"}),i.jsx("path",{d:"M102 26q7 8 0 16"}),i.jsx("path",{d:"M129 26q7 8 0 16"})]}),i.jsxs("g",{className:"radio-tuning-receiver",children:[i.jsx("path",{d:"M165 49l30-22"}),i.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),i.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),i.jsx("circle",{cx:"202",cy:"65",r:"7"}),i.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),i.jsx("strong",{children:t(e?"radio.loading.opening":"radio.loading.tuning")}),i.jsx("span",{children:t(e?"radio.loading.ready":"radio.loading.finding")})]})}function cpe({onClose:e}){const t=se(),[n]=m.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),a=Zt(e);return i.jsxs("div",{ref:a,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":t("radio.loading.opening"),"data-keyboard-interaction":n||void 0,onKeyDown:ule,children:[i.jsx("button",{type:"button",className:"icon-btn","aria-label":t("radio.close"),onClick:e,children:i.jsx(ope,{name:"close"})}),i.jsx(rpe,{opening:!0})]})}const lpe=m.lazy(()=>Xs(()=>import("./RadioPanel-j_p9qx4L.js"),[]));function eG({fm:e,characterEnabled:t,character:n,open:a,onClose:s}){const[o,r]=m.useState(!1),c=se(),[l,u]=m.useState("connecting"),h=c(`radio.disabled.${l}`),p=Iue(),[f,b]=m.useState(null),v=m.useRef(new Set);m.useEffect(()=>{const _=new AbortController;return fetch("/api/music-config",{signal:_.signal}).then(D=>D.ok?D.json():null).then(D=>{_.signal.aborted||(r((D==null?void 0:D.enabled)===!0),u(D?"off":"unreachable"))}).catch(()=>{_.signal.aborted||u("unreachable")}),()=>_.abort()},[a]);const w=e.customFmStations.find(_=>Au(_.id)===e.fmSource),T=w!=null&&w.radio?w:void 0,y=Pue({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),x=Q5(e.fmSource,w,c),C=o&&T&&y.dead&&e.fmPlayRequest>0?W5(f??p.catalogue,T.id,v.current):null,{remember:A}=p,E=(w==null?void 0:w.id)??e.fmSource;m.useEffect(()=>{y.playing&&A(E)},[E,y.playing,A]);const R=s,z=tn(s),I=m.useCallback((_,D=!1)=>{var j;if(!o)return;D||v.current.clear();const L=Au(_.id),P=L===e.fmSource;if(P&&y.armed&&!y.dead){y.press();return}const O=P&&!!w&&(w.url!==_.url||((j=w.radio)==null?void 0:j.hls)!==_.radio.hls);e.addFmStation(_,!0),P&&!y.dead&&!O?y.press():e.pickFmSource(L,O),fetch(`/api/radio-click?id=${encodeURIComponent(_.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,y.armed,y.dead,y.press]);return m.useEffect(()=>{y.playing&&!y.dead&&v.current.clear()},[y.playing,y.dead]),m.useEffect(()=>{if(!(!o||!T||!y.dead||e.fmPlayRequest===0))return Due(f??p.catalogue,T.id,v.current,_=>I(_,!0))},[o,T==null?void 0:T.id,y.dead,e.fmPlayRequest,f,p.catalogue,I]),i.jsxs(i.Fragment,{children:[t&&i.jsx(ape,{character:n,player:y,source:e.fmSource,customStation:w}),i.jsx(spe,{player:y,label:x}),i.jsx(Ft,{when:a,children:()=>$t.createPortal(i.jsx(s5,{scrim:z,className:"radio-backdrop",children:i.jsx(m.Suspense,{fallback:i.jsx(cpe,{onClose:R}),children:i.jsx(lpe,{fm:e,player:y,library:p,selected:T,label:x,enabled:o,disabledReason:h,autoNext:C==null?void 0:C.name,onPick:I,onQueueChange:b,onClose:R})})}),document.body)})]})}function dpe(){return i.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[i.jsx("path",{d:"M3.3 3.3l5.4 5.4M8.7 3.3l-5.4 5.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",fill:"none"}),i.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),i.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function n0({recap:e}){return e?i.jsx(dpe,{}):i.jsx("svg",{className:"recap-glyph note-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:i.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"currentColor"})})}function upe({data:e}){const t=se(),n=xo(3e4),a=e.note,s=e.plan??null,o=(a==null?void 0:a.kind)==="recap",r=Yb((a==null?void 0:a.at)??(s==null?void 0:s.at)??n,n),c=`${o?"recap-note":`recap-note is-status status-${(a==null?void 0:a.kind)??"plan"}`}${s?" has-plan":""}`,l=o||!a?void 0:av(a),u=yo(s),h=a?Su(a.kind):`${t("board.detail.plan").toLowerCase()} ${u?`${u.done}/${u.total}`:""}`.trim();return i.jsxs("div",{className:c,role:"note","aria-label":o?t("board.node.recapLabel"):t("board.node.noteLabel",{tag:h}),"aria-description":l,children:[i.jsxs("div",{className:"recap-note-head",title:l,children:[i.jsxs("span",{className:"recap-note-mark",children:[i.jsx(n0,{recap:o}),h]}),i.jsx("span",{className:"recap-note-age",title:r.title,children:r.label}),i.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":t(o?"board.node.hideRecap":a?"board.node.hideNote":"board.node.hidePlan"),title:t("board.note.hideTitle"),onClick:p=>{p.stopPropagation(),Gle(e.noteKey)},children:i.jsx(Ze,{name:"close"})})]}),a&&i.jsx("p",{className:"recap-note-text",title:vre(a.text,l),children:a.text}),(a==null?void 0:a.reply)&&i.jsx("p",{className:"recap-note-reply",title:t("board.list.reply",{reply:a.reply}),children:t("board.list.reply",{reply:a.reply})}),s&&i.jsx(_P,{plan:s,head:a!=null}),i.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[i.jsxs("div",{className:"lod-id",children:[i.jsxs("span",{className:"recap-note-mark",children:[i.jsx(n0,{recap:o}),h]}),i.jsx("span",{className:"recap-face-age",children:r.label})]}),a&&i.jsx("p",{className:"recap-face-text",children:a.text}),s&&i.jsx(_P,{plan:s,head:a!=null,face:!0})]}),i.jsx(Tl,{type:"source",position:xt.Right,style:{background:"transparent",border:"none"}})]})}const hpe={completed:"board.state.done",in_progress:"board.detail.now",pending:"board.detail.todo"};function _P({plan:e,head:t,face:n=!1}){const a=se(),s=yo(e);if(!s)return null;const o=ure(e.items);return i.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:Kk(e.items),children:[t&&i.jsxs("div",{className:"recap-note-plan-head",children:[a("board.detail.plan")," ",i.jsxs("span",{className:"recap-note-plan-count",children:[s.done,"/",s.total,s.allDone?` · ${a("board.state.done")}`:""]})]}),!s.allDone&&i.jsxs("ol",{className:"plan-list",children:[o.shown.map((r,c)=>i.jsxs("li",{className:"plan-item","data-status":r.status,children:[i.jsx("span",{className:"plan-mark","aria-hidden":!0}),!n&&i.jsxs("span",{className:"vis-hidden",children:[a(hpe[r.status]),a("board.detail.colon")]}),i.jsx("span",{className:"plan-text",children:r.status==="in_progress"&&r.active?r.active:r.text}),r.status==="in_progress"&&i.jsx("span",{className:"plan-now","aria-hidden":!0,children:a("board.detail.now")})]},r.id??`${c}:${r.text}`)),(o.before>0||o.after>0)&&i.jsx("li",{className:"recap-note-plan-more",children:[o.before>0?a("board.note.earlier",{n:o.before}):null,o.after>0?a("board.note.more",{n:o.after}):null].filter(Boolean).join(" · ")})]})]})}function ppe({sourceX:e,sourceY:t,targetX:n,targetY:a,sourcePosition:s,targetPosition:o,style:r}){const[c]=GE({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:a,targetPosition:o,curvature:.35});return i.jsxs("g",{className:"recap-tie",style:r,children:[i.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),i.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),i.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),i.jsx("circle",{className:"recap-tie-end",cx:n,cy:a,r:3.5})]})}function tG(e,t=S){const n=[e.tipWorkspace,e.planLine?t("board.cluster.plan",{plan:e.planLine}):void 0,e.tipRest||void 0].filter(Boolean).join(du),a=e.startedAt!=null&&e.idTail?`${f5(e.startedAt,e.idTail,Date.now(),t)}
|
|
123
123
|
`:"";return`${e.alarm?t("board.cluster.waitingOnYou"):""}${n}
|
|
124
124
|
${a}${t("board.cluster.zoomTo")}
|
|
125
125
|
${t("board.cluster.dragWrapper")}`}const du=" · ",gpe=32,mpe=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function LP(e){return mpe.test(e)?2:1}function PP(e,t=gpe){const n=[...e];let a=0;for(const r of n)a+=LP(r);if(a<=t)return e;const s=[];let o=0;for(const r of n){const c=LP(r);if(o+c>t-1)break;s.push(r),o+=c}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function fpe(e,t,n,a=[],{branch:s,plan:o,alarm:r=!1,startedAt:c}={}){const l=(t==null?void 0:t.trim())??"",u=l&&!El(l,e)?l:"",h=sv(n,a),p=[e,u||void 0].filter(Boolean),f=[s,u||void 0].filter(Boolean).join(du);return{label:PP(e),name:u?PP(u):void 0,fullLabel:p.join(du),title:tG({alarm:r,tipWorkspace:e,tipRest:f,planLine:o,startedAt:c,idTail:h}),tipWorkspace:e,tipRest:f,...c!=null?{startedAt:c}:null,idTail:h}}const ek=n1,bpe={at:e=>e,back:e=>e};function OP(e,t,n){const a=t.length;if(a===0||!Number.isFinite(e))return e;if(e<=t[0])return e-t[0]+n[0];if(e>=t[a-1])return e-t[a-1]+n[a-1];for(let s=1;s<a;s++){if(e>t[s])continue;const o=t[s]-t[s-1];return o>0?n[s-1]+(e-t[s-1])*(n[s]-n[s-1])/o:n[s]}return e}function F1(e,t=ek){const n=[...e].filter(c=>Number.isFinite(c.left)&&Number.isFinite(c.right)&&c.right>=c.left).sort((c,l)=>c.left-l.left),a=[];for(const c of n){const l=a[a.length-1];l&&c.left-l.right<=t?l.right=Math.max(l.right,c.right):a.push({left:c.left,right:c.right})}if(a.length<2)return bpe;const s=[],o=[];let r=a[0].left;return a.forEach((c,l)=>{l>0&&(r+=t),s.push(c.left,c.right),o.push(r,r+(c.right-c.left)),r+=c.right-c.left}),{at:c=>OP(c,s,o),back:c=>OP(c,o,s)}}function kpe(e){const t=[];for(const n of e)n.type==="agent"&&t.push({left:n.position.x,right:n.position.x+(n.width??hc)});return F1(t)}function vpe(e,t){const n=(o,r)=>r===o.position.x?o:{...o,position:{x:r,y:o.position.y}},a=new Map;return e.map(o=>{if(o.type==="recapNote")return o;const r=t.at(o.position.x);return o.type==="agent"&&a.set(o.id,r),n(o,r)}).map(o=>{var l;if(o.type!=="recapNote")return o;const r=(l=o.data)==null?void 0:l.parentId,c=r!=null?a.get(r):void 0;return n(o,c??t.at(o.position.x))})}function wpe(e,t){const n=e.zoom-t.zoom;if(!(Math.abs(n)>1e-6))return null;const a=(t.x*e.zoom-e.x*t.zoom)/n,s=(t.y*e.zoom-e.y*t.zoom)/n;return Number.isFinite(a)&&Number.isFinite(s)?{x:a,y:s}:null}function ype(e,t,n,a,s){let o=1/0,r=0;for(const c of e){if(c.type!=="agent")continue;const l=t?t.at(c.position.x):c.position.x,u=l*a.zoom+a.x,h=c.position.y*a.zoom+a.y,p=u+(c.width??hc)*a.zoom,f=h+(c.height??Fl)*a.zoom,b=Math.max(u-s.x,0,s.x-p),v=Math.max(h-s.y,0,s.y-f),w=b*b+v*v;w>=o||(o=w,r=(l-(n?n.at(c.position.x):c.position.x))*a.zoom)}return r}const xpe=240,B1=16,Cpe=ek-2*oo-B1-8;function nG(e,t,n=xpe){return(e+n)*(t||1)}function Spe(e){return{position:"absolute",left:0,top:0,transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h}}function Tpe(e,t,n){return{position:"absolute",left:e.x+B1,top:e.y-t1/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:n??nG(e.w,t)}}function aG(e,{notes:t=!0}={}){const n=new Map;for(const o of e){if(o.type!=="agent"&&o.type!=="recapNote"||o.type==="recapNote"&&!t)continue;const r=o.data;if(!(r!=null&&r.sessionId)||r.exitAt!=null||o.width==null||o.height==null)continue;const c=o.position.x,l=o.position.y,u=c+o.width,h=l+o.height,p=n.get(wn(o)),f=r.canvasSessionId&&r.canvasSessionId!==r.sessionId?null:Npe(r);p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,l),p.maxX=Math.max(p.maxX,u),p.maxY=Math.max(p.maxY,h),f&&(p.label=f.label??p.label,p.name=f.name,p.alarm=f.alarm,p.branch=f.branch,p.plan=f.plan,p.planLine=f.planLine,p.startedAt=f.startedAt)):n.set(wn(o),{minX:c,minY:l,maxX:u,maxY:h,label:(f==null?void 0:f.label)??r.sessionId,name:f==null?void 0:f.name,alarm:(f==null?void 0:f.alarm)??!1,branch:f==null?void 0:f.branch,plan:f==null?void 0:f.plan,planLine:f==null?void 0:f.planLine,startedAt:f==null?void 0:f.startedAt})}const a=[...n.keys()],s=[];for(const[o,r]of n)s.push({sessionId:o,...fpe(r.label,r.name,o,a,{branch:r.branch,plan:r.planLine,alarm:r.alarm,startedAt:r.startedAt}),x:r.minX-oo,y:r.minY-oo-zj,w:r.maxX-r.minX+oo*2,h:r.maxY-r.minY+oo*2+zj,...r.alarm?{alarm:!0}:null,...r.branch?{branch:r.branch}:null,...r.plan?{plan:r.plan,planLine:r.planLine}:null});return s}function Npe(e){if(e.kind!=="root")return null;const t=e.branch,n=yo(e.plan);return{label:e.label,name:Vk(e.sessionName,e.sessionTitle).face,alarm:bs(e.waiting),branch:t&&t.total>0?C4(t):void 0,plan:n?`plan ${n.done}/${n.total}`:void 0,planLine:n?c1(n):void 0,startedAt:e.startedAt}}function Ape(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const a=e[n],s=t[n];if(a.sessionId!==s.sessionId||a.label!==s.label||a.name!==s.name||a.idTail!==s.idTail||a.startedAt!==s.startedAt||a.alarm!==s.alarm||a.branch!==s.branch||a.plan!==s.plan||a.planLine!==s.planLine||a.fullLabel!==s.fullLabel||a.title!==s.title||a.x!==s.x||a.y!==s.y||a.w!==s.w||a.h!==s.h)return!1}return!0}const jpe=20,$o=4,Epe=64,Rpe=".cat-filter-bar, .react-flow__panel, .rearrange-undo, .usage-panel, .sysdetail, .detail";function zpe(e,t,n,a,s){const o=t.zoom||1,r=nG(e.w,o,s);if(n.width<=0||n.height<=0)return{maxWidth:r,hidden:!1};const c=(e.x+B1)*o+t.x,l=e.y*o+t.y-t1,u=l+jpe;let h=Math.min(r,n.width-$o-c),p=c<$o||l<$o||u>n.height-$o;for(const f of a)if(!(f.top-$o>=u||f.bottom+$o<=l)&&!(f.right+$o<=c)){if(f.left-$o<=c){p=!0;break}h=Math.min(h,f.left-$o-c)}return h<Epe&&(p=!0),{maxWidth:Math.max(0,h),hidden:p}}function qpe(e){const t=e.getBoundingClientRect(),n=[];for(const a of e.ownerDocument.querySelectorAll(Rpe)){const s=a.getBoundingClientRect(),o=Math.max(s.left,t.left)-t.left,r=Math.max(s.top,t.top)-t.top,c=Math.min(s.right,t.right)-t.left,l=Math.min(s.bottom,t.bottom)-t.top;c-o<1||l-r<1||n.push({left:Math.round(o),top:Math.round(r),right:Math.round(c),bottom:Math.round(l)})}return n}function _pe(e,t){return e.length===t.length&&e.every((n,a)=>{const s=t[a];return n.left===s.left&&n.top===s.top&&n.right===s.right&&n.bottom===s.bottom})}const sG=500;function iG({focus:e,setTimeout:t,clearTimeout:n,ms:a=sG}){let s=null;const o=()=>{s!==null&&(n(s),s=null)};return{hold(r){o(),s=t(()=>{s=null;try{e(r)}catch{}},a)},cancel:o}}const Lpe=e=>aG(e.nodeInternals.values()),Ppe=e=>aG(e.nodeInternals.values(),{notes:!1}),Ope=e=>e.width,Mpe=e=>e.height,Ipe=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function Dpe({onFocusSession:e,notes:t=!0}){const n=se(),{x:a,y:s,zoom:o}=K3(),r=Wt(t?Lpe:Ppe,Ape),c=Wt(Ope),l=Wt(Mpe),u={width:c,height:l},h=m.useRef(null),p=Wt(Ipe),[f,b]=m.useState([]);m.useLayoutEffect(()=>{var I;const E=(I=h.current)==null?void 0:I.parentElement;if(!E)return;const R=qpe(E),z=requestAnimationFrame(()=>{b(_=>_pe(_,R)?_:R)});return()=>cancelAnimationFrame(z)});const v=m.useRef(e);v.current=e;const[w]=m.useState(()=>iG({focus:E=>{var R;return(R=v.current)==null?void 0:R.call(v,E)},setTimeout:(E,R)=>window.setTimeout(E,R),clearTimeout:E=>window.clearTimeout(E)}));if(m.useEffect(()=>()=>w.cancel(),[w]),r.length<=1)return null;const T=E=>{try{e==null||e(E)}catch{}},y=(E,R)=>{E.detail>0&&Ya()?w.hold(R):T(R)},x={transform:`translate(${a}px, ${s}px) scale(${o})`},C=i.jsx("div",{className:"session-clusters",style:x,ref:h,children:r.map(E=>{const R=Spe(E);return i.jsx("div",{className:"cluster-card",style:R,"aria-hidden":!0},E.sessionId)})}),A=p&&$t.createPortal(i.jsx("div",{className:"cluster-labels nopan",children:r.map(E=>{const R=zpe(E,{x:a,y:s,zoom:o},u,f,t?void 0:Cpe),z=Tpe(E,o,R.maxWidth);return i.jsxs("button",{type:"button",className:"cluster-label","data-alarm":E.alarm?"":void 0,"data-offpane":R.hidden?"":void 0,style:z,title:tG(E,n),onClick:I=>y(I,E.sessionId),children:[E.alarm?i.jsxs(i.Fragment,{children:[i.jsx(ic,{}),i.jsx("span",{className:"cluster-label-said",children:n("board.cluster.waitingOnYou")})]}):null,E.label,E.plan?i.jsx("span",{className:"cluster-label-plan",children:du+n("board.cluster.planCount",{progress:E.plan.replace(/^plan /,"")})}):null,E.branch?i.jsx("span",{className:"cluster-label-branch",children:du+E.branch}):null,E.name?i.jsx("span",{className:"cluster-label-name",children:du+E.name}):null]},E.sessionId)})}),p);return i.jsxs(i.Fragment,{children:[C,A]})}function Fpe({data:e}){return i.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}function Bpe({agents:e,visibleAgentIds:t,positions:n,pinned:a,measured:s,spotlight:o,hiddenCategories:r,now:c,onOpenTool:l}){const u=Pte(e,t,n,a,s,c),h=r&&r.size>0?u.filter(p=>!r.has(p.category)):u;return Dte(h),i.jsx(Upe,{bursts:h,spotlight:o,onOpenTool:l})}function Upe({bursts:e,spotlight:t,onOpenTool:n}){const a=e.map(o=>{const r=o.anchorX,c=o.anchorY,l=o.worldX+6,u=o.worldY+ng,h=Math.max(1,l-r),p=Math.min(1,Math.abs(u-c)/h),f=r+h*(.55-.22*p),b=c+(u-c)*.12,v=l-h*.25,w=t!=null&&!t.has(o.agentId),T=o.fade*(w?.14:1);return i.jsx("path",{d:`M ${r} ${c} C ${f} ${b}, ${v} ${u}, ${l} ${u}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:T,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),s=e.map(o=>i.jsx(Gpe,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return i.jsx(Wpe,{connectors:a,bubbles:s})}function Wpe({connectors:e,bubbles:t}){const{x:n,y:a,zoom:s}=K3();return i.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*ng}px`},children:[i.jsx("svg",{className:"tool-bursts-svg",children:i.jsx("g",{transform:`translate(${n} ${a}) scale(${s})`,children:e})}),i.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${a}px) scale(${s})`},children:t})]})}function Hpe(e,t){const n=e.b,a=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===a.id&&n.toolId===a.toolId&&n.worldX===a.worldX&&n.worldY===a.worldY&&n.spawnDx===a.spawnDx&&n.spawnDy===a.spawnDy&&n.status===a.status&&n.fading===a.fading&&n.category===a.category&&n.mcpHue===a.mcpHue&&n.isSub===a.isSub&&n.emoji===a.emoji&&n.name===a.name&&n.fullName===a.fullName&&n.toolName===a.toolName&&n.inputPreview===a.inputPreview}const Gpe=m.memo(function({b:t,dim:n,onOpenTool:a}){const s={left:`${t.worldX}px`,top:`${t.worldY}px`,"--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},o=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,r=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=a!=null,l=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},u=n?" dim":"";return i.jsx("div",{className:"tool-burst-wrap",style:s,children:i.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${u}`,style:l,title:r,onClick:c?()=>a(t.agentId,t.toolId):void 0,children:[i.jsx("span",{className:"tb-emoji",children:t.emoji}),i.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&i.jsx("span",{className:"tb-spin"}),t.status==="done"&&i.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&i.jsx("span",{className:"tb-mark err",children:"×"})]})})},Hpe),Vpe={width:140,height:105},Kpe={agent:Hde,sessionGroup:Fpe,recapNote:upe},$pe={recapTie:ppe};function Jpe({nodeColor:e,palette:t,notes:n=!0}){const a=se(),s=Tg(),o=Ws(Bl),r=Lre(n);return s||o||!r?null:i.jsx(qee,{ariaLabel:a("board.minimap"),position:r==="left"?"bottom-left":"bottom-right",style:Vpe,zoomable:!0,pannable:!0,nodeColor:e,nodeStrokeWidth:2,maskColor:t["--minimap-mask"],maskStrokeColor:t["--line"]})}function Ype({graph:e,layout:t,viewport:n,clicks:a,drag:s,appearance:o,fm:r,radioOpen:c,onRadioClose:l,autoFit:u,pause:h,stateRef:p,measuredRef:f,hiddenCats:b,now:v,openTool:w,focusAgent:T,requestClear:y,setKeyHelpOpen:x,zoomBy:C,zoomReset:A,onTerminal:E,notesDrawn:R=!0,presentCats:z,toggleCat:I}){const{allNodes:_,edges:D,visibleAgentIds:L,spotlightSet:P}=e,{positionsRef:O,pinnedRef:j,handleRelayout:M,rearrangeUndo:F}=t,{restoredViewport:U,onMoveStart:H,onMove:$}=n,{onNodeClick:Y,onPaneClick:W,onNodeDoubleClick:G,onNodeMouseEnter:Q,onNodeMouseLeave:J}=a,{onNodeDragStart:X,onNodeDrag:te,onNodeDragStop:K}=s,{palette:V,minimapNodeFill:ee,characterEnabled:de}=o,{autoFitDisabled:he,enableAutoFitAndRefit:me}=u,{paused:be,togglePause:ie}=h;return i.jsxs(V3,{nodes:_,edges:D,nodeTypes:Kpe,edgesFocusable:!1,edgeTypes:$pe,fitView:!U,fitViewOptions:{padding:.25},minZoom:j4,maxZoom:E4,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:Y,onPaneClick:W,onNodeDoubleClick:G,onNodeMouseEnter:Q,onNodeMouseLeave:J,onMoveStart:H,onMove:$,onNodeDragStart:(ne,ke,Se)=>{F.dismiss(),X(ne,ke,Se)},onNodeDrag:te,onNodeDragStop:K,children:[i.jsx(Hee,{gap:28,size:1,color:V["--grid-line"]}),i.jsx(Dpe,{onFocusSession:T,notes:R}),i.jsx(Bpe,{agents:p.current.agents,visibleAgentIds:L,positions:O.current,pinned:j.current,measured:f.current,spotlight:P,hiddenCategories:b,now:v,onOpenTool:w}),i.jsx("div",{className:"canvas-notices"}),i.jsx(gue,{autoFitDisabled:he,enableAutoFitAndRefit:me,paused:be,togglePause:ie,handleRelayout:M,requestClear:y,setKeyHelpOpen:x,zoomBy:C,zoomReset:A,onTerminal:E,presentCats:z,hiddenCats:b,toggleCat:I}),i.jsx(Jpe,{nodeColor:ee,palette:V,notes:R}),i.jsx(eG,{fm:r,character:o.character,characterEnabled:de,open:c,onClose:l})]})}function Zpe(){const e=se(),t=window.ccdeckWindow;return m.useEffect(()=>{if(!t)return;const n=()=>{const s=document.querySelector(".topbar");if(!s)return;const o=getComputedStyle(s),r=c=>{var u;const l=(u=c.match(/\d+/g))==null?void 0:u.slice(0,3);return(l==null?void 0:l.length)===3?`#${l.map(h=>Number(h).toString(16).padStart(2,"0")).join("")}`:"#191a1c"};t.colors({color:r(o.backgroundColor),symbolColor:r(o.color)}).catch(()=>{})};n();const a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>a.disconnect()},[t]),!t||t.platform==="darwin"?null:i.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":e("shell.appMenu"),title:e("shell.appMenu"),"aria-haspopup":"menu",onClick:()=>{t.menu().catch(()=>{})},children:i.jsx(Ze,{name:"more"})})}const ju="agent-dag.sessionsSeen";function U1(e){const t=new Map;if(!e)return t;try{const n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n))for(const[a,s]of Object.entries(n))typeof s=="number"&&Number.isFinite(s)&&t.set(a,s)}catch{}return t}function a0(e,t){const n=new Map(e);for(const[s,o]of t)o>(n.get(s)??-1/0)&&n.set(s,o);const a=[...n].sort((s,o)=>s[1]-o[1]).slice(-200);return new Map(a)}let Zo=U1(gt(ju)),W1=gt(ju)===null;const vp=new Set;let oG=0;function rG(){oG++;for(const e of vp)e()}function Xpe(){const e=gt(ju);e!==null&&(W1=!1);const t=a0(Zo,U1(e));t.size===Zo.size&&[...t].every(([n,a])=>Zo.get(n)===a)||(Zo=t,rG())}function MP(e){(e.key===ju||e.key===null)&&Xpe()}function Qpe(e){return vp.size===0&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.addEventListener("storage",MP),vp.add(e),()=>{vp.delete(e),vp.size===0&&typeof window<"u"&&typeof window.removeEventListener=="function"&&window.removeEventListener("storage",MP)}}function cG(e){const t=a0(Zo,U1(gt(ju)));e(t),Zo=a0(t,new Map),W1=!1,rG(),yt(ju,JSON.stringify(Object.fromEntries(Zo)))}function tk(e){var n;const t=((n=e.waiting)==null?void 0:n.kind)==="idle"?e.waiting.since:null;return e.state==="active"&&t==null?null:e.endedAt??t}function ege(e,t){return t!=null&&t>(Zo.get(e)??0)}function tge(e,t){t!=null&&(typeof document<"u"&&document.visibilityState!=="visible"||(Zo.get(e)??0)>=t||cG(n=>{n.set(e,Math.max(t,n.get(e)??0))}))}function nge(e){if(!W1)return!1;const t=[...e];return t.length===0?!1:(cG(n=>{for(const[a,s]of t)s!=null&&s>(n.get(a)??0)&&n.set(a,s)}),!0)}function lG(){return m.useSyncExternalStore(Qpe,()=>oG,()=>0)}function Iu({children:e,narrow:t}){return i.jsx("svg",{className:t?"glyph glyph-narrow":"glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e})}const dG=()=>i.jsx(Ze,{name:"sessions",className:"glyph"}),age=()=>i.jsx(Ze,{name:"integrations",className:"glyph"}),uG=()=>i.jsx(Ze,{name:"account",className:"glyph"}),sge=()=>i.jsx(Ze,{name:"usage",className:"glyph glyph-narrow"}),ige=()=>i.jsx(Ze,{name:"activity",className:"glyph"}),oge=()=>i.jsx(Ze,{name:"machine",className:"glyph"}),rge=()=>i.jsx(Ze,{name:"radar",className:"glyph"}),cge=({watching:e})=>e?i.jsx(Ze,{name:"browser-watch",className:"glyph"}):i.jsxs(Iu,{children:[i.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),i.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),lge=()=>i.jsx(Ze,{name:"settings",className:"glyph"}),dge=()=>i.jsx(Ze,{name:"feedback",className:"glyph"}),uge=()=>i.jsx(Ze,{name:"play",className:"glyph"}),hge=()=>i.jsx(Ze,{name:"update",className:"glyph"}),pge=()=>i.jsx(Ze,{name:"restart",className:"glyph"}),gge=()=>i.jsx(Ze,{name:"radio",className:"glyph"}),mge=()=>i.jsx(Ze,{name:"tools",className:"glyph"}),hG=()=>i.jsx(Ze,{name:"skills",className:"glyph"}),fge=()=>i.jsx(Ze,{name:"capacity",className:"glyph"}),bge=()=>i.jsx(Ze,{name:"calendar",className:"glyph"}),kge=()=>i.jsx(Ze,{name:"info",className:"glyph"}),pG=()=>i.jsx(Ze,{name:"time",className:"glyph"}),vge=()=>i.jsx(Iu,{children:i.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"M11.571 11.513H0a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 12.575 24V12.518a1.005 1.005 0 0 0-1.005-1.005zm5.723-5.756H5.736a5.215 5.215 0 0 0 5.215 5.214h2.129v2.058a5.218 5.218 0 0 0 5.215 5.214V6.758a1.001 1.001 0 0 0-1.001-1.001zM23.013 0H11.455a5.215 5.215 0 0 0 5.215 5.215h2.129v2.057A5.215 5.215 0 0 0 24 12.483V1.005A1.001 1.001 0 0 0 23.013 0z"})}),wge=()=>i.jsx(Iu,{children:i.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})}),yge=()=>i.jsx(Iu,{children:i.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"m23.6004 9.5927-.0337-.0862L20.3.9814a.851.851 0 0 0-.3362-.405.8748.8748 0 0 0-.9997.0539.8748.8748 0 0 0-.29.4399l-2.2055 6.748H7.5375l-2.2057-6.748a.8573.8573 0 0 0-.29-.4412.8748.8748 0 0 0-.9997-.0537.8585.8585 0 0 0-.3362.4049L.4332 9.5015l-.0325.0862a6.0657 6.0657 0 0 0 2.0119 7.0105l.0113.0087.03.0213 4.976 3.7264 2.462 1.8633 1.4995 1.1321a1.0085 1.0085 0 0 0 1.2197 0l1.4995-1.1321 2.4619-1.8633 5.006-3.7489.0125-.01a6.0682 6.0682 0 0 0 2.0094-7.003z"})}),gG=()=>i.jsx(Ze,{name:"search",className:"glyph"}),xge=()=>i.jsx(Ze,{name:"recenter",className:"glyph"}),Cge=()=>i.jsx(Ze,{name:"arrange",className:"glyph"}),Sge=()=>i.jsx(Ze,{name:"pause",className:"glyph"}),Tge=()=>i.jsx(Ze,{name:"clear",className:"glyph"}),Nge=({shown:e})=>i.jsx(Iu,{children:i.jsx("path",{d:e?"M7 3.5 3.5 7 7 10.5M10.5 3.5 7 7l3.5 3.5":"M3.5 3.5 7 7l-3.5 3.5M7 3.5 10.5 7 7 10.5"})}),Age=()=>i.jsx(Iu,{children:i.jsx("path",{d:"M4.6 3.6 1.4 7l3.2 3.4M9.4 3.6 12.6 7l-3.2 3.4M8 2.2 6 11.8"})}),mG=120;function fG(e){if(!e||e.kind!=="root"||typeof e.sessionId!="string"||!e.sessionId)return null;const t=bu({sessionName:e.providerSessionName??(e.deckName?void 0:e.sessionName),sessionTitle:e.sessionTitle,label:e.label,cwdBasename:e.cwdBasename})??"";return{provider:e.provider==="codex"?"codex":"claude",sessionId:e.sessionId,current:bu(e)??"",fallback:t,deckNamed:typeof e.deckName=="string"&&e.deckName.trim()!==""}}function jge(e){const t=e.replace(/\s+/g," ").trim();return Array.from(t).slice(0,mG).join("")}function Ege(e,t){const n=jge(e);return!n||n===t.fallback?t.deckNamed?{kind:"save",name:null}:{kind:"none"}:n===t.current?{kind:"none"}:{kind:"save",name:n}}function IP(e){return e.isComposing?null:e.key==="Enter"?"save":e.key==="Escape"?"cancel":null}function Rge(e){return e.key==="F2"&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey}async function zge(e,t,n=fetch){try{const a=await n("/api/session-name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e.provider,sessionId:e.sessionId,name:t,syncProvider:!0})}),s=await a.json().catch(()=>null);return!a.ok||!s||s.ok!==!0?{ok:!1}:{ok:!0,name:typeof s.name=="string"?s.name:null}}catch{return{ok:!1}}}function qge(){return i.jsxs("svg",{className:"sn-glyph",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M9.4 2.6l2 2L5 11l-2.6.6L3 9z"}),i.jsx("path",{d:"M8.2 3.8l2 2"})]})}function bG(e,t){const[n,a]=m.useState(null),s=m.useRef(!1),o=n!=null&&n===e;return m.useEffect(()=>{var r,c;o||!s.current||(s.current=!1,fa(((r=document.activeElement)==null?void 0:r.tagName)??null)&&((c=t.current)==null||c.focus()))},[o,t]),{on:o,start(){e&&a(e)},done(){s.current=!0,a(null)}}}function kG({facts:e,place:t,onDone:n}){const a=se(),[s]=m.useState(e),[o,r]=m.useState(e.current),[c,l]=m.useState(!1),[u,h]=m.useState(!1),p=m.useRef(null),f=m.useRef(null),b=m.useRef(!0),v=m.useRef(!1),w=m.useId();m.useEffect(()=>{var x,C;return(x=p.current)==null||x.focus(),(C=p.current)==null||C.select(),()=>{b.current=!1}},[]);const T=x=>{v.current||(v.current=!0,n(x))},y=async x=>{var R,z;if(u||v.current)return;const C=Ege(x,s);if(C.kind==="none"){T(!1);return}h(!0);const A=await zge(s,C.name);if(!b.current)return;if(h(!1),A.ok){T(!0);return}l(!0);const E=document.activeElement;(fa((E==null?void 0:E.tagName)??null)||(R=f.current)!=null&&R.contains(E))&&((z=p.current)==null||z.focus())};return i.jsxs("span",{ref:f,className:"sn-field","data-place":t,"data-failed":c||void 0,onBlur:x=>{var C;x.target===p.current||!document.hasFocus()||x.relatedTarget instanceof Node&&((C=f.current)!=null&&C.contains(x.relatedTarget))||y(o)},onKeyDown:x=>{x.target!==p.current&&(x.stopPropagation(),IP({key:x.key})==="cancel"&&(x.preventDefault(),T(!1)))},children:[i.jsx("input",{ref:p,className:"ap-manage-input sn-input",value:o,maxLength:mG,placeholder:s.fallback,spellCheck:!1,autoComplete:"off","aria-label":a("board.rename.field"),"aria-invalid":c||void 0,"aria-describedby":c?w:void 0,"aria-busy":u||void 0,readOnly:u,onChange:x=>r(x.target.value),onKeyDown:x=>{x.stopPropagation();const C=IP({key:x.key,isComposing:x.nativeEvent.isComposing});C&&(x.preventDefault(),C==="save"?y(o):T(!1))},onBlur:x=>{var C;document.hasFocus()&&(x.relatedTarget instanceof Node&&((C=f.current)!=null&&C.contains(x.relatedTarget))||y(o))},onClick:x=>x.stopPropagation(),onDoubleClick:x=>x.stopPropagation()}),s.deckNamed&&i.jsx("button",{type:"button",className:"glyph-btn sn-reset","aria-label":a("board.rename.reset"),title:s.fallback?`${a("board.rename.reset")}: ${s.fallback}`:a("board.rename.reset"),onMouseDown:x=>x.preventDefault(),onClick:x=>{x.stopPropagation(),y("")},children:i.jsx(Ze,{name:"restart"})}),c&&i.jsx("span",{id:w,className:"sn-error",role:"alert",children:a("board.rename.failed")})]})}const vG="application/x-ccdeck-session",wG="application/x-ccdeck-pane";let H1=null,DP=!1;function g4e(){return H1}function m4e(e){if(!e)return!1;const t=Array.from(e);return t.includes(vG)||t.includes(wG)}function s0(){H1=null}function _ge(e,t,n=typeof document>"u"?void 0:document){const a=e.dataTransfer;if(a){if(H1=t,a.setData(t.kind==="session"?vG:wG,t.id),a.effectAllowed="move",n&&typeof a.setDragImage=="function")try{const s=n.createElement("div");s.className="wsp-drag-chip",s.textContent=t.name,n.body.appendChild(s),a.setDragImage(s,12,14),setTimeout(()=>s.remove(),0)}catch{}!DP&&typeof window<"u"&&(DP=!0,window.addEventListener("dragend",s0,!0),window.addEventListener("drop",()=>setTimeout(s0,0),!0))}}const Lge="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%3e%3c/path%3e%3c/svg%3e",Pge="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M8.086.457a6.105%206.105%200%20013.046-.415c1.333.153%202.521.72%203.564%201.7a.117.117%200%2000.107.029c1.408-.346%202.762-.224%204.061.366l.063.03.154.076c1.357.703%202.33%201.77%202.918%203.198.278.679.418%201.388.421%202.126a5.655%205.655%200%2001-.18%201.631.167.167%200%2000.04.155%205.982%205.982%200%20011.578%202.891c.385%201.901-.01%203.615-1.183%205.14l-.182.22a6.063%206.063%200%2001-2.934%201.851.162.162%200%2000-.108.102c-.255.736-.511%201.364-.987%201.992-1.199%201.582-2.962%202.462-4.948%202.451-1.583-.008-2.986-.587-4.21-1.736a.145.145%200%2000-.14-.032c-.518.167-1.04.191-1.604.185a5.924%205.924%200%2001-2.595-.622%206.058%206.058%200%2001-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74%207.74%200%2001-.495-1.283%206.11%206.11%200%2001-.017-3.064.166.166%200%2000.008-.074.115.115%200%2000-.037-.064%205.958%205.958%200%2001-1.38-2.202%205.196%205.196%200%2001-.333-1.589%206.915%206.915%200%2001.188-2.132c.45-1.484%201.309-2.648%202.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129%200%2000.087-.087A6.016%206.016%200%20015.635%202.31C6.315%201.464%207.132.846%208.086.457zm-.804%207.85a.848.848%200%2000-1.473.842l1.694%202.965-1.688%202.848a.849.849%200%20001.46.864l1.94-3.272a.849.849%200%2000.007-.854l-1.94-3.393zm5.446%206.24a.849.849%200%20000%201.695h4.848a.849.849%200%20000-1.696h-4.848z'%3e%3c/path%3e%3c/svg%3e";function Oge({provider:e}){const t=e==="codex"?"Codex":"Claude Code",n={"--provider-mark":`url("${e==="codex"?Pge:Lge}")`};return i.jsx("span",{className:"provider-avatar","data-provider":e,role:"img","aria-label":t,title:t,style:n})}function Wy({kind:e}){const t=m.useRef(e),n=m.useRef(null);return m.useEffect(()=>{t.current!==e&&(t.current=e,Yce(n.current))},[e]),i.jsx("span",{className:"sl-glyph","data-glyph":e,"aria-hidden":!0,children:i.jsxs("span",{ref:n,className:"sl-glyph-mark",children:[e==="waiting"&&i.jsx(ic,{size:14}),e==="working"&&i.jsx(yi,{kind:"live",size:14}),e==="done"&&i.jsx(yi,{kind:"done",size:14}),e==="partial"&&i.jsx(yi,{kind:"partial",size:14}),e==="error"&&i.jsx(yi,{kind:"err",size:14}),e==="idle"&&i.jsx(yi,{kind:"idle",size:14})]},e)})}function yG({size:e=12}){return i.jsx("svg",{className:"sl-chev",width:e,height:e,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5"})})}function Mge(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M3.5 3.5l7 7M10.5 3.5l-7 7"})})}function Ige(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M7 3v8M3 7h8"})})}function Dge(e,t){if(t)return n=>{n.key!=="Enter"||n.repeat||n.shiftKey||n.ctrlKey||n.altKey||n.metaKey||(n.preventDefault(),t(e))}}function Fge(e,t){if(t)return n=>n.key!=="Enter"||!n.shiftKey||n.repeat||n.ctrlKey||n.altKey||n.metaKey?!1:(n.preventDefault(),t(e),!0)}function Bge({row:e,group:t,now:n,selected:a,removed:s,leaving:o,landNonce:r,onSelect:c,onOpenKeys:l,onOpenBeside:u,rename:h,compact:p=!1,showContext:f=!1,context:b,pane:v}){const w=se(),T=rde(e,t,w),y=p&&b?b.twin:e.twin,x=!p||f||(b==null?void 0:b.detail)==="task"||(b==null?void 0:b.detail)==="project"||t===0||!!y||s||!!T||e.state==="err"||!e.folder,C=p&&b&&t!==0&&!s&&!T&&e.state!=="err"&&!e.neverPrompted,A=C&&b.detail==="project",E=x?C&&b.text?{kind:"words",text:b.text}:b5(e,t):null,R=y?p&&(b!=null&&b.idTail)?b.idTail:Nu(e.startedAt,y):null,z=p&&b&&t===0&&b.detail!=="none"&&!s&&!T?e.folder??e.cwdBasename:null,I=p&&(!x||A||t===0||e.fullTask&&(e.fullTask!==e.task||(b==null?void 0:b.text)!==void 0&&!b.text.includes(e.fullTask)))?e.fullTask??e.task:null,_=!!(E||s||T),D=_||!!R,L=k5(e,t,n),P=t===1,O=i.jsx(Uge,{removed:s,failed:T,line:E}),[j,M]=m.useState(null);m.useEffect(()=>{r!=null&&M(r)},[r]);const F=m.useRef(null),U=bG(h==null?void 0:h.sessionId,F),[H,$]=m.useState(!1),Y=s?void 0:u,W=Fge(e.sessionId,Y);return U.on&&h?i.jsx("li",{className:"sl-row-item","data-rail-id":e.sessionId,children:i.jsx("div",{className:"sl-row-in",children:i.jsxs("div",{className:`sl-row sl-row-edit${a?" selected":""}`,children:[i.jsx(Wy,{kind:qp(e,t)}),i.jsx(kG,{facts:h,place:"row",onDone:U.done})]})})}):i.jsx("li",{className:`sl-row-item${o?" leaving":""}`,"data-rail-id":e.sessionId,ref:G=>{G&&(G.inert=o)},children:i.jsx("div",{className:"sl-row-in","data-dragging":H||void 0,draggable:Y?!0:void 0,onDragStart:Y?G=>{_ge(G,{kind:"session",id:e.sessionId,name:e.label}),$(!0)}:void 0,onDragEnd:Y?()=>{$(!1),s0()}:void 0,onKeyDown:h||W?G=>{G.target===F.current&&(W!=null&&W(G)||h&&Rge(G)&&(G.preventDefault(),U.start()))}:void 0,children:i.jsxs("button",{ref:F,type:"button",className:`sl-row${a?" selected":""}${s?" removed":""}`,"aria-current":a?"true":void 0,"aria-keyshortcuts":h?"F2":void 0,"data-session":e.sessionId,"data-one-line":!D||void 0,"data-compact":p||void 0,"data-pane-active":(v==null?void 0:v.active)||void 0,onClick:()=>c(e.sessionId),onDoubleClick:h?U.start:void 0,onKeyDown:Dge(e.sessionId,l),title:[hde(e,s,p),v?w(v.active?"board.stage.split.activePane":"board.stage.split.paneNumber",{number:v.number}):""].filter(Boolean).join(`
|
|
@@ -145,13 +145,13 @@ ${n}`:c("accounts.sort.by",{label:t}),onClick:()=>o(s(a,e)),children:[t,i.jsx("s
|
|
|
145
145
|
`).map(n=>({text:`+ ${n}`,tone:"add"}))]}function pje(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!$s(n)||!Array.isArray(n.lines))return null;t.push({text:`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,tone:"ctx"});for(const a of n.lines){const s=String(a);t.push(s.startsWith("+")?{text:s,tone:"add"}:s.startsWith("-")?{text:s,tone:"del"}:{text:s})}}return t}function VM(e){if(typeof e=="string")return[Ka(void 0,e)];if(!$s(e))return[Ka(void 0,Il(e))];const t=[],n=Ts(e.type);n==="create"&&t.push(go("result",S("insights.tv.created")));const a=pje(e.structuredPatch);return a&&t.push(qK(HR("applied"),a)),e.userModified===!0&&t.push(go("note",S("insights.tv.userChanged"))),t.length?t:[go("result",S(n==="update"?"insights.tv.updated":"insights.tv.done"))]}function gje(e){const t=typeof e.offset=="number"?e.offset:null,n=typeof e.limit=="number"?e.limit:null;if(t==null&&n==null)return null;const a=t??1;return n!=null?`${a}–${a+n-1}`:S("insights.tv.from",{from:a})}function mje(e){if(typeof e=="string")return[Ka(void 0,e)];const t=$s(e)&&$s(e.file)?e.file:null,n=Ts(t==null?void 0:t.content);if(t&&n!=null){const s=[],o=Number(t.numLines),r=Number(t.totalLines),c=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(r)&&r>0&&s.push(go("lines",o>=r?S("insights.tv.allLines",{total:r}):Number.isFinite(c)?S("insights.tv.range",{from:c,to:c+o-1,total:r}):S("insights.tv.someOf",{shown:o,total:r}))),s.push(Ka("content",n)),s}const a=$s(e)?Ts(e.type):null;return a&&a!=="text"?[go("result",S(/^[aeiou]/i.test(a)?"insights.tv.anFile":"insights.tv.aFile",{kind:a}))]:[Ka(void 0,Il(e))]}function fje(e){if(typeof e=="string")return[Ka("output",e)];if(!$s(e))return[Ka(void 0,Il(e))];const t=Ts(e.stdout),n=Ts(e.stderr);if(t==null&&n==null)return[Ka(void 0,Il(e))];const a=[];return t&&a.push(Ka("output",t.replace(/\n$/,""))),n&&a.push(Ka("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&a.push(go("note",S("insights.tv.interrupted"))),a.length?a:[go("output",S("insights.tv.noneWord"))]}function bje(e,t,n){const a=_u(t),s=_u(n),o=$s(a)?a:null;if(o&&(e==="Edit"||e==="MultiEdit")){const r=Ts(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter($s).filter(l=>Ts(l.old_string)!=null&&Ts(l.new_string)!=null);if(r&&c.length){const l=[Jf(r)];return c.forEach((u,h)=>{const p=u.replace_all===!0;l.push(qK(S(c.length>1?p?"insights.tv.changeNEvery":"insights.tv.changeN":p?"insights.tv.changeEvery":"insights.tv.change",{n:h+1}),hje(u.old_string,u.new_string)))}),{input:l,response:VM(s)}}}if(o&&e==="Write"){const r=Ts(o.file_path),c=Ts(o.content);if(r&&c!=null)return{input:[Jf(r),Ka("content",c)],response:VM(s)}}if(o&&e==="Read"){const r=Ts(o.file_path);if(r){const c=gje(o);return{input:c?[Jf(r),go("lines",c)]:[Jf(r)],response:mje(s)}}}if(o&&e==="Bash"){const r=Ts(o.command);if(r!=null){const c=Ts(o.description);return{input:c?[Ka("command",r),go("why",c)]:[Ka("command",r)],response:fje(s)}}}return{input:[Ka(void 0,Il(a))],response:[Ka(void 0,Il(s))]}}function KM(e,t,n){const a=_u(n);if(a==null)return"";if(typeof a=="string")return a;if($s(a)){if(e==="Bash"&&t==="input"&&typeof a.command=="string")return a.command;if(e==="Bash"&&t==="response"&&(typeof a.stdout=="string"||typeof a.stderr=="string"))return[a.stdout,a.stderr].filter(s=>typeof s=="string"&&s!=="").join(`
|
|
146
146
|
`);if(e==="Read"&&t==="response"&&$s(a.file)&&typeof a.file.content=="string")return a.file.content}try{return JSON.stringify(a,null,2)??String(a)}catch{return String(a)}}function $M(e,t){return e.length>t?[...e.slice(0,t-1),"…"].join(""):e}function mg(e,t=80){const n=_u(e);if(n==null)return"";if(typeof n=="string")return $M(n,t);try{const a=JSON.stringify(n);return $M(a,t)}catch{return String(n)}}const JM=200;function _K(e,t,n){const a=t.ok===!1;t.ok=n,e&&a===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function LK(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Fp(e,t,n){const a=e.toolCountByName??=new Map,s=(a.get(t)??0)+n;s>0?a.set(t,s):a.delete(t)}function kje(e,t,n){var a;return((a=e.get(t))==null?void 0:a.tools.find(s=>s.id===n))??null}const PK=25;function OK(e,t){const n=t.tools;if(n.length>JM){const a=n.splice(0,n.length-JM);for(const s of a)IK(e,t,s)}for(let a=n.length-PK-1;a>=0;a--){const s=n[a];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function vje(e,t,n){const a=e.toolIndex.get(Bu(t.sessionId,n));if(a)return a;for(let s=t.tools.length-1;s>=0;s--)if(t.tools[s].id===n)return t.tools[s];return null}function MK(e,t){for(const n of t.tools)IK(e,t,n)}function IK(e,t,n){const a=Bu(t.sessionId,n.id);e.toolIndex.get(a)===n&&e.toolIndex.delete(a)}function wje(e,t){const n=e.agents.get(t);if(!n)return;let a=!1;for(const s of e.agents.values()){if(s===n||s.sessionId!==t)continue;const o=s.tools.filter(r=>r.explicitSubagentId==null);if(o.length!==0){for(const r of o)s.toolCount-=1,Fp(s,r.name,-1),r.ok===!1&&(s.toolErrorCount=(s.toolErrorCount??0)-1),r.agentId=n.id,n.tools.push(r),n.toolCount+=1,Fp(n,r.name,1),r.ok===!1&&(n.toolErrorCount=(n.toolErrorCount??0)+1);s.tools=s.tools.filter(r=>r.explicitSubagentId!=null),a=!0}}if(a){n.tools.sort((s,o)=>s.startedAt-o.startedAt),OK(e,n);for(let s=0;s<n.tools.length-PK;s++){const o=n.tools[s];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const yje=()=>S("board.tool.dropped");function DK(e,t,n,a,s){n.endedAt=a,_K(t,n,!1),n.errorPreview=n.outcomeGap?yje():s,e.toolIndex.delete(Bu(t.sessionId,n.id))}function xje(e,t){const n=t==null?void 0:t.payload,a=n==null?void 0:n.hook_event_name;if(a!=="PostToolUse"&&a!=="PostToolUseFailure")return!1;const s=n==null?void 0:n.tool_use_id;return typeof s!="string"||s.length===0?!1:e.toolIndex.has(Bu((n==null?void 0:n.session_id)??"unknown",s))}function Cje(e,t,n,a,s){const o=t.tool_use_id?vje(e,a,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const u=LK(e,o);u&&(Fp(u,"?",-1),Fp(u,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=mg(t.tool_input));return}const r=t.tool_use_id??`${a.id}:${a.toolCount}`,c=Uu(t),l={id:r,name:t.tool_name??"?",input:t.tool_input,inputPreview:mg(t.tool_input),agentId:a.id,explicitSubagentId:c?dr(n,c):void 0,startedAt:s};a.tools.push(l),a.toolCount+=1,Fp(a,l.name,1),a.state="active",e.toolIndex.set(Bu(a.sessionId,r),l),OK(e,a),lre(a,l.name,t.tool_input,s)}function Sje(e,t,n,a,s){const o=t.tool_use_id;if(!o)return;const r=Bu(a,o);let c=e.toolIndex.get(r),l=!1;if(!c)for(const h of e.agents.values()){if(h.sessionId!==a)continue;const p=h.tools.find(f=>f.id===o);if(p){c=p,l=!0;break}}if(!c||c.outcomeApplied)return;if(c.outcomeApplied=!0,n==="PostToolUse"){const h=e.agents.get(a);h&&dre(h,t.tool_name??c.name,t.tool_input??c.input,t.tool_response,s)}c.outcomeGap=void 0,c.endedAt=s,_K(LK(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=mg(t.tool_response):l&&(c.errorPreview=void 0);const u=wK(t.tool_response);u&&(c.usage=u),e.toolIndex.delete(r)}function Tje(e,t,n){const a=e.agents.get(t);a&&n>(a.lastEventAt??0)&&(a.lastEventAt=n,a.reaped&&(a.reaped=!1,a.state="active",a.endedAt=void 0,a.closedAt=void 0))}function GR(e,t){e!=null&&e.stopFailure&&t>e.stopFailure.at&&(e.stopFailure=null)}function Nje(e,t,n,a){const s=gc(e,n,a,!1);s.synthetic=!1,s.state="active",s.closedAt=void 0,s.endedAt=void 0,GR(s,a),s.startedAt=Math.min(s.startedAt??a,a),Ml(s,t),BR(s,t)}function Aje(e,t,n,a){for(const r of e.agents.values())r.sessionId===n&&r.kind==="subagent"&&r.state==="done"&&r.exitAt==null&&r.endedAt!=null&&r.endedAt<a&&(r.exitAt=a);const s=gc(e,n,a,!1);s.state="active",s.endedAt=void 0,s.closedAt=void 0,s.exitAt=void 0,GR(s,a);const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&ije(s.prompts,a,o)&&!s.firstPrompt&&!jl(o)&&(s.firstPrompt=mg(o,120))}function K0(e,t,n,a,s){const o=gc(e,n,a,!1),r=oje(o);if(a<r)return;const c=o.lastTurnEndAt;if(!(c!=null&&r>c&&a<=c+vk)){o.state="done",o.endedAt=a,o.lastTurnEndAt=a,s&&(!o.stopFailure||a>=o.stopFailure.at)&&(o.stopFailure=s.stopFailure);for(const l of o.provider==="codex"?[]:e.agents.values())if(l.sessionId===n)for(const u of l.tools)u.endedAt==null&&u.explicitSubagentId==null&&DK(e,l,u,a,"the turn ended before this call returned");t==="SessionEnd"&&(o.closedAt=a),e.activeSubagentStack.delete(n)}}function jje(e,t,n){var r;const a=t.session_id;if(t.provider!=="codex"&&t.provider!=="claude"||typeof a!="string"||!a)return;const s=e.agents.get(a);if(s!=null&&s.provider&&s.provider!==t.provider||s&&Number.isFinite(t.snapshot_observed_at)&&(s.recoveryLiveAt??s.lastEventAt??0)>=t.snapshot_observed_at)return;if(t.recovery_active===!1){s&&(K0(e,t.recovery_session_closed===!0?"SessionEnd":"Stop",a,n),s.restoredFromLog=void 0);return}const o=gc(e,a,n,!0);o.recoveryLiveAt??=(s==null?void 0:s.lastEventAt)??0,o.provider=t.provider,o.state="active",o.endedAt=o.closedAt=o.exitAt=void 0,o.reaped=!1,o.restoredFromLog=!0,o.lastEventAt=n,Ml(o,t),BR(o,t),typeof t.model=="string"&&t.model&&(o.model=t.model),!s&&Number.isFinite(t.turn_started_at)&&t.turn_started_at<=n&&(o.startedAt=t.turn_started_at),typeof t.prompt=="string"&&t.prompt&&(((r=o.prompts.at(-1))==null?void 0:r.text)!==t.prompt&&o.prompts.push({at:n,text:t.prompt}),!o.firstPrompt&&!jl(t.prompt)&&(o.firstPrompt=mg(t.prompt,120))),UR(e,t,a),WR(e,t,a)}function Eje(e,t,n){const a=t.session_id,s=t.parent_session_id;if(t.provider!=="codex"||typeof a!="string"||!a||typeof s!="string"||!s||a===s)return;const o=e.agents.get(a);if(o!=null&&o.provider&&o.provider!=="codex"||o!=null&&o.parentId&&o.parentId!==s)return;const r=new Set([a]);for(let h=s;h;){if(r.has(h))return;r.add(h);const p=e.agents.get(h);if(p!=null&&p.provider&&p.provider!=="codex")return;h=p==null?void 0:p.parentId}const c=gc(e,a,n,!0);c.provider="codex",c.parentId=s,Ml(c,t);const l=t.agent_nickname||t.agent_role;typeof l=="string"&&l.trim()&&(c.label=l);const u=e.agents.get(s);u&&(u.childCount=[...e.agents.values()].filter(h=>h.parentId===s).length)}const Rje=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,zje=new Set(["tool_input","tool_response"]);function FK(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&Rje.test(ro(n.model)))return n.model;for(const[a,s]of Object.entries(n)){if(zje.has(a))continue;const o=FK(s,t+1);if(o)return o}return null}const qje=256,Cb={ModelObserved:NK,UsageObserved:WR,ContextObserved:AK,SessionNamed:jK,ActivityObserved:EK,JobObserved:RK},Jo=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Yf=e=>typeof e=="string"&&e.trim()!=="",_je=[["model_context_window",e=>typeof e=="number"&&e>0],["approval_policy",e=>typeof e=="string"&&e!==""],["reasoning_effort",e=>typeof e=="string"&&e!==""||e===null],["context_tokens",e=>typeof e=="number"&&e>=0]],Lje=new Set(["working","blocked","done","failed","stopped"]),YM=e=>Jo(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function Pje(e,t){if(!e)return t;const n={...e};for(const[s,o]of Object.entries(t))o!==void 0&&(n[s]=o);const a=s=>{s in e?n[s]=e[s]:delete n[s]};for(const[s,o]of _je)o(t[s])||a(s);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||a("model"),(Jo(e.subagentModels)||Jo(t.subagentModels))&&(n.subagentModels={...Jo(e.subagentModels)?e.subagentModels:{},...Jo(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Jo(t.context)){a("context");break}const s=Jo(e.context)?{...e.context}:{};for(const[o,r]of Object.entries(t.context))(typeof r=="number"||Array.isArray(r))&&(s[o]=r);n.context=s;break}case"SessionNamed":{const s=Yf(t.sessionName)?t.sessionName:e.sessionName??null;let o=Yf(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;Yf(s)&&Yf(o)&&o.trim().toLowerCase()===s.trim().toLowerCase()&&(o=null),n.sessionName=s,n.sessionTitle=o;break}case"ActivityObserved":(!YM(t.activity)||YM(e.activity)&&t.activity.at<e.activity.at)&&a("activity");break;case"JobObserved":t.job===null||Jo(t.job)&&Lje.has(t.job.state)||a("job");break;case"UsageObserved":Jo(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(a("usage"),a("usageByModel"));break}return n}function Oje(e,t,n,a){if(!(t in Cb)||e.agents.has(a))return!1;const s=e.parkedEnrichment.get(a)??new Map,o=Pje(s.get(t),n);for(s.delete(t),s.set(t,o),e.parkedEnrichment.delete(a),e.parkedEnrichment.set(a,s);e.parkedEnrichment.size>qje;){const r=e.parkedEnrichment.keys().next().value;if(r===void 0)break;e.parkedEnrichment.delete(r)}return!0}function Mje(e,t){var a;const n=e.parkedEnrichment.get(t);if(!(!n||!e.agents.has(t))){e.parkedEnrichment.delete(t);for(const[s,o]of n)UR(e,o,t),(a=Cb[s])==null||a.call(Cb,e,o,t)}}function BK(e,t){e.parkedEnrichment.delete(t)}const Ije=32;function ZM(e,t,n){if(!t||!n)return;const a=e.agents.get(t);if(a){if(a.panelLaunch===n)return;a.panelLaunch=n,e.revision+=1;return}for(e.panelLaunches.delete(t),e.panelLaunches.set(t,n);e.panelLaunches.size>Ije;){const s=e.panelLaunches.keys().next().value;if(s===void 0)break;e.panelLaunches.delete(s)}}function Dje(e,t){const n=e.panelLaunches.get(t),a=n===void 0?void 0:e.agents.get(t);a&&(e.panelLaunches.delete(t),a.panelLaunch=n)}const Fje="StopFailure",XM=Object.freeze({authentication_failed:"login",rate_limit:"usage-limit"});function Bje(e){return typeof e=="string"&&Object.hasOwn(XM,e)?XM[e]:"api-error"}const Uje=/^[a-z][a-z0-9_]{0,39}$/;function Wje(e){const t=e==null?void 0:e.error;return typeof t=="string"&&Uje.test(t)?t:"unknown"}const QM=160;function eI(e){if(typeof e!="string")return"";const t=e.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"").replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)?/g,"").replace(/[\p{Cc}\p{Cf}]/gu," ").replace(/\bsk-ant-[A-Za-z0-9_-]+/g,"sk-ant-…").replace(/\b(Bearer)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 …").replace(/\s+/g," ").trim(),n=[...t];return n.length>QM?`${n.slice(0,QM-1).join("").trimEnd()}…`:t}function Hje(e){return eI(e==null?void 0:e.last_assistant_message)||eI(e==null?void 0:e.error_details)}function Gje(e,t){if(!e||typeof e!="object"||e.hook_event_name!==Fje)return null;const n=Wje(e);return{kind:Bje(n),error:n,message:Hje(e),at:t}}const Vje=new Set(["Task","Agent"]),Kje=1e3;function $je(e,t,n,a,s){var u;const o=new Set,r=[];for(const h of e.agents.values())if(!(h.sessionId!==t||h===n)){h.spawnCall&&o.add(h.spawnCall.id);for(const p of h.tools)Vje.has(p.name)&&r.push(p)}if(a.parent_tool_use_id){const h=r.find(p=>p.id===a.parent_tool_use_id);if(h)return h}const c=a.agent_type??a.subagent_type;let l;for(const h of r){if(o.has(h.id)||h.endedAt!=null||h.startedAt>s+Kje)continue;const p=(u=h.input)==null?void 0:u.subagent_type;c&&typeof p=="string"&&p!==c||(!l||h.startedAt<l.startedAt)&&(l=h)}return l}function Jje(e,t,n,a){var h;const s=Uu(t);if(!s)return;const o=YAe(e,n,s,t,a),r=FR(t);if(r&&(o.label=r),!o.spawnCall){const p=$je(e,n,o,t,a),f=(h=p==null?void 0:p.input)==null?void 0:h.description;p&&(o.spawnCall=typeof f=="string"&&f.trim()?{id:p.id,description:f.trim()}:{id:p.id})}const c=e.subagentTombstones.get(o.id);c!=null&&e.subagentTombstones.delete(o.id);const l=o.endedAt!=null&&a-o.endedAt<=vk,u=c!=null&&a-c<=vk;if(l||u){const p=u?c:o.endedAt;o.state="done",o.endedAt=p,o.startedAt=Math.min(o.startedAt,p),CK(e,n,s);return}o.state="active",o.startedAt=o.startedAt||a,o.exitAt=void 0,o.endedAt=void 0,ZAe(e,n,s)}function Yje(e,t,n,a){const s=Uu(t);if(!s)return;const o=xK(e,n,s,t);if(!o){for(const[r,c]of e.subagentTombstones)a-c>vk&&e.subagentTombstones.delete(r);e.subagentTombstones.set(dr(n,s),a);return}o.state="done",o.endedAt=Math.min(o.endedAt??a,a),CK(e,n,s)}function Zje(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const Xje=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function Qje(e,t){let n=null;for(const a of e.toolIndex.values()){const s=a.agentId?e.agents.get(a.agentId):void 0;!s||s.sessionId!==t||(!n||a.startedAt>n.startedAt)&&(n=a)}return n}const e0e=3e4;function t0e(e,t){if(!e||!e.name||t-e.startedAt>e0e||e.startedAt>t)return;const n=p5(e.input);return{name:e.name,preview:(n==null?void 0:n.text)??"",...n!=null&&n.path?{path:!0}:{}}}function n0e(e,t,n,a,s){if(n!=="permission")return{kind:n,message:a,since:s};const o=Qje(e,t),r={kind:n,message:a,since:s};o!=null&&o.explicitSubagentId&&(r.subagentId=o.explicitSubagentId);const c=t0e(o,s);return c&&(r.tool=c),r}function a0e(e,t,n){if(e.kind==="idle")return!0;const a=Uu(t);return a==null?!0:e.subagentId!=null&&dr(n,a)===e.subagentId}function s0e(e,t,n,a){if(!Xje.has(t)){const s=e.agents.get(a);s!=null&&s.waiting&&a0e(s.waiting,n,a)&&(s.waiting=null)}}function i0e(e,t,n,a){const s=Zje(t.notification_type);if(!s)return;const o=gc(e,n,a,!1),r=typeof t.message=="string"?t.message:"",c=o.waiting;o.waiting=c&&c.kind===s&&c.message===r?{...c,since:Math.min(c.since,a)}:n0e(e,n,s,r,a)}function Ug(e,t){return t&&(e.revision+=1),t}function o0e(e,t,n,a,s){if(e.agents.size<=n)return!1;const o=b=>b.state==="done"&&b.endedAt!=null&&t-b.endedAt>a,r=Ag(e.agents.values()),c=new Set([...e.agents.values()].filter(b=>b.provider==="codex"&&!o(b)).map(b=>r.get(b.id))),l=[],u=new Map;for(const[b,v]of e.agents){if(v.parentId!=null){const w=u.get(v.parentId);w?w.push(b):u.set(v.parentId,[b])}o(v)&&!c.has(r.get(b))&&l.push({id:b,endedAt:v.endedAt})}if(l.length===0)return!1;l.sort((b,v)=>b.endedAt-v.endedAt);let h=0;const p=new Set,f=b=>{const v=e.agents.get(b);v&&(MK(e,v),e.agents.delete(b),v.kind==="root"&&BK(e,v.sessionId),p.add(v.sessionId),h++)};for(const b of l){if(e.agents.size<=n)break;if(!e.agents.has(b.id))continue;const v=[],w=new Set([b.id]),T=[...u.get(b.id)??[]];for(;T.length;){const y=T.pop();if(w.has(y))continue;w.add(y);const x=e.agents.get(y);x&&(v.push(x),T.push(...u.get(y)??[]))}if(!v.some(y=>!o(y))){for(const y of v.reverse())f(y.id);f(b.id)}}if(s&&p.size>0){const b=new Set;for(const v of e.agents.values())b.add(v.sessionId);for(const v of p)b.has(v)||s(v)}return Ug(e,h>0)}function r0e(e,t,n,a,s){const o=new Map;for(const[f,b]of e.agents){let v=o.get(b.sessionId);v||(v={ids:[],endedAt:0,live:!1,closed:!1},o.set(b.sessionId,v)),v.ids.push(f),b.kind==="root"&&b.closedAt!=null&&(v.closed=!0),b.state==="done"&&b.endedAt!=null?v.endedAt=Math.max(v.endedAt,b.endedAt):v.live=!0}const r=Ag(e.agents.values()),c=new Set([...e.agents.values()].filter(f=>f.state!=="done"||f.endedAt==null).map(f=>r.get(f.id))),l=[...o].filter(([f,b])=>!c.has(r.get(f))&&!b.live&&b.endedAt>0&&t-b.endedAt>a).sort(([,f],[,b])=>f.closed===b.closed?f.endedAt-b.endedAt:f.closed?-1:1);let h=[...o.values()].filter(f=>!f.live).length-n;if(h<=0)return!1;let p=!1;for(const[f,b]of l){if(h<=0)break;for(const w of b.ids){const T=e.agents.get(w);T&&MK(e,T),e.agents.delete(w)}BK(e,f);const v=dr(f,"");for(const w of e.pendingSubagentModels.keys())w.startsWith(v)&&e.pendingSubagentModels.delete(w);s==null||s(f),h--,p=!0}return Ug(e,p)}function c0e(e){let t=!1;for(const n of e.agents.values())for(const a of n.tools)a.endedAt!=null||a.outcomeGap||(a.outcomeGap=!0,t=!0);return Ug(e,t)}function l0e(e,t,n){let a=!1;for(const s of e.agents.values()){if(s.provider==="codex")continue;const o=e.agents.get(s.sessionId),r=(o==null?void 0:o.lastEventAt)??(o==null?void 0:o.startedAt);for(const c of s.tools){const l=Math.max(c.startedAt,r??c.startedAt);c.endedAt==null&&t-l>n&&(DK(e,s,c,l,S("board.tool.sessionEnded")),a=!0)}}return Ug(e,a)}const tI=90*6e4;function d0e(e,t,n){let a=!1;for(const s of e.agents.values()){if(s.kind!=="root")continue;const o=s.lastEventAt??s.startedAt;if(!(t-o<=n)){s.waiting&&(s.waiting=null,a=!0),s.closedAt==null&&(s.closedAt=o),s.state==="active"&&(s.state="done",s.endedAt=o,s.reaped=!0,a=!0);for(const r of e.agents.values())r.sessionId!==s.sessionId||r.kind==="root"||r.state!=="active"||(r.state="done",r.endedAt=o,a=!0);e.activeSubagentStack.delete(s.sessionId)}}return Ug(e,a)}function UK(e,t){const n=t.epoch??null;if(n!==null&&n!==e.seqEpoch)e.seqEpoch=n,e.lastSeq=0;else if(t.seq<=e.lastSeq)return e;const a=t.payload??{},s=t.receivedAt,o=a.hook_event_name??"Unknown";if(o==="__clear")return{...IR(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};if(o==="__panel_launch")return e.lastSeq=t.seq,e;if(e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1,o==="CodexSessionRecovered"||o==="ClaudeSessionRecovered")return jje(e,a,s),e;if(o==="CodexThreadLinked")return Eje(e,a,s),e;const r=a.session_id??"unknown";if(s0e(e,o,a,r),o!=="JobObserved"&&Tje(e,r,s),UR(e,a,r),Oje(e,o,a,r))return e;switch(o){case"ModelObserved":return NK(e,a,r),e;case"ContextObserved":return AK(e,a,r),e;case"SessionNamed":return jK(e,a,r),e;case"SessionRecapped":return tje(e,a,r),e;case"ActivityObserved":return EK(e,a,r),e;case"JobObserved":return RK(e,a,r),e;case"OutputObserved":return aje(e,a,r,s),e;case"UsageObserved":return WR(e,a,r),e}const c=$Ae(e,a,s),l=e.agents.get(r);l&&s>=(l.recoveryLiveAt??0)&&(l.recoveryLiveAt=s,l.restoredFromLog=void 0),Mje(e,r),Dje(e,r),JAe(e,o,a,r)&&wje(e,r),c.provider||(c.provider=a.provider==="codex"?"codex":"claude"),c.provider==="codex"&&(c.childCount=[...e.agents.values()].filter(b=>b.parentId===c.id).length);const u=FK(a),h=Uu(a),p=h?dr(r,h):r;u&&c.id===p&&(c.model=u);const f=QAe(o,a);switch(f!==void 0&&c.id===p&&(c.effort=f??void 0),(o==="PreToolUse"||o==="PostToolUse"||o==="PostToolUseFailure")&&h==null&&GR(e.agents.get(r),s),o){case"SessionStart":Nje(e,a,r,s);break;case"UserPromptSubmit":Aje(e,a,r,s);break;case"PreToolUse":Cje(e,a,r,c,s);break;case"PostToolUse":case"PostToolUseFailure":Sje(e,a,o,r,s);break;case"SubagentStart":Jje(e,a,r,s);break;case"SubagentStop":Yje(e,a,r,s);break;case"Stop":case"StopFailure":K0(e,o,r,s,{stopFailure:Gje(a,s)});break;case"SessionEnd":K0(e,o,r,s);break;case"Notification":i0e(e,a,r,s);break}return e}const u0e=6,h0e="ccdeck-tabs";function p0e(e){return e>=u0e}function g0e(e,t,n){const a=s=>{const o=s.data;(o==null?void 0:o.kind)==="who"&&o.from!==t&&e.postMessage({kind:"here",from:t,to:o.from,streaming:n()})};return e.addEventListener("message",a),{ask(s,o=(r,c)=>setTimeout(r,c)){return new Promise(r=>{const c=new Set,l=u=>{const h=u.data;(h==null?void 0:h.kind)==="here"&&h.to===t&&h.streaming&&c.add(h.from)};e.addEventListener("message",l),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",l),r(c.size)},s)})},leave(){var s;e.removeEventListener("message",a),(s=e.close)==null||s.call(e)}}}function m0e({stateRef:e,rerender:t,pauseGate:n,chimesRef:a,desktopUpdateRef:s}){const[o,r]=m.useState(!1),[c,l]=m.useState(!1),[u,h]=m.useState(!1),p=m.useRef(FAe),[f,b]=m.useState(null),v=m.useRef(!0),[w,T]=m.useState(null);return m.useEffect(()=>{const y=new EventSource("/events"),x=DAe(t,{now:()=>Date.now(),setTimeout:(R,z)=>window.setTimeout(R,z),clearTimeout:R=>window.clearTimeout(R)});let C=!1;const A=typeof BroadcastChannel=="function"?g0e(new BroadcastChannel(h0e),Math.random().toString(36).slice(2),()=>C):null,E=window.setInterval(()=>{C||!A||A.ask(600).then(R=>{C||l(p0e(R))})},3e3);return y.addEventListener("open",()=>{r(!0),h(!0)}),y.addEventListener("error",()=>{r(!1),T(null)}),y.addEventListener("open",()=>{p.current=BAe(p.current)}),y.addEventListener("error",()=>{p.current=UAe(p.current,Date.now()),b(p.current.droppedAt)}),y.addEventListener("open",()=>{C=!0,l(!1)}),y.addEventListener("error",()=>{C=!1}),y.addEventListener("replay-end",()=>{v.current=!1,x.flush(),T(Date.now())}),y.addEventListener("desktop-update",R=>s.current(R.data)),y.addEventListener("account",R=>{window.dispatchEvent(new CustomEvent(PAe,{detail:R.data}))}),y.addEventListener("open",()=>{window.dispatchEvent(new Event(OAe))}),y.addEventListener("hook",R=>{var z;try{const I=JSON.parse(R.data);if(!n.accept(I))return;e.current=UK(e.current,I);const _=I.replay===!0||v.current||Date.now()-I.receivedAt>3e4;_?x.replay():x.live();const D=Nfe(I,_);D&&((z=a.current)==null||z.play(D))}catch{}}),()=>{y.close(),x.cancel(),window.clearInterval(E),A==null||A.leave()}},[t]),{live:o,tabCapped:c,everConnected:u,liveSince:w,lastNewsAt:f}}const f0e=200,b0e=5*6e4,k0e=6,v0e=2*6e4;function np(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function w0e(e,t){let n=!1;for(const s of e)if(!t.has(s)){n=!0;break}if(!n)return e;const a=new Set;for(const s of e)t.has(s)&&a.add(s);return a}function y0e(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(N1(n.id));return t}function x0e(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(N1(n.id));return t}function C0e(e,t){let n=l0e(e,t,tI);d0e(e,t,tI)&&(n=!0);const a=[],s=o=>{a.push(o)};return o0e(e,t,f0e,b0e,s)&&(n=!0),r0e(e,t,k0e,v0e,s)&&(n=!0),{changed:n,forgotten:a}}function S0e(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const a=new Set(e.ids);if(!a.has(t))return a.add(t),{ids:a,primary:t};if(a.delete(t),e.primary!==t)return{ids:a,primary:e.primary};let s=null;for(const o of a)s=o;return{ids:a,primary:s}}function T0e(e,t){const[n,a]=m.useState(()=>({ids:new Set,primary:null})),{ids:s,primary:o}=n,r=m.useCallback((u,h,p=!h)=>{a(f=>S0e(f,u,h)),!h&&p&&t(!0)},[]),c=m.useCallback(()=>{a({ids:new Set,primary:null})},[]),l=m.useCallback(()=>{a(u=>{const h=w0e(u.ids,e.current.agents),p=u.primary!=null&&!e.current.agents.has(u.primary)?null:u.primary;return h===u.ids&&p===u.primary?u:{ids:h,primary:p}})},[e]);return{selectedIds:s,primarySelectedId:o,selectAgent:r,clearSelection:c,pruneSelectionToBoard:l}}const VR="agent-dag.term-text-size",N0e=13.3,wl=[67,75,80,90,100,110,125,150,175,200],wk=100;function Wu(e){const t=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):NaN;if(!Number.isFinite(t))return wk;let n=wk;for(const a of wl)Math.abs(a-t)<Math.abs(n-t)&&(n=a);return n}function A0e(e,t){if(t==="reset")return wk;const n=wl.indexOf(Wu(e)),a=t==="larger"?Math.min(wl.length-1,n+1):Math.max(0,n-1);return wl[a]}const k4e=e=>Wu(e)<wl[wl.length-1],v4e=e=>Wu(e)>wl[0];function w4e(e){return Math.round(N0e*Wu(e))/100}function j0e(e,t=zs(js())){if(e.altKey||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey))return null;const n=String(e.key??"");return n==="="||n==="+"||e.code==="NumpadAdd"?"larger":(n==="-"||e.code==="NumpadSubtract")&&!e.shiftKey?"smaller":(n==="0"||e.code==="Digit0"||e.code==="Numpad0")&&!e.shiftKey?"reset":null}function y4e(e,t=zs(js())){return t?"⌘+ · ⌘− · ⌘0":`${e}++ · ${e}+− · ${e}+0`}const eu=new Set;let Bp=null;function KR(){return Bp===null&&(Bp=Wu(gt(VR))),Bp}function E0e(e){const t=Wu(e);if(t!==KR()){Bp=t,yt(VR,String(t));for(const n of[...eu])n()}}function x4e(e){E0e(A0e(KR(),e))}function nI(e){if(!(e.key!==null&&e.key!==VR)){Bp=null;for(const t of[...eu])t()}}function R0e(e){return eu.size===0&&typeof window<"u"&&window.addEventListener("storage",nI),eu.add(e),()=>{eu.delete(e),eu.size===0&&typeof window<"u"&&window.removeEventListener("storage",nI)}}function C4e(){return m.useSyncExternalStore(R0e,KR,()=>wk)}const Hd=Object.freeze({key:"`",code:"Backquote",ctrlKey:!0,shiftKey:!1,altKey:!1,metaKey:!1});function $R(e){return e.ctrlKey!==Hd.ctrlKey||e.shiftKey!==Hd.shiftKey||e.altKey!==Hd.altKey||e.metaKey!==Hd.metaKey?!1:String(e.key??"")===Hd.key||e.code===Hd.code}const z0e="Ctrl+`",Gd=Object.freeze({key:"x",code:"KeyX",ctrlKey:!0,shiftKey:!0,altKey:!1,metaKey:!1});function JR(e){if(e.ctrlKey!==Gd.ctrlKey||e.shiftKey!==Gd.shiftKey||e.altKey!==Gd.altKey||e.metaKey!==Gd.metaKey)return!1;const t=String(e.key??"");return/^[a-z]$/i.test(t)?t.toLowerCase()===Gd.key:e.code===Gd.code}function q0e(e){return zs(e)?"⌃⇧X":"Ctrl+Shift+X"}const _0e="board.keys.releaseChordSpoken",YR="[data-terminal-panel]",WK="data-terminal-name";function L0e(e){var n;if(typeof(e==null?void 0:e.closest)!="function")return null;const t=e.closest(YR);return t?((n=t.getAttribute)==null?void 0:n.call(t,WK))??"":null}function HK(e){return typeof(e==null?void 0:e.closest)=="function"&&e.closest(YR)!=null}const P0e="\x1B\r",aI=Object.freeze({"/":"",2:"\0",3:"\x1B",4:"",5:"",6:"",7:"",8:"","^":""});function GK(e){return!e.ctrlKey||e.altKey||e.metaKey?null:Object.prototype.hasOwnProperty.call(aI,e.key)?aI[e.key]:null}function VK(e){if(e.ctrlKey||e.shiftKey)return null;if(e.metaKey&&!e.altKey){if(e.key==="ArrowLeft")return"";if(e.key==="ArrowRight")return"";if(e.key==="Backspace")return""}if(e.altKey&&!e.metaKey){if(e.key==="ArrowLeft")return"\x1Bb";if(e.key==="ArrowRight")return"\x1Bf"}return null}function O0e(e){if(!e.ctrlKey||!e.shiftKey||e.altKey||e.metaKey)return!1;const t=String(e.key??"");return/^[a-z]$/i.test(t)?t.toLowerCase()==="c":e.code==="KeyC"}const M0e=Object.freeze({p:{code:"KeyP",glyph:"π"},o:{code:"KeyO",glyph:"ø"},t:{code:"KeyT",glyph:"†"},b:{code:"KeyB",glyph:"∫"},f:{code:"KeyF",glyph:"ƒ"},d:{code:"KeyD",glyph:"∂"},y:{code:"KeyY",glyph:"¥"}});function KK(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;for(const[t,n]of Object.entries(M0e))if(e.code===n.code&&e.key===n.glyph)return t;return null}function I0e(e,t=zs(js())){return e.key==="Escape"?"pass":JR(e)?"release":$R(e)?"view":j0e(e,t)?"zoom":e.isComposing||e.keyCode===229?"pass":e.key==="Enter"&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey?"newline":O0e(e)?"copy":GK(e)||t&&VK(e)?"send":t&&KK(e)?"meta":"pass"}function D0e(e,t,n=zs(js())){if(t==="newline")return P0e;if(t==="send")return GK(e)??(n?VK(e):null);if(t==="meta"){const a=KK(e);return a?`\x1B${a}`:null}return null}const F0e=160;function B0e({key:e,repeat:t,target:n,modalOpen:a}){if(a)return null;if(e==="Enter")return t||Vb(n,e)?null:{kind:"focus-pane"};if(!/^[jkinw]$/i.test(e)||n!=null&&n.caught)return null;const s=e.toLowerCase();return Vb(n&&{...n,pointerFocused:!0},e)?null:s==="j"||s==="k"?{kind:"step",direction:s==="j"?1:-1}:t?null:s==="i"?{kind:"focus-pane"}:{kind:"next-ask"}}function sI(e,t,n){if(e.length===0)return null;const a=t==null?-1:e.indexOf(t);return a<0?n===1?e[0]:e[e.length-1]:e[(a+n+e.length)%e.length]}const U0e=4;function W0e({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:a,setSummaryFor:s}){const[o,r]=m.useState(Date.now());return m.useEffect(()=>{let c=0;const l=setInterval(()=>{if(c+=1,c%U0e!==0&&typeof document<"u"&&HK(document.activeElement))return;const u=Date.now();r(u);const{changed:h,forgotten:p}=C0e(e.current,u);p.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:p})}).catch(()=>{}),n(),a(f=>f!=null&&!e.current.agents.has(f)?null:f),s(f=>f!=null&&!e.current.agents.has(f)?null:f),h&&t()},250);return()=>clearInterval(l)},[t]),o}const H0e="data-board-head";function fg(e){var n;return(((n=e.hasAttribute)!=null&&n.call(e,H0e)?e.querySelector(":scope > .react-flow"):null)??e).getBoundingClientRect()}function G0e(e){if(typeof document>"u")return null;const t=document.querySelectorAll(".react-flow__node");for(const n of Array.from(t))if(n.dataset.id===e)return n.querySelector(".agent-node");return null}function V0e(e){const t=G0e(e);t&&(t.setAttribute("data-land",""),t.offsetWidth,requestAnimationFrame(()=>t.removeAttribute("data-land")))}function K0e(e=Nl){const t=typeof document<"u"&&document.hidden;return bp({durationMs:e,documentHidden:t})?e:0}function ZR(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 yx,iI;function $0e(){if(iI)return yx;iI=1;function e(){this.__data__=[],this.size=0}return yx=e,yx}var xx,oI;function Hu(){if(oI)return xx;oI=1;function e(t,n){return t===n||t!==t&&n!==n}return xx=e,xx}var Cx,rI;function Lv(){if(rI)return Cx;rI=1;var e=Hu();function t(n,a){for(var s=n.length;s--;)if(e(n[s][0],a))return s;return-1}return Cx=t,Cx}var Sx,cI;function J0e(){if(cI)return Sx;cI=1;var e=Lv(),t=Array.prototype,n=t.splice;function a(s){var o=this.__data__,r=e(o,s);if(r<0)return!1;var c=o.length-1;return r==c?o.pop():n.call(o,r,1),--this.size,!0}return Sx=a,Sx}var Tx,lI;function Y0e(){if(lI)return Tx;lI=1;var e=Lv();function t(n){var a=this.__data__,s=e(a,n);return s<0?void 0:a[s][1]}return Tx=t,Tx}var Nx,dI;function Z0e(){if(dI)return Nx;dI=1;var e=Lv();function t(n){return e(this.__data__,n)>-1}return Nx=t,Nx}var Ax,uI;function X0e(){if(uI)return Ax;uI=1;var e=Lv();function t(n,a){var s=this.__data__,o=e(s,n);return o<0?(++this.size,s.push([n,a])):s[o][1]=a,this}return Ax=t,Ax}var jx,hI;function Pv(){if(hI)return jx;hI=1;var e=$0e(),t=J0e(),n=Y0e(),a=Z0e(),s=X0e();function o(r){var c=-1,l=r==null?0:r.length;for(this.clear();++c<l;){var u=r[c];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=a,o.prototype.set=s,jx=o,jx}var Ex,pI;function Q0e(){if(pI)return Ex;pI=1;var e=Pv();function t(){this.__data__=new e,this.size=0}return Ex=t,Ex}var Rx,gI;function eEe(){if(gI)return Rx;gI=1;function e(t){var n=this.__data__,a=n.delete(t);return this.size=n.size,a}return Rx=e,Rx}var zx,mI;function tEe(){if(mI)return zx;mI=1;function e(t){return this.__data__.get(t)}return zx=e,zx}var qx,fI;function nEe(){if(fI)return qx;fI=1;function e(t){return this.__data__.has(t)}return qx=e,qx}var _x,bI;function $K(){if(bI)return _x;bI=1;var e=typeof lf=="object"&&lf&&lf.Object===Object&&lf;return _x=e,_x}var Lx,kI;function qi(){if(kI)return Lx;kI=1;var e=$K(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Lx=n,Lx}var Px,vI;function Gu(){if(vI)return Px;vI=1;var e=qi(),t=e.Symbol;return Px=t,Px}var Ox,wI;function aEe(){if(wI)return Ox;wI=1;var e=Gu(),t=Object.prototype,n=t.hasOwnProperty,a=t.toString,s=e?e.toStringTag:void 0;function o(r){var c=n.call(r,s),l=r[s];try{r[s]=void 0;var u=!0}catch{}var h=a.call(r);return u&&(c?r[s]=l:delete r[s]),h}return Ox=o,Ox}var Mx,yI;function sEe(){if(yI)return Mx;yI=1;var e=Object.prototype,t=e.toString;function n(a){return t.call(a)}return Mx=n,Mx}var Ix,xI;function Vl(){if(xI)return Ix;xI=1;var e=Gu(),t=aEe(),n=sEe(),a="[object Null]",s="[object Undefined]",o=e?e.toStringTag:void 0;function r(c){return c==null?c===void 0?s:a:o&&o in Object(c)?t(c):n(c)}return Ix=r,Ix}var Dx,CI;function ei(){if(CI)return Dx;CI=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Dx=e,Dx}var Fx,SI;function Wg(){if(SI)return Fx;SI=1;var e=Vl(),t=ei(),n="[object AsyncFunction]",a="[object Function]",s="[object GeneratorFunction]",o="[object Proxy]";function r(c){if(!t(c))return!1;var l=e(c);return l==a||l==s||l==n||l==o}return Fx=r,Fx}var Bx,TI;function iEe(){if(TI)return Bx;TI=1;var e=qi(),t=e["__core-js_shared__"];return Bx=t,Bx}var Ux,NI;function oEe(){if(NI)return Ux;NI=1;var e=iEe(),t=(function(){var a=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function n(a){return!!t&&t in a}return Ux=n,Ux}var Wx,AI;function JK(){if(AI)return Wx;AI=1;var e=Function.prototype,t=e.toString;function n(a){if(a!=null){try{return t.call(a)}catch{}try{return a+""}catch{}}return""}return Wx=n,Wx}var Hx,jI;function rEe(){if(jI)return Hx;jI=1;var e=Wg(),t=oEe(),n=ei(),a=JK(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,r=Function.prototype,c=Object.prototype,l=r.toString,u=c.hasOwnProperty,h=RegExp("^"+l.call(u).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(f){if(!n(f)||t(f))return!1;var b=e(f)?h:o;return b.test(a(f))}return Hx=p,Hx}var Gx,EI;function cEe(){if(EI)return Gx;EI=1;function e(t,n){return t==null?void 0:t[n]}return Gx=e,Gx}var Vx,RI;function Kl(){if(RI)return Vx;RI=1;var e=rEe(),t=cEe();function n(a,s){var o=t(a,s);return e(o)?o:void 0}return Vx=n,Vx}var Kx,zI;function XR(){if(zI)return Kx;zI=1;var e=Kl(),t=qi(),n=e(t,"Map");return Kx=n,Kx}var $x,qI;function Ov(){if(qI)return $x;qI=1;var e=Kl(),t=e(Object,"create");return $x=t,$x}var Jx,_I;function lEe(){if(_I)return Jx;_I=1;var e=Ov();function t(){this.__data__=e?e(null):{},this.size=0}return Jx=t,Jx}var Yx,LI;function dEe(){if(LI)return Yx;LI=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Yx=e,Yx}var Zx,PI;function uEe(){if(PI)return Zx;PI=1;var e=Ov(),t="__lodash_hash_undefined__",n=Object.prototype,a=n.hasOwnProperty;function s(o){var r=this.__data__;if(e){var c=r[o];return c===t?void 0:c}return a.call(r,o)?r[o]:void 0}return Zx=s,Zx}var Xx,OI;function hEe(){if(OI)return Xx;OI=1;var e=Ov(),t=Object.prototype,n=t.hasOwnProperty;function a(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return Xx=a,Xx}var Qx,MI;function pEe(){if(MI)return Qx;MI=1;var e=Ov(),t="__lodash_hash_undefined__";function n(a,s){var o=this.__data__;return this.size+=this.has(a)?0:1,o[a]=e&&s===void 0?t:s,this}return Qx=n,Qx}var eC,II;function gEe(){if(II)return eC;II=1;var e=lEe(),t=dEe(),n=uEe(),a=hEe(),s=pEe();function o(r){var c=-1,l=r==null?0:r.length;for(this.clear();++c<l;){var u=r[c];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=a,o.prototype.set=s,eC=o,eC}var tC,DI;function mEe(){if(DI)return tC;DI=1;var e=gEe(),t=Pv(),n=XR();function a(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return tC=a,tC}var nC,FI;function fEe(){if(FI)return nC;FI=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return nC=e,nC}var aC,BI;function Mv(){if(BI)return aC;BI=1;var e=fEe();function t(n,a){var s=n.__data__;return e(a)?s[typeof a=="string"?"string":"hash"]:s.map}return aC=t,aC}var sC,UI;function bEe(){if(UI)return sC;UI=1;var e=Mv();function t(n){var a=e(this,n).delete(n);return this.size-=a?1:0,a}return sC=t,sC}var iC,WI;function kEe(){if(WI)return iC;WI=1;var e=Mv();function t(n){return e(this,n).get(n)}return iC=t,iC}var oC,HI;function vEe(){if(HI)return oC;HI=1;var e=Mv();function t(n){return e(this,n).has(n)}return oC=t,oC}var rC,GI;function wEe(){if(GI)return rC;GI=1;var e=Mv();function t(n,a){var s=e(this,n),o=s.size;return s.set(n,a),this.size+=s.size==o?0:1,this}return rC=t,rC}var cC,VI;function QR(){if(VI)return cC;VI=1;var e=mEe(),t=bEe(),n=kEe(),a=vEe(),s=wEe();function o(r){var c=-1,l=r==null?0:r.length;for(this.clear();++c<l;){var u=r[c];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=a,o.prototype.set=s,cC=o,cC}var lC,KI;function yEe(){if(KI)return lC;KI=1;var e=Pv(),t=XR(),n=QR(),a=200;function s(o,r){var c=this.__data__;if(c instanceof e){var l=c.__data__;if(!t||l.length<a-1)return l.push([o,r]),this.size=++c.size,this;c=this.__data__=new n(l)}return c.set(o,r),this.size=c.size,this}return lC=s,lC}var dC,$I;function Iv(){if($I)return dC;$I=1;var e=Pv(),t=Q0e(),n=eEe(),a=tEe(),s=nEe(),o=yEe();function r(c){var l=this.__data__=new e(c);this.size=l.size}return r.prototype.clear=t,r.prototype.delete=n,r.prototype.get=a,r.prototype.has=s,r.prototype.set=o,dC=r,dC}var uC,JI;function ez(){if(JI)return uC;JI=1;function e(t,n){for(var a=-1,s=t==null?0:t.length;++a<s&&n(t[a],a,t)!==!1;);return t}return uC=e,uC}var hC,YI;function YK(){if(YI)return hC;YI=1;var e=Kl(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return hC=t,hC}var pC,ZI;function Dv(){if(ZI)return pC;ZI=1;var e=YK();function t(n,a,s){a=="__proto__"&&e?e(n,a,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[a]=s}return pC=t,pC}var gC,XI;function Fv(){if(XI)return gC;XI=1;var e=Dv(),t=Hu(),n=Object.prototype,a=n.hasOwnProperty;function s(o,r,c){var l=o[r];(!(a.call(o,r)&&t(l,c))||c===void 0&&!(r in o))&&e(o,r,c)}return gC=s,gC}var mC,QI;function Hg(){if(QI)return mC;QI=1;var e=Fv(),t=Dv();function n(a,s,o,r){var c=!o;o||(o={});for(var l=-1,u=s.length;++l<u;){var h=s[l],p=r?r(o[h],a[h],h,o,a):void 0;p===void 0&&(p=a[h]),c?t(o,h,p):e(o,h,p)}return o}return mC=n,mC}var fC,eD;function xEe(){if(eD)return fC;eD=1;function e(t,n){for(var a=-1,s=Array(t);++a<t;)s[a]=n(a);return s}return fC=e,fC}var bC,tD;function Co(){if(tD)return bC;tD=1;function e(t){return t!=null&&typeof t=="object"}return bC=e,bC}var kC,nD;function CEe(){if(nD)return kC;nD=1;var e=Vl(),t=Co(),n="[object Arguments]";function a(s){return t(s)&&e(s)==n}return kC=a,kC}var vC,aD;function Gg(){if(aD)return vC;aD=1;var e=CEe(),t=Co(),n=Object.prototype,a=n.hasOwnProperty,s=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(r){return t(r)&&a.call(r,"callee")&&!s.call(r,"callee")};return vC=o,vC}var wC,sD;function Mn(){if(sD)return wC;sD=1;var e=Array.isArray;return wC=e,wC}var Cp={exports:{}},yC,iD;function SEe(){if(iD)return yC;iD=1;function e(){return!1}return yC=e,yC}Cp.exports;var oD;function Vu(){return oD||(oD=1,(function(e,t){var n=qi(),a=SEe(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,r=o&&o.exports===s,c=r?n.Buffer:void 0,l=c?c.isBuffer:void 0,u=l||a;e.exports=u})(Cp,Cp.exports)),Cp.exports}var xC,rD;function Bv(){if(rD)return xC;rD=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(a,s){var o=typeof a;return s=s??e,!!s&&(o=="number"||o!="symbol"&&t.test(a))&&a>-1&&a%1==0&&a<s}return xC=n,xC}var CC,cD;function tz(){if(cD)return CC;cD=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return CC=t,CC}var SC,lD;function TEe(){if(lD)return SC;lD=1;var e=Vl(),t=tz(),n=Co(),a="[object Arguments]",s="[object Array]",o="[object Boolean]",r="[object Date]",c="[object Error]",l="[object Function]",u="[object Map]",h="[object Number]",p="[object Object]",f="[object RegExp]",b="[object Set]",v="[object String]",w="[object WeakMap]",T="[object ArrayBuffer]",y="[object DataView]",x="[object Float32Array]",C="[object Float64Array]",A="[object Int8Array]",E="[object Int16Array]",R="[object Int32Array]",z="[object Uint8Array]",I="[object Uint8ClampedArray]",_="[object Uint16Array]",D="[object Uint32Array]",L={};L[x]=L[C]=L[A]=L[E]=L[R]=L[z]=L[I]=L[_]=L[D]=!0,L[a]=L[s]=L[T]=L[o]=L[y]=L[r]=L[c]=L[l]=L[u]=L[h]=L[p]=L[f]=L[b]=L[v]=L[w]=!1;function P(O){return n(O)&&t(O.length)&&!!L[e(O)]}return SC=P,SC}var TC,dD;function Uv(){if(dD)return TC;dD=1;function e(t){return function(n){return t(n)}}return TC=e,TC}var Sp={exports:{}};Sp.exports;var uD;function nz(){return uD||(uD=1,(function(e,t){var n=$K(),a=t&&!t.nodeType&&t,s=a&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===a,r=o&&n.process,c=(function(){try{var l=s&&s.require&&s.require("util").types;return l||r&&r.binding&&r.binding("util")}catch{}})();e.exports=c})(Sp,Sp.exports)),Sp.exports}var NC,hD;function Vg(){if(hD)return NC;hD=1;var e=TEe(),t=Uv(),n=nz(),a=n&&n.isTypedArray,s=a?t(a):e;return NC=s,NC}var AC,pD;function ZK(){if(pD)return AC;pD=1;var e=xEe(),t=Gg(),n=Mn(),a=Vu(),s=Bv(),o=Vg(),r=Object.prototype,c=r.hasOwnProperty;function l(u,h){var p=n(u),f=!p&&t(u),b=!p&&!f&&a(u),v=!p&&!f&&!b&&o(u),w=p||f||b||v,T=w?e(u.length,String):[],y=T.length;for(var x in u)(h||c.call(u,x))&&!(w&&(x=="length"||b&&(x=="offset"||x=="parent")||v&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||s(x,y)))&&T.push(x);return T}return AC=l,AC}var jC,gD;function Wv(){if(gD)return jC;gD=1;var e=Object.prototype;function t(n){var a=n&&n.constructor,s=typeof a=="function"&&a.prototype||e;return n===s}return jC=t,jC}var EC,mD;function XK(){if(mD)return EC;mD=1;function e(t,n){return function(a){return t(n(a))}}return EC=e,EC}var RC,fD;function NEe(){if(fD)return RC;fD=1;var e=XK(),t=e(Object.keys,Object);return RC=t,RC}var zC,bD;function az(){if(bD)return zC;bD=1;var e=Wv(),t=NEe(),n=Object.prototype,a=n.hasOwnProperty;function s(o){if(!e(o))return t(o);var r=[];for(var c in Object(o))a.call(o,c)&&c!="constructor"&&r.push(c);return r}return zC=s,zC}var qC,kD;function ur(){if(kD)return qC;kD=1;var e=Wg(),t=tz();function n(a){return a!=null&&t(a.length)&&!e(a)}return qC=n,qC}var _C,vD;function mc(){if(vD)return _C;vD=1;var e=ZK(),t=az(),n=ur();function a(s){return n(s)?e(s):t(s)}return _C=a,_C}var LC,wD;function AEe(){if(wD)return LC;wD=1;var e=Hg(),t=mc();function n(a,s){return a&&e(s,t(s),a)}return LC=n,LC}var PC,yD;function jEe(){if(yD)return PC;yD=1;function e(t){var n=[];if(t!=null)for(var a in Object(t))n.push(a);return n}return PC=e,PC}var OC,xD;function EEe(){if(xD)return OC;xD=1;var e=ei(),t=Wv(),n=jEe(),a=Object.prototype,s=a.hasOwnProperty;function o(r){if(!e(r))return n(r);var c=t(r),l=[];for(var u in r)u=="constructor"&&(c||!s.call(r,u))||l.push(u);return l}return OC=o,OC}var MC,CD;function $l(){if(CD)return MC;CD=1;var e=ZK(),t=EEe(),n=ur();function a(s){return n(s)?e(s,!0):t(s)}return MC=a,MC}var IC,SD;function REe(){if(SD)return IC;SD=1;var e=Hg(),t=$l();function n(a,s){return a&&e(s,t(s),a)}return IC=n,IC}var Tp={exports:{}};Tp.exports;var TD;function QK(){return TD||(TD=1,(function(e,t){var n=qi(),a=t&&!t.nodeType&&t,s=a&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===a,r=o?n.Buffer:void 0,c=r?r.allocUnsafe:void 0;function l(u,h){if(h)return u.slice();var p=u.length,f=c?c(p):new u.constructor(p);return u.copy(f),f}e.exports=l})(Tp,Tp.exports)),Tp.exports}var DC,ND;function e$(){if(ND)return DC;ND=1;function e(t,n){var a=-1,s=t.length;for(n||(n=Array(s));++a<s;)n[a]=t[a];return n}return DC=e,DC}var FC,AD;function t$(){if(AD)return FC;AD=1;function e(t,n){for(var a=-1,s=t==null?0:t.length,o=0,r=[];++a<s;){var c=t[a];n(c,a,t)&&(r[o++]=c)}return r}return FC=e,FC}var BC,jD;function n$(){if(jD)return BC;jD=1;function e(){return[]}return BC=e,BC}var UC,ED;function sz(){if(ED)return UC;ED=1;var e=t$(),t=n$(),n=Object.prototype,a=n.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(r){return r==null?[]:(r=Object(r),e(s(r),function(c){return a.call(r,c)}))}:t;return UC=o,UC}var WC,RD;function zEe(){if(RD)return WC;RD=1;var e=Hg(),t=sz();function n(a,s){return e(a,t(a),s)}return WC=n,WC}var HC,zD;function iz(){if(zD)return HC;zD=1;function e(t,n){for(var a=-1,s=n.length,o=t.length;++a<s;)t[o+a]=n[a];return t}return HC=e,HC}var GC,qD;function Hv(){if(qD)return GC;qD=1;var e=XK(),t=e(Object.getPrototypeOf,Object);return GC=t,GC}var VC,_D;function a$(){if(_D)return VC;_D=1;var e=iz(),t=Hv(),n=sz(),a=n$(),s=Object.getOwnPropertySymbols,o=s?function(r){for(var c=[];r;)e(c,n(r)),r=t(r);return c}:a;return VC=o,VC}var KC,LD;function qEe(){if(LD)return KC;LD=1;var e=Hg(),t=a$();function n(a,s){return e(a,t(a),s)}return KC=n,KC}var $C,PD;function s$(){if(PD)return $C;PD=1;var e=iz(),t=Mn();function n(a,s,o){var r=s(a);return t(a)?r:e(r,o(a))}return $C=n,$C}var JC,OD;function i$(){if(OD)return JC;OD=1;var e=s$(),t=sz(),n=mc();function a(s){return e(s,n,t)}return JC=a,JC}var YC,MD;function _Ee(){if(MD)return YC;MD=1;var e=s$(),t=a$(),n=$l();function a(s){return e(s,n,t)}return YC=a,YC}var ZC,ID;function LEe(){if(ID)return ZC;ID=1;var e=Kl(),t=qi(),n=e(t,"DataView");return ZC=n,ZC}var XC,DD;function PEe(){if(DD)return XC;DD=1;var e=Kl(),t=qi(),n=e(t,"Promise");return XC=n,XC}var QC,FD;function o$(){if(FD)return QC;FD=1;var e=Kl(),t=qi(),n=e(t,"Set");return QC=n,QC}var eS,BD;function OEe(){if(BD)return eS;BD=1;var e=Kl(),t=qi(),n=e(t,"WeakMap");return eS=n,eS}var tS,UD;function Ku(){if(UD)return tS;UD=1;var e=LEe(),t=XR(),n=PEe(),a=o$(),s=OEe(),o=Vl(),r=JK(),c="[object Map]",l="[object Object]",u="[object Promise]",h="[object Set]",p="[object WeakMap]",f="[object DataView]",b=r(e),v=r(t),w=r(n),T=r(a),y=r(s),x=o;return(e&&x(new e(new ArrayBuffer(1)))!=f||t&&x(new t)!=c||n&&x(n.resolve())!=u||a&&x(new a)!=h||s&&x(new s)!=p)&&(x=function(C){var A=o(C),E=A==l?C.constructor:void 0,R=E?r(E):"";if(R)switch(R){case b:return f;case v:return c;case w:return u;case T:return h;case y:return p}return A}),tS=x,tS}var nS,WD;function MEe(){if(WD)return nS;WD=1;var e=Object.prototype,t=e.hasOwnProperty;function n(a){var s=a.length,o=new a.constructor(s);return s&&typeof a[0]=="string"&&t.call(a,"index")&&(o.index=a.index,o.input=a.input),o}return nS=n,nS}var aS,HD;function r$(){if(HD)return aS;HD=1;var e=qi(),t=e.Uint8Array;return aS=t,aS}var sS,GD;function oz(){if(GD)return sS;GD=1;var e=r$();function t(n){var a=new n.constructor(n.byteLength);return new e(a).set(new e(n)),a}return sS=t,sS}var iS,VD;function IEe(){if(VD)return iS;VD=1;var e=oz();function t(n,a){var s=a?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return iS=t,iS}var oS,KD;function DEe(){if(KD)return oS;KD=1;var e=/\w*$/;function t(n){var a=new n.constructor(n.source,e.exec(n));return a.lastIndex=n.lastIndex,a}return oS=t,oS}var rS,$D;function FEe(){if($D)return rS;$D=1;var e=Gu(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function a(s){return n?Object(n.call(s)):{}}return rS=a,rS}var cS,JD;function c$(){if(JD)return cS;JD=1;var e=oz();function t(n,a){var s=a?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return cS=t,cS}var lS,YD;function BEe(){if(YD)return lS;YD=1;var e=oz(),t=IEe(),n=DEe(),a=FEe(),s=c$(),o="[object Boolean]",r="[object Date]",c="[object Map]",l="[object Number]",u="[object RegExp]",h="[object Set]",p="[object String]",f="[object Symbol]",b="[object ArrayBuffer]",v="[object DataView]",w="[object Float32Array]",T="[object Float64Array]",y="[object Int8Array]",x="[object Int16Array]",C="[object Int32Array]",A="[object Uint8Array]",E="[object Uint8ClampedArray]",R="[object Uint16Array]",z="[object Uint32Array]";function I(_,D,L){var P=_.constructor;switch(D){case b:return e(_);case o:case r:return new P(+_);case v:return t(_,L);case w:case T:case y:case x:case C:case A:case E:case R:case z:return s(_,L);case c:return new P;case l:case p:return new P(_);case u:return n(_);case h:return new P;case f:return a(_)}}return lS=I,lS}var dS,ZD;function l$(){if(ZD)return dS;ZD=1;var e=ei(),t=Object.create,n=(function(){function a(){}return function(s){if(!e(s))return{};if(t)return t(s);a.prototype=s;var o=new a;return a.prototype=void 0,o}})();return dS=n,dS}var uS,XD;function d$(){if(XD)return uS;XD=1;var e=l$(),t=Hv(),n=Wv();function a(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return uS=a,uS}var hS,QD;function UEe(){if(QD)return hS;QD=1;var e=Ku(),t=Co(),n="[object Map]";function a(s){return t(s)&&e(s)==n}return hS=a,hS}var pS,eF;function WEe(){if(eF)return pS;eF=1;var e=UEe(),t=Uv(),n=nz(),a=n&&n.isMap,s=a?t(a):e;return pS=s,pS}var gS,tF;function HEe(){if(tF)return gS;tF=1;var e=Ku(),t=Co(),n="[object Set]";function a(s){return t(s)&&e(s)==n}return gS=a,gS}var mS,nF;function GEe(){if(nF)return mS;nF=1;var e=HEe(),t=Uv(),n=nz(),a=n&&n.isSet,s=a?t(a):e;return mS=s,mS}var fS,aF;function u$(){if(aF)return fS;aF=1;var e=Iv(),t=ez(),n=Fv(),a=AEe(),s=REe(),o=QK(),r=e$(),c=zEe(),l=qEe(),u=i$(),h=_Ee(),p=Ku(),f=MEe(),b=BEe(),v=d$(),w=Mn(),T=Vu(),y=WEe(),x=ei(),C=GEe(),A=mc(),E=$l(),R=1,z=2,I=4,_="[object Arguments]",D="[object Array]",L="[object Boolean]",P="[object Date]",O="[object Error]",j="[object Function]",M="[object GeneratorFunction]",F="[object Map]",U="[object Number]",H="[object Object]",$="[object RegExp]",Y="[object Set]",W="[object String]",G="[object Symbol]",Q="[object WeakMap]",J="[object ArrayBuffer]",X="[object DataView]",te="[object Float32Array]",K="[object Float64Array]",V="[object Int8Array]",ee="[object Int16Array]",de="[object Int32Array]",he="[object Uint8Array]",me="[object Uint8ClampedArray]",be="[object Uint16Array]",ie="[object Uint32Array]",ne={};ne[_]=ne[D]=ne[J]=ne[X]=ne[L]=ne[P]=ne[te]=ne[K]=ne[V]=ne[ee]=ne[de]=ne[F]=ne[U]=ne[H]=ne[$]=ne[Y]=ne[W]=ne[G]=ne[he]=ne[me]=ne[be]=ne[ie]=!0,ne[O]=ne[j]=ne[Q]=!1;function ke(Se,ve,xe,Ee,Ge,Qe){var Je,He=ve&R,_e=ve&z,le=ve&I;if(xe&&(Je=Ge?xe(Se,Ee,Ge,Qe):xe(Se)),Je!==void 0)return Je;if(!x(Se))return Se;var Re=w(Se);if(Re){if(Je=f(Se),!He)return r(Se,Je)}else{var ge=p(Se),Pe=ge==j||ge==M;if(T(Se))return o(Se,He);if(ge==H||ge==_||Pe&&!Ge){if(Je=_e||Pe?{}:v(Se),!He)return _e?l(Se,s(Je,Se)):c(Se,a(Je,Se))}else{if(!ne[ge])return Ge?Se:{};Je=b(Se,ge,He)}}Qe||(Qe=new e);var Fe=Qe.get(Se);if(Fe)return Fe;Qe.set(Se,Je),C(Se)?Se.forEach(function(ce){Je.add(ke(ce,ve,xe,ce,Se,Qe))}):y(Se)&&Se.forEach(function(ce,Ce){Je.set(Ce,ke(ce,ve,xe,Ce,Se,Qe))});var Ve=le?_e?h:u:_e?E:A,ot=Re?void 0:Ve(Se);return t(ot||Se,function(ce,Ce){ot&&(Ce=ce,ce=Se[Ce]),n(Je,Ce,ke(ce,ve,xe,Ce,Se,Qe))}),Je}return fS=ke,fS}var bS,sF;function VEe(){if(sF)return bS;sF=1;var e=u$(),t=4;function n(a){return e(a,t)}return bS=n,bS}var kS,iF;function rz(){if(iF)return kS;iF=1;function e(t){return function(){return t}}return kS=e,kS}var vS,oF;function KEe(){if(oF)return vS;oF=1;function e(t){return function(n,a,s){for(var o=-1,r=Object(n),c=s(n),l=c.length;l--;){var u=c[t?l:++o];if(a(r[u],u,r)===!1)break}return n}}return vS=e,vS}var wS,rF;function cz(){if(rF)return wS;rF=1;var e=KEe(),t=e();return wS=t,wS}var yS,cF;function lz(){if(cF)return yS;cF=1;var e=cz(),t=mc();function n(a,s){return a&&e(a,s,t)}return yS=n,yS}var xS,lF;function $Ee(){if(lF)return xS;lF=1;var e=ur();function t(n,a){return function(s,o){if(s==null)return s;if(!e(s))return n(s,o);for(var r=s.length,c=a?r:-1,l=Object(s);(a?c--:++c<r)&&o(l[c],c,l)!==!1;);return s}}return xS=t,xS}var CS,dF;function Gv(){if(dF)return CS;dF=1;var e=lz(),t=$Ee(),n=t(e);return CS=n,CS}var SS,uF;function Jl(){if(uF)return SS;uF=1;function e(t){return t}return SS=e,SS}var TS,hF;function h$(){if(hF)return TS;hF=1;var e=Jl();function t(n){return typeof n=="function"?n:e}return TS=t,TS}var NS,pF;function p$(){if(pF)return NS;pF=1;var e=ez(),t=Gv(),n=h$(),a=Mn();function s(o,r){var c=a(o)?e:t;return c(o,n(r))}return NS=s,NS}var AS,gF;function g$(){return gF||(gF=1,AS=p$()),AS}var jS,mF;function JEe(){if(mF)return jS;mF=1;var e=Gv();function t(n,a){var s=[];return e(n,function(o,r,c){a(o,r,c)&&s.push(o)}),s}return jS=t,jS}var ES,fF;function YEe(){if(fF)return ES;fF=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return ES=t,ES}var RS,bF;function ZEe(){if(bF)return RS;bF=1;function e(t){return this.__data__.has(t)}return RS=e,RS}var zS,kF;function m$(){if(kF)return zS;kF=1;var e=QR(),t=YEe(),n=ZEe();function a(s){var o=-1,r=s==null?0:s.length;for(this.__data__=new e;++o<r;)this.add(s[o])}return a.prototype.add=a.prototype.push=t,a.prototype.has=n,zS=a,zS}var qS,vF;function XEe(){if(vF)return qS;vF=1;function e(t,n){for(var a=-1,s=t==null?0:t.length;++a<s;)if(n(t[a],a,t))return!0;return!1}return qS=e,qS}var _S,wF;function f$(){if(wF)return _S;wF=1;function e(t,n){return t.has(n)}return _S=e,_S}var LS,yF;function b$(){if(yF)return LS;yF=1;var e=m$(),t=XEe(),n=f$(),a=1,s=2;function o(r,c,l,u,h,p){var f=l&a,b=r.length,v=c.length;if(b!=v&&!(f&&v>b))return!1;var w=p.get(r),T=p.get(c);if(w&&T)return w==c&&T==r;var y=-1,x=!0,C=l&s?new e:void 0;for(p.set(r,c),p.set(c,r);++y<b;){var A=r[y],E=c[y];if(u)var R=f?u(E,A,y,c,r,p):u(A,E,y,r,c,p);if(R!==void 0){if(R)continue;x=!1;break}if(C){if(!t(c,function(z,I){if(!n(C,I)&&(A===z||h(A,z,l,u,p)))return C.push(I)})){x=!1;break}}else if(!(A===E||h(A,E,l,u,p))){x=!1;break}}return p.delete(r),p.delete(c),x}return LS=o,LS}var PS,xF;function QEe(){if(xF)return PS;xF=1;function e(t){var n=-1,a=Array(t.size);return t.forEach(function(s,o){a[++n]=[o,s]}),a}return PS=e,PS}var OS,CF;function dz(){if(CF)return OS;CF=1;function e(t){var n=-1,a=Array(t.size);return t.forEach(function(s){a[++n]=s}),a}return OS=e,OS}var MS,SF;function e1e(){if(SF)return MS;SF=1;var e=Gu(),t=r$(),n=Hu(),a=b$(),s=QEe(),o=dz(),r=1,c=2,l="[object Boolean]",u="[object Date]",h="[object Error]",p="[object Map]",f="[object Number]",b="[object RegExp]",v="[object Set]",w="[object String]",T="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",C=e?e.prototype:void 0,A=C?C.valueOf:void 0;function E(R,z,I,_,D,L,P){switch(I){case x:if(R.byteLength!=z.byteLength||R.byteOffset!=z.byteOffset)return!1;R=R.buffer,z=z.buffer;case y:return!(R.byteLength!=z.byteLength||!L(new t(R),new t(z)));case l:case u:case f:return n(+R,+z);case h:return R.name==z.name&&R.message==z.message;case b:case w:return R==z+"";case p:var O=s;case v:var j=_&r;if(O||(O=o),R.size!=z.size&&!j)return!1;var M=P.get(R);if(M)return M==z;_|=c,P.set(R,z);var F=a(O(R),O(z),_,D,L,P);return P.delete(R),F;case T:if(A)return A.call(R)==A.call(z)}return!1}return MS=E,MS}var IS,TF;function t1e(){if(TF)return IS;TF=1;var e=i$(),t=1,n=Object.prototype,a=n.hasOwnProperty;function s(o,r,c,l,u,h){var p=c&t,f=e(o),b=f.length,v=e(r),w=v.length;if(b!=w&&!p)return!1;for(var T=b;T--;){var y=f[T];if(!(p?y in r:a.call(r,y)))return!1}var x=h.get(o),C=h.get(r);if(x&&C)return x==r&&C==o;var A=!0;h.set(o,r),h.set(r,o);for(var E=p;++T<b;){y=f[T];var R=o[y],z=r[y];if(l)var I=p?l(z,R,y,r,o,h):l(R,z,y,o,r,h);if(!(I===void 0?R===z||u(R,z,c,l,h):I)){A=!1;break}E||(E=y=="constructor")}if(A&&!E){var _=o.constructor,D=r.constructor;_!=D&&"constructor"in o&&"constructor"in r&&!(typeof _=="function"&&_ instanceof _&&typeof D=="function"&&D instanceof D)&&(A=!1)}return h.delete(o),h.delete(r),A}return IS=s,IS}var DS,NF;function n1e(){if(NF)return DS;NF=1;var e=Iv(),t=b$(),n=e1e(),a=t1e(),s=Ku(),o=Mn(),r=Vu(),c=Vg(),l=1,u="[object Arguments]",h="[object Array]",p="[object Object]",f=Object.prototype,b=f.hasOwnProperty;function v(w,T,y,x,C,A){var E=o(w),R=o(T),z=E?h:s(w),I=R?h:s(T);z=z==u?p:z,I=I==u?p:I;var _=z==p,D=I==p,L=z==I;if(L&&r(w)){if(!r(T))return!1;E=!0,_=!1}if(L&&!_)return A||(A=new e),E||c(w)?t(w,T,y,x,C,A):n(w,T,z,y,x,C,A);if(!(y&l)){var P=_&&b.call(w,"__wrapped__"),O=D&&b.call(T,"__wrapped__");if(P||O){var j=P?w.value():w,M=O?T.value():T;return A||(A=new e),C(j,M,y,x,A)}}return L?(A||(A=new e),a(w,T,y,x,C,A)):!1}return DS=v,DS}var FS,AF;function k$(){if(AF)return FS;AF=1;var e=n1e(),t=Co();function n(a,s,o,r,c){return a===s?!0:a==null||s==null||!t(a)&&!t(s)?a!==a&&s!==s:e(a,s,o,r,n,c)}return FS=n,FS}var BS,jF;function a1e(){if(jF)return BS;jF=1;var e=Iv(),t=k$(),n=1,a=2;function s(o,r,c,l){var u=c.length,h=u,p=!l;if(o==null)return!h;for(o=Object(o);u--;){var f=c[u];if(p&&f[2]?f[1]!==o[f[0]]:!(f[0]in o))return!1}for(;++u<h;){f=c[u];var b=f[0],v=o[b],w=f[1];if(p&&f[2]){if(v===void 0&&!(b in o))return!1}else{var T=new e;if(l)var y=l(v,w,b,o,r,T);if(!(y===void 0?t(w,v,n|a,l,T):y))return!1}}return!0}return BS=s,BS}var US,EF;function v$(){if(EF)return US;EF=1;var e=ei();function t(n){return n===n&&!e(n)}return US=t,US}var WS,RF;function s1e(){if(RF)return WS;RF=1;var e=v$(),t=mc();function n(a){for(var s=t(a),o=s.length;o--;){var r=s[o],c=a[r];s[o]=[r,c,e(c)]}return s}return WS=n,WS}var HS,zF;function w$(){if(zF)return HS;zF=1;function e(t,n){return function(a){return a==null?!1:a[t]===n&&(n!==void 0||t in Object(a))}}return HS=e,HS}var GS,qF;function i1e(){if(qF)return GS;qF=1;var e=a1e(),t=s1e(),n=w$();function a(s){var o=t(s);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(r){return r===s||e(r,s,o)}}return GS=a,GS}var VS,_F;function $u(){if(_F)return VS;_F=1;var e=Vl(),t=Co(),n="[object Symbol]";function a(s){return typeof s=="symbol"||t(s)&&e(s)==n}return VS=a,VS}var KS,LF;function uz(){if(LF)return KS;LF=1;var e=Mn(),t=$u(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function s(o,r){if(e(o))return!1;var c=typeof o;return c=="number"||c=="symbol"||c=="boolean"||o==null||t(o)?!0:a.test(o)||!n.test(o)||r!=null&&o in Object(r)}return KS=s,KS}var $S,PF;function o1e(){if(PF)return $S;PF=1;var e=QR(),t="Expected a function";function n(a,s){if(typeof a!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var o=function(){var r=arguments,c=s?s.apply(this,r):r[0],l=o.cache;if(l.has(c))return l.get(c);var u=a.apply(this,r);return o.cache=l.set(c,u)||l,u};return o.cache=new(n.Cache||e),o}return n.Cache=e,$S=n,$S}var JS,OF;function r1e(){if(OF)return JS;OF=1;var e=o1e(),t=500;function n(a){var s=e(a,function(r){return o.size===t&&o.clear(),r}),o=s.cache;return s}return JS=n,JS}var YS,MF;function c1e(){if(MF)return YS;MF=1;var e=r1e(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,a=e(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(t,function(r,c,l,u){o.push(l?u.replace(n,"$1"):c||r)}),o});return YS=a,YS}var ZS,IF;function Vv(){if(IF)return ZS;IF=1;function e(t,n){for(var a=-1,s=t==null?0:t.length,o=Array(s);++a<s;)o[a]=n(t[a],a,t);return o}return ZS=e,ZS}var XS,DF;function l1e(){if(DF)return XS;DF=1;var e=Gu(),t=Vv(),n=Mn(),a=$u(),s=e?e.prototype:void 0,o=s?s.toString:void 0;function r(c){if(typeof c=="string")return c;if(n(c))return t(c,r)+"";if(a(c))return o?o.call(c):"";var l=c+"";return l=="0"&&1/c==-1/0?"-0":l}return XS=r,XS}var QS,FF;function y$(){if(FF)return QS;FF=1;var e=l1e();function t(n){return n==null?"":e(n)}return QS=t,QS}var eT,BF;function Kv(){if(BF)return eT;BF=1;var e=Mn(),t=uz(),n=c1e(),a=y$();function s(o,r){return e(o)?o:t(o,r)?[o]:n(a(o))}return eT=s,eT}var tT,UF;function Kg(){if(UF)return tT;UF=1;var e=$u();function t(n){if(typeof n=="string"||e(n))return n;var a=n+"";return a=="0"&&1/n==-1/0?"-0":a}return tT=t,tT}var nT,WF;function $v(){if(WF)return nT;WF=1;var e=Kv(),t=Kg();function n(a,s){s=e(s,a);for(var o=0,r=s.length;a!=null&&o<r;)a=a[t(s[o++])];return o&&o==r?a:void 0}return nT=n,nT}var aT,HF;function d1e(){if(HF)return aT;HF=1;var e=$v();function t(n,a,s){var o=n==null?void 0:e(n,a);return o===void 0?s:o}return aT=t,aT}var sT,GF;function u1e(){if(GF)return sT;GF=1;function e(t,n){return t!=null&&n in Object(t)}return sT=e,sT}var iT,VF;function x$(){if(VF)return iT;VF=1;var e=Kv(),t=Gg(),n=Mn(),a=Bv(),s=tz(),o=Kg();function r(c,l,u){l=e(l,c);for(var h=-1,p=l.length,f=!1;++h<p;){var b=o(l[h]);if(!(f=c!=null&&u(c,b)))break;c=c[b]}return f||++h!=p?f:(p=c==null?0:c.length,!!p&&s(p)&&a(b,p)&&(n(c)||t(c)))}return iT=r,iT}var oT,KF;function C$(){if(KF)return oT;KF=1;var e=u1e(),t=x$();function n(a,s){return a!=null&&t(a,s,e)}return oT=n,oT}var rT,$F;function h1e(){if($F)return rT;$F=1;var e=k$(),t=d1e(),n=C$(),a=uz(),s=v$(),o=w$(),r=Kg(),c=1,l=2;function u(h,p){return a(h)&&s(p)?o(r(h),p):function(f){var b=t(f,h);return b===void 0&&b===p?n(f,h):e(p,b,c|l)}}return rT=u,rT}var cT,JF;function S$(){if(JF)return cT;JF=1;function e(t){return function(n){return n==null?void 0:n[t]}}return cT=e,cT}var lT,YF;function p1e(){if(YF)return lT;YF=1;var e=$v();function t(n){return function(a){return e(a,n)}}return lT=t,lT}var dT,ZF;function g1e(){if(ZF)return dT;ZF=1;var e=S$(),t=p1e(),n=uz(),a=Kg();function s(o){return n(o)?e(a(o)):t(o)}return dT=s,dT}var uT,XF;function hr(){if(XF)return uT;XF=1;var e=i1e(),t=h1e(),n=Jl(),a=Mn(),s=g1e();function o(r){return typeof r=="function"?r:r==null?n:typeof r=="object"?a(r)?t(r[0],r[1]):e(r):s(r)}return uT=o,uT}var hT,QF;function T$(){if(QF)return hT;QF=1;var e=t$(),t=JEe(),n=hr(),a=Mn();function s(o,r){var c=a(o)?e:t;return c(o,n(r,3))}return hT=s,hT}var pT,e2;function m1e(){if(e2)return pT;e2=1;var e=Object.prototype,t=e.hasOwnProperty;function n(a,s){return a!=null&&t.call(a,s)}return pT=n,pT}var gT,t2;function N$(){if(t2)return gT;t2=1;var e=m1e(),t=x$();function n(a,s){return a!=null&&t(a,s,e)}return gT=n,gT}var mT,n2;function f1e(){if(n2)return mT;n2=1;var e=az(),t=Ku(),n=Gg(),a=Mn(),s=ur(),o=Vu(),r=Wv(),c=Vg(),l="[object Map]",u="[object Set]",h=Object.prototype,p=h.hasOwnProperty;function f(b){if(b==null)return!0;if(s(b)&&(a(b)||typeof b=="string"||typeof b.splice=="function"||o(b)||c(b)||n(b)))return!b.length;var v=t(b);if(v==l||v==u)return!b.size;if(r(b))return!e(b).length;for(var w in b)if(p.call(b,w))return!1;return!0}return mT=f,mT}var fT,a2;function A$(){if(a2)return fT;a2=1;function e(t){return t===void 0}return fT=e,fT}var bT,s2;function j$(){if(s2)return bT;s2=1;var e=Gv(),t=ur();function n(a,s){var o=-1,r=t(a)?Array(a.length):[];return e(a,function(c,l,u){r[++o]=s(c,l,u)}),r}return bT=n,bT}var kT,i2;function E$(){if(i2)return kT;i2=1;var e=Vv(),t=hr(),n=j$(),a=Mn();function s(o,r){var c=a(o)?e:n;return c(o,t(r,3))}return kT=s,kT}var vT,o2;function b1e(){if(o2)return vT;o2=1;function e(t,n,a,s){var o=-1,r=t==null?0:t.length;for(s&&r&&(a=t[++o]);++o<r;)a=n(a,t[o],o,t);return a}return vT=e,vT}var wT,r2;function k1e(){if(r2)return wT;r2=1;function e(t,n,a,s,o){return o(t,function(r,c,l){a=s?(s=!1,r):n(a,r,c,l)}),a}return wT=e,wT}var yT,c2;function R$(){if(c2)return yT;c2=1;var e=b1e(),t=Gv(),n=hr(),a=k1e(),s=Mn();function o(r,c,l){var u=s(r)?e:a,h=arguments.length<3;return u(r,n(c,4),l,h,t)}return yT=o,yT}var xT,l2;function v1e(){if(l2)return xT;l2=1;var e=Vl(),t=Mn(),n=Co(),a="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==a}return xT=s,xT}var CT,d2;function w1e(){if(d2)return CT;d2=1;var e=S$(),t=e("length");return CT=t,CT}var ST,u2;function y1e(){if(u2)return ST;u2=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",a="\\u20d0-\\u20ff",s=t+n+a,o="\\ufe0e\\ufe0f",r="\\u200d",c=RegExp("["+r+e+s+o+"]");function l(u){return c.test(u)}return ST=l,ST}var TT,h2;function x1e(){if(h2)return TT;h2=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",a="\\u20d0-\\u20ff",s=t+n+a,o="\\ufe0e\\ufe0f",r="["+e+"]",c="["+s+"]",l="\\ud83c[\\udffb-\\udfff]",u="(?:"+c+"|"+l+")",h="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",b="\\u200d",v=u+"?",w="["+o+"]?",T="(?:"+b+"(?:"+[h,p,f].join("|")+")"+w+v+")*",y=w+v+T,x="(?:"+[h+c+"?",c,p,f,r].join("|")+")",C=RegExp(l+"(?="+l+")|"+x+y,"g");function A(E){for(var R=C.lastIndex=0;C.test(E);)++R;return R}return TT=A,TT}var NT,p2;function C1e(){if(p2)return NT;p2=1;var e=w1e(),t=y1e(),n=x1e();function a(s){return t(s)?n(s):e(s)}return NT=a,NT}var AT,g2;function S1e(){if(g2)return AT;g2=1;var e=az(),t=Ku(),n=ur(),a=v1e(),s=C1e(),o="[object Map]",r="[object Set]";function c(l){if(l==null)return 0;if(n(l))return a(l)?s(l):l.length;var u=t(l);return u==o||u==r?l.size:e(l).length}return AT=c,AT}var jT,m2;function T1e(){if(m2)return jT;m2=1;var e=ez(),t=l$(),n=lz(),a=hr(),s=Hv(),o=Mn(),r=Vu(),c=Wg(),l=ei(),u=Vg();function h(p,f,b){var v=o(p),w=v||r(p)||u(p);if(f=a(f,4),b==null){var T=p&&p.constructor;w?b=v?new T:[]:l(p)?b=c(T)?t(s(p)):{}:b={}}return(w?e:n)(p,function(y,x,C){return f(b,y,x,C)}),b}return jT=h,jT}var ET,f2;function N1e(){if(f2)return ET;f2=1;var e=Gu(),t=Gg(),n=Mn(),a=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(a&&o&&o[a])}return ET=s,ET}var RT,b2;function hz(){if(b2)return RT;b2=1;var e=iz(),t=N1e();function n(a,s,o,r,c){var l=-1,u=a.length;for(o||(o=t),c||(c=[]);++l<u;){var h=a[l];s>0&&o(h)?s>1?n(h,s-1,o,r,c):e(c,h):r||(c[c.length]=h)}return c}return RT=n,RT}var zT,k2;function A1e(){if(k2)return zT;k2=1;function e(t,n,a){switch(a.length){case 0:return t.call(n);case 1:return t.call(n,a[0]);case 2:return t.call(n,a[0],a[1]);case 3:return t.call(n,a[0],a[1],a[2])}return t.apply(n,a)}return zT=e,zT}var qT,v2;function z$(){if(v2)return qT;v2=1;var e=A1e(),t=Math.max;function n(a,s,o){return s=t(s===void 0?a.length-1:s,0),function(){for(var r=arguments,c=-1,l=t(r.length-s,0),u=Array(l);++c<l;)u[c]=r[s+c];c=-1;for(var h=Array(s+1);++c<s;)h[c]=r[c];return h[s]=o(u),e(a,this,h)}}return qT=n,qT}var _T,w2;function j1e(){if(w2)return _T;w2=1;var e=rz(),t=YK(),n=Jl(),a=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return _T=a,_T}var LT,y2;function E1e(){if(y2)return LT;y2=1;var e=800,t=16,n=Date.now;function a(s){var o=0,r=0;return function(){var c=n(),l=t-(c-r);if(r=c,l>0){if(++o>=e)return arguments[0]}else o=0;return s.apply(void 0,arguments)}}return LT=a,LT}var PT,x2;function q$(){if(x2)return PT;x2=1;var e=j1e(),t=E1e(),n=t(e);return PT=n,PT}var OT,C2;function Jv(){if(C2)return OT;C2=1;var e=Jl(),t=z$(),n=q$();function a(s,o){return n(t(s,o,e),s+"")}return OT=a,OT}var MT,S2;function _$(){if(S2)return MT;S2=1;function e(t,n,a,s){for(var o=t.length,r=a+(s?1:-1);s?r--:++r<o;)if(n(t[r],r,t))return r;return-1}return MT=e,MT}var IT,T2;function R1e(){if(T2)return IT;T2=1;function e(t){return t!==t}return IT=e,IT}var DT,N2;function z1e(){if(N2)return DT;N2=1;function e(t,n,a){for(var s=a-1,o=t.length;++s<o;)if(t[s]===n)return s;return-1}return DT=e,DT}var FT,A2;function q1e(){if(A2)return FT;A2=1;var e=_$(),t=R1e(),n=z1e();function a(s,o,r){return o===o?n(s,o,r):e(s,t,r)}return FT=a,FT}var BT,j2;function _1e(){if(j2)return BT;j2=1;var e=q1e();function t(n,a){var s=n==null?0:n.length;return!!s&&e(n,a,0)>-1}return BT=t,BT}var UT,E2;function L1e(){if(E2)return UT;E2=1;function e(t,n,a){for(var s=-1,o=t==null?0:t.length;++s<o;)if(a(n,t[s]))return!0;return!1}return UT=e,UT}var WT,R2;function P1e(){if(R2)return WT;R2=1;function e(){}return WT=e,WT}var HT,z2;function O1e(){if(z2)return HT;z2=1;var e=o$(),t=P1e(),n=dz(),a=1/0,s=e&&1/n(new e([,-0]))[1]==a?function(o){return new e(o)}:t;return HT=s,HT}var GT,q2;function M1e(){if(q2)return GT;q2=1;var e=m$(),t=_1e(),n=L1e(),a=f$(),s=O1e(),o=dz(),r=200;function c(l,u,h){var p=-1,f=t,b=l.length,v=!0,w=[],T=w;if(h)v=!1,f=n;else if(b>=r){var y=u?null:s(l);if(y)return o(y);v=!1,f=a,T=new e}else T=u?[]:w;e:for(;++p<b;){var x=l[p],C=u?u(x):x;if(x=h||x!==0?x:0,v&&C===C){for(var A=T.length;A--;)if(T[A]===C)continue e;u&&T.push(C),w.push(x)}else f(T,C,h)||(T!==w&&T.push(C),w.push(x))}return w}return GT=c,GT}var VT,_2;function L$(){if(_2)return VT;_2=1;var e=ur(),t=Co();function n(a){return t(a)&&e(a)}return VT=n,VT}var KT,L2;function I1e(){if(L2)return KT;L2=1;var e=hz(),t=Jv(),n=M1e(),a=L$(),s=t(function(o){return n(e(o,1,a,!0))});return KT=s,KT}var $T,P2;function D1e(){if(P2)return $T;P2=1;var e=Vv();function t(n,a){return e(a,function(s){return n[s]})}return $T=t,$T}var JT,O2;function P$(){if(O2)return JT;O2=1;var e=D1e(),t=mc();function n(a){return a==null?[]:e(a,t(a))}return JT=n,JT}var YT,M2;function ti(){if(M2)return YT;M2=1;var e;if(typeof ZR=="function")try{e={clone:VEe(),constant:rz(),each:g$(),filter:T$(),has:N$(),isArray:Mn(),isEmpty:f1e(),isFunction:Wg(),isUndefined:A$(),keys:mc(),map:E$(),reduce:R$(),size:S1e(),transform:T1e(),union:I1e(),values:P$()}}catch{}return e||(e=window._),YT=e,YT}var ZT,I2;function pz(){if(I2)return ZT;I2=1;var e=ti();ZT=s;var t="\0",n="\0",a="";function s(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(h){return this._label=h,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(p){return e.isEmpty(h._in[p])})},s.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(p){return e.isEmpty(h._out[p])})},s.prototype.setNodes=function(h,p){var f=arguments,b=this;return e.each(h,function(v){f.length>1?b.setNode(v,p):b.setNode(v)}),this},s.prototype.setNode=function(h,p){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=p),this):(this._nodes[h]=arguments.length>1?p:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=n,this._children[h]={},this._children[n][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},s.prototype.node=function(h){return this._nodes[h]},s.prototype.hasNode=function(h){return e.has(this._nodes,h)},s.prototype.removeNode=function(h){var p=this;if(e.has(this._nodes,h)){var f=function(b){p.removeEdge(p._edgeObjs[b])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(b){p.setParent(b)}),delete this._children[h]),e.each(e.keys(this._in[h]),f),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),f),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},s.prototype.setParent=function(h,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=n;else{p+="";for(var f=p;!e.isUndefined(f);f=this.parent(f))if(f===h)throw new Error("Setting "+p+" as parent of "+h+" would create a cycle");this.setNode(p)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=p,this._children[p][h]=!0,this},s.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},s.prototype.parent=function(h){if(this._isCompound){var p=this._parent[h];if(p!==n)return p}},s.prototype.children=function(h){if(e.isUndefined(h)&&(h=n),this._isCompound){var p=this._children[h];if(p)return e.keys(p)}else{if(h===n)return this.nodes();if(this.hasNode(h))return[]}},s.prototype.predecessors=function(h){var p=this._preds[h];if(p)return e.keys(p)},s.prototype.successors=function(h){var p=this._sucs[h];if(p)return e.keys(p)},s.prototype.neighbors=function(h){var p=this.predecessors(h);if(p)return e.union(p,this.successors(h))},s.prototype.isLeaf=function(h){var p;return this.isDirected()?p=this.successors(h):p=this.neighbors(h),p.length===0},s.prototype.filterNodes=function(h){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var f=this;e.each(this._nodes,function(w,T){h(T)&&p.setNode(T,w)}),e.each(this._edgeObjs,function(w){p.hasNode(w.v)&&p.hasNode(w.w)&&p.setEdge(w,f.edge(w))});var b={};function v(w){var T=f.parent(w);return T===void 0||p.hasNode(T)?(b[w]=T,T):T in b?b[T]:v(T)}return this._isCompound&&e.each(p.nodes(),function(w){p.setParent(w,v(w))}),p},s.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(h,p){var f=this,b=arguments;return e.reduce(h,function(v,w){return b.length>1?f.setEdge(v,w,p):f.setEdge(v,w),w}),this},s.prototype.setEdge=function(){var h,p,f,b,v=!1,w=arguments[0];typeof w=="object"&&w!==null&&"v"in w?(h=w.v,p=w.w,f=w.name,arguments.length===2&&(b=arguments[1],v=!0)):(h=w,p=arguments[1],f=arguments[3],arguments.length>2&&(b=arguments[2],v=!0)),h=""+h,p=""+p,e.isUndefined(f)||(f=""+f);var T=c(this._isDirected,h,p,f);if(e.has(this._edgeLabels,T))return v&&(this._edgeLabels[T]=b),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(p),this._edgeLabels[T]=v?b:this._defaultEdgeLabelFn(h,p,f);var y=l(this._isDirected,h,p,f);return h=y.v,p=y.w,Object.freeze(y),this._edgeObjs[T]=y,o(this._preds[p],h),o(this._sucs[h],p),this._in[p][T]=y,this._out[h][T]=y,this._edgeCount++,this},s.prototype.edge=function(h,p,f){var b=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,h,p,f);return this._edgeLabels[b]},s.prototype.hasEdge=function(h,p,f){var b=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,h,p,f);return e.has(this._edgeLabels,b)},s.prototype.removeEdge=function(h,p,f){var b=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,h,p,f),v=this._edgeObjs[b];return v&&(h=v.v,p=v.w,delete this._edgeLabels[b],delete this._edgeObjs[b],r(this._preds[p],h),r(this._sucs[h],p),delete this._in[p][b],delete this._out[h][b],this._edgeCount--),this},s.prototype.inEdges=function(h,p){var f=this._in[h];if(f){var b=e.values(f);return p?e.filter(b,function(v){return v.v===p}):b}},s.prototype.outEdges=function(h,p){var f=this._out[h];if(f){var b=e.values(f);return p?e.filter(b,function(v){return v.w===p}):b}},s.prototype.nodeEdges=function(h,p){var f=this.inEdges(h,p);if(f)return f.concat(this.outEdges(h,p))};function o(h,p){h[p]?h[p]++:h[p]=1}function r(h,p){--h[p]||delete h[p]}function c(h,p,f,b){var v=""+p,w=""+f;if(!h&&v>w){var T=v;v=w,w=T}return v+a+w+a+(e.isUndefined(b)?t:b)}function l(h,p,f,b){var v=""+p,w=""+f;if(!h&&v>w){var T=v;v=w,w=T}var y={v,w};return b&&(y.name=b),y}function u(h,p){return c(h,p.v,p.w,p.name)}return ZT}var XT,D2;function F1e(){return D2||(D2=1,XT="2.1.8"),XT}var QT,F2;function B1e(){return F2||(F2=1,QT={Graph:pz(),version:F1e()}),QT}var eN,B2;function U1e(){if(B2)return eN;B2=1;var e=ti(),t=pz();eN={write:n,read:o};function n(r){var c={options:{directed:r.isDirected(),multigraph:r.isMultigraph(),compound:r.isCompound()},nodes:a(r),edges:s(r)};return e.isUndefined(r.graph())||(c.value=e.clone(r.graph())),c}function a(r){return e.map(r.nodes(),function(c){var l=r.node(c),u=r.parent(c),h={v:c};return e.isUndefined(l)||(h.value=l),e.isUndefined(u)||(h.parent=u),h})}function s(r){return e.map(r.edges(),function(c){var l=r.edge(c),u={v:c.v,w:c.w};return e.isUndefined(c.name)||(u.name=c.name),e.isUndefined(l)||(u.value=l),u})}function o(r){var c=new t(r.options).setGraph(r.value);return e.each(r.nodes,function(l){c.setNode(l.v,l.value),l.parent&&c.setParent(l.v,l.parent)}),e.each(r.edges,function(l){c.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),c}return eN}var tN,U2;function W1e(){if(U2)return tN;U2=1;var e=ti();tN=t;function t(n){var a={},s=[],o;function r(c){e.has(a,c)||(a[c]=!0,o.push(c),e.each(n.successors(c),r),e.each(n.predecessors(c),r))}return e.each(n.nodes(),function(c){o=[],r(c),o.length&&s.push(o)}),s}return tN}var nN,W2;function O$(){if(W2)return nN;W2=1;var e=ti();nN=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 a=this._keyIndices[n];if(a!==void 0)return this._arr[a].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,a){var s=this._keyIndices;if(n=String(n),!e.has(s,n)){var o=this._arr,r=o.length;return s[n]=r,o.push({key:n,priority:a}),this._decrease(r),!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,a){var s=this._keyIndices[n];if(a>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[s].priority+" New: "+a);this._arr[s].priority=a,this._decrease(s)},t.prototype._heapify=function(n){var a=this._arr,s=2*n,o=s+1,r=n;s<a.length&&(r=a[s].priority<a[r].priority?s:r,o<a.length&&(r=a[o].priority<a[r].priority?o:r),r!==n&&(this._swap(n,r),this._heapify(r)))},t.prototype._decrease=function(n){for(var a=this._arr,s=a[n].priority,o;n!==0&&(o=n>>1,!(a[o].priority<s));)this._swap(n,o),n=o},t.prototype._swap=function(n,a){var s=this._arr,o=this._keyIndices,r=s[n],c=s[a];s[n]=c,s[a]=r,o[c.key]=n,o[r.key]=a},nN}var aN,H2;function M$(){if(H2)return aN;H2=1;var e=ti(),t=O$();aN=a;var n=e.constant(1);function a(o,r,c,l){return s(o,String(r),c||n,l||function(u){return o.outEdges(u)})}function s(o,r,c,l){var u={},h=new t,p,f,b=function(v){var w=v.v!==p?v.v:v.w,T=u[w],y=c(v),x=f.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+v+" Weight: "+y);x<T.distance&&(T.distance=x,T.predecessor=p,h.decrease(w,x))};for(o.nodes().forEach(function(v){var w=v===r?0:Number.POSITIVE_INFINITY;u[v]={distance:w},h.add(v,w)});h.size()>0&&(p=h.removeMin(),f=u[p],f.distance!==Number.POSITIVE_INFINITY);)l(p).forEach(b);return u}return aN}var sN,G2;function H1e(){if(G2)return sN;G2=1;var e=M$(),t=ti();sN=n;function n(a,s,o){return t.transform(a.nodes(),function(r,c){r[c]=e(a,c,s,o)},{})}return sN}var iN,V2;function I$(){if(V2)return iN;V2=1;var e=ti();iN=t;function t(n){var a=0,s=[],o={},r=[];function c(l){var u=o[l]={onStack:!0,lowlink:a,index:a++};if(s.push(l),n.successors(l).forEach(function(f){e.has(o,f)?o[f].onStack&&(u.lowlink=Math.min(u.lowlink,o[f].index)):(c(f),u.lowlink=Math.min(u.lowlink,o[f].lowlink))}),u.lowlink===u.index){var h=[],p;do p=s.pop(),o[p].onStack=!1,h.push(p);while(l!==p);r.push(h)}}return n.nodes().forEach(function(l){e.has(o,l)||c(l)}),r}return iN}var oN,K2;function G1e(){if(K2)return oN;K2=1;var e=ti(),t=I$();oN=n;function n(a){return e.filter(t(a),function(s){return s.length>1||s.length===1&&a.hasEdge(s[0],s[0])})}return oN}var rN,$2;function V1e(){if($2)return rN;$2=1;var e=ti();rN=n;var t=e.constant(1);function n(s,o,r){return a(s,o||t,r||function(c){return s.outEdges(c)})}function a(s,o,r){var c={},l=s.nodes();return l.forEach(function(u){c[u]={},c[u][u]={distance:0},l.forEach(function(h){u!==h&&(c[u][h]={distance:Number.POSITIVE_INFINITY})}),r(u).forEach(function(h){var p=h.v===u?h.w:h.v,f=o(h);c[u][p]={distance:f,predecessor:u}})}),l.forEach(function(u){var h=c[u];l.forEach(function(p){var f=c[p];l.forEach(function(b){var v=f[u],w=h[b],T=f[b],y=v.distance+w.distance;y<T.distance&&(T.distance=y,T.predecessor=w.predecessor)})})}),c}return rN}var cN,J2;function D$(){if(J2)return cN;J2=1;var e=ti();cN=t,t.CycleException=n;function t(a){var s={},o={},r=[];function c(l){if(e.has(o,l))throw new n;e.has(s,l)||(o[l]=!0,s[l]=!0,e.each(a.predecessors(l),c),delete o[l],r.push(l))}if(e.each(a.sinks(),c),e.size(s)!==a.nodeCount())throw new n;return r}function n(){}return n.prototype=new Error,cN}var lN,Y2;function K1e(){if(Y2)return lN;Y2=1;var e=D$();lN=t;function t(n){try{e(n)}catch(a){if(a instanceof e.CycleException)return!1;throw a}return!0}return lN}var dN,Z2;function F$(){if(Z2)return dN;Z2=1;var e=ti();dN=t;function t(a,s,o){e.isArray(s)||(s=[s]);var r=(a.isDirected()?a.successors:a.neighbors).bind(a),c=[],l={};return e.each(s,function(u){if(!a.hasNode(u))throw new Error("Graph does not have node: "+u);n(a,u,o==="post",l,r,c)}),c}function n(a,s,o,r,c,l){e.has(r,s)||(r[s]=!0,o||l.push(s),e.each(c(s),function(u){n(a,u,o,r,c,l)}),o&&l.push(s))}return dN}var uN,X2;function $1e(){if(X2)return uN;X2=1;var e=F$();uN=t;function t(n,a){return e(n,a,"post")}return uN}var hN,Q2;function J1e(){if(Q2)return hN;Q2=1;var e=F$();hN=t;function t(n,a){return e(n,a,"pre")}return hN}var pN,eB;function Y1e(){if(eB)return pN;eB=1;var e=ti(),t=pz(),n=O$();pN=a;function a(s,o){var r=new t,c={},l=new n,u;function h(f){var b=f.v===u?f.w:f.v,v=l.priority(b);if(v!==void 0){var w=o(f);w<v&&(c[b]=u,l.decrease(b,w))}}if(s.nodeCount()===0)return r;e.each(s.nodes(),function(f){l.add(f,Number.POSITIVE_INFINITY),r.setNode(f)}),l.decrease(s.nodes()[0],0);for(var p=!1;l.size()>0;){if(u=l.removeMin(),e.has(c,u))r.setEdge(u,c[u]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(u).forEach(h)}return r}return pN}var gN,tB;function Z1e(){return tB||(tB=1,gN={components:W1e(),dijkstra:M$(),dijkstraAll:H1e(),findCycles:G1e(),floydWarshall:V1e(),isAcyclic:K1e(),postorder:$1e(),preorder:J1e(),prim:Y1e(),tarjan:I$(),topsort:D$()}),gN}var mN,nB;function X1e(){if(nB)return mN;nB=1;var e=B1e();return mN={Graph:e.Graph,json:U1e(),alg:Z1e(),version:e.version},mN}var fN,aB;function Ei(){if(aB)return fN;aB=1;var e;if(typeof ZR=="function")try{e=X1e()}catch{}return e||(e=window.graphlib),fN=e,fN}var bN,sB;function Q1e(){if(sB)return bN;sB=1;var e=u$(),t=1,n=4;function a(s){return e(s,t|n)}return bN=a,bN}var kN,iB;function Yv(){if(iB)return kN;iB=1;var e=Hu(),t=ur(),n=Bv(),a=ei();function s(o,r,c){if(!a(c))return!1;var l=typeof r;return(l=="number"?t(c)&&n(r,c.length):l=="string"&&r in c)?e(c[r],o):!1}return kN=s,kN}var vN,oB;function eRe(){if(oB)return vN;oB=1;var e=Jv(),t=Hu(),n=Yv(),a=$l(),s=Object.prototype,o=s.hasOwnProperty,r=e(function(c,l){c=Object(c);var u=-1,h=l.length,p=h>2?l[2]:void 0;for(p&&n(l[0],l[1],p)&&(h=1);++u<h;)for(var f=l[u],b=a(f),v=-1,w=b.length;++v<w;){var T=b[v],y=c[T];(y===void 0||t(y,s[T])&&!o.call(c,T))&&(c[T]=f[T])}return c});return vN=r,vN}var wN,rB;function tRe(){if(rB)return wN;rB=1;var e=hr(),t=ur(),n=mc();function a(s){return function(o,r,c){var l=Object(o);if(!t(o)){var u=e(r,3);o=n(o),r=function(p){return u(l[p],p,l)}}var h=s(o,r,c);return h>-1?l[u?o[h]:h]:void 0}}return wN=a,wN}var yN,cB;function nRe(){if(cB)return yN;cB=1;var e=/\s/;function t(n){for(var a=n.length;a--&&e.test(n.charAt(a)););return a}return yN=t,yN}var xN,lB;function aRe(){if(lB)return xN;lB=1;var e=nRe(),t=/^\s+/;function n(a){return a&&a.slice(0,e(a)+1).replace(t,"")}return xN=n,xN}var CN,dB;function sRe(){if(dB)return CN;dB=1;var e=aRe(),t=ei(),n=$u(),a=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,r=/^0o[0-7]+$/i,c=parseInt;function l(u){if(typeof u=="number")return u;if(n(u))return a;if(t(u)){var h=typeof u.valueOf=="function"?u.valueOf():u;u=t(h)?h+"":h}if(typeof u!="string")return u===0?u:+u;u=e(u);var p=o.test(u);return p||r.test(u)?c(u.slice(2),p?2:8):s.test(u)?a:+u}return CN=l,CN}var SN,uB;function B$(){if(uB)return SN;uB=1;var e=sRe(),t=1/0,n=17976931348623157e292;function a(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var o=s<0?-1:1;return o*n}return s===s?s:0}return SN=a,SN}var TN,hB;function iRe(){if(hB)return TN;hB=1;var e=B$();function t(n){var a=e(n),s=a%1;return a===a?s?a-s:a:0}return TN=t,TN}var NN,pB;function oRe(){if(pB)return NN;pB=1;var e=_$(),t=hr(),n=iRe(),a=Math.max;function s(o,r,c){var l=o==null?0:o.length;if(!l)return-1;var u=c==null?0:n(c);return u<0&&(u=a(l+u,0)),e(o,t(r,3),u)}return NN=s,NN}var AN,gB;function rRe(){if(gB)return AN;gB=1;var e=tRe(),t=oRe(),n=e(t);return AN=n,AN}var jN,mB;function U$(){if(mB)return jN;mB=1;var e=hz();function t(n){var a=n==null?0:n.length;return a?e(n,1):[]}return jN=t,jN}var EN,fB;function cRe(){if(fB)return EN;fB=1;var e=cz(),t=h$(),n=$l();function a(s,o){return s==null?s:e(s,t(o),n)}return EN=a,EN}var RN,bB;function lRe(){if(bB)return RN;bB=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return RN=e,RN}var zN,kB;function dRe(){if(kB)return zN;kB=1;var e=Dv(),t=lz(),n=hr();function a(s,o){var r={};return o=n(o,3),t(s,function(c,l,u){e(r,l,o(c,l,u))}),r}return zN=a,zN}var qN,vB;function gz(){if(vB)return qN;vB=1;var e=$u();function t(n,a,s){for(var o=-1,r=n.length;++o<r;){var c=n[o],l=a(c);if(l!=null&&(u===void 0?l===l&&!e(l):s(l,u)))var u=l,h=c}return h}return qN=t,qN}var _N,wB;function uRe(){if(wB)return _N;wB=1;function e(t,n){return t>n}return _N=e,_N}var LN,yB;function hRe(){if(yB)return LN;yB=1;var e=gz(),t=uRe(),n=Jl();function a(s){return s&&s.length?e(s,n,t):void 0}return LN=a,LN}var PN,xB;function W$(){if(xB)return PN;xB=1;var e=Dv(),t=Hu();function n(a,s,o){(o!==void 0&&!t(a[s],o)||o===void 0&&!(s in a))&&e(a,s,o)}return PN=n,PN}var ON,CB;function pRe(){if(CB)return ON;CB=1;var e=Vl(),t=Hv(),n=Co(),a="[object Object]",s=Function.prototype,o=Object.prototype,r=s.toString,c=o.hasOwnProperty,l=r.call(Object);function u(h){if(!n(h)||e(h)!=a)return!1;var p=t(h);if(p===null)return!0;var f=c.call(p,"constructor")&&p.constructor;return typeof f=="function"&&f instanceof f&&r.call(f)==l}return ON=u,ON}var MN,SB;function H$(){if(SB)return MN;SB=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return MN=e,MN}var IN,TB;function gRe(){if(TB)return IN;TB=1;var e=Hg(),t=$l();function n(a){return e(a,t(a))}return IN=n,IN}var DN,NB;function mRe(){if(NB)return DN;NB=1;var e=W$(),t=QK(),n=c$(),a=e$(),s=d$(),o=Gg(),r=Mn(),c=L$(),l=Vu(),u=Wg(),h=ei(),p=pRe(),f=Vg(),b=H$(),v=gRe();function w(T,y,x,C,A,E,R){var z=b(T,x),I=b(y,x),_=R.get(I);if(_){e(T,x,_);return}var D=E?E(z,I,x+"",T,y,R):void 0,L=D===void 0;if(L){var P=r(I),O=!P&&l(I),j=!P&&!O&&f(I);D=I,P||O||j?r(z)?D=z:c(z)?D=a(z):O?(L=!1,D=t(I,!0)):j?(L=!1,D=n(I,!0)):D=[]:p(I)||o(I)?(D=z,o(z)?D=v(z):(!h(z)||u(z))&&(D=s(I))):L=!1}L&&(R.set(I,D),A(D,I,C,E,R),R.delete(I)),e(T,x,D)}return DN=w,DN}var FN,AB;function fRe(){if(AB)return FN;AB=1;var e=Iv(),t=W$(),n=cz(),a=mRe(),s=ei(),o=$l(),r=H$();function c(l,u,h,p,f){l!==u&&n(u,function(b,v){if(f||(f=new e),s(b))a(l,u,v,h,c,p,f);else{var w=p?p(r(l,v),b,v+"",l,u,f):void 0;w===void 0&&(w=b),t(l,v,w)}},o)}return FN=c,FN}var BN,jB;function bRe(){if(jB)return BN;jB=1;var e=Jv(),t=Yv();function n(a){return e(function(s,o){var r=-1,c=o.length,l=c>1?o[c-1]:void 0,u=c>2?o[2]:void 0;for(l=a.length>3&&typeof l=="function"?(c--,l):void 0,u&&t(o[0],o[1],u)&&(l=c<3?void 0:l,c=1),s=Object(s);++r<c;){var h=o[r];h&&a(s,h,r,l)}return s})}return BN=n,BN}var UN,EB;function kRe(){if(EB)return UN;EB=1;var e=fRe(),t=bRe(),n=t(function(a,s,o){e(a,s,o)});return UN=n,UN}var WN,RB;function G$(){if(RB)return WN;RB=1;function e(t,n){return t<n}return WN=e,WN}var HN,zB;function vRe(){if(zB)return HN;zB=1;var e=gz(),t=G$(),n=Jl();function a(s){return s&&s.length?e(s,n,t):void 0}return HN=a,HN}var GN,qB;function wRe(){if(qB)return GN;qB=1;var e=gz(),t=hr(),n=G$();function a(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return GN=a,GN}var VN,_B;function yRe(){if(_B)return VN;_B=1;var e=qi(),t=function(){return e.Date.now()};return VN=t,VN}var KN,LB;function xRe(){if(LB)return KN;LB=1;var e=Fv(),t=Kv(),n=Bv(),a=ei(),s=Kg();function o(r,c,l,u){if(!a(r))return r;c=t(c,r);for(var h=-1,p=c.length,f=p-1,b=r;b!=null&&++h<p;){var v=s(c[h]),w=l;if(v==="__proto__"||v==="constructor"||v==="prototype")return r;if(h!=f){var T=b[v];w=u?u(T,v,b):void 0,w===void 0&&(w=a(T)?T:n(c[h+1])?[]:{})}e(b,v,w),b=b[v]}return r}return KN=o,KN}var $N,PB;function CRe(){if(PB)return $N;PB=1;var e=$v(),t=xRe(),n=Kv();function a(s,o,r){for(var c=-1,l=o.length,u={};++c<l;){var h=o[c],p=e(s,h);r(p,h)&&t(u,n(h,s),p)}return u}return $N=a,$N}var JN,OB;function SRe(){if(OB)return JN;OB=1;var e=CRe(),t=C$();function n(a,s){return e(a,s,function(o,r){return t(a,r)})}return JN=n,JN}var YN,MB;function TRe(){if(MB)return YN;MB=1;var e=U$(),t=z$(),n=q$();function a(s){return n(t(s,void 0,e),s+"")}return YN=a,YN}var ZN,IB;function NRe(){if(IB)return ZN;IB=1;var e=SRe(),t=TRe(),n=t(function(a,s){return a==null?{}:e(a,s)});return ZN=n,ZN}var XN,DB;function ARe(){if(DB)return XN;DB=1;var e=Math.ceil,t=Math.max;function n(a,s,o,r){for(var c=-1,l=t(e((s-a)/(o||1)),0),u=Array(l);l--;)u[r?l:++c]=a,a+=o;return u}return XN=n,XN}var QN,FB;function jRe(){if(FB)return QN;FB=1;var e=ARe(),t=Yv(),n=B$();function a(s){return function(o,r,c){return c&&typeof c!="number"&&t(o,r,c)&&(r=c=void 0),o=n(o),r===void 0?(r=o,o=0):r=n(r),c=c===void 0?o<r?1:-1:n(c),e(o,r,c,s)}}return QN=a,QN}var eA,BB;function ERe(){if(BB)return eA;BB=1;var e=jRe(),t=e();return eA=t,eA}var tA,UB;function RRe(){if(UB)return tA;UB=1;function e(t,n){var a=t.length;for(t.sort(n);a--;)t[a]=t[a].value;return t}return tA=e,tA}var nA,WB;function zRe(){if(WB)return nA;WB=1;var e=$u();function t(n,a){if(n!==a){var s=n!==void 0,o=n===null,r=n===n,c=e(n),l=a!==void 0,u=a===null,h=a===a,p=e(a);if(!u&&!p&&!c&&n>a||c&&l&&h&&!u&&!p||o&&l&&h||!s&&h||!r)return 1;if(!o&&!c&&!p&&n<a||p&&s&&r&&!o&&!c||u&&s&&r||!l&&r||!h)return-1}return 0}return nA=t,nA}var aA,HB;function qRe(){if(HB)return aA;HB=1;var e=zRe();function t(n,a,s){for(var o=-1,r=n.criteria,c=a.criteria,l=r.length,u=s.length;++o<l;){var h=e(r[o],c[o]);if(h){if(o>=u)return h;var p=s[o];return h*(p=="desc"?-1:1)}}return n.index-a.index}return aA=t,aA}var sA,GB;function _Re(){if(GB)return sA;GB=1;var e=Vv(),t=$v(),n=hr(),a=j$(),s=RRe(),o=Uv(),r=qRe(),c=Jl(),l=Mn();function u(h,p,f){p.length?p=e(p,function(w){return l(w)?function(T){return t(T,w.length===1?w[0]:w)}:w}):p=[c];var b=-1;p=e(p,o(n));var v=a(h,function(w,T,y){var x=e(p,function(C){return C(w)});return{criteria:x,index:++b,value:w}});return s(v,function(w,T){return r(w,T,f)})}return sA=u,sA}var iA,VB;function LRe(){if(VB)return iA;VB=1;var e=hz(),t=_Re(),n=Jv(),a=Yv(),s=n(function(o,r){if(o==null)return[];var c=r.length;return c>1&&a(o,r[0],r[1])?r=[]:c>2&&a(r[0],r[1],r[2])&&(r=[r[0]]),t(o,e(r,1),[])});return iA=s,iA}var oA,KB;function PRe(){if(KB)return oA;KB=1;var e=y$(),t=0;function n(a){var s=++t;return e(a)+s}return oA=n,oA}var rA,$B;function ORe(){if($B)return rA;$B=1;function e(t,n,a){for(var s=-1,o=t.length,r=n.length,c={};++s<o;){var l=s<r?n[s]:void 0;a(c,t[s],l)}return c}return rA=e,rA}var cA,JB;function MRe(){if(JB)return cA;JB=1;var e=Fv(),t=ORe();function n(a,s){return t(a||[],s||[],e)}return cA=n,cA}var lA,YB;function bn(){if(YB)return lA;YB=1;var e;if(typeof ZR=="function")try{e={cloneDeep:Q1e(),constant:rz(),defaults:eRe(),each:g$(),filter:T$(),find:rRe(),flatten:U$(),forEach:p$(),forIn:cRe(),has:N$(),isUndefined:A$(),last:lRe(),map:E$(),mapValues:dRe(),max:hRe(),merge:kRe(),min:vRe(),minBy:wRe(),now:yRe(),pick:NRe(),range:ERe(),reduce:R$(),sortBy:LRe(),uniqueId:PRe(),values:P$(),zipObject:MRe()}}catch{}return e||(e=window._),lA=e,lA}var dA,ZB;function IRe(){if(ZB)return dA;ZB=1,dA=e;function e(){var a={};a._next=a._prev=a,this._sentinel=a}e.prototype.dequeue=function(){var a=this._sentinel,s=a._prev;if(s!==a)return t(s),s},e.prototype.enqueue=function(a){var s=this._sentinel;a._prev&&a._next&&t(a),a._next=s._next,s._next._prev=a,s._next=a,a._prev=s},e.prototype.toString=function(){for(var a=[],s=this._sentinel,o=s._prev;o!==s;)a.push(JSON.stringify(o,n)),o=o._prev;return"["+a.join(", ")+"]"};function t(a){a._prev._next=a._next,a._next._prev=a._prev,delete a._next,delete a._prev}function n(a,s){if(a!=="_next"&&a!=="_prev")return s}return dA}var uA,XB;function DRe(){if(XB)return uA;XB=1;var e=bn(),t=Ei().Graph,n=IRe();uA=s;var a=e.constant(1);function s(u,h){if(u.nodeCount()<=1)return[];var p=c(u,h||a),f=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(f,function(b){return u.outEdges(b.v,b.w)}),!0)}function o(u,h,p){for(var f=[],b=h[h.length-1],v=h[0],w;u.nodeCount();){for(;w=v.dequeue();)r(u,h,p,w);for(;w=b.dequeue();)r(u,h,p,w);if(u.nodeCount()){for(var T=h.length-2;T>0;--T)if(w=h[T].dequeue(),w){f=f.concat(r(u,h,p,w,!0));break}}}return f}function r(u,h,p,f,b){var v=b?[]:void 0;return e.forEach(u.inEdges(f.v),function(w){var T=u.edge(w),y=u.node(w.v);b&&v.push({v:w.v,w:w.w}),y.out-=T,l(h,p,y)}),e.forEach(u.outEdges(f.v),function(w){var T=u.edge(w),y=w.w,x=u.node(y);x.in-=T,l(h,p,x)}),u.removeNode(f.v),v}function c(u,h){var p=new t,f=0,b=0;e.forEach(u.nodes(),function(T){p.setNode(T,{v:T,in:0,out:0})}),e.forEach(u.edges(),function(T){var y=p.edge(T.v,T.w)||0,x=h(T),C=y+x;p.setEdge(T.v,T.w,C),b=Math.max(b,p.node(T.v).out+=x),f=Math.max(f,p.node(T.w).in+=x)});var v=e.range(b+f+3).map(function(){return new n}),w=f+1;return e.forEach(p.nodes(),function(T){l(v,w,p.node(T))}),{graph:p,buckets:v,zeroIdx:w}}function l(u,h,p){p.out?p.in?u[p.out-p.in+h].enqueue(p):u[u.length-1].enqueue(p):u[0].enqueue(p)}return uA}var hA,QB;function FRe(){if(QB)return hA;QB=1;var e=bn(),t=DRe();hA={run:n,undo:s};function n(o){var r=o.graph().acyclicer==="greedy"?t(o,c(o)):a(o);e.forEach(r,function(l){var u=o.edge(l);o.removeEdge(l),u.forwardName=l.name,u.reversed=!0,o.setEdge(l.w,l.v,u,e.uniqueId("rev"))});function c(l){return function(u){return l.edge(u).weight}}}function a(o){var r=[],c={},l={};function u(h){e.has(l,h)||(l[h]=!0,c[h]=!0,e.forEach(o.outEdges(h),function(p){e.has(c,p.w)?r.push(p):u(p.w)}),delete c[h])}return e.forEach(o.nodes(),u),r}function s(o){e.forEach(o.edges(),function(r){var c=o.edge(r);if(c.reversed){o.removeEdge(r);var l=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(r.w,r.v,c,l)}})}return hA}var pA,eU;function ms(){if(eU)return pA;eU=1;var e=bn(),t=Ei().Graph;pA={addDummyNode:n,simplify:a,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:r,intersectRect:c,buildLayerMatrix:l,normalizeRanks:u,removeEmptyRanks:h,addBorderNode:p,maxRank:f,partition:b,time:v,notime:w};function n(T,y,x,C){var A;do A=e.uniqueId(C);while(T.hasNode(A));return x.dummy=y,T.setNode(A,x),A}function a(T){var y=new t().setGraph(T.graph());return e.forEach(T.nodes(),function(x){y.setNode(x,T.node(x))}),e.forEach(T.edges(),function(x){var C=y.edge(x.v,x.w)||{weight:0,minlen:1},A=T.edge(x);y.setEdge(x.v,x.w,{weight:C.weight+A.weight,minlen:Math.max(C.minlen,A.minlen)})}),y}function s(T){var y=new t({multigraph:T.isMultigraph()}).setGraph(T.graph());return e.forEach(T.nodes(),function(x){T.children(x).length||y.setNode(x,T.node(x))}),e.forEach(T.edges(),function(x){y.setEdge(x,T.edge(x))}),y}function o(T){var y=e.map(T.nodes(),function(x){var C={};return e.forEach(T.outEdges(x),function(A){C[A.w]=(C[A.w]||0)+T.edge(A).weight}),C});return e.zipObject(T.nodes(),y)}function r(T){var y=e.map(T.nodes(),function(x){var C={};return e.forEach(T.inEdges(x),function(A){C[A.v]=(C[A.v]||0)+T.edge(A).weight}),C});return e.zipObject(T.nodes(),y)}function c(T,y){var x=T.x,C=T.y,A=y.x-x,E=y.y-C,R=T.width/2,z=T.height/2;if(!A&&!E)throw new Error("Not possible to find intersection inside of the rectangle");var I,_;return Math.abs(E)*R>Math.abs(A)*z?(E<0&&(z=-z),I=z*A/E,_=z):(A<0&&(R=-R),I=R,_=R*E/A),{x:x+I,y:C+_}}function l(T){var y=e.map(e.range(f(T)+1),function(){return[]});return e.forEach(T.nodes(),function(x){var C=T.node(x),A=C.rank;e.isUndefined(A)||(y[A][C.order]=x)}),y}function u(T){var y=e.min(e.map(T.nodes(),function(x){return T.node(x).rank}));e.forEach(T.nodes(),function(x){var C=T.node(x);e.has(C,"rank")&&(C.rank-=y)})}function h(T){var y=e.min(e.map(T.nodes(),function(E){return T.node(E).rank})),x=[];e.forEach(T.nodes(),function(E){var R=T.node(E).rank-y;x[R]||(x[R]=[]),x[R].push(E)});var C=0,A=T.graph().nodeRankFactor;e.forEach(x,function(E,R){e.isUndefined(E)&&R%A!==0?--C:C&&e.forEach(E,function(z){T.node(z).rank+=C})})}function p(T,y,x,C){var A={width:0,height:0};return arguments.length>=4&&(A.rank=x,A.order=C),n(T,"border",A,y)}function f(T){return e.max(e.map(T.nodes(),function(y){var x=T.node(y).rank;if(!e.isUndefined(x))return x}))}function b(T,y){var x={lhs:[],rhs:[]};return e.forEach(T,function(C){y(C)?x.lhs.push(C):x.rhs.push(C)}),x}function v(T,y){var x=e.now();try{return y()}finally{console.log(T+" time: "+(e.now()-x)+"ms")}}function w(T,y){return y()}return pA}var gA,tU;function BRe(){if(tU)return gA;tU=1;var e=bn(),t=ms();gA={run:n,undo:s};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(r){a(o,r)})}function a(o,r){var c=r.v,l=o.node(c).rank,u=r.w,h=o.node(u).rank,p=r.name,f=o.edge(r),b=f.labelRank;if(h!==l+1){o.removeEdge(r);var v,w,T;for(T=0,++l;l<h;++T,++l)f.points=[],w={width:0,height:0,edgeLabel:f,edgeObj:r,rank:l},v=t.addDummyNode(o,"edge",w,"_d"),l===b&&(w.width=f.width,w.height=f.height,w.dummy="edge-label",w.labelpos=f.labelpos),o.setEdge(c,v,{weight:f.weight},p),T===0&&o.graph().dummyChains.push(v),c=v;o.setEdge(c,u,{weight:f.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(r){var c=o.node(r),l=c.edgeLabel,u;for(o.setEdge(c.edgeObj,l);c.dummy;)u=o.successors(r)[0],o.removeNode(r),l.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(l.x=c.x,l.y=c.y,l.width=c.width,l.height=c.height),r=u,c=o.node(r)})}return gA}var mA,nU;function yk(){if(nU)return mA;nU=1;var e=bn();mA={longestPath:t,slack:n};function t(a){var s={};function o(r){var c=a.node(r);if(e.has(s,r))return c.rank;s[r]=!0;var l=e.min(e.map(a.outEdges(r),function(u){return o(u.w)-a.edge(u).minlen}));return(l===Number.POSITIVE_INFINITY||l===void 0||l===null)&&(l=0),c.rank=l}e.forEach(a.sources(),o)}function n(a,s){return a.node(s.w).rank-a.node(s.v).rank-a.edge(s).minlen}return mA}var fA,aU;function V$(){if(aU)return fA;aU=1;var e=bn(),t=Ei().Graph,n=yk().slack;fA=a;function a(c){var l=new t({directed:!1}),u=c.nodes()[0],h=c.nodeCount();l.setNode(u,{});for(var p,f;s(l,c)<h;)p=o(l,c),f=l.hasNode(p.v)?n(c,p):-n(c,p),r(l,c,f);return l}function s(c,l){function u(h){e.forEach(l.nodeEdges(h),function(p){var f=p.v,b=h===f?p.w:f;!c.hasNode(b)&&!n(l,p)&&(c.setNode(b,{}),c.setEdge(h,b,{}),u(b))})}return e.forEach(c.nodes(),u),c.nodeCount()}function o(c,l){return e.minBy(l.edges(),function(u){if(c.hasNode(u.v)!==c.hasNode(u.w))return n(l,u)})}function r(c,l,u){e.forEach(c.nodes(),function(h){l.node(h).rank+=u})}return fA}var bA,sU;function URe(){if(sU)return bA;sU=1;var e=bn(),t=V$(),n=yk().slack,a=yk().longestPath,s=Ei().alg.preorder,o=Ei().alg.postorder,r=ms().simplify;bA=c,c.initLowLimValues=p,c.initCutValues=l,c.calcCutValue=h,c.leaveEdge=b,c.enterEdge=v,c.exchangeEdges=w;function c(C){C=r(C),a(C);var A=t(C);p(A),l(A,C);for(var E,R;E=b(A);)R=v(A,C,E),w(A,C,E,R)}function l(C,A){var E=o(C,C.nodes());E=E.slice(0,E.length-1),e.forEach(E,function(R){u(C,A,R)})}function u(C,A,E){var R=C.node(E),z=R.parent;C.edge(E,z).cutvalue=h(C,A,E)}function h(C,A,E){var R=C.node(E),z=R.parent,I=!0,_=A.edge(E,z),D=0;return _||(I=!1,_=A.edge(z,E)),D=_.weight,e.forEach(A.nodeEdges(E),function(L){var P=L.v===E,O=P?L.w:L.v;if(O!==z){var j=P===I,M=A.edge(L).weight;if(D+=j?M:-M,y(C,E,O)){var F=C.edge(E,O).cutvalue;D+=j?-F:F}}}),D}function p(C,A){arguments.length<2&&(A=C.nodes()[0]),f(C,{},1,A)}function f(C,A,E,R,z){var I=E,_=C.node(R);return A[R]=!0,e.forEach(C.neighbors(R),function(D){e.has(A,D)||(E=f(C,A,E,D,R))}),_.low=I,_.lim=E++,z?_.parent=z:delete _.parent,E}function b(C){return e.find(C.edges(),function(A){return C.edge(A).cutvalue<0})}function v(C,A,E){var R=E.v,z=E.w;A.hasEdge(R,z)||(R=E.w,z=E.v);var I=C.node(R),_=C.node(z),D=I,L=!1;I.lim>_.lim&&(D=_,L=!0);var P=e.filter(A.edges(),function(O){return L===x(C,C.node(O.v),D)&&L!==x(C,C.node(O.w),D)});return e.minBy(P,function(O){return n(A,O)})}function w(C,A,E,R){var z=E.v,I=E.w;C.removeEdge(z,I),C.setEdge(R.v,R.w,{}),p(C),l(C,A),T(C,A)}function T(C,A){var E=e.find(C.nodes(),function(z){return!A.node(z).parent}),R=s(C,E);R=R.slice(1),e.forEach(R,function(z){var I=C.node(z).parent,_=A.edge(z,I),D=!1;_||(_=A.edge(I,z),D=!0),A.node(z).rank=A.node(I).rank+(D?_.minlen:-_.minlen)})}function y(C,A,E){return C.hasEdge(A,E)}function x(C,A,E){return E.low<=A.lim&&A.lim<=E.lim}return bA}var kA,iU;function WRe(){if(iU)return kA;iU=1;var e=yk(),t=e.longestPath,n=V$(),a=URe();kA=s;function s(l){switch(l.graph().ranker){case"network-simplex":c(l);break;case"tight-tree":r(l);break;case"longest-path":o(l);break;default:c(l)}}var o=t;function r(l){t(l),n(l)}function c(l){a(l)}return kA}var vA,oU;function HRe(){if(oU)return vA;oU=1;var e=bn();vA=t;function t(s){var o=a(s);e.forEach(s.graph().dummyChains,function(r){for(var c=s.node(r),l=c.edgeObj,u=n(s,o,l.v,l.w),h=u.path,p=u.lca,f=0,b=h[f],v=!0;r!==l.w;){if(c=s.node(r),v){for(;(b=h[f])!==p&&s.node(b).maxRank<c.rank;)f++;b===p&&(v=!1)}if(!v){for(;f<h.length-1&&s.node(b=h[f+1]).minRank<=c.rank;)f++;b=h[f]}s.setParent(r,b),r=s.successors(r)[0]}})}function n(s,o,r,c){var l=[],u=[],h=Math.min(o[r].low,o[c].low),p=Math.max(o[r].lim,o[c].lim),f,b;f=r;do f=s.parent(f),l.push(f);while(f&&(o[f].low>h||p>o[f].lim));for(b=f,f=c;(f=s.parent(f))!==b;)u.push(f);return{path:l.concat(u.reverse()),lca:b}}function a(s){var o={},r=0;function c(l){var u=r;e.forEach(s.children(l),c),o[l]={low:u,lim:r++}}return e.forEach(s.children(),c),o}return vA}var wA,rU;function GRe(){if(rU)return wA;rU=1;var e=bn(),t=ms();wA={run:n,cleanup:r};function n(c){var l=t.addDummyNode(c,"root",{},"_root"),u=s(c),h=e.max(e.values(u))-1,p=2*h+1;c.graph().nestingRoot=l,e.forEach(c.edges(),function(b){c.edge(b).minlen*=p});var f=o(c)+1;e.forEach(c.children(),function(b){a(c,l,p,f,h,u,b)}),c.graph().nodeRankFactor=p}function a(c,l,u,h,p,f,b){var v=c.children(b);if(!v.length){b!==l&&c.setEdge(l,b,{weight:0,minlen:u});return}var w=t.addBorderNode(c,"_bt"),T=t.addBorderNode(c,"_bb"),y=c.node(b);c.setParent(w,b),y.borderTop=w,c.setParent(T,b),y.borderBottom=T,e.forEach(v,function(x){a(c,l,u,h,p,f,x);var C=c.node(x),A=C.borderTop?C.borderTop:x,E=C.borderBottom?C.borderBottom:x,R=C.borderTop?h:2*h,z=A!==E?1:p-f[b]+1;c.setEdge(w,A,{weight:R,minlen:z,nestingEdge:!0}),c.setEdge(E,T,{weight:R,minlen:z,nestingEdge:!0})}),c.parent(b)||c.setEdge(l,w,{weight:0,minlen:p+f[b]})}function s(c){var l={};function u(h,p){var f=c.children(h);f&&f.length&&e.forEach(f,function(b){u(b,p+1)}),l[h]=p}return e.forEach(c.children(),function(h){u(h,1)}),l}function o(c){return e.reduce(c.edges(),function(l,u){return l+c.edge(u).weight},0)}function r(c){var l=c.graph();c.removeNode(l.nestingRoot),delete l.nestingRoot,e.forEach(c.edges(),function(u){var h=c.edge(u);h.nestingEdge&&c.removeEdge(u)})}return wA}var yA,cU;function VRe(){if(cU)return yA;cU=1;var e=bn(),t=ms();yA=n;function n(s){function o(r){var c=s.children(r),l=s.node(r);if(c.length&&e.forEach(c,o),e.has(l,"minRank")){l.borderLeft=[],l.borderRight=[];for(var u=l.minRank,h=l.maxRank+1;u<h;++u)a(s,"borderLeft","_bl",r,l,u),a(s,"borderRight","_br",r,l,u)}}e.forEach(s.children(),o)}function a(s,o,r,c,l,u){var h={width:0,height:0,rank:u,borderType:o},p=l[o][u-1],f=t.addDummyNode(s,"border",h,r);l[o][u]=f,s.setParent(f,c),p&&s.setEdge(p,f,{weight:1})}return yA}var xA,lU;function KRe(){if(lU)return xA;lU=1;var e=bn();xA={adjust:t,undo:n};function t(u){var h=u.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&a(u)}function n(u){var h=u.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&o(u),(h==="lr"||h==="rl")&&(c(u),a(u))}function a(u){e.forEach(u.nodes(),function(h){s(u.node(h))}),e.forEach(u.edges(),function(h){s(u.edge(h))})}function s(u){var h=u.width;u.width=u.height,u.height=h}function o(u){e.forEach(u.nodes(),function(h){r(u.node(h))}),e.forEach(u.edges(),function(h){var p=u.edge(h);e.forEach(p.points,r),e.has(p,"y")&&r(p)})}function r(u){u.y=-u.y}function c(u){e.forEach(u.nodes(),function(h){l(u.node(h))}),e.forEach(u.edges(),function(h){var p=u.edge(h);e.forEach(p.points,l),e.has(p,"x")&&l(p)})}function l(u){var h=u.x;u.x=u.y,u.y=h}return xA}var CA,dU;function $Re(){if(dU)return CA;dU=1;var e=bn();CA=t;function t(n){var a={},s=e.filter(n.nodes(),function(u){return!n.children(u).length}),o=e.max(e.map(s,function(u){return n.node(u).rank})),r=e.map(e.range(o+1),function(){return[]});function c(u){if(!e.has(a,u)){a[u]=!0;var h=n.node(u);r[h.rank].push(u),e.forEach(n.successors(u),c)}}var l=e.sortBy(s,function(u){return n.node(u).rank});return e.forEach(l,c),r}return CA}var SA,uU;function JRe(){if(uU)return SA;uU=1;var e=bn();SA=t;function t(a,s){for(var o=0,r=1;r<s.length;++r)o+=n(a,s[r-1],s[r]);return o}function n(a,s,o){for(var r=e.zipObject(o,e.map(o,function(f,b){return b})),c=e.flatten(e.map(s,function(f){return e.sortBy(e.map(a.outEdges(f),function(b){return{pos:r[b.w],weight:a.edge(b).weight}}),"pos")}),!0),l=1;l<o.length;)l<<=1;var u=2*l-1;l-=1;var h=e.map(new Array(u),function(){return 0}),p=0;return e.forEach(c.forEach(function(f){var b=f.pos+l;h[b]+=f.weight;for(var v=0;b>0;)b%2&&(v+=h[b+1]),b=b-1>>1,h[b]+=f.weight;p+=f.weight*v})),p}return SA}var TA,hU;function YRe(){if(hU)return TA;hU=1;var e=bn();TA=t;function t(n,a){return e.map(a,function(s){var o=n.inEdges(s);if(o.length){var r=e.reduce(o,function(c,l){var u=n.edge(l),h=n.node(l.v);return{sum:c.sum+u.weight*h.order,weight:c.weight+u.weight}},{sum:0,weight:0});return{v:s,barycenter:r.sum/r.weight,weight:r.weight}}else return{v:s}})}return TA}var NA,pU;function ZRe(){if(pU)return NA;pU=1;var e=bn();NA=t;function t(s,o){var r={};e.forEach(s,function(l,u){var h=r[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:u};e.isUndefined(l.barycenter)||(h.barycenter=l.barycenter,h.weight=l.weight)}),e.forEach(o.edges(),function(l){var u=r[l.v],h=r[l.w];!e.isUndefined(u)&&!e.isUndefined(h)&&(h.indegree++,u.out.push(r[l.w]))});var c=e.filter(r,function(l){return!l.indegree});return n(c)}function n(s){var o=[];function r(u){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(u.barycenter)||h.barycenter>=u.barycenter)&&a(u,h)}}function c(u){return function(h){h.in.push(u),--h.indegree===0&&s.push(h)}}for(;s.length;){var l=s.pop();o.push(l),e.forEach(l.in.reverse(),r(l)),e.forEach(l.out,c(l))}return e.map(e.filter(o,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function a(s,o){var r=0,c=0;s.weight&&(r+=s.barycenter*s.weight,c+=s.weight),o.weight&&(r+=o.barycenter*o.weight,c+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=r/c,s.weight=c,s.i=Math.min(o.i,s.i),o.merged=!0}return NA}var AA,gU;function XRe(){if(gU)return AA;gU=1;var e=bn(),t=ms();AA=n;function n(o,r){var c=t.partition(o,function(w){return e.has(w,"barycenter")}),l=c.lhs,u=e.sortBy(c.rhs,function(w){return-w.i}),h=[],p=0,f=0,b=0;l.sort(s(!!r)),b=a(h,u,b),e.forEach(l,function(w){b+=w.vs.length,h.push(w.vs),p+=w.barycenter*w.weight,f+=w.weight,b=a(h,u,b)});var v={vs:e.flatten(h,!0)};return f&&(v.barycenter=p/f,v.weight=f),v}function a(o,r,c){for(var l;r.length&&(l=e.last(r)).i<=c;)r.pop(),o.push(l.vs),c++;return c}function s(o){return function(r,c){return r.barycenter<c.barycenter?-1:r.barycenter>c.barycenter?1:o?c.i-r.i:r.i-c.i}}return AA}var jA,mU;function QRe(){if(mU)return jA;mU=1;var e=bn(),t=YRe(),n=ZRe(),a=XRe();jA=s;function s(c,l,u,h){var p=c.children(l),f=c.node(l),b=f?f.borderLeft:void 0,v=f?f.borderRight:void 0,w={};b&&(p=e.filter(p,function(E){return E!==b&&E!==v}));var T=t(c,p);e.forEach(T,function(E){if(c.children(E.v).length){var R=s(c,E.v,u,h);w[E.v]=R,e.has(R,"barycenter")&&r(E,R)}});var y=n(T,u);o(y,w);var x=a(y,h);if(b&&(x.vs=e.flatten([b,x.vs,v],!0),c.predecessors(b).length)){var C=c.node(c.predecessors(b)[0]),A=c.node(c.predecessors(v)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+C.order+A.order)/(x.weight+2),x.weight+=2}return x}function o(c,l){e.forEach(c,function(u){u.vs=e.flatten(u.vs.map(function(h){return l[h]?l[h].vs:h}),!0)})}function r(c,l){e.isUndefined(c.barycenter)?(c.barycenter=l.barycenter,c.weight=l.weight):(c.barycenter=(c.barycenter*c.weight+l.barycenter*l.weight)/(c.weight+l.weight),c.weight+=l.weight)}return jA}var EA,fU;function eze(){if(fU)return EA;fU=1;var e=bn(),t=Ei().Graph;EA=n;function n(s,o,r){var c=a(s),l=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(u){return s.node(u)});return e.forEach(s.nodes(),function(u){var h=s.node(u),p=s.parent(u);(h.rank===o||h.minRank<=o&&o<=h.maxRank)&&(l.setNode(u),l.setParent(u,p||c),e.forEach(s[r](u),function(f){var b=f.v===u?f.w:f.v,v=l.edge(b,u),w=e.isUndefined(v)?0:v.weight;l.setEdge(b,u,{weight:s.edge(f).weight+w})}),e.has(h,"minRank")&&l.setNode(u,{borderLeft:h.borderLeft[o],borderRight:h.borderRight[o]}))}),l}function a(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return EA}var RA,bU;function tze(){if(bU)return RA;bU=1;var e=bn();RA=t;function t(n,a,s){var o={},r;e.forEach(s,function(c){for(var l=n.parent(c),u,h;l;){if(u=n.parent(l),u?(h=o[u],o[u]=l):(h=r,r=l),h&&h!==l){a.setEdge(h,l);return}l=u}})}return RA}var zA,kU;function nze(){if(kU)return zA;kU=1;var e=bn(),t=$Re(),n=JRe(),a=QRe(),s=eze(),o=tze(),r=Ei().Graph,c=ms();zA=l;function l(f){var b=c.maxRank(f),v=u(f,e.range(1,b+1),"inEdges"),w=u(f,e.range(b-1,-1,-1),"outEdges"),T=t(f);p(f,T);for(var y=Number.POSITIVE_INFINITY,x,C=0,A=0;A<4;++C,++A){h(C%2?v:w,C%4>=2),T=c.buildLayerMatrix(f);var E=n(f,T);E<y&&(A=0,x=e.cloneDeep(T),y=E)}p(f,x)}function u(f,b,v){return e.map(b,function(w){return s(f,w,v)})}function h(f,b){var v=new r;e.forEach(f,function(w){var T=w.graph().root,y=a(w,T,v,b);e.forEach(y.vs,function(x,C){w.node(x).order=C}),o(w,v,y.vs)})}function p(f,b){e.forEach(b,function(v){e.forEach(v,function(w,T){f.node(w).order=T})})}return zA}var qA,vU;function aze(){if(vU)return qA;vU=1;var e=bn(),t=Ei().Graph,n=ms();qA={positionX:v,findType1Conflicts:a,findType2Conflicts:s,addConflict:r,hasConflict:c,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:p,balance:b};function a(y,x){var C={};function A(E,R){var z=0,I=0,_=E.length,D=e.last(R);return e.forEach(R,function(L,P){var O=o(y,L),j=O?y.node(O).order:_;(O||L===D)&&(e.forEach(R.slice(I,P+1),function(M){e.forEach(y.predecessors(M),function(F){var U=y.node(F),H=U.order;(H<z||j<H)&&!(U.dummy&&y.node(M).dummy)&&r(C,F,M)})}),I=P+1,z=j)}),R}return e.reduce(x,A),C}function s(y,x){var C={};function A(R,z,I,_,D){var L;e.forEach(e.range(z,I),function(P){L=R[P],y.node(L).dummy&&e.forEach(y.predecessors(L),function(O){var j=y.node(O);j.dummy&&(j.order<_||j.order>D)&&r(C,O,L)})})}function E(R,z){var I=-1,_,D=0;return e.forEach(z,function(L,P){if(y.node(L).dummy==="border"){var O=y.predecessors(L);O.length&&(_=y.node(O[0]).order,A(z,D,P,I,_),D=P,I=_)}A(z,D,z.length,_,R.length)}),z}return e.reduce(x,E),C}function o(y,x){if(y.node(x).dummy)return e.find(y.predecessors(x),function(C){return y.node(C).dummy})}function r(y,x,C){if(x>C){var A=x;x=C,C=A}var E=y[x];E||(y[x]=E={}),E[C]=!0}function c(y,x,C){if(x>C){var A=x;x=C,C=A}return e.has(y[x],C)}function l(y,x,C,A){var E={},R={},z={};return e.forEach(x,function(I){e.forEach(I,function(_,D){E[_]=_,R[_]=_,z[_]=D})}),e.forEach(x,function(I){var _=-1;e.forEach(I,function(D){var L=A(D);if(L.length){L=e.sortBy(L,function(F){return z[F]});for(var P=(L.length-1)/2,O=Math.floor(P),j=Math.ceil(P);O<=j;++O){var M=L[O];R[D]===D&&_<z[M]&&!c(C,D,M)&&(R[M]=D,R[D]=E[D]=E[M],_=z[M])}}})}),{root:E,align:R}}function u(y,x,C,A,E){var R={},z=h(y,x,C,E),I=E?"borderLeft":"borderRight";function _(P,O){for(var j=z.nodes(),M=j.pop(),F={};M;)F[M]?P(M):(F[M]=!0,j.push(M),j=j.concat(O(M))),M=j.pop()}function D(P){R[P]=z.inEdges(P).reduce(function(O,j){return Math.max(O,R[j.v]+z.edge(j))},0)}function L(P){var O=z.outEdges(P).reduce(function(M,F){return Math.min(M,R[F.w]-z.edge(F))},Number.POSITIVE_INFINITY),j=y.node(P);O!==Number.POSITIVE_INFINITY&&j.borderType!==I&&(R[P]=Math.max(R[P],O))}return _(D,z.predecessors.bind(z)),_(L,z.successors.bind(z)),e.forEach(A,function(P){R[P]=R[C[P]]}),R}function h(y,x,C,A){var E=new t,R=y.graph(),z=w(R.nodesep,R.edgesep,A);return e.forEach(x,function(I){var _;e.forEach(I,function(D){var L=C[D];if(E.setNode(L),_){var P=C[_],O=E.edge(P,L);E.setEdge(P,L,Math.max(z(y,D,_),O||0))}_=D})}),E}function p(y,x){return e.minBy(e.values(x),function(C){var A=Number.NEGATIVE_INFINITY,E=Number.POSITIVE_INFINITY;return e.forIn(C,function(R,z){var I=T(y,z)/2;A=Math.max(R+I,A),E=Math.min(R-I,E)}),A-E})}function f(y,x){var C=e.values(x),A=e.min(C),E=e.max(C);e.forEach(["u","d"],function(R){e.forEach(["l","r"],function(z){var I=R+z,_=y[I],D;if(_!==x){var L=e.values(_);D=z==="l"?A-e.min(L):E-e.max(L),D&&(y[I]=e.mapValues(_,function(P){return P+D}))}})})}function b(y,x){return e.mapValues(y.ul,function(C,A){if(x)return y[x.toLowerCase()][A];var E=e.sortBy(e.map(y,A));return(E[1]+E[2])/2})}function v(y){var x=n.buildLayerMatrix(y),C=e.merge(a(y,x),s(y,x)),A={},E;e.forEach(["u","d"],function(z){E=z==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(E=e.map(E,function(P){return e.values(P).reverse()}));var _=(z==="u"?y.predecessors:y.successors).bind(y),D=l(y,E,C,_),L=u(y,E,D.root,D.align,I==="r");I==="r"&&(L=e.mapValues(L,function(P){return-P})),A[z+I]=L})});var R=p(y,A);return f(A,R),b(A,y.graph().align)}function w(y,x,C){return function(A,E,R){var z=A.node(E),I=A.node(R),_=0,D;if(_+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":D=-z.width/2;break;case"r":D=z.width/2;break}if(D&&(_+=C?D:-D),D=0,_+=(z.dummy?x:y)/2,_+=(I.dummy?x:y)/2,_+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":D=I.width/2;break;case"r":D=-I.width/2;break}return D&&(_+=C?D:-D),D=0,_}}function T(y,x){return y.node(x).width}return qA}var _A,wU;function sze(){if(wU)return _A;wU=1;var e=bn(),t=ms(),n=aze().positionX;_A=a;function a(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(n(o),function(r,c){o.node(c).x=r})}function s(o){var r=t.buildLayerMatrix(o),c=o.graph().ranksep,l=0;e.forEach(r,function(u){var h=e.max(e.map(u,function(p){return o.node(p).height}));e.forEach(u,function(p){o.node(p).y=l+h/2}),l+=h+c})}return _A}var LA,yU;function ize(){if(yU)return LA;yU=1;var e=bn(),t=FRe(),n=BRe(),a=WRe(),s=ms().normalizeRanks,o=HRe(),r=ms().removeEmptyRanks,c=GRe(),l=VRe(),u=KRe(),h=nze(),p=sze(),f=ms(),b=Ei().Graph;LA=v;function v(J,X){var te=X&&X.debugTiming?f.time:f.notime;te("layout",function(){var K=te(" buildLayoutGraph",function(){return _(J)});te(" runLayout",function(){w(K,te)}),te(" updateInputGraph",function(){T(J,K)})})}function w(J,X){X(" makeSpaceForEdgeLabels",function(){D(J)}),X(" removeSelfEdges",function(){$(J)}),X(" acyclic",function(){t.run(J)}),X(" nestingGraph.run",function(){c.run(J)}),X(" rank",function(){a(f.asNonCompoundGraph(J))}),X(" injectEdgeLabelProxies",function(){L(J)}),X(" removeEmptyRanks",function(){r(J)}),X(" nestingGraph.cleanup",function(){c.cleanup(J)}),X(" normalizeRanks",function(){s(J)}),X(" assignRankMinMax",function(){P(J)}),X(" removeEdgeLabelProxies",function(){O(J)}),X(" normalize.run",function(){n.run(J)}),X(" parentDummyChains",function(){o(J)}),X(" addBorderSegments",function(){l(J)}),X(" order",function(){h(J)}),X(" insertSelfEdges",function(){Y(J)}),X(" adjustCoordinateSystem",function(){u.adjust(J)}),X(" position",function(){p(J)}),X(" positionSelfEdges",function(){W(J)}),X(" removeBorderNodes",function(){H(J)}),X(" normalize.undo",function(){n.undo(J)}),X(" fixupEdgeLabelCoords",function(){F(J)}),X(" undoCoordinateSystem",function(){u.undo(J)}),X(" translateGraph",function(){j(J)}),X(" assignNodeIntersects",function(){M(J)}),X(" reversePoints",function(){U(J)}),X(" acyclic.undo",function(){t.undo(J)})}function T(J,X){e.forEach(J.nodes(),function(te){var K=J.node(te),V=X.node(te);K&&(K.x=V.x,K.y=V.y,X.children(te).length&&(K.width=V.width,K.height=V.height))}),e.forEach(J.edges(),function(te){var K=J.edge(te),V=X.edge(te);K.points=V.points,e.has(V,"x")&&(K.x=V.x,K.y=V.y)}),J.graph().width=X.graph().width,J.graph().height=X.graph().height}var y=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},C=["acyclicer","ranker","rankdir","align"],A=["width","height"],E={width:0,height:0},R=["minlen","weight","width","height","labeloffset"],z={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function _(J){var X=new b({multigraph:!0,compound:!0}),te=Q(J.graph());return X.setGraph(e.merge({},x,G(te,y),e.pick(te,C))),e.forEach(J.nodes(),function(K){var V=Q(J.node(K));X.setNode(K,e.defaults(G(V,A),E)),X.setParent(K,J.parent(K))}),e.forEach(J.edges(),function(K){var V=Q(J.edge(K));X.setEdge(K,e.merge({},z,G(V,R),e.pick(V,I)))}),X}function D(J){var X=J.graph();X.ranksep/=2,e.forEach(J.edges(),function(te){var K=J.edge(te);K.minlen*=2,K.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?K.width+=K.labeloffset:K.height+=K.labeloffset)})}function L(J){e.forEach(J.edges(),function(X){var te=J.edge(X);if(te.width&&te.height){var K=J.node(X.v),V=J.node(X.w),ee={rank:(V.rank-K.rank)/2+K.rank,e:X};f.addDummyNode(J,"edge-proxy",ee,"_ep")}})}function P(J){var X=0;e.forEach(J.nodes(),function(te){var K=J.node(te);K.borderTop&&(K.minRank=J.node(K.borderTop).rank,K.maxRank=J.node(K.borderBottom).rank,X=e.max(X,K.maxRank))}),J.graph().maxRank=X}function O(J){e.forEach(J.nodes(),function(X){var te=J.node(X);te.dummy==="edge-proxy"&&(J.edge(te.e).labelRank=te.rank,J.removeNode(X))})}function j(J){var X=Number.POSITIVE_INFINITY,te=0,K=Number.POSITIVE_INFINITY,V=0,ee=J.graph(),de=ee.marginx||0,he=ee.marginy||0;function me(be){var ie=be.x,ne=be.y,ke=be.width,Se=be.height;X=Math.min(X,ie-ke/2),te=Math.max(te,ie+ke/2),K=Math.min(K,ne-Se/2),V=Math.max(V,ne+Se/2)}e.forEach(J.nodes(),function(be){me(J.node(be))}),e.forEach(J.edges(),function(be){var ie=J.edge(be);e.has(ie,"x")&&me(ie)}),X-=de,K-=he,e.forEach(J.nodes(),function(be){var ie=J.node(be);ie.x-=X,ie.y-=K}),e.forEach(J.edges(),function(be){var ie=J.edge(be);e.forEach(ie.points,function(ne){ne.x-=X,ne.y-=K}),e.has(ie,"x")&&(ie.x-=X),e.has(ie,"y")&&(ie.y-=K)}),ee.width=te-X+de,ee.height=V-K+he}function M(J){e.forEach(J.edges(),function(X){var te=J.edge(X),K=J.node(X.v),V=J.node(X.w),ee,de;te.points?(ee=te.points[0],de=te.points[te.points.length-1]):(te.points=[],ee=V,de=K),te.points.unshift(f.intersectRect(K,ee)),te.points.push(f.intersectRect(V,de))})}function F(J){e.forEach(J.edges(),function(X){var te=J.edge(X);if(e.has(te,"x"))switch((te.labelpos==="l"||te.labelpos==="r")&&(te.width-=te.labeloffset),te.labelpos){case"l":te.x-=te.width/2+te.labeloffset;break;case"r":te.x+=te.width/2+te.labeloffset;break}})}function U(J){e.forEach(J.edges(),function(X){var te=J.edge(X);te.reversed&&te.points.reverse()})}function H(J){e.forEach(J.nodes(),function(X){if(J.children(X).length){var te=J.node(X),K=J.node(te.borderTop),V=J.node(te.borderBottom),ee=J.node(e.last(te.borderLeft)),de=J.node(e.last(te.borderRight));te.width=Math.abs(de.x-ee.x),te.height=Math.abs(V.y-K.y),te.x=ee.x+te.width/2,te.y=K.y+te.height/2}}),e.forEach(J.nodes(),function(X){J.node(X).dummy==="border"&&J.removeNode(X)})}function $(J){e.forEach(J.edges(),function(X){if(X.v===X.w){var te=J.node(X.v);te.selfEdges||(te.selfEdges=[]),te.selfEdges.push({e:X,label:J.edge(X)}),J.removeEdge(X)}})}function Y(J){var X=f.buildLayerMatrix(J);e.forEach(X,function(te){var K=0;e.forEach(te,function(V,ee){var de=J.node(V);de.order=ee+K,e.forEach(de.selfEdges,function(he){f.addDummyNode(J,"selfedge",{width:he.label.width,height:he.label.height,rank:de.rank,order:ee+ ++K,e:he.e,label:he.label},"_se")}),delete de.selfEdges})})}function W(J){e.forEach(J.nodes(),function(X){var te=J.node(X);if(te.dummy==="selfedge"){var K=J.node(te.e.v),V=K.x+K.width/2,ee=K.y,de=te.x-V,he=K.height/2;J.setEdge(te.e,te.label),J.removeNode(X),te.label.points=[{x:V+2*de/3,y:ee-he},{x:V+5*de/6,y:ee-he},{x:V+de,y:ee},{x:V+5*de/6,y:ee+he},{x:V+2*de/3,y:ee+he}],te.label.x=te.x,te.label.y=te.y}})}function G(J,X){return e.mapValues(e.pick(J,X),Number)}function Q(J){var X={};return e.forEach(J,function(te,K){X[K.toLowerCase()]=te}),X}return LA}var PA,xU;function oze(){if(xU)return PA;xU=1;var e=bn(),t=ms(),n=Ei().Graph;PA={debugOrdering:a};function a(s){var o=t.buildLayerMatrix(s),r=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(c){r.setNode(c,{label:c}),r.setParent(c,"layer"+s.node(c).rank)}),e.forEach(s.edges(),function(c){r.setEdge(c.v,c.w,{},c.name)}),e.forEach(o,function(c,l){var u="layer"+l;r.setNode(u,{rank:"same"}),e.reduce(c,function(h,p){return r.setEdge(h,p,{style:"invis"}),p})}),r}return PA}var OA,CU;function rze(){return CU||(CU=1,OA="0.8.5"),OA}var MA,SU;function cze(){return SU||(SU=1,MA={graphlib:Ei(),layout:ize(),debug:oze(),util:{time:ms().time,notime:ms().notime},version:rze()}),MA}var lze=cze();const TU=qE(lze),NU=e=>{var t;return(t=e.data)==null?void 0:t.parentId};function dze(e,t,n,a){const s=Gk(e,h=>!t.has(h.id)&&n(h.id)!=null);if(s.size===0)return e;for(const h of s.values())h.sort((p,f)=>p.id.localeCompare(f.id));const o=h=>{var p;return(a==null?void 0:a(h).h)??((p=e.find(f=>f.id===h))==null?void 0:p.height)??Fl},r=new Map(e.map(h=>[h.id,h.position])),c=new Map,l=h=>t.has(h)?void 0:c.get(h)??n(h),u=e.filter(h=>!t.has(h.id)&&!n(h.id)&&s.has(wn(h))).sort((h,p)=>h.position.x-p.position.x||h.position.y-p.position.y);for(const h of u){const p=wn(h),f=NU(h),b=f?l(f):void 0;if(f&&b&&h.type!=="recapNote"){const y={x:b.x-r.get(f).x,y:b.y-r.get(f).y},x={x:h.position.x+y.x,y:h.position.y+y.y};let C=null;for(const A of e){if(A.id===h.id||A.type==="recapNote"||NU(A)!==f||wn(A)!==p)continue;const E=l(A.id);if(!E||Math.abs(E.x-x.x)>po||E.x<=b.x)continue;const R=E.y+o(A.id);(!C||R>C.bottom)&&(C={at:E,bottom:R})}if(C){c.set(h.id,{x:C.at.x,y:C.bottom+o4});continue}}const v=s.get(p)[0].id,w=b??n(v),T=r.get(b?f:v);c.set(h.id,{x:h.position.x+w.x-T.x,y:h.position.y+w.y-T.y})}return c.size===0?e:e.map(h=>{const p=c.get(h.id);return p?{...h,position:p}:h})}const IA=e=>e.type==="recapNote";function uze(e){const t=new Map;for(const s of e){if(s.note)continue;const o=t.get(s.sid);o?(o.l=Math.min(o.l,s.x),o.r=Math.max(o.r,s.x+s.cw)):t.set(s.sid,{l:s.x,r:s.x+s.cw})}let n=0,a=-1/0;for(const{l:s,r:o}of[...t.values()].sort((r,c)=>r.l-c.l))s>=a&&n++,a=Math.max(a,o);return n}function hze(e,t,n,a,s,o,r){const c=C=>Lu(C,a,o),l=C=>n.get(C)??t.get(C),u=C=>{const{w:A,h:E}=pl(C,a);return{cw:A,ch:E}},h=r!=null&&r.width>0&&r.height>0,p=Gk(e,C=>l(C.id)!=null&&!IA(C)),f=new Set;for(const[C,A]of p)A.every(E=>s.has(E.id)&&!n.has(E.id))&&f.add(C);const b=new Map,v=[];for(const C of e){const A=l(C.id);if(!A)continue;const{w:E,h:R}=c(C.id),z=wn(C);f.has(z)?IA(C)||(b.get(z)??b.set(z,[]).get(z)).push(C):v.push({sid:z,x:A.x,y:A.y,w:E,h:R,...u(C.id),note:IA(C)})}if(b.size===0||h&&v.length===0)return[];const w=fu,T=(C,A,E,R)=>v.some(z=>C<z.x+z.w+Ib&&z.x<C+E+Ib&&A<z.y+z.h+w&&z.y<A+R+w),y=a1,x=[];for(const C of[...b.keys()].sort()){const A=b.get(C);let E=1/0,R=1/0,z=-1/0,I=-1/0,_=-1/0,D=-1/0;for(const Y of A){const W=l(Y.id),{w:G,h:Q}=c(Y.id),{cw:J,ch:X}=u(Y.id);E=Math.min(E,W.x),R=Math.min(R,W.y),z=Math.max(z,W.x+G),I=Math.max(I,W.y+Q),_=Math.max(_,W.x+J),D=Math.max(D,W.y+X)}const L=I-R,P=A.some(Y=>{var W;return((W=Y.data)==null?void 0:W.kind)==="root"})?pb+r4:0,O=Math.max(z,_+po)-E,j=(Y,W)=>!T(Y-P,W,P+O,L),M=new Map;for(const Y of v)Y.note||M.set(Y.sid,Math.min(M.get(Y.sid)??1/0,Y.x));const F=[...new Set([...M.values()].map(Y=>Math.round(Y)))].sort((Y,W)=>Y-W),U=F.length?F:[E],H=[0,...v.map(Y=>Y.y+Y.h+w)].sort((Y,W)=>Y-W);let $=null;if(h){let Y=1/0,W=1/0,G=-1/0,Q=-1/0;for(const ee of v)Y=Math.min(Y,ee.x),W=Math.min(W,ee.y),G=Math.max(G,ee.x+ee.cw),Q=Math.max(Q,ee.y+ee.ch);const J=(ee,de)=>{const he=Math.max(G,ee+_-E)-Math.min(Y,ee-P),me=r.width/(he+po),be=r.height/(Math.max(Q,de+D-R)-Math.min(W,de));return[MR(Math.min(ag,me,be),Math.min(ag,r.width/he,be)),Math.min(me,be),Math.max(me,be)]},X=(ee,de)=>{for(let he=0;he<ee.length;he++){if(ee[he]>de[he]+1e-9)return!0;if(ee[he]<de[he]-1e-9)return!1}return!1},te=Math.round(G+po+y+P),K=[...new Set([...H,W])].sort((ee,de)=>ee-de);let V=null;for(const ee of uze(v)<qj?[...U,te]:U)for(const de of K){if(!j(ee,de))continue;const he=J(ee,de);(V===null||X(he,V))&&(V=he,$={x:ee,y:de})}$&&$.x===E&&$.y===R&&($=null)}else e:for(const Y of U)for(const W of H){if(W>=R)break;if(j(Y,W)){$={x:Y,y:W};break e}}if($){const Y=$.x-E,W=$.y-R;for(const G of A){const Q=l(G.id);t.set(G.id,{x:Q.x+Y,y:Q.y+W})}x.push(C)}for(const Y of A){const W=l(Y.id),{w:G,h:Q}=c(Y.id);v.push({sid:C,x:W.x,y:W.y,w:G,h:Q,...u(Y.id),note:!1})}if(P>0){const Y=E+($?$.x-E:0),W=R+($?$.y-R:0);v.push({sid:C,x:Y-P,y:W,w:pb,h:_j,cw:pb,ch:_j,note:!0})}}return x}function pze(e,t,n,a,s,o){const r=f=>Lu(f,a,s),c=new Map(e.map(f=>[f.id,wn(f)])),l=[],u=e.map(f=>({id:f.id,pos:n.get(f.id)??t.get(f.id)})).filter(f=>f.pos!=null).sort((f,b)=>f.pos.y-b.pos.y||f.pos.x-b.pos.x||f.id.localeCompare(b.id)),h=f=>(o==null?void 0:o.has(f))===!0&&!n.has(f);for(const{id:f,pos:b}of u){if(!h(f))continue;const{w:v,h:w}=r(f);l.push({x:b.x,y:b.y,w:v,h:w,sid:c.get(f)??"_default"})}const p=[];for(const{id:f,pos:b}of u){if(h(f))continue;const{w:v,h:w}=r(f),T=c.get(f)??"_default";if(n.has(f)){l.push({x:b.x,y:b.y,w:v,h:w,sid:T});continue}let y=b.y;for(let x=0;x<l.length+1;x++){const C=l.find(A=>{const E=A.sid===T?hb:Db,R=A.sid===T?hb:fu;return b.x<A.x+A.w+E&&A.x<b.x+v+E&&y<A.y+A.h+R&&A.y<y+w+R});if(!C)break;y=C.y+C.h+(C.sid===T?hb:fu)}y!==b.y&&(t.set(f,{x:b.x,y}),p.push(f)),l.push({x:b.x,y,w:v,h:w,sid:T})}return p}function gze(e,t,n,a,s,o=!1,r){const l=Db+1,u=fu+1,h=8,p=1.75,f=200,b=.7,v=.01,w=P=>Lu(P,a,r),T=P=>n.get(P)??t.get(P),y=Gk(e,P=>T(P.id)!=null),x=[],C=new Set,A=new Set,E=s.size===0;for(const P of[...y.keys()].sort()){const O=y.get(P);let j=1/0,M=1/0,F=-1/0,U=-1/0,H=!1;for(const G of O){const Q=T(G.id),{w:J,h:X}=w(G.id);j=Math.min(j,Q.x),M=Math.min(M,Q.y),F=Math.max(F,Q.x+J),U=Math.max(U,Q.y+X),n.has(G.id)&&(H=!0)}const $=F-j,Y=U-M;A.add(P);const W=s.get(P);W&&($>W.w+h||Y>W.h+h)&&C.add(P),s.set(P,{w:$,h:Y}),x.push({sid:P,members:O.map(G=>G.id),x:j,y:M,w:$,h:Y,anchored:H,mass:1})}for(const P of[...s.keys()])A.has(P)||s.delete(P);if(o||E)return[];let R=!1;for(let P=0;P<x.length&&!R;P++)for(let O=P+1;O<x.length;O++){const j=x[P],M=x[O];if(!(j.anchored&&M.anchored)&&Math.abs(j.x+j.w/2-(M.x+M.w/2))<(j.w+M.w)/2+l&&Math.abs(j.y+j.h/2-(M.y+M.h/2))<(j.h+M.h)/2+u){R=!0;break}}if(C.size===0&&!R)return[];if(C.size>0)for(const P of x)C.has(P.sid)&&(P.mass=8);else for(const P of x)P.mass=Math.max(1,P.w*P.h/(hc*Fl));const z=new Map(x.map(P=>[P.sid,P.x])),I=new Map(x.map(P=>[P.sid,P.y])),_=new Map(x.map(P=>[P.sid,Math.min(0,P.x)])),D=new Map(x.map(P=>[P.sid,Math.min(0,P.y)]));for(let P=0;P<f;P++){const O=new Map,j=new Map;let M=0;for(let F=0;F<x.length;F++)for(let U=F+1;U<x.length;U++){const H=x[F],$=x[U];if(H.anchored&&$.anchored)continue;const Y=H.x+H.w/2,W=H.y+H.h/2,G=$.x+$.w/2,Q=$.y+$.h/2,J=(H.w+$.w)/2+l-Math.abs(Y-G),X=(H.h+$.h)/2+u-Math.abs(W-Q);if(J<=0||X<=0)continue;const te=(_e,le)=>!_e.anchored&&!(le<0&&_e.x<=_.get(_e.sid)),K=(_e,le)=>!_e.anchored&&!(le<0&&_e.y<=D.get(_e.sid)),V=(_e,le,Re)=>{const ge=_e===le,Pe=ge?H.sid<$.sid?-1:1:Math.sign(_e-le);return Re(H,Pe)||Re($,-Pe)?Pe:ge&&(Re(H,-Pe)||Re($,Pe))?-Pe:0},ee=V(Y,G,te),de=V(W,Q,K),he=ee!==0,me=de!==0;if(!he&&!me)continue;const be=he&&(!me||J*p<X),[ie,ne,ke,Se]=be?[ee,J,O,te]:[de,X,j,K],ve=Se(H,ie),xe=Se($,-ie),Ee=H.mass,Ge=$.mass,Qe=ve?xe?Ge/(Ee+Ge):1:0,Je=xe?ve?Ee/(Ee+Ge):1:0,He=ne*b;ke.set(H.sid,(ke.get(H.sid)??0)+ie*He*Qe),ke.set($.sid,(ke.get($.sid)??0)-ie*He*Je),M+=He}for(const F of x)F.anchored||(F.x=Math.max(_.get(F.sid),F.x+(O.get(F.sid)??0)),F.y=Math.max(D.get(F.sid),F.y+(j.get(F.sid)??0)));if(M<v)break}const L=[];for(const P of x){const O=P.x-z.get(P.sid),j=P.y-I.get(P.sid);if(!(Math.abs(O)<1&&Math.abs(j)<1)){for(const M of P.members){if(n.has(M))continue;const F=t.get(M);F&&t.set(M,{x:F.x+O,y:F.y+j})}L.push(P.sid)}}return L}const mze=40,fze=80;function AU(e,t,n){const a=pl(e,t),s=Lu(e,t,n),o=s.w-a.w,r=mze+(t.has(e)?0:fze);return o>0?{w:a.w+Math.max(0,o+r-n1),h:s.h}:s}function bze(e,t,n,a,s,o,r=new Set){const c=new TU.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:o4,ranksep:n1,edgesep:30});const l=e.filter(R=>!s.has(R)),u=new Set(l);for(const R of l){const{w:z,h:I}=AU(R,a,o);c.setNode(R,{width:z,height:I})}for(const R of t)u.has(R.source)&&u.has(R.target)&&c.setEdge(R.source,R.target);TU.layout(c);const h=new Map;let p=1/0,f=1/0,b=-1/0,v=-1/0;for(const R of l){const z=c.node(R);if(!z)continue;const{w:I,h:_}=pl(R,a),D=AU(R,a,o),L=z.x-D.w/2,P=z.y-D.h/2;h.set(R,{x:L,y:P}),L<p&&(p=L),P<f&&(f=P),L+I>b&&(b=L+I),P+_>v&&(v=P+_)}if(Number.isFinite(p)&&Number.isFinite(f))for(const[R,z]of h)h.set(R,{x:z.x-p,y:z.y-f});const w=Number.isFinite(b)?b-p:0,T=Number.isFinite(v)?v-f:0;let y=1/0;for(const[R,z]of h)r.has(R)||(y=Math.min(y,z.x));Number.isFinite(y)||(y=0);const x=[...h].filter(([R])=>!r.has(R)).map(([R,z])=>({left:z.x,right:z.x+pl(R,a).w})),C=F1(x),A=x.length>0?Math.max(...x.map(R=>C.at(R.right)))-y:0;let E=null;for(const R of e){const z=s.get(R);if(!z)continue;const{w:I,h:_}=pl(R,a);E=E===null?{minX:z.x,minY:z.y,maxX:z.x+I,maxY:z.y+_}:{minX:Math.min(E.minX,z.x),minY:Math.min(E.minY,z.y),maxX:Math.max(E.maxX,z.x+I),maxY:Math.max(E.maxY,z.y+_)}}return{positions:h,width:w,height:T,cardLeft:y,packedTail:A,pinnedBox:E}}function kze(e,t,n){const a=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,r=n.lanes,c=Gk(e),l=new Map;for(const f of n.order??[])l.has(f)||l.set(f,l.size);const u=f=>l.get(f)??l.size,h=Array.from(c.keys()).sort((f,b)=>u(f)-u(b)||(f<b?-1:f>b?1:0)),p=new Set(e.filter(f=>f.type==="recapNote").map(f=>f.id));return h.map(f=>({sid:f,...bze(c.get(f).map(b=>b.id),t,a,o,s,r,p)}))}const K$=e=>e.reduce((t,n)=>Math.max(t,n.cardLeft),0),vze=e=>K$(e)+e.reduce((t,n)=>Math.max(t,n.width-n.cardLeft),0),wze=e=>vze(e)+po;function yze(e,t,n){const a=e.length,s=[e];if(!(t>0&&n>0)||a<2)return s;const o=[0];for(const b of e)o.push(o[o.length-1]+b.height+Zd);const r=e.map((b,v)=>{const w=[];for(let T=v,y=0,x=0;T<a;T++)y=Math.max(y,e[T].cardLeft),x=Math.max(x,e[T].width-e[T].cardLeft),w.push(y+x);return w}),c=e.map((b,v)=>{const w=[];for(let T=v,y=0;T<a;T++)w.push(y=Math.max(y,e[T].packedTail));return w}),l=b=>{let v=0,w=0,T=0;for(let x=0;x<b.length;x++){const C=b[x],A=x+1<b.length?b[x+1]:a;v+=r[C][A-1-C]+(x+1<b.length?po+a1:0),w+=c[C][A-1-C]+(x+1<b.length?ek:0),T=Math.max(T,o[A]-o[C]-Zd)}const y=yL(w,T,t,n);return{shows:MR(yL(v+po,T,t,n),y),bare:y,h:T}};let u=[0],h=l(u);if(h.bare>=Bte)return s;const p=1e-9,f=(b,v,w)=>{if(b.length>1){const x=l(b),C=Math.abs(x.shows-h.shows)<=p;(x.shows>h.shows+p||C&&(b.length<u.length||b.length===u.length&&x.h<h.h-p))&&(u=b,h=x)}if(b.length===qj)return;const T=b[b.length-1],y=qj-b.length;for(let x=T+1;x<a;x++){const C=v+c[T][x-1-T]+ek,A=Math.max(w,o[x]-o[T]-Zd);if(Math.min(ag,t/C,n/A)<h.shows-p)break;const E=(o[a]-o[x]-y*Zd)/y;Math.min(ag,n/Math.max(A,E))<h.shows-p||f([...b,x],C,A)}};return f([0],0,0),u.map((b,v)=>e.slice(b,v+1<u.length?u[v+1]:a))}function xze(e,t,n={}){const a=n.pinned??new Map,s=kze(e,t,n),o=yze(s,n.availableWidth??0,n.availableHeight??0),r=new Map;let c=0;for(const l of o){const u=wze(l),h=K$(l);let p=0;for(const{positions:f,height:b,cardLeft:v,pinnedBox:w}of l){const T=c+h-v;for(const[x,C]of f)r.set(x,{x:C.x+T,y:C.y+p});let y=p+b;w&&w.maxY>y&&w.minX<c+u&&c<w.maxX&&(y=w.maxY),p=y+Zd}c+=u+a1}return e.map(l=>{const u=a.get(l.id);if(u)return{...l,position:u};const h=r.get(l.id);return h?{...l,position:h}:l})}function Zr(e,t,n){return!t.has(e)||n.has(e)}function Cze(e,t,n,a){return!t.has(e)&&Zr(e,n,a)}function Sze(e,t,n){const a={x:0,y:0};return t.set(e,a),n.add(e),a}function $0(e,t,n,a){n.set(e,t),a.delete(e)}function $$(e,t,n,a){var c,l;const s=((c=a.get(e))==null?void 0:c.width)??pb,o=((l=a.get(e))==null?void 0:l.height)??_j,r=pl(t,a).h;return{x:n.x-r4-s,y:n.y+(r-o)/2}}function Tze(e,t,n,a,s){var r;const o=[];for(const c of e){if(c.type!=="recapNote"||a.has(c.id))continue;const l=(r=c.data)==null?void 0:r.parentId;if(!l||a.has(l)||Zr(l,t,n))continue;const u=$$(c.id,l,t.get(l),s),h=Zr(c.id,t,n)?void 0:t.get(c.id);h&&h.x===u.x&&h.y===u.y||($0(c.id,u,t,n),o.push(c.id))}return o}const Nze=e=>e.type==="recapNote",Aze=e=>{var t;return(t=e.data)==null?void 0:t.sessionId};function jze(e,t,n,a,s,o,r){if(r.size===0)return[];const c=new Set;for(const f of e){const b=Aze(f);b&&r.has(b)&&(c.add(wn(f)),r.delete(b))}if(c.size===0)return[];const l=f=>{const b=a.get(f.id)??(Zr(f.id,t,n)?void 0:t.get(f.id));if(!b)return;const{w:v,h:w}=Lu(f.id,s,o);return{x:b.x,y:b.y,w:v,h:w}},u=[];for(const f of e){if(c.has(wn(f)))continue;const b=l(f);b&&u.push(b)}const h=f=>u.some(b=>f.x<b.x+b.w+Db&&b.x<f.x+f.w+Db&&f.y<b.y+b.h+fu&&b.y<f.y+f.h+fu),p=[];for(const f of c){const b=e.filter(v=>wn(v)===f&&!Nze(v));if(b.some(v=>{const w=l(v);return w!=null&&h(w)})){for(const v of b)a.has(v.id)||(t.delete(v.id),n.delete(v.id));p.push(f)}}return p}const jU=new WeakMap;function Eze(e,t,n){let a=jU.get(e);(!a||a.revision!==e.revision||a.open!==t)&&(a={revision:e.revision,open:t,byId:new Map,branches:kre(e.agents.values()),groups:Ag(e.agents.values()),roots:Rze(e),twins:new Map,twinKey:""},jU.set(e,a));const s=ov(n?a.roots.filter(h=>n.has(h.id)):a.roots),o=[...s].map(([h,p])=>`${h}:${p}`).sort().join(`
|
|
147
147
|
`);o!==a.twinKey&&(a.byId.clear(),a.twins=s,a.twinKey=o);const{byId:r,branches:c,groups:l}=a,u=a.twins;return h=>{let p=r.get(h.id);if(!p){const f=h.kind==="root"?c.get(h.sessionId):void 0,b=h.kind==="root"?u.get(h.id):void 0;p={...h,onOpenContext:t,...f?{branch:f}:null,...b?{twin:b}:null},p.canvasSessionId=l.get(h.id),r.set(h.id,p)}return p}}function Rze(e){const t=[];for(const n of e.agents.values()){if(n.kind!=="root")continue;const{title:a,task:s}=Wl(n);t.push({id:n.id,title:a,task:s,startedAt:n.startedAt})}return t}function J$(e){const t=new Map;for(const n of e.agents.values())n.tools.length>0&&t.set(n.id,Math.min(4,n.tools.length));return t}function zze(e,t){const n=r=>wn(r),a=new Map;for(const r of e){const c=n(r),l=r.position.x+(r.width??hc),u=a.get(c);u?(u.minX=Math.min(u.minX,r.position.x),u.maxX=Math.max(u.maxX,l),u.minY=Math.min(u.minY,r.position.y)):a.set(c,{minX:r.position.x,maxX:l,minY:r.position.y})}const s=[];for(const[r,c]of[...a].sort((l,u)=>l[1].minX-u[1].minX)){const l=s[s.length-1];l&&c.minX<l.maxX?(l.maxX=Math.max(l.maxX,c.maxX),l.sessions.push({sid:r,top:c.minY})):s.push({maxX:c.maxX,sessions:[{sid:r,top:c.minY}]})}const o=new Map;for(const r of s)for(const{sid:c}of r.sessions.sort((l,u)=>l.top-u.top))o.set(c,o.size);return e.slice().sort((r,c)=>o.get(n(r))-o.get(n(c))||t(r)-t(c)||r.position.y-c.position.y||r.position.x-c.position.x)}function EU(e,t){return e.map(n=>{const a=t.get(n.id);return a?`${n.id}@${Math.round(a.x)},${Math.round(a.y)}`:n.id}).join("|")}function qze(e,t,n){const a=new Set;for(const s of e){const o=t.get(s.id),r=n.get(s.id);o&&r&&(Math.abs(o.x-r.x)>.5||Math.abs(o.y-r.y)>.5)&&a.add(wn(s))}return[...a]}function _ze(e,t){var a;let n=0;for(let s=t.parentId;s!=null&&n<e.agents.size;s=(a=e.agents.get(s))==null?void 0:a.parentId)n++;return n}function Lze(e,t,n,a,s,o,r,c,l,u,h,p,f,b,v,w,T,y,x,C,A=new Set,E){var te,K;const R=[],z=[],I=Eze(e,y,T);for(const V of e.agents.values()){if(!T.has(V.id))continue;const ee=V.exitAt!=null,de=w!=null&&!w.has(V.id),he=[ee?"rf-exiting":"",de?"rf-spotlit-out":"",v.has(V.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,me=o.get(V.id);if(R.push({id:V.id,type:"agent",position:{x:0,y:0},data:I(V),className:he,ariaLabel:D4(V,t,v.has(V.id)),...me?{width:me.width,height:me.height}:null}),V.parentId&&T.has(V.parentId)){const ke=ee,Se=v.size>0&&(v.has(V.id)||v.has(V.parentId)),ve=w!=null&&!w.has(V.id)&&!w.has(V.parentId),xe=V.state==="active"?2:1.5,Ee=Se?xe+1.5:xe,Ge=ke?0:ve?.12:1,Qe=["sess-edge",V.state==="active"?"sess-live":"sess-idle",ke?"rf-edge-exiting":"",Se?"rf-edge-selected":""].filter(Boolean).join(" ");z.push({id:`e:${V.parentId}->${V.id}`,source:V.parentId,target:V.id,ariaLabel:S("board.edge.aria",{label:V.label}),animated:V.state==="active"&&!ke,type:"smoothstep",style:{strokeWidth:`calc(${Ee}px * var(--edge-k, 1))`,opacity:Ge,transition:"var(--edge-transition)",...ke?{"--edge-transition":"opacity var(--dur-exit) var(--ease)"}:null},className:Qe})}const be=V.kind==="root"?Qle(V):null,ie=(be==null?void 0:be.note)??null,ne=be?be.key:null;if(be&&ne&&!Hle(ne)){const ke=N1(V.id),Se=o.get(ke);R.push({id:ke,type:"recapNote",position:{x:0,y:0},data:{sessionId:V.sessionId,canvasSessionId:I(V).canvasSessionId,parentId:V.id,note:ie,plan:be.plan,noteKey:ne},className:de?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:ie?ie.kind==="recap"?S("board.note.recapFor",{label:V.label}):`${V.label}: ${Su(ie.kind)}`:S("board.note.planFor",{label:V.label}),...Se?{width:Se.width,height:Se.height}:null}),z.push({id:`e:recap:${V.id}`,source:ke,target:V.id,type:"recapTie",className:"recap-edge",ariaLabel:S("board.edge.aria",{label:V.label}),focusable:!1})}}const _=J$(e),D=C.size>0&&!(l&&x),L=!D&&R.some(V=>C.has(V.id));D||C.clear();const P=R.filter(V=>V.data.provider==="codex"&&V.data.parentId).map(V=>`${V.id}:${wn(V)}:${V.data.parentId}`).sort().join("|"),O=`${f}${P?`#codex:${P}`:""}#lanes:${Hte(_)}${D?"#held":""}`,j=!D&&b.current.endsWith("#held")?EU(R,h):null,M=new Set(R.filter(V=>V.type==="recapNote").map(V=>V.id));for(const V of Array.from(h.keys()))x&&Vle(V)&&!M.has(V)&&!s.has(V)&&(h.delete(V),p.delete(V));x&&jze(R,h,p,s,o,_,A);let F=!1,U=null;if(E&&!E.flowed.current&&l&&x){if(L)E.flowed.current=!0;else if(!u){E.flowed.current=!0,F=!0,U=new Map;for(const V of R){if(s.has(V.id))continue;const ee=Zr(V.id,h,p)?void 0:h.get(V.id);ee&&U.set(V.id,{...ee}),h.delete(V.id),p.delete(V.id)}}}const H=R.filter(V=>Cze(V.id,s,h,p));if(H.length>0||O!==b.current){if(H.length>0){for(const ee of H)C.delete(ee.id);const V=dze(xze(R,z,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:a,lanes:_,order:E==null?void 0:E.order()}),s,ee=>Zr(ee,h,p)?void 0:h.get(ee),ee=>Lu(ee,o,_));for(const ee of V)Zr(ee.id,h,p)&&$0(ee.id,ee.position,h,p);F||hze(R,h,s,o,new Set(H.filter(ee=>ee.type!=="recapNote").map(ee=>ee.id)),_,{width:n,height:a});for(const ee of H){if(ee.type!=="recapNote")continue;const de=(te=ee.data)==null?void 0:te.parentId;if(!de)continue;const he=s.get(de)??(Zr(de,h,p)?void 0:h.get(de));he&&$0(ee.id,$$(ee.id,de,he,o),h,p)}}pze(R,h,s,o,_,D?C:void 0),b.current=O}D||Tze(R,h,p,s,o);const $=gze(R,h,s,o,r,!l||u||F,_),Y=U?[...new Set([...qze(R,U,h),...$])]:$;Y.length>0&&c(Y);const W=j!==null&&j!==EU(R,h);(F||Y.length>0||W)&&((K=E==null?void 0:E.onMoved)==null||K.call(E));const G=x0e(e.agents.values());x&&np(h,G),np(p,G),np(A,G),x&&np(s,G),np(o,y0e(e.agents.values()));const Q=[];let J=!1;for(const V of R){let ee=s.get(V.id)??h.get(V.id);ee||(ee=Sze(V.id,h,p),J=!0),Q.push({...V,position:ee})}return J&&(b.current=""),{nodes:zze(Q,V=>{if(V.type==="recapNote")return-1;const ee=e.agents.get(V.id);return ee?_ze(e,ee):0}),edges:z}}function Pze(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Oze(e,t,n){var r;if(e.length===0)return null;const a=Pze(e),s=t?a.findIndex(c=>c.id===t):-1,o=s===-1?n===1?0:a.length-1:(s+n+a.length)%a.length;return((r=a[o])==null?void 0:r.id)??null}const Mze=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function Ize(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Mze.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const Dze=new Set(["","BODY","HTML","#DOCUMENT"]);function Fze(e){return!e||bl(e)?!1:!Dze.has(String(e.tagName??"").toUpperCase())}const mz="react-flow__node";function Zv(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,mz))===!0}function Bze(e){try{return document.querySelector(`.${mz}[data-id="${CSS.escape(e)}"]`)}catch{return null}}function Uze(e){var a;const t=(a=e.closest(".react-flow"))==null?void 0:a.getBoundingClientRect(),n=e.getBoundingClientRect();return!t||n.width===0?!1:n.right>t.left&&n.left<t.right&&n.bottom>t.top&&n.top<t.bottom}function fz(e){try{const t=document.querySelector(`.${mz}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let mo=null,tu=null;const J0=new Set,Y0=()=>{for(const e of J0)e()},Wze=e=>(J0.add(e),()=>{J0.delete(e)}),RU=()=>mo,Hze=90;function Y$(e){!tu||e!=null&&tu.at.id!==e||(clearTimeout(tu.timer),tu=null)}function bz(e,t,n="pointer"){Y$();const a={id:e,anchor:t,by:n};if(mo||n==="focus"){mo=a,Y0();return}tu={at:a,timer:setTimeout(()=>{tu=null,mo=a,Y0()},Hze)}}function Gze(){return(mo==null?void 0:mo.id)??null}function Zs(e){Y$(e),!(!mo||e!=null&&mo.id!==e)&&(mo=null,Y0())}function Vze({agentFor:e,recapFor:t,labelFor:n,peers:a,bounds:s}){const o=m.useSyncExternalStore(Wze,RU,RU),r=o?e(o.id):void 0,c=o&&!r?t(o.id):void 0,l=o!=null&&(!r&&!c||!o.anchor.isConnected);return m.useEffect(()=>{l&&o&&Zs(o.id)},[l,o]),!o||l?null:r?i.jsx($ze,{a:r,anchor:o.anchor,parentLabel:r.parentId?n(r.parentId):void 0,peers:r.kind==="root"?a():[],bounds:s},o.id):c?i.jsx(Kze,{r:c,anchor:o.anchor,bounds:s},o.id):null}function Z$(e,t){const n=m.useRef(null),a=m.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;s.style.maxHeight="";const o=cv(e.getBoundingClientRect(),{width:s.offsetWidth,height:s.offsetHeight},t());s.style.top=`${o.top}px`,s.style.left=`${o.left}px`,s.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,s.dataset.side=o.side},[e,t]);return m.useLayoutEffect(()=>{a()}),n}function Kze({r:e,anchor:t,bounds:n}){var h;const a=se(),s=Z$(t,n),o=xo(3e4),r=e.note,c=yo(e.plan),l=(r==null?void 0:r.kind)==="recap",u=Yb((r==null?void 0:r.at)??((h=e.plan)==null?void 0:h.at)??o,o);return $t.createPortal(i.jsxs("div",{ref:s,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",children:[i.jsxs("div",{className:"node-peek-head",children:[i.jsxs("span",{className:"recap-peek-mark",children:[i.jsx(n0,{recap:l}),r?Su(r.kind):a("insights.peek.plan")]}),i.jsx("span",{className:"node-peek-time",title:u.title,children:u.label})]}),e.sessionLabel&&i.jsx("div",{className:"node-peek-kind",children:i.jsxs("span",{children:[r?`${av(r)} · `:"",e.sessionLabel]})}),r&&i.jsx("p",{className:"recap-peek-text",children:r.text}),(r==null?void 0:r.reply)&&i.jsx("p",{className:"recap-peek-text",children:a("insights.peek.reply",{reply:r.reply})}),c&&e.plan&&i.jsxs("p",{className:"recap-peek-text recap-peek-plan",children:[a("insights.peek.planLine",{line:c1(c)}),c.allDone?"":`
|
|
148
|
-
${Kk(e.plan.items)}`]}),i.jsx("p",{className:"node-peek-hint",children:a("insights.peek.hintNote")})]}),document.body)}function $ze({a:e,anchor:t,parentLabel:n,peers:a,bounds:s}){const o=se(),r=Z$(t,s),c=xo(1e3),l=e.kind==="root"?Wl(e):null,u=(l==null?void 0:l.title)??e.label,h=l?iv(l):"",p=Eg(e,o),f=e.toolErrorCount??0,b=e.tools.filter(A=>!A.endedAt).length,v=fs(e,c).total,w=e.usage.inputTokens+e.usage.outputTokens,T=e.kind==="root"&&bs(e.waiting),y=L4(e),x=e.kind==="root"?o("insights.peek.session"):n?o("insights.peek.subagentOf",{parent:n}):o("insights.peek.subagent"),C=[o("insights.peek.tools",{count:e.toolCount,n:e.toolCount}),b>0?o("insights.peek.inflight",{n:b}):null,w>0?o("insights.peek.tok",{n:Yt(w)}):null,v>0?`${Ut(v)}${yu(e,c)>0?"+":""}`:null].filter(Boolean).join(" · ");return $t.createPortal(i.jsxs("div",{ref:r,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[i.jsxs("div",{className:"node-peek-head",children:[i.jsx("span",{className:"node-peek-name",title:u,children:u}),i.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",Cu(e.startedAt,e.endedAt,c)]})]}),i.jsxs("div",{className:"node-peek-kind",children:[i.jsxs("span",{className:"node-peek-state","data-kind":p.mark,children:[p.mark==="alert"?i.jsx(ic,{}):i.jsx(yi,{kind:p.mark}),p.word]}),i.jsx("span",{children:x}),e.model?i.jsx("span",{children:Rg(e.model,e.effort)}):null]}),h&&i.jsx("p",{className:"node-peek-title",title:h,children:h}),e.kind==="root"&&e.waiting&&i.jsxs("p",{className:`node-peek-wait${T?" warn":""}`,children:[T&&i.jsx(ic,{}),i.jsxs("span",{className:"node-peek-said",title:Hj(e.waiting),children:[i.jsx("span",{className:"node-peek-since",children:i.jsx("b",{children:Cu(e.waiting.since,void 0,c)})}),Hj(e.waiting)]})]}),y&&i.jsxs("p",{className:"node-peek-blind",children:[i.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),y.label]}),i.jsxs("p",{className:"node-peek-facts",children:[C,f>0&&i.jsxs("span",{className:"node-peek-failed",children:[" · ",o("insights.peek.failed",{n:f})]})]}),e.kind==="root"&&i.jsx("p",{className:"node-peek-facts",children:Tu(e.startedAt,e.sessionId,a,c)}),e.branch&&e.branch.total>0&&i.jsx("p",{className:"node-peek-branch",children:x4(e.branch)}),i.jsx("p",{className:"node-peek-hint",children:o("insights.peek.hint")})]}),document.body)}function Jze(e){const t=e.minZoom??qAe,n=e.maxZoom??_Ae,a=e.fill??.9,s=e.insets.left,o=e.insets.top,r=Math.max(1,e.pane.width-e.insets.left-e.insets.right),c=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),l=e.context,u=e.anchor,h=Math.min(r/Math.max(1,l.width),c/Math.max(1,l.height))*a,p=Math.max(t,Math.min(n,h)),f=(b,v,w,T,y,x)=>{let C=b+(v-T*p)/2-w*p;const A=y*p+C,E=(y+x)*p+C;return x*p<=v?A<b?C+=b-A:E>b+v&&(C-=E-(b+v)):C+=b-A,C};return{x:f(s,r,l.x,l.width,u.x,u.width),y:f(o,c,l.y,l.height,u.y,u.height),zoom:p}}const zU=.5;function Yze(e){const{view:t,card:n}=e,a=e.minZoom??qv,s=t.zoom<a,o=s?a:t.zoom;let r=t.x,c=t.y;if(s){const C=n.x+n.width/2,A=n.y+n.height/2;r=C*t.zoom+t.x-C*o,c=A*t.zoom+t.y-A*o}const l=s?null:e.note??null,u=e.insets.left,h=e.insets.top,p=e.pane.width-e.insets.right,f=e.pane.height-e.insets.bottom,b=l?X$([n,l]):n,w=(C=>C.width*o<=p-u&&C.height*o<=f-h)(b)?b:n,T=(C,A,E,R)=>A-C>R-E||C<E-zU?E-C:A>R+zU?R-A:0,y=T(w.x*o+r,(w.x+w.width)*o+r,u,p),x=T(w.y*o+c,(w.y+w.height)*o+c,h,f);return!s&&y===0&&x===0?null:{x:r+y,y:c+x,zoom:o}}function X$(e){let t=1/0,n=1/0,a=-1/0,s=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),a=Math.max(a,o.x+o.width),s=Math.max(s,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:a-t,height:s-n}:null}const xk={usage:!1,machine:!1};function qU(e,t,n,a){return e.mode!=="board"?e:t?{...e,folded:!0,unfold:n}:a?{...e,refold:a}:e}function Zze(e,t){if(!t.on)return xk;if(!t.wasOn)return{usage:t.open.usage,machine:t.open.machine};const n=a=>e[a]&&!(t.open[a]&&!t.wasOpen[a]);return{usage:n("usage"),machine:n("machine")}}function Xze(e,t){const[n,a]=m.useState(xk),s=m.useRef({on:!1,open:xk});m.useLayoutEffect(()=>{const c=s.current,l={usage:t.usage,machine:t.machine};s.current={on:e,open:l},a(u=>{const h=Zze(u,{on:e,wasOn:c.on,open:l,wasOpen:c.open});return h.usage===u.usage&&h.machine===u.machine?u:h})},[e,t.usage,t.machine]);const o=m.useCallback(c=>a(l=>l[c]?{...l,[c]:!1}:l),[]),r=m.useCallback(c=>{s.current.on&&a(l=>l[c]?l:{...l,[c]:!0})},[]);return{folds:n,unfold:o,fold:r,on:e}}function Pt(e){const t=m.useRef(e);return t.current=e,t}const Z0=80,X0=.86;function Q$(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;const a=':not(.leaving):not([data-fold="inspector"])';for(const s of document.querySelectorAll(`.sysdetail${a}, .usage-panel${a}`)){const o=s.getBoundingClientRect();o.width>0&&o.left>t.left&&(n=Math.min(n,o.left))}return Math.max(0,t.right-n)}function Qze({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:a,usagePanelOpen:s,detailShown:o,folds:r=xk}){const[c,l]=m.useState(0);m.useEffect(()=>{const f=Q$(e.current);l(b=>Math.abs(b-f)>40?f:b)},[n,a,s,o,t.w,r.usage,r.machine]);const u=Pt(c),h=t.w>0?Math.max(0,(t.w-c-Z0*2)*X0):0,p=t.h>0?Math.max(0,(t.h-Z0*2)*X0):0;return{railInsetRef:u,availableWidth:h,availableHeight:p}}const eqe=1,Q0=.2,tqe=qv;function nqe(e,{pane:t,rail:n,bodyPx:a=zv,floor:s=Q0}){const o=Z0,r=eqe,c=Q0,l=X0;if(e.length===0)return null;const u=(R,z=0)=>{const I=Math.min(...R.map(P=>P.left))-z,_=Math.min(...R.map(P=>P.top))-z,D=Math.max(...R.map(P=>P.right))+z-I,L=Math.max(...R.map(P=>P.bottom))+z-_;return{minX:I,minY:_,w:D,h:L}},h=u(e),p=e.filter(R=>R.type==="agent"),f=p.length>0?u(p,oo):h;if(!(h.w>0&&h.h>0)||!(f.w>0&&f.h>0))return null;const b=aqe(p,f),v=(R,z)=>Math.max(c,Math.min(r,(t.width-n-o*2)/(R.w+z)*l,(t.height-o*2)/R.h*l)),w=Math.max(s,MR(v(h,po),v(b,0),a)),T=w*a>=OR,{minX:y,minY:x,h:C}=T?h:f,A=T?h.w+po:b.w,E=Math.max(0,t.width-n-o*2-A*w);return{x:o+E/2-y*w,y:(t.height>t.width-n?o:Math.max(o,(t.height-C*w)/2))-x*w,zoom:w}}function aqe(e,t){if(e.length===0)return t;const n=F1(e),a=Math.max(...e.map(s=>s.right));return{...t,w:n.at(a)+oo-t.minX}}const Zf=oo;function e8(e){const t=new Map;for(const a of e){const s=a.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;const o=a.width,r=a.height;if(o==null||r==null)continue;const c=a.position.x,l=a.position.y,u=c+o,h=l+r,p=t.get(wn(a));p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,l),p.maxX=Math.max(p.maxX,u),p.maxY=Math.max(p.maxY,h)):t.set(wn(a),{minX:c,minY:l,maxX:u,maxY:h})}const n=[];for(const[a,s]of t){const o=s.maxX-s.minX+Zf*2,r=s.maxY-s.minY+Zf*2;n.push({id:`group:${a}`,type:ig,position:{x:s.minX-Zf,y:s.minY-Zf},data:{sessionId:a,w:o,h:r},width:o,height:r,style:{width:o,height:r},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return n}const _U=1e-6;function Up(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function LU(e,t,n){return Math.abs(e[2]-t[2])<=_U*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=_U*n}function sqe(e,t){const n=t[2]/e[2];return a=>[e[0]+(t[0]-e[0])*a,e[1]+(t[1]-e[1])*a,e[2]*n**a]}function iqe(e,t,n){const a=e(0),s=e(.5),o=e(1);if(!Up(a)||!Up(s)||!Up(o))return!1;const r=Math.max(t[2],n[2]);return LU(a,t,r)&&LU(o,n,r)}function oqe(e){return(t,n)=>{const a=e(t,n),s=iqe(a,t,n)?a:sqe(t,n);let o=Up(t)?t:n;return r=>{const c=s(r);return Up(c)&&(o=c),o}}}function rqe(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const PU=new WeakSet;function DA(e,t){return e.transition().duration(t).ease(rbe)}function cqe(e){var t;(t=e==null?void 0:e.interrupt)==null||t.call(e)}const lqe=420;function dqe(){const e=Sg(),t=qn(),n=m.useCallback((E,R)=>{if(!rqe(E))return;const{d3Zoom:z,d3Selection:I}=t.getState(),_=I==null?void 0:I.property("__zoom");if(bp({durationMs:R,documentHidden:document.hidden})){if(z&&I&&_&&_.k>0&&E.zoom>0){z.transform(DA(I,R),_.scale(E.zoom/_.k).translate((E.x-_.x)/E.zoom,(E.y-_.y)/E.zoom));return}e.setViewport(E,{duration:R});return}if(z&&I&&_&&_.k>0&&E.zoom>0){z.transform(I,_.scale(E.zoom/_.k).translate((E.x-_.x)/E.zoom,(E.y-_.y)/E.zoom));return}e.setViewport(E,{duration:0})},[e,t]);m.useEffect(()=>{const E=R=>{!R||PU.has(R)||(PU.add(R),R.interpolate(oqe(R.interpolate())))};return E(t.getState().d3Zoom),t.subscribe(R=>E(R.d3Zoom))},[t]);const a=m.useRef(null),s=m.useRef(0),o=m.useRef(0),r=m.useRef(null),c=m.useRef(null),l=m.useRef(null),u=m.useRef(!1),h=m.useCallback((E,R)=>{const z=++s.current;return r.current=null,c.current=null,o.current=Date.now(),n(E,R),a.current=bp({durationMs:R,documentHidden:document.hidden})?{target:E,until:Date.now()+R+60}:null,z},[n]),p=m.useRef(()=>{}),f=m.useCallback((E=Nl,R=u.current?"all":"auto")=>{try{const z=document.querySelector(".canvas-wrap"),I=Array.from(document.querySelectorAll(".react-flow__node")).filter($=>$.offsetWidth>0);if(!z||I.length===0)return;const _=fg(z),D=e.getViewport();if(!Number.isFinite(D.zoom)||D.zoom<=0)return;const L=l.current,P=new Map((L?[...e8(L),...L]:e.getNodes()).map($=>[$.id,$])),O=I.flatMap($=>{const Y=P.get($.dataset.id??"");if(!Y)return[];const W=Y.positionAbsolute??Y.position,G=Y.width??$.offsetWidth,Q=Y.height??$.offsetHeight;return G>0&&Q>0?[{left:W.x,right:W.x+G,top:W.y,bottom:W.y+Q,type:Y.type}]:[]}),j=Q$(z),M=gK(nR[aR()]),F=nqe(O,{pane:{width:_.width,height:_.height},rail:j,bodyPx:M,floor:R==="all"?Q0:tqe});if(!F)return;const{zoom:U}=F,H=h(F,E);r.current=()=>p.current(E,R),window.setTimeout(()=>{var $;try{if((($=a.current)==null?void 0:$.target)===F&&(a.current=null),s.current!==H)return;const Y=e.getViewport();(Math.abs(Y.zoom-U)>.01||Math.abs(Y.x-F.x)>2||Math.abs(Y.y-F.y)>2)&&n(F,0)}catch{}},E+60)}catch{}},[e,n,h]);p.current=f;const b=m.useCallback(()=>{u.current=!0,f(Nl,"all")},[f]),v=m.useCallback(()=>{u.current=!1},[]);m.useEffect(()=>{const E=()=>{if(!document.hidden)return;const R=a.current;if(a.current=null,!(!R||Date.now()>R.until)){try{n(R.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",E),()=>document.removeEventListener("visibilitychange",E)},[n]);const w=m.useCallback(()=>{a.current&&(a.current=null,r.current=null,s.current+=1,o.current=0,cqe(t.getState().d3Selection))},[t]),T=m.useCallback(E=>{u.current=!1;const{d3Zoom:R,d3Selection:z,minZoom:I,maxZoom:_}=t.getState(),D=z==null?void 0:z.property("__zoom");if(!R||!z||!D||!(D.k>0))return;const L=c.current&&c.current.until>Date.now()?c.current.zoom:D.k,P=Math.max(I??0,Math.min(_??1/0,E(L)));!Number.isFinite(P)||!(P>0)||(s.current+=1,r.current=null,a.current=null,o.current=0,bp({durationMs:qy,documentHidden:document.hidden})?(c.current={zoom:P,until:Date.now()+qy+60},R.scaleTo(DA(z,qy),P)):(c.current=null,R.scaleTo(z,P)))},[t]),y=m.useCallback(E=>{if(!Number.isFinite(E)||E===0)return;const{d3Zoom:R,d3Selection:z}=t.getState(),I=z==null?void 0:z.property("__zoom");if(!R||!z||!I||!(I.k>0))return;R.transform(z,I.translate(E/I.k,0));const _=c.current,D=_?_.until-60-Date.now():0;_&&D>0&&bp({durationMs:D,documentHidden:document.hidden})&&R.scaleTo(DA(z,D),_.zoom)},[t]),x=m.useCallback(E=>T(R=>R*E),[T]),C=m.useCallback(()=>T(()=>1),[T]);m.useEffect(()=>{let E;const R=()=>{!a.current||!r.current||(window.clearTimeout(E),E=window.setTimeout(()=>{var z;a.current&&((z=r.current)==null||z.call(r))},100))};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),window.clearTimeout(E)}},[]);const A=m.useCallback(()=>e.getViewport(),[e]);return{applyViewport:n,moveCamera:h,fitLeft:f,fitAll:b,releaseFitAll:v,panBy:y,boardRef:l,currentViewport:A,cameraEpochRef:s,lastFitTimeRef:o,takeOver:w,zoomBy:x,zoomReset:C}}const FA=Nl,OU=e=>({top:56,left:32,bottom:56,right:e+32});function uqe({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:a,shownRef:s,lodRef:o,railInsetRef:r,moveCamera:c,currentViewport:l,disableAutoFit:u,lastFocusRef:h,focusAgentRef:p,selectAgent:f,primarySelectedIdRef:b,onLand:v}){const w=m.useCallback(C=>{const A=e.current,E=t.current.agents.get(C);if(!A||!E)return;const R=J$(t.current),z=(O,j)=>{const M=n.current.get(O.id);if(!M)return null;const F=j&&R.has(O.id)?lqe:0;return{x:O.position.x,y:O.position.y,width:M.width+F,height:M.height}},I=a.current.find(O=>O.id===C),_=I?z(I,!1):null;if(!_)return;const D=[];for(const O of a.current){if(O.type!=="agent"&&O.type!=="recapNote"||wn(O)!==wn(I))continue;const j=z(O,O.type==="agent");j&&D.push(j)}const L=fg(A),P=Jze({pane:{width:L.width,height:L.height},insets:OU(r.current),context:X$(D)??_,anchor:_});Zs(),u(),h.current={id:C,at:Date.now()},c(P,FA)},[c,u]),T=m.useCallback(C=>{const A=e.current;if(!A||!t.current.agents.get(C))return;const E=s.current,R=O=>{const j=n.current.get(O.id);return j?{x:O.position.x,y:O.position.y,width:j.width,height:j.height}:null},z=E.find(O=>O.id===C),I=z?R(z):null;if(!z||!I)return;const _=wn(z),D=o.current==="detail"?E.find(O=>O.type==="recapNote"&&wn(O)===_):void 0,L=fg(A),P=Yze({view:l(),pane:{width:L.width,height:L.height},insets:OU(r.current),card:I,note:D?R(D):null,minZoom:qv});Zs(),h.current={id:C,at:Date.now(),reveal:!0},P&&(u(),c(P,FA))},[c,l,u]);p.current=C=>{var A;return((A=h.current)!=null&&A.reveal?T:w)(C)};const y=m.useCallback(C=>{const A=a.current.filter(I=>I.type==="agent"),E=Oze(A.map(I=>({id:I.id,x:I.position.x,y:I.position.y})),b.current,C),R=E?A.find(I=>I.id===E):void 0;if(!R)return!1;const z=Zv(document.activeElement);return f(R.id,!1),window.setTimeout(()=>{try{T(R.id)}catch{}z&&fz(R.id)},30),!0},[f,T]),x=m.useCallback(C=>{f(C,!1),v==null||v(C),window.setTimeout(()=>{try{T(C)}catch{}window.setTimeout(()=>V0e(C),K0e(FA))},60)},[f,T,v]);return{focusAgent:w,revealAgent:T,stepAgent:y,focusSession:x}}function hqe({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:a}){const s=m.useCallback(u=>{const h=e.current.find(p=>p.id===u&&p.type==="agent");return h?h.data:void 0},[]),o=m.useCallback(u=>{const h=t.current.agents.get(u);return h?bu(h):void 0},[]),r=m.useCallback(()=>{const u=[];for(const h of e.current){const p=h.type==="agent"?h.data:void 0;(p==null?void 0:p.kind)==="root"&&u.push(p.sessionId)}return u},[]),c=m.useCallback(u=>{const h=e.current.find(f=>f.id===u&&f.type==="recapNote");if(!h)return;const p=h.data;return{note:p.note,plan:p.plan,sessionLabel:o(p.parentId)}},[]),l=m.useCallback(()=>{var p;const u=(p=n.current)==null?void 0:p.getBoundingClientRect(),h=document.documentElement;return u?{width:u.right-a.current,height:u.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekPeers:r,peekRecap:c,peekBounds:l}}function pqe(e){const t=new Set(e.pins),n=new Map,a=new Map;for(const[s,o]of e.positions)n.set(s,o),t.has(s)&&a.set(s,o);return{positions:n,pinned:a,restored:new Set(n.keys())}}function MU(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function gqe(e){const t={positions:[],pins:[]};if(!e)return t;let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!="object")return t;if(!("v"in n)){const s=MU(n);return{positions:s,pins:s.map(([o])=>o)}}const a=n;return{positions:MU(a.positions),pins:Array.isArray(a.pins)?a.pins:[]}}function mqe(e,t){const n={};for(const[a,s]of e)n[a]=s;for(const[a,s]of t)n[a]=s;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function fqe(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return!(typeof(t==null?void 0:t.width)=="number"&&typeof(t==null?void 0:t.height)=="number")||!(t.width>0&&t.height>0)?null:{width:t.width,height:t.height}}const $g="agent-dag.layout",Jg="agent-dag.layoutFrame",Yg="agent-dag.viewport";function bqe(){return gqe(gt($g))}function Wp(e,t){yt($g,mqe(e,t))}function kqe(){return fqe(gt(Jg))}function t8(e){yt(Jg,JSON.stringify(e))}function vqe(){return Vre(gt(Yg))}function wqe(e){yt(Yg,JSON.stringify(e))}function yqe(){return{layout:gt($g),frame:gt(Jg),viewport:gt(Yg)}}function xqe(e){const t=(n,a)=>a===null?Ja(n):yt(n,a);t($g,e.layout),t(Jg,e.frame),t(Yg,e.viewport)}function n8(){Ja($g),Ja(Yg),Ja(Jg)}const Ck=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function Cqe(e,t,n){return{positions:Ck(e.positions),pinned:Ck(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function Sqe(e,t){t.positions.clear();for(const[n,a]of Ck(e.positions))t.positions.set(n,a);t.pinned.clear();for(const[n,a]of Ck(e.pinned))t.pinned.set(n,a);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const Tqe=400,IU=7e3+Tqe,Nqe=2e3,Aqe=(e=S)=>e("board.rearrange.said"),DU=(e=S)=>e("board.rearrange.restored"),jqe={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function Eqe(e,t=jqe){let n=null,a=null,s=0,o=IU;const r=new Set,c=()=>{a!==null&&t.clear(a),a=null},l=()=>{c(),!(n===null||r.size>0)&&(s=t.now()+o,a=t.set(()=>{a=null,u()},o))};function u(){c(),r.clear(),n!==null&&(n=null,e(!1))}return{open(h){const p=n===null;n=h,o=IU,l(),p&&e(!0)},take(){const h=n;return u(),h},close:u,hold(h){n!==null&&(r.size===0&&a!==null&&(o=Math.max(0,s-t.now()),c()),r.add(h))},release(h){!r.delete(h)||r.size>0||n===null||(o=Math.max(o,Nqe),l())},get isOpen(){return n!==null},get snapshot(){return n}}}function Rqe(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function zqe({fitLeft:e,moveCamera:t,currentViewport:n}){const a=m.useState(()=>pqe(bqe()))[0],s=m.useRef(a.pinned),o=m.useRef(a.positions),r=m.useRef(new Set),c=m.useRef(new Set),l=m.useRef(""),[u,h]=m.useState(0),p=m.useRef(!1),f=m.useState(kqe)[0],b=m.useRef(f),[v,w]=m.useState(!1),[T,y]=m.useState(""),x=m.useState(()=>Eqe(L=>{w(L),L||y(P=>P===DU()?P:"")}))[0];m.useEffect(()=>()=>x.close(),[x]),m.useEffect(()=>{if(typeof document>"u")return;const L=()=>document.hidden?x.hold("hidden"):x.release("hidden");return document.addEventListener("visibilitychange",L),()=>document.removeEventListener("visibilitychange",L)},[x]);const C=m.useRef(null),A=()=>({positions:o.current,pinned:s.current,provisional:r.current,layoutSig:l}),E=m.useCallback(()=>{x.open(x.snapshot??Cqe(A(),yqe(),n())),y(Aqe()),s.current.clear(),o.current.clear(),l.current="",n8(),h(L=>L+1),C.current!=null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{C.current=null,Wp(o.current,s.current),b.current&&t8(b.current),e()},80)},[e,n,x]),R=m.useCallback(()=>{const L=x.take();return L?(C.current!=null&&window.clearTimeout(C.current),C.current=null,Sqe(L,A()),xqe(L.stored),h(P=>P+1),L.viewport&&t(L.viewport,Nl),y(DU()),!0):!1},[t,x]),z=m.useCallback(()=>x.close(),[x]),I=m.useCallback(L=>x.hold(L),[x]),_=m.useCallback(L=>x.release(L),[x]);return{restoredLayout:a,pinnedRef:s,positionsRef:o,provisionalRef:r,returningRef:c,lastLayoutSigRef:l,layoutEpoch:u,setLayoutEpoch:h,lastLayoutFrameRef:b,flowedRef:p,handleRelayout:E,rearrangeUndo:{open:v,said:T,undo:R,dismiss:z,hold:I,release:_}}}function qqe(e,t){const{positionsRef:n,pinnedRef:a}=t,s=m.useRef(null),o=m.useCallback(()=>{s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{Wp(n.current,a.current)},1500)},[]);return m.useEffect(()=>(o(),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e]),{saveSoon:o}}function _qe({settled:e,dragging:t,availableWidth:n,availableHeight:a,layout:s,camera:o,lastFocusRef:r,focusAgentRef:c,autoFitDisabledRef:l}){const{lastLayoutFrameRef:u}=s,{fitLeft:h,cameraEpochRef:p}=o;m.useEffect(()=>{if(!e||t)return;const f={width:n,height:a};if(!(f.width>0&&f.height>0))return;const b=u.current;if(u.current=f,t8(f),!b||b.width===f.width&&b.height===f.height)return;const v=r.current&&Date.now()-r.current.at<1500?r.current.id:null,w=p.current,T=window.setTimeout(()=>{var y;p.current===w&&(l.current?v&&((y=r.current)==null?void 0:y.id)===v&&c.current(v):h())},80);return()=>window.clearTimeout(T)},[n,a,e,t,h])}function Lqe(e,t=Date.now()){const n=Ag(e.agents.values()),a=new Map;for(const r of e.agents.values())r.kind==="root"&&!a.has(r.sessionId)&&a.set(r.sessionId,n.get(r.id)??r.sessionId);const s=[],o=new Set;for(const r of uv(e,t)){const c=a.get(r.sessionId)??r.sessionId;o.has(c)||(o.add(c),s.push(c))}return s}function Pqe(e,t,n,a,s){const o=[];for(const r of e)!Ng(r,t)||n.has(r.id)||o.push(r.id+(r.parentId?`>${r.parentId}`:""));return o.sort(),`${o.join("|")}#sv${a}.${s}`}function Oqe(e){return e!==""&&!e.startsWith("#sv")}const kz="agent-dag.removedNodes";function Mqe(e){try{const t=JSON.parse((e==null?void 0:e.getItem(kz))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function BA(e,t){try{e==null||e.setItem(kz,JSON.stringify([...t]))}catch{}}function a8(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),a=new Set(t),s=o=>{if(a.has(o))return!0;const r=new Set([o]);let c=n.get(o);for(;c&&!r.has(c);){if(a.has(c))return a.add(o),!0;r.add(c),c=n.get(c)}return!1};return o=>s(o.id)||s(o.sessionId??o.id)}function Iqe(e,t){if(t.size===0)return new Set;const n=[...e],a=a8(n,t);return new Set(n.filter(a).map(s=>s.id))}function Dqe(e,t,n){const a=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),s=a8(e.map(a),n),o=e.filter(c=>!s(a(c))),r=new Set(o.map(c=>c.id));return{nodes:o,edges:t.filter(c=>r.has(c.source)&&r.has(c.target))}}function Fqe(e,t){let n=null;for(const a of t)e.has(a)&&(n??=new Set(e),n.delete(a));return n??e}function Bqe(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function s8(e){let t=e.kind==="subagent"?e.startedAt:-1/0;const n=e.tools[e.tools.length-1];n&&n.startedAt>t&&(t=n.startedAt);const a=e.prompts[e.prompts.length-1];return a&&a.at>t&&(t=a.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function Uqe(e,t,n){let a=null;for(const s of t)e.has(s)||(a??=new Map(e),a.set(s,n));for(const s of e.keys())t.has(s)||(a??=new Map(e),a.delete(s));return a??e}function Wqe(e,t,n,a){if(n.size===0)return[];let s=1/0;for(const r of a.values())r<s&&(s=r);const o=new Set;for(const r of t){const c=e.get(r);if(!c)continue;const l=s8(c);if(l<=s)continue;const u=[],h=new Set,p=b=>{var v;for(let w=b;w&&!h.has(w);w=(v=e.get(w))==null?void 0:v.parentId)h.add(w),n.has(w)&&u.push(w)};p(c.id),p(c.sessionId);let f=-1/0;for(const b of u)f=Math.max(f,a.get(b)??1/0);if(l>f)for(const b of u)o.add(b)}return[...o]}function Hqe(e,t){if(!t||!e.agents.get(t))return null;const a=new Set([t]);let s=t;for(;s;){const r=e.agents.get(s);if(!(r!=null&&r.parentId)||a.has(r.parentId))break;a.add(r.parentId),s=r.parentId}let o=!0;for(;o;){o=!1;for(const r of e.agents.values())r.parentId&&a.has(r.parentId)&&!a.has(r.id)&&(a.add(r.id),o=!0)}return a}function Gqe(e,t){const n=new Set;for(const a of t){const s=Hqe(e,a);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function Vqe({stateRef:e,now:t,removedAgentIds:n,sizeVersion:a,domSizeVersion:s}){return m.useMemo(()=>Pqe(e.current.agents.values(),t,n,a,s),[e.current,e.current.revision,t,a,s,n])}function Kqe({stateRef:e,now:t,availableWidth:n,availableHeight:a,layout:s,measuredRef:o,onBubble:r,settled:c,dragging:l,layoutSig:u,selectedIds:h,openContext:p,historyReplayed:f,removedNodes:b,removedAgentIds:v,dragTick:w,dragPatchRef:T,dragMoveTick:y,onMoved:x,packed:C=!1}){const{pinnedRef:A,positionsRef:E,provisionalRef:R,returningRef:z,lastLayoutSigRef:I,restoredLayout:_,layoutEpoch:D,flowedRef:L}=s,P=m.useRef(x);P.current=x;const O=m.useMemo(()=>({flowed:L,order:()=>Lqe(e.current),onMoved:()=>{var J;return(J=P.current)==null?void 0:J.call(P)}}),[L,e]),j=m.useMemo(()=>Gqe(e.current,h),[e.current,e.current.revision,h]),M=m.useMemo(()=>{const J=yte(e.current,t);for(const X of v)J.delete(X);return J},[e.current,e.current.revision,t,v]),F=m.useRef(new Map),U=Kle(),{nodes:H,edges:$}=m.useMemo(()=>{const J=Lze(e.current,t,n,a,A.current,o.current,F.current,r,c,l,E.current,R.current,u,I,h,j,M,p,f,_.restored,z.current,O);return Dqe(J.nodes,J.edges,b)},[e.current,e.current.revision,t,n,a,c,l,u,h,j,M,p,w,U,b,D,f]),Y=m.useRef(null),W=m.useMemo(()=>C?((!l||!Y.current)&&(Y.current=kpe(H)),vpe(H,Y.current)):(Y.current=null,H),[H,C,l]),G=m.useMemo(()=>e8(W),[W]),Q=m.useMemo(()=>{const J=[...G,...W],X=T.current;return!X||X.size===0?J:J.map(te=>{const K=X.get(te.id);return K?{...te,position:K}:te})},[G,W,y]);return{spotlightSet:j,visibleAgentIds:M,nodes:H,shown:W,squeeze:Y.current,edges:$,allNodes:Q}}function $qe(e,t,n){const a=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,o=(e.x+e.width)*t.zoom+t.x,r=(e.y+e.height)*t.zoom+t.y;return o>0&&a<n.width&&r>0&&s<n.height}function Jqe({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 a=!1;for(const s of n)if(a=!0,$qe(s,t,e))return!1;return a}const Yqe=1500;function Zqe(e,t){return e>0&&t-e<Yqe?0:Nl}function Xqe({layoutSig:e,rf:t,stateRef:n,measuredRef:a,pinnedRef:s,positionsRef:o,paneSizeRef:r,lastInteractRef:c,autoFitDisabledRef:l,lastFitTimeRef:u,fitLeft:h}){const p=m.useRef(null),f=m.useRef(""),b=m.useRef(0),v=()=>h(Zqe(b.current,Date.now()));return m.useEffect(()=>{const T=setInterval(()=>{if(l.current||Date.now()-c.current<800)return;const y=n.current,x=Date.now(),C=[];for(const E of y.agents.values())Ng(E,x)&&C.push({id:E.id});if(C.length===0)return;const A=[];for(const{id:E}of C){const R=a.current.get(E),z=s.current.get(E)??o.current.get(E);!R||!z||A.push({x:z.x,y:z.y,width:R.width,height:R.height})}Jqe({pane:r.current,viewport:t.getViewport(),boxes:A})&&v()},1500);return()=>clearInterval(T)},[t]),m.useEffect(()=>{if(f.current===e)return;const T=f.current;if(f.current=e,!b.current&&Oqe(e)&&(b.current=Date.now()),!T||l.current)return;Date.now()-u.current>1200&&v(),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{l.current||v()},280)},[e,t,h]),{fitSoon:m.useCallback(()=>{l.current||(p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{l.current||v()},280))},[h])}}function Qqe({stateRef:e,pinnedRef:t,positionsRef:n,returningRef:a,canvasRef:s,clearSelection:o,primarySelectedId:r}){const[c,l]=m.useState(()=>Mqe(Gs())),[u,h]=m.useState(null),p=m.useMemo(()=>Iqe(e.current.agents.values(),c),[e.current,e.current.revision,c]),f=m.useCallback(C=>{const A=e.current.agents.get(C);A&&(l(E=>{const R=new Set(E);return R.add(C),BA(Gs(),R),R}),h({id:C,label:A.label}),t.current.delete(C),n.current.delete(C),o())},[o]),b=m.useCallback(()=>{r&&f(r)},[r,f]),v=u&&c.has(u.id)?u:null;m.useEffect(()=>{var C;u&&((C=s.current)==null||C.focus())},[u]);const w=m.useCallback(C=>{const A=[...C];l(E=>{let R=null;for(const z of A)E.has(z)||(R??=new Set(E),R.add(z));return R?(BA(Gs(),R),R):E})},[]),T=m.useCallback(C=>{const A=[...C];l(E=>{var z;const R=Fqe(E,A);R!==E&&BA(Gs(),R);for(const I of A)R!==E&&E.has(I)&&((z=e.current.agents.get(I))==null?void 0:z.kind)==="root"&&a.current.add(I);return R})},[]),y=m.useCallback(()=>{T([...c]),h(null)},[T,c]),x=m.useCallback(()=>{l(new Set),h(null),Ja(kz)},[]);return{removedNodes:c,lastRemoval:u,removedAgentIds:p,removeNode:f,removeSelectedNode:b,removalNotice:v,hideSessions:w,bringBack:T,bringBackAll:y,forgetRemovals:x}}function e_e({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:a,bringBack:s}){const o=m.useRef(new Map);m.useEffect(()=>{o.current=Uqe(o.current,a,Date.now());const r=[...Bqe(t,n),...Wqe(e.current.agents,n,a,o.current)];r.length>0&&s(r)},[t,n,a,s])}const i8=[0,5,15,30,60],vz="agent-dag.hide-finished-after",o8="agent-dag.hide-finished-turns",t_e=300,n_e=1e4;function wz(e){const t=Number(e);return i8.includes(t)?t:0}let yl=null;const Np=new Set;function r8(){for(const e of Np)e()}function FU(){return yl===null&&(yl=wz(gt(vz))),yl}function c8(e){const t=wz(String(e));yl!==t&&(yl=t,yt(vz,String(t)),r8())}function BU(e){if(e.key!==vz)return;const t=wz(e.newValue);t!==yl&&(yl=t,r8())}function a_e(e){var t;return Np.add(e),Np.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",BU)),()=>{var n;Np.delete(e),Np.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",BU))}}function s_e(e){try{const t=JSON.parse((e==null?void 0:e.getItem(o8))??"{}");return!t||typeof t!="object"||Array.isArray(t)?new Map:new Map(Object.entries(t).filter(n=>typeof n[1]=="number"))}catch{return new Map}}function UU(e,t){const n=[...t].sort((a,s)=>s[1]-a[1]).slice(0,t_e);try{e==null||e.setItem(o8,JSON.stringify(Object.fromEntries(n)))}catch{}}function l8(e){const t=new Map;for(const a of e){let s=t.get(a.sessionId);s||(s={endedAt:0,live:!1},t.set(a.sessionId,s)),a.kind==="root"&&bs(a.waiting)&&(s.live=!0),a.state==="done"&&a.endedAt!=null?s.endedAt=Math.max(s.endedAt,a.endedAt):s.live=!0}const n=new Map;for(const[a,s]of t)!s.live&&s.endedAt>0&&n.set(a,s.endedAt);return n}function i_e(e,{afterMs:t,now:n,removed:a,handled:s,keep:o}){if(t<=0)return[];const r=Array.isArray(o)?o:[o],c=[];for(const[l,u]of l8(e))n-u<t||a.has(l)||r.includes(l)||s.get(l)!==u&&c.push({id:l,endedAt:u});return c}function o_e(e,t,n,a){const s=[...t].filter(c=>!n.has(c));if(s.length===0)return e;const o=l8(a);let r=null;for(const c of s){const l=o.get(c);l==null||e.get(c)===l||(r??=new Map(e),r.set(c,l))}return r??e}function r_e(e,t){if(t.size===0)return!1;const n=new Map;for(const s of e.agents.values()){if(!t.has(s.sessionId))continue;const o=s8(s);o>(n.get(s.sessionId)??-1/0)&&n.set(s.sessionId,o)}let a=!1;for(const s of e.agents.values()){if(s.kind!=="subagent"||s.state!=="done"||s.endedAt==null||s.exitAt!=null)continue;const o=t.get(s.sessionId);o==null||s.endedAt>o||!((n.get(s.sessionId)??-1/0)>o)||(s.exitAt=o,a=!0)}return a&&(e.revision+=1),a}function d8(){return m.useSyncExternalStore(a_e,FU,FU)}function c_e({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:a,stageSessionId:s=null,ready:o}){const r=d8(),[c]=m.useState(()=>s_e(Gs())),l=m.useRef(c),u=m.useRef(t);m.useEffect(()=>{const h=o_e(l.current,u.current,t,e.current.agents.values());u.current=t,h!==l.current&&(l.current=h,UU(Gs(),h))},[t]),m.useEffect(()=>{o&&r_e(e.current,l.current)},[o,e.current,e.current.revision]),m.useEffect(()=>{if(!o||r===0)return;const h=()=>{const f=i_e(e.current.agents.values(),{afterMs:r*6e4,now:Date.now(),removed:t,handled:l.current,keep:[a,s]});if(f.length===0)return;const b=new Map(l.current);for(const{id:v,endedAt:w}of f)b.set(v,w);l.current=b,UU(Gs(),b),n(f.map(v=>v.id))};h();const p=window.setInterval(h,n_e);return()=>window.clearInterval(p)},[o,r,t,a,s,n])}function l_e({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) waiting · ${an}`:an,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const u8=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),h8=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),d_e=Object.freeze([...new Set([...Object.values(u8),...Object.values(h8)])]),eE=new Map;function WU(e){return eE.get(e)??e}async function u_e(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!eE.has(n))try{const a=await t(n),s=(a.headers.get("Content-Type")??"").split(";")[0].trim();if(!a.ok||!s.startsWith("image/"))return;eE.set(n,`data:${s};base64,${h_e(new Uint8Array(await a.arrayBuffer()))}`)}catch{}}))}function h_e(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function p_e({stateRef:e,waitingSessions:t,live:n}){const a=m.useMemo(()=>Vte(e.current.agents.values()),[e.current,e.current.revision]),s=m.useRef(null);m.useEffect(()=>{n&&u_e(d_e)},[n]),m.useEffect(()=>{const o=l_e({waiting:t.length,running:a,connected:n}),r=s.current;s.current=o,(r==null?void 0:r.title)!==o.title&&(document.title=o.title),(r==null?void 0:r.icon)!==o.icon&&p8(o.icon)},[t.length,a,n])}function p8(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=WU(u8[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=WU(h8[e]))}const g8=1200,g_e=1e3;function UA(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<g8?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<g_e}function m_e({applyViewport:e,takeOver:t,lastFitTimeRef:n,cameraEpochRef:a,disableAutoFit:s,markInteract:o,canvasRef:r,applyZoom:c,zoomFocusRef:l}){const u=m.useState(()=>vqe())[0];m.useEffect(()=>{if(!u)return;const y=window.setTimeout(()=>{try{e(u,0)}catch{}n.current=Date.now()},60);return()=>window.clearTimeout(y)},[e,u]);const h=m.useRef(null),p=m.useRef(0),f=m.useCallback(y=>{((y==null?void 0:y.type)==="pointerdown"||(y==null?void 0:y.type)==="wheel")&&t(),p.current=Date.now()},[t]),b=m.useCallback(y=>({hasSourceEvent:!!y,at:Date.now(),lastDeckFitAt:n.current,lastCanvasInputAt:p.current}),[]),v=y=>{Zs(),UA(b(y))&&(a.current+=1),UA(b(y))&&s()},w=m.useRef(null);return{restoredViewport:u,markCanvasInput:f,onMoveStart:v,onMove:(y,x)=>{var E;o(),UA(b(y))&&s();const C=w.current;w.current=x;const A=C&&l?wpe(C,x):null;if(A&&l){const R=n.current>0&&Date.now()-n.current<g8;l.current={...A,reader:!!y||!R}}(E=r.current)==null||E.style.setProperty("--zoom",String(x.zoom)),c(x.zoom)==="detail"&&Zs(),h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>wqe(x),250)}}}const HU="data-repack";function f_e({packed:e,nodes:t,squeeze:n,focusRef:a,canvasRef:s,getViewport:o,panBy:r}){const c=m.useRef({packed:e,squeeze:n}),l=m.useRef(null),u=c.current;u.packed!==e&&(l.current={from:u.squeeze,to:n}),c.current={packed:e,squeeze:n};const h=m.useRef(t);h.current=t,m.useLayoutEffect(()=>{var p;l.current&&((p=s.current)==null||p.setAttribute(HU,""))},[e]),m.useEffect(()=>{const p=l.current;if(!p)return;l.current=null;const f=a.current;f!=null&&f.reader&&r(ype(h.current,p.from,p.to,o(),f));const b=s.current;b&&requestAnimationFrame(()=>requestAnimationFrame(()=>b.removeAttribute(HU)))},[e])}function b_e({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:a,detailShown:s,focusAgent:o,revealAgent:r,draggingRef:c,lodRef:l,stage:u}){const h=m.useRef(r);h.current=r;const[p]=m.useState(()=>iG({focus:y=>h.current(y),setTimeout:(y,x)=>window.setTimeout(y,x),clearTimeout:y=>window.clearTimeout(y)}));return m.useEffect(()=>()=>p.cancel(),[p]),{onNodeClick:(y,x)=>{if(x.type==="sessionGroup"){p.cancel(),e();return}const C=x.type==="recapNote"?x.data.parentId:x.id;if(t(C,y.shiftKey,!1),!y.shiftKey){if(u!=null&&u.onNodeClick(C,y.currentTarget)){p.cancel();return}n&&a(!1),Ya()?p.hold(C):s?window.setTimeout(()=>{try{r(C)}catch{}},80):r(C)}},onPaneClick:()=>{p.cancel(),Zs(),e()},onNodeDoubleClick:(y,x)=>{if(x.type!=="agent"&&x.type!=="recapNote")return;p.cancel();const C=x.type==="recapNote"?x.data.parentId:x.id;t(C,!1),window.setTimeout(()=>{try{o(C)}catch{}},80)},onNodeMouseEnter:(y,x)=>{x.type!=="agent"&&x.type!=="recapNote"||c.current||l.current==null||l.current==="detail"||bz(x.id,y.currentTarget)},onNodeMouseLeave:(y,x)=>Zs(x.id)}}const k_e="board-head";function v_e({settleAt:e,now:t,take:n,schedule:a,cancel:s}){let o=null;const r=()=>{o!=null&&s(o),o=null};return{read(c,l){r();const u=e()-t();if(u>0){o=a(()=>{o=null,n(c,l)},u);return}n(c,l)},dispose:r}}function w_e(e){const t=m.useRef(null),n=m.useRef(null),[a,s]=m.useState({w:0,h:0}),o=m.useRef(()=>{});m.useLayoutEffect(()=>{const c=n.current;if(!c||typeof ResizeObserver>"u")return;const l=v_e({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(p,f)=>s(b=>Math.abs(b.w-p)>40||Math.abs(b.h-f)>40?{w:p,h:f}:b),schedule:(p,f)=>window.setTimeout(p,f),cancel:p=>window.clearTimeout(p)}),u=()=>{var p;return((p=c.querySelector(`:scope > .${k_e}`))==null?void 0:p.offsetHeight)??0},h=new ResizeObserver(p=>{var v;const f=(v=p[0])==null?void 0:v.contentRect;if(!f)return;const b={width:f.width,height:f.height-u()};t.current={width:b.width,height:b.height},l.read(b.width,b.height)});return h.observe(c),t.current={width:c.clientWidth,height:c.clientHeight},s({w:c.clientWidth,h:c.clientHeight}),o.current=()=>{const p=c.clientWidth,f=c.clientHeight-u();t.current={width:p,height:f},l.read(p,f)},()=>{h.disconnect(),l.dispose(),o.current=()=>{}}},[]);const r=m.useCallback(()=>o.current(),[]);return{canvasRef:n,canvasSize:a,paneSizeRef:t,remeasureCanvas:r}}function y_e(e,t){const n=qn(),a=m.useRef(new Map),s=m.useRef(0),o=m.useRef(new Map),[r,c]=m.useState(0),[l,u]=m.useState(0),h=m.useRef(null),p=m.useCallback(()=>{h.current=null;let b=!1;const v=n.getState().nodeInternals,w=t.current.agents,T=x=>v.has(x)||w.has(x)||x.startsWith("recap:")&&w.has(x.slice(6));for(const x of o.current.keys())T(x)||o.current.delete(x);for(const x of a.current.keys())T(x)||(a.current.delete(x),b=!0);for(const x of v.values()){if(x.type===ig)continue;const C=x.width,A=x.height;if(C==null||A==null)continue;const E=o.current.get(x.id);(!E||Math.abs(E.width-C)>4||Math.abs(E.height-A)>4)&&(o.current.set(x.id,{width:C,height:A}),a.current.set(x.id,{width:C,height:A}),b=!0)}if(b&&(s.current+=1,c(s.current)),e.current)return;let y=!1;for(const x of document.querySelectorAll(".react-flow__node[data-id]")){if(x.classList.contains(`react-flow__node-${ig}`))continue;const C=x.getAttribute("data-id");if(!C)continue;const A=x.offsetWidth,E=x.offsetHeight;if(!A||!E)continue;const R=a.current.get(C);(!R||Math.abs(R.width-A)>4||Math.abs(R.height-E)>4)&&(a.current.set(C,{width:A,height:E}),y=!0)}y&&u(x=>x+1)},[n,e,t]),f=m.useCallback(()=>{h.current||(h.current=document.visibilityState==="hidden"?{frame:0,timer:window.setTimeout(p,32)}:{frame:requestAnimationFrame(p),timer:0})},[p]);return m.useEffect(()=>{const b=n.subscribe(f);return f(),()=>{b();const v=h.current;v&&(cancelAnimationFrame(v.frame),window.clearTimeout(v.timer),h.current=null)}},[n,f]),m.useEffect(f),{measuredRef:a,measuredVersionRef:s,sizeVersion:r,domSizeVersion:l}}function x_e(){const[e,t]=m.useState(!1);return m.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function C_e(){const e=m.useRef(null);return m.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},a=s=>{e.current=performance.now()-t<250?s.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",a,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",a,!0)}},[]),e}const yz=3;function xz(e){if(!e)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[a,s]of Object.entries(t))typeof s=="number"&&Number.isFinite(s)&&s>0&&(n[a]=Math.min(yz,Math.floor(s)));return n}catch{return{}}}let Hp=null;const tE=new Set;function Sk(){return Hp===null&&(Hp=xz(gt(sg))),Hp}function m8(e,t=Sk()){return(t[e]??0)>=yz}function Xf(e){const t=Sk();if(m8(e,t))return;const n={...t};for(const[a,s]of Object.entries(xz(gt(sg))))n[a]=Math.max(n[a]??0,s);n[e]=Math.min(yz,(n[e]??0)+1),Hp=n,yt(sg,JSON.stringify(n)),S_e()}function S_e(){for(const e of tE)e()}function T_e(e){var n;tE.add(e);const t=a=>{a.key!==sg&&a.key!==null||(Hp=xz(gt(sg)),e())};return typeof window<"u"&&((n=window.addEventListener)==null||n.call(window,"storage",t)),()=>{var a;tE.delete(e),typeof window<"u"&&((a=window.removeEventListener)==null||a.call(window,"storage",t))}}function N_e(){return m.useSyncExternalStore(T_e,Sk,Sk)}function nE(e,t,n){const a=ku(e.agents.values());return a.length>0?(t(a[0].id),!0):n(1)}function f8(e,t,n,a=!1){const s=ku(e.agents.values()),o=a?Gte(s,t.current):c4(s,t.current);o&&(t.current=o.id,n(o.id))}function A_e(e,t,n){return n?null:e.kind==="step"?"sessions":e.kind==="focus-pane"?t==="Enter"?"openAndType":null:t==="n"||t==="N"?"nextWaiting":null}function GU(e,t,{onCard:n=!1,stageOpen:a=!1}={}){if(t)return null;if(n)return e==="Enter"?"select":null;switch(e){case"j":case"J":case"k":case"K":return"cards";case"n":case"N":return"nextWaiting";case"p":case"P":return a?null:"peek";default:return null}}function j_e({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:a,providersRef:s,soundOnRef:o,keyHelpOpenRef:r,modalOpenRef:c,waitingCursorRef:l,removeSelectedRef:u,activateSoundRef:h,clearSelection:p,selectAgent:f,focusAgent:b,stepAgent:v,focusSession:w,requestClear:T,handleRelayout:y,undoRearrange:x,handleFit:C,togglePause:A,toggleSessionList:E,toggleAccountsPanel:R,setDetailOpen:z,setUsageHistoryOpen:I,setUsagePanelOpen:_,setMachinePanelOpen:D,setBrowserWatchOpen:L,setKeyHelpOpen:P,setTheme:O,openSettings:j,openIntegrationRef:M,openQuickOpen:F,stageRef:U,viewRef:H,lodRef:$,inspectorSheetFoldRef:Y,inspectorDoorRef:W}){m.useEffect(()=>{let G=null;const Q=()=>{G&&clearTimeout(G.timer),G=null},J=(K,V,ee)=>{var de,he;if(K.kind==="step"){if(V.mode==="rail"){const ke=sI(V.order,((de=V.sessionAt)==null?void 0:de.call(V,ee))??V.current,K.direction);ke!=null&&V.focusTile(ke);return}const me=G?G.from:V.current,be=((he=V.sessionAt)==null?void 0:he.call(V,ee))??(G?G.to:V.current),ie=sI(V.order,be,K.direction);if(Q(),ie==null)return;V.focusTile(ie);const ne=setTimeout(()=>{G=null;const ke=U==null?void 0:U.current;!(ke!=null&&ke.open)||ke.current!==me||ke.current===ie||ke.switchTo(ie,{focusPane:!1})},F0e);G={to:ie,from:me,timer:ne};return}if(K.kind==="focus-pane"){const me=G;Q(),me&&me.to!==V.current&&me.from===V.current?V.switchTo(me.to,{focusPane:!0}):V.focusPane();return}Q(),V.nextAsk()},X=()=>{var de;if(Gze()!=null){Zs();return}if($&&($.current==null||$.current==="detail"))return;const K=n.current,V=a.current,ee=[V&&K.agents.has(V)?V:null,((de=ku(K.agents.values())[0])==null?void 0:de.id)??null];for(const he of ee){const me=he?Bze(he):null;if(he&&me&&Uze(me)){bz(he,me,"focus");return}}},te=K=>{var ke,Se,ve,xe,Ee,Ge,Qe,Je,He,_e,le,Re;const V=K.target,ee=((ke=V==null?void 0:V.hasAttribute)==null?void 0:ke.call(V,hle))===!0,de={tagName:V==null?void 0:V.tagName,isContentEditable:V==null?void 0:V.isContentEditable,role:(Se=V==null?void 0:V.getAttribute)==null?void 0:Se.call(V,"role"),type:V==null?void 0:V.type,pointerFocused:V!=null&&V===e.current&&!ee,caught:ee};if($R(K)){const ge=H==null?void 0:H.current;if(ge!=null&&ge.available){Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()})||(K.preventDefault(),K.repeat||Xf("view"),K.repeat||ge.toggle());return}}if(HK(V)){JR(K)&&(K.preventDefault(),K.repeat||(ve=U==null?void 0:U.current)==null||ve.release());return}if(K.key==="Escape"){const ge=cle({overlayOpen:Rn.depth()>0,typing:bl(de)});ge==="dismiss"?Rn.dismissTop():ge==="blur"?V==null||V.blur():Y!=null&&Y.current&&((xe=V==null?void 0:V.closest)!=null&&xe.call(V,".detail"))?Y.current():Y!=null&&Y.current&&((Ee=V==null?void 0:V.closest)!=null&&Ee.call(V,".stage-dock"))||(Fze(de)&&(V==null||V.blur()),p(),Zs());return}if(NG(K,zs(js()))){if(Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}))return;K.preventDefault(),K.repeat||F();return}if(K.key===","&&_me(K)){if(bl(de)||Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}))return;K.preventDefault(),K.repeat||j();return}if(Rqe(K)){if(bl(de)||Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}))return;!K.repeat&&x()&&K.preventDefault();return}if(tv(K))return;const he=Zv(V)?(Ge=V==null?void 0:V.getAttribute)==null?void 0:Ge.call(V,"data-id"):null,me=he&&t.current.some(ge=>ge.id===he)?he:null,be=Ize(K,me);if(be.kind==="activate"){K.preventDefault();const ge=GU(K.key,K.repeat,{onCard:!0});ge&&Xf(ge),f(be.nodeId,be.additive);return}if(be.kind==="node"||Qde(K.key,Zj()))return;if(kle({key:K.key,sheetOpen:r.current,target:de})){K.repeat||P(!1);return}if(K.key==="t"||K.key==="T"){const ge=Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()});if(be.nodeId==null&&vle({target:de,modalOpen:ge}))return;K.repeat||O(Afe);return}const ie=U==null?void 0:U.current;if(ie!=null&&ie.open){const ge=B0e({key:K.key,repeat:K.repeat,target:de,modalOpen:Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()})});if(ge){K.preventDefault();const Pe=A_e(ge,K.key,K.repeat);Pe&&Xf(Pe),J(ge,ie,K.target);return}}if(be.nodeId==null&&Vb(de,K.key)||ble({key:K.key,modalOpen:Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}),sheetOpen:r.current})||K.repeat&&!/^[jkJK]$/.test(K.key))return;if(/^[1-4]$/.test(K.key)&&!K.ctrlKey&&!K.metaKey&&!K.altKey&&((Qe=U==null?void 0:U.current)!=null&&Qe.open)&&((He=(Je=U.current).focusPaneAt)!=null&&He.call(Je,Number(K.key)))){K.preventDefault();return}const ne=GU(K.key,K.repeat,{stageOpen:!!((_e=U==null?void 0:U.current)!=null&&_e.open)});if(ne&&Xf(ne),(K.key==="c"||K.key==="C")&&T("shortcut"),(K.key==="r"||K.key==="R")&&y(),(K.key==="f"||K.key==="F")&&C(),(K.key==="z"||K.key==="Z")&&a.current&&b(a.current),K.key==="Delete"&&u.current(),(K.key==="l"||K.key==="L")&&E(),(K.key==="d"||K.key==="D")&&(a.current?z(ge=>!ge):nE(n.current,w,v)||(le=W==null?void 0:W.current)==null||le.call(W)),(K.key==="h"||K.key==="H")&&I(ge=>!ge),(K.key==="u"||K.key==="U")&&_(ge=>!ge),(K.key==="a"||K.key==="A")&&(s.current.claude||s.current.codex)&&R(),(K.key==="j"||K.key==="J")&&v(1),(K.key==="k"||K.key==="K")&&v(-1),K.key==="w"||K.key==="W"){const ge=c4(ku(n.current.agents.values()),l.current);ge&&(l.current=ge.id,w(ge.id))}(K.key==="n"||K.key==="N")&&f8(n.current,l,w,K.shiftKey),(K.key==="p"||K.key==="P")&&((Re=U==null?void 0:U.current)!=null&&Re.open||X()),(K.key==="m"||K.key==="M")&&o.current!==null&&h.current(K.shiftKey),(K.key==="s"||K.key==="S")&&D(ge=>!ge),(K.key==="b"||K.key==="B")&&L(ge=>!ge),(K.key==="v"||K.key==="V")&&j("sounds"),(K.key==="i"||K.key==="I")&&(M==null||M.current("jira")),K.key==="?"&&P(ge=>!ge)};return window.addEventListener("keydown",te),()=>{window.removeEventListener("keydown",te),Q()}},[T,y,x,C,p,f,v,w,b,A])}function E_e(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function R_e({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:a,codexShown:s=!1,detailShown:o,primarySelectedId:r,canvasRef:c}){const l={sessionList:m.useRef(null),usage:m.useRef(null),accounts:m.useRef(null),codex:m.useRef(null),machine:m.useRef(null)},u=h=>()=>{E_e()&&h()};return{toggles:l,sessionList:u(so(!e,l.sessionList)),usage:u(so(!t,l.usage)),machine:u(so(!n,l.machine)),accounts:u(so(!a,l.accounts)),codex:u(so(!s,l.codex)),detail:u(so(!o,()=>{var h,p;r&&fz(r),fa(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((p=c.current)==null||p.focus({preventScroll:!0}))}))}}function z_e({nodes:e,shown:t=e,squeeze:n=null,stateRef:a,pinnedRef:s,positionsRef:o,draggingRef:r,dragPatchRef:c,setDragging:l,setDragMoveTick:u,setDragTick:h,endBubble:p,markInteract:f,disableAutoFit:b,beginTrashDrag:v,trackTrashDrag:w,endTrashDrag:T,removeNode:y}){const x=m.useRef(null),C=I=>n?{x:n.back(I.x),y:I.y}:{x:I.x,y:I.y},A=(I,_)=>n?n.back(I+_)-n.back(I):_;return{onNodeDragStart:(I,_)=>{var D,L;if(_){if(Zs(),p(),r.current=!0,c.current=new Map,l(!0),f(),b(),_.type==="sessionGroup"){const P=(D=_.data)==null?void 0:D.sessionId,O=new Map,j=new Map,M=new Map;let F=1/0;if(P){for(const H of e)!H.data||wn(H)!==P||(O.set(H.id,{x:H.position.x,y:H.position.y}),M.set(H.id,s.current.get(H.id)));for(const H of t)O.has(H.id)&&(j.set(H.id,{x:H.position.x,y:H.position.y}),H.type==="agent"&&(F=Math.min(F,H.position.x)))}x.current={sessionId:P,start:{x:_.position.x,y:_.position.y},members:O,drawn:j,anchor:Number.isFinite(F)?F:_.position.x,pinsBefore:M};const U=P?a.current.agents.get(P):void 0;v(U?U.label:null);return}v(_.type==="agent"?((L=a.current.agents.get(_.id))==null?void 0:L.label)??"":null),s.current.set(_.id,C(_.position))}},onNodeDrag:(I,_)=>{var D;if(_){if(f(),(_.type==="agent"||_.type==="sessionGroup")&&w(I),_.type==="sessionGroup"){const L=x.current;if(!L)return;const P=_.position.x-L.start.x,O=_.position.y-L.start.y,j=A(L.anchor,P);for(const[F,U]of L.members){const H={x:U.x+j,y:U.y+O};s.current.set(F,H),o.current.set(F,H)}const M=c.current;if(M){for(const[F,U]of L.members){const H=L.drawn.get(F)??U;M.set(F,{x:H.x+P,y:H.y+O})}M.set(_.id,{x:_.position.x,y:_.position.y})}u(F=>F+1);return}s.current.set(_.id,C(_.position)),o.current.set(_.id,C(_.position)),(D=c.current)==null||D.set(_.id,{x:_.position.x,y:_.position.y}),u(L=>L+1)}},onNodeDragStop:(I,_)=>{f();const D=T(I,(_==null?void 0:_.type)==="agent"||(_==null?void 0:_.type)==="sessionGroup");if(r.current=!1,c.current=null,l(!1),h(L=>L+1),!_){x.current=null,Wp(o.current,s.current);return}if(_.type==="sessionGroup"){const L=x.current;if(L&&D&&L.sessionId){for(const[P,O]of L.members){const j=L.pinsBefore.get(P);j?s.current.set(P,j):s.current.delete(P),o.current.set(P,O)}x.current=null,y(L.sessionId);return}if(L){const P=_.position.x-L.start.x,O=_.position.y-L.start.y,j=A(L.anchor,P);for(const[M,F]of L.members){const U={x:F.x+j,y:F.y+O};s.current.set(M,U),o.current.set(M,U)}}x.current=null,Wp(o.current,s.current),h(P=>P+1);return}if(s.current.set(_.id,C(_.position)),o.current.set(_.id,C(_.position)),D){y(_.id);return}Wp(o.current,s.current)}}}function q_e(e,t=S){if(e==null)return{kind:"unknown",lead:t("board.scope.unknown"),workspace:null,tail:""};const n=e.trim();return n===""?{kind:"machine",lead:t("board.scope.machine"),workspace:null,tail:""}:{kind:"scoped",lead:t("board.scope.scopedLead"),workspace:n,tail:t("board.scope.scopedTail")}}function Cz(e,t){return e.split(new RegExp(`(${t.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`)).map((a,s)=>t.includes(a)?i.jsx("code",{children:a},s):a)}function b8(){return i.jsx("div",{className:"empty-symbol","aria-hidden":"true",children:i.jsxs("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"m6 8 4 4-4 4"}),i.jsx("path",{d:"M13 16h5"})]})})}function __e({reservedRight:e=0}){const t=se();return i.jsx("div",{className:"empty-stage",style:{right:e},children:i.jsxs("div",{className:"empty-hero empty-notice",children:[i.jsx(b8,{}),i.jsx("h2",{children:t("board.hero.tabs",{product:an})}),i.jsx("p",{children:Cz(t("board.hero.tabsBody",{product:an}),[an])})]})})}function L_e({live:e,everConnected:t,providers:n,workspace:a,onTour:s,onNewSession:o,reservedRight:r=0}){const c=se(),l=!e;return i.jsx("div",{className:"empty-stage",style:{right:r},children:i.jsxs("div",{className:l?"empty-hero empty-notice":"empty-hero",children:[l?i.jsxs(i.Fragment,{children:[i.jsx(b8,{}),i.jsx("h2",{children:c(t?"board.hero.disconnected":"board.hero.unreachable")}),i.jsx("p",{children:Cz(c(t?"board.hero.lost":"board.hero.cannotReach",{product:an}),[an])})]}):O_e(n,a,c,o),!l&&i.jsxs("div",{className:"empty-actions",role:"group","aria-label":c("board.hero.explore"),"data-quiet":o?"":void 0,children:[i.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:c("board.hero.tour")}),i.jsx(F0,{film:"tour",action:!0})]})]})})}const P_e=["claude","codex"];function O_e(e,t,n,a){const s=q_e(t,n);return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:n("board.hero.noSessions")}),a&&i.jsx("button",{type:"button",className:"btn primary empty-new","aria-haspopup":"dialog",title:n("board.newSession.hint"),onClick:o=>a(o.currentTarget),children:n("board.newSession.title")}),s.kind==="scoped"?i.jsxs("p",{children:[s.lead," ",i.jsx("code",{children:s.workspace}),s.tail]}):a?i.jsx("p",{className:"empty-or",children:Cz(n("board.hero.orRun"),P_e)}):i.jsx("p",{children:n("board.hero.startHint")}),i.jsxs("details",{className:"empty-help",children:[i.jsx("summary",{children:n("board.hero.notShowing")}),hce(e).map(o=>i.jsx("p",{className:"hint-row",children:o.spans.map((r,c)=>r.code?i.jsx("code",{children:r.text},c):i.jsx("span",{children:r.text},c))},o.provider))]})]})}const M_e=1;function I_e(e){return{id:e.id,name:e.name,inputPreview:e.inputPreview,startedAt:e.startedAt,endedAt:e.endedAt,ok:e.ok,errorPreview:e.errorPreview,usage:e.usage}}function D_e(e,t,n){const a=e.agents.get(t);if(!a)return null;const s=[];for(const o of e.agents.values())o.sessionId===t&&s.push(o);return{schemaVersion:M_e,exportedAt:n,sessionId:t,label:a.label,cwd:a.cwd,startedAt:a.startedAt,endedAt:a.endedAt,model:a.model,agents:s.map(o=>({id:o.id,kind:o.kind,label:o.label,parentId:o.parentId,state:o.state,startedAt:o.startedAt,endedAt:o.endedAt,model:o.model,cwd:o.cwd,usage:o.usage,prompts:o.prompts,tools:o.tools.map(I_e)}))}}function F_e(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${an}-${n}-${$b(t,8)}.json`}function B_e(e){const t=Eg(e),n=t.tone==="active"?"working":t.tone==="waiting"?"waiting":t.tone==="partial"?"partial":t.tone==="err"?"error":t.tone==="ready"?"idle":"done",a=t.tone==="partial"?`${S("board.card.stateDone")} · ${t.word}`:t.word;return{glyph:n,phrase:a.toLowerCase()}}function U_e(e,t,n,a){const[s,o]=m.useState(null);return m.useEffect(()=>{if(!a||s)return;let r=!0;return Xs(()=>import("./inspector-status-pane-DP7kOBus.js"),__vite__mapDeps([0,1])).then(c=>{r&&o(c)},()=>{}),()=>{r=!1}},[a,s]),s&&e.kind==="root"?s.paneStatus(e,t,n):B_e(e)}const $r=["agents","time","context"],k8="agent-dag.inspector-tab",v8={get agents(){return S("board.inspector.tabAgents")},get time(){return S("board.inspector.tabTime")},get context(){return S("board.inspector.tabContext")}};function W_e(){const e=gt(k8);return $r.find(t=>t===e)??"agents"}function H_e(e){yt(k8,e)}const w8="agent-dag.inspector-details";function G_e(){return gt(w8)==="1"}function V_e(e){yt(w8,e?"1":"0")}const K_e={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},aE=ZE;function Sz(e,t){for(const n of e.values())if(n.sessionId===t&&n.kind==="root")return n;return e.get(t)}function $_e(e,t){const n=[];for(const h of e.values())h.sessionId===t&&n.push(h);const a=Sz(e,t);if(!a)return[];const s=new Map(n.map(h=>[h.id,h])),o=h=>{const p=new Set;let f=h;for(;f;){if(f===a)return!0;if(p.has(f.id))return!1;p.add(f.id),f=f.parentId?s.get(f.parentId):void 0}return!1},r=new Map;for(const h of n){if(h===a)continue;const p=h.parentId&&o(h)?h.parentId:a.id,f=r.get(p);f?f.push(h):r.set(p,[h])}for(const h of r.values())h.sort((p,f)=>p.startedAt-f.startedAt||(p.id<f.id?-1:p.id>f.id?1:0));const c=[],l=new Set,u=(h,p)=>{if(l.has(h.id))return;l.add(h.id),c.push({agent:h,depth:p.length,more:p});const f=r.get(h.id)??[];f.forEach((b,v)=>u(b,[...p,v<f.length-1]))};return u(a,[]),c}function J_e(e){const t=e.length-1;return t<=0?S("board.inspector.noSubagents"):S("board.inspector.subagents",{count:t})}const sE=e=>{var t;return((t=QE(e.name,e.input))==null?void 0:t.detail)??Y_e(e.inputPreview??"")},y8=(e,t)=>rte(e.name)&&/[\\/]/.test(t)&&!t.endsWith("…");function Y_e(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return t;const n=(a,s=0)=>{if(typeof a=="string")return a;if(s>2||a===null||typeof a!="object")return null;for(const o of Object.values(a)){const r=n(o,s+1);if(r)return r}return null};try{return n(JSON.parse(t))??""}catch{const a=/"(?:[^"\\]|\\.)*"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(t);return a?a[1].replace(/\\(.)/g,"$1"):""}}function VU(e,t=!1){return t||e==="Task"||e==="Agent"?"agents":e==="Read"||e==="Edit"||e==="Write"||e==="MultiEdit"||e==="NotebookEdit"?"file":e==="Search"||e==="Grep"||e==="Glob"||e==="WebSearch"||e==="WebFetch"?"search":e==="Bash"?"terminal":"tools"}const Ap=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function Z_e(e){if(e===null)return null;const t=e;if(!(typeof t!="object"||typeof t.open!="boolean"||!Ap(t.totalMs)||!Ap(t.claudeMs)||!Ap(t.machineMs)||!Ap(t.youMs)))return{open:t.open,totalMs:t.totalMs,claudeMs:t.claudeMs,machineMs:t.machineMs,youMs:t.youMs}}async function X_e(e,t){const n=await fetch(`/api/tool-audit?session=${encodeURIComponent(e)}`,{signal:t});if(n.ok)return Z_e(await n.json())}const Q_e=5e3,WA=15e3;function eLe(e,t,n){if(!e.open||(t==null?void 0:t.kind)!=="permission"||!Ap(t.since))return e;const a=Math.min(e.machineMs,Math.max(0,n-t.since));return a>0?{...e,machineMs:e.machineMs-a,youMs:e.youMs+a}:e}function ao(e){const t=Math.max(0,Math.round(e));return Math.round(t/100)<100?`${(Math.round(t/100)/10).toFixed(1)}s`:Cu(0,Math.round(t/1e3)*1e3,0)}function tLe(e){return e.totalMs>0?Math.round(e.youMs/e.totalMs*100):0}function nLe(e){return[["you",e.youMs],["claude",e.claudeMs],["machine",e.machineMs]].filter(([,t])=>t>0).map(([t,n])=>({lane:t,ms:n}))}const aLe=new Set(["Task","Agent"]);function sLe(e){var a;const t=(a=e.prompts.at(-1))==null?void 0:a.at;if(t!==void 0)return t;let n=null;for(const s of e.tools)(n===null||s.startedAt<n)&&(n=s.startedAt);return n}function iLe(e){const{agents:t,sessionId:n,start:a,now:s}=e,o=Sz(t,n),r=[];if(!o)return{rows:r,start:a,end:e.end};const c=new Map;for(const p of t.values()){if(p.sessionId!==n||p===o||!p.parentId)continue;const f=c.get(p.parentId);f?f.push(p):c.set(p.parentId,[p])}const l=new Set,u=(p,f,b)=>{if(l.has(p.id))return;l.add(p.id);const v=[...p.tools].sort((C,A)=>C.startedAt-A.startedAt),w=(c.get(p.id)??[]).sort((C,A)=>C.startedAt-A.startedAt),T=new Map,y=[];for(const C of w){let A;for(const E of v)aLe.has(E.name)&&!T.has(E.id)&&E.startedAt<=C.startedAt+1e3&&(A=E);A?T.set(A.id,C):y.push(C)}const x=[...v.map(C=>({at:C.startedAt,call:C,kid:T.get(C.id)})),...y.map(C=>({at:C.startedAt,kid:C}))].sort((C,A)=>C.at-A.at);for(const{at:C,call:A,kid:E}of x)if(!(C<a)){if(E){const R=`g:${E.id}`;r.push({key:R,name:E.label||(A==null?void 0:A.name)||"Agent",arg:A?sE(A):"",depth:f,group:!0,under:b,from:C,to:A?A.endedAt??null:E.endedAt??null,waitingSince:null}),u(E,f+1,[...b,R])}else if(A){const R=sE(A);r.push({key:`c:${p.id}:${A.id}`,name:A.name,arg:R,...y8(A,R)?{path:!0}:{},depth:f,group:!1,under:b,from:C,to:A.endedAt??null,waitingSince:null})}}};u(o,0,[]),oLe(r,o.waiting);let h=e.end;for(const p of r)h=Math.max(h,p.to??Math.min(s,h));return{rows:r,start:a,end:h,...o.cwd?{cwd:o.cwd}:{}}}function oLe(e,t){if(!(!t||t.kind==="idle"))for(let n=e.length-1;n>=0;n--){const a=e[n];if(!(a.group||a.to!==null)&&!(t.tool&&t.tool.name!==a.name)){a.waitingSince=t.since;return}}}function rLe(e){const t=Math.max(1,e.end-e.start);return[0,1,2,3].map(n=>n===0?"0":ao(t*n/3))}function cLe(e,t,n){const a=Math.max(1,t.end-t.start),s=e.to??Math.min(n,t.end),o=Math.min(100,Math.max(0,(e.from-t.start)/a*100));return{left:o,width:Math.min(100-o,Math.max(0,(s-e.from)/a*100))}}function lLe({agent:e,now:t}){const n=se(),a=m.useRef(null),s=fG(e),o=bG(s==null?void 0:s.sessionId,a);return i.jsxs(i.Fragment,{children:[o.on&&s?i.jsx(kG,{facts:s,place:"hero",onDone:o.done}):i.jsx("h2",{className:"hero-title","data-renamable":s?"":void 0,onDoubleClick:s?o.start:void 0,title:e.kind==="root"?[e.cwd??e.label,Tu(e.startedAt,e.sessionId,void 0,t,n)].join(`
|
|
148
|
+
${Kk(e.plan.items)}`]}),i.jsx("p",{className:"node-peek-hint",children:a("insights.peek.hintNote")})]}),document.body)}function $ze({a:e,anchor:t,parentLabel:n,peers:a,bounds:s}){const o=se(),r=Z$(t,s),c=xo(1e3),l=e.kind==="root"?Wl(e):null,u=(l==null?void 0:l.title)??e.label,h=l?iv(l):"",p=Eg(e,o),f=e.toolErrorCount??0,b=e.tools.filter(A=>!A.endedAt).length,v=fs(e,c).total,w=e.usage.inputTokens+e.usage.outputTokens,T=e.kind==="root"&&bs(e.waiting),y=L4(e),x=e.kind==="root"?o("insights.peek.session"):n?o("insights.peek.subagentOf",{parent:n}):o("insights.peek.subagent"),C=[o("insights.peek.tools",{count:e.toolCount,n:e.toolCount}),b>0?o("insights.peek.inflight",{n:b}):null,w>0?o("insights.peek.tok",{n:Yt(w)}):null,v>0?`${Ut(v)}${yu(e,c)>0?"+":""}`:null].filter(Boolean).join(" · ");return $t.createPortal(i.jsxs("div",{ref:r,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[i.jsxs("div",{className:"node-peek-head",children:[i.jsx("span",{className:"node-peek-name",title:u,children:u}),i.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",Cu(e.startedAt,e.endedAt,c)]})]}),i.jsxs("div",{className:"node-peek-kind",children:[i.jsxs("span",{className:"node-peek-state","data-kind":p.mark,children:[p.mark==="alert"?i.jsx(ic,{}):i.jsx(yi,{kind:p.mark}),p.word]}),i.jsx("span",{children:x}),e.model?i.jsx("span",{children:Rg(e.model,e.effort)}):null]}),h&&i.jsx("p",{className:"node-peek-title",title:h,children:h}),e.kind==="root"&&e.waiting&&i.jsxs("p",{className:`node-peek-wait${T?" warn":""}`,children:[T&&i.jsx(ic,{}),i.jsxs("span",{className:"node-peek-said",title:Hj(e.waiting),children:[i.jsx("span",{className:"node-peek-since",children:i.jsx("b",{children:Cu(e.waiting.since,void 0,c)})}),Hj(e.waiting)]})]}),y&&i.jsxs("p",{className:"node-peek-blind",children:[i.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),y.label]}),i.jsxs("p",{className:"node-peek-facts",children:[C,f>0&&i.jsxs("span",{className:"node-peek-failed",children:[" · ",o("insights.peek.failed",{n:f})]})]}),e.kind==="root"&&i.jsx("p",{className:"node-peek-facts",children:Tu(e.startedAt,e.sessionId,a,c)}),e.branch&&e.branch.total>0&&i.jsx("p",{className:"node-peek-branch",children:x4(e.branch)}),i.jsx("p",{className:"node-peek-hint",children:o("insights.peek.hint")})]}),document.body)}function Jze(e){const t=e.minZoom??qAe,n=e.maxZoom??_Ae,a=e.fill??.9,s=e.insets.left,o=e.insets.top,r=Math.max(1,e.pane.width-e.insets.left-e.insets.right),c=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),l=e.context,u=e.anchor,h=Math.min(r/Math.max(1,l.width),c/Math.max(1,l.height))*a,p=Math.max(t,Math.min(n,h)),f=(b,v,w,T,y,x)=>{let C=b+(v-T*p)/2-w*p;const A=y*p+C,E=(y+x)*p+C;return x*p<=v?A<b?C+=b-A:E>b+v&&(C-=E-(b+v)):C+=b-A,C};return{x:f(s,r,l.x,l.width,u.x,u.width),y:f(o,c,l.y,l.height,u.y,u.height),zoom:p}}const zU=.5;function Yze(e){const{view:t,card:n}=e,a=e.minZoom??qv,s=t.zoom<a,o=s?a:t.zoom;let r=t.x,c=t.y;if(s){const C=n.x+n.width/2,A=n.y+n.height/2;r=C*t.zoom+t.x-C*o,c=A*t.zoom+t.y-A*o}const l=s?null:e.note??null,u=e.insets.left,h=e.insets.top,p=e.pane.width-e.insets.right,f=e.pane.height-e.insets.bottom,b=l?X$([n,l]):n,w=(C=>C.width*o<=p-u&&C.height*o<=f-h)(b)?b:n,T=(C,A,E,R)=>A-C>R-E||C<E-zU?E-C:A>R+zU?R-A:0,y=T(w.x*o+r,(w.x+w.width)*o+r,u,p),x=T(w.y*o+c,(w.y+w.height)*o+c,h,f);return!s&&y===0&&x===0?null:{x:r+y,y:c+x,zoom:o}}function X$(e){let t=1/0,n=1/0,a=-1/0,s=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),a=Math.max(a,o.x+o.width),s=Math.max(s,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:a-t,height:s-n}:null}const xk={usage:!1,machine:!1};function qU(e,t,n,a){return e.mode!=="board"?e:t?{...e,folded:!0,unfold:n}:a?{...e,refold:a}:e}function Zze(e,t){if(!t.on)return xk;if(!t.wasOn)return{usage:t.open.usage,machine:t.open.machine};const n=a=>e[a]&&!(t.open[a]&&!t.wasOpen[a]);return{usage:n("usage"),machine:n("machine")}}function Xze(e,t){const[n,a]=m.useState(xk),s=m.useRef({on:!1,open:xk});m.useLayoutEffect(()=>{const c=s.current,l={usage:t.usage,machine:t.machine};s.current={on:e,open:l},a(u=>{const h=Zze(u,{on:e,wasOn:c.on,open:l,wasOpen:c.open});return h.usage===u.usage&&h.machine===u.machine?u:h})},[e,t.usage,t.machine]);const o=m.useCallback(c=>a(l=>l[c]?{...l,[c]:!1}:l),[]),r=m.useCallback(c=>{s.current.on&&a(l=>l[c]?l:{...l,[c]:!0})},[]);return{folds:n,unfold:o,fold:r,on:e}}function Pt(e){const t=m.useRef(e);return t.current=e,t}const Z0=80,X0=.86;function Q$(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;const a=':not(.leaving):not([data-fold="inspector"])';for(const s of document.querySelectorAll(`.sysdetail${a}, .usage-panel${a}`)){const o=s.getBoundingClientRect();o.width>0&&o.left>t.left&&(n=Math.min(n,o.left))}return Math.max(0,t.right-n)}function Qze({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:a,usagePanelOpen:s,detailShown:o,folds:r=xk}){const[c,l]=m.useState(0);m.useEffect(()=>{const f=Q$(e.current);l(b=>Math.abs(b-f)>40?f:b)},[n,a,s,o,t.w,r.usage,r.machine]);const u=Pt(c),h=t.w>0?Math.max(0,(t.w-c-Z0*2)*X0):0,p=t.h>0?Math.max(0,(t.h-Z0*2)*X0):0;return{railInsetRef:u,availableWidth:h,availableHeight:p}}const eqe=1,Q0=.2,tqe=qv;function nqe(e,{pane:t,rail:n,bodyPx:a=zv,floor:s=Q0}){const o=Z0,r=eqe,c=Q0,l=X0;if(e.length===0)return null;const u=(R,z=0)=>{const I=Math.min(...R.map(P=>P.left))-z,_=Math.min(...R.map(P=>P.top))-z,D=Math.max(...R.map(P=>P.right))+z-I,L=Math.max(...R.map(P=>P.bottom))+z-_;return{minX:I,minY:_,w:D,h:L}},h=u(e),p=e.filter(R=>R.type==="agent"),f=p.length>0?u(p,oo):h;if(!(h.w>0&&h.h>0)||!(f.w>0&&f.h>0))return null;const b=aqe(p,f),v=(R,z)=>Math.max(c,Math.min(r,(t.width-n-o*2)/(R.w+z)*l,(t.height-o*2)/R.h*l)),w=Math.max(s,MR(v(h,po),v(b,0),a)),T=w*a>=OR,{minX:y,minY:x,h:C}=T?h:f,A=T?h.w+po:b.w,E=Math.max(0,t.width-n-o*2-A*w);return{x:o+E/2-y*w,y:(t.height>t.width-n?o:Math.max(o,(t.height-C*w)/2))-x*w,zoom:w}}function aqe(e,t){if(e.length===0)return t;const n=F1(e),a=Math.max(...e.map(s=>s.right));return{...t,w:n.at(a)+oo-t.minX}}const Zf=oo;function e8(e){const t=new Map;for(const a of e){const s=a.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;const o=a.width,r=a.height;if(o==null||r==null)continue;const c=a.position.x,l=a.position.y,u=c+o,h=l+r,p=t.get(wn(a));p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,l),p.maxX=Math.max(p.maxX,u),p.maxY=Math.max(p.maxY,h)):t.set(wn(a),{minX:c,minY:l,maxX:u,maxY:h})}const n=[];for(const[a,s]of t){const o=s.maxX-s.minX+Zf*2,r=s.maxY-s.minY+Zf*2;n.push({id:`group:${a}`,type:ig,position:{x:s.minX-Zf,y:s.minY-Zf},data:{sessionId:a,w:o,h:r},width:o,height:r,style:{width:o,height:r},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return n}const _U=1e-6;function Up(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function LU(e,t,n){return Math.abs(e[2]-t[2])<=_U*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=_U*n}function sqe(e,t){const n=t[2]/e[2];return a=>[e[0]+(t[0]-e[0])*a,e[1]+(t[1]-e[1])*a,e[2]*n**a]}function iqe(e,t,n){const a=e(0),s=e(.5),o=e(1);if(!Up(a)||!Up(s)||!Up(o))return!1;const r=Math.max(t[2],n[2]);return LU(a,t,r)&&LU(o,n,r)}function oqe(e){return(t,n)=>{const a=e(t,n),s=iqe(a,t,n)?a:sqe(t,n);let o=Up(t)?t:n;return r=>{const c=s(r);return Up(c)&&(o=c),o}}}function rqe(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const PU=new WeakSet;function DA(e,t){return e.transition().duration(t).ease(rbe)}function cqe(e){var t;(t=e==null?void 0:e.interrupt)==null||t.call(e)}const lqe=420;function dqe(){const e=Sg(),t=qn(),n=m.useCallback((E,R)=>{if(!rqe(E))return;const{d3Zoom:z,d3Selection:I}=t.getState(),_=I==null?void 0:I.property("__zoom");if(bp({durationMs:R,documentHidden:document.hidden})){if(z&&I&&_&&_.k>0&&E.zoom>0){z.transform(DA(I,R),_.scale(E.zoom/_.k).translate((E.x-_.x)/E.zoom,(E.y-_.y)/E.zoom));return}e.setViewport(E,{duration:R});return}if(z&&I&&_&&_.k>0&&E.zoom>0){z.transform(I,_.scale(E.zoom/_.k).translate((E.x-_.x)/E.zoom,(E.y-_.y)/E.zoom));return}e.setViewport(E,{duration:0})},[e,t]);m.useEffect(()=>{const E=R=>{!R||PU.has(R)||(PU.add(R),R.interpolate(oqe(R.interpolate())))};return E(t.getState().d3Zoom),t.subscribe(R=>E(R.d3Zoom))},[t]);const a=m.useRef(null),s=m.useRef(0),o=m.useRef(0),r=m.useRef(null),c=m.useRef(null),l=m.useRef(null),u=m.useRef(!1),h=m.useCallback((E,R)=>{const z=++s.current;return r.current=null,c.current=null,o.current=Date.now(),n(E,R),a.current=bp({durationMs:R,documentHidden:document.hidden})?{target:E,until:Date.now()+R+60}:null,z},[n]),p=m.useRef(()=>{}),f=m.useCallback((E=Nl,R=u.current?"all":"auto")=>{try{const z=document.querySelector(".canvas-wrap"),I=Array.from(document.querySelectorAll(".react-flow__node")).filter($=>$.offsetWidth>0);if(!z||I.length===0)return;const _=fg(z),D=e.getViewport();if(!Number.isFinite(D.zoom)||D.zoom<=0)return;const L=l.current,P=new Map((L?[...e8(L),...L]:e.getNodes()).map($=>[$.id,$])),O=I.flatMap($=>{const Y=P.get($.dataset.id??"");if(!Y)return[];const W=Y.positionAbsolute??Y.position,G=Y.width??$.offsetWidth,Q=Y.height??$.offsetHeight;return G>0&&Q>0?[{left:W.x,right:W.x+G,top:W.y,bottom:W.y+Q,type:Y.type}]:[]}),j=Q$(z),M=gK(nR[aR()]),F=nqe(O,{pane:{width:_.width,height:_.height},rail:j,bodyPx:M,floor:R==="all"?Q0:tqe});if(!F)return;const{zoom:U}=F,H=h(F,E);r.current=()=>p.current(E,R),window.setTimeout(()=>{var $;try{if((($=a.current)==null?void 0:$.target)===F&&(a.current=null),s.current!==H)return;const Y=e.getViewport();(Math.abs(Y.zoom-U)>.01||Math.abs(Y.x-F.x)>2||Math.abs(Y.y-F.y)>2)&&n(F,0)}catch{}},E+60)}catch{}},[e,n,h]);p.current=f;const b=m.useCallback(()=>{u.current=!0,f(Nl,"all")},[f]),v=m.useCallback(()=>{u.current=!1},[]);m.useEffect(()=>{const E=()=>{if(!document.hidden)return;const R=a.current;if(a.current=null,!(!R||Date.now()>R.until)){try{n(R.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",E),()=>document.removeEventListener("visibilitychange",E)},[n]);const w=m.useCallback(()=>{a.current&&(a.current=null,r.current=null,s.current+=1,o.current=0,cqe(t.getState().d3Selection))},[t]),T=m.useCallback(E=>{u.current=!1;const{d3Zoom:R,d3Selection:z,minZoom:I,maxZoom:_}=t.getState(),D=z==null?void 0:z.property("__zoom");if(!R||!z||!D||!(D.k>0))return;const L=c.current&&c.current.until>Date.now()?c.current.zoom:D.k,P=Math.max(I??0,Math.min(_??1/0,E(L)));!Number.isFinite(P)||!(P>0)||(s.current+=1,r.current=null,a.current=null,o.current=0,bp({durationMs:qy,documentHidden:document.hidden})?(c.current={zoom:P,until:Date.now()+qy+60},R.scaleTo(DA(z,qy),P)):(c.current=null,R.scaleTo(z,P)))},[t]),y=m.useCallback(E=>{if(!Number.isFinite(E)||E===0)return;const{d3Zoom:R,d3Selection:z}=t.getState(),I=z==null?void 0:z.property("__zoom");if(!R||!z||!I||!(I.k>0))return;R.transform(z,I.translate(E/I.k,0));const _=c.current,D=_?_.until-60-Date.now():0;_&&D>0&&bp({durationMs:D,documentHidden:document.hidden})&&R.scaleTo(DA(z,D),_.zoom)},[t]),x=m.useCallback(E=>T(R=>R*E),[T]),C=m.useCallback(()=>T(()=>1),[T]);m.useEffect(()=>{let E;const R=()=>{!a.current||!r.current||(window.clearTimeout(E),E=window.setTimeout(()=>{var z;a.current&&((z=r.current)==null||z.call(r))},100))};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),window.clearTimeout(E)}},[]);const A=m.useCallback(()=>e.getViewport(),[e]);return{applyViewport:n,moveCamera:h,fitLeft:f,fitAll:b,releaseFitAll:v,panBy:y,boardRef:l,currentViewport:A,cameraEpochRef:s,lastFitTimeRef:o,takeOver:w,zoomBy:x,zoomReset:C}}const FA=Nl,OU=e=>({top:56,left:32,bottom:56,right:e+32});function uqe({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:a,shownRef:s,lodRef:o,railInsetRef:r,moveCamera:c,currentViewport:l,disableAutoFit:u,lastFocusRef:h,focusAgentRef:p,selectAgent:f,primarySelectedIdRef:b,onLand:v}){const w=m.useCallback(C=>{const A=e.current,E=t.current.agents.get(C);if(!A||!E)return;const R=J$(t.current),z=(O,j)=>{const M=n.current.get(O.id);if(!M)return null;const F=j&&R.has(O.id)?lqe:0;return{x:O.position.x,y:O.position.y,width:M.width+F,height:M.height}},I=a.current.find(O=>O.id===C),_=I?z(I,!1):null;if(!_)return;const D=[];for(const O of a.current){if(O.type!=="agent"&&O.type!=="recapNote"||wn(O)!==wn(I))continue;const j=z(O,O.type==="agent");j&&D.push(j)}const L=fg(A),P=Jze({pane:{width:L.width,height:L.height},insets:OU(r.current),context:X$(D)??_,anchor:_});Zs(),u(),h.current={id:C,at:Date.now()},c(P,FA)},[c,u]),T=m.useCallback(C=>{const A=e.current;if(!A||!t.current.agents.get(C))return;const E=s.current,R=O=>{const j=n.current.get(O.id);return j?{x:O.position.x,y:O.position.y,width:j.width,height:j.height}:null},z=E.find(O=>O.id===C),I=z?R(z):null;if(!z||!I)return;const _=wn(z),D=o.current==="detail"?E.find(O=>O.type==="recapNote"&&wn(O)===_):void 0,L=fg(A),P=Yze({view:l(),pane:{width:L.width,height:L.height},insets:OU(r.current),card:I,note:D?R(D):null,minZoom:qv});Zs(),h.current={id:C,at:Date.now(),reveal:!0},P&&(u(),c(P,FA))},[c,l,u]);p.current=C=>{var A;return((A=h.current)!=null&&A.reveal?T:w)(C)};const y=m.useCallback(C=>{const A=a.current.filter(I=>I.type==="agent"),E=Oze(A.map(I=>({id:I.id,x:I.position.x,y:I.position.y})),b.current,C),R=E?A.find(I=>I.id===E):void 0;if(!R)return!1;const z=Zv(document.activeElement);return f(R.id,!1),window.setTimeout(()=>{try{T(R.id)}catch{}z&&fz(R.id)},30),!0},[f,T]),x=m.useCallback(C=>{f(C,!1),v==null||v(C),window.setTimeout(()=>{try{T(C)}catch{}window.setTimeout(()=>V0e(C),K0e(FA))},60)},[f,T,v]);return{focusAgent:w,revealAgent:T,stepAgent:y,focusSession:x}}function hqe({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:a}){const s=m.useCallback(u=>{const h=e.current.find(p=>p.id===u&&p.type==="agent");return h?h.data:void 0},[]),o=m.useCallback(u=>{const h=t.current.agents.get(u);return h?bu(h):void 0},[]),r=m.useCallback(()=>{const u=[];for(const h of e.current){const p=h.type==="agent"?h.data:void 0;(p==null?void 0:p.kind)==="root"&&u.push(p.sessionId)}return u},[]),c=m.useCallback(u=>{const h=e.current.find(f=>f.id===u&&f.type==="recapNote");if(!h)return;const p=h.data;return{note:p.note,plan:p.plan,sessionLabel:o(p.parentId)}},[]),l=m.useCallback(()=>{var p;const u=(p=n.current)==null?void 0:p.getBoundingClientRect(),h=document.documentElement;return u?{width:u.right-a.current,height:u.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekPeers:r,peekRecap:c,peekBounds:l}}function pqe(e){const t=new Set(e.pins),n=new Map,a=new Map;for(const[s,o]of e.positions)n.set(s,o),t.has(s)&&a.set(s,o);return{positions:n,pinned:a,restored:new Set(n.keys())}}function MU(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function gqe(e){const t={positions:[],pins:[]};if(!e)return t;let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!="object")return t;if(!("v"in n)){const s=MU(n);return{positions:s,pins:s.map(([o])=>o)}}const a=n;return{positions:MU(a.positions),pins:Array.isArray(a.pins)?a.pins:[]}}function mqe(e,t){const n={};for(const[a,s]of e)n[a]=s;for(const[a,s]of t)n[a]=s;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function fqe(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return!(typeof(t==null?void 0:t.width)=="number"&&typeof(t==null?void 0:t.height)=="number")||!(t.width>0&&t.height>0)?null:{width:t.width,height:t.height}}const $g="agent-dag.layout",Jg="agent-dag.layoutFrame",Yg="agent-dag.viewport";function bqe(){return gqe(gt($g))}function Wp(e,t){yt($g,mqe(e,t))}function kqe(){return fqe(gt(Jg))}function t8(e){yt(Jg,JSON.stringify(e))}function vqe(){return Vre(gt(Yg))}function wqe(e){yt(Yg,JSON.stringify(e))}function yqe(){return{layout:gt($g),frame:gt(Jg),viewport:gt(Yg)}}function xqe(e){const t=(n,a)=>a===null?Ja(n):yt(n,a);t($g,e.layout),t(Jg,e.frame),t(Yg,e.viewport)}function n8(){Ja($g),Ja(Yg),Ja(Jg)}const Ck=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function Cqe(e,t,n){return{positions:Ck(e.positions),pinned:Ck(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function Sqe(e,t){t.positions.clear();for(const[n,a]of Ck(e.positions))t.positions.set(n,a);t.pinned.clear();for(const[n,a]of Ck(e.pinned))t.pinned.set(n,a);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const Tqe=400,IU=7e3+Tqe,Nqe=2e3,Aqe=(e=S)=>e("board.rearrange.said"),DU=(e=S)=>e("board.rearrange.restored"),jqe={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function Eqe(e,t=jqe){let n=null,a=null,s=0,o=IU;const r=new Set,c=()=>{a!==null&&t.clear(a),a=null},l=()=>{c(),!(n===null||r.size>0)&&(s=t.now()+o,a=t.set(()=>{a=null,u()},o))};function u(){c(),r.clear(),n!==null&&(n=null,e(!1))}return{open(h){const p=n===null;n=h,o=IU,l(),p&&e(!0)},take(){const h=n;return u(),h},close:u,hold(h){n!==null&&(r.size===0&&a!==null&&(o=Math.max(0,s-t.now()),c()),r.add(h))},release(h){!r.delete(h)||r.size>0||n===null||(o=Math.max(o,Nqe),l())},get isOpen(){return n!==null},get snapshot(){return n}}}function Rqe(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function zqe({fitLeft:e,moveCamera:t,currentViewport:n}){const a=m.useState(()=>pqe(bqe()))[0],s=m.useRef(a.pinned),o=m.useRef(a.positions),r=m.useRef(new Set),c=m.useRef(new Set),l=m.useRef(""),[u,h]=m.useState(0),p=m.useRef(!1),f=m.useState(kqe)[0],b=m.useRef(f),[v,w]=m.useState(!1),[T,y]=m.useState(""),x=m.useState(()=>Eqe(L=>{w(L),L||y(P=>P===DU()?P:"")}))[0];m.useEffect(()=>()=>x.close(),[x]),m.useEffect(()=>{if(typeof document>"u")return;const L=()=>document.hidden?x.hold("hidden"):x.release("hidden");return document.addEventListener("visibilitychange",L),()=>document.removeEventListener("visibilitychange",L)},[x]);const C=m.useRef(null),A=()=>({positions:o.current,pinned:s.current,provisional:r.current,layoutSig:l}),E=m.useCallback(()=>{x.open(x.snapshot??Cqe(A(),yqe(),n())),y(Aqe()),s.current.clear(),o.current.clear(),l.current="",n8(),h(L=>L+1),C.current!=null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{C.current=null,Wp(o.current,s.current),b.current&&t8(b.current),e()},80)},[e,n,x]),R=m.useCallback(()=>{const L=x.take();return L?(C.current!=null&&window.clearTimeout(C.current),C.current=null,Sqe(L,A()),xqe(L.stored),h(P=>P+1),L.viewport&&t(L.viewport,Nl),y(DU()),!0):!1},[t,x]),z=m.useCallback(()=>x.close(),[x]),I=m.useCallback(L=>x.hold(L),[x]),_=m.useCallback(L=>x.release(L),[x]);return{restoredLayout:a,pinnedRef:s,positionsRef:o,provisionalRef:r,returningRef:c,lastLayoutSigRef:l,layoutEpoch:u,setLayoutEpoch:h,lastLayoutFrameRef:b,flowedRef:p,handleRelayout:E,rearrangeUndo:{open:v,said:T,undo:R,dismiss:z,hold:I,release:_}}}function qqe(e,t){const{positionsRef:n,pinnedRef:a}=t,s=m.useRef(null),o=m.useCallback(()=>{s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{Wp(n.current,a.current)},1500)},[]);return m.useEffect(()=>(o(),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e]),{saveSoon:o}}function _qe({settled:e,dragging:t,availableWidth:n,availableHeight:a,layout:s,camera:o,lastFocusRef:r,focusAgentRef:c,autoFitDisabledRef:l}){const{lastLayoutFrameRef:u}=s,{fitLeft:h,cameraEpochRef:p}=o;m.useEffect(()=>{if(!e||t)return;const f={width:n,height:a};if(!(f.width>0&&f.height>0))return;const b=u.current;if(u.current=f,t8(f),!b||b.width===f.width&&b.height===f.height)return;const v=r.current&&Date.now()-r.current.at<1500?r.current.id:null,w=p.current,T=window.setTimeout(()=>{var y;p.current===w&&(l.current?v&&((y=r.current)==null?void 0:y.id)===v&&c.current(v):h())},80);return()=>window.clearTimeout(T)},[n,a,e,t,h])}function Lqe(e,t=Date.now()){const n=Ag(e.agents.values()),a=new Map;for(const r of e.agents.values())r.kind==="root"&&!a.has(r.sessionId)&&a.set(r.sessionId,n.get(r.id)??r.sessionId);const s=[],o=new Set;for(const r of uv(e,t)){const c=a.get(r.sessionId)??r.sessionId;o.has(c)||(o.add(c),s.push(c))}return s}function Pqe(e,t,n,a,s){const o=[];for(const r of e)!Ng(r,t)||n.has(r.id)||o.push(r.id+(r.parentId?`>${r.parentId}`:""));return o.sort(),`${o.join("|")}#sv${a}.${s}`}function Oqe(e){return e!==""&&!e.startsWith("#sv")}const kz="agent-dag.removedNodes";function Mqe(e){try{const t=JSON.parse((e==null?void 0:e.getItem(kz))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function BA(e,t){try{e==null||e.setItem(kz,JSON.stringify([...t]))}catch{}}function a8(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),a=new Set(t),s=o=>{if(a.has(o))return!0;const r=new Set([o]);let c=n.get(o);for(;c&&!r.has(c);){if(a.has(c))return a.add(o),!0;r.add(c),c=n.get(c)}return!1};return o=>s(o.id)||s(o.sessionId??o.id)}function Iqe(e,t){if(t.size===0)return new Set;const n=[...e],a=a8(n,t);return new Set(n.filter(a).map(s=>s.id))}function Dqe(e,t,n){const a=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),s=a8(e.map(a),n),o=e.filter(c=>!s(a(c))),r=new Set(o.map(c=>c.id));return{nodes:o,edges:t.filter(c=>r.has(c.source)&&r.has(c.target))}}function Fqe(e,t){let n=null;for(const a of t)e.has(a)&&(n??=new Set(e),n.delete(a));return n??e}function Bqe(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function s8(e){let t=e.kind==="subagent"?e.startedAt:-1/0;const n=e.tools[e.tools.length-1];n&&n.startedAt>t&&(t=n.startedAt);const a=e.prompts[e.prompts.length-1];return a&&a.at>t&&(t=a.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function Uqe(e,t,n){let a=null;for(const s of t)e.has(s)||(a??=new Map(e),a.set(s,n));for(const s of e.keys())t.has(s)||(a??=new Map(e),a.delete(s));return a??e}function Wqe(e,t,n,a){if(n.size===0)return[];let s=1/0;for(const r of a.values())r<s&&(s=r);const o=new Set;for(const r of t){const c=e.get(r);if(!c)continue;const l=s8(c);if(l<=s)continue;const u=[],h=new Set,p=b=>{var v;for(let w=b;w&&!h.has(w);w=(v=e.get(w))==null?void 0:v.parentId)h.add(w),n.has(w)&&u.push(w)};p(c.id),p(c.sessionId);let f=-1/0;for(const b of u)f=Math.max(f,a.get(b)??1/0);if(l>f)for(const b of u)o.add(b)}return[...o]}function Hqe(e,t){if(!t||!e.agents.get(t))return null;const a=new Set([t]);let s=t;for(;s;){const r=e.agents.get(s);if(!(r!=null&&r.parentId)||a.has(r.parentId))break;a.add(r.parentId),s=r.parentId}let o=!0;for(;o;){o=!1;for(const r of e.agents.values())r.parentId&&a.has(r.parentId)&&!a.has(r.id)&&(a.add(r.id),o=!0)}return a}function Gqe(e,t){const n=new Set;for(const a of t){const s=Hqe(e,a);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function Vqe({stateRef:e,now:t,removedAgentIds:n,sizeVersion:a,domSizeVersion:s}){return m.useMemo(()=>Pqe(e.current.agents.values(),t,n,a,s),[e.current,e.current.revision,t,a,s,n])}function Kqe({stateRef:e,now:t,availableWidth:n,availableHeight:a,layout:s,measuredRef:o,onBubble:r,settled:c,dragging:l,layoutSig:u,selectedIds:h,openContext:p,historyReplayed:f,removedNodes:b,removedAgentIds:v,dragTick:w,dragPatchRef:T,dragMoveTick:y,onMoved:x,packed:C=!1}){const{pinnedRef:A,positionsRef:E,provisionalRef:R,returningRef:z,lastLayoutSigRef:I,restoredLayout:_,layoutEpoch:D,flowedRef:L}=s,P=m.useRef(x);P.current=x;const O=m.useMemo(()=>({flowed:L,order:()=>Lqe(e.current),onMoved:()=>{var J;return(J=P.current)==null?void 0:J.call(P)}}),[L,e]),j=m.useMemo(()=>Gqe(e.current,h),[e.current,e.current.revision,h]),M=m.useMemo(()=>{const J=yte(e.current,t);for(const X of v)J.delete(X);return J},[e.current,e.current.revision,t,v]),F=m.useRef(new Map),U=Kle(),{nodes:H,edges:$}=m.useMemo(()=>{const J=Lze(e.current,t,n,a,A.current,o.current,F.current,r,c,l,E.current,R.current,u,I,h,j,M,p,f,_.restored,z.current,O);return Dqe(J.nodes,J.edges,b)},[e.current,e.current.revision,t,n,a,c,l,u,h,j,M,p,w,U,b,D,f]),Y=m.useRef(null),W=m.useMemo(()=>C?((!l||!Y.current)&&(Y.current=kpe(H)),vpe(H,Y.current)):(Y.current=null,H),[H,C,l]),G=m.useMemo(()=>e8(W),[W]),Q=m.useMemo(()=>{const J=[...G,...W],X=T.current;return!X||X.size===0?J:J.map(te=>{const K=X.get(te.id);return K?{...te,position:K}:te})},[G,W,y]);return{spotlightSet:j,visibleAgentIds:M,nodes:H,shown:W,squeeze:Y.current,edges:$,allNodes:Q}}function $qe(e,t,n){const a=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,o=(e.x+e.width)*t.zoom+t.x,r=(e.y+e.height)*t.zoom+t.y;return o>0&&a<n.width&&r>0&&s<n.height}function Jqe({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 a=!1;for(const s of n)if(a=!0,$qe(s,t,e))return!1;return a}const Yqe=1500;function Zqe(e,t){return e>0&&t-e<Yqe?0:Nl}function Xqe({layoutSig:e,rf:t,stateRef:n,measuredRef:a,pinnedRef:s,positionsRef:o,paneSizeRef:r,lastInteractRef:c,autoFitDisabledRef:l,lastFitTimeRef:u,fitLeft:h}){const p=m.useRef(null),f=m.useRef(""),b=m.useRef(0),v=()=>h(Zqe(b.current,Date.now()));return m.useEffect(()=>{const T=setInterval(()=>{if(l.current||Date.now()-c.current<800)return;const y=n.current,x=Date.now(),C=[];for(const E of y.agents.values())Ng(E,x)&&C.push({id:E.id});if(C.length===0)return;const A=[];for(const{id:E}of C){const R=a.current.get(E),z=s.current.get(E)??o.current.get(E);!R||!z||A.push({x:z.x,y:z.y,width:R.width,height:R.height})}Jqe({pane:r.current,viewport:t.getViewport(),boxes:A})&&v()},1500);return()=>clearInterval(T)},[t]),m.useEffect(()=>{if(f.current===e)return;const T=f.current;if(f.current=e,!b.current&&Oqe(e)&&(b.current=Date.now()),!T||l.current)return;Date.now()-u.current>1200&&v(),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{l.current||v()},280)},[e,t,h]),{fitSoon:m.useCallback(()=>{l.current||(p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{l.current||v()},280))},[h])}}function Qqe({stateRef:e,pinnedRef:t,positionsRef:n,returningRef:a,canvasRef:s,clearSelection:o,primarySelectedId:r}){const[c,l]=m.useState(()=>Mqe(Gs())),[u,h]=m.useState(null),p=m.useMemo(()=>Iqe(e.current.agents.values(),c),[e.current,e.current.revision,c]),f=m.useCallback(C=>{const A=e.current.agents.get(C);A&&(l(E=>{const R=new Set(E);return R.add(C),BA(Gs(),R),R}),h({id:C,label:A.label}),t.current.delete(C),n.current.delete(C),o())},[o]),b=m.useCallback(()=>{r&&f(r)},[r,f]),v=u&&c.has(u.id)?u:null;m.useEffect(()=>{var C;u&&((C=s.current)==null||C.focus())},[u]);const w=m.useCallback(C=>{const A=[...C];l(E=>{let R=null;for(const z of A)E.has(z)||(R??=new Set(E),R.add(z));return R?(BA(Gs(),R),R):E})},[]),T=m.useCallback(C=>{const A=[...C];l(E=>{var z;const R=Fqe(E,A);R!==E&&BA(Gs(),R);for(const I of A)R!==E&&E.has(I)&&((z=e.current.agents.get(I))==null?void 0:z.kind)==="root"&&a.current.add(I);return R})},[]),y=m.useCallback(()=>{T([...c]),h(null)},[T,c]),x=m.useCallback(()=>{l(new Set),h(null),Ja(kz)},[]);return{removedNodes:c,lastRemoval:u,removedAgentIds:p,removeNode:f,removeSelectedNode:b,removalNotice:v,hideSessions:w,bringBack:T,bringBackAll:y,forgetRemovals:x}}function e_e({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:a,bringBack:s}){const o=m.useRef(new Map);m.useEffect(()=>{o.current=Uqe(o.current,a,Date.now());const r=[...Bqe(t,n),...Wqe(e.current.agents,n,a,o.current)];r.length>0&&s(r)},[t,n,a,s])}const i8=[0,5,15,30,60],vz="agent-dag.hide-finished-after",o8="agent-dag.hide-finished-turns",t_e=300,n_e=1e4;function wz(e){const t=Number(e);return i8.includes(t)?t:0}let yl=null;const Np=new Set;function r8(){for(const e of Np)e()}function FU(){return yl===null&&(yl=wz(gt(vz))),yl}function c8(e){const t=wz(String(e));yl!==t&&(yl=t,yt(vz,String(t)),r8())}function BU(e){if(e.key!==vz)return;const t=wz(e.newValue);t!==yl&&(yl=t,r8())}function a_e(e){var t;return Np.add(e),Np.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",BU)),()=>{var n;Np.delete(e),Np.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",BU))}}function s_e(e){try{const t=JSON.parse((e==null?void 0:e.getItem(o8))??"{}");return!t||typeof t!="object"||Array.isArray(t)?new Map:new Map(Object.entries(t).filter(n=>typeof n[1]=="number"))}catch{return new Map}}function UU(e,t){const n=[...t].sort((a,s)=>s[1]-a[1]).slice(0,t_e);try{e==null||e.setItem(o8,JSON.stringify(Object.fromEntries(n)))}catch{}}function l8(e){const t=new Map;for(const a of e){let s=t.get(a.sessionId);s||(s={endedAt:0,live:!1},t.set(a.sessionId,s)),a.kind==="root"&&bs(a.waiting)&&(s.live=!0),a.state==="done"&&a.endedAt!=null?s.endedAt=Math.max(s.endedAt,a.endedAt):s.live=!0}const n=new Map;for(const[a,s]of t)!s.live&&s.endedAt>0&&n.set(a,s.endedAt);return n}function i_e(e,{afterMs:t,now:n,removed:a,handled:s,keep:o}){if(t<=0)return[];const r=Array.isArray(o)?o:[o],c=[];for(const[l,u]of l8(e))n-u<t||a.has(l)||r.includes(l)||s.get(l)!==u&&c.push({id:l,endedAt:u});return c}function o_e(e,t,n,a){const s=[...t].filter(c=>!n.has(c));if(s.length===0)return e;const o=l8(a);let r=null;for(const c of s){const l=o.get(c);l==null||e.get(c)===l||(r??=new Map(e),r.set(c,l))}return r??e}function r_e(e,t){if(t.size===0)return!1;const n=new Map;for(const s of e.agents.values()){if(!t.has(s.sessionId))continue;const o=s8(s);o>(n.get(s.sessionId)??-1/0)&&n.set(s.sessionId,o)}let a=!1;for(const s of e.agents.values()){if(s.kind!=="subagent"||s.state!=="done"||s.endedAt==null||s.exitAt!=null)continue;const o=t.get(s.sessionId);o==null||s.endedAt>o||!((n.get(s.sessionId)??-1/0)>o)||(s.exitAt=o,a=!0)}return a&&(e.revision+=1),a}function d8(){return m.useSyncExternalStore(a_e,FU,FU)}function c_e({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:a,stageSessionId:s=null,ready:o}){const r=d8(),[c]=m.useState(()=>s_e(Gs())),l=m.useRef(c),u=m.useRef(t);m.useEffect(()=>{const h=o_e(l.current,u.current,t,e.current.agents.values());u.current=t,h!==l.current&&(l.current=h,UU(Gs(),h))},[t]),m.useEffect(()=>{o&&r_e(e.current,l.current)},[o,e.current,e.current.revision]),m.useEffect(()=>{if(!o||r===0)return;const h=()=>{const f=i_e(e.current.agents.values(),{afterMs:r*6e4,now:Date.now(),removed:t,handled:l.current,keep:[a,s]});if(f.length===0)return;const b=new Map(l.current);for(const{id:v,endedAt:w}of f)b.set(v,w);l.current=b,UU(Gs(),b),n(f.map(v=>v.id))};h();const p=window.setInterval(h,n_e);return()=>window.clearInterval(p)},[o,r,t,a,s,n])}function l_e({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) waiting · ${an}`:an,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const u8=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),h8=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),d_e=Object.freeze([...new Set([...Object.values(u8),...Object.values(h8)])]),eE=new Map;function WU(e){return eE.get(e)??e}async function u_e(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!eE.has(n))try{const a=await t(n),s=(a.headers.get("Content-Type")??"").split(";")[0].trim();if(!a.ok||!s.startsWith("image/"))return;eE.set(n,`data:${s};base64,${h_e(new Uint8Array(await a.arrayBuffer()))}`)}catch{}}))}function h_e(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function p_e({stateRef:e,waitingSessions:t,live:n}){const a=m.useMemo(()=>Vte(e.current.agents.values()),[e.current,e.current.revision]),s=m.useRef(null);m.useEffect(()=>{n&&u_e(d_e)},[n]),m.useEffect(()=>{const o=l_e({waiting:t.length,running:a,connected:n}),r=s.current;s.current=o,(r==null?void 0:r.title)!==o.title&&(document.title=o.title),(r==null?void 0:r.icon)!==o.icon&&p8(o.icon)},[t.length,a,n])}function p8(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=WU(u8[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=WU(h8[e]))}const g8=1200,g_e=1e3;function UA(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<g8?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<g_e}function m_e({applyViewport:e,takeOver:t,lastFitTimeRef:n,cameraEpochRef:a,disableAutoFit:s,markInteract:o,canvasRef:r,applyZoom:c,zoomFocusRef:l}){const u=m.useState(()=>vqe())[0];m.useEffect(()=>{if(!u)return;const y=window.setTimeout(()=>{try{e(u,0)}catch{}n.current=Date.now()},60);return()=>window.clearTimeout(y)},[e,u]);const h=m.useRef(null),p=m.useRef(0),f=m.useCallback(y=>{((y==null?void 0:y.type)==="pointerdown"||(y==null?void 0:y.type)==="wheel")&&t(),p.current=Date.now()},[t]),b=m.useCallback(y=>({hasSourceEvent:!!y,at:Date.now(),lastDeckFitAt:n.current,lastCanvasInputAt:p.current}),[]),v=y=>{Zs(),UA(b(y))&&(a.current+=1),UA(b(y))&&s()},w=m.useRef(null);return{restoredViewport:u,markCanvasInput:f,onMoveStart:v,onMove:(y,x)=>{var E;o(),UA(b(y))&&s();const C=w.current;w.current=x;const A=C&&l?wpe(C,x):null;if(A&&l){const R=n.current>0&&Date.now()-n.current<g8;l.current={...A,reader:!!y||!R}}(E=r.current)==null||E.style.setProperty("--zoom",String(x.zoom)),c(x.zoom)==="detail"&&Zs(),h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>wqe(x),250)}}}const HU="data-repack";function f_e({packed:e,nodes:t,squeeze:n,focusRef:a,canvasRef:s,getViewport:o,panBy:r}){const c=m.useRef({packed:e,squeeze:n}),l=m.useRef(null),u=c.current;u.packed!==e&&(l.current={from:u.squeeze,to:n}),c.current={packed:e,squeeze:n};const h=m.useRef(t);h.current=t,m.useLayoutEffect(()=>{var p;l.current&&((p=s.current)==null||p.setAttribute(HU,""))},[e]),m.useEffect(()=>{const p=l.current;if(!p)return;l.current=null;const f=a.current;f!=null&&f.reader&&r(ype(h.current,p.from,p.to,o(),f));const b=s.current;b&&requestAnimationFrame(()=>requestAnimationFrame(()=>b.removeAttribute(HU)))},[e])}function b_e({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:a,detailShown:s,focusAgent:o,revealAgent:r,draggingRef:c,lodRef:l,stage:u}){const h=m.useRef(r);h.current=r;const[p]=m.useState(()=>iG({focus:y=>h.current(y),setTimeout:(y,x)=>window.setTimeout(y,x),clearTimeout:y=>window.clearTimeout(y)}));return m.useEffect(()=>()=>p.cancel(),[p]),{onNodeClick:(y,x)=>{if(x.type==="sessionGroup"){p.cancel(),e();return}const C=x.type==="recapNote"?x.data.parentId:x.id;if(t(C,y.shiftKey,!1),!y.shiftKey){if(u!=null&&u.onNodeClick(C,y.currentTarget)){p.cancel();return}n&&a(!1),Ya()?p.hold(C):s?window.setTimeout(()=>{try{r(C)}catch{}},80):r(C)}},onPaneClick:()=>{p.cancel(),Zs(),e()},onNodeDoubleClick:(y,x)=>{if(x.type!=="agent"&&x.type!=="recapNote")return;p.cancel();const C=x.type==="recapNote"?x.data.parentId:x.id;t(C,!1),window.setTimeout(()=>{try{o(C)}catch{}},80)},onNodeMouseEnter:(y,x)=>{x.type!=="agent"&&x.type!=="recapNote"||c.current||l.current==null||l.current==="detail"||bz(x.id,y.currentTarget)},onNodeMouseLeave:(y,x)=>Zs(x.id)}}const k_e="board-head";function v_e({settleAt:e,now:t,take:n,schedule:a,cancel:s}){let o=null;const r=()=>{o!=null&&s(o),o=null};return{read(c,l){r();const u=e()-t();if(u>0){o=a(()=>{o=null,n(c,l)},u);return}n(c,l)},dispose:r}}function w_e(e){const t=m.useRef(null),n=m.useRef(null),[a,s]=m.useState({w:0,h:0}),o=m.useRef(()=>{});m.useLayoutEffect(()=>{const c=n.current;if(!c||typeof ResizeObserver>"u")return;const l=v_e({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(p,f)=>s(b=>Math.abs(b.w-p)>40||Math.abs(b.h-f)>40?{w:p,h:f}:b),schedule:(p,f)=>window.setTimeout(p,f),cancel:p=>window.clearTimeout(p)}),u=()=>{var p;return((p=c.querySelector(`:scope > .${k_e}`))==null?void 0:p.offsetHeight)??0},h=new ResizeObserver(p=>{var v;const f=(v=p[0])==null?void 0:v.contentRect;if(!f)return;const b={width:f.width,height:f.height-u()};t.current={width:b.width,height:b.height},l.read(b.width,b.height)});return h.observe(c),t.current={width:c.clientWidth,height:c.clientHeight},s({w:c.clientWidth,h:c.clientHeight}),o.current=()=>{const p=c.clientWidth,f=c.clientHeight-u();t.current={width:p,height:f},l.read(p,f)},()=>{h.disconnect(),l.dispose(),o.current=()=>{}}},[]);const r=m.useCallback(()=>o.current(),[]);return{canvasRef:n,canvasSize:a,paneSizeRef:t,remeasureCanvas:r}}function y_e(e,t){const n=qn(),a=m.useRef(new Map),s=m.useRef(0),o=m.useRef(new Map),[r,c]=m.useState(0),[l,u]=m.useState(0),h=m.useRef(null),p=m.useCallback(()=>{h.current=null;let b=!1;const v=n.getState().nodeInternals,w=t.current.agents,T=x=>v.has(x)||w.has(x)||x.startsWith("recap:")&&w.has(x.slice(6));for(const x of o.current.keys())T(x)||o.current.delete(x);for(const x of a.current.keys())T(x)||(a.current.delete(x),b=!0);for(const x of v.values()){if(x.type===ig)continue;const C=x.width,A=x.height;if(C==null||A==null)continue;const E=o.current.get(x.id);(!E||Math.abs(E.width-C)>4||Math.abs(E.height-A)>4)&&(o.current.set(x.id,{width:C,height:A}),a.current.set(x.id,{width:C,height:A}),b=!0)}if(b&&(s.current+=1,c(s.current)),e.current)return;let y=!1;for(const x of document.querySelectorAll(".react-flow__node[data-id]")){if(x.classList.contains(`react-flow__node-${ig}`))continue;const C=x.getAttribute("data-id");if(!C)continue;const A=x.offsetWidth,E=x.offsetHeight;if(!A||!E)continue;const R=a.current.get(C);(!R||Math.abs(R.width-A)>4||Math.abs(R.height-E)>4)&&(a.current.set(C,{width:A,height:E}),y=!0)}y&&u(x=>x+1)},[n,e,t]),f=m.useCallback(()=>{h.current||(h.current=document.visibilityState==="hidden"?{frame:0,timer:window.setTimeout(p,32)}:{frame:requestAnimationFrame(p),timer:0})},[p]);return m.useEffect(()=>{const b=n.subscribe(f);return f(),()=>{b();const v=h.current;v&&(cancelAnimationFrame(v.frame),window.clearTimeout(v.timer),h.current=null)}},[n,f]),m.useEffect(f),{measuredRef:a,measuredVersionRef:s,sizeVersion:r,domSizeVersion:l}}function x_e(){const[e,t]=m.useState(!1);return m.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function C_e(){const e=m.useRef(null);return m.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},a=s=>{e.current=performance.now()-t<250?s.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",a,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",a,!0)}},[]),e}const yz=3;function xz(e){if(!e)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[a,s]of Object.entries(t))typeof s=="number"&&Number.isFinite(s)&&s>0&&(n[a]=Math.min(yz,Math.floor(s)));return n}catch{return{}}}let Hp=null;const tE=new Set;function Sk(){return Hp===null&&(Hp=xz(gt(sg))),Hp}function m8(e,t=Sk()){return(t[e]??0)>=yz}function Xf(e){const t=Sk();if(m8(e,t))return;const n={...t};for(const[a,s]of Object.entries(xz(gt(sg))))n[a]=Math.max(n[a]??0,s);n[e]=Math.min(yz,(n[e]??0)+1),Hp=n,yt(sg,JSON.stringify(n)),S_e()}function S_e(){for(const e of tE)e()}function T_e(e){var n;tE.add(e);const t=a=>{a.key!==sg&&a.key!==null||(Hp=xz(gt(sg)),e())};return typeof window<"u"&&((n=window.addEventListener)==null||n.call(window,"storage",t)),()=>{var a;tE.delete(e),typeof window<"u"&&((a=window.removeEventListener)==null||a.call(window,"storage",t))}}function N_e(){return m.useSyncExternalStore(T_e,Sk,Sk)}function nE(e,t,n){const a=ku(e.agents.values());return a.length>0?(t(a[0].id),!0):n(1)}function f8(e,t,n,a=!1){const s=ku(e.agents.values()),o=a?Gte(s,t.current):c4(s,t.current);o&&(t.current=o.id,n(o.id))}function A_e(e,t,n){return n?null:e.kind==="step"?"sessions":e.kind==="focus-pane"?t==="Enter"?"openAndType":null:t==="n"||t==="N"?"nextWaiting":null}function GU(e,t,{onCard:n=!1,stageOpen:a=!1}={}){if(t)return null;if(n)return e==="Enter"?"select":null;switch(e){case"j":case"J":case"k":case"K":return"cards";case"n":case"N":return"nextWaiting";case"p":case"P":return a?null:"peek";default:return null}}function j_e({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:a,providersRef:s,soundOnRef:o,keyHelpOpenRef:r,modalOpenRef:c,waitingCursorRef:l,removeSelectedRef:u,activateSoundRef:h,clearSelection:p,selectAgent:f,focusAgent:b,stepAgent:v,focusSession:w,requestClear:T,handleRelayout:y,undoRearrange:x,handleFit:C,togglePause:A,toggleSessionList:E,toggleAccountsPanel:R,setDetailOpen:z,setUsageHistoryOpen:I,setUsagePanelOpen:_,setMachinePanelOpen:D,setBrowserWatchOpen:L,setKeyHelpOpen:P,setTheme:O,openSettings:j,openIntegrationRef:M,openQuickOpen:F,stageRef:U,viewRef:H,lodRef:$,inspectorSheetFoldRef:Y,inspectorDoorRef:W}){m.useEffect(()=>{let G=null;const Q=()=>{G&&clearTimeout(G.timer),G=null},J=(K,V,ee)=>{var de,he;if(K.kind==="step"){if(V.mode==="rail"){const ke=sI(V.order,((de=V.sessionAt)==null?void 0:de.call(V,ee))??V.current,K.direction);ke!=null&&V.focusTile(ke);return}const me=G?G.from:V.current,be=((he=V.sessionAt)==null?void 0:he.call(V,ee))??(G?G.to:V.current),ie=sI(V.order,be,K.direction);if(Q(),ie==null)return;V.focusTile(ie);const ne=setTimeout(()=>{G=null;const ke=U==null?void 0:U.current;!(ke!=null&&ke.open)||ke.current!==me||ke.current===ie||ke.switchTo(ie,{focusPane:!1})},F0e);G={to:ie,from:me,timer:ne};return}if(K.kind==="focus-pane"){const me=G;Q(),me&&me.to!==V.current&&me.from===V.current?V.switchTo(me.to,{focusPane:!0}):V.focusPane();return}Q(),V.nextAsk()},X=()=>{var de;if(Gze()!=null){Zs();return}if($&&($.current==null||$.current==="detail"))return;const K=n.current,V=a.current,ee=[V&&K.agents.has(V)?V:null,((de=ku(K.agents.values())[0])==null?void 0:de.id)??null];for(const he of ee){const me=he?Bze(he):null;if(he&&me&&Uze(me)){bz(he,me,"focus");return}}},te=K=>{var ke,Se,ve,xe,Ee,Ge,Qe,Je,He,_e,le,Re;const V=K.target,ee=((ke=V==null?void 0:V.hasAttribute)==null?void 0:ke.call(V,hle))===!0,de={tagName:V==null?void 0:V.tagName,isContentEditable:V==null?void 0:V.isContentEditable,role:(Se=V==null?void 0:V.getAttribute)==null?void 0:Se.call(V,"role"),type:V==null?void 0:V.type,pointerFocused:V!=null&&V===e.current&&!ee,caught:ee};if($R(K)){const ge=H==null?void 0:H.current;if(ge!=null&&ge.available){Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()})||(K.preventDefault(),K.repeat||Xf("view"),K.repeat||ge.toggle());return}}if(HK(V)){JR(K)&&(K.preventDefault(),K.repeat||(ve=U==null?void 0:U.current)==null||ve.release());return}if(K.key==="Escape"){const ge=cle({overlayOpen:Rn.depth()>0,typing:bl(de)});ge==="dismiss"?Rn.dismissTop():ge==="blur"?V==null||V.blur():Y!=null&&Y.current&&((xe=V==null?void 0:V.closest)!=null&&xe.call(V,".detail"))?Y.current():Y!=null&&Y.current&&((Ee=V==null?void 0:V.closest)!=null&&Ee.call(V,".stage-dock"))||(Fze(de)&&(V==null||V.blur()),p(),Zs());return}if(NG(K,zs(js()))){if(Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}))return;K.preventDefault(),K.repeat||F();return}if(K.key===","&&_me(K)){if(bl(de)||Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}))return;K.preventDefault(),K.repeat||j();return}if(Rqe(K)){if(bl(de)||Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}))return;!K.repeat&&x()&&K.preventDefault();return}if(tv(K))return;const he=Zv(V)?(Ge=V==null?void 0:V.getAttribute)==null?void 0:Ge.call(V,"data-id"):null,me=he&&t.current.some(ge=>ge.id===he)?he:null,be=Ize(K,me);if(be.kind==="activate"){K.preventDefault();const ge=GU(K.key,K.repeat,{onCard:!0});ge&&Xf(ge),f(be.nodeId,be.additive);return}if(be.kind==="node"||Qde(K.key,Zj()))return;if(kle({key:K.key,sheetOpen:r.current,target:de})){K.repeat||P(!1);return}if(K.key==="t"||K.key==="T"){const ge=Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()});if(be.nodeId==null&&vle({target:de,modalOpen:ge}))return;K.repeat||O(Afe);return}const ie=U==null?void 0:U.current;if(ie!=null&&ie.open){const ge=B0e({key:K.key,repeat:K.repeat,target:de,modalOpen:Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()})});if(ge){K.preventDefault();const Pe=A_e(ge,K.key,K.repeat);Pe&&Xf(Pe),J(ge,ie,K.target);return}}if(be.nodeId==null&&Vb(de,K.key)||ble({key:K.key,modalOpen:Fr({appModal:c.current,dialogDepth:Rn.dialogDepth()}),sheetOpen:r.current})||K.repeat&&!/^[jkJK]$/.test(K.key))return;if(/^[1-4]$/.test(K.key)&&!K.ctrlKey&&!K.metaKey&&!K.altKey&&((Qe=U==null?void 0:U.current)!=null&&Qe.open)&&((He=(Je=U.current).focusPaneAt)!=null&&He.call(Je,Number(K.key)))){K.preventDefault();return}const ne=GU(K.key,K.repeat,{stageOpen:!!((_e=U==null?void 0:U.current)!=null&&_e.open)});if(ne&&Xf(ne),(K.key==="c"||K.key==="C")&&T("shortcut"),(K.key==="r"||K.key==="R")&&y(),(K.key==="f"||K.key==="F")&&C(),(K.key==="z"||K.key==="Z")&&a.current&&b(a.current),K.key==="Delete"&&u.current(),(K.key==="l"||K.key==="L")&&E(),(K.key==="d"||K.key==="D")&&(a.current?z(ge=>!ge):nE(n.current,w,v)||(le=W==null?void 0:W.current)==null||le.call(W)),(K.key==="h"||K.key==="H")&&I(ge=>!ge),(K.key==="u"||K.key==="U")&&_(ge=>!ge),(K.key==="a"||K.key==="A")&&(s.current.claude||s.current.codex)&&R(),(K.key==="j"||K.key==="J")&&v(1),(K.key==="k"||K.key==="K")&&v(-1),K.key==="w"||K.key==="W"){const ge=c4(ku(n.current.agents.values()),l.current);ge&&(l.current=ge.id,w(ge.id))}(K.key==="n"||K.key==="N")&&f8(n.current,l,w,K.shiftKey),(K.key==="p"||K.key==="P")&&((Re=U==null?void 0:U.current)!=null&&Re.open||X()),(K.key==="m"||K.key==="M")&&o.current!==null&&h.current(K.shiftKey),(K.key==="s"||K.key==="S")&&D(ge=>!ge),(K.key==="b"||K.key==="B")&&L(ge=>!ge),(K.key==="v"||K.key==="V")&&j("sounds"),(K.key==="i"||K.key==="I")&&(M==null||M.current("jira")),K.key==="?"&&P(ge=>!ge)};return window.addEventListener("keydown",te),()=>{window.removeEventListener("keydown",te),Q()}},[T,y,x,C,p,f,v,w,b,A])}function E_e(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function R_e({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:a,codexShown:s=!1,detailShown:o,primarySelectedId:r,canvasRef:c}){const l={sessionList:m.useRef(null),usage:m.useRef(null),accounts:m.useRef(null),codex:m.useRef(null),machine:m.useRef(null)},u=h=>()=>{E_e()&&h()};return{toggles:l,sessionList:u(so(!e,l.sessionList)),usage:u(so(!t,l.usage)),machine:u(so(!n,l.machine)),accounts:u(so(!a,l.accounts)),codex:u(so(!s,l.codex)),detail:u(so(!o,()=>{var h,p;r&&fz(r),fa(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((p=c.current)==null||p.focus({preventScroll:!0}))}))}}function z_e({nodes:e,shown:t=e,squeeze:n=null,stateRef:a,pinnedRef:s,positionsRef:o,draggingRef:r,dragPatchRef:c,setDragging:l,setDragMoveTick:u,setDragTick:h,endBubble:p,markInteract:f,disableAutoFit:b,beginTrashDrag:v,trackTrashDrag:w,endTrashDrag:T,removeNode:y}){const x=m.useRef(null),C=I=>n?{x:n.back(I.x),y:I.y}:{x:I.x,y:I.y},A=(I,_)=>n?n.back(I+_)-n.back(I):_;return{onNodeDragStart:(I,_)=>{var D,L;if(_){if(Zs(),p(),r.current=!0,c.current=new Map,l(!0),f(),b(),_.type==="sessionGroup"){const P=(D=_.data)==null?void 0:D.sessionId,O=new Map,j=new Map,M=new Map;let F=1/0;if(P){for(const H of e)!H.data||wn(H)!==P||(O.set(H.id,{x:H.position.x,y:H.position.y}),M.set(H.id,s.current.get(H.id)));for(const H of t)O.has(H.id)&&(j.set(H.id,{x:H.position.x,y:H.position.y}),H.type==="agent"&&(F=Math.min(F,H.position.x)))}x.current={sessionId:P,start:{x:_.position.x,y:_.position.y},members:O,drawn:j,anchor:Number.isFinite(F)?F:_.position.x,pinsBefore:M};const U=P?a.current.agents.get(P):void 0;v(U?U.label:null);return}v(_.type==="agent"?((L=a.current.agents.get(_.id))==null?void 0:L.label)??"":null),s.current.set(_.id,C(_.position))}},onNodeDrag:(I,_)=>{var D;if(_){if(f(),(_.type==="agent"||_.type==="sessionGroup")&&w(I),_.type==="sessionGroup"){const L=x.current;if(!L)return;const P=_.position.x-L.start.x,O=_.position.y-L.start.y,j=A(L.anchor,P);for(const[F,U]of L.members){const H={x:U.x+j,y:U.y+O};s.current.set(F,H),o.current.set(F,H)}const M=c.current;if(M){for(const[F,U]of L.members){const H=L.drawn.get(F)??U;M.set(F,{x:H.x+P,y:H.y+O})}M.set(_.id,{x:_.position.x,y:_.position.y})}u(F=>F+1);return}s.current.set(_.id,C(_.position)),o.current.set(_.id,C(_.position)),(D=c.current)==null||D.set(_.id,{x:_.position.x,y:_.position.y}),u(L=>L+1)}},onNodeDragStop:(I,_)=>{f();const D=T(I,(_==null?void 0:_.type)==="agent"||(_==null?void 0:_.type)==="sessionGroup");if(r.current=!1,c.current=null,l(!1),h(L=>L+1),!_){x.current=null,Wp(o.current,s.current);return}if(_.type==="sessionGroup"){const L=x.current;if(L&&D&&L.sessionId){for(const[P,O]of L.members){const j=L.pinsBefore.get(P);j?s.current.set(P,j):s.current.delete(P),o.current.set(P,O)}x.current=null,y(L.sessionId);return}if(L){const P=_.position.x-L.start.x,O=_.position.y-L.start.y,j=A(L.anchor,P);for(const[M,F]of L.members){const U={x:F.x+j,y:F.y+O};s.current.set(M,U),o.current.set(M,U)}}x.current=null,Wp(o.current,s.current),h(P=>P+1);return}if(s.current.set(_.id,C(_.position)),o.current.set(_.id,C(_.position)),D){y(_.id);return}Wp(o.current,s.current)}}}function q_e(e,t=S){if(e==null)return{kind:"unknown",lead:t("board.scope.unknown"),workspace:null,tail:""};const n=e.trim();return n===""?{kind:"machine",lead:t("board.scope.machine"),workspace:null,tail:""}:{kind:"scoped",lead:t("board.scope.scopedLead"),workspace:n,tail:t("board.scope.scopedTail")}}function Cz(e,t){return e.split(new RegExp(`(${t.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`)).map((a,s)=>t.includes(a)?i.jsx("code",{children:a},s):a)}function b8(){return i.jsx("div",{className:"empty-symbol","aria-hidden":"true",children:i.jsxs("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"m6 8 4 4-4 4"}),i.jsx("path",{d:"M13 16h5"})]})})}function __e({reservedRight:e=0}){const t=se();return i.jsx("div",{className:"empty-stage",style:{right:e},children:i.jsxs("div",{className:"empty-hero empty-notice",children:[i.jsx(b8,{}),i.jsx("h2",{children:t("board.hero.tabs",{product:an})}),i.jsx("p",{children:Cz(t("board.hero.tabsBody",{product:an}),[an])})]})})}function L_e({live:e,everConnected:t,providers:n,workspace:a,onTour:s,onNewSession:o,reservedRight:r=0}){const c=se(),l=!e;return i.jsx("div",{className:"empty-stage",style:{right:r},children:i.jsxs("div",{className:l?"empty-hero empty-notice":"empty-hero",children:[l?i.jsxs(i.Fragment,{children:[i.jsx(b8,{}),i.jsx("h2",{children:c(t?"board.hero.disconnected":"board.hero.unreachable")}),i.jsx("p",{children:Cz(c(t?"board.hero.lost":"board.hero.cannotReach",{product:an}),[an])})]}):O_e(n,a,c,o),!l&&i.jsxs("div",{className:"empty-actions",role:"group","aria-label":c("board.hero.explore"),"data-quiet":o?"":void 0,children:[i.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:c("board.hero.tour")}),i.jsx(F0,{film:"tour",action:!0})]})]})})}const P_e=["claude","codex"];function O_e(e,t,n,a){const s=q_e(t,n);return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:n("board.hero.noSessions")}),a&&i.jsx("button",{type:"button",className:"btn primary empty-new","aria-haspopup":"dialog",title:n("board.newSession.hint"),onClick:o=>a(o.currentTarget),children:n("board.newSession.title")}),s.kind==="scoped"?i.jsxs("p",{children:[s.lead," ",i.jsx("code",{children:s.workspace}),s.tail]}):a?i.jsx("p",{className:"empty-or",children:Cz(n("board.hero.orRun"),P_e)}):i.jsx("p",{children:n("board.hero.startHint")}),i.jsxs("details",{className:"empty-help",children:[i.jsx("summary",{children:n("board.hero.notShowing")}),hce(e).map(o=>i.jsx("p",{className:"hint-row",children:o.spans.map((r,c)=>r.code?i.jsx("code",{children:r.text},c):i.jsx("span",{children:r.text},c))},o.provider))]})]})}const M_e=1;function I_e(e){return{id:e.id,name:e.name,inputPreview:e.inputPreview,startedAt:e.startedAt,endedAt:e.endedAt,ok:e.ok,errorPreview:e.errorPreview,usage:e.usage}}function D_e(e,t,n){const a=e.agents.get(t);if(!a)return null;const s=[];for(const o of e.agents.values())o.sessionId===t&&s.push(o);return{schemaVersion:M_e,exportedAt:n,sessionId:t,label:a.label,cwd:a.cwd,startedAt:a.startedAt,endedAt:a.endedAt,model:a.model,agents:s.map(o=>({id:o.id,kind:o.kind,label:o.label,parentId:o.parentId,state:o.state,startedAt:o.startedAt,endedAt:o.endedAt,model:o.model,cwd:o.cwd,usage:o.usage,prompts:o.prompts,tools:o.tools.map(I_e)}))}}function F_e(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${an}-${n}-${$b(t,8)}.json`}function B_e(e){const t=Eg(e),n=t.tone==="active"?"working":t.tone==="waiting"?"waiting":t.tone==="partial"?"partial":t.tone==="err"?"error":t.tone==="ready"?"idle":"done",a=t.tone==="partial"?`${S("board.card.stateDone")} · ${t.word}`:t.word;return{glyph:n,phrase:a.toLowerCase()}}function U_e(e,t,n,a){const[s,o]=m.useState(null);return m.useEffect(()=>{if(!a||s)return;let r=!0;return Xs(()=>import("./inspector-status-pane-BY6DHEeo.js"),__vite__mapDeps([0,1])).then(c=>{r&&o(c)},()=>{}),()=>{r=!1}},[a,s]),s&&e.kind==="root"?s.paneStatus(e,t,n):B_e(e)}const $r=["agents","time","context"],k8="agent-dag.inspector-tab",v8={get agents(){return S("board.inspector.tabAgents")},get time(){return S("board.inspector.tabTime")},get context(){return S("board.inspector.tabContext")}};function W_e(){const e=gt(k8);return $r.find(t=>t===e)??"agents"}function H_e(e){yt(k8,e)}const w8="agent-dag.inspector-details";function G_e(){return gt(w8)==="1"}function V_e(e){yt(w8,e?"1":"0")}const K_e={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},aE=ZE;function Sz(e,t){for(const n of e.values())if(n.sessionId===t&&n.kind==="root")return n;return e.get(t)}function $_e(e,t){const n=[];for(const h of e.values())h.sessionId===t&&n.push(h);const a=Sz(e,t);if(!a)return[];const s=new Map(n.map(h=>[h.id,h])),o=h=>{const p=new Set;let f=h;for(;f;){if(f===a)return!0;if(p.has(f.id))return!1;p.add(f.id),f=f.parentId?s.get(f.parentId):void 0}return!1},r=new Map;for(const h of n){if(h===a)continue;const p=h.parentId&&o(h)?h.parentId:a.id,f=r.get(p);f?f.push(h):r.set(p,[h])}for(const h of r.values())h.sort((p,f)=>p.startedAt-f.startedAt||(p.id<f.id?-1:p.id>f.id?1:0));const c=[],l=new Set,u=(h,p)=>{if(l.has(h.id))return;l.add(h.id),c.push({agent:h,depth:p.length,more:p});const f=r.get(h.id)??[];f.forEach((b,v)=>u(b,[...p,v<f.length-1]))};return u(a,[]),c}function J_e(e){const t=e.length-1;return t<=0?S("board.inspector.noSubagents"):S("board.inspector.subagents",{count:t})}const sE=e=>{var t;return((t=QE(e.name,e.input))==null?void 0:t.detail)??Y_e(e.inputPreview??"")},y8=(e,t)=>rte(e.name)&&/[\\/]/.test(t)&&!t.endsWith("…");function Y_e(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return t;const n=(a,s=0)=>{if(typeof a=="string")return a;if(s>2||a===null||typeof a!="object")return null;for(const o of Object.values(a)){const r=n(o,s+1);if(r)return r}return null};try{return n(JSON.parse(t))??""}catch{const a=/"(?:[^"\\]|\\.)*"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(t);return a?a[1].replace(/\\(.)/g,"$1"):""}}function VU(e,t=!1){return t||e==="Task"||e==="Agent"?"agents":e==="Read"||e==="Edit"||e==="Write"||e==="MultiEdit"||e==="NotebookEdit"?"file":e==="Search"||e==="Grep"||e==="Glob"||e==="WebSearch"||e==="WebFetch"?"search":e==="Bash"?"terminal":"tools"}const Ap=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function Z_e(e){if(e===null)return null;const t=e;if(!(typeof t!="object"||typeof t.open!="boolean"||!Ap(t.totalMs)||!Ap(t.claudeMs)||!Ap(t.machineMs)||!Ap(t.youMs)))return{open:t.open,totalMs:t.totalMs,claudeMs:t.claudeMs,machineMs:t.machineMs,youMs:t.youMs}}async function X_e(e,t){const n=await fetch(`/api/tool-audit?session=${encodeURIComponent(e)}`,{signal:t});if(n.ok)return Z_e(await n.json())}const Q_e=5e3,WA=15e3;function eLe(e,t,n){if(!e.open||(t==null?void 0:t.kind)!=="permission"||!Ap(t.since))return e;const a=Math.min(e.machineMs,Math.max(0,n-t.since));return a>0?{...e,machineMs:e.machineMs-a,youMs:e.youMs+a}:e}function ao(e){const t=Math.max(0,Math.round(e));return Math.round(t/100)<100?`${(Math.round(t/100)/10).toFixed(1)}s`:Cu(0,Math.round(t/1e3)*1e3,0)}function tLe(e){return e.totalMs>0?Math.round(e.youMs/e.totalMs*100):0}function nLe(e){return[["you",e.youMs],["claude",e.claudeMs],["machine",e.machineMs]].filter(([,t])=>t>0).map(([t,n])=>({lane:t,ms:n}))}const aLe=new Set(["Task","Agent"]);function sLe(e){var a;const t=(a=e.prompts.at(-1))==null?void 0:a.at;if(t!==void 0)return t;let n=null;for(const s of e.tools)(n===null||s.startedAt<n)&&(n=s.startedAt);return n}function iLe(e){const{agents:t,sessionId:n,start:a,now:s}=e,o=Sz(t,n),r=[];if(!o)return{rows:r,start:a,end:e.end};const c=new Map;for(const p of t.values()){if(p.sessionId!==n||p===o||!p.parentId)continue;const f=c.get(p.parentId);f?f.push(p):c.set(p.parentId,[p])}const l=new Set,u=(p,f,b)=>{if(l.has(p.id))return;l.add(p.id);const v=[...p.tools].sort((C,A)=>C.startedAt-A.startedAt),w=(c.get(p.id)??[]).sort((C,A)=>C.startedAt-A.startedAt),T=new Map,y=[];for(const C of w){let A;for(const E of v)aLe.has(E.name)&&!T.has(E.id)&&E.startedAt<=C.startedAt+1e3&&(A=E);A?T.set(A.id,C):y.push(C)}const x=[...v.map(C=>({at:C.startedAt,call:C,kid:T.get(C.id)})),...y.map(C=>({at:C.startedAt,kid:C}))].sort((C,A)=>C.at-A.at);for(const{at:C,call:A,kid:E}of x)if(!(C<a)){if(E){const R=`g:${E.id}`;r.push({key:R,name:E.label||(A==null?void 0:A.name)||"Agent",arg:A?sE(A):"",depth:f,group:!0,under:b,from:C,to:A?A.endedAt??null:E.endedAt??null,waitingSince:null}),u(E,f+1,[...b,R])}else if(A){const R=sE(A);r.push({key:`c:${p.id}:${A.id}`,name:A.name,arg:R,...y8(A,R)?{path:!0}:{},depth:f,group:!1,under:b,from:C,to:A.endedAt??null,waitingSince:null})}}};u(o,0,[]),oLe(r,o.waiting);let h=e.end;for(const p of r)h=Math.max(h,p.to??Math.min(s,h));return{rows:r,start:a,end:h,...o.cwd?{cwd:o.cwd}:{}}}function oLe(e,t){if(!(!t||t.kind==="idle"))for(let n=e.length-1;n>=0;n--){const a=e[n];if(!(a.group||a.to!==null)&&!(t.tool&&t.tool.name!==a.name)){a.waitingSince=t.since;return}}}function rLe(e){const t=Math.max(1,e.end-e.start);return[0,1,2,3].map(n=>n===0?"0":ao(t*n/3))}function cLe(e,t,n){const a=Math.max(1,t.end-t.start),s=e.to??Math.min(n,t.end),o=Math.min(100,Math.max(0,(e.from-t.start)/a*100));return{left:o,width:Math.min(100-o,Math.max(0,(s-e.from)/a*100))}}function lLe({agent:e,now:t}){const n=se(),a=m.useRef(null),s=fG(e),o=bG(s==null?void 0:s.sessionId,a);return i.jsxs(i.Fragment,{children:[o.on&&s?i.jsx(kG,{facts:s,place:"hero",onDone:o.done}):i.jsx("h2",{className:"hero-title","data-renamable":s?"":void 0,onDoubleClick:s?o.start:void 0,title:e.kind==="root"?[e.cwd??e.label,Tu(e.startedAt,e.sessionId,void 0,t,n)].join(`
|
|
149
149
|
`):e.cwd??e.label,children:e.kind==="root"?Wl(e).title:e.label}),s&&!o.on&&i.jsx("button",{ref:a,type:"button",className:"glyph-btn hero-rename","aria-label":n("board.rename.action"),title:n("board.rename.tip"),onClick:o.start,children:i.jsx(qge,{})})]})}function dLe(e,t){return e.kind!=="root"||!t.canOpen?null:bs(e.waiting)?"answer":t.stageSession===e.sessionId?null:"open"}function uLe({agent:e,now:t,onOpenTool:n,onShowSummary:a,onOpenSession:s,stageSession:o=null,onExportSession:r,onRemove:c,singleKeys:l=!0,status:u}){const h=se(),p=Es(),f=`${e.synthetic?"≥ ":""}${Cu(e.startedAt,e.endedAt,t)}`,b=fs(e),v=b.total>0,w=e.usage.inputTokens+e.usage.outputTokens,T=j1(e),y=h5(e.prompts),x=gLe(y,T),C=xu(e,h)!==h("board.kind.session");return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"detail-hero",children:[i.jsxs("div",{className:"hero-line",children:[i.jsx("span",{className:"hero-state",role:"img","data-state":(u==null?void 0:u.glyph)??"idle","aria-label":(u==null?void 0:u.phrase)??cu(e).word,title:(u==null?void 0:u.phrase)??cu(e).word,children:i.jsx(Ys,{name:(u==null?void 0:u.glyph)??(e.state==="active"?"working":e.state==="err"?"error":"done")})}),i.jsx(lLe,{agent:e,now:t}),(r||c)&&i.jsx(pLe,{agent:e,onExportSession:r,onRemove:c,singleKeys:l})]}),i.jsxs("div",{className:"hero-meta",children:[C&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hero-meta-item",children:xu(e,h)}),i.jsx("span",{className:"hero-sep",children:"·"})]}),i.jsx("span",{className:"hero-meta-item","aria-hidden":"true",children:(u==null?void 0:u.phrase)??cu(e).word.toLowerCase()}),i.jsx("span",{className:"hero-sep",children:"·"}),i.jsx("span",{className:"hero-meta-item",title:h("board.detail.started",{time:new Date(e.startedAt).toLocaleString(p)}),children:f}),e.model&&(()=>{const A=_4(e);return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hero-sep",children:"·"}),i.jsxs("span",{className:"model-chip","data-family":M4(e.model),title:A.length>0?`${Uj(e.model,e.effort)}
|
|
150
150
|
${h("board.detail.modelCovers")}
|
|
151
151
|
${A.join(`
|
|
152
152
|
`)}`:Uj(e.model,e.effort),children:[Rg(e.model,e.effort),A.length>0?` +${A.length}`:""]})]})})()]}),v&&i.jsx("div",{className:"hero-cost",children:i.jsxs("div",{className:"hero-cost-headline",children:[i.jsx("span",{className:"hero-cost-value",children:Ut(b.total)}),i.jsx("span",{className:"hero-cost-label",children:h("board.detail.spend")})]})})]}),(()=>{const A=dLe(e,{canOpen:s!==void 0,stageSession:o}),E=e.kind==="root"&&e.state==="done"?a:void 0;if(!A&&!E)return null;const R=Wl(e).title,z=A==="answer";return i.jsxs("div",{className:"hero-actions",children:[A&&s&&i.jsx("button",{type:"button",className:z?"btn primary":"btn","aria-label":z?h("board.keys.answerLabel",{name:R}):h("board.stage.open",{name:R}),onClick:()=>s(e.sessionId),children:h(z?"board.keys.answer":"board.quick.verb.open")}),E&&i.jsx("button",{type:"button",className:"btn",onClick:()=>E(e.sessionId),title:h("board.detail.recapTitle"),children:h("board.detail.recap")})]})})(),i.jsx(Ude,{agent:e}),(()=>{if(!T)return null;const A=Yb(T.at,t),E=T.kind==="recap"?h("board.detail.recapHeading"):Su(T.kind).replace(/^./,R=>R.toUpperCase());return i.jsxs("section",{className:"detail-section detail-note",children:[i.jsxs("h3",{children:[E," ",i.jsx("span",{className:"section-count",title:A.title,children:A.label})]}),i.jsx("p",{className:"detail-recap",title:av(T),children:T.text}),T.reply&&i.jsx("p",{className:"detail-recap detail-note-reply",children:h("board.detail.suggestedReply",{reply:T.reply})})]})})(),(()=>{const A=yo(e.plan);return!A||!e.plan?null:i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:[h("board.detail.plan")," ",i.jsxs("span",{className:"section-count","aria-hidden":!0,children:[A.done,"/",A.total]}),i.jsx("span",{className:"vis-hidden",children:h("board.detail.planDone",{done:A.done,total:A.total})})]}),e.plan.note&&i.jsx("p",{className:"detail-plan-note",children:e.plan.note}),i.jsx("ol",{className:"plan-list",children:e.plan.items.map((E,R)=>i.jsxs("li",{className:"plan-item","data-status":E.status,children:[i.jsx("span",{className:"plan-mark","aria-hidden":!0,children:i.jsx(Ys,{name:E.status==="completed"?"done":E.status==="in_progress"?"working":"idle"})}),i.jsxs("span",{className:"vis-hidden",children:[h(wLe[E.status]),h("board.detail.colon")]}),i.jsx("span",{className:"plan-text",children:E.status==="in_progress"&&E.active?E.active:E.text}),E.status==="in_progress"&&i.jsx("span",{className:"plan-now","aria-hidden":!0,children:h("board.detail.now")})]},E.id??`${R}:${E.text}`))})]})})(),x.length>0&&i.jsxs("section",{className:"detail-section detail-prompt-history",children:[i.jsxs("h3",{children:[x.length<y.length?h("board.detail.earlierPrompts"):h("board.detail.prompts")," ",i.jsx("span",{className:"section-count",children:x.length})]}),i.jsx("div",{className:"prompts",children:bLe(y).filter(({pr:A})=>x.includes(A)).reverse().map(({pr:A,key:E})=>{const R=Yb(A.at,t);return i.jsxs("div",{className:"prompt-entry",children:[i.jsx("div",{className:"prompt-time",title:R.title,children:R.label}),i.jsx("div",{className:"prompt-text",children:A.text})]},E)})})]}),i.jsxs(hLe,{calls:Math.max(e.toolCount,e.tools.length),children:[(v||w>0)&&i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:h("board.detail.tokens")}),i.jsx(rR,{cost:b}),w>0&&i.jsxs("div",{className:"tokens-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"k tk-key tk-in",children:h("board.tokens.in")}),i.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:Yt(e.usage.inputTokens)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k tk-key tk-out",children:h("board.tokens.out")}),i.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:Yt(e.usage.outputTokens)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k tk-key tk-cr",children:h("board.tokens.cacheR")}),i.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:Yt(e.usage.cacheReadTokens)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k tk-key tk-cw",children:h("board.tokens.cacheC")}),i.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:Yt(e.usage.cacheCreateTokens)})]})]})]}),i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:h("board.detail.identity")}),i.jsxs("div",{children:[e.cwd&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"cwd"}),i.jsx(zg,{className:"v",path:e.cwd})]}),i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:h("board.kind.session")}),i.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:h("board.detail.parent")}),i.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),i.jsx(mLe,{agent:e,onOpenTool:n},e.id)]})]})}function hLe({calls:e,children:t}){const n=se(),[a,s]=m.useState(G_e);return i.jsxs("details",{className:"detail-more",open:a,onToggle:o=>{const r=o.currentTarget.open;r!==a&&(s(r),V_e(r))},children:[i.jsxs("summary",{children:[i.jsx(Ze,{name:"chevron-right",className:"detail-more-chev"}),i.jsx("span",{children:n("common.details")}),e>0&&i.jsx("span",{className:"detail-more-count",children:n("board.spark.tools",{count:e})})]}),i.jsx("div",{className:"detail-more-body",children:t})]})}function pLe({agent:e,onExportSession:t,onRemove:n,singleKeys:a}){const s=se(),o=m.useId(),r=`${o}-more`,c=`${o}-more-menu`,[l,u]=m.useState(null),h=l!==null,p=s("accounts.row.more"),f=b=>{var v;(v=document.getElementById(r))==null||v.focus(),u(null),window.requestAnimationFrame(b)};return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",id:r,className:"glyph-btn hero-more","aria-label":p,title:p,"aria-haspopup":"menu","aria-expanded":h,"aria-controls":h?c:void 0,onKeyDown:b=>{b.key!=="ArrowDown"&&b.key!=="ArrowUp"||(b.preventDefault(),u(b.key==="ArrowUp"?"last":"first"))},onClick:()=>u(h?null:"first"),children:i.jsx(Ze,{name:"more"})}),h&&i.jsxs(Rs,{anchorId:r,id:c,className:"ap-pop",role:"menu",labelledBy:r,start:l,onClose:()=>u(null),children:[t&&i.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:s("board.detail.exportTitle"),onClick:()=>f(()=>t(e.sessionId)),children:s("board.detail.export")}),n&&i.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:e.kind==="root"?s("board.detail.removeRoot",{list:bo(s("board.detail.listLower"),"L",a)}):s("board.detail.removeSub",{list:bo(s("board.detail.listUpper"),"L",a)}),onClick:()=>f(n),children:s("board.detail.remove")})]})]})}function gLe(e,t){let n=null;for(const a of e)(!n||a.at>n.at)&&(n=a);return!t||!n||A1(n.text)!==t.text?e.slice():e.filter(a=>a!==n)}function mLe({agent:e,onOpenTool:t}){var b;const n=se(),[a,s]=m.useState(null),o=new Map;for(const[v,w]of e.toolCountByName??[]){const T=aE(v);o.set(T,(o.get(T)??0)+w)}const r=e.toolErrorCount??0,c=e.tools.filter(v=>!v.endedAt).length,l=Array.from(o.entries()).sort((v,w)=>w[1]-v[1]),u=o.has("mcp")?wte(((b=e.toolCountByName)==null?void 0:b.keys())??[]):null,h=Math.max(e.toolCount,e.tools.length),p=a?e.tools.filter(v=>aE(v.name)===a):e.tools,f=a?o.get(a)??0:h;return i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:[n("board.detail.toolCalls")," ",i.jsx("span",{className:"section-count",children:h}),(c>0||r>0)&&i.jsxs("span",{className:"activity-counters",children:[c>0&&i.jsxs("span",{className:"ac-item ac-live",children:[i.jsx("b",{children:c})," ",n("board.state.live")]}),r>0&&i.jsxs("span",{className:"ac-item ac-err",children:[i.jsx("b",{children:r})," ",n("board.meta.err")]})]})]}),l.length>0&&i.jsx("div",{className:"cat-strip",role:"group","aria-label":n("board.detail.kinds"),children:l.map(([v,w])=>i.jsx("button",{type:"button",className:"call-kind","aria-pressed":a===v,onClick:()=>s(T=>T===v?null:v),children:i.jsx(fLe,{c:v,n:w,one:v==="mcp"?u:null})},v))}),e.tools.length===0&&i.jsx("div",{className:"empty",children:n("board.detail.noTools")}),i.jsx("div",{children:p.slice().reverse().map(v=>i.jsx(vLe,{call:v,cwd:e.cwd,onClick:()=>t(e.id,v.id)},v.id))}),e.tools.length>0&&p.length<f&&i.jsx("div",{className:"empty",children:n("board.detail.olderNotListed")})]})}function fLe({c:e,n:t,one:n}){const a=se(),s=n==null?void 0:n.hue,o=a("board.detail.catCalls",{count:t,cat:Wb(e,a)});return i.jsxs("span",{className:`cat-chip cat-${e}${s!=null?" mcp-hue":""}`,style:s!=null?{"--mcp-hue":s}:void 0,title:n?a("board.detail.catAllTo",{calls:o,server:n.label}):o,children:[i.jsx("span",{className:"cat-name",children:Wb(e,a)}),i.jsx("span",{className:"cat-count",children:t}),n&&i.jsx("span",{className:"cat-server",children:n.label})]})}function bLe(e){const t=new Map;return e.map(n=>{const a=t.get(n.at)??0;return t.set(n.at,a+1),{pr:n,key:a===0?String(n.at):`${n.at}:${a}`}})}const kLe={inflight:"board.toolStatus.inflight",done:"board.toolStatus.done",err:"board.toolStatus.err"};function vLe({call:e,cwd:t,onClick:n}){const a=se(),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=B4(e,"…"),r=sE(e),c=y8(e,r);return i.jsxs("button",{className:"tool clickable",title:c?r:e.inputPreview||e.name,onClick:n,children:[i.jsxs("span",{className:"name",children:[i.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:a(kLe[s])}),i.jsx("span",{className:"tool-name",children:e.name}),r&&(c?i.jsx(zg,{className:"tool-arg",path:r,cwd:t,hint:!1}):i.jsx("span",{className:"tool-arg",children:r}))]}),i.jsx("span",{className:"tool-dur",children:o})]})}const wLe={completed:"board.state.done",in_progress:"board.detail.now",pending:"board.detail.todo"},Tz="inspector";function yLe(e){return e.workspace&&e.wide&&!e.column}function xLe(e){return e.zoomed?!1:e.shown||e.workspace&&e.column&&!e.folded}function CLe(e){return e.workspace&&(e.column||e.sheet)?e.open?"fold":"show":"d"}function SLe(e,t,n){var o;const[a,s]=m.useState({});return m.useEffect(()=>{const r=new AbortController;let c;const l=()=>typeof document<"u"&&document.visibilityState==="hidden",u=f=>{clearTimeout(c),l()||(c=setTimeout(h,f))};async function h(){clearTimeout(c);try{const f=await X_e(e,r.signal);if(r.signal.aborted)return;if(f===void 0){s(b=>({...b,failedFor:e})),u(WA);return}s({reading:{session:e,turn:f,readAt:Date.now()}}),f!=null&&f.open&&n?u(Q_e):f===null&&n&&u(WA)}catch{r.signal.aborted||(s(f=>({...f,failedFor:e})),u(WA))}}const p=()=>{l()?clearTimeout(c):h()};return document.addEventListener("visibilitychange",p),h(),()=>{r.abort(),clearTimeout(c),document.removeEventListener("visibilitychange",p)}},[e,t,n]),{reading:((o=a.reading)==null?void 0:o.session)===e?a.reading:void 0,failed:a.failedFor===e}}function TLe({selected:e,agents:t,revision:n}){const a=se(),s=Sz(t,e.sessionId)??e;return s.provider==="codex"?i.jsx("p",{className:"insp-note",children:a("board.insTime.codexOnly")}):i.jsx(NLe,{root:s,agents:t,revision:n})}function NLe({root:e,agents:t,revision:n}){const a=se(),s=e.state==="active",o=`${e.prompts.length}:${e.endedAt??""}`,{reading:r,failed:c}=SLe(e.sessionId,o,s),l=m.useMemo(()=>{if(!(r!=null&&r.turn))return r==null?void 0:r.turn;const f=s?r.turn:{...r.turn,open:!1};return eLe(f,e.waiting,r.readAt)},[r,s,e.waiting]),u=xo(l!=null&&l.open?1e3:3e4),h=(r==null?void 0:r.readAt)??0,p=m.useMemo(()=>{if(!l)return null;const f=sLe(e)??h-l.totalMs,b=Math.max(f+1,l.open?h:f+l.totalMs);return iLe({agents:t,sessionId:e.sessionId,start:f,end:b,now:h})},[l,t,e.sessionId,n,h]);return l===void 0?c?i.jsx("p",{className:"insp-note",role:"status",children:a("board.insTime.failed")}):i.jsxs("p",{className:"insp-note insp-time-load",role:"status",children:[i.jsx(Fg,{busy:!0,size:"s"}),i.jsx("span",{children:a("board.insTime.reading")})]}):l===null||!p?i.jsx("p",{className:"insp-note",children:a("board.insTime.none")}):i.jsx(ALe,{turn:l,table:p,now:u})}function ALe({turn:e,table:t,now:n}){const a=se(),s=e.open?a("board.insTime.thisTurnLower"):a("board.insTime.lastTurnLower"),[o,r]=m.useState(new Set),c=h=>r(p=>{const f=new Set(p);return f.delete(h)||f.add(h),f}),l=nLe(e),u=t.rows.filter(h=>!h.under.some(p=>o.has(p)));return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"insp-head",children:[i.jsx("span",{className:"insp-title",children:a("board.insTime.title")}),i.jsx("span",{className:"insp-qual",children:s})]}),i.jsxs("dl",{className:"insp-time-stats",children:[i.jsx(Qf,{label:e.open?a("board.insTime.thisTurn"):a("board.insTime.lastTurn"),value:ao(e.totalMs)}),i.jsx(Qf,{label:a("board.insTime.waitingOnYou"),value:ao(e.youMs),tone:e.youMs>0?"warn":void 0}),i.jsx(Qf,{label:"Claude",value:ao(e.claudeMs)}),i.jsx(Qf,{label:a("board.insTime.thisMachine"),value:ao(e.machineMs)})]}),i.jsxs("div",{className:"insp-time-split",children:[i.jsxs("p",{className:"insp-time-share",children:[i.jsxs("b",{children:[tLe(e),"%"]})," ",a("board.insTime.shareOf",{which:s})]}),i.jsx("div",{className:"insp-time-bar",role:"img","aria-label":a("board.insTime.barLabel",{you:ao(e.youMs),claude:ao(e.claudeMs),machine:ao(e.machineMs)}),children:l.map(h=>i.jsx("i",{"data-lane":h.lane,style:{flexGrow:h.ms}},h.lane))})]}),t.rows.length>0&&i.jsxs("div",{className:"insp-time-table",role:"table","aria-label":a("board.insTime.calls"),children:[i.jsxs("div",{className:"insp-time-axis",role:"row",children:[i.jsx("span",{role:"columnheader",children:a("board.insTime.span")}),i.jsx("span",{className:"insp-time-ticks","aria-hidden":"true",children:rLe(t).map((h,p)=>i.jsx("span",{children:h},p))})]}),u.map(h=>i.jsx(jLe,{row:h,table:t,now:n,folded:o.has(h.key),onToggle:c},h.key))]}),i.jsx("p",{className:"insp-note",children:a("board.insTime.note")})]})}function Qf({label:e,value:t,tone:n}){return i.jsxs("div",{className:"insp-time-stat","data-tone":n,children:[i.jsx("dt",{children:e}),i.jsx("dd",{children:t})]})}function jLe({row:e,table:t,now:n,folded:a,onToggle:s}){const o=se(),r=cLe(e,t,n),c=e.to===null?null:ao(e.to-e.from),l=r.width*1.72<6,u=r.left+r.width,h=u>72?{right:`${100-r.left}%`,marginRight:4}:{left:`${u}%`,marginLeft:4};return i.jsxs("div",{className:"insp-time-row",role:"row","data-group":e.group||void 0,style:{"--depth":e.depth},children:[i.jsxs("span",{className:"insp-time-name",role:"cell",children:[i.jsx("span",{className:"insp-time-slot",children:e.group?i.jsx("button",{type:"button",className:"insp-time-fold","aria-expanded":!a,"aria-label":o(a?"board.insTime.show":"board.insTime.hide",{name:e.name}),onClick:()=>s(e.key),children:i.jsx(Ze,{name:"chevron-down"})}):null}),i.jsx("span",{className:"insp-time-icon","data-icon":VU(e.name,e.group),children:i.jsx(Ze,{name:VU(e.name,e.group)})}),i.jsx("span",{className:"insp-time-op",children:e.name}),e.arg&&(e.path?i.jsx(zg,{className:"insp-time-arg",path:e.arg,cwd:t.cwd}):i.jsx("span",{className:"insp-time-arg",title:e.arg,children:e.arg}))]}),i.jsx("span",{className:"insp-time-lane",role:"cell",children:e.waitingSince!==null?i.jsx("span",{className:"insp-time-wait",style:r.left>40?{right:0}:{left:`${r.left}%`},children:o("board.insTime.waitingFor",{span:ao(n-e.waitingSince)})}):i.jsxs(i.Fragment,{children:[i.jsx("i",{className:"insp-time-span","data-group":e.group||void 0,"data-thin":l||void 0,style:{left:`${r.left}%`,width:`${r.width}%`}}),c&&i.jsx("span",{className:"insp-time-took",style:h,children:c})]})})]})}const x8={agents:()=>i.jsx(Ze,{name:"agents",className:"glyph"}),time:()=>i.jsx(Ze,{name:"time",className:"glyph"}),context:()=>i.jsx(Ze,{name:"context",className:"glyph"})};function ELe({selected:e,agents:t,revision:n=0,onSelectAgent:a,onClose:s,detail:o}){const r=se(),[c,l]=m.useState(W_e),u=m.useRef({}),h=f=>{l(f),H_e(f)},p=f=>{var w;const b=Fu(f,$r.indexOf(c),$r.length);if(b.kind!=="select")return;f.preventDefault();const v=$r[b.index];h(v),(w=u.current[v])==null||w.focus()};return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"insp-h",children:[i.jsx("div",{className:"insp-tabs",role:"tablist","aria-label":r("board.inspector.label"),onKeyDown:p,children:$r.map(f=>{const b=x8[f];return i.jsxs("button",{type:"button",role:"tab",id:`insp-tab-${f}`,className:"insp-tab","aria-selected":c===f,"aria-controls":`insp-panel-${f}`,tabIndex:c===f?0:-1,ref:v=>{u.current[f]=v},onClick:()=>h(f),children:[i.jsx(b,{}),i.jsx("span",{children:v8[f]})]},f)})}),i.jsx("button",{type:"button",className:"glyph-btn insp-fold",title:r("board.inspector.fold"),"aria-label":r("board.inspector.fold"),onClick:s,children:i.jsx(Ze,{name:"chevron-right"})})]}),$r.map(f=>i.jsxs("div",{role:"tabpanel",id:`insp-panel-${f}`,"aria-labelledby":`insp-tab-${f}`,className:"insp-b",hidden:c!==f,children:[c===f&&f==="agents"&&i.jsx(qLe,{selected:e,agents:t,revision:n,onSelectAgent:a,detail:o}),c===f&&f==="time"&&i.jsx(TLe,{selected:e,agents:t,revision:n}),c===f&&f==="context"&&i.jsx(LLe,{agent:e})]},f))]})}function C8(e,t){const n=m.useRef(null),[a,s]=m.useState(!e);return m.useLayoutEffect(()=>{var r;e&&((r=n.current)==null||r.offsetWidth,s(!0))},[e]),{asideRef:n,sheetState:e?t?"out":a?"in":"pre":void 0}}const RLe="board.inspector.chooseSession";function KU({leaving:e=!1,sheet:t=!1}={}){const n=se(),{asideRef:a,sheetState:s}=C8(t,e);return i.jsxs("aside",{ref:a,id:Tz,className:e?"detail leaving":"detail","data-sheet":s,"aria-label":n("board.inspector.detail"),"data-empty":"",children:[i.jsx(Du,{}),i.jsx("header",{className:"insp-h",children:i.jsx("div",{className:"insp-tabs","aria-hidden":"true",children:$r.map(o=>{const r=x8[o];return i.jsxs("span",{className:"insp-tab","aria-current":o===$r[0]?"true":void 0,children:[i.jsx(r,{}),i.jsx("span",{children:v8[o]})]},o)})})}),i.jsx("div",{className:"insp-b insp-none",children:i.jsx("p",{className:"insp-note",children:n(RLe)})})]})}function S8({title:e,info:t,qualifier:n,figure:a}){return i.jsxs("div",{className:"insp-head",children:[i.jsx("span",{className:"insp-title",children:e}),t&&i.jsx(zLe,{detail:t}),n&&i.jsx("span",{className:"insp-qual",children:n}),i.jsx("span",{className:"insp-spacer"}),a&&i.jsx("span",{className:"insp-fig",children:a})]})}function zLe({detail:e}){return i.jsx(hR,{className:"ap-peek insp-hint",detail:e,children:i.jsx("span",{className:"insp-info",role:"img","aria-label":e,children:i.jsx(Ze,{name:"info"})})})}function qLe({selected:e,agents:t,revision:n,onSelectAgent:a,detail:s}){const o=m.useMemo(()=>$_e(t,e.sessionId),[t,e.sessionId,n]),r=se(),c=o.length>1;return i.jsxs(i.Fragment,{children:[c&&i.jsxs(i.Fragment,{children:[i.jsx(S8,{title:r("board.inspector.agents"),info:r("board.inspector.agentsNote"),qualifier:J_e(o)}),i.jsx("ul",{className:"insp-tree",children:o.map(l=>i.jsx(_Le,{row:l,revision:n,current:l.agent.id===e.id,onSelectAgent:a},l.agent.id))})]}),i.jsx("div",{className:"insp-detail",children:s})]})}const _Le=m.memo(function({row:t,current:n,onSelectAgent:a}){const s=t.agent.id;return i.jsxs("li",{className:"insp-row","data-depth":t.depth,children:[t.more.map((o,r)=>i.jsx("span",{className:"insp-gut","data-line":r<t.depth-1?o?"through":void 0:o?"tee":"elbow","aria-hidden":"true"},r)),i.jsxs("div",{className:"insp-card",onClick:()=>a(s),children:[i.jsx("button",{type:"button",className:"insp-pick","aria-label":D4(t.agent),"aria-current":n||void 0}),i.jsx(_5,{data:t.agent})]})]})},(e,t)=>e.row.agent===t.row.agent&&e.revision===t.revision&&e.row.depth===t.row.depth&&e.row.more.length===t.row.more.length&&e.row.more.every((n,a)=>n===t.row.more[a])&&e.current===t.current&&e.onSelectAgent===t.onSelectAgent);function LLe({agent:e}){const{used:t,limit:n}=S1(e),a=se();return i.jsxs(i.Fragment,{children:[i.jsx(S8,{title:a("board.stage.contextWindow"),qualifier:e.model?Rg(e.model):null,figure:zce(t,n)}),i.jsx(c5,{agent:e})]})}function PLe(e,t){const n=D_e(e,t,new Date().toISOString());if(!n)return;const a=JSON.stringify(n,null,2),s=new Blob([a],{type:"application/json"}),o=URL.createObjectURL(s),r=document.createElement("a");r.href=o,r.download=F_e(n.label,t),document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function $U({selected:e,now:t,openTool:n,setSummaryFor:a,onClose:s,onSelectAgent:o,stateRef:r,removeSelectedNode:c,onOpenSession:l,stageSession:u=null,workspace:h=!1,leaving:p=!1,sheet:f=!1}){const b=se();na("detail-panel");const v=sa(),w=U_e(e,r.current.agents,t,h),{asideRef:T,sheetState:y}=C8(f,p);return i.jsxs("aside",{ref:T,id:Tz,className:p?"detail leaving":"detail","data-sheet":y,"aria-label":b("board.detailPanel.title"),children:[i.jsx(Du,{}),i.jsx(ELe,{selected:e,agents:r.current.agents,revision:r.current.revision,onSelectAgent:o,onClose:s,detail:i.jsx(uLe,{agent:e,now:t,onOpenTool:n,onShowSummary:a,onOpenSession:l,stageSession:u,onExportSession:x=>PLe(r.current,x),onRemove:c,singleKeys:v,status:w})})]})}const OLe={"Boards, sprints, and issues":"integrations.provider.jira.detail","Jira Cloud, or Jira Server / Data Center 8.14 and newer.":"integrations.provider.jira.blurb","Repositories, pull requests, and Actions":"integrations.provider.github.detail","github.com, read-only, with a personal access token.":"integrations.provider.github.blurb","Projects, merge requests, and pipelines":"integrations.provider.gitlab.detail","GitLab.com or your own instance, read-only.":"integrations.provider.gitlab.blurb","Which Jira":"integrations.field.whichJira","Jira URL":"integrations.field.jiraUrl","The address you open Jira at, with its path if it has one (…/jira). https only.":"integrations.field.jiraUrlHint","Site URL":"integrations.field.siteUrl","The address you open Jira at. Your site name alone is enough.":"integrations.field.siteUrlHint","Atlassian account email":"integrations.field.email","Personal access token":"integrations.field.pat","API token":"integrations.field.apiToken","Paste the token":"integrations.field.pasteToken","Paste the API token":"integrations.field.pasteApiToken","Which GitLab":"integrations.field.whichGitlab","Self-managed":"integrations.field.selfManaged","GitLab URL":"integrations.field.gitlabUrl","The address you open GitLab at, with its path if it has one. https only.":"integrations.field.gitlabUrlHint"};function jp(e,t){const n=t===void 0?void 0:OLe[t];return n?e(n):t}const MLe="board.quick.placeholder";function ILe(e,t,n=S){const a=n(e?"board.rail.watch.on":"board.rail.watch.off");return t>0?`${a}
|
|
153
|
-
${n("board.rail.unreadCount",{n:t})}`:a}function DLe(e,t){return e>0?{ariaLabel:S("board.rail.feedbackUnread",{count:e}),detail:S("board.rail.unreadCount",{n:e}),dot:!0,...t?{onPress:t}:{}}:{}}function Ir(e,t){return t.map(n=>({...n,group:e}))}function FLe({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:a,toggleAccountsPanel:s,accountsPanelId:o="accounts-panel",codexPanelOpen:r=!1,toggleCodexPanel:c=()=>{},usagePanelOpen:l,setUsagePanelOpen:u,machinePanelOpen:h,setMachinePanelOpen:p,setUsageHistoryOpen:f,watchOn:b,watchUnseen:v,setBrowserWatchOpen:w,setTrafficRadarOpen:T,setRadioOpen:y,openToolActivity:x,openSettings:C,onFeedback:A,toggles:E,openCapacity:R,integrations:z=[],openExploreIntegrations:I,openQuickOpen:_,feedbackUnread:D=0,openFeedbackConversations:L,inspectorOpen:P=!1,toggleInspector:O=()=>{}}){const j=Lme(js()),M=zs(js()),F={id:"session-list",label:S("board.rail.sessionList"),short:S("board.rail.sessionList.short"),key:{cap:"L",aria:"L",single:!0},ariaLabel:S("board.rail.sessionList"),glyph:i.jsx(dG,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:E.sessionList},U={id:"accounts",label:S("board.rail.accounts"),short:S("board.rail.accounts"),key:{cap:"A",aria:"A",single:!0},ariaLabel:S("board.rail.accounts"),hint:e.codex?void 0:S("board.rail.accounts.hint"),glyph:i.jsx(uG,{}),kind:"panel",open:a,controls:o,onPress:s,buttonRef:E.accounts},H=R?[{id:"account-capacity",label:S("board.rail.capacity"),short:S("board.rail.capacity.short"),ariaLabel:S("board.rail.capacity"),detail:S("board.rail.capacity.detail"),glyph:i.jsx(fge,{}),kind:"dialog",onPress:()=>R("accounts")},{id:"reset-calendar",label:S("board.rail.calendar"),short:S("board.rail.calendar.short"),stripeWord:S("board.rail.calendar"),ariaLabel:S("board.rail.calendar"),detail:S("board.rail.calendar.detail"),glyph:i.jsx(bge,{}),kind:"dialog",onPress:()=>R("calendar")}]:[],$={id:"codex-accounts",label:S("codex.panel.title"),short:"Codex",stripeWord:S("codex.panel.title"),...e.claude?{}:{key:{cap:"A",aria:"A",single:!0}},ariaLabel:S("codex.panel.title"),glyph:i.jsx(Age,{}),kind:"panel",open:r,controls:"codex-accounts-panel",onPress:c,buttonRef:E.codex},Y={id:"inspector",label:S("board.inspector.show"),short:S("board.inspector.show"),stripeWord:S("board.inspector.label"),key:{cap:"D",aria:"D",single:!0},ariaLabel:S("board.inspector.show"),glyph:i.jsx(kge,{}),kind:"panel",open:P,controls:Tz,onPress:O},W={id:"usage",label:S("board.rail.usage"),short:S("board.rail.usage"),key:{cap:"U",aria:"U",single:!0},ariaLabel:S("board.rail.usage"),glyph:i.jsx(sge,{}),kind:"panel",open:l,controls:"usage-panel",onPress:()=>u(be=>!be),buttonRef:E.usage},G={id:"machine",label:S("board.rail.machine"),short:S("board.rail.machine"),key:{cap:"S",aria:"S",single:!0},ariaLabel:S("board.rail.machine"),hint:S("board.rail.machine.hint"),stripeWord:S("board.rail.machine.hint"),glyph:i.jsx(oge,{}),kind:"panel",open:h,controls:"system-panel",onPress:()=>p(be=>!be),buttonRef:E.machine},Q={id:"history",label:S("board.rail.history"),short:S("board.rail.history.short"),stripeWord:S("board.rail.history"),key:{cap:"H",aria:"H",single:!0},ariaLabel:S("board.rail.history"),glyph:i.jsx(ige,{}),kind:"dialog",onPress:()=>f(be=>!be)},J={id:"browser-watch",label:S("board.rail.browserWatch"),short:S("board.rail.browserWatch.short"),stripeWord:S("board.rail.browserWatch"),key:{cap:"B",aria:"B",single:!0},ariaLabel:`${S("board.rail.browserWatch")}${S("board.listSep")}${S(b?"board.rail.watching":"board.rail.notWatching")}${v>0?`${S("board.listSep")}${S("board.rail.unreadCount",{n:v})}`:""}`,detail:ILe(b,v,S),glyph:i.jsx(cge,{watching:b===!0||v>0}),kind:"dialog",onPress:()=>w(be=>!be),badge:v},X={id:"settings",label:S("board.rail.settings"),short:S("board.rail.settings.short"),key:{cap:j,aria:"Control+, Meta+,",single:!1},ariaLabel:S("board.rail.settings"),glyph:i.jsx(lge,{}),kind:"dialog",onPress:()=>C()},te={id:"quick-open",label:S("board.rail.search"),short:S("board.rail.search"),key:{cap:lme(M),aria:M?"Meta+K":"Control+K",single:!1},ariaLabel:S("board.rail.search"),detail:S("board.rail.search.detail"),glyph:i.jsx(gG,{}),kind:"dialog",onPress:_,barLook:"field",fieldText:S(MLe)},K={id:"feedback",label:S("board.rail.feedback"),short:S("board.rail.feedback"),menu:S("board.rail.feedback.menu"),ariaLabel:S("board.rail.feedback.menu"),glyph:i.jsx(dge,{}),kind:"dialog",onPress:A,barLook:"icon",...DLe(D,L),...D>0?{badge:D}:{}},V=x?[{id:"tool-activity",label:S("board.rail.tools.activity"),short:S("board.rail.tools.short"),stripeWord:S("board.rail.tools.activity"),ariaLabel:S("board.rail.tools.activity"),glyph:i.jsx(mge,{}),kind:"dialog",detail:S("board.rail.tools.detail"),onPress:()=>x("tools")},{id:"skill-activity",label:S("board.rail.skills"),short:S("board.rail.skills.short"),stripeWord:S("board.rail.skills"),ariaLabel:S("board.rail.skills"),glyph:i.jsx(hG,{}),kind:"dialog",detail:S("board.rail.skills.detail"),onPress:()=>x("skills")}]:[],ee=T?[{id:"traffic-radar",label:S("board.rail.radar"),short:S("board.rail.radar.short"),ariaLabel:S("board.rail.radar"),glyph:i.jsx(rge,{}),kind:"dialog",detail:S("board.rail.radar.detail"),onPress:()=>T(!0)}]:[],de=y?[{id:"radio",label:S("board.rail.radio"),short:S("board.rail.radio"),ariaLabel:S("board.rail.radio"),glyph:i.jsx(gge,{}),kind:"dialog",detail:S("board.rail.radio.detail"),onPress:()=>y(!0)}]:[],he=I?[{id:"explore-integrations",label:S("board.rail.explore"),short:S("board.rail.explore.short"),ariaLabel:S("board.rail.explore"),glyph:i.jsx(age,{}),kind:"dialog",onPress:I}]:[],me=z.map(({provider:be,onPress:ie})=>({id:`integration-${be.kind}`,label:be.label,short:be.label,ariaLabel:be.label,detail:jp(S,be.detail),key:be.shortcut?{cap:be.shortcut.toUpperCase(),aria:be.shortcut.toUpperCase(),single:!0}:void 0,glyph:i.jsx(be.Glyph,{}),kind:"dialog",onPress:ie}));return{left:e.claude?[U,F]:e.codex?[$,F]:[F],codexDoor:e.claude&&e.codex?[$]:[],leftStripe:[Ir(S("shell.rail.left"),[F,...e.claude?[U]:e.codex?[$]:[]]),e.claude?Ir(S("board.rail.group.accounts"),H):[],me,he].filter(be=>be.length>0),leftFoot:[...de,X],rightStripe:[[Y],Ir(S("board.rail.group.usage"),[W,G]),Ir(S("board.rail.group.activity"),[Q,...V]),Ir(S("board.rail.group.watchers"),[J,...ee])].filter(be=>be.length>0),corner:K,capacity:e.claude?H:[],right:[Ir(S("board.rail.group.usage"),[W,G]),Ir(S("board.rail.group.activity"),[Q,...V]),Ir(S("board.rail.group.watchers"),[J,...ee]),de].filter(be=>be.length>0),utilities:[X,K],search:te,explore:he,integrations:me}}function BLe(e){if(!e)return[];const t=S("board.controls.openPanel");return[{id:"command-panel",label:t,short:t,ariaLabel:t,detail:S("board.controls.openPanelTip"),glyph:i.jsx(Ze,{name:"terminal"}),kind:"panel",onPress:()=>e(typeof document>"u"?null:document.getElementById(wp))}]}let iE=null;const oE=new Set,ULe=(e,t)=>e===t||e!==null&&t!==null&&e.connected===t.connected&&e.email===t.email&&e.unread===t.unread&&e.latestAt===t.latestAt&&e.mail===t.mail;function S4e(e){const t=e===null?null:{connected:e.connected===!0,email:typeof e.email=="string"&&e.email!==""?e.email:null,unread:Number.isInteger(e.unread)&&e.unread>0?e.unread:0,latestAt:typeof e.latestAt=="string"?e.latestAt:null,mail:e.mail!==!1};if(!ULe(iE,t)){iE=t;for(const n of oE)n()}}function rE(){return iE}function WLe(e){return oE.add(e),()=>{oE.delete(e)}}function T8(){return m.useSyncExternalStore(WLe,rE,rE)}function HLe(e){return(e==null?void 0:e.mail)!==!1}function GLe(e){return e!=null&&e.connected?e.unread:0}const VLe=[".stage-dock .xterm-helper-textarea",".stage-dock button:not(:disabled)",'.sl-row[aria-current="true"]'];function KLe(e,t=VLe){for(const n of t){const a=e.querySelector(n);if(a&&(a.focus(),e.activeElement===a))return a}return null}const $Le='button[data-rail-item="inspector"]';function JU(e){const t=KLe(e);if(t)return t;const n=e.querySelector($Le);return n?(n.focus(),e.activeElement===n?n:null):null}function eb(e,t){return e.split(/\{(\w+)\}/).map((a,s)=>s%2===0?a:i.jsx(m.Fragment,{children:a in t?t[a]:`{${a}}`},s))}const Tk=[{value:"bug",get label(){return S("shell.feedback.kind.bug")},get question(){return S("shell.feedback.q.bug")},get placeholder(){return S("shell.feedback.ph.bug")}},{value:"idea",get label(){return S("shell.feedback.kind.idea")},get question(){return S("shell.feedback.q.idea")},get placeholder(){return S("shell.feedback.ph.idea")}},{value:"other",get label(){return S("shell.feedback.kind.other")},get question(){return S("shell.feedback.q.other")},get placeholder(){return S("shell.feedback.ph.other")}}];function N8(e){return Tk.find(t=>t.value===e)??Tk[0]}const cE=3,HA=120,A8=1e4,j8=200,JLe=()=>S("shell.feedback.missing");function YU(e){return e.trim()!==""}function YLe(e){var o;const t=e.trim();if(t==="")return"";const n=ZU(t.split(/\r?\n/,1)[0]),a=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=GA(a).length>=cE?GA(a):GA(n);return XLe(s.length>=cE?s:ZU(t))}function ZLe(e,t){const n=YLe(t);return n.length>=cE?n:S("shell.feedback.titleKind",{kind:N8(e).label,text:n})}function ZU(e){return e.replace(/\s+/g," ").trim()}function GA(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function XLe(e){if(e.length<=HA)return e;const t=e.slice(0,HA-1),n=t.lastIndexOf(" ");return`${(n>=HA/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function XU({kind:e,body:t,contact:n}){const a={kind:e,title:ZLe(e,t),body:t.trim()};return n.trim()!==""&&(a.contact=n.trim()),a}function QLe(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const ePe={darwin:"macOS",win32:"Windows",linux:"Linux"};function tPe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),a=t===-1?"":e.slice(t+1),s=ePe[n]??n;return a?`${s} · ${a}`:s}function nPe(e){return e?`ccdeck ${e.appVersion} · ${tPe(e.platform)}`:null}const aPe=()=>S("shell.feedback.factsWith"),sPe=()=>S("shell.feedback.factsUnknown"),iPe=()=>S("shell.feedback.addDetails"),oPe=()=>S("shell.feedback.contact"),rPe=()=>S("shell.feedback.contactPh"),cPe=()=>S("shell.feedback.contactHint"),lPe=()=>[S("shell.feedback.where1"),S("shell.feedback.where2")],dPe="shell.feedback.accountTitle",uPe="shell.feedback.tabWrite",hPe="shell.feedback.tabConversations",pPe="shell.feedback.sendWithout";function gPe(e,t=!0){return e?S(t?"shell.feedback.sentAsMail":"shell.feedback.sentAsNoMail",{email:e}):S(t?"shell.feedback.sentAsAccountMail":"shell.feedback.sentAsAccountNoMail")}const mPe=["shell.feedback.whereAccount1","shell.feedback.whereAccount2"],fPe=["shell.feedback.whereAccount1NoMail","shell.feedback.whereAccount2"],bPe=(e=!0)=>(e?mPe:fPe).map(t=>S(t)),kPe="shell.feedback.sentAccount",vPe="shell.feedback.sentAccountNoMail",wPe="shell.feedback.accountUnavailable";function yPe(e,t){return new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",hourCycle:"h23",timeZone:t}).format(e)}function xPe(e,t,n,a){return S(e==="conversations"?"shell.feedback.limitConversations":"shell.feedback.limitReplies",{limit:t,time:yPe(n,a)})}function QU(e,t,n=Date.now()){const a=t==null?void 0:t.reason;return a==="too_many"&&Number.isInteger(t==null?void 0:t.limit)&&Number.isInteger(t==null?void 0:t.retryAfterSec)?xPe("conversations",t.limit,new Date(n+t.retryAfterSec*1e3)):a==="invalid"||a==="too_large"?lE(e,a,t==null?void 0:t.errors):S(wPe)}function CPe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Nz(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function SPe(e){return zs(e)?["⌘","Enter"]:["Ctrl","Enter"]}function TPe(e){return[...e].length===1}const E8=(e=!1,t=!0)=>S(e?t?kPe:vPe:"shell.feedback.sent");function NPe(e){const t=/^At most (\d+) images\.$/.exec(e);if(t)return S("shell.feedback.problem.count",{n:t[1]});const n=/^Image (\d+) is over (\d+) MB\.$/.exec(e);if(n)return S("shell.feedback.problem.size",{n:n[1],mb:n[2]});const a=/^Image (\d+) is not a PNG or a JPEG\.$/.exec(e);return a?S("shell.feedback.problem.format",{n:a[1]}):e}function lE(e,t,n){if(t==="vetoed")return S("shell.feedback.fail.vetoed");if(e===429||t==="too_many")return S("shell.feedback.fail.tooMany");if(e===413||t==="too_large")return S("shell.feedback.fail.tooLarge");const a=n==null?void 0:n.images;return e===400&&Array.isArray(a)&&typeof a[0]=="string"?S("shell.feedback.fail.image",{reason:NPe(a[0])}):S(e===400?"shell.feedback.fail.rejected":"shell.feedback.fail.unreachable")}function APe(e,t=!1,n=!0){return e==="sending"?S("shell.feedback.sending"):e==="sent"?E8(t,n):""}const eW=1400,jPe=150,R8=m.createContext({values:{}});function z8(){return m.useContext(R8)}function EPe(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const tW=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function RPe({def:e,existing:t,busy:n,error:a,onSubmit:s,onCancel:o,onDirtyChange:r}){var j,M;const c=se(),l=m.useId(),[u,h]=m.useState(()=>Object.fromEntries(e.fields.map(F=>{var U,H,$;return[F.name,F.secret?"":((U=F.initial)==null?void 0:U.call(F,t))??(F.type==="choice"?(($=(H=F.options)==null?void 0:H[0])==null?void 0:$.value)??"":"")]}))),[p,f]=m.useState((t==null?void 0:t.name)??""),b=m.useRef(null),v=m.useRef(new Map),w=!!t,T=m.useRef(u),y=m.useRef(p);m.useEffect(()=>{r==null||r(p!==y.current||Object.keys(u).some(F=>u[F]!==T.current[F]))},[p,u,r]);const x=e.fields.filter(F=>F.type==="choice").every(F=>u[F.name]===T.current[F.name]),C=w&&t.tokenSaved&&x,A=(F,U)=>{n||h(H=>({...H,[F]:U}))},E=F=>{var H;if(F.preventDefault(),n)return;const U={};for(const $ of e.fields)tW($,u)&&(U[$.name]=(u[$.name]??"").trim());(H=F.currentTarget.querySelector('button[type="submit"]'))==null||H.focus(),s(U,p.trim()),h($=>Object.fromEntries(Object.entries($).map(([Y,W])=>{var G;return[Y,(G=e.fields.find(Q=>Q.name===Y))!=null&&G.secret?"":W]})))},R=m.useMemo(()=>{const F=u.baseUrl??"";try{return F?new URL(/^[a-z]+:\/\//i.test(F)?F:`https://${F}`).host:""}catch{return""}},[u.baseUrl]),z=m.useMemo(()=>({values:u,existing:t}),[u,t]),I=e.fields.filter(F=>tW(F,u)),_=(j=I.find(F=>!F.secret&&F.type!=="choice"))==null?void 0:j.name,D=(M=I.find(F=>F.secret))==null?void 0:M.name,L=a!=null&&a.field&&I.some(F=>F.name===a.field&&F.type!=="choice")?a.field:null,P=`${l}-error`;m.useEffect(()=>{var U,H,$;const F=w?D:_??D;F&&((U=v.current.get(F))==null||U.focus()),($=(H=b.current)==null?void 0:H.scrollIntoView)==null||$.call(H,{block:"nearest"})},[w]),m.useEffect(()=>{var F;L&&((F=v.current.get(L))==null||F.focus())},[a,L]);const O=a&&i.jsxs(i.Fragment,{children:[a.message,a.detail&&i.jsxs("span",{className:"ig-form-detail",children:[" ",c("integrations.failure.said",{provider:e.label,said:a.detail})]}),a.kind==="rate-limit"&&a.retryAfter?i.jsxs("span",{children:[" ",c("integrations.form.retryIn",{n:a.retryAfter})]}):null]});return i.jsx(R8.Provider,{value:z,children:i.jsxs("form",{ref:b,className:"ig-form",onSubmit:E,"aria-labelledby":`${l}-title`,noValidate:!0,children:[i.jsxs("header",{className:"ig-managed-header",children:[i.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:i.jsx(e.Glyph,{})}),i.jsxs("div",{className:"ig-managed-identity",children:[i.jsx("h2",{className:"ig-form-title",id:`${l}-title`,children:w?c("integrations.form.edit",{name:t.name}):c("integrations.form.connect",{provider:e.label})}),w&&i.jsx("p",{children:c("integrations.form.connectionOf",{provider:e.label})})]})]}),I.map(F=>{const U=EPe(F,u),H={...U,label:jp(c,U.label),hint:jp(c,U.hint),placeholder:jp(c,U.placeholder)},$=(a==null?void 0:a.field)===H.name,Y=[H.hint?`${l}-${H.name}-hint`:"",$?P:""].filter(Boolean).join(" ")||void 0;if(H.type==="choice")return i.jsxs("fieldset",{className:"fb-kinds","aria-invalid":$||void 0,children:[i.jsx("legend",{className:"vis-hidden",children:H.label}),(H.options??[]).map(Q=>i.jsxs("label",{className:"fb-kind",children:[i.jsx("input",{type:"radio",name:`${l}-${H.name}`,value:Q.value,checked:u[H.name]===Q.value,"aria-disabled":n||void 0,onChange:()=>A(H.name,Q.value),onKeyDown:J=>{Nz(J.nativeEvent)&&J.preventDefault()}}),jp(c,Q.label)]},Q.value))]},H.name);const W=H.secret&&C,G=`${l}-${H.name}`;return i.jsxs("div",{className:"fb-field",children:[i.jsxs("label",{className:"fb-field-label",htmlFor:G,children:[H.label,H.optional&&i.jsxs("span",{className:"fb-optional",children:[" ",c("integrations.form.optional")]})]}),i.jsx("input",{id:G,className:`ap-manage-input ig-input${H.secret?" ig-mono":""}`,ref:Q=>{Q?v.current.set(H.name,Q):v.current.delete(H.name)},type:H.type,inputMode:H.type==="url"?"url":H.type==="email"?"email":void 0,autoComplete:H.autoComplete??"off",spellCheck:!1,value:u[H.name]??"",onChange:Q=>A(H.name,Q.target.value),placeholder:W?c("integrations.form.keepSaved"):H.placeholder,readOnly:n,"aria-invalid":$||void 0,"aria-describedby":Y,"aria-required":!H.optional&&!W||void 0}),H.hint&&i.jsx("span",{className:"ig-hint",id:`${l}-${H.name}-hint`,children:H.hint}),$&&L===H.name&&i.jsx("span",{className:"ig-form-error",id:P,role:"alert",children:O})]},H.name)}),i.jsxs("details",{className:"ig-help ig-token-help",children:[i.jsx("summary",{children:c("integrations.form.howTo",{provider:e.label})}),e.tokenHelp]}),i.jsxs("div",{className:"fb-field",children:[i.jsxs("label",{className:"fb-field-label",htmlFor:`${l}-name`,children:[c("integrations.form.name")," ",i.jsx("span",{className:"fb-optional",children:c("integrations.form.optional")})]}),i.jsx("input",{id:`${l}-name`,className:"ap-manage-input ig-input",type:"text",autoComplete:"off",maxLength:120,readOnly:n,value:p,onChange:F=>f(F.target.value),placeholder:R||e.label})]}),a&&!L&&i.jsx("p",{className:"ig-form-error",id:P,role:"alert",children:O}),i.jsxs("div",{className:"ig-form-actions",children:[i.jsx("button",{type:"submit",className:"btn primary","aria-disabled":n,"aria-busy":n,children:c(n?"integrations.form.checking":w?"integrations.form.save":"integrations.form.connectBtn")}),i.jsx("button",{type:"button",className:"btn","aria-disabled":n||void 0,onClick:()=>{n||o()},children:c("integrations.cancel")})]})]})})}const zPe="https://id.atlassian.com/manage-profile/security/api-tokens",qPe="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",_Pe="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",LPe=[{scope:"read:jira-work",why:"issues, comments, search",whyKey:"integrations.token.why.work"},{scope:"read:jira-user",why:"your account and avatars",whyKey:"integrations.token.why.user"},{scope:"read:board-scope:jira-software",why:"boards and backlogs",whyKey:"integrations.token.why.board"},{scope:"read:board-scope.admin:jira-software",why:"a board's estimation and quick filters",whyKey:"integrations.token.why.boardAdmin"},{scope:"read:sprint:jira-software",why:"sprints",whyKey:"integrations.token.why.sprint"},{scope:"read:epic:jira-software",why:"epic names and colours",whyKey:"integrations.token.why.epic"},{scope:"read:issue-details:jira",why:"issue lists",whyKey:"integrations.token.why.issueDetails"},{scope:"read:jql:jira",why:"filtered lists",whyKey:"integrations.token.why.jql"}];function PPe(e){const t=e.trim();if(!t)return null;try{const n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`),a=n.hostname==="localhost"||n.hostname==="127.0.0.1";return n.protocol!=="https:"&&!a||!n.hostname.includes(".")&&!a?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens`}catch{return null}}function OPe(){const e=se(),{values:t}=z8(),n=t.deployment==="cloud",a=n?null:PPe(t.baseUrl??"");let s="";try{s=a?new URL(a).host:""}catch{}return i.jsxs(i.Fragment,{children:[n?i.jsxs(i.Fragment,{children:[i.jsx("p",{children:eb(e("integrations.token.cloud.intro"),{link:i.jsx("a",{href:zPe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.cloud.path")}),scoped:i.jsx("em",{children:e("integrations.token.cloud.scoped")})})}),i.jsx("ul",{className:"ig-scopes",children:LPe.map(o=>i.jsxs("li",{children:[i.jsx("code",{children:o.scope})," ",i.jsx("span",{children:e(o.whyKey)})]},o.scope))}),i.jsx("p",{children:i.jsx("a",{href:qPe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.cloud.docs")})})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{children:eb(e("integrations.token.server.intro"),{profile:i.jsx("strong",{children:e("integrations.token.server.profile")}),pats:i.jsx("strong",{children:e("integrations.token.server.pats")}),create:i.jsx("strong",{children:e("integrations.token.server.create")}),page:a?eb(e("integrations.token.server.page"),{link:i.jsx("a",{href:a,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.openOn",{host:s})})}):""})}),i.jsx("p",{children:i.jsx("a",{href:_Pe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.docs")})})]}),i.jsx("p",{className:"ig-dim",children:e("integrations.token.reads")}),n&&i.jsx("p",{className:"ig-dim",children:eb(e("integrations.token.scopedWrite"),{rank:i.jsx("code",{children:"write:issue:jira-software"}),sprint:i.jsx("code",{children:"write:sprint:jira-software"}),backlog:i.jsx("code",{children:"write:board-scope:jira-software"}),work:i.jsx("code",{children:"write:jira-work"})})})]})}function VA(e,t,n="classic"){if(e==="github")return n==="classic"?"https://github.com/settings/tokens/new?scopes=repo,read:org&description=ccdeck":"https://github.com/settings/personal-access-tokens/new";const a=(t??"").trim()||"https://gitlab.com";let s;try{s=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(a)?a:`https://${a}`)}catch{return null}return s.protocol!=="https:"&&s.protocol!=="http:"||!s.hostname.includes(".")&&s.hostname!=="localhost"?null:`${s.origin}${s.pathname.replace(/\/+$/,"")}/-/user_settings/personal_access_tokens?name=ccdeck&scopes=read_api`}function nW(e,t){return e.split(/(\{\w+\})/).map((n,a)=>{var o;const s=(o=/^\{(\w+)\}$/.exec(n))==null?void 0:o[1];return s&&s in t?i.jsx("span",{children:t[s]},a):n})}function KA({href:e,children:t}){return e?i.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",i.jsx(dR,{})]}):null}function q8({kind:e,baseUrl:t}){const{values:n}=z8(),a=se();if(e==="github")return i.jsxs("div",{className:"fg-token-help",children:[i.jsx("p",{children:a("forge.token.gh.intro")}),i.jsxs("ul",{children:[i.jsxs("li",{children:[i.jsx("strong",{children:a("forge.token.gh.classicName")})," ",nW(a("forge.token.gh.classic"),{repo:i.jsx("code",{children:"repo"}),org:i.jsx("code",{children:"read:org"})})," ",i.jsx(KA,{href:VA("github"),children:a("forge.token.makeOne")})]}),i.jsxs("li",{children:[i.jsx("strong",{children:a("forge.token.gh.fineName")})," ",a("forge.token.gh.fine")," ",i.jsx(KA,{href:VA("github",null,"fine-grained"),children:a("forge.token.makeOne")})]})]}),i.jsx("p",{children:a("forge.token.gh.approval")})]});const s=VA("gitlab",t??(n.where==="self"?n.baseUrl:null));return i.jsxs("div",{className:"fg-token-help",children:[i.jsxs("p",{children:[nW(a("forge.token.gl.scope"),{scope:i.jsx("code",{children:"read_api"})})," ",i.jsx(KA,{href:s,children:a("forge.token.makeOn",{host:s?new URL(s).host:"GitLab"})})]}),i.jsx("p",{children:a("forge.token.gl.expire")})]})}const _8={name:"token",type:"password",secret:!0,get label(){return S("forge.field.token")},get placeholder(){return S("forge.field.tokenPlaceholder")}},MPe=[_8],aW=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},IPe=[{name:"where",type:"choice",get label(){return S("forge.field.which")},get options(){return[{value:"cloud",label:"GitLab.com"},{value:"self",label:S("forge.field.selfManaged")}]},initial:e=>aW(e)?"self":"cloud"},{name:"baseUrl",type:"url",placeholder:"https://gitlab.example.com",get label(){return S("forge.field.url")},get hint(){return S("forge.field.urlHint")},when:{field:"where",is:["self"]},initial:e=>aW(e)?e.baseUrl:""},_8],DPe=m.createElement(q8,{kind:"github"}),FPe=m.createElement(q8,{kind:"gitlab"}),BPe=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},UPe={kind:"jira",label:"Jira",Glyph:vge,shortcut:"I",detail:"Boards, sprints, and issues",blurb:"Jira Cloud, or Jira Server / Data Center 8.14 and newer.",fields:[{name:"deployment",label:"Which Jira",type:"choice",options:[{value:"server",label:"Jira Server / Data Center"},{value:"cloud",label:"Jira Cloud"}],initial:BPe},{name:"baseUrl",label:"Jira URL",type:"url",initial:e=>(e==null?void 0:e.baseUrl)??"",variants:{field:"deployment",by:{server:{label:"Jira URL",placeholder:"https://jira.example.com",hint:"The address you open Jira at, with its path if it has one (…/jira). https only."},cloud:{label:"Site URL",placeholder:"your-site.atlassian.net",hint:"The address you open Jira at. Your site name alone is enough."}}}},{name:"email",label:"Atlassian account email",type:"email",placeholder:"you@example.com",autoComplete:"username",secret:!0,when:{field:"deployment",is:["cloud"]}},{name:"token",label:"Personal access token",type:"password",secret:!0,variants:{field:"deployment",by:{server:{label:"Personal access token",placeholder:"Paste the token"},cloud:{label:"API token",placeholder:"Paste the API token"}}}}],tokenHelp:m.createElement(OPe)},WPe={kind:"github",label:"GitHub",Glyph:wge,detail:"Repositories, pull requests, and Actions",blurb:"github.com, read-only, with a personal access token.",fields:MPe,tokenHelp:DPe},HPe={kind:"gitlab",label:"GitLab",Glyph:yge,detail:"Projects, merge requests, and pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:IPe,tokenHelp:FPe},dE={jira:UPe,github:WPe,gitlab:HPe},Az=()=>Object.values(dE).filter(e=>!!e);function Ep(e){return(Object.hasOwn(dE,e)?dE[e]:void 0)??null}function Xv(e,t){const n=a=>typeof t=="string"?t:t(a);return m.lazy(()=>e().catch(a=>(console.warn(`ccdeck could not load ${typeof t=="string"?t:"a dialog"}`,a),{default:s=>i.jsx(GPe,{name:n(s),onClose:s.onClose})})))}function GPe({name:e,onClose:t}){const n=se(),a=m.useRef(null),s=Zt(t,{focusRef:a}),o=tn(t);return i.jsxs(dn,{scrim:o,dialogRef:s,className:"dialog-missing",labelledBy:"dialog-missing-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:t,label:n("shell.closeEsc")})})]}),i.jsx("section",{className:"modal-body",children:i.jsx("p",{className:"dm-note",children:n("shell.lazy.didNotLoad",{name:e})})}),i.jsxs("footer",{className:"modal-foot",children:[i.jsx("button",{type:"button",className:"btn",onClick:t,children:n("shell.close")}),i.jsx("button",{type:"button",ref:a,className:"btn primary",onClick:()=>window.location.reload(),children:n("shell.reload")})]})]})}const L8=()=>Xs(()=>import("./IntegrationModal-4Z8_QVBa.js"),__vite__mapDeps([2,3]));function VPe(){L8().catch(()=>{})}const KPe=Xv(L8,e=>{var t;return((t=Ep(e.kind))==null?void 0:t.label)??S("integrations.modal.tracker")});function $Pe({onClose:e}){const t=a5();return m.useEffect(()=>t?void 0:Rn.push(e,0,"dialog"),[e,t]),null}function JPe(e){return i.jsx(m.Suspense,{fallback:i.jsx($Pe,{onClose:e.onClose}),children:i.jsx(KPe,{...e})})}const sW={"The deck failed while reading the tracker.":"integrations.srv.deckFailed","The answer was larger than the deck accepts.":"integrations.srv.tooLarge","Enter a token.":"integrations.srv.enterToken","Enter an API token.":"integrations.srv.enterApiToken","Enter a personal access token.":"integrations.srv.enterPat","The token has a space in it. Paste it again.":"integrations.srv.tokenSpace","Enter the email address of your Atlassian account.":"integrations.srv.enterEmail","Choose Jira Cloud or Jira Server / Data Center.":"integrations.srv.chooseDeployment","Enter your Jira site URL.":"integrations.srv.enterSiteUrl","Enter your Jira URL.":"integrations.srv.enterJiraUrl","Enter your GitLab's address.":"integrations.srv.enterGitlabUrl","Your Jira site URL is not a valid URL.":"integrations.srv.badSiteUrl","Your Jira URL is not a valid URL.":"integrations.srv.badJiraUrl","Your GitLab's address is not a valid URL.":"integrations.srv.badGitlabUrl","Leave the user name and password out of the address.":"integrations.srv.urlUser","Use an https:// address. Plain http is only accepted for a server on this machine.":"integrations.srv.httpsOnly","Use an https:// address.":"integrations.srv.httpsAddress","That connection is not there any more.":"integrations.srv.connectionGone","No token is saved for this connection. Edit it and enter one.":"integrations.srv.noTokenEdit","No token is saved for this connection. Reconnect it in Settings.":"integrations.srv.noTokenReconnect","Enter a comment of up to 10,000 characters.":"integrations.srv.commentLength","This Jira write is outside the connection's token origins.":"integrations.srv.writeOutside","Jira redirected the comment. Refresh the issue before sending again.":"integrations.srv.commentRedirected","The comment could not be confirmed. Refresh the issue before sending again.":"integrations.srv.commentUnconfirmed","Jira redirected the write. It was not replayed; refresh the board before trying again.":"integrations.srv.writeRedirected","Jira's rank result was too large. Refresh the board to check its position.":"integrations.srv.rankTooLarge","Jira did not confirm every requested issue update. Some issues may have changed; refresh the board to check them.":"integrations.srv.updateUnconfirmed","Jira did not confirm the write. Refresh the board to check the issue.":"integrations.srv.writeUnconfirmed","Jira refused the move: the account or token needs permission to edit and schedule this issue.":"integrations.srv.moveRefused","Jira did not return its available transitions.":"integrations.srv.transitionsMissing","Choose a valid transition.":"integrations.srv.transitionChoose","This transition is unavailable or requires additional fields in Jira.":"integrations.srv.transitionUnavailable","Jira redirected the transition. Refresh the issue before trying again.":"integrations.srv.transitionRedirected","Jira did not confirm the transition. Refresh the issue.":"integrations.srv.transitionUnconfirmed","There is no Jira REST API at this address. Check the URL — some servers live under a path such as /jira.":"integrations.srv.noRestApi","This is a Jira Cloud site. Choose Jira Cloud and connect with your email and an API token.":"integrations.srv.isCloud","This is Jira Server or Data Center, not Cloud. Choose Jira Server / Data Center and use a personal access token.":"integrations.srv.isServer","Jira did not accept this email and API token, on the site or through api.atlassian.com. Check both, and that the token has not expired.":"integrations.srv.emailTokenRefused","Jira wants a CAPTCHA after too many failed sign-ins. Sign in to Jira once in your browser, then test the connection again.":"integrations.srv.captcha","Jira did not accept this personal access token: it answered as an anonymous visitor. Check that the token is right and has not expired or been revoked.":"integrations.srv.patAnonymous","That quick filter is not on this board any more. Refresh the board.":"integrations.srv.quickFilterGone","Jira writes are unavailable because this system cannot safely coordinate them.":"integrations.srv.writesUnavailable","Supply either one issueKey or 2–50 ordered issueKeys and a sprint or backlog target.":"integrations.srv.moveWhere","Supply unique, valid issue keys (2–50 for a batch).":"integrations.srv.moveKeys","Not a valid issue key or move target.":"integrations.srv.moveTarget","Use at most one other issue as the rank anchor.":"integrations.srv.moveAnchor","The issues and anchor must all belong to this board.":"integrations.srv.moveSameBoard","The issues and rank anchor must be top-level issues.":"integrations.srv.moveTopLevel","Only top-level non-epic issues with a known status can be moved.":"integrations.srv.moveEpicStatus","Done issues cannot be moved to the backlog because Jira hides them there. Change the status first.":"integrations.srv.moveDone","Every issue must be in the backlog or one active or future sprint.":"integrations.srv.moveSource","The source and target must be active or future sprints on this board.":"integrations.srv.moveSprints","An issue's source changed or is a closed sprint. Refresh the board.":"integrations.srv.moveSourceChanged","Could not determine the destination's last issue. Refresh and try again.":"integrations.srv.moveLastIssue","Could not verify the destination order. Refresh and try again.":"integrations.srv.moveOrder","The destination is too large to determine the last issue. Refresh and try again.":"integrations.srv.moveDestinationLarge","The rank anchor must be in the target group. Refresh the board.":"integrations.srv.moveAnchorGroup","This server runs Jira of an unknown version. Personal access tokens need Jira Server or Data Center 8.14 or newer, so the deck cannot connect to it.":"integrations.srv.serverOldUnknown","too many redirects":"forge.srv.redirects","answer too large":"forge.srv.answerLarge","answer cut off":"forge.srv.answerCut","unreadable JSON":"forge.srv.badJson","log too large to read the end of":"forge.srv.logLarge","image too large":"forge.srv.imageLarge","image cut off":"forge.srv.imageCut","that cursor is not a page of this list":"forge.srv.cursorPage","that cursor is not one of this list":"forge.srv.cursorList"},YPe=[[/^The deck could not verify (Jira|GitHub|GitLab)'s HTTPS certificate \((.+?)\)\. Check that the address is right and that the server's certificate is valid for it\.$/,"integrations.srv.tlsCert",["provider","code"]],[/^(Jira|GitHub|GitLab) did not answer in time\.$/,"integrations.srv.timeout",["provider"]],[/^The deck could not find (Jira|GitHub|GitLab)'s address\. Check the URL and your network\.$/,"integrations.srv.noAddress",["provider"]],[/^The deck could not reach (Jira|GitHub|GitLab) \((.+?)\)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReachCode",["provider","code"]],[/^The deck could not reach (Jira|GitHub|GitLab)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReach",["provider"]],[/^(Jira|GitHub|GitLab) did not accept these credentials\.$/,"integrations.srv.noCredentials",["provider"]],[/^(Jira|GitHub|GitLab) no longer accepts the saved token\. It may have expired or been revoked — reconnect with a new one\.$/,"integrations.srv.tokenGone",["provider"]],[/^(Jira|GitHub|GitLab) refused: the account or token is not allowed to read this\.$/,"integrations.srv.notAllowed",["provider"]],[/^(Jira|GitHub|GitLab) is limiting requests\. Try again in (\d+) s\.$/,"integrations.srv.limiting",["provider","n"]],[/^(Jira|GitHub|GitLab) has no such page or record, or this account cannot see it\.$/,"integrations.srv.noSuchPage",["provider"]],[/^(Jira|GitHub|GitLab) refused the request\.$/,"integrations.srv.refusedRequest",["provider"]],[/^(Jira|GitHub|GitLab) is not answering right now \((\d+)\)\. Try again shortly\.$/,"integrations.srv.notAnswering",["provider","status"]],[/^(Jira|GitHub|GitLab) answered (\d+)\.$/,"integrations.srv.answered",["provider","status"]],[/^The deck only sends this connection's token to (.+)\.$/,"integrations.srv.tokenOrigins",["origins"]],[/^(Jira|GitHub|GitLab) redirected to (\S+?), and the deck does not send the token there\. Check the address you connected\.$/,"integrations.srv.redirectedAway",["provider","origin"]],[/^(Jira|GitHub|GitLab) redirected too many times\.$/,"integrations.srv.redirectedMany",["provider"]],[/^(Jira|GitHub|GitLab) answered with something that is not JSON\. Check that the address is the \1 site itself\.$/,"integrations.srv.notJson",["provider"]],[/^The deck will not send a token to (\S+?)\.$/,"integrations.srv.noTokenTo",["origin"]],[/^This server runs Jira (.+?)\. Personal access tokens need Jira Server or Data Center 8\.14 or newer, so the deck cannot connect to it\.$/,"integrations.srv.serverOld",["version"]],[/^(Jira|GitHub|GitLab) is not available on this deck\.$/,"integrations.srv.notOnDeck",["provider"]],[/^(\S+?) did not answer in time$/,"forge.srv.timeout",["origin"]],[/^(\S+?): the certificate is not trusted \((.+?)\)$/,"forge.srv.cert",["origin","code"]],[/^(\S+?): no answer$/,"forge.srv.noAnswer",["origin"]],[/^(\S+?) is not a host this connection reads from$/,"forge.srv.notHost",["origin"]],[/^(\S+?) sent this read to (\S+?), not to this connection's address$/,"forge.srv.sentElsewhere",["origin","next"]],[/^(\S+?) answered (.+?), not the API$/,"forge.srv.notApi",["origin","type"]],[/^not an image \((.+?)\)$/,"forge.srv.notImage",["type"]]];function ZPe(e,t=S){if(!e)return"";const n=e.replace(/\u2019/g,"'"),a=Object.hasOwn(sW,n)?sW[n]:void 0;if(a)return t(a);for(const[s,o,r]of YPe){const c=s.exec(n);if(!c)continue;const l={};return r.forEach((u,h)=>{l[u]=c[h+1]}),t(o,l)}return e}function XPe(e){if(!e||typeof e!="object")return;const t=e;if(!(typeof t.operationId!="string"||!/^[0-9a-f-]{36}$/.test(t.operationId)||typeof t.connectionId!="string"||!["comment","status","move"].includes(t.kind)||!["pending","uncertain","confirmed"].includes(t.state))&&!(t.kind==="move"?!Array.isArray(t.issueKeys)||!t.issueKeys.every(n=>typeof n=="string"):typeof t.issueKey!="string"))return t}class Ks extends $n{constructor(n,a,s={}){super(a);Ss(this,"kind");Ss(this,"operation");Ss(this,"status");Ss(this,"retryAfter");Ss(this,"field");Ss(this,"detail");Ss(this,"refreshRequired");Ss(this,"outcomes");Ss(this,"moveOutcome");this.name="IntegrationFailure",this.kind=n,Object.assign(this,s)}}async function P8(e){try{const t=await e.json(),n=t==null?void 0:t.error,a=XPe(t==null?void 0:t.operation);if((t==null?void 0:t.code)==="jira_write_guard_conflict")return new Ks("upstream",S("integrations.error.writeAwaiting"),{status:e.status,operation:a});if(n&&typeof n.kind=="string"&&typeof n.message=="string"){const s=Array.isArray(t.outcomes)?t.outcomes.slice(0,50).filter(c=>{if(!c||typeof c!="object")return!1;const l=c;return typeof l.issueKey=="string"&&/^[A-Z][A-Z0-9_]{0,40}-[1-9]\d{0,11}$/.test(l.issueKey)&&["moved","unchanged","unknown"].includes(String(l.membership))&&["ranked","unchanged","failed","unknown"].includes(String(l.rank))}).map(c=>({issueKey:c.issueKey,membership:c.membership,rank:c.rank})):[],o=t.outcome,r=o&&["moved","unchanged","unknown"].includes(o.membership)&&["ranked","unchanged","failed","unknown"].includes(o.rank)?{membership:o.membership,rank:o.rank}:void 0;return new Ks(n.kind,ZPe(n.message),{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail,...t.refresh===!0?{refreshRequired:!0}:{},...s.length?{outcomes:s}:{},...r?{moveOutcome:r}:{},...a?{operation:a}:{}})}}catch{}return new Ks(e.status===401?"auth":"upstream",S("integrations.error.deckAnswered",{status:e.status}))}async function Zg(e,t={}){const{timeoutMs:n=3e4,...a}=t;return O8(a.signal,n,async s=>{let o;try{o=await fetch(e,{...a,signal:s,headers:a.body?{"Content-Type":"application/json",...a.headers??{}}:a.headers})}catch(r){throw s.aborted?r:new Ks("network",S("integrations.error.unreachable"))}if(!o.ok)throw await P8(o);return o.json()})}async function O8(e,t,n){const a=new AbortController,s=window.setTimeout(()=>a.abort(),t),o=()=>a.abort(e==null?void 0:e.reason);e==null||e.addEventListener("abort",o,{once:!0}),e!=null&&e.aborted&&o();try{return a.signal.throwIfAborted(),await n(a.signal)}catch(r){throw e!=null&&e.aborted?e.reason??r:a.signal.aborted?new Ks("network",S("integrations.error.timeout")):r}finally{window.clearTimeout(s),e==null||e.removeEventListener("abort",o)}}const M8=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function T4e(e){const t=M8(e);return(n,a)=>fetch(`${t}${n.replace(/^\/+/,"")}`,a)}function N4e(e){const t=M8(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function A4e(e,t){if(!t)return null;try{const n=new URL(t);return n.username||n.password||n.protocol!=="https:"&&n.protocol!=="http:"?null:n.origin===new URL(e.baseUrl).origin?n.href:null}catch{return null}}function j4e(e){const t=new URLSearchParams;for(const[a,s]of Object.entries(e))s===void 0||s===""||s===!1||t.set(a,s===!0?"1":String(s));const n=t.toString();return n?`?${n}`:""}async function E4e(e,t,{signal:n,timeoutMs:a=45e3}={}){return O8(n,a,async s=>{let o;try{o=await e(t,{signal:s,headers:{Accept:"application/json"}})}catch(r){throw s.aborted?r:new Ks("network",S("integrations.error.unreachable"))}if(!o.ok)throw await P8(o);try{return await o.json()}catch(r){throw s.aborted?r:new Ks("upstream",S("integrations.error.notJson"))}})}let ar={connections:null,providers:[],error:""};const nu=new Set;let tb=null,ap=null,hu=null,iW=0;const QPe=5e3,eOe=3;function Nk(e){ar={...ar,...e},nu.forEach(t=>t(ar))}function Qv(){return ap||(ap=(async()=>{try{const e=await Zg("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new Ks("upstream",S("integrations.error.notList"));Nk({connections:t,providers:n,error:""})}catch(e){Nk({error:rr(e,S("integrations.error.readConnections"))}),ar.connections===null&&nu.size>0&&hu===null&&iW<eOe&&(hu=window.setTimeout(()=>{hu=null,Qv()},QPe*2**iW++))}finally{ap=null}})(),ap)}function tOe(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function oW(){tOe(ar)&&Qv()}function jz(e){const t=ar.connections??[],n=t.findIndex(a=>a.id===e.id);Nk({connections:n<0?[...t,e]:t.map(a=>a.id===e.id?e:a)})}function nOe(e){Nk({connections:(ar.connections??[]).filter(t=>t.id!==e)})}function Xg(){const[e,t]=m.useState(ar);return m.useEffect(()=>{nu.add(t),t(ar);const n=()=>{document.visibilityState==="visible"&&oW()};return nu.size===1&&(Qv(),tb=window.setInterval(oW,6e4),document.addEventListener("visibilitychange",n)),()=>{nu.delete(t),nu.size===0&&(tb!==null&&window.clearInterval(tb),tb=null,hu!==null&&window.clearTimeout(hu),hu=null,document.removeEventListener("visibilitychange",n))}},[]),e}function Ak(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function Qg(e){return e.connections===null?new Set:new Set(e.providers.filter(t=>(t==null?void 0:t.available)===!0).map(t=>t.kind))}function Qo(e,t){return Qg(e).has(t)}function uE(e,t){return Qo(e,t)&&Ak(e,t).length>0}function Ez(e){return Qg(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function aOe(e,t,n){const a=await Zg("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return jz(a.connection),a.connection}async function sOe(e,t){const n=await Zg(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return jz(n.connection),n}async function iOe(e){const t=await Zg(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return jz(t.connection),t.connection}async function oOe(e){await Zg(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),nOe(e)}function Yc(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function R4e(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length?(t.length===1?t[0].slice(0,2):`${t[0][0]}${t[t.length-1][0]}`).toUpperCase():"?"}let jk=null,Ek=null;function rW(e){Ek=null,jk=e}function rOe(e){jk=null,Ek=e}function cOe(){const e=Ek;return Ek=null,e}function lOe(){const e=jk;return jk=null,e}const dOe={jira:"integrations.explore.cap.jira",github:"integrations.explore.cap.github",gitlab:"integrations.explore.cap.gitlab"},uOe={jira:"integrations.explore.access.jira",github:"integrations.explore.access.read",gitlab:"integrations.explore.access.read"};function hOe(){return Array.from(document.querySelectorAll('[data-rail-item="explore-integrations"], [data-rail-item="more"]')).find(e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0)??null}function pOe({integrations:e,onClose:t,onOpen:n,onConnect:a,onManage:s}){const o=se(),r=Zt(t,{restoreFocusFallback:hOe}),c=tn(t),l=Az().filter(p=>e.providers.some(f=>f.kind===p.kind)||Ak(e,p.kind).length>0),u=l.filter(p=>uE(e,p.kind)).length,h=p=>{t(),p()};return $t.createPortal(i.jsxs(dn,{scrim:c,dialogRef:r,className:"explore-integrations",labelledBy:"explore-integrations-title","aria-describedby":"explore-integrations-description",children:[i.jsxs("div",{className:"modal-head explore-head",children:[i.jsx("h2",{id:"explore-integrations-title",children:o("integrations.explore.title")}),i.jsx("button",{type:"button",className:"glyph-btn","aria-label":o("integrations.explore.closeAria"),title:o("integrations.closeEsc"),onClick:t,children:"×"})]}),i.jsxs("div",{className:"explore-body",children:[i.jsx("p",{id:"explore-integrations-description",className:"explore-intro",children:o("integrations.explore.intro")}),e.error&&e.connections!==null&&i.jsxs("p",{className:"explore-status","data-tone":"err",role:"alert",children:[e.error," ",o("integrations.explore.stale")]}),e.connections===null?e.error?i.jsx("p",{className:"explore-status","data-tone":"err",role:"alert",title:e.error,children:o("integrations.explore.statusUnavailable")}):i.jsx("p",{className:"explore-status",role:"status",children:i.jsxs("span",{className:"loader-line",children:[i.jsx(Fg,{busy:!0}),o("integrations.explore.reading")]})}):l.length===0?i.jsx("p",{className:"explore-status",role:"status",children:o("integrations.explore.none")}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"explore-caption",children:[i.jsx("span",{children:o("integrations.explore.available")}),i.jsx("span",{children:o("integrations.explore.connectedCount",{n:u})})]}),i.jsx("ul",{className:"explore-providers",children:l.map(p=>{const f=Qo(e,p.kind),b=uE(e,p.kind),v=Ak(e,p.kind)[0];return i.jsxs("li",{className:"explore-provider",children:[i.jsxs("div",{className:"explore-info",children:[i.jsxs("div",{className:"explore-name",children:[i.jsx("h3",{children:p.label}),i.jsx("span",{className:"explore-tag",children:o(uOe[p.kind])})]}),i.jsx("p",{children:o(dOe[p.kind])})]}),i.jsx("span",{className:"explore-connection",children:o(f?b?"integrations.explore.connected":"integrations.explore.notConnected":"integrations.explore.unavailableOnDeck")}),i.jsx("div",{className:"explore-actions",children:b?i.jsx("button",{type:"button",className:"btn primary","aria-label":o("integrations.explore.openAria",{label:p.label}),onClick:()=>h(()=>n(p.kind)),children:o("integrations.explore.open")}):f?i.jsx("button",{type:"button",className:"btn","aria-label":o("integrations.form.connect",{provider:p.label}),onClick:()=>h(()=>a(p.kind)),children:o("integrations.form.connectBtn")}):v?i.jsx("button",{type:"button",className:"explore-text-action","aria-label":o("integrations.manageProvider",{label:p.label}),onClick:()=>h(()=>s(v.id)),children:o("integrations.manage")}):i.jsx("span",{className:"explore-unavailable",children:o("integrations.explore.notAvailable")})})]},p.kind)})})]}),i.jsx("p",{className:"explore-footnote",children:o("integrations.explore.footer")})]}),i.jsxs("div",{className:"explore-footer",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>h(()=>s()),children:o("integrations.explore.manageInSettings")}),i.jsx("button",{type:"button",className:"btn primary",onClick:t,children:o("shell.done")})]})]}),document.body)}const gOe="board.counts.working",mOe="board.counts.done";function fOe(e){const t={waiting:0,working:0,done:0};for(const n of e){if(n.kind!=="root")continue;const a=cu(n).tone;a==="waiting"?t.waiting++:a==="active"?t.working++:a==="done"&&t.done++}return t}function cW(e,t=S){const n=Math.max(0,Math.floor(e));return t("board.pill.events",{count:n})}const lW=99;function bOe(e){const t=Math.max(0,Math.floor(e));return t>lW?`${lW}+`:String(t)}function kOe(e,t=S){return e.connected||!e.paused?null:t("board.pill.outage")}const I8=e=>e("board.pill.pausedFull"),vOe=(e,t,n)=>t>0?I8(n):e>0?n("board.pill.pausedCount",{held:bOe(e)}):n("board.pill.paused");function wOe(e,t=S){const n=Math.max(0,Math.floor(e.dropped??0)),a=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:vOe(e.held,n,t),widest:I8(t),title:bo(n>0?t("board.pill.title.connectedFull",{held:cW(e.held,t)}):e.held>0?t("board.pill.title.connectedHeld",{held:cW(e.held,t)}):t("board.pill.title.connectedNone"),"Space",a)}:{tone:"live",resting:!0,label:t("board.pill.live"),widest:t("board.pill.live"),title:t("board.pill.title.live")}:{tone:"dead",resting:!1,label:t("board.pill.offline"),widest:t("board.pill.offline"),title:e.paused?t("board.pill.title.offlinePaused"):t("board.pill.title.offline")}}function yOe(e,t=S){return e.tool?e.tool.name:e.kind==="asked"?t("board.queue.question"):t("board.queue.permission")}const xOe=20;function COe(e,t=xOe){if(e.length<=t)return e;const n=Math.floor((t-1)*.4),a=t-1-n;return`${e.slice(0,a)}…${e.slice(e.length-n)}`}function SOe(e,t=S){const n=Math.floor(Math.max(0,e)/6e4);if(n<1)return t("board.queue.lessThanMinute");if(n<60)return t("board.queue.minutes",{count:n});const a=Math.floor(n/60),s=n%60;return s===0?t("board.queue.hours",{count:a}):t("board.queue.hoursMinutes",{h:t("board.queue.hours",{count:a}),m:t("board.queue.minutes",{count:s})})}function TOe(e,t,n,a=S){var r;const s=SOe(n,a),o=t.tool?"board.queue.entry.tool":t.kind==="asked"?"board.queue.entry.answer":"board.queue.entry.permission";return a(o,{label:e,wait:s,tool:((r=t.tool)==null?void 0:r.name)??""})}const NOe=new Set(["idle","checking","current","downloading","ready","error"]);function dW(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!NOe.has(t.status))return null;const n=typeof t.version=="string"&&t.version.trim()?t.version.trim():null;return t.status==="ready"&&!n?null:{status:t.status,version:n}}function AOe(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function D8(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const jOe="shell.desktop.restartToUpdate",Rk=()=>S(jOe),F8=3e4;function B8(e=typeof navigator>"u"?"":navigator.userAgent){return/\bMac OS X\b|\bMacintosh\b/.test(e)?S("shell.desktop.menuMac"):S("shell.desktop.menuTray")}const EOe="shell.desktop.restartToFinish";function ROe(e,t,n=!1){return{text:S(n?"shell.notes.restarting":EOe),title:`v${e} → v${t} · ${S("shell.desktop.restartTitle",{to:t})}`}}function zOe(e,t=!1){return{text:t?S("shell.notes.restarting"):Rk(),label:t?void 0:S("shell.desktop.restartLabel",{action:Rk(),to:e}),title:S("shell.desktop.restartTitle",{to:e})}}function qOe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function U8(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const a=B8(n),s=Rk(),o=S("shell.desktop.way",{action:s,menu:a});switch(e){case"app_disconnected":return S("shell.desktop.fail.app_disconnected",{way:o});case"update_not_ready":return S("shell.desktop.fail.update_not_ready",{version:t,action:s,menu:a});case"timeout":return S("shell.desktop.fail.timeout",{seconds:F8/1e3,way:o});case"refused":return S("shell.desktop.fail.refused",{way:o});case"unreachable":return S("shell.desktop.fail.unreachable",{way:o})}}function _Oe(e){const t=e.kind==="restart"?S("shell.chip.noticeRestart",{to:e.to}):S("shell.chip.noticeUpgrade",{to:e.to}),n=e.open?S("shell.chip.noticeShow"):S("shell.chip.noticeShowBanner");return S("shell.chip.noticeLabel",{text:W8(e),from:e.from,what:t,does:n})}function W8(e){return e.kind==="restart"?S("shell.chip.textRestart",{to:e.to}):S("shell.chip.textUpgrade",{to:e.to})}function H8(e){return e?`${e.kind}:${e.to}`:""}function LOe(e,t){return e!=null&&t!==H8(e)}function G8(e){return!!e.readyAppUpdate||!!e.notice}function POe({readyAppUpdate:e,notice:t,noticeOpen:n,chipVersion:a,openReleaseNotes:s,showNotice:o,restartToUpdate:r,updateRestarting:c=!1}){return Es(),G8({readyAppUpdate:e,notice:t})?i.jsx(i.Fragment,{children:e?(()=>{const l=ROe(D8()??a,e.version,c);return i.jsxs("button",{type:"button",className:"v ready",onClick:()=>r(e.version),"aria-busy":c||void 0,title:l.title,children:[i.jsx("span",{className:"v-icon","aria-hidden":!0,children:i.jsx(Ze,{name:"restart"})}),l.text]})})():t?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{s(),o()},"aria-haspopup":"dialog","aria-label":_Oe({...t,open:n}),title:t.kind==="restart"?S("shell.chip.runningRestart",{from:t.from,to:t.to}):S("shell.chip.runningUpgrade",{from:t.from,to:t.to}),children:[i.jsx("span",{className:"v-icon","aria-hidden":!0,children:i.jsx(Ze,{name:"update"})}),W8(t)]}):null}):null}function OOe({live:e,paused:t,pauseGate:n}){const a=se(),s=sa(),o=wOe({connected:e,paused:t,held:n.size,dropped:n.dropped,singleKeys:s},a);return i.jsx(uR,{show:!o.resting,className:"status",children:!o.resting&&i.jsx("span",{className:`pill ${o.tone}`,title:o.title,children:i.jsx("span",{className:"pill-label",children:o.label})})})}function MOe({w:e,now:t}){const n=se();return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"we-name",children:COe(e.name??e.label)}),i.jsx("span",{className:"we-wait",children:sde(e.waiting.since,void 0,t)}),i.jsxs("span",{className:"we-what",children:["· ",yOe(e.waiting,n)]})]})}function IOe(e){const[t,n]=Array.from(e.children);if(!t)return 0;const a=n?n.offsetTop-t.offsetTop:t.offsetHeight;return a<=0?e.children.length:Math.floor((e.clientHeight+a-t.offsetHeight)/a)}const hE="waiting-pill",V8="queue-pop",DOe=150;function K8(){return typeof document<"u"&&document.documentElement.dataset.motion==="instant"}function FOe({sessions:e,now:t,leaving:n,onPick:a,onClose:s}){const o=se(),r=sa(),[c,l]=m.useState(!1);m.useLayoutEffect(()=>{if(K8()){l(!0);return}let b=requestAnimationFrame(()=>{b=requestAnimationFrame(()=>l(!0))});return()=>cancelAnimationFrame(b)},[]);const u=m.useRef(null),h=m.useRef(0),[p,f]=m.useState(0);return m.useLayoutEffect(()=>{const b=u.current;if(b){if(b.scrollHeight<=b.clientHeight+1){f(0);return}b.scrollTop=h.current,f(Math.max(0,e.length-IOe(b)))}}),i.jsxs(Rs,{anchorId:hE,id:V8,role:"menu",labelledBy:hE,align:"start",className:n?"queue-pop queue-pop-leaving":c?"queue-pop queue-pop-open":"queue-pop",onClose:s,children:[i.jsx("div",{className:"queue-head","aria-hidden":!0,children:o("board.queue.title")}),i.jsx("div",{className:"queue-rows",ref:u,onScroll:b=>{h.current=b.currentTarget.scrollTop},children:e.map(b=>i.jsxs("button",{type:"button",role:"menuitem",className:"queue-row",onClick:()=>a(b.id),"aria-label":TOe(b.name??b.label,b.waiting,t-b.waiting.since,o),children:[i.jsx(ic,{size:14}),i.jsx(MOe,{w:b,now:t})]},b.id))}),p>0&&i.jsxs("div",{className:"queue-foot","aria-hidden":!0,children:[i.jsx("span",{children:o("board.queue.more",{n:p})}),r&&i.jsx(lu,{children:"n"})]})]})}const BOe={working:"count-pill count-working",done:"count-pill count-done"};function uW({kind:e,count:t,glyph:n,word:a}){return t===0?null:i.jsxs("span",{className:BOe[e],children:[n,i.jsx("b",{children:t}),i.jsx("span",{className:"count-word",children:a})]})}function UOe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:a}){const s=se(),o=sa(),r=qg("below"),c=e.length,[l,u]=m.useState("closed"),h=m.useRef(l);h.current=l;const p=m.useRef(void 0);m.useEffect(()=>()=>window.clearTimeout(p.current),[]);const f=m.useCallback(()=>{if(h.current==="open"){if(K8()){u("closed");return}u("leaving"),window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("closed"),DOe)}},[]);if(m.useEffect(()=>{c===0&&l!=="closed"&&u("closed")},[c,l]),c===0)return null;const b=s("board.queue.waitingForYou",{count:c});return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",id:hE,className:"count-pill waiting-stat",onClick:()=>{h.current==="closed"?u("open"):f()},onKeyDown:v=>{v.key==="ArrowDown"&&h.current==="closed"&&(v.preventDefault(),u("open"))},"aria-label":b,"aria-haspopup":"menu","aria-expanded":l==="open","aria-controls":l!=="closed"?V8:void 0,"aria-keyshortcuts":o?"W":void 0,...r.bind({label:b,keys:o?"W":void 0}),children:[i.jsx(ic,{size:14}),i.jsx("b",{children:c}),i.jsx("span",{className:"count-word",children:s("board.queue.waiting")})]}),r.node,l!=="closed"&&i.jsx(FOe,{sessions:e,now:a,leaving:l==="leaving",onClose:f,onPick:v=>{t.current=v,f(),n(v)}})]})}const WOe={on:"board.notify.means.on",blocked:"board.notify.means.blocked"};function HOe(e,t=S){return e==="on"?t("board.notify.said.on"):e==="blocked"?t("board.notify.said.blocked"):""}function GOe({notifySaid:e}){const t=se();return i.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:t(WOe[e]),children:t(e==="on"?"board.notify.on":"board.notify.blocked")})}function VOe({versionCheck:e,welcome:t,desktopUpdate:n,pause:a,announcements:s,notify:o,waitingSessions:r,waitingCursorRef:c,focusSession:l,live:u,now:h,incidents:p,counts:f,asksSaid:b,children:v}){const{notice:w,noticeOpen:T,showNotice:y}=e,{chipVersion:x,openReleaseNotes:C}=t,{readyAppUpdate:A,desktopUpdateRestarting:E,desktopUpdateFailure:R,askDesktopUpdateRestart:z}=n,I=m.useRef(!1);m.useEffect(()=>{E||!I.current||(I.current=!1,R&&C())},[E,R,C]);const _=H=>{I.current=!0,z(H)},{paused:D,pauseGate:L}=a,P=se(),{blockedSaid:O,watchSaid:j,incidentSaid:M}=s,{notifySaid:F}=o,U=Tg();return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"readout",children:[i.jsxs("div",{className:"brand",children:[i.jsx("img",{className:"logo logo-on-dark",src:Eke,width:19,height:16,alt:""}),i.jsx("img",{className:"logo logo-on-light",src:Rke,width:19,height:16,alt:""}),i.jsx("h1",{children:an})]}),!U&&r.length+f.working+f.done>0&&i.jsxs("div",{className:"counts",children:[i.jsx(UOe,{waitingSessions:r,waitingCursorRef:c,focusSession:l,now:h}),i.jsx(uW,{kind:"working",count:f.working,glyph:i.jsx(yi,{kind:"live",size:14}),word:P(gOe,{count:f.working})}),i.jsx(uW,{kind:"done",count:f.done,glyph:i.jsx(yi,{kind:"done",size:14}),word:P(mOe,{count:f.done})})]}),i.jsx(OOe,{live:u,paused:D,pauseGate:L}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:j}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:HOe(F,P)}),b!=null&&i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:b}),i.jsx(Uke,{incidents:p}),F&&i.jsx(GOe,{notifySaid:F})]}),i.jsxs("div",{className:"tb-end",children:[i.jsx(uR,{show:G8({readyAppUpdate:A,notice:w}),children:i.jsx("span",{className:"v-group",children:i.jsx(POe,{readyAppUpdate:A,notice:w,noticeOpen:T,chipVersion:x,openReleaseNotes:C,showNotice:y,restartToUpdate:_,updateRestarting:E})})}),v]})]})}function KOe(e,t,n={},a=S){var r;const s=[];for(const c of uv(e,t,n.watching)){const l=e.agents.get(c.sessionId);if(!l||(r=n.removed)!=null&&r.has(c.sessionId)||!Ng(l,t))continue;const u={...c};delete u.twin,s.push({row:u,group:Eu(u),status:Eg(l,a)})}const o=ov(s.map(c=>({id:c.row.sessionId,title:c.row.label,task:c.row.task,startedAt:c.row.startedAt})));for(const c of s){const l=o.get(c.row.sessionId);l&&(c.row.twin=l)}return s}function $Oe(e,t,n){return{model:e.modelId?Rg(e.modelId,e.effort):null,time:k5(e,t,n)}}function JOe({state:e,now:t,watching:n,removedIds:a,selectedIds:s,onOpen:o}){const r=se(),c=Es(),l=lG(),u=n?[...n].sort().join(`
|
|
154
|
-
`):"",h=m.useMemo(()=>KOe(e,t,{watching:n,removed:a},r),[e,e.revision,t,l,u,a,c]),[p,f]=m.useState(!1),b=m.useRef([]),v=h.map(y=>({id:y.row.sessionId,group:y.group})),w=p&&b.current.length>0?X4(b.current,v).order:v;if(b.current=w,h.length===0)return null;const T=new Map(h.map(y=>[y.row.sessionId,y]));return i.jsx("ul",{className:"phone-board",role:"list","aria-label":r("board.phone.stack"),onPointerEnter:()=>f(!0),onPointerLeave:()=>f(!1),children:w.map(y=>i.jsx("li",{className:"pb-item",children:i.jsx(YOe,{card:T.get(y.id),now:t,selected:(s==null?void 0:s.has(y.id))??!1,onOpen:o})},y.id))})}function YOe({card:e,now:t,selected:n,onOpen:a}){const{row:s,group:o,status:r}=e,c=b5(s,o),{model:l,time:u}=$Oe(s,o,t),h=[l,u&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"vis-hidden",children:[u.spoken," "]}),u.text]}),s.twin&&i.jsx("span",{className:"pb-start",children:Nu(s.startedAt,s.twin)})].filter(Boolean);return i.jsxs("button",{type:"button",className:`pb-card${n?" selected":""}`,"data-session":s.sessionId,"data-tone":r.tone,"aria-current":n?"true":void 0,onClick:()=>a(s.sessionId),children:[i.jsxs("span",{className:"pb-head",children:[r.mark==="alert"?i.jsx(ic,{}):i.jsx(yi,{kind:r.mark}),i.jsx("span",{className:"pb-name",children:s.label}),i.jsx("span",{className:"pb-state",children:r.word})]}),c&&i.jsx("span",{className:`pb-line${c.kind==="tool"?" mono":""}`,children:c.kind==="tool"?i.jsxs(i.Fragment,{children:[i.jsx("b",{className:"pb-tool",children:c.name}),c.rest?` · ${c.rest}`:""]}):c.text}),h.length>0&&i.jsx("span",{className:"pb-meta",children:h.map((p,f)=>i.jsxs(m.Fragment,{children:[f>0?" · ":"",p]},f))}),i.jsx("span",{className:"vis-hidden",children:v5(s)})]})}const ZOe=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function XOe(e){var n,a;const t=e.target;!(t!=null&&t.closest)||t.closest(ZOe)!==e.currentTarget||(e.preventDefault(),(a=(n=document.activeElement)==null?void 0:n.blur)==null||a.call(n))}function QOe({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:a}){const s=se(),o=sa();return i.jsx("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:i.jsxs("span",{className:"drag-trash-copy",children:[i.jsx("span",{className:"drag-trash-text",children:t==="over"?i.jsxs(i.Fragment,{children:[s("board.trash.release")," ",i.jsx("strong",{className:"drag-trash-name",children:a||s("board.trash.thisCard")})]}):s("board.trash.drop")}),i.jsx("span",{className:"drag-trash-hint",children:t==="over"?s("board.trash.bringsBack",{list:bo(s("board.detail.listUpper"),"L",o)}):s("board.trash.keepsRunning")})]})})}function eMe({canvasRef:e,bubbling:t,dragging:n,trash:a,zoom:s,viewport:o,stateRef:r,peek:c,stagePhase:l,joins:u,closing:h,children:p}){const{trashDragging:f,trashState:b,trashPhase:v,trashZoneRef:w,trashLabel:T}=a,{lod:y,lodRef:x}=s,{markCanvasInput:C}=o,{peekAgent:A,peekLabel:E,peekPeers:R,peekRecap:z,peekBounds:I}=c,_=Tg();return i.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${h?" closing":""}${n?" dragging-any":""}${f&&b==="over"?" trash-hover":""}`,"data-lod":y,"data-live":u?"":void 0,"data-stage":l,"data-empty":_?"":void 0,ref:e,onMouseDownCapture:XOe,onPointerDownCapture:C,onPointerUpCapture:C,onWheelCapture:C,onFocusCapture:D=>{const L=D.target;if(!Zv(L)||x.current==null||x.current==="detail")return;const P=L.getAttribute("data-id");P&&r.current.agents.has(P)&&L.matches(":focus-visible")&&bz(P,L,"focus")},onBlurCapture:D=>{var P,O;const L=(O=(P=D.target).getAttribute)==null?void 0:O.call(P,"data-id");L&&Zs(L)},children:[p,no(v)&&i.jsx(QOe,{trashZoneRef:w,trashState:b,trashPhase:v,trashLabel:T}),i.jsx(Vze,{agentFor:A,recapFor:z,labelFor:E,peers:R,bounds:I})]})}function Fs(...e){const t=e.filter(n=>typeof n=="string"&&n.length>0);return t.length===0?"":t.reduce((n,a)=>S("board.stage.twoSentences",{first:n,second:a}))}const tMe="shell.banner.unreachableTitle",nMe="shell.banner.unreachableSub";function aMe(e,t=Date.now()){const n=new Date(e),a=Me(),s=n.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"});return n.toDateString()===new Date(t).toDateString()?s:`${n.toLocaleDateString(a,{month:"short",day:"numeric"})} ${s}`}function sMe(e,t=Date.now()){return e==null?S(nMe):S("shell.banner.unreachableSubAt",{time:aMe(e,t)})}function $8({lastNewsAt:e}){const t=se();return i.jsxs("div",{className:"conn-banner conn-banner-phone",role:"alert",children:[i.jsx("span",{className:"conn-unreachable",children:i.jsx(w6,{})}),i.jsxs("span",{className:"conn-phone-text",children:[i.jsx("span",{className:"conn-phone-title",children:t(tMe)}),i.jsx("span",{className:"conn-phone-sub",children:sMe(e)})]})]})}function iMe({restarting:e,restartMode:t,live:n,paused:a,phone:s=!1,lastNewsAt:o=null}){const r=se();return s&&!e?i.jsx($8,{lastNewsAt:o}):i.jsxs("div",{className:"conn-banner",role:"alert",children:[e?i.jsx(Ol,{glyph:"info",tone:"info"}):i.jsx(Ol,{glyph:"unreachable",tone:"err"}),e?t==="npx"?r("shell.banner.fetchingNpx"):r("shell.banner.restartingProduct",{product:an}):(()=>{const c=kOe({connected:n,paused:a});return c?Fs(r("shell.banner.lostShort"),c):r("shell.banner.lost",{product:an})})()]})}function oMe({oldName:e,version:t,dismissOldName:n}){const a=se();return i.jsxs("div",{className:"ver-banner",role:"status",children:[i.jsx(Ol,{glyph:"info",tone:"info"}),i.jsx("strong",{children:Fs(a("shell.banner.oldName",{old:e,product:an}),t==null?void 0:t.renameFix)}),i.jsx("button",{type:"button","aria-label":a("shell.dismiss"),className:"ver-close",onClick:n,children:i.jsx(Ze,{name:"close"})})]})}const pE=()=>S("shell.rating.thanks"),rMe=Array.from({length:11},(e,t)=>t);function cMe(e){return e===0?S("shell.rating.score0"):e===10?S("shell.rating.score10"):S("shell.rating.score",{n:e})}const lMe=6;function dMe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function uMe({phase:e,score:t,onAnswer:n,onLater:a,onClose:s,onFeedback:o,onHold:r}){se();const c=m.useRef(null),l=m.useRef(null),u=m.useRef(null),h=m.useRef(!1);m.useEffect(()=>{var f,b;e!=="thanks"||!h.current||(h.current=!1,fa(((f=document.activeElement)==null?void 0:f.tagName)??null)&&((b=l.current??u.current)==null||b.focus()))},[e]);const p=f=>{var b;(b=c.current)!=null&&b.contains(document.activeElement)&&dMe(),f()};if(e==="thanks"){const f=t!==null&&t<=lMe;return i.jsxs("div",{ref:c,className:"ver-banner rating-banner",onFocus:()=>r(!0),onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||r(!1)},children:[i.jsx(Ol,{glyph:"done",tone:"ok"}),i.jsx("strong",{children:f?Fs(pE(),S("shell.rating.better")):pE()}),f?i.jsx("button",{ref:l,type:"button",className:"ver-act",onClick:o,"aria-label":S("shell.rating.better"),children:S("shell.rating.tellUs")}):null,i.jsx("button",{ref:u,type:"button","aria-label":S("shell.dismiss"),className:"ver-close",onClick:()=>p(s),children:i.jsx(Ze,{name:"close"})})]})}return i.jsxs("div",{ref:c,className:"ver-banner rating-banner rating-ask",role:"group","aria-labelledby":"rating-question",children:[i.jsx("strong",{id:"rating-question",children:S("shell.rating.question")}),i.jsx("span",{className:"rating-scale",children:rMe.map(f=>i.jsx("button",{type:"button",className:f===10?"rating-pick ten":"rating-pick","aria-label":cMe(f),onClick:b=>{h.current=b.detail===0||b.currentTarget.matches(":focus-visible"),n(f)},children:f},f))}),i.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:S("shell.rating.ends")}),i.jsx("button",{type:"button",className:"rating-later",onClick:()=>p(a),children:S("shell.rating.later")})]})}const hMe=".app > .banner-strip:has(.ver-banner, .conn-banner > .banner-mark)";function pMe(){let e=null,t=null,n=null;const a=()=>{n==null||n.disconnect(),n=null,t==null||t.style.removeProperty("--rating-h"),e=null,t=null};return{sync(s){var c;if(s===e)return;a();const o=(s==null?void 0:s.closest(".app"))??null;if(!s||!o)return;e=s,t=o;const r=()=>o.style.setProperty("--rating-h",`${Math.ceil(s.getBoundingClientRect().height)}px`);r(),n=typeof ResizeObserver>"u"?null:new ResizeObserver(r),(c=n==null?void 0:n.observe)==null||c.call(n,s)},release:a}}function gMe(){const e=m.useRef(null);e.current||(e.current=pMe()),m.useLayoutEffect(()=>{e.current.sync(document.querySelector(hMe))}),m.useLayoutEffect(()=>()=>{var t;return(t=e.current)==null?void 0:t.release()},[])}function mMe(){return gMe(),null}const fMe=3e4;function bMe({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function kMe({bundle:e,running:t,pending:n,lastTried:a}){return t?bMe({bundle:e,running:t,lastTried:a})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function vMe(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function wMe({asked:e,reported:t}){return t?t!==e:!1}function J8(e){const t=e.thresholdMs??fMe;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function yMe(e){return S("shell.banner.restartingIn",{seconds:Math.max(0,Math.ceil(e/1e3))})}function hW(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function xMe(e,t=!1){return e<=0&&t?{label:S("shell.banner.restartAnyway"),clause:S("shell.banner.clausePaused"),risky:!0}:e<=0?{label:S("shell.banner.restartNow"),clause:S("shell.banner.clauseIdle"),risky:!1}:{label:S("shell.banner.restartAnyway"),clause:S("shell.banner.clauseAgents",{count:e}),risky:!0}}function CMe(e){const t=J8(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}const SMe={get git_checkout(){return S("shell.banner.block.git_checkout")},get npx(){return S("shell.banner.block.npx")},get one_off(){return S("shell.banner.block.one_off")},get not_writable(){return S("shell.banner.block.not_writable")},get opted_out(){return S("shell.banner.block.opted_out")},get retired_name(){return S("shell.banner.block.retired_name")}},pW={get git_checkout(){return S("shell.banner.blockSentence.git_checkout")},get npx(){return S("shell.banner.blockSentence.npx")},get one_off(){return S("shell.banner.blockSentence.one_off")},get not_writable(){return S("shell.banner.blockSentence.not_writable")},get opted_out(){return S("shell.banner.blockSentence.opted_out")},get retired_name(){return S("shell.banner.blockSentence.retired_name")}};function TMe({notice:e,version:t,dismissNotice:n,upgradeState:a,startUpgrade:s,copyCommand:o,cmdCopied:r,askRestart:c,restartCopy:l,restartFuseMs:u,restarting:h}){var I,_;const p=se(),f=e.kind!=="restart",b=f&&a==="failed",v=f&&(t==null?void 0:t.upgradeMode)==="npx",w=f&&(t==null?void 0:t.upgradeMode)==="install"&&!b,T=f&&!w?t==null?void 0:t.command:void 0,y=e.kind==="restart"&&(t==null?void 0:t.canRestart)===!0&&l.risky,x=p("shell.banner.failedLine",{what:(t==null?void 0:t.upgradeMode)==="npx"?p("shell.banner.updateFailed"):p("shell.banner.installFailed"),error:((I=t==null?void 0:t.upgrade)==null?void 0:I.error)??p("shell.banner.unknownError")}),C=p("shell.banner.isOutShort",{product:an,to:e.to});let A,E=null;if(e.kind==="restart"){const D=p("shell.banner.isInstalled",{to:e.to}),L=p("shell.banner.installedStale",{to:e.to,from:e.from});if(!(t!=null&&t.canRestart))A=Fs(L,p("shell.banner.restartNeeded"));else if(h)A=L;else if(u!=null){const P=Fs(D,y&&l.clause);A=Fs(P,p("shell.banner.restartingWhenIdle")),E=Fs(P,yMe(u))}else y?A=Fs(D,l.clause):A=Fs(L,l.clause)}else if(b)A=x;else if(v)A=Fs(C,t!=null&&t.canRestart?p("shell.banner.npxRerun"):pW.npx);else if(t!=null&&t.upgradeBlocked){const D=On(pW,t.upgradeBlocked)??p("shell.banner.cannotInstall");A=t.upgradeBlocked==="git_checkout"?D:Fs(C,D)}else A=p("shell.banner.isOut",{product:an,to:e.to,from:e.from});const R=()=>{var D;(D=window.getSelection())!=null&&D.toString()||o()},z=i.jsxs(i.Fragment,{children:[i.jsx(Ol,{glyph:b?"unreachable":y?"warning":"info",tone:b?"err":y?"warn":"info",armed:u!=null}),E!=null?i.jsxs("strong",{children:[i.jsx("span",{"aria-hidden":"true",children:E}),i.jsx("span",{className:"vis-hidden",children:A})]}):i.jsx("strong",{title:b?A:void 0,children:A}),e.kind==="restart"&&(t==null?void 0:t.canRestart)&&i.jsx("button",{type:"button",className:"ver-act",onClick:()=>c(),...gs(h),title:p("shell.banner.restartTitle"),children:h?p("shell.banner.restarting"):l.label}),w&&i.jsx("button",{type:"button",className:"ver-act",onClick:s,...gs(a==="running",a==="done"),title:p("shell.banner.installTitle",{command:((_=t==null?void 0:t.upgrade)==null?void 0:_.command)??(t==null?void 0:t.command)??"npm i -g"}),children:p(a==="running"?"shell.banner.installing":a==="done"?"shell.banner.installed":"shell.update.now")}),v&&(t==null?void 0:t.canRestart)&&i.jsx("button",{type:"button",className:"ver-act",onClick:()=>c({upgrade:!0}),...gs(h),title:p("shell.banner.npxTitle",{command:(t==null?void 0:t.command)??""}),children:p(h?"shell.banner.fetching":a==="failed"?"shell.update.retry":"shell.update.andRestart")}),i.jsx("button",{type:"button","aria-label":p("shell.dismiss"),className:"ver-close",onClick:n,children:i.jsx(Ze,{name:"close"})})]});return T?i.jsxs("div",{className:`ver-banner ver-stack ${e.kind}`,role:"status",children:[i.jsx("div",{className:"ver-row",children:z}),i.jsx("div",{className:"ver-cmdrow",children:i.jsxs("div",{className:"ver-cmd",onClick:R,title:p("shell.banner.copyTitle"),children:[i.jsx("code",{children:T}),i.jsx("button",{type:"button",className:"ver-copy","aria-label":p("shell.banner.copyTitle"),children:r?i.jsx(Ys,{name:"done"}):i.jsx(Ze,{name:"copy"})}),i.jsx("span",{className:"vis-hidden",children:r?p("shell.banner.copiedHint"):""})]})})]}):i.jsx("div",{className:`ver-banner ${e.kind}`,role:"status",children:z})}function NMe({children:e}){const t=m.useRef(null),n=e!=null;n&&(t.current=e);const[a,s]=m.useState(()=>V4(n)),o=K4(a,n,{instant:!1,hasContent:t.current!=null});o!==a&&s(o);const r=o.closing,c=m.useCallback(()=>s($4),[]);if(m.useEffect(()=>{if(!r)return;const h=window.setTimeout(c,zn("--dur-exit")+Y4);return()=>window.clearTimeout(h)},[r,c]),!J4(o))return t.current=null,null;const l=h=>{r&&h.target===h.currentTarget&&h.propertyName==="opacity"&&c()},u=r?{inert:""}:{};return i.jsx("div",{className:"banner-strip","data-open":r?void 0:"",...u,onTransitionEnd:l,children:i.jsx("div",{className:"banner-strip-in",children:n?e:t.current})})}function AMe({restart:e,versionCheck:t,upgrade:n,oldNameNotice:a,rating:s,onFeedback:o,everConnected:r,live:c,paused:l,phone:u=!1,lastNewsAt:h=null,cardInList:p=!1}){const f=se(),{restarting:b,restartMode:v,restartedTo:w,dismissRestarted:T,askRestart:y,restartCopy:x,restartFuseMs:C}=e,{version:A,notice:E,noticeOpen:R,dismissNotice:z}=t,{upgradeState:I,startUpgrade:_,copyCommand:D,cmdCopied:L}=n,{oldName:P,oldNameOpen:O,dismissOldName:j}=a,{ratingPhase:M,ratingScore:F,answerRating:U,rateLater:H,closeRating:$,holdThanks:Y}=s,W=w?i.jsxs("div",{className:"ver-banner done",role:"status",children:[i.jsx(Ol,{glyph:"done",tone:"ok"}),i.jsx("strong",{children:Fs(f("shell.banner.restartedTo",{version:w}),f("shell.banner.replayed"))}),i.jsx("button",{type:"button","aria-label":f("shell.dismiss"),className:"ver-close",onClick:T,children:i.jsx(Ze,{name:"close"})})]}):r&&!c?u&&p&&!b?null:i.jsx(iMe,{restarting:b,restartMode:v,live:c,paused:l,phone:u,lastNewsAt:h}):R&&E?i.jsx(TMe,{notice:E,version:A,dismissNotice:z,upgradeState:I,startUpgrade:_,copyCommand:D,cmdCopied:L,askRestart:y,restartCopy:x,restartFuseMs:C,restarting:b}):O&&P?i.jsx(oMe,{oldName:P,version:A,dismissOldName:j}):M!=="hidden"?i.jsx(uMe,{phase:M,score:F,onAnswer:U,onLater:H,onClose:$,onFeedback:o,onHold:Y}):null;return i.jsxs(i.Fragment,{children:[i.jsx(NMe,{children:W}),i.jsx(mMe,{}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?pE():""})]})}const jMe=.11,EMe=12,RMe=8,zMe=.4,qMe=44,au=["accounts","usage","machine","inspector"],_Me=()=>zn("--dur-stage-in"),Gp=()=>zn("--dur-stage-out"),LMe=()=>zn("--dur-base"),Y8=()=>fo("--ease-stage");function PMe(e,t,n,a){return e>=EMe&&a>0&&n/a>jMe?!0:t>0&&e>zMe*t}function OMe(e){return Math.abs(e)>=RMe}function $A(e){if(e>=0)return e;const t=-e;return-(t*24)/(t+24)}function Z8(e){const t=au.filter(n=>e[n]);return t.length>0?t[t.length-1]:null}function gW(e,t){const n=au.filter(s=>t[s]);if(n.length===0)return null;const a=n.filter(s=>!e[s]);return a.length>0?a[a.length-1]:Z8(t)}function MMe(e){return e.phone&&e.accountsOpen&&!e.accountsWasOpen&&e.paneOpen}function mW(e){if(e.sheet==null){e.toggleList();return}e.closeSheet(),e.listOpen||e.toggleList()}const IMe={accounts:".accounts-panel:not([hidden]):not(.leaving)",usage:".usage-panel:not(.leaving)",machine:".sysdetail:not(.leaving)",inspector:".app > .right-col > .detail:not(.leaving)"},DMe="button, a, input, select, textarea, label, summary, [role='button'], [role='tab'], [role='switch'], [role='menuitem']",FMe=".anchored-popover, .modal-backdrop, [role='dialog'], [role='alertdialog']",BMe=".topbar, .left-column, main, .stage-dock, .ver-banner, .conn-banner, .skip-link",UMe=12,WMe={accounts:!1,usage:!1,machine:!1,inspector:!1};function fW(e,t=document){return t.querySelector(IMe[e])}function Rz(e){e.style.transform="",e.style.transition="",e.removeAttribute("data-sheet-dragging")}function HMe(e,t){return Rz(e),typeof e.animate!="function"||Ya()?null:e.animate([{transform:`translateY(${t}px)`},{transform:"translateY(100%)"}],{duration:Gp(),easing:Y8(),fill:"forwards"})}function GMe(e,t){Rz(e),!(typeof e.animate!="function"||Ya()||t===0)&&e.animate([{transform:`translateY(${t}px)`},{transform:"translateY(0)"}],{duration:_Me(),easing:Y8()})}function VMe({phone:e,open:t,close:n,openers:a,modalOpenRef:s,onLeavePhone:o,hold:r,home:c}){const l=m.useRef(WMe),u=m.useRef(n);u.current=n;const h=m.useRef(a);h.current=a;const p=m.useRef(o);p.current=o;const f=m.useRef(r);f.current=r;const b=m.useRef(c);b.current=c;const v=m.useRef(e),w=m.useRef(null),T=m.useRef({}),y=e?gW(l.current,t):null,x=au.map(D=>t[D]).join();m.useLayoutEffect(()=>{var L,P,O,j;const D=v.current!==e;v.current=e;for(const M of au)t[M]!==l.current[M]&&(w.current===M&&(w.current=null),t[M]&&((L=T.current[M])==null||L.cancel(),delete T.current[M]));if(D){if(e){const M=Z8(t);for(const F of au)t[F]&&F!==M&&((O=(P=f.current)==null?void 0:P[F])==null||O.call(P))}l.current={...t},e||(j=p.current)==null||j.call(p);return}if(e){const M=gW(l.current,t);for(const F of au)t[F]&&F!==M&&u.current[F]()}l.current={...t}},[e,x]);const C=y,A=m.useRef(C);A.current=C;const E=m.useCallback(D=>{const L=D??A.current;!L||w.current===L||(w.current=L,window.setTimeout(()=>{w.current===L&&(w.current=null)},Gp()+200),u.current[L]())},[]),R=m.useRef(()=>{});R.current=()=>{s!=null&&s.current||document.querySelector(FMe)||E()},m.useEffect(()=>{if(!e||!C)return;const D=Rn.push(()=>R.current(),0,"popover");return()=>{window.setTimeout(D,Gp()+50)}},[e,C]),m.useEffect(()=>{if(!e||!C)return;const D=[],L=()=>{for(const j of Array.from(document.querySelectorAll(BMe)))j.hasAttribute("inert")||(j.setAttribute("inert",""),D.push(j))};L();const P=document.querySelector(".app"),O=P&&typeof MutationObserver=="function"?new MutationObserver(L):null;return P&&(O==null||O.observe(P,{childList:!0})),()=>{O==null||O.disconnect();for(const j of D)j.removeAttribute("inert")}},[e,C]);const z=m.useRef(null),I=m.useRef(null),_=m.useRef(null);return m.useEffect(()=>{var L,P,O;const D=z.current;if(z.current=e?C:null,e&&C&&C!==D){const j=document.activeElement,M=I.current!=null&&j!=null&&I.current.contains(j);_.current=j&&j!==document.body&&!M?j:_.current;let F=0,U=0;const H=()=>{const $=fW(C);if(!$){++F<UMe&&(U=window.requestAnimationFrame(H));return}I.current&&I.current!==$&&I.current.removeAttribute("tabindex"),I.current=$,$.tabIndex=-1,$.focus({preventScroll:!0})};return H(),()=>{U&&window.cancelAnimationFrame(U)}}if(D&&!(e&&C)){const j=I.current;if(I.current=null,j==null||j.removeAttribute("tabindex"),!e)return;const M=document.activeElement;if(!(!M||M===document.body||!M.isConnected||j!=null&&j.contains(M)))return;const U=((P=(L=h.current)==null?void 0:L[D])==null?void 0:P.call(L))??_.current,H=U&&U.isConnected?U:((O=b.current)==null?void 0:O.call(b))??null;H&&H.isConnected&&H.focus({preventScroll:!0})}},[e,C]),m.useEffect(()=>{if(!e)return;let D=null;const L=j=>{const M=A.current;if(!M||D||j.pointerType==="mouse"&&j.button!==0)return;const F=fW(M),U=j.target;if(!F||!U||!F.contains(U))return;const H=F.getBoundingClientRect();j.clientY-H.top>qMe||U.closest(DMe)||(D={id:j.pointerId,el:F,name:M,y0:j.clientY,height:H.height,engaged:!1,dy:0,base:0,samples:[[j.timeStamp,j.clientY]]})},P=j=>{if(!D||j.pointerId!==D.id)return;const M=j.clientY-D.y0;if(D.samples.push([j.timeStamp,j.clientY]),D.samples.length>6&&D.samples.shift(),!D.engaged){if(!OMe(M))return;D.engaged=!0,D.base=$A(M);try{D.el.setPointerCapture(j.pointerId)}catch{}}D.dy=M,D.el.setAttribute("data-sheet-dragging",""),D.el.style.transition="none",D.el.style.transform=`translateY(${$A(M)-D.base}px)`,j.preventDefault()},O=j=>{var G;if(!D||j.pointerId!==D.id)return;const M=D;if(D=null,!M.engaged)return;try{M.el.releasePointerCapture(j.pointerId)}catch{}const F=M.samples[M.samples.length-1],U=M.samples.find(([Q])=>j.timeStamp-Q<=100),H=U&&U!==F?U:M.samples[Math.max(0,M.samples.length-2)],$=F[0]-H[0],Y=F[1]-H[1],W=$A(M.dy)-M.base;if(j.type==="pointerup"&&PMe(M.dy,M.height,Y,$)){const Q=HMe(M.el,W);Q&&((G=T.current[M.name])==null||G.cancel(),T.current[M.name]=Q,window.setTimeout(()=>{Q.cancel(),T.current[M.name]===Q&&delete T.current[M.name]},Gp()+200)),E(M.name)}else GMe(M.el,W)};return document.addEventListener("pointerdown",L),document.addEventListener("pointermove",P,{passive:!1}),document.addEventListener("pointerup",O),document.addEventListener("pointercancel",O),()=>{if(document.removeEventListener("pointerdown",L),document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",O),document.removeEventListener("pointercancel",O),D){try{D.el.releasePointerCapture(D.id)}catch{}Rz(D.el)}}},[e,E]),{sheet:C,closeSheet:E}}function KMe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function $Me(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 JMe(e,t){return e<=0?null:t("board.clear.goes.agents",{count:e})}function YMe(e,t,n=S){const a=JMe(e,n),s=(...l)=>[a,...l,n("board.clear.goes.view")].filter(u=>u!==null),o=n("board.clear.final"),r=n("board.clear.confirmAll");if(!t)return{goes:s(n("board.clear.goes.logUnknown")),stays:[],final:o,confirm:r};if(!t.path)return{goes:s(),stays:[],final:n("board.clear.final.noLog",{final:o}),confirm:r};if(!t.mine){const l=t.ownerPort===null?n("board.clear.owner.other"):n("board.clear.owner.port",{port:t.ownerPort}),u=t.decks>2?n("board.clear.owner.shared",{decks:t.decks}):"";return{goes:s(),stays:[n("board.clear.stays.log",{owner:l,shared:u}),n("board.clear.stays.replay")],final:null,confirm:n("board.clear.confirmCanvas")}}if(t.decks<=1)return{goes:s(n("board.clear.goes.logOwn")),stays:[],final:o,confirm:r};const c=t.decks-1;return{goes:s(n("board.clear.goes.logShared",{count:c})),stays:[n("board.clear.stays.shared",{count:c})],final:o,confirm:r}}function ZMe({agentCount:e,onConfirm:t,onCancel:n}){const a=se(),s=m.useRef(null),o=Zt(n,{focusRef:s,layer:ole}),r=tn(n),[c,l]=m.useState(null);m.useEffect(()=>{let b=!1;return fetch("/api/clear").then(v=>v.ok?v.json():null).then(v=>{b||l($Me(v))}).catch(()=>{}),()=>{b=!0}},[]);const{goes:u,stays:h,final:p,confirm:f}=YMe(e,c,a);return i.jsxs(dn,{scrim:r,dialogRef:o,className:"clear-confirm",labelledBy:"clear-confirm-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:a("board.clear.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:n,label:a("board.clear.cancelEsc")})})]}),i.jsxs("section",{className:"modal-body cc-body",children:[i.jsxs("dl",{className:"cc-plan",children:[i.jsxs("div",{className:"cc-col",children:[i.jsx("dt",{children:a("board.clear.goes")}),i.jsx("dd",{children:u.map(b=>i.jsx("span",{children:b},b))})]}),i.jsxs("div",{className:"cc-col",children:[i.jsx("dt",{children:a("board.clear.stays")}),i.jsx("dd",{children:h.length>0?h.map(b=>i.jsx("span",{children:b},b)):i.jsx("span",{className:"cc-none",children:a("board.clear.nothing")})})]})]}),p&&i.jsx("p",{className:"cc-final",children:p})]}),i.jsxs("footer",{className:"modal-foot",children:[i.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:a("board.clear.cancel")}),i.jsx("button",{type:"button",className:"btn danger",onClick:t,children:f})]})]})}function XMe({kind:e,onChange:t}){const n=se();return i.jsxs("fieldset",{className:"fb-kinds",children:[i.jsx("legend",{className:"vis-hidden",children:n("shell.feedback.kinds")}),Tk.map(a=>i.jsxs("label",{className:"fb-kind",children:[i.jsx("input",{type:"radio",name:"feedback-kind",value:a.value,checked:e===a.value,onChange:()=>t(a.value),onKeyDown:s=>{Nz(s.nativeEvent)&&s.preventDefault()}}),a.label]},a.value))]})}const X8="fb-details";function QMe({open:e,onToggle:t}){return se(),i.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":X8,onClick:t,children:[i.jsx("svg",{className:"fb-chev",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"M5.25 3.5 8.75 7l-3.5 3.5"})}),iPe()]})}function eIe({open:e,contact:t,onContact:n,account:a=!1,mail:s=!0}){const o=se(),r=m.useId();return i.jsx("div",{id:X8,className:"fb-details","data-open":e||void 0,children:i.jsx("div",{className:"fb-details-clip",children:i.jsxs("div",{className:"fb-details-body",children:[!a&&i.jsxs("div",{className:"fb-field",children:[i.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[oPe(),i.jsx("span",{className:"fb-optional",children:o("shell.feedback.optional")})]}),i.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:j8,autoComplete:"email",placeholder:rPe(),"aria-describedby":r,onChange:c=>n(c.target.value),onKeyDown:c=>{Nz(c.nativeEvent)&&c.preventDefault()}}),i.jsx("p",{id:r,className:"fb-hint",children:cPe()})]}),a?i.jsx("div",{className:"fb-where",children:bPe(s).map(c=>i.jsx("p",{children:c},c))}):i.jsx("div",{className:"fb-where",children:lPe().map(c=>i.jsx("p",{children:c},c))})]})})})}const cl=3,tIe=5*1024*1024,nIe=12*1024*1024,gE=8192,aIe=64*1024,sIe=256*1024,iIe=.92,oIe=640,Q8=.9,rIe=.85,cIe=6,lIe=512*1024,zk={png:"image/png",jpeg:"image/jpeg"},dIe={png:"png",jpeg:"jpg"},uIe=[137,80,78,71,13,10,26,10],hIe=[255,216,255];function e7(e){const t=n=>e.length>=n.length&&n.every((a,s)=>e[s]===a);return t(uIe)?"png":t(hIe)?"jpeg":null}function pIe(e){const t=e7(e);return t==="png"?gIe(e):t==="jpeg"?fIe(e):null}function gIe(e){const t=[73,72,68,82];if(e.length<24||!t.every((a,s)=>e[12+s]===a))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function mIe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function fIe(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const a=e[t]<<8|e[t+1];if(a<2)return null;if(mIe(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=a}return null}function bW(e,t){return e.bytes>t||e.width>gE||e.height>gE}function bIe(e){return Math.min(tIe,nIe-aIe-e)}function t7(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function kIe(e,t){const n=gE/Math.max(e.width,e.height),a=e.bytes>t?Math.sqrt(t/e.bytes)*Q8:1;return t7(e,Math.min(1,n,a))}async function vIe(e,t,n){let a=kIe(e,t),s=e.format;for(let o=0;o<cIe;o++){const r=await n(a,s,s==="jpeg"?iIe:void 0);if(!r)return null;if(r.size<=t)return{...a,blob:r,format:s};if(s==="png"){s="jpeg";continue}if(a=t7(a,Math.min(rIe,Math.sqrt(t/r.size)*Q8)),Math.max(a.width,a.height)<oIe)return null}return null}async function wIe(e,t,n){const a=new Uint8Array(await e.slice(0,lIe).arrayBuffer()),s=e7(a);if(!s)return{ok:!1,problem:"type"};if(t<sIe)return{ok:!1,problem:"no_room"};const o=e.type===zk[s]?e:new Blob([e],{type:zk[s]}),r=pIe(a);if(r&&!bW({...r,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const l={width:c.width,height:c.height,bytes:e.size,format:s};if(!bW(l,t))return{ok:!0,blob:o,resized:null};const u=await vIe(l,t,c.encoder);return u?{ok:!0,blob:u.blob,resized:{width:u.width,height:u.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function yIe(e){return({width:t,height:n},a,s)=>new Promise(o=>{const r=document.createElement("canvas");r.width=t,r.height=n;const c=r.getContext("2d");if(!c)return o(null);a==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),r.toBlob(l=>{r.width=0,r.height=0,o(l)},zk[a],s)})}const xIe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:yIe(t),release:()=>t.close()}};function CIe(e){return e.includes("Files")}function SIe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function TIe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function kW(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((a,s)=>{const o=a.type===zk.jpeg?"jpeg":"png";n.append("images",a,`image-${s+1}.${dIe[o]}`)}),{method:"POST",body:n}}const NIe=()=>S("shell.feedback.addShot"),vW=()=>S("shell.feedback.addHint"),AIe=()=>S("shell.feedback.shotsNote"),wW=()=>S("shell.feedback.full"),jIe=()=>S("shell.feedback.refusedWhileSending");function EIe(e,t,n){const a=n?S("shell.feedback.resized",{width:n.width,height:n.height}):"";return S("shell.feedback.replaceLabel",{n:e+1,name:t,fit:a})}function RIe(e,t){const n=S("shell.feedback.shotsCount",{count:e,max:cl});return t>0?S("shell.feedback.shotsResized",{of:n,resized:t}):n}function zIe(e){return S("shell.feedback.leftOut",{count:e})}function qIe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function _Ie(e,t){const n=qIe(t);return e==="type"?S("shell.feedback.problem.type",{file:n}):e==="no_room"?S("shell.feedback.problem.noRoom",{file:n}):e==="unreadable"?S("shell.feedback.problem.unreadable",{file:n}):S("shell.feedback.problem.tooLarge",{file:n})}const n7="image/png,image/jpeg";function a7({className:e="fb-glyph"}){return i.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),i.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),i.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function LIe({images:e,buttonRef:t}){se();const n=m.useRef(null),a=e.shots.length>=cl;return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:vW(),"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return a?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[i.jsx(a7,{}),NIe()]}),i.jsx("span",{id:"fb-attach-hint",hidden:!0,children:vW()}),i.jsx("input",{ref:n,type:"file",accept:n7,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function PIe({images:e,addRef:t}){const n=se(),a=m.useRef(new Map),s=m.useRef(null),o=m.useRef(null),r=m.useRef(null),[c,l]=m.useState(null),{shots:u}=e,h=RIe(u.length,u.filter(b=>b.resized).length);m.useLayoutEffect(()=>{var b;c!==null&&((b=c==="add"?t.current:a.current.get(c))==null||b.focus(),l(null))},[c,t]),m.useEffect(()=>{var b;e.problem&&((b=s.current)==null||b.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function p(b){l(TIe(u.map(v=>v.id),b)??"add"),e.remove(b)}function f(b){var v;r.current=b,(v=o.current)==null||v.click()}return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),i.jsx("input",{ref:o,type:"file",accept:n7,hidden:!0,onChange:b=>{const v=r.current;v!==null&&e.replace(v,Array.from(b.target.files??[])),r.current=null,b.target.value=""}}),u.length>0&&i.jsxs("div",{className:"fb-shots",children:[i.jsxs("div",{className:"fb-shots-row",children:[i.jsx("ul",{className:"fb-shots-list",children:u.map((b,v)=>i.jsxs("li",{className:"fb-shot","data-fitting":b.blob?void 0:!0,children:[i.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":EIe(v,b.name,b.resized),onClick:()=>f(b.id),children:[i.jsx("img",{className:"fb-shot-img",src:b.url,alt:""}),b.blob?i.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:n("shell.feedback.replace")}):i.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:n("shell.feedback.resizing")})]}),i.jsx("button",{ref:w=>{w?a.current.set(b.id,w):a.current.delete(b.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":n("shell.feedback.removeImage",{n:v+1}),title:n("shell.feedback.removeImage",{n:v+1}),onClick:()=>p(b.id),children:i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},b.id))}),i.jsx("span",{className:"fb-shots-count",children:h})]}),i.jsx("p",{className:"fb-hint",children:AIe()})]}),e.problem&&i.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}const JA=["write","conversations"],OIe="shell.feedback.didNotLoad";function s7(){const e=se();return i.jsxs("div",{className:"fc-missing",children:[i.jsx("p",{className:"fc-note",children:e(OIe)}),i.jsx("button",{type:"button",className:"btn",onClick:()=>window.location.reload(),children:e("shell.reload")})]})}const MIe=m.lazy(()=>Xs(()=>import("./FeedbackConversations-BDjrxpxf.js"),__vite__mapDeps([4,5])).catch(e=>(console.warn("ccdeck could not load your conversations",e),{default:s7})));class IIe extends m.Component{constructor(){super(...arguments);Ss(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n,a){console.error("ccdeck could not draw your conversations",n,a.componentStack)}render(){return this.state.failed?i.jsx(s7,{}):this.props.children}}function DIe(e){return i.jsx(IIe,{children:i.jsx(m.Suspense,{fallback:null,children:i.jsx(MIe,{...e})})})}function FIe(e){return e>0?S("shell.feedback.tabConversationsUnread",{count:e}):void 0}function BIe({tab:e,onTab:t,unread:n,conversationsTabRef:a,write:s,conversations:o}){const r=m.useRef(null),c=m.useRef(null),l=se(),u=a??c,h=[r,u];return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"fc-tabs",role:"tablist","aria-label":l("shell.feedback.tabs"),onKeyDown:p=>{var b;const f=Fu(p.nativeEvent,JA.indexOf(e),JA.length);f.kind==="select"&&(p.preventDefault(),t(JA[f.index]),(b=h[f.index].current)==null||b.focus())},children:[i.jsx("button",{ref:r,type:"button",id:"fc-tab-write",className:"fc-tab",role:"tab","aria-selected":e==="write","aria-controls":"fc-panel-write",tabIndex:e==="write"?0:-1,onClick:()=>t("write"),children:l(uPe)}),i.jsxs("button",{ref:u,type:"button",id:"fc-tab-conversations",className:"fc-tab",role:"tab","aria-selected":e==="conversations","aria-controls":"fc-panel-conversations",tabIndex:e==="conversations"?0:-1,"aria-label":FIe(n),onClick:()=>t("conversations"),children:[l(hPe),n>0&&i.jsx("span",{className:"fc-tab-count","aria-hidden":"true",children:n})]})]}),i.jsx("div",{className:"fc-panel",id:"fc-panel-write",role:"tabpanel","aria-labelledby":"fc-tab-write",hidden:e!=="write",children:s}),i.jsx("div",{className:"fc-panel",id:"fc-panel-conversations",role:"tabpanel","aria-labelledby":"fc-tab-conversations",hidden:e!=="conversations",children:o})]})}function UIe(e,t){return e.map((n,a)=>({id:t+a,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function WIe(e,t,n){return n?e.map(a=>a.id===t.id?t:a):[...e,t]}function HIe(e,t,n){return n?e.map(a=>a.id===t?n:a):e.filter(a=>a.id!==t)}function GIe(e){const[t,n]=m.useState(()=>UIe((e==null?void 0:e.ready)??[],1)),[a,s]=m.useState({problem:"",id:0}),o=m.useRef(0),r=m.useCallback(P=>{P&&o.current++,s(O=>P?{problem:P,id:O.id+1}:O.problem?{problem:"",id:O.id}:O)},[]),[c,l]=m.useState(""),u=m.useRef(t),h=m.useRef(null),p=m.useRef(t.length),f=m.useRef(!0),b=m.useRef(new Map),v=m.useRef([]),w=m.useRef(0),T=m.useCallback(P=>{u.current=P(u.current),n(u.current)},[]);m.useEffect(()=>(f.current=!0,()=>{f.current=!1;for(const P of u.current)URL.revokeObjectURL(P.url)}),[]);const y=m.useCallback(async(P,O)=>{const j=u.current.reduce((Q,J)=>{var X;return Q+(J.id===(O==null?void 0:O.id)?0:((X=J.blob)==null?void 0:X.size)??0)},0),M=(O==null?void 0:O.id)??++p.current,F=URL.createObjectURL(P),U={id:M,name:P.name||"image",url:F,blob:null,resized:null},H=w.current;b.current.set(M,P);let $=!1;const Y=()=>{$||($=!0,T(Q=>WIe(Q,U,O!==void 0)))},W=await wIe(P,bIe(j),async Q=>(Y(),xIe(Q))).catch(()=>({ok:!1,problem:"unreadable"})),G=u.current.some(Q=>Q.id===M);return!f.current||w.current!==H||!G&&($||O)?(URL.revokeObjectURL(F),O&&URL.revokeObjectURL(O.url),f.current&&b.current.delete(M),""):(b.current.delete(M),W.ok?(Y(),O&&URL.revokeObjectURL(O.url),T(Q=>Q.map(J=>J.id===M?{...J,blob:W.blob,resized:W.resized}:J)),""):(URL.revokeObjectURL(F),$&&T(Q=>HIe(Q,M,O)),_Ie(W.problem,P.name||"image")))},[T]),x=m.useCallback(async P=>{r("");const O=w.current,j=[];let M=0,F=0;for(const H of P){if(!f.current||w.current!==O)return;const $=v.current.indexOf(H);if($!==-1&&v.current.splice($,1),u.current.length>=cl){M++;continue}const Y=u.current.length,W=await y(H);W&&j.push(W),u.current.length>Y&&F++}if(!f.current||w.current!==O)return;M>0&&j.push(F===0&&j.length===0?wW():zIe(M)),r(j.join(" "));const U=u.current.length;F>0&&l(S("shell.feedback.imagesAdded",{count:F,total:U,max:cl}))},[y,r]),C=m.useCallback(async(P,O)=>{r("");const j=u.current.find(U=>U.id===P);if(!j)return x([O]);const M=await y(O,j);if(!f.current)return;r(M);const F=u.current.findIndex(U=>U.id===P);!M&&F!==-1&&l(S("shell.feedback.imageReplaced",{n:F+1,total:u.current.length,max:cl}))},[x,y,r]),A=m.useCallback(P=>{const O=w.current;h.current=(h.current??Promise.resolve()).then(()=>w.current===O?P():void 0).catch(()=>{})},[]),E=m.useCallback(P=>{P.length!==0&&(v.current.push(...P),A(()=>x(P)))},[x,A]);m.useEffect(()=>{e&&e.waiting.length>0&&E(e.waiting)},[]);const R=m.useCallback((P,O)=>{const j=O[0];j&&A(()=>C(P,j))},[A,C]),z=m.useCallback(P=>{const O=u.current.find(j=>j.id===P);O&&(URL.revokeObjectURL(O.url),b.current.delete(P),T(j=>j.filter(M=>M.id!==P)),r(""),l(S("shell.feedback.imageRemoved",{count:u.current.length,max:cl})))},[T,r]),I=m.useCallback(()=>r(wW()),[r]),_=m.useCallback(async()=>{const P=o.current;return await h.current,o.current!==P?null:u.current.flatMap(O=>O.blob?[O.blob]:[])},[]),D=m.useCallback(()=>({ready:u.current.flatMap(P=>P.blob&&!b.current.has(P.id)?[{name:P.name,blob:P.blob,resized:P.resized}]:[]),waiting:[...b.current.values(),...v.current]}),[]),L=m.useCallback(()=>{w.current++;for(const P of u.current)URL.revokeObjectURL(P.url);b.current.clear(),v.current=[],T(()=>[]),r("")},[T,r]);return{shots:t,problem:a.problem,problemId:a.id,announcement:c,add:E,replace:R,remove:z,sayFull:I,ready:_,kept:D,clear:L}}function VIe(){const[e,t]=m.useState(null);return m.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(a=>a.ok?a.json():null).then(a=>{n&&t(QLe(a))}).catch(()=>{}),()=>{n=!1}},[]),e}const KIe="/api/account/feedback/threads";function $Ie(e,{asAccount:t=!1}={}){const[n,a]=m.useState({state:"idle"}),[s,o]=m.useState(!1),r=m.useRef(!1),c=m.useRef(null);m.useEffect(()=>()=>{var h;return(h=c.current)==null?void 0:h.abort()},[]);async function l(h){if(!$a(r.current))return;r.current=!0;const{signal:p}=c.current=new AbortController,f=t;o(f),a({state:"sending"});try{const b=await e.ready();if(p.aborted)return;if(!b){a({state:"failed",message:jIe()});return}const v=kW(XU(f?{...h,contact:""}:h),b),w=await fetch(f?KIe:"/api/feedback",{...v,signal:p}),T=await w.json().catch(()=>null),y=w.ok&&(f?(T==null?void 0:T.thread)!=null:T==null?void 0:T.ok);a(y?{state:"sent"}:{state:"failed",message:f?QU(w.status,T):lE(w.status,T==null?void 0:T.reason,T==null?void 0:T.errors)})}catch{p.aborted||a({state:"failed",message:f?QU(0,null):lE(0,null)})}finally{r.current=!1}}const u=()=>a(h=>h.state==="failed"?{state:"idle"}:h);return{outcome:n,sending:n.state==="sending",sentAsAccount:s,send:l,clearFailure:u}}function JIe(e,t){const[n,a]=m.useState(!1),s=m.useRef(t);return s.current=t,m.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>a(!0),eW),r=window.setTimeout(()=>s.current(),eW+jPe);return()=>{window.clearTimeout(o),window.clearTimeout(r)}},[e]),n}const YA="agent-dag.feedbackDrafts",yW=4;function YIe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function ZIe(e){return JSON.stringify([e.kind,e.body])}function XIe(e){return e.ready.length+e.waiting.length}function i7(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function QIe(e){return S("shell.feedback.lost",{count:e})}const eDe=()=>S("shell.feedback.discard"),tDe=()=>S("shell.feedback.discardConfirm"),nDe=()=>S("shell.feedback.discardTitle"),xW=()=>S("shell.feedback.discardArmed"),aDe={ready:[],waiting:[]};function sDe(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:a,contact:s,images:o,anonymous:r}=t;return!Tk.some(c=>c.value===n)||typeof a!="string"||a.length>A8||typeof s!="string"||s.length>j8||typeof o!="number"||!Number.isInteger(o)||o<0||o>cl||r!==void 0&&typeof r!="boolean"?null:[e[0],{kind:n,body:a,contact:s,images:o,...r?{anonymous:r}:{}}]}function iDe(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const r=(o=e())==null?void 0:o.getItem(YA),c=r?JSON.parse(r):[];if(Array.isArray(c))for(const l of c.slice(-yW)){const u=sDe(l);u&&t.set(u[0],{...u[1],anonymous:u[1].anonymous===!0,images:null,imageCount:u[1].images})}}catch{}return t}function a(){try{const o=e();if(!o)return;const r=[...n()].map(([c,l])=>[c,{kind:l.kind,body:l.body,contact:l.contact,images:l.imageCount,...l.anonymous?{anonymous:!0}:{}}]);r.length===0?o.removeItem(YA):o.setItem(YA,JSON.stringify(r))}catch{}}function s(o){n().delete(o)&&a()}return{read(o){const r=n().get(o);return r?{kind:r.kind,body:r.body,contact:r.contact,...r.anonymous?{anonymous:!0}:{},images:r.images??aDe,imagesLost:r.images?0:r.imageCount}:null},keep(o,r,c){const l=XIe(r.images);if(!i7({body:r.body,contact:r.contact,images:l},c)){s(o);return}const u=n();u.delete(o),u.set(o,{kind:r.kind,body:r.body,contact:r.contact,anonymous:r.anonymous===!0,images:r.images,imageCount:l});for(const h of u.keys()){if(u.size<=yW)break;u.delete(h)}a()},forget:s}}function oDe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const mE=iDe(oDe),rDe=4e3;function cDe(e,t,n,a,s){const o=m.useRef(null);o.current={key:e,seed:t,words:n,images:a,sent:s};const r=m.useCallback(()=>{const c=o.current;!c||c.sent||mE.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);m.useEffect(r,[r,n.kind,n.body,n.contact,n.anonymous,a.shots]),m.useEffect(()=>r,[r]),m.useEffect(()=>{s&&mE.forget(e)},[s,e])}const CW="draft";function lDe(e){const[t,n]=m.useState(!1),a=m.useRef(0);m.useEffect(()=>{if(!t)return;const r=window.setTimeout(()=>n(!1),rDe);return()=>window.clearTimeout(r)},[t]);function s(){const r=Date.now(),c=zl({armedFor:t?CW:null,target:CW,armedAt:a.current,now:r,gapMs:Rl});if(c==="arm"){n(!0),a.current=r;return}c!=="ignore"&&(n(!1),e())}const o=m.useCallback(()=>n(!1),[]);return{armed:t,press:s,disarm:o}}function o7({onClose:e,initialKind:t,initialBody:n,initialTab:a,account:s}){const o=se(),r=m.useRef(null),c=m.useRef(null),l=m.useRef(null),u=m.useRef(null),h=m.useRef(null),p=m.useRef(null),f=m.useRef(null),b=m.useRef(null),v=m.useRef(0),w=m.useRef(null),T=Zt(e,{focusRef:r}),y=T8(),x=s!==void 0?s:y,C=(x==null?void 0:x.connected)===!0,A=HLe(x),[E,R]=m.useState(C&&a==="conversations"?"conversations":"write"),[z,I]=m.useState(E==="conversations"),_=Le=>{R(Le),Le==="conversations"&&I(!0)},D=C&&E==="conversations",[L,P]=m.useState(""),O=Le=>{P(""),window.setTimeout(()=>P(Le),50)},j=tn(e),M=YIe({initialKind:t,initialBody:n}),F=ZIe(M),[U]=m.useState(()=>mE.read(F)),[H,$]=m.useState((U==null?void 0:U.kind)??M.kind),[Y,W]=m.useState((U==null?void 0:U.body)??M.body),[G,Q]=m.useState((U==null?void 0:U.contact)??""),[J,X]=m.useState((U==null?void 0:U.imagesLost)??0),[te,K]=m.useState((U==null?void 0:U.anonymous)===!0),V=C&&!te,[ee,de]=m.useState(!1),[he,me]=m.useState(!1),[be,ie]=m.useState(!1),ne=GIe(U==null?void 0:U.images),ke=nPe(VIe()),{outcome:Se,sending:ve,sentAsAccount:xe,send:Ee,clearFailure:Ge}=$Ie(ne,{asAccount:V}),Qe=Se.state==="sent",Je=JIe(Qe,e);cDe(F,M,{kind:H,body:Y,contact:G,anonymous:te},ne,Qe);const He=i7({body:Y,contact:G,images:ne.shots.length},M),_e=lDe(()=>{var Le;$(M.kind),W(M.body),Q(""),X(0),K(!1),me(!1),ne.clear(),Ge(),(Le=r.current)==null||Le.focus()}),{armed:le,disarm:Re}=_e;m.useEffect(()=>{le&&Re()},[Y,G]);const ge=N8(H),Pe=he&&!YU(Y),Fe=J>0&&ne.shots.length===0,Ve=[Pe&&"fb-body-error",Fe&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ot,ce]=SPe(js());m.useEffect(()=>{var Le;E==="conversations"&&((Le=w.current)==null||Le.focus())},[]),m.useEffect(()=>{var Mt,yn;const Le=u.current;if(!Le)return;const Ht=Le.contains(document.activeElement)||fa(((Mt=document.activeElement)==null?void 0:Mt.tagName)??null);Le.inert=Qe,Qe&&Ht&&((yn=c.current)==null||yn.focus())},[Qe]),m.useEffect(()=>{var mn,xn;const Le=h.current;if(!Le)return;const Ht=f.current;if(ve){const Gt=document.activeElement,tt=Gt!=null&&(Le.contains(Gt)||Gt===Ht);b.current=tt?Gt:null,Le.inert=!0,Ht&&(Ht.inert=!0),b.current&&((mn=p.current)==null||mn.focus());return}Le.inert=!1,Ht&&(Ht.inert=!1);const Mt=b.current;b.current=null;const yn=document.activeElement===p.current||fa(((xn=document.activeElement)==null?void 0:xn.tagName)??null);!Qe&&Mt&&yn&&Mt.focus()},[ve,Qe]);function Ce(Le){var Ht;if(Le.preventDefault(),!YU(Y)){me(!0),(Ht=r.current)==null||Ht.focus();return}Ee({kind:H,body:Y,contact:G})}const Ke=!Qe&&!ve&&!D,Oe=Le=>CIe(Array.from(Le.dataTransfer.types));function at(Le){!Oe(Le)||!Ke||(Le.preventDefault(),v.current++,ie(!0))}function ut(Le){Oe(Le)&&(Le.preventDefault(),Le.dataTransfer.dropEffect=Ke?"copy":"none")}function vt(Le){Oe(Le)&&(v.current=Math.max(0,v.current-1),v.current===0&&ie(!1))}function qe(Le){Oe(Le)&&(Le.preventDefault(),v.current=0,ie(!1),Ke&&ne.add(Array.from(Le.dataTransfer.files)))}function dt(Le){Le.target!==Le.currentTarget||!Oe(Le)||(Le.preventDefault(),Le.dataTransfer.dropEffect="none")}function et(Le){Oe(Le)&&Le.preventDefault()}function Ie(Le){if(!Ke)return;const Ht=Array.from(Le.clipboardData.files),Mt=Le.target,yn=Mt instanceof HTMLTextAreaElement||Mt instanceof HTMLInputElement,mn=Array.from(Le.clipboardData.types).includes("text/plain");SIe({files:Ht.length,hasText:mn,intoTextField:yn})&&(Le.preventDefault(),ne.add(Ht))}const ct=Nt();return i.jsxs(dn,{scrim:j,dialogRef:T,backdropProps:{onDragOver:dt,onDrop:et,"data-leaving":Je||void 0},className:"feedback-dialog","data-account":C||void 0,onDragEnter:at,onDragOver:ut,onDragLeave:vt,onDrop:qe,onPaste:Ie,labelledBy:"feedback-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:o(C?dPe:"shell.feedback.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:e,"aria-label":o("shell.closeEsc"),title:o("shell.closeEsc"),children:"×"})})]}),i.jsx("p",{className:"vis-hidden",role:"status",children:_e.armed?xW():D?L:APe(Se.state,xe,A)}),C&&x?i.jsx(BIe,{tab:E,onTab:_,unread:x.unread,conversationsTabRef:w,write:ct,conversations:z?i.jsx(DIe,{account:x,active:D,announce:O}):null}):ct,i.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":be||void 0,children:i.jsxs("div",{className:"fb-drop-frame",children:[i.jsx(a7,{className:"fb-drop-glyph"}),i.jsx("p",{className:"fb-drop-title",children:o("shell.feedback.dropTitle")}),i.jsx("p",{className:"fb-drop-note",children:o("shell.feedback.dropNote")})]})})]});function Nt(){return i.jsxs("div",{className:"fb-stage",children:[i.jsxs("form",{ref:u,className:"fb-form",onSubmit:Ce,onKeyDown:Le=>{CPe(Le.nativeEvent)&&(Le.preventDefault(),Le.currentTarget.requestSubmit())},noValidate:!0,children:[i.jsxs("section",{ref:h,className:"modal-body fb-body",children:[i.jsx(XMe,{kind:H,onChange:$}),i.jsxs("div",{className:"fb-compose",children:[i.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:ge.question}),i.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:Y,maxLength:A8,rows:5,placeholder:ge.placeholder,onChange:Le=>W(Le.target.value),"aria-invalid":Pe||void 0,"aria-describedby":Ve,required:!0}),Pe&&i.jsx("p",{id:"fb-body-error",className:"fb-error",children:JLe()}),i.jsx(PIe,{images:ne,addRef:l}),Fe&&i.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:QIe(J)}),i.jsxs("div",{className:"fb-tools",children:[i.jsx(LIe,{images:ne,buttonRef:l}),i.jsx(QMe,{open:ee,onToggle:()=>de(Le=>!Le)})]}),C&&i.jsxs("div",{className:"fc-account",children:[i.jsxs("label",{className:"fc-anon",children:[i.jsx(_g,{checked:te,onChange:Le=>K(Le.target.checked)}),o(pPe)]}),!te&&i.jsx("p",{className:"fc-sent-as",children:gPe((x==null?void 0:x.email)??null,A)})]}),i.jsx(eIe,{open:ee,contact:G,onContact:Q,account:V,mail:A})]}),i.jsxs("p",{className:"fb-facts",children:[i.jsx("span",{className:"fb-facts-text",children:ke?ck(aPe(),"facts",i.jsx("span",{className:"fb-facts-value",children:ke})):sPe()}),i.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[i.jsx("kbd",{"data-symbol":TPe(ot)||void 0,children:ot}),i.jsx("kbd",{children:ce})," ",o("shell.feedback.toSend")]})]}),Se.state==="failed"&&i.jsx("p",{className:"fb-error",role:"alert",children:Se.message})]}),i.jsxs("div",{className:"fb-foot",children:[He&&i.jsx("button",{ref:f,type:"button",className:`btn danger fb-discard${_e.armed?" armed":""}`,onKeyDown:Le=>{Le.repeat&&Le.preventDefault()},onClick:_e.press,title:_e.armed?xW():nDe(),children:_e.armed?tDe():eDe()}),i.jsx("button",{type:"button",className:"btn",onClick:e,children:o("shell.cancel")}),i.jsx("button",{ref:p,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...gs(ve),children:i.jsxs("span",{className:"fb-send-label",children:[i.jsx("span",{className:"fb-send-idle",children:o("shell.feedback.send")}),i.jsx("span",{className:"fb-send-busy",children:o("shell.feedback.sending")})]})})]})]}),Qe&&i.jsxs("div",{className:"fb-done",children:[i.jsx(gg,{}),i.jsx("p",{className:"fb-done-line",children:E8(xe,A)})]})]})}}const nb=[{id:"deck",get title(){return S("settings.key.group.deck")},rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",get action(){return S("settings.key.all")},binds:[","],chord:!0},{cap:"?",get action(){return S("settings.key.sheet")},binds:["?"]},{cap:"C",get action(){return S("settings.key.clear")},binds:["c","C"]},{cap:"R",get action(){return S("settings.key.rearrange")},binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",get action(){return S("settings.key.undo")},binds:["z","Z"],chord:!0},{cap:"V",get action(){return S("settings.key.sound")},binds:["v","V"]},{cap:"M",get action(){return S("settings.key.mute")},binds:["m","M"]},{cap:"T",get action(){return S("settings.key.theme")},binds:["t","T"]},{cap:"Esc",get action(){return S("settings.key.esc")},binds:["Escape"]}]},{id:"question",get title(){return S("settings.key.group.question")},rows:[{cap:"W",get action(){return S("settings.key.waiting")},binds:["w","W"]},{cap:"N",get action(){return S("settings.key.nextWaiting")},binds:["n","N"]},{cap:"Shift + N",get action(){return S("settings.key.prevWaiting")},binds:["N"]}]},{id:"canvas",get title(){return S("settings.key.group.canvas")},rows:[{cap:"J",get action(){return S("settings.key.next")},binds:["j","J"]},{cap:"K",get action(){return S("settings.key.prev")},binds:["k","K"]},{cap:"P",get action(){return S("settings.key.peek")},binds:["p","P"]},{cap:"F",get action(){return S("settings.key.fit")},binds:["f","F"]},{cap:"Z",get action(){return S("settings.key.zoom")},binds:["z","Z"]},{cap:"Delete",get action(){return S("settings.key.delete")},binds:["Delete"]},{cap:"Tab",get action(){return S("settings.key.tab")},binds:[]},{cap:"Enter",get action(){return S("settings.key.enter")},binds:["Enter"]},{cap:"Shift + Enter",get action(){return S("settings.key.shiftEnter")},binds:["Enter"]},{get cap(){return S("settings.key.cap.drag")},get action(){return S("settings.key.drag")},binds:[]},{get cap(){return S("settings.key.cap.shiftClick")},get action(){return S("settings.key.shiftClick")},binds:[]},{get cap(){return S("settings.key.cap.click")},get action(){return S("settings.key.click")},get panelAction(){return S("settings.key.clickPanel")},binds:[]},{get cap(){return S("settings.key.cap.doubleClick")},get action(){return S("settings.key.doubleClick")},binds:[]},{get cap(){return S("settings.key.cap.hover")},get action(){return S("settings.key.hover")},binds:[]}]},{id:"panels",get title(){return S("settings.key.group.panels")},rows:[{cap:"Ctrl + K",macCap:"⌘ K",get action(){return S("settings.key.quick")},binds:["k","K"],chord:!0},{cap:"U",get action(){return S("settings.key.usage")},binds:["u","U"]},{cap:"L",get action(){return S("settings.key.sessions")},binds:["l","L"]},{cap:"F2",get action(){return S("settings.key.rename")},binds:["F2"]},{cap:"D",get action(){return S("settings.key.detail")},binds:["d","D"]},{cap:"H",get action(){return S("settings.key.history")},binds:["h","H"]},{cap:"A",get action(){return S("settings.key.accounts")},binds:["a","A"]},{cap:"S",get action(){return S("settings.key.machine")},binds:["s","S"]},{cap:"B",get action(){return S("settings.key.bw")},binds:["b","B"]},{cap:"I",get action(){return S("settings.key.jira")},binds:["i","I"],integration:"jira"}]}],dDe={cap:"Ctrl + `",get action(){return S("settings.key.workspace")},binds:["`"],chord:!0},uDe={id:"workspace",get title(){return S("settings.key.group.workspace")},rows:[dDe,{get cap(){return S("settings.key.cap.click")},get action(){return S("settings.key.wsClick")},binds:[]},{cap:"Enter",get action(){return S("settings.key.wsEnter")},binds:["Enter"]},{cap:"Shift + Enter",get action(){return S("settings.key.wsBeside")},binds:["Enter"]},{get cap(){return S("settings.key.cap.drag")},get action(){return S("settings.key.wsDrag")},binds:[]},{cap:"1 – 4",get action(){return S("settings.key.wsPanes")},binds:["1","2","3","4"]}]},hDe={id:"terminal",get title(){return S("settings.key.group.terminal")},rows:[{cap:"Esc",get action(){return S("settings.key.paneEsc")},binds:["Escape"]},{cap:"Ctrl + Shift + X",macCap:"⌃ ⇧ X",get action(){return S("settings.key.release")},binds:["x","X"],chord:!0},{cap:"Ctrl + =",macCap:"⌘ =",get action(){return S("settings.key.textLarger")},binds:["=","+"],chord:!0},{cap:"Ctrl + -",macCap:"⌘ -",get action(){return S("settings.key.textSmaller")},binds:["-"],chord:!0},{cap:"Ctrl + 0",macCap:"⌘ 0",get action(){return S("settings.key.textReset")},binds:["0"],chord:!0}]};function pDe(e){const t=e.findIndex(n=>n.id==="canvas");return[...e.slice(0,t),uDe,hDe,...e.slice(t)].map(n=>n.rows.some(a=>a.panelAction!==void 0)?{...n,rows:n.rows.map(a=>a.panelAction!==void 0?{...a,action:a.panelAction}:a)}:n)}const gDe=/ ?\([A-Z?]\)/g;function r7(e,t=()=>!0,n=!1){const a=s=>s.integration===void 0||t(s.integration);return e&&!n&&nb.every(s=>s.rows.every(a))?nb:(n?pDe(nb):nb).map(s=>({...s,rows:s.rows.filter(a).filter(o=>e||o.chord||!o.binds.some(O1)).map(o=>e?o:{...o,action:o.action.replace(gDe,"")})})).filter(s=>s.rows.length>0)}function mDe(e,t){return e.split(/\{(\w+)\}/g).map((a,s)=>s%2===1&&a in t?i.jsx(m.Fragment,{children:t[a]},s):a===""?null:i.jsx(m.Fragment,{children:s%2===1?`{${a}}`:a},s))}const ZA=["deck","question"],fDe=["workspace","terminal","canvas","panels"];function bDe(e){const t=[],n=[],a=o=>o.reduce((r,c)=>r+c.rows.length+1,0),s=e.some(o=>o.id==="workspace")?[...ZA,"panels"]:ZA;for(const o of e)((ZA.includes(o.id)||fDe.includes(o.id)?s.includes(o.id):a(t)<a(n))?t:n).push(o);return[t,n].filter(o=>o.length>0)}function kDe(e){return e.includes(" + ")?e.split(" + "):/^[⌘⌃⌥⇧] /.test(e)?e.split(" "):[e]}function vDe({onClose:e,onTour:t,onSettings:n,workspace:a=!1,extraGroups:s}){const o=se(),r=Zt(e),c=tn(e),l=zs(js()),u=sa(),h=Xg(),p=r7(u,b=>Qo(h,b),a),f=s!=null&&s.length?[...p,...s]:p;return i.jsxs(dn,{scrim:c,dialogRef:r,className:"key-help",labelledBy:"key-help-title","aria-describedby":u?void 0:"key-help-off",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:o("settings.key.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:e,label:o("settings.key.close")})})]}),i.jsxs("section",{className:"modal-body",children:[!u&&i.jsxs("div",{className:"kh-off",children:[i.jsx("p",{className:"kh-off-text",id:"key-help-off",children:mDe(o("settings.key.offText",{title:"{title}",place:"{place}"}),{title:i.jsx("strong",{children:o("settings.key.offTitle")}),place:i.jsx("span",{className:"kh-place",children:o("settings.key.place")})})}),n&&i.jsx("button",{type:"button",className:"btn",onClick:n,children:o("settings.key.openSettings")})]}),t&&i.jsx("p",{className:"kh-intro",children:o("settings.key.tourText")}),i.jsx("div",{className:"kh-cols",children:bDe(f).map((b,v)=>i.jsx("div",{className:"kh-col",children:b.map(w=>i.jsxs("section",{className:"kh-block",children:[i.jsx("h3",{className:"kh-group",children:w.title}),w.rows.map(T=>i.jsxs("div",{className:"sc",children:[i.jsx("span",{className:"kh-action",children:T.action}),i.jsx("span",{className:"kh-keys",children:kDe(l&&T.macCap?T.macCap:T.cap).map((y,x)=>i.jsxs(m.Fragment,{children:[x>0&&i.jsx("span",{className:"kh-plus",children:"+"}),i.jsx("kbd",{children:y})]},x))})]},`${w.id}:${T.cap}:${T.action}`))]},w.id))},v))})]}),i.jsxs("footer",{className:"modal-foot kh-bottom",children:[u&&i.jsxs("p",{className:"kh-foot",children:[o("settings.key.note")," ",o("settings.key.switchNote",{place:o("settings.key.place")})]}),t&&i.jsx("button",{type:"button",className:"kh-tour",onClick:t,children:o("settings.key.tour")})]})]})}function wDe(e,t){return`${e}#${t}`}function yDe(e,{lan:t,now:n,closed:a}){if(t===void 0)return[];const s=[];for(const o of e??[]){const r=o.reauth;if(!r||r.dismissed||o.origin!=="ccdeck_signin")continue;const c=wDe(r.key,r.since);if(a.has(c)||Sxe(r.key,o.email,t,n))continue;const l=o.email??"";s.push({id:c,key:r.key,since:r.since,num:o.num,email:l,name:l||o.alias||S("accounts.accountN",{n:o.num}),alias:l&&o.alias?o.alias:null})}return s}function xDe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(a=>a.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(a.num)===String(t.num))).map(a=>a.id):[]}function c7({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function CDe(e,t=S){return t("accounts.reauth.title",{count:e})}function SDe(e,t=S){return t("accounts.reauth.lead",{count:e})}const TDe=(e=S)=>e("accounts.reauth.expired"),NDe=(e=S)=>e("accounts.reauth.singleNote"),ADe=(e=S)=>e("accounts.reauth.laterTip");function jDe(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const a=[...n].sort((s,o)=>(s.at??0)-(o.at??0));return{request:a[0],waiting:a.length-1}}function EDe({request:e,waiting:t,busy:n,now:a,onAccept:s,onDecline:o,onLater:r}){const c=se(),l=m.useRef(null),u=Zt(r,{focusRef:l}),h=tn(r),p=oc(n,"accept"),f=oc(n,"dismiss");return i.jsxs(dn,{scrim:h,dialogRef:u,className:"lan-ask",labelledBy:"lan-ask-title","aria-describedby":"lan-ask-who",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:c("lan.ask.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:r,label:c("lan.ask.later")})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{id:"lan-ask-who",className:"lan-ask-who",children:i.jsx(qu,{text:c("lan.ask.who",{when:xR(e.at,a)}),parts:{name:i.jsx("strong",{className:"lan-ask-name",children:e.name}),addr:i.jsx("code",{className:"ap-lan-code",children:e.addr})}})}),i.jsx("p",{className:"lan-ask-note",children:c("lan.ask.note")}),i.jsx("p",{className:"lan-ask-fp",children:c("lan.ask.fp")}),i.jsx("code",{className:"lan-ask-fp-box",children:e.fp}),t>0&&i.jsx("p",{className:"lan-ask-more",children:c("lan.ask.more",{count:t})})]}),i.jsxs("footer",{className:"modal-foot lan-ask-foot",children:[i.jsx("button",{type:"button",ref:l,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:o,title:c("lan.ask.declineTitle"),children:c(n==="dismiss"?"lan.ask.declining":"lan.ask.decline")}),i.jsx("button",{type:"button",className:"btn primary",disabled:p.disabled,"aria-busy":p.busy,onClick:s,title:c("lan.ask.acceptTitle"),children:c(n==="accept"?"lan.ask.accepting":"lan.ask.accept")})]})]})}function RDe(e){const t=m.useRef(!1),n=zDe(e),a=c7({rows:n?1:0,ours:t.current,dialogs:Rn.dialogDepth()});t.current=a;const s=a&&n?n:null;return{node:i.jsx(Ft,{when:s,children:o=>o}),pairing:s!=null}}function zDe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:a,deferLanPair:s}){const{request:o,waiting:r}=jDe(e,t.current);return o?i.jsx(EDe,{request:o,waiting:r,busy:n,now:Date.now(),onAccept:()=>void a("accept",o.fp),onDecline:()=>void a("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function qDe({rows:e,onSignIn:t,onLater:n,firstRef:a}){const s=se(),o=e.length===1?e[0]:null;return i.jsxs("section",{className:"modal-body",children:[o?i.jsxs(i.Fragment,{children:[i.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:SR(s,"accounts.reauth.leadOne",{name:i.jsxs(i.Fragment,{children:[i.jsx("strong",{className:"reauth-name",children:o.name}),o.alias?i.jsxs("span",{className:"reauth-alias",children:[" (",o.alias,")"]}):null]})})}),i.jsx("p",{className:"reauth-note",children:NDe(s)})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:SDe(e.length,s)}),i.jsx("ul",{className:"reauth-list",children:e.map((r,c)=>i.jsxs("li",{className:"reauth-row",children:[i.jsxs("span",{className:"reauth-who",title:r.alias?`${r.alias} — ${r.name}`:r.name,children:[r.name,r.alias?i.jsxs("span",{className:"reauth-alias",children:[" ",r.alias]}):null]}),i.jsx("span",{className:"reauth-what",children:TDe(s)}),i.jsx("button",{type:"button",className:"btn",ref:c===0?a:void 0,"aria-label":s("accounts.reauth.againAs",{name:r.name}),onClick:()=>t(r),children:s("accounts.reauth.again")})]},r.id))}),i.jsx("p",{className:"reauth-note",children:s("accounts.reauth.keeps")})]}),i.jsxs("div",{className:"reauth-acts",children:[i.jsx("button",{type:"button",className:"btn",title:ADe(s),onClick:n,children:s("accounts.reauth.later")}),o&&i.jsx("button",{type:"button",className:"btn primary",ref:a,onClick:()=>t(o),children:s("accounts.reauth.again")})]})]})}function _De({rows:e,onSignIn:t,onLater:n}){const a=se(),s=m.useRef(null),o=Zt(n,{focusRef:s}),r=tn(n);return i.jsxs(dn,{scrim:r,dialogRef:o,className:"reauth-ask",labelledBy:"reauth-title","aria-describedby":"reauth-lead",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:CDe(e.length,a)})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:n,label:a("accounts.reauth.laterEsc")})})]}),i.jsx(qDe,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})}function LDe({rows:e,signingIn:t,signIn:n,signedIn:a,refresh:s,closeSignIn:o,later:r,pairing:c=!1}){const l=m.useRef(!1),u=Rn.dialogDepth()+(c?1:0),h=t!=null||c7({rows:e.length,ours:l.current,dialogs:u});return l.current=h,i.jsxs(i.Fragment,{children:[i.jsx(Ft,{when:t,children:p=>i.jsx(yV,{email:p.email||null,onClose:o,onChanged:s,onSignedIn:a})}),i.jsx(Ft,{when:!t&&h,children:()=>i.jsx(_De,{rows:e,onSignIn:n,onLater:r},e.length===1?"one":"many")})]})}const PDe={"4.0.2":[{title:"🖱️ A click on a Board card opens the session in Workspace",body:"With the terminal on, clicking a session's card on the Board switches to Workspace with that session in the pane and the keys in it, and Sessions shows the same rows in both views."},{title:"🔍 The Inspector opens beside your Workspace session",body:"On a window 1320 px or wider, opening a session in Workspace unfolds the Inspector next to its terminal, with Usage and This machine at the window's edge, and its context and recap are easier to scan."},{title:"🗂️ Sessions appears whole when the deck loads",body:"The Sessions list waits for the session history to load and then shows every row at once, in its final order, instead of filling in and reshuffling."},{title:"🧰 Panes draw correctly with tmux 3.2 to 3.5",body:"Where the system's tmux is 3.2 to 3.5, as on Ubuntu 24.04, the deck now runs its own newer tmux, so a pane that reconnects no longer shows a line shifted by one character; sessions already running keep their tmux until they end."},{title:"🎨 Codex keeps its colours in terminal panes",body:"A Codex session started from the deck now shows its prompt and status line in colour, even where the deck itself runs with NO_COLOR set."},{title:"📡 Browser Watch's radar keeps turning",body:"The radar no longer stops with an error when its dialog has no room for it, and draws again as soon as there is space."}],"4.0.0":[{title:"🖥️ Your sessions' terminals, inside the deck",body:"Open, resume or attach to a Claude Code or Codex session in a terminal pane on the board or in Workspace, on Linux, macOS and Windows.",priority:"highlight",noticeLabel:"Setup change",notice:"The terminal is on by default; Settings › General › Experimental turns it off. It runs through ccdeck's terminal engine, a separate program under its own licence that comes with ccdeck (npm installs the one for this machine, the desktop app carries it) and is checked before every start. Windows on ARM has no terminal yet.",details:"In Workspace, a Claude Code or Codex session's pane offers Chat | Term: Chat shows the conversation, and you can reply from it while the session's terminal is open here. The terminal has its own text size, apart from the page's: Aa, or Ctrl+= / Ctrl+- / Ctrl+0 (⌘ on a Mac)."},{title:"🧭 A calmer deck that shows what needs you",body:"The Sessions list reads like an inbox, colour on the board means state, and the Inspector offers each session's next step under its title.",priority:"highlight",details:"Counters at zero and key hints you have learned step aside, and the board's tools sit in one ⋯ menu. Quotas moved from Sessions to Usage, and Codex's helper agents stay inside their main conversation. Every key works as before."},{title:"🪟 Up to four sessions side by side in Workspace",body:"Drag a session onto a pane's edge, or press ⇧↵ on its row, to open it beside the others; one pane has the keys while the rest keep running.",priority:"highlight",details:"Rename a session where its name is drawn (double click, F2 or the pencil), and that name shows everywhere in the deck; for a Codex session, Codex itself gets the new name too. The Sessions list's edge drags to resize it."},{title:"🔀 Move a Claude session here from Ghostty",body:"On a Mac, a Claude Code session running in Ghostty 1.4 or later offers Move session here in its ccdeck pane: one click continues the same conversation in that pane."},{title:"🔁 A Codex account switch keeps the turn going",body:"Switching Codex accounts lets the running tool call finish first, and a turn stopped by a usage limit in the minutes before the switch continues on the new account."},{title:"🔔 A notification when a session finishes",body:"If Settings › Notifications › While the deck is closed is on, a session that ends its turn now notifies you too, as a waiting one already did."},{title:"🚪 A pane closes when its agent exits",body:"Ending an agent yourself (/exit or Ctrl+D) closes its pane, and the session stays in the list. After a crash or a kill, the pane keeps its last frame and offers Reopen here."},{title:"▶️ The board always stays live",body:"Pause is gone from the board's menu and the keyboard help, and Space no longer freezes the board."},{title:"👥 Accounts you can switch to now come first",body:"Other accounts are grouped by whether you can use them now, and the sort menu is gone. Rows stay put while your pointer is in the list."},{title:"📂 New session finds its folder by search",body:"One field searches your projects, remembered folders and Git repositories, and takes a full path; Worktrees groups each repository's worktrees. The deck says before starting if an agent cannot open that folder."},{title:"🎨 Ink, a new light theme",body:"Settings › Appearance now has Ink: warm paper surfaces with charcoal text."},{title:"📱 The board as a card stack on a phone",body:"On a phone, the board is a full-width stack of readable cards, and More opens the Command Panel."},{title:"🌡️ CPU temperature on Intel Macs",body:"This machine now shows the CPU temperature on Intel Macs too."},{title:"⌨️ ccdeck tui stays current after a deck restart",body:"The account screen in ccdeck tui keeps updating when the deck restarts underneath it."}],"3.82.4":[{title:"🪟 Start at login works on Windows without administrator rights",body:'Turning on Start at login now works on ordinary Windows accounts too. Before, Windows answered "Access is denied" unless ccdeck ran as an administrator.',priority:"highlight"},{title:"🧹 No error at login after removing ccdeck",body:"If Start at login is on and you remove ccdeck with npm uninstall, the login item now ends quietly instead of failing at every login.",notice:"On Windows, a login item turned on before this version keeps its old form until you turn Start at login off and on again."}],"3.82.3":[{title:"🖥️ Windows CPU performance limits",body:"Machine now shows CPU performance limits reported by Windows, even when no CPU temperature sensor is available.",priority:"highlight",notice:"The reading includes power-policy and firmware limits. It does not identify overheating or rule out every hardware thermal restriction."},{title:"🎯 More reliable session status",body:"Failed turns stop appearing active, and background scans no longer create phantom sessions.",priority:"highlight"},{title:"🔁 Usage history recovers from temporary errors",body:"Project usage, quota history and tool history recover more reliably after temporary read or save failures.",priority:"highlight"},{title:"🧹 No hook errors in Claude Code after uninstalling the desktop app",body:"From this version on, the hook the desktop app leaves in Claude Code's settings ends quietly once the app is uninstalled, instead of showing an error on every tool call."}],"//":["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.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is","author metadata and never a release.","","Editorial metadata: optional //summaries maps a release version to one","specific, verified headline (1–120 characters). No generic marketing claims.","A note may have priority: highlight or required. Choose at most 3 highlights,","only when warranted. Unmarked notes go under More improvements when highlights","exist. Legacy notes stay unabridged; legacy upgrade notes stay visible.","Use required for breaking changes, changed settings, privacy/security impact,","compatibility requirements or mandatory actions. A highlight with any such","impact must also carry a notice with all essential qualifications: highlight","alone is editorial placement, not an instruction to surface it across upgrades.","Required notes and notices stay visible across upgrades, never in a closed section.","Write a short benefit-led title and one useful sentence where possible; keep","opt-outs and limits. Avoid inflated adjectives, filler and generic claims.","Preserve original factual meaning. Never invent capabilities or results.","Retain setup instructions and compatibility minimums. Say only what a user","sees in the app: usage reports, telemetry and environment variables are for","README to explain, not for a note.","Verify each claim against the released diff and tests. No promotion","for invisible fixes. Do not rewrite historical releases to fit the layout.","","Keep highlight titles within 72 characters (excluding a leading emoji) and","benefit descriptions within 240 characters. These limits are validated.","Put essential compatibility, privacy or configuration details in optional","notice text, outside More improvements. Current/upgrade notices stay visible and","have no truncation limit. A notice also keeps its change visible across upgrades.","Optional noticeLabel gives it a short factual heading (1–32 characters), such","as Setup change or Compatibility. It requires notice text; default is Important.","Optional details holds secondary context, shown under the same improvements","disclosure for highlights and beside other notes. Keep the body to one useful","sentence. Never move setup, safety, privacy or compatibility conditions into","details: use notice for those, so they remain visible across upgrades.","The disclosure counts other improvements, not extra details of highlights.","Mark any other mandatory action as required. The manual digest shows only the","running release; Release history opens the full changelog. Upgrade notes keep","required/noticed changes visible and disclose the other notes in that range.","Unclassified legacy upgrade notes stay visible rather than guessing safety.","Before adding editorial metadata to a release, review every note: unmarked","changes will be treated as optional in later upgrades. Never infer safety","from a title, keyword, emoji, position or a shortened description.","","Optional icon is a semantic key: plans, accounts or skills. Use it only when","it matches the change; do not infer icons from versions, titles or emoji.","The modal shows a title's leading emoji; the glyph stands in only for a title","without one."],"//summaries":{"4.0.2":"Board cards open in Workspace, the Inspector opens with the session, and panes draw right on tmux 3.2–3.5","4.0.0":"A calmer deck, with your sessions' terminals inside it","3.82.3":"Windows CPU limits and more reliable session and usage history","3.82.2":"Arrow keys show the selected row on ccdeck tui's Network tab","3.82.1":"Clearer network shortcuts, accurate account capacity and Codex recovery fixes","3.82.0":"Steadier Codex switching, and uninstall cleans up Codex's terminal selection","3.81.4":"Codex account switching works with Windows sandbox logins","3.81.3":"More reliable Codex switching and quieter account rows","3.81.2":"Codex account switches wait through activity changes","3.81.1":"Codex reconnection and Windows fixes","3.81.0":"Codex accounts on a par with Claude's, Codex over Local network, and ccdeck tui for the whole deck","3.80.0":"Codex account switching, continuation and sharing","3.53.0":"Codex accounts, with sign-in, switching and Auto-switch","3.52.0":"ccdeck in nine more languages","3.51.0":"Jira integration updates","3.46.0":"Plans, accounts and skills at a glance"},"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4","3.40.1","3.41.3","3.43.1","3.43.3","3.48.1","3.49.1","3.53.1","3.53.3","4.0.1"],"3.82.2":[{title:"⌨️ Arrow keys show where you are on ccdeck tui's Network tab",body:"In ccdeck tui, ↑ and ↓ on the Network tab now highlight the row you are on and scroll the list to it."}],"3.82.1":[{title:"Local network controls, easier to find",body:"Open this deck’s network settings or the network graph directly from the Local network row.",priority:"highlight"},{title:"More accurate account capacity",body:"Accounts at their weekly limit no longer inflate the average remaining five-hour capacity.",priority:"highlight",icon:"accounts"},{title:"Codex account recovery fixes",body:"Codex account control can recover after temporary startup timeouts and checks account changes again when reconnecting.",priority:"highlight",icon:"accounts"}],"3.82.0":[{title:"🔄 Codex switching recovers instead of staying stuck",body:"A failed reconnect or manual switch no longer leaves Codex account control disconnected, and turning Auto-switch off stops a switch it had already queued.",priority:"highlight",icon:"accounts",details:"On Windows, a Codex connection that never answers now fails after 30 seconds instead of waiting forever."},{title:"⏱️ Slow Codex logins get more time and a Retry button",body:"ccdeck now gives Codex more time to read a login during a switch, and if it still runs out, the panel says why and offers Retry selected account.",priority:"highlight",icon:"accounts"},{title:"🧹 Uninstall also removes Codex's terminal selection",body:"ccdeck --uninstall now takes the codex block that Enable terminal selection added out of your shell profiles, and names any file it could not clean.",priority:"highlight"},{title:"⌨️ A opens Codex accounts on a Codex-only deck",body:"With Codex alone, the Codex accounts door now shows its A key, and its name follows your interface language."},{title:"🔑 Jira token help names the permission for comments and statuses",body:"A scoped Jira Cloud token needs write:jira-work to add comments and change statuses, and the token help and Settings › Integrations now say so."},{title:"🌍 Codex messages read correctly in every language",body:"The message about a Codex login folder that is not private enough had lost its accented and non-Latin letters; it is whole again, and the new timeout message is translated."}],"3.81.4":[{title:"🔄 Switch Codex accounts without another sign-in",body:"On Windows, Switch can use your existing native Codex login while keeping its sandbox permissions unchanged.",priority:"highlight",icon:"accounts"},{title:"🔐 New Windows accounts are ready for switching",body:"Accounts added through + now get private folders from the start, and older native login files are recognized."},{title:"💬 Clearer account-switching errors",body:"If a login cannot be used safely, ccdeck explains the folder-permission problem and how to continue."}],"3.81.3":[{title:"🔄 More reliable Codex account switching",body:"ccdeck retries temporary connection failures before switching the open Codex app.",priority:"highlight",icon:"accounts"},{title:"✨ Quieter account switching",body:"Successful switches no longer leave an extra message under the account row."},{title:"⌨️ Arrow-key navigation in ccdeck tui",body:"The footer and help now show the left and right arrow keys for moving between tabs."}],"3.81.2":[{title:"🔄 Codex account switches wait through activity changes",body:"If new work starts while a switch is being prepared, ccdeck now waits and retries safely instead of leaving the switch failed.",priority:"highlight",icon:"accounts"}],"3.81.1":[{title:"🔐 Fix Codex sharing on Windows",body:"Codex logins blocked by Windows folder permissions can now be prepared for sharing from the Share dialog.",priority:"highlight",icon:"accounts",noticeLabel:"Folder permissions",notice:"Secure permissions and share is optional and restricts the selected Codex folders and auth.json to your Windows user, including changes to inherited access for their contents. Your login, settings and active account stay in place. Automatic network sync never changes folder permissions."},{title:"🪟 Windows updates reach the copy you use",body:"Global npm updates now target the active installation and confirm that newer files arrived before showing installed.",priority:"highlight",noticeLabel:"Already stuck?",notice:"An older Windows installation already stuck at installed may need one manual update to receive this fix. For the desktop app, run the latest Windows installer. For npm, follow the Windows recovery steps in README, then restart ccdeck. Accounts and settings are kept."},{title:"🔄 Reconnect Codex without a false login-change warning",body:"Connecting to an unchanged Codex account no longer pauses control because of its initial account update.",priority:"highlight",icon:"accounts"},{title:"📡 See why a shared login did not arrive",body:"The network map now shows a failed transfer instead of promising that the login will arrive next round."}],"3.81.0":[{title:"👥 Codex accounts work the way Claude's do",body:"A Codex account's menu now has Set as home, Share and Projects, and Auto-switch shows even when you have only one Codex account.",priority:"highlight",icon:"accounts",details:"Auto-switch moves back to the home account once it has room again, and a notification says each move it makes. Projects shows where that account's work went, per project and per day."},{title:"📡 Share Codex logins with your paired decks",body:"Local network now lists Codex logins beside Claude's, and a paired deck adds a login you tick as a Codex account of its own.",priority:"highlight",icon:"accounts",noticeLabel:"Login privacy",notice:"Only the logins you tick are sent, and the one this deck is using stays here unless Send the login this deck is using too is on. A copy another deck renewed is repaired in place; a separate sign-in is never replaced.",details:"Codex rows show which paired decks a login is offered to, as Claude rows do, and Local network opens from the Codex side too."},{title:"⌨️ ccdeck tui looks after the whole deck over SSH",body:"The terminal view now draws the machine live, manages Claude and Codex accounts from a menu, and pairs and shares decks on a Local network tab.",priority:"highlight",details:"A Codex account signs in with a link and a code you type into any browser."},{title:"➕ Paste a Codex share from the + button",body:"Import Codex accounts is now the Paste a share tab under + in the Codex accounts panel, as on Claude's side."},{title:"🪟 The desktop window comes back the way you closed it",body:"Reopened from the tray, the Dock or a second launch, the window keeps its size and place, and stays maximized or full screen if it was.",details:"On macOS, a window reopened after an update or at login never enters full screen."}],"3.80.0":[{title:"Switch Codex accounts without losing your place",body:"Move supported running Codex conversations and their subagents to another account, then continue the same work.",priority:"highlight",icon:"accounts",noticeLabel:"Compatibility",notice:"Requires Codex 0.166.0 or newer and a private auth.json login on a supported shared native server. Conversations connected to that server switch together. ccdeck waits for tools and approvals, and must stay open to renew the selected login. After a lost connection or restart, a server that cannot confirm the workspace identity requires Reconnect selected account. If continuation is unconfirmed, check the conversation before continuing manually; uncertain sends are never repeated automatically."},{title:"Share Codex logins between your machines",body:"Choose accounts to export, then paste the code into Import Codex accounts on another machine, including Windows.",priority:"highlight",icon:"accounts",noticeLabel:"Login privacy",notice:"Sharing is optional and exports live ChatGPT credentials, including the renewal token, from file-backed logins. The code is encoded, not encrypted, and has no automatic expiry or ccdeck revocation. Use a trusted private channel and delete clipboard or message copies afterward. Renewal on one machine can invalidate the other copy and require signing in again. Configuration and conversation history are not transferred."},{title:"See your available Codex resets",body:"Usage shows saved rate-limit resets and their nearest expiry when the selected account provides them.",priority:"highlight",noticeLabel:"Availability",notice:"Reset inventory requires a validated file-backed login and an available provider reading. Checking the inventory never spends a reset."},{title:"Continue managed terminal tasks on another account",body:"With Codex Auto-switch enabled, supported terminal tasks can resume the same conversation on an account with quota after a usage-limit failure.",priority:"required",noticeLabel:"Terminal setup",notice:"Update an existing setup with Enable in terminal, then open a new terminal. Interactive continuation requires Codex 0.166.0 or newer with the native remote transport. Only supported commands launched through ccdeck terminal selection are covered; explicit CODEX_HOME pins, independent sessions and incompatible profile settings require manual handling."},{title:"Help us improve Codex support",body:"We are continuing to improve Codex support, and feedback on switching, subagents and sharing is welcome through the Feedback button in ccdeck."}],"3.53.2":[{title:"🔁 The deck stays up on machines without Codex",body:"Since 3.53.0 a deck with no Codex restarted itself every few seconds, and it now stays up."}],"3.53.0":[{title:"👥 Codex accounts: sign in, switch and Auto-switch",body:"Add Codex accounts from ccdeck with the official sign-in, see each one's usage, choose the default for new sessions and, if you turn it on, let Auto-switch move to the account with room.",priority:"highlight",noticeLabel:"Codex accounts",notice:"Each account keeps its own Codex folder, and ccdeck never copies, logs or refreshes its tokens. Removing an account moves its folder to codex-profiles-removed instead of deleting it. Auto-switch is off by default and acts only on a reading taken now."},{title:"🔀 One Accounts panel for Claude and Codex",body:"With both CLIs installed, a Claude | Codex switch in the panel's header changes the view, never the account in use, and ccdeck remembers it."},{title:"🕐 Reset times fit in every language",body:"The time until a reset beside each quota bar is no longer cut where a language's words run longer."},{title:"🛠️ Tool and Skill activity work when the deck's folder is gone",body:"Both open again when the folder ccdeck was started from has been deleted."}],"3.52.0":[{title:"🌍 ccdeck in your language",body:"Choose Traditional or Simplified Chinese, German, Japanese, Korean, French, Spanish, Brazilian Portuguese or Romanian in Settings › General › Language. Until you choose, ccdeck follows your browser's language.",priority:"highlight",noticeLabel:"Language",notice:"What's new and text written by Jira, GitHub or GitLab stay as they were written, and anything without a translation shows in English."},{title:"📅 Codex 30-day windows say what a day may cost",body:"A Codex window reported as 30 days is paced over its real length, and its pace note says what a day may cost to last until the reset."}],"3.51.0":[{title:"✏️ Comment and change status in Jira",body:"Add a comment or change an issue’s status from its details in ccdeck.",priority:"highlight",noticeLabel:"Jira edits",notice:"Changes are sent to your connected Jira account and follow its permissions. Jira edits require a supported native build and filesystem; if safe coordination is unavailable, ccdeck refuses the edit and you can still browse your board."},{title:"📍 Jira moves follow your selection",body:"Drag the issue you select, move completed issues between sprints, and place issues at the end by default.",priority:"highlight"},{title:"🛠️ Reduced memory use during long sessions",body:"ccdeck releases more unused memory, and Jira edits recover more reliably when a connection is interrupted."}],"3.50.0":[{title:"🤝 Paired decks no longer each read a shared account's usage",body:"No more rate limits from every machine reading it: one deck reads the account and passes the numbers to the others. Hover the reading's age to see which deck read it."}],"3.49.0":[{title:"🗞️ What's new is shorter and easier to scan",body:"Up to three main changes come first and the rest wait under Show details; Check for updates moved to the dialog's More options menu."},{title:"👥 No warning when one account is in use on several decks",body:"The account row and the desktop no longer flag it, and the Login active on another deck switch is gone from Settings › Notifications; expired logins are still shown.",priority:"required"},{title:"📍 Auto-hidden sessions come back where they were",body:"With Hide finished sessions after on, a session that works again returns to its place, with its new subagents beside it rather than further down the board."},{title:"💻 Windows: About flags an outdated terminal CLI",body:"When the npm ccdeck on PATH is older than the desktop app, Settings › About shows the command that updates it."},{title:"✏️ Texts that fell behind are up to date",body:"Explore integrations says Jira can move issues, and the Radar and Where the time went tips match what the app does."}],"3.48.0":[{title:"🗂️ Jira: move issues between sprints and the backlog",body:"On a Scrum board ordered by Rank, drag issues or use Move to reorder them or send them to another sprint or the backlog, one at a time or up to 50 together. Browsing still only reads."},{title:"🔎 The Jira list is easier to scan",body:"Titles keep more room, a row's preview no longer covers the next row, the issue key shows once in the detail, and Clear filters stays in reach on a phone."},{title:"⌨️ ccdeck tui keeps your Claude accounts on one screen over SSH",body:"Switch accounts, turn Auto-switch on or off, and sign an account in with a link you open in any browser, all from the terminal."},{title:"🎮 Machine shows NVIDIA GPU readings",body:"On Linux and Windows with nvidia-smi: each GPU's utilization, video memory, temperature and power."},{title:"👤 Claude accounts are quieter, and an expired login has a Sign in button",body:"Telemetry is a small shield explained on hover or focus, and an account whose login expired shows Sign in on its own row."},{title:"🩹 Fewer page errors from browser extensions and translation",body:"The Accounts panel recovers when an extension breaks its requests, and Local network keeps working while the browser translates the page."}],"3.47.0":[{title:"⌨️ Quick open: Cmd/Ctrl+K reaches any panel, setting, session or theme by name",body:"Type a few letters to open a panel, land on a setting inside Settings, jump to a session or switch the theme. It is also Search on the bar."},{title:"⚙️ Settings › Claude Code changes Claude Code's own settings from the deck",body:"Twelve settings in five groups, from auto memory and compaction to the Co-Authored-By credit and the update channel, written to your settings.json on this computer."},{title:"📡 Radar monitors all the time, and packet capture is one explained step",body:"There is no Start or Stop any more: Radar finds Claude Code's collector by itself. Where capture needs a permission, Allow packet capture once asks for it on your press only."},{title:"⏱️ Tool activity shows where the time went, and Skill activity who starts your skills",body:"Tool activity splits the turns' time between Claude, this machine and you. Skill activity shows how many skill uses Claude, Codex or you started, overall and per skill."},{title:"📊 Usage remembers how full each quota week ended, and names your Claude plan",body:"Under each 7-day bar a line says how full the last weeks were at their reset. The Claude quota card shows your plan beside its title, as the Codex card does."},{title:"🗂️ Stripes, dialogs and floating panels are organized more evenly",body:"The doors on both edge stripes sit in named groups, dialogs share one frame, and T switches the theme inside any dialog too."},{title:"🪟 The desktop app works on a first run without Node, and integrations got fixes",body:"Usage no longer needs npm, and Claude Code installed while the app is open is picked up. Jira and GitLab avatars load, and panels reopen where you left them."}],"3.46.0":[{title:"🔗 Jira, GitHub and GitLab panels are easier to read and navigate",body:"Jira rows show each issue's status, lists answer the arrow keys and fit a phone, and a failed refresh says “Not updated”."},{title:"📡 Radar finds more Claude Code processes on Linux",body:"It now sees Claude Code started from its versioned install folder, plus connection attempts that got no reply and the telemetry variables it was launched with."},{title:"🗺️ Follow plans at any zoom",body:"See plan progress on session notes and directly on the canvas.",priority:"highlight",icon:"plans",details:"Subagents stay in one column beside their parent."},{title:"✅ Keep your Claude account in sync",body:"After `/login`, Accounts, Switch, Auto-switch and Usage follow your active Claude Code account.",priority:"highlight",icon:"accounts",details:"Auto-switch can also be set up while it is off."},{title:"📊 Account capacity and the Reset calendar have their own buttons",body:"Both open from the left stripe, under Claude accounts, instead of from the small gauge in the accounts panel's header."},{title:"🧩 See which skills your agents use",body:"Review skill activity from the right sidebar, including typed slash commands.",priority:"highlight",notice:"Counting typed slash commands adds a `UserPromptExpansion` hook to Claude Code's `settings.json` on supported versions (2.1.116+). Set `AGENTS_DECK_SKILL_HOOK=0` to opt out.",icon:"skills",noticeLabel:"Setup change"},{title:"📈 Load history keeps the reading you click",body:"Click a minute on a chart to keep its reading. Saved limit resets now show their expiry time, and Tool activity has a clearer icon."}],"3.45.0":[{title:"🔗 Read-only Jira, GitHub and GitLab panels beside your agents",body:"Settings › Integrations connects Jira (Cloud, Server or Data Center), GitHub, and GitLab.com or your own GitLab, each with a token, and a control on the left stripe opens its panel: a Jira board's backlog in Jira's own order, or a project's branches, pull or merge requests, pipelines and issues, with the item beside the list. The panels only read: they never comment, merge, re-run a job or change an issue. The token stays on this machine, in a file only you can read, and goes only to that connection's own API. Nothing is read until you connect a tracker, and then only while its panel is open."},{title:"📤 Each account says what its organization's telemetry sends",body:"A Team or Enterprise organization can turn on Claude Code's telemetry for every member, and Claude Code applies it without asking. Each account of such an organization now carries a line under its name: “Telemetry · usage data”, or “Telemetry · prompts, tool details” in the warning colour when your prompts and tool details are sent too. Its tooltip names the organization and where the data goes. After a switch, Auto-switch's notification and the row's “Now active” note say it too. The deck changes nothing; it learns what the organization turns on from a Claude Code session run on one of its accounts, and until then that account shows no line."},{title:"⚠️ A warning when a paired deck is on the same Claude login",body:"A Claude login renews once, so when two machines use one copied login, the one that renews second is signed out. When a paired deck on Local network says it is on the login this deck is using, the live account's row now says “Also active on” and names that deck, with what to do: use a different account on one of the machines, or sign in on each one separately. A switch onto such a login says so too, and so does one desktop notification per incident, “Login active on another deck” in Settings › Notifications, which is on by default."},{title:"📱 A phone opens one panel at most when the deck loads",body:"On a window 640 px wide or less, a reload used to open Accounts, Usage and the machine panel on top of each other, with none of the board in sight. It now opens at most one of them, preferring Usage over the machine panel, and Accounts and the session list open from the dock. A wider window loads exactly as before, and nothing you chose is forgotten."}],"3.44.0":[{title:"⛔ A turn that stops on an error now shows as stopped",body:"When Claude Code ends a turn on an API error, such as an expired login or a usage limit, it sends StopFailure instead of Stop. The deck now adds StopFailure to the hooks it writes in Claude Code's settings.json, but only when every Claude Code it finds is 2.1.78 or newer; with an older one, or one whose version it cannot read, nothing changes. The card then says “Stopped · login expired”, “Stopped · usage limit” or “Stopped · API error”, and the sessions one expired login stops together arrive as one notification that names them. Each needs a “continue” once a working login is active."},{title:"🔑 Auto-switch leaves an expired login, and nothing switches onto one",body:"When Claude Code has signed a login out and claude-swap's saved copy is dead too, Auto-switch now moves to another account under your home and weekly-reset rules, and its notification says why. Neither Auto-switch nor Switch moves onto a login that is already known to be expired: that account's row says its login expired, with Sign in again, and nothing moves."},{title:"💲 Usage totals say how complete they are",body:"The usage headline is always shown now, by the rule History and the model table already used: an exact total when every cost is known, a known $0 included; the known part with “+” when some tokens could not be priced; and “not priced”, never a bare $0, when no cost is known. Sessions whose cost is a known zero show it too."},{title:"📡 Radar: a resizable inspector, prompt previews and a JSON view",body:"Radar's inspector can be resized and shows prompt previews, highlights and each record as a JSON tree, beside the File view. Settings › Radar has a new Monitor automatically switch. It is off, so Radar still watches only after you press Start, as before; turn it on to have the deck start monitoring by itself."},{title:"🧰 Tool activity opens over the deck, with the first tool's details open",body:"Tool activity now opens as a dialog over the deck instead of a page of its own, with the first tool selected and its details beside the list. Escape closes the details first, then the dialog. On a phone the details open as a sheet."},{title:"🧩 Tool activity counts skills, and the slash commands you type if you opt in",body:"Tool activity's Skills tab ranks the skills your Claude Code and Codex agents used. Counting the slash commands you type needs Claude Code's UserPromptExpansion hook, which the deck adds to settings.json only when you start it with AGENTS_DECK_SKILL_HOOK=1 and every Claude Code it finds is 2.1.116 or newer. Without that variable nothing in settings.json changes."},{title:"▶️ Continue a background session that stopped",body:"A background session that stopped on an error has a Continue button on its card and panel: the deck stops it if Claude Code still lists it, then resumes it in its own folder with “Continue from where you left off.” Continue stopped background sessions, in Settings › General, presses it for you once per stop. It is off until you turn it on."},{title:"⌨️ ccdeck commands for your terminal",body:"ccdeck accounts, ccdeck switch, ccdeck usage, ccdeck sessions and ccdeck open work from any terminal. ccdeck switch --best goes where Auto-switch would, and every switch follows the deck's own rules. Over SSH, ccdeck open prints the line that opens the deck on your own computer. Each command takes --json for scripts."}],"3.43.4":[{title:"🔐 Local network no longer sends the login a deck is signed in to",body:`Two machines on one Claude login race to renew it, and the one that renews second is signed out with “Login expired”. So paired decks no longer receive the login a deck is signed in to right now. Every other login you tick is shared as before, and this one goes out once the deck switches to another account.
|
|
153
|
+
${n("board.rail.unreadCount",{n:t})}`:a}function DLe(e,t){return e>0?{ariaLabel:S("board.rail.feedbackUnread",{count:e}),detail:S("board.rail.unreadCount",{n:e}),dot:!0,...t?{onPress:t}:{}}:{}}function Ir(e,t){return t.map(n=>({...n,group:e}))}function FLe({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:a,toggleAccountsPanel:s,accountsPanelId:o="accounts-panel",codexPanelOpen:r=!1,toggleCodexPanel:c=()=>{},usagePanelOpen:l,setUsagePanelOpen:u,machinePanelOpen:h,setMachinePanelOpen:p,setUsageHistoryOpen:f,watchOn:b,watchUnseen:v,setBrowserWatchOpen:w,setTrafficRadarOpen:T,setRadioOpen:y,openToolActivity:x,openSettings:C,onFeedback:A,toggles:E,openCapacity:R,integrations:z=[],openExploreIntegrations:I,openQuickOpen:_,feedbackUnread:D=0,openFeedbackConversations:L,inspectorOpen:P=!1,toggleInspector:O=()=>{}}){const j=Lme(js()),M=zs(js()),F={id:"session-list",label:S("board.rail.sessionList"),short:S("board.rail.sessionList.short"),key:{cap:"L",aria:"L",single:!0},ariaLabel:S("board.rail.sessionList"),glyph:i.jsx(dG,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:E.sessionList},U={id:"accounts",label:S("board.rail.accounts"),short:S("board.rail.accounts"),key:{cap:"A",aria:"A",single:!0},ariaLabel:S("board.rail.accounts"),hint:e.codex?void 0:S("board.rail.accounts.hint"),glyph:i.jsx(uG,{}),kind:"panel",open:a,controls:o,onPress:s,buttonRef:E.accounts},H=R?[{id:"account-capacity",label:S("board.rail.capacity"),short:S("board.rail.capacity.short"),ariaLabel:S("board.rail.capacity"),detail:S("board.rail.capacity.detail"),glyph:i.jsx(fge,{}),kind:"dialog",onPress:()=>R("accounts")},{id:"reset-calendar",label:S("board.rail.calendar"),short:S("board.rail.calendar.short"),stripeWord:S("board.rail.calendar"),ariaLabel:S("board.rail.calendar"),detail:S("board.rail.calendar.detail"),glyph:i.jsx(bge,{}),kind:"dialog",onPress:()=>R("calendar")}]:[],$={id:"codex-accounts",label:S("codex.panel.title"),short:"Codex",stripeWord:S("codex.panel.title"),...e.claude?{}:{key:{cap:"A",aria:"A",single:!0}},ariaLabel:S("codex.panel.title"),glyph:i.jsx(Age,{}),kind:"panel",open:r,controls:"codex-accounts-panel",onPress:c,buttonRef:E.codex},Y={id:"inspector",label:S("board.inspector.show"),short:S("board.inspector.show"),stripeWord:S("board.inspector.label"),key:{cap:"D",aria:"D",single:!0},ariaLabel:S("board.inspector.show"),glyph:i.jsx(kge,{}),kind:"panel",open:P,controls:Tz,onPress:O},W={id:"usage",label:S("board.rail.usage"),short:S("board.rail.usage"),key:{cap:"U",aria:"U",single:!0},ariaLabel:S("board.rail.usage"),glyph:i.jsx(sge,{}),kind:"panel",open:l,controls:"usage-panel",onPress:()=>u(be=>!be),buttonRef:E.usage},G={id:"machine",label:S("board.rail.machine"),short:S("board.rail.machine"),key:{cap:"S",aria:"S",single:!0},ariaLabel:S("board.rail.machine"),hint:S("board.rail.machine.hint"),stripeWord:S("board.rail.machine.hint"),glyph:i.jsx(oge,{}),kind:"panel",open:h,controls:"system-panel",onPress:()=>p(be=>!be),buttonRef:E.machine},Q={id:"history",label:S("board.rail.history"),short:S("board.rail.history.short"),stripeWord:S("board.rail.history"),key:{cap:"H",aria:"H",single:!0},ariaLabel:S("board.rail.history"),glyph:i.jsx(ige,{}),kind:"dialog",onPress:()=>f(be=>!be)},J={id:"browser-watch",label:S("board.rail.browserWatch"),short:S("board.rail.browserWatch.short"),stripeWord:S("board.rail.browserWatch"),key:{cap:"B",aria:"B",single:!0},ariaLabel:`${S("board.rail.browserWatch")}${S("board.listSep")}${S(b?"board.rail.watching":"board.rail.notWatching")}${v>0?`${S("board.listSep")}${S("board.rail.unreadCount",{n:v})}`:""}`,detail:ILe(b,v,S),glyph:i.jsx(cge,{watching:b===!0||v>0}),kind:"dialog",onPress:()=>w(be=>!be),badge:v},X={id:"settings",label:S("board.rail.settings"),short:S("board.rail.settings.short"),key:{cap:j,aria:"Control+, Meta+,",single:!1},ariaLabel:S("board.rail.settings"),glyph:i.jsx(lge,{}),kind:"dialog",onPress:()=>C()},te={id:"quick-open",label:S("board.rail.search"),short:S("board.rail.search"),key:{cap:lme(M),aria:M?"Meta+K":"Control+K",single:!1},ariaLabel:S("board.rail.search"),detail:S("board.rail.search.detail"),glyph:i.jsx(gG,{}),kind:"dialog",onPress:_,barLook:"field",fieldText:S(MLe)},K={id:"feedback",label:S("board.rail.feedback"),short:S("board.rail.feedback"),menu:S("board.rail.feedback.menu"),ariaLabel:S("board.rail.feedback.menu"),glyph:i.jsx(dge,{}),kind:"dialog",onPress:A,barLook:"icon",...DLe(D,L),...D>0?{badge:D}:{}},V=x?[{id:"tool-activity",label:S("board.rail.tools.activity"),short:S("board.rail.tools.short"),stripeWord:S("board.rail.tools.activity"),ariaLabel:S("board.rail.tools.activity"),glyph:i.jsx(mge,{}),kind:"dialog",detail:S("board.rail.tools.detail"),onPress:()=>x("tools")},{id:"skill-activity",label:S("board.rail.skills"),short:S("board.rail.skills.short"),stripeWord:S("board.rail.skills"),ariaLabel:S("board.rail.skills"),glyph:i.jsx(hG,{}),kind:"dialog",detail:S("board.rail.skills.detail"),onPress:()=>x("skills")}]:[],ee=T?[{id:"traffic-radar",label:S("board.rail.radar"),short:S("board.rail.radar.short"),ariaLabel:S("board.rail.radar"),glyph:i.jsx(rge,{}),kind:"dialog",detail:S("board.rail.radar.detail"),onPress:()=>T(!0)}]:[],de=y?[{id:"radio",label:S("board.rail.radio"),short:S("board.rail.radio"),ariaLabel:S("board.rail.radio"),glyph:i.jsx(gge,{}),kind:"dialog",detail:S("board.rail.radio.detail"),onPress:()=>y(!0)}]:[],he=I?[{id:"explore-integrations",label:S("board.rail.explore"),short:S("board.rail.explore.short"),ariaLabel:S("board.rail.explore"),glyph:i.jsx(age,{}),kind:"dialog",onPress:I}]:[],me=z.map(({provider:be,onPress:ie})=>({id:`integration-${be.kind}`,label:be.label,short:be.label,ariaLabel:be.label,detail:jp(S,be.detail),key:be.shortcut?{cap:be.shortcut.toUpperCase(),aria:be.shortcut.toUpperCase(),single:!0}:void 0,glyph:i.jsx(be.Glyph,{}),kind:"dialog",onPress:ie}));return{left:e.claude?[U,F]:e.codex?[$,F]:[F],codexDoor:e.claude&&e.codex?[$]:[],leftStripe:[Ir(S("shell.rail.left"),[F,...e.claude?[U]:e.codex?[$]:[]]),e.claude?Ir(S("board.rail.group.accounts"),H):[],me,he].filter(be=>be.length>0),leftFoot:[...de,X],rightStripe:[[Y],Ir(S("board.rail.group.usage"),[W,G]),Ir(S("board.rail.group.activity"),[Q,...V]),Ir(S("board.rail.group.watchers"),[J,...ee])].filter(be=>be.length>0),corner:K,capacity:e.claude?H:[],right:[Ir(S("board.rail.group.usage"),[W,G]),Ir(S("board.rail.group.activity"),[Q,...V]),Ir(S("board.rail.group.watchers"),[J,...ee]),de].filter(be=>be.length>0),utilities:[X,K],search:te,explore:he,integrations:me}}function BLe(e){if(!e)return[];const t=S("board.controls.openPanel");return[{id:"command-panel",label:t,short:t,ariaLabel:t,detail:S("board.controls.openPanelTip"),glyph:i.jsx(Ze,{name:"terminal"}),kind:"panel",onPress:()=>e(typeof document>"u"?null:document.getElementById(wp))}]}let iE=null;const oE=new Set,ULe=(e,t)=>e===t||e!==null&&t!==null&&e.connected===t.connected&&e.email===t.email&&e.unread===t.unread&&e.latestAt===t.latestAt&&e.mail===t.mail;function S4e(e){const t=e===null?null:{connected:e.connected===!0,email:typeof e.email=="string"&&e.email!==""?e.email:null,unread:Number.isInteger(e.unread)&&e.unread>0?e.unread:0,latestAt:typeof e.latestAt=="string"?e.latestAt:null,mail:e.mail!==!1};if(!ULe(iE,t)){iE=t;for(const n of oE)n()}}function rE(){return iE}function WLe(e){return oE.add(e),()=>{oE.delete(e)}}function T8(){return m.useSyncExternalStore(WLe,rE,rE)}function HLe(e){return(e==null?void 0:e.mail)!==!1}function GLe(e){return e!=null&&e.connected?e.unread:0}const VLe=[".stage-dock .xterm-helper-textarea",".stage-dock button:not(:disabled)",'.sl-row[aria-current="true"]'];function KLe(e,t=VLe){for(const n of t){const a=e.querySelector(n);if(a&&(a.focus(),e.activeElement===a))return a}return null}const $Le='button[data-rail-item="inspector"]';function JU(e){const t=KLe(e);if(t)return t;const n=e.querySelector($Le);return n?(n.focus(),e.activeElement===n?n:null):null}function eb(e,t){return e.split(/\{(\w+)\}/).map((a,s)=>s%2===0?a:i.jsx(m.Fragment,{children:a in t?t[a]:`{${a}}`},s))}const Tk=[{value:"bug",get label(){return S("shell.feedback.kind.bug")},get question(){return S("shell.feedback.q.bug")},get placeholder(){return S("shell.feedback.ph.bug")}},{value:"idea",get label(){return S("shell.feedback.kind.idea")},get question(){return S("shell.feedback.q.idea")},get placeholder(){return S("shell.feedback.ph.idea")}},{value:"other",get label(){return S("shell.feedback.kind.other")},get question(){return S("shell.feedback.q.other")},get placeholder(){return S("shell.feedback.ph.other")}}];function N8(e){return Tk.find(t=>t.value===e)??Tk[0]}const cE=3,HA=120,A8=1e4,j8=200,JLe=()=>S("shell.feedback.missing");function YU(e){return e.trim()!==""}function YLe(e){var o;const t=e.trim();if(t==="")return"";const n=ZU(t.split(/\r?\n/,1)[0]),a=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=GA(a).length>=cE?GA(a):GA(n);return XLe(s.length>=cE?s:ZU(t))}function ZLe(e,t){const n=YLe(t);return n.length>=cE?n:S("shell.feedback.titleKind",{kind:N8(e).label,text:n})}function ZU(e){return e.replace(/\s+/g," ").trim()}function GA(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function XLe(e){if(e.length<=HA)return e;const t=e.slice(0,HA-1),n=t.lastIndexOf(" ");return`${(n>=HA/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function XU({kind:e,body:t,contact:n}){const a={kind:e,title:ZLe(e,t),body:t.trim()};return n.trim()!==""&&(a.contact=n.trim()),a}function QLe(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const ePe={darwin:"macOS",win32:"Windows",linux:"Linux"};function tPe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),a=t===-1?"":e.slice(t+1),s=ePe[n]??n;return a?`${s} · ${a}`:s}function nPe(e){return e?`ccdeck ${e.appVersion} · ${tPe(e.platform)}`:null}const aPe=()=>S("shell.feedback.factsWith"),sPe=()=>S("shell.feedback.factsUnknown"),iPe=()=>S("shell.feedback.addDetails"),oPe=()=>S("shell.feedback.contact"),rPe=()=>S("shell.feedback.contactPh"),cPe=()=>S("shell.feedback.contactHint"),lPe=()=>[S("shell.feedback.where1"),S("shell.feedback.where2")],dPe="shell.feedback.accountTitle",uPe="shell.feedback.tabWrite",hPe="shell.feedback.tabConversations",pPe="shell.feedback.sendWithout";function gPe(e,t=!0){return e?S(t?"shell.feedback.sentAsMail":"shell.feedback.sentAsNoMail",{email:e}):S(t?"shell.feedback.sentAsAccountMail":"shell.feedback.sentAsAccountNoMail")}const mPe=["shell.feedback.whereAccount1","shell.feedback.whereAccount2"],fPe=["shell.feedback.whereAccount1NoMail","shell.feedback.whereAccount2"],bPe=(e=!0)=>(e?mPe:fPe).map(t=>S(t)),kPe="shell.feedback.sentAccount",vPe="shell.feedback.sentAccountNoMail",wPe="shell.feedback.accountUnavailable";function yPe(e,t){return new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",hourCycle:"h23",timeZone:t}).format(e)}function xPe(e,t,n,a){return S(e==="conversations"?"shell.feedback.limitConversations":"shell.feedback.limitReplies",{limit:t,time:yPe(n,a)})}function QU(e,t,n=Date.now()){const a=t==null?void 0:t.reason;return a==="too_many"&&Number.isInteger(t==null?void 0:t.limit)&&Number.isInteger(t==null?void 0:t.retryAfterSec)?xPe("conversations",t.limit,new Date(n+t.retryAfterSec*1e3)):a==="invalid"||a==="too_large"?lE(e,a,t==null?void 0:t.errors):S(wPe)}function CPe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Nz(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function SPe(e){return zs(e)?["⌘","Enter"]:["Ctrl","Enter"]}function TPe(e){return[...e].length===1}const E8=(e=!1,t=!0)=>S(e?t?kPe:vPe:"shell.feedback.sent");function NPe(e){const t=/^At most (\d+) images\.$/.exec(e);if(t)return S("shell.feedback.problem.count",{n:t[1]});const n=/^Image (\d+) is over (\d+) MB\.$/.exec(e);if(n)return S("shell.feedback.problem.size",{n:n[1],mb:n[2]});const a=/^Image (\d+) is not a PNG or a JPEG\.$/.exec(e);return a?S("shell.feedback.problem.format",{n:a[1]}):e}function lE(e,t,n){if(t==="vetoed")return S("shell.feedback.fail.vetoed");if(e===429||t==="too_many")return S("shell.feedback.fail.tooMany");if(e===413||t==="too_large")return S("shell.feedback.fail.tooLarge");const a=n==null?void 0:n.images;return e===400&&Array.isArray(a)&&typeof a[0]=="string"?S("shell.feedback.fail.image",{reason:NPe(a[0])}):S(e===400?"shell.feedback.fail.rejected":"shell.feedback.fail.unreachable")}function APe(e,t=!1,n=!0){return e==="sending"?S("shell.feedback.sending"):e==="sent"?E8(t,n):""}const eW=1400,jPe=150,R8=m.createContext({values:{}});function z8(){return m.useContext(R8)}function EPe(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const tW=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function RPe({def:e,existing:t,busy:n,error:a,onSubmit:s,onCancel:o,onDirtyChange:r}){var j,M;const c=se(),l=m.useId(),[u,h]=m.useState(()=>Object.fromEntries(e.fields.map(F=>{var U,H,$;return[F.name,F.secret?"":((U=F.initial)==null?void 0:U.call(F,t))??(F.type==="choice"?(($=(H=F.options)==null?void 0:H[0])==null?void 0:$.value)??"":"")]}))),[p,f]=m.useState((t==null?void 0:t.name)??""),b=m.useRef(null),v=m.useRef(new Map),w=!!t,T=m.useRef(u),y=m.useRef(p);m.useEffect(()=>{r==null||r(p!==y.current||Object.keys(u).some(F=>u[F]!==T.current[F]))},[p,u,r]);const x=e.fields.filter(F=>F.type==="choice").every(F=>u[F.name]===T.current[F.name]),C=w&&t.tokenSaved&&x,A=(F,U)=>{n||h(H=>({...H,[F]:U}))},E=F=>{var H;if(F.preventDefault(),n)return;const U={};for(const $ of e.fields)tW($,u)&&(U[$.name]=(u[$.name]??"").trim());(H=F.currentTarget.querySelector('button[type="submit"]'))==null||H.focus(),s(U,p.trim()),h($=>Object.fromEntries(Object.entries($).map(([Y,W])=>{var G;return[Y,(G=e.fields.find(Q=>Q.name===Y))!=null&&G.secret?"":W]})))},R=m.useMemo(()=>{const F=u.baseUrl??"";try{return F?new URL(/^[a-z]+:\/\//i.test(F)?F:`https://${F}`).host:""}catch{return""}},[u.baseUrl]),z=m.useMemo(()=>({values:u,existing:t}),[u,t]),I=e.fields.filter(F=>tW(F,u)),_=(j=I.find(F=>!F.secret&&F.type!=="choice"))==null?void 0:j.name,D=(M=I.find(F=>F.secret))==null?void 0:M.name,L=a!=null&&a.field&&I.some(F=>F.name===a.field&&F.type!=="choice")?a.field:null,P=`${l}-error`;m.useEffect(()=>{var U,H,$;const F=w?D:_??D;F&&((U=v.current.get(F))==null||U.focus()),($=(H=b.current)==null?void 0:H.scrollIntoView)==null||$.call(H,{block:"nearest"})},[w]),m.useEffect(()=>{var F;L&&((F=v.current.get(L))==null||F.focus())},[a,L]);const O=a&&i.jsxs(i.Fragment,{children:[a.message,a.detail&&i.jsxs("span",{className:"ig-form-detail",children:[" ",c("integrations.failure.said",{provider:e.label,said:a.detail})]}),a.kind==="rate-limit"&&a.retryAfter?i.jsxs("span",{children:[" ",c("integrations.form.retryIn",{n:a.retryAfter})]}):null]});return i.jsx(R8.Provider,{value:z,children:i.jsxs("form",{ref:b,className:"ig-form",onSubmit:E,"aria-labelledby":`${l}-title`,noValidate:!0,children:[i.jsxs("header",{className:"ig-managed-header",children:[i.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:i.jsx(e.Glyph,{})}),i.jsxs("div",{className:"ig-managed-identity",children:[i.jsx("h2",{className:"ig-form-title",id:`${l}-title`,children:w?c("integrations.form.edit",{name:t.name}):c("integrations.form.connect",{provider:e.label})}),w&&i.jsx("p",{children:c("integrations.form.connectionOf",{provider:e.label})})]})]}),I.map(F=>{const U=EPe(F,u),H={...U,label:jp(c,U.label),hint:jp(c,U.hint),placeholder:jp(c,U.placeholder)},$=(a==null?void 0:a.field)===H.name,Y=[H.hint?`${l}-${H.name}-hint`:"",$?P:""].filter(Boolean).join(" ")||void 0;if(H.type==="choice")return i.jsxs("fieldset",{className:"fb-kinds","aria-invalid":$||void 0,children:[i.jsx("legend",{className:"vis-hidden",children:H.label}),(H.options??[]).map(Q=>i.jsxs("label",{className:"fb-kind",children:[i.jsx("input",{type:"radio",name:`${l}-${H.name}`,value:Q.value,checked:u[H.name]===Q.value,"aria-disabled":n||void 0,onChange:()=>A(H.name,Q.value),onKeyDown:J=>{Nz(J.nativeEvent)&&J.preventDefault()}}),jp(c,Q.label)]},Q.value))]},H.name);const W=H.secret&&C,G=`${l}-${H.name}`;return i.jsxs("div",{className:"fb-field",children:[i.jsxs("label",{className:"fb-field-label",htmlFor:G,children:[H.label,H.optional&&i.jsxs("span",{className:"fb-optional",children:[" ",c("integrations.form.optional")]})]}),i.jsx("input",{id:G,className:`ap-manage-input ig-input${H.secret?" ig-mono":""}`,ref:Q=>{Q?v.current.set(H.name,Q):v.current.delete(H.name)},type:H.type,inputMode:H.type==="url"?"url":H.type==="email"?"email":void 0,autoComplete:H.autoComplete??"off",spellCheck:!1,value:u[H.name]??"",onChange:Q=>A(H.name,Q.target.value),placeholder:W?c("integrations.form.keepSaved"):H.placeholder,readOnly:n,"aria-invalid":$||void 0,"aria-describedby":Y,"aria-required":!H.optional&&!W||void 0}),H.hint&&i.jsx("span",{className:"ig-hint",id:`${l}-${H.name}-hint`,children:H.hint}),$&&L===H.name&&i.jsx("span",{className:"ig-form-error",id:P,role:"alert",children:O})]},H.name)}),i.jsxs("details",{className:"ig-help ig-token-help",children:[i.jsx("summary",{children:c("integrations.form.howTo",{provider:e.label})}),e.tokenHelp]}),i.jsxs("div",{className:"fb-field",children:[i.jsxs("label",{className:"fb-field-label",htmlFor:`${l}-name`,children:[c("integrations.form.name")," ",i.jsx("span",{className:"fb-optional",children:c("integrations.form.optional")})]}),i.jsx("input",{id:`${l}-name`,className:"ap-manage-input ig-input",type:"text",autoComplete:"off",maxLength:120,readOnly:n,value:p,onChange:F=>f(F.target.value),placeholder:R||e.label})]}),a&&!L&&i.jsx("p",{className:"ig-form-error",id:P,role:"alert",children:O}),i.jsxs("div",{className:"ig-form-actions",children:[i.jsx("button",{type:"submit",className:"btn primary","aria-disabled":n,"aria-busy":n,children:c(n?"integrations.form.checking":w?"integrations.form.save":"integrations.form.connectBtn")}),i.jsx("button",{type:"button",className:"btn","aria-disabled":n||void 0,onClick:()=>{n||o()},children:c("integrations.cancel")})]})]})})}const zPe="https://id.atlassian.com/manage-profile/security/api-tokens",qPe="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",_Pe="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",LPe=[{scope:"read:jira-work",why:"issues, comments, search",whyKey:"integrations.token.why.work"},{scope:"read:jira-user",why:"your account and avatars",whyKey:"integrations.token.why.user"},{scope:"read:board-scope:jira-software",why:"boards and backlogs",whyKey:"integrations.token.why.board"},{scope:"read:board-scope.admin:jira-software",why:"a board's estimation and quick filters",whyKey:"integrations.token.why.boardAdmin"},{scope:"read:sprint:jira-software",why:"sprints",whyKey:"integrations.token.why.sprint"},{scope:"read:epic:jira-software",why:"epic names and colours",whyKey:"integrations.token.why.epic"},{scope:"read:issue-details:jira",why:"issue lists",whyKey:"integrations.token.why.issueDetails"},{scope:"read:jql:jira",why:"filtered lists",whyKey:"integrations.token.why.jql"}];function PPe(e){const t=e.trim();if(!t)return null;try{const n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`),a=n.hostname==="localhost"||n.hostname==="127.0.0.1";return n.protocol!=="https:"&&!a||!n.hostname.includes(".")&&!a?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens`}catch{return null}}function OPe(){const e=se(),{values:t}=z8(),n=t.deployment==="cloud",a=n?null:PPe(t.baseUrl??"");let s="";try{s=a?new URL(a).host:""}catch{}return i.jsxs(i.Fragment,{children:[n?i.jsxs(i.Fragment,{children:[i.jsx("p",{children:eb(e("integrations.token.cloud.intro"),{link:i.jsx("a",{href:zPe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.cloud.path")}),scoped:i.jsx("em",{children:e("integrations.token.cloud.scoped")})})}),i.jsx("ul",{className:"ig-scopes",children:LPe.map(o=>i.jsxs("li",{children:[i.jsx("code",{children:o.scope})," ",i.jsx("span",{children:e(o.whyKey)})]},o.scope))}),i.jsx("p",{children:i.jsx("a",{href:qPe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.cloud.docs")})})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{children:eb(e("integrations.token.server.intro"),{profile:i.jsx("strong",{children:e("integrations.token.server.profile")}),pats:i.jsx("strong",{children:e("integrations.token.server.pats")}),create:i.jsx("strong",{children:e("integrations.token.server.create")}),page:a?eb(e("integrations.token.server.page"),{link:i.jsx("a",{href:a,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.openOn",{host:s})})}):""})}),i.jsx("p",{children:i.jsx("a",{href:_Pe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.docs")})})]}),i.jsx("p",{className:"ig-dim",children:e("integrations.token.reads")}),n&&i.jsx("p",{className:"ig-dim",children:eb(e("integrations.token.scopedWrite"),{rank:i.jsx("code",{children:"write:issue:jira-software"}),sprint:i.jsx("code",{children:"write:sprint:jira-software"}),backlog:i.jsx("code",{children:"write:board-scope:jira-software"}),work:i.jsx("code",{children:"write:jira-work"})})})]})}function VA(e,t,n="classic"){if(e==="github")return n==="classic"?"https://github.com/settings/tokens/new?scopes=repo,read:org&description=ccdeck":"https://github.com/settings/personal-access-tokens/new";const a=(t??"").trim()||"https://gitlab.com";let s;try{s=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(a)?a:`https://${a}`)}catch{return null}return s.protocol!=="https:"&&s.protocol!=="http:"||!s.hostname.includes(".")&&s.hostname!=="localhost"?null:`${s.origin}${s.pathname.replace(/\/+$/,"")}/-/user_settings/personal_access_tokens?name=ccdeck&scopes=read_api`}function nW(e,t){return e.split(/(\{\w+\})/).map((n,a)=>{var o;const s=(o=/^\{(\w+)\}$/.exec(n))==null?void 0:o[1];return s&&s in t?i.jsx("span",{children:t[s]},a):n})}function KA({href:e,children:t}){return e?i.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",i.jsx(dR,{})]}):null}function q8({kind:e,baseUrl:t}){const{values:n}=z8(),a=se();if(e==="github")return i.jsxs("div",{className:"fg-token-help",children:[i.jsx("p",{children:a("forge.token.gh.intro")}),i.jsxs("ul",{children:[i.jsxs("li",{children:[i.jsx("strong",{children:a("forge.token.gh.classicName")})," ",nW(a("forge.token.gh.classic"),{repo:i.jsx("code",{children:"repo"}),org:i.jsx("code",{children:"read:org"})})," ",i.jsx(KA,{href:VA("github"),children:a("forge.token.makeOne")})]}),i.jsxs("li",{children:[i.jsx("strong",{children:a("forge.token.gh.fineName")})," ",a("forge.token.gh.fine")," ",i.jsx(KA,{href:VA("github",null,"fine-grained"),children:a("forge.token.makeOne")})]})]}),i.jsx("p",{children:a("forge.token.gh.approval")})]});const s=VA("gitlab",t??(n.where==="self"?n.baseUrl:null));return i.jsxs("div",{className:"fg-token-help",children:[i.jsxs("p",{children:[nW(a("forge.token.gl.scope"),{scope:i.jsx("code",{children:"read_api"})})," ",i.jsx(KA,{href:s,children:a("forge.token.makeOn",{host:s?new URL(s).host:"GitLab"})})]}),i.jsx("p",{children:a("forge.token.gl.expire")})]})}const _8={name:"token",type:"password",secret:!0,get label(){return S("forge.field.token")},get placeholder(){return S("forge.field.tokenPlaceholder")}},MPe=[_8],aW=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},IPe=[{name:"where",type:"choice",get label(){return S("forge.field.which")},get options(){return[{value:"cloud",label:"GitLab.com"},{value:"self",label:S("forge.field.selfManaged")}]},initial:e=>aW(e)?"self":"cloud"},{name:"baseUrl",type:"url",placeholder:"https://gitlab.example.com",get label(){return S("forge.field.url")},get hint(){return S("forge.field.urlHint")},when:{field:"where",is:["self"]},initial:e=>aW(e)?e.baseUrl:""},_8],DPe=m.createElement(q8,{kind:"github"}),FPe=m.createElement(q8,{kind:"gitlab"}),BPe=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},UPe={kind:"jira",label:"Jira",Glyph:vge,shortcut:"I",detail:"Boards, sprints, and issues",blurb:"Jira Cloud, or Jira Server / Data Center 8.14 and newer.",fields:[{name:"deployment",label:"Which Jira",type:"choice",options:[{value:"server",label:"Jira Server / Data Center"},{value:"cloud",label:"Jira Cloud"}],initial:BPe},{name:"baseUrl",label:"Jira URL",type:"url",initial:e=>(e==null?void 0:e.baseUrl)??"",variants:{field:"deployment",by:{server:{label:"Jira URL",placeholder:"https://jira.example.com",hint:"The address you open Jira at, with its path if it has one (…/jira). https only."},cloud:{label:"Site URL",placeholder:"your-site.atlassian.net",hint:"The address you open Jira at. Your site name alone is enough."}}}},{name:"email",label:"Atlassian account email",type:"email",placeholder:"you@example.com",autoComplete:"username",secret:!0,when:{field:"deployment",is:["cloud"]}},{name:"token",label:"Personal access token",type:"password",secret:!0,variants:{field:"deployment",by:{server:{label:"Personal access token",placeholder:"Paste the token"},cloud:{label:"API token",placeholder:"Paste the API token"}}}}],tokenHelp:m.createElement(OPe)},WPe={kind:"github",label:"GitHub",Glyph:wge,detail:"Repositories, pull requests, and Actions",blurb:"github.com, read-only, with a personal access token.",fields:MPe,tokenHelp:DPe},HPe={kind:"gitlab",label:"GitLab",Glyph:yge,detail:"Projects, merge requests, and pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:IPe,tokenHelp:FPe},dE={jira:UPe,github:WPe,gitlab:HPe},Az=()=>Object.values(dE).filter(e=>!!e);function Ep(e){return(Object.hasOwn(dE,e)?dE[e]:void 0)??null}function Xv(e,t){const n=a=>typeof t=="string"?t:t(a);return m.lazy(()=>e().catch(a=>(console.warn(`ccdeck could not load ${typeof t=="string"?t:"a dialog"}`,a),{default:s=>i.jsx(GPe,{name:n(s),onClose:s.onClose})})))}function GPe({name:e,onClose:t}){const n=se(),a=m.useRef(null),s=Zt(t,{focusRef:a}),o=tn(t);return i.jsxs(dn,{scrim:o,dialogRef:s,className:"dialog-missing",labelledBy:"dialog-missing-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:t,label:n("shell.closeEsc")})})]}),i.jsx("section",{className:"modal-body",children:i.jsx("p",{className:"dm-note",children:n("shell.lazy.didNotLoad",{name:e})})}),i.jsxs("footer",{className:"modal-foot",children:[i.jsx("button",{type:"button",className:"btn",onClick:t,children:n("shell.close")}),i.jsx("button",{type:"button",ref:a,className:"btn primary",onClick:()=>window.location.reload(),children:n("shell.reload")})]})]})}const L8=()=>Xs(()=>import("./IntegrationModal-CKgtTF3f.js"),__vite__mapDeps([2,3]));function VPe(){L8().catch(()=>{})}const KPe=Xv(L8,e=>{var t;return((t=Ep(e.kind))==null?void 0:t.label)??S("integrations.modal.tracker")});function $Pe({onClose:e}){const t=a5();return m.useEffect(()=>t?void 0:Rn.push(e,0,"dialog"),[e,t]),null}function JPe(e){return i.jsx(m.Suspense,{fallback:i.jsx($Pe,{onClose:e.onClose}),children:i.jsx(KPe,{...e})})}const sW={"The deck failed while reading the tracker.":"integrations.srv.deckFailed","The answer was larger than the deck accepts.":"integrations.srv.tooLarge","Enter a token.":"integrations.srv.enterToken","Enter an API token.":"integrations.srv.enterApiToken","Enter a personal access token.":"integrations.srv.enterPat","The token has a space in it. Paste it again.":"integrations.srv.tokenSpace","Enter the email address of your Atlassian account.":"integrations.srv.enterEmail","Choose Jira Cloud or Jira Server / Data Center.":"integrations.srv.chooseDeployment","Enter your Jira site URL.":"integrations.srv.enterSiteUrl","Enter your Jira URL.":"integrations.srv.enterJiraUrl","Enter your GitLab's address.":"integrations.srv.enterGitlabUrl","Your Jira site URL is not a valid URL.":"integrations.srv.badSiteUrl","Your Jira URL is not a valid URL.":"integrations.srv.badJiraUrl","Your GitLab's address is not a valid URL.":"integrations.srv.badGitlabUrl","Leave the user name and password out of the address.":"integrations.srv.urlUser","Use an https:// address. Plain http is only accepted for a server on this machine.":"integrations.srv.httpsOnly","Use an https:// address.":"integrations.srv.httpsAddress","That connection is not there any more.":"integrations.srv.connectionGone","No token is saved for this connection. Edit it and enter one.":"integrations.srv.noTokenEdit","No token is saved for this connection. Reconnect it in Settings.":"integrations.srv.noTokenReconnect","Enter a comment of up to 10,000 characters.":"integrations.srv.commentLength","This Jira write is outside the connection's token origins.":"integrations.srv.writeOutside","Jira redirected the comment. Refresh the issue before sending again.":"integrations.srv.commentRedirected","The comment could not be confirmed. Refresh the issue before sending again.":"integrations.srv.commentUnconfirmed","Jira redirected the write. It was not replayed; refresh the board before trying again.":"integrations.srv.writeRedirected","Jira's rank result was too large. Refresh the board to check its position.":"integrations.srv.rankTooLarge","Jira did not confirm every requested issue update. Some issues may have changed; refresh the board to check them.":"integrations.srv.updateUnconfirmed","Jira did not confirm the write. Refresh the board to check the issue.":"integrations.srv.writeUnconfirmed","Jira refused the move: the account or token needs permission to edit and schedule this issue.":"integrations.srv.moveRefused","Jira did not return its available transitions.":"integrations.srv.transitionsMissing","Choose a valid transition.":"integrations.srv.transitionChoose","This transition is unavailable or requires additional fields in Jira.":"integrations.srv.transitionUnavailable","Jira redirected the transition. Refresh the issue before trying again.":"integrations.srv.transitionRedirected","Jira did not confirm the transition. Refresh the issue.":"integrations.srv.transitionUnconfirmed","There is no Jira REST API at this address. Check the URL — some servers live under a path such as /jira.":"integrations.srv.noRestApi","This is a Jira Cloud site. Choose Jira Cloud and connect with your email and an API token.":"integrations.srv.isCloud","This is Jira Server or Data Center, not Cloud. Choose Jira Server / Data Center and use a personal access token.":"integrations.srv.isServer","Jira did not accept this email and API token, on the site or through api.atlassian.com. Check both, and that the token has not expired.":"integrations.srv.emailTokenRefused","Jira wants a CAPTCHA after too many failed sign-ins. Sign in to Jira once in your browser, then test the connection again.":"integrations.srv.captcha","Jira did not accept this personal access token: it answered as an anonymous visitor. Check that the token is right and has not expired or been revoked.":"integrations.srv.patAnonymous","That quick filter is not on this board any more. Refresh the board.":"integrations.srv.quickFilterGone","Jira writes are unavailable because this system cannot safely coordinate them.":"integrations.srv.writesUnavailable","Supply either one issueKey or 2–50 ordered issueKeys and a sprint or backlog target.":"integrations.srv.moveWhere","Supply unique, valid issue keys (2–50 for a batch).":"integrations.srv.moveKeys","Not a valid issue key or move target.":"integrations.srv.moveTarget","Use at most one other issue as the rank anchor.":"integrations.srv.moveAnchor","The issues and anchor must all belong to this board.":"integrations.srv.moveSameBoard","The issues and rank anchor must be top-level issues.":"integrations.srv.moveTopLevel","Only top-level non-epic issues with a known status can be moved.":"integrations.srv.moveEpicStatus","Done issues cannot be moved to the backlog because Jira hides them there. Change the status first.":"integrations.srv.moveDone","Every issue must be in the backlog or one active or future sprint.":"integrations.srv.moveSource","The source and target must be active or future sprints on this board.":"integrations.srv.moveSprints","An issue's source changed or is a closed sprint. Refresh the board.":"integrations.srv.moveSourceChanged","Could not determine the destination's last issue. Refresh and try again.":"integrations.srv.moveLastIssue","Could not verify the destination order. Refresh and try again.":"integrations.srv.moveOrder","The destination is too large to determine the last issue. Refresh and try again.":"integrations.srv.moveDestinationLarge","The rank anchor must be in the target group. Refresh the board.":"integrations.srv.moveAnchorGroup","This server runs Jira of an unknown version. Personal access tokens need Jira Server or Data Center 8.14 or newer, so the deck cannot connect to it.":"integrations.srv.serverOldUnknown","too many redirects":"forge.srv.redirects","answer too large":"forge.srv.answerLarge","answer cut off":"forge.srv.answerCut","unreadable JSON":"forge.srv.badJson","log too large to read the end of":"forge.srv.logLarge","image too large":"forge.srv.imageLarge","image cut off":"forge.srv.imageCut","that cursor is not a page of this list":"forge.srv.cursorPage","that cursor is not one of this list":"forge.srv.cursorList"},YPe=[[/^The deck could not verify (Jira|GitHub|GitLab)'s HTTPS certificate \((.+?)\)\. Check that the address is right and that the server's certificate is valid for it\.$/,"integrations.srv.tlsCert",["provider","code"]],[/^(Jira|GitHub|GitLab) did not answer in time\.$/,"integrations.srv.timeout",["provider"]],[/^The deck could not find (Jira|GitHub|GitLab)'s address\. Check the URL and your network\.$/,"integrations.srv.noAddress",["provider"]],[/^The deck could not reach (Jira|GitHub|GitLab) \((.+?)\)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReachCode",["provider","code"]],[/^The deck could not reach (Jira|GitHub|GitLab)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReach",["provider"]],[/^(Jira|GitHub|GitLab) did not accept these credentials\.$/,"integrations.srv.noCredentials",["provider"]],[/^(Jira|GitHub|GitLab) no longer accepts the saved token\. It may have expired or been revoked — reconnect with a new one\.$/,"integrations.srv.tokenGone",["provider"]],[/^(Jira|GitHub|GitLab) refused: the account or token is not allowed to read this\.$/,"integrations.srv.notAllowed",["provider"]],[/^(Jira|GitHub|GitLab) is limiting requests\. Try again in (\d+) s\.$/,"integrations.srv.limiting",["provider","n"]],[/^(Jira|GitHub|GitLab) has no such page or record, or this account cannot see it\.$/,"integrations.srv.noSuchPage",["provider"]],[/^(Jira|GitHub|GitLab) refused the request\.$/,"integrations.srv.refusedRequest",["provider"]],[/^(Jira|GitHub|GitLab) is not answering right now \((\d+)\)\. Try again shortly\.$/,"integrations.srv.notAnswering",["provider","status"]],[/^(Jira|GitHub|GitLab) answered (\d+)\.$/,"integrations.srv.answered",["provider","status"]],[/^The deck only sends this connection's token to (.+)\.$/,"integrations.srv.tokenOrigins",["origins"]],[/^(Jira|GitHub|GitLab) redirected to (\S+?), and the deck does not send the token there\. Check the address you connected\.$/,"integrations.srv.redirectedAway",["provider","origin"]],[/^(Jira|GitHub|GitLab) redirected too many times\.$/,"integrations.srv.redirectedMany",["provider"]],[/^(Jira|GitHub|GitLab) answered with something that is not JSON\. Check that the address is the \1 site itself\.$/,"integrations.srv.notJson",["provider"]],[/^The deck will not send a token to (\S+?)\.$/,"integrations.srv.noTokenTo",["origin"]],[/^This server runs Jira (.+?)\. Personal access tokens need Jira Server or Data Center 8\.14 or newer, so the deck cannot connect to it\.$/,"integrations.srv.serverOld",["version"]],[/^(Jira|GitHub|GitLab) is not available on this deck\.$/,"integrations.srv.notOnDeck",["provider"]],[/^(\S+?) did not answer in time$/,"forge.srv.timeout",["origin"]],[/^(\S+?): the certificate is not trusted \((.+?)\)$/,"forge.srv.cert",["origin","code"]],[/^(\S+?): no answer$/,"forge.srv.noAnswer",["origin"]],[/^(\S+?) is not a host this connection reads from$/,"forge.srv.notHost",["origin"]],[/^(\S+?) sent this read to (\S+?), not to this connection's address$/,"forge.srv.sentElsewhere",["origin","next"]],[/^(\S+?) answered (.+?), not the API$/,"forge.srv.notApi",["origin","type"]],[/^not an image \((.+?)\)$/,"forge.srv.notImage",["type"]]];function ZPe(e,t=S){if(!e)return"";const n=e.replace(/\u2019/g,"'"),a=Object.hasOwn(sW,n)?sW[n]:void 0;if(a)return t(a);for(const[s,o,r]of YPe){const c=s.exec(n);if(!c)continue;const l={};return r.forEach((u,h)=>{l[u]=c[h+1]}),t(o,l)}return e}function XPe(e){if(!e||typeof e!="object")return;const t=e;if(!(typeof t.operationId!="string"||!/^[0-9a-f-]{36}$/.test(t.operationId)||typeof t.connectionId!="string"||!["comment","status","move"].includes(t.kind)||!["pending","uncertain","confirmed"].includes(t.state))&&!(t.kind==="move"?!Array.isArray(t.issueKeys)||!t.issueKeys.every(n=>typeof n=="string"):typeof t.issueKey!="string"))return t}class Ks extends $n{constructor(n,a,s={}){super(a);Ss(this,"kind");Ss(this,"operation");Ss(this,"status");Ss(this,"retryAfter");Ss(this,"field");Ss(this,"detail");Ss(this,"refreshRequired");Ss(this,"outcomes");Ss(this,"moveOutcome");this.name="IntegrationFailure",this.kind=n,Object.assign(this,s)}}async function P8(e){try{const t=await e.json(),n=t==null?void 0:t.error,a=XPe(t==null?void 0:t.operation);if((t==null?void 0:t.code)==="jira_write_guard_conflict")return new Ks("upstream",S("integrations.error.writeAwaiting"),{status:e.status,operation:a});if(n&&typeof n.kind=="string"&&typeof n.message=="string"){const s=Array.isArray(t.outcomes)?t.outcomes.slice(0,50).filter(c=>{if(!c||typeof c!="object")return!1;const l=c;return typeof l.issueKey=="string"&&/^[A-Z][A-Z0-9_]{0,40}-[1-9]\d{0,11}$/.test(l.issueKey)&&["moved","unchanged","unknown"].includes(String(l.membership))&&["ranked","unchanged","failed","unknown"].includes(String(l.rank))}).map(c=>({issueKey:c.issueKey,membership:c.membership,rank:c.rank})):[],o=t.outcome,r=o&&["moved","unchanged","unknown"].includes(o.membership)&&["ranked","unchanged","failed","unknown"].includes(o.rank)?{membership:o.membership,rank:o.rank}:void 0;return new Ks(n.kind,ZPe(n.message),{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail,...t.refresh===!0?{refreshRequired:!0}:{},...s.length?{outcomes:s}:{},...r?{moveOutcome:r}:{},...a?{operation:a}:{}})}}catch{}return new Ks(e.status===401?"auth":"upstream",S("integrations.error.deckAnswered",{status:e.status}))}async function Zg(e,t={}){const{timeoutMs:n=3e4,...a}=t;return O8(a.signal,n,async s=>{let o;try{o=await fetch(e,{...a,signal:s,headers:a.body?{"Content-Type":"application/json",...a.headers??{}}:a.headers})}catch(r){throw s.aborted?r:new Ks("network",S("integrations.error.unreachable"))}if(!o.ok)throw await P8(o);return o.json()})}async function O8(e,t,n){const a=new AbortController,s=window.setTimeout(()=>a.abort(),t),o=()=>a.abort(e==null?void 0:e.reason);e==null||e.addEventListener("abort",o,{once:!0}),e!=null&&e.aborted&&o();try{return a.signal.throwIfAborted(),await n(a.signal)}catch(r){throw e!=null&&e.aborted?e.reason??r:a.signal.aborted?new Ks("network",S("integrations.error.timeout")):r}finally{window.clearTimeout(s),e==null||e.removeEventListener("abort",o)}}const M8=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function T4e(e){const t=M8(e);return(n,a)=>fetch(`${t}${n.replace(/^\/+/,"")}`,a)}function N4e(e){const t=M8(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function A4e(e,t){if(!t)return null;try{const n=new URL(t);return n.username||n.password||n.protocol!=="https:"&&n.protocol!=="http:"?null:n.origin===new URL(e.baseUrl).origin?n.href:null}catch{return null}}function j4e(e){const t=new URLSearchParams;for(const[a,s]of Object.entries(e))s===void 0||s===""||s===!1||t.set(a,s===!0?"1":String(s));const n=t.toString();return n?`?${n}`:""}async function E4e(e,t,{signal:n,timeoutMs:a=45e3}={}){return O8(n,a,async s=>{let o;try{o=await e(t,{signal:s,headers:{Accept:"application/json"}})}catch(r){throw s.aborted?r:new Ks("network",S("integrations.error.unreachable"))}if(!o.ok)throw await P8(o);try{return await o.json()}catch(r){throw s.aborted?r:new Ks("upstream",S("integrations.error.notJson"))}})}let ar={connections:null,providers:[],error:""};const nu=new Set;let tb=null,ap=null,hu=null,iW=0;const QPe=5e3,eOe=3;function Nk(e){ar={...ar,...e},nu.forEach(t=>t(ar))}function Qv(){return ap||(ap=(async()=>{try{const e=await Zg("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new Ks("upstream",S("integrations.error.notList"));Nk({connections:t,providers:n,error:""})}catch(e){Nk({error:rr(e,S("integrations.error.readConnections"))}),ar.connections===null&&nu.size>0&&hu===null&&iW<eOe&&(hu=window.setTimeout(()=>{hu=null,Qv()},QPe*2**iW++))}finally{ap=null}})(),ap)}function tOe(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function oW(){tOe(ar)&&Qv()}function jz(e){const t=ar.connections??[],n=t.findIndex(a=>a.id===e.id);Nk({connections:n<0?[...t,e]:t.map(a=>a.id===e.id?e:a)})}function nOe(e){Nk({connections:(ar.connections??[]).filter(t=>t.id!==e)})}function Xg(){const[e,t]=m.useState(ar);return m.useEffect(()=>{nu.add(t),t(ar);const n=()=>{document.visibilityState==="visible"&&oW()};return nu.size===1&&(Qv(),tb=window.setInterval(oW,6e4),document.addEventListener("visibilitychange",n)),()=>{nu.delete(t),nu.size===0&&(tb!==null&&window.clearInterval(tb),tb=null,hu!==null&&window.clearTimeout(hu),hu=null,document.removeEventListener("visibilitychange",n))}},[]),e}function Ak(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function Qg(e){return e.connections===null?new Set:new Set(e.providers.filter(t=>(t==null?void 0:t.available)===!0).map(t=>t.kind))}function Qo(e,t){return Qg(e).has(t)}function uE(e,t){return Qo(e,t)&&Ak(e,t).length>0}function Ez(e){return Qg(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function aOe(e,t,n){const a=await Zg("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return jz(a.connection),a.connection}async function sOe(e,t){const n=await Zg(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return jz(n.connection),n}async function iOe(e){const t=await Zg(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return jz(t.connection),t.connection}async function oOe(e){await Zg(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),nOe(e)}function Yc(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function R4e(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length?(t.length===1?t[0].slice(0,2):`${t[0][0]}${t[t.length-1][0]}`).toUpperCase():"?"}let jk=null,Ek=null;function rW(e){Ek=null,jk=e}function rOe(e){jk=null,Ek=e}function cOe(){const e=Ek;return Ek=null,e}function lOe(){const e=jk;return jk=null,e}const dOe={jira:"integrations.explore.cap.jira",github:"integrations.explore.cap.github",gitlab:"integrations.explore.cap.gitlab"},uOe={jira:"integrations.explore.access.jira",github:"integrations.explore.access.read",gitlab:"integrations.explore.access.read"};function hOe(){return Array.from(document.querySelectorAll('[data-rail-item="explore-integrations"], [data-rail-item="more"]')).find(e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0)??null}function pOe({integrations:e,onClose:t,onOpen:n,onConnect:a,onManage:s}){const o=se(),r=Zt(t,{restoreFocusFallback:hOe}),c=tn(t),l=Az().filter(p=>e.providers.some(f=>f.kind===p.kind)||Ak(e,p.kind).length>0),u=l.filter(p=>uE(e,p.kind)).length,h=p=>{t(),p()};return $t.createPortal(i.jsxs(dn,{scrim:c,dialogRef:r,className:"explore-integrations",labelledBy:"explore-integrations-title","aria-describedby":"explore-integrations-description",children:[i.jsxs("div",{className:"modal-head explore-head",children:[i.jsx("h2",{id:"explore-integrations-title",children:o("integrations.explore.title")}),i.jsx("button",{type:"button",className:"glyph-btn","aria-label":o("integrations.explore.closeAria"),title:o("integrations.closeEsc"),onClick:t,children:"×"})]}),i.jsxs("div",{className:"explore-body",children:[i.jsx("p",{id:"explore-integrations-description",className:"explore-intro",children:o("integrations.explore.intro")}),e.error&&e.connections!==null&&i.jsxs("p",{className:"explore-status","data-tone":"err",role:"alert",children:[e.error," ",o("integrations.explore.stale")]}),e.connections===null?e.error?i.jsx("p",{className:"explore-status","data-tone":"err",role:"alert",title:e.error,children:o("integrations.explore.statusUnavailable")}):i.jsx("p",{className:"explore-status",role:"status",children:i.jsxs("span",{className:"loader-line",children:[i.jsx(Fg,{busy:!0}),o("integrations.explore.reading")]})}):l.length===0?i.jsx("p",{className:"explore-status",role:"status",children:o("integrations.explore.none")}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"explore-caption",children:[i.jsx("span",{children:o("integrations.explore.available")}),i.jsx("span",{children:o("integrations.explore.connectedCount",{n:u})})]}),i.jsx("ul",{className:"explore-providers",children:l.map(p=>{const f=Qo(e,p.kind),b=uE(e,p.kind),v=Ak(e,p.kind)[0];return i.jsxs("li",{className:"explore-provider",children:[i.jsxs("div",{className:"explore-info",children:[i.jsxs("div",{className:"explore-name",children:[i.jsx("h3",{children:p.label}),i.jsx("span",{className:"explore-tag",children:o(uOe[p.kind])})]}),i.jsx("p",{children:o(dOe[p.kind])})]}),i.jsx("span",{className:"explore-connection",children:o(f?b?"integrations.explore.connected":"integrations.explore.notConnected":"integrations.explore.unavailableOnDeck")}),i.jsx("div",{className:"explore-actions",children:b?i.jsx("button",{type:"button",className:"btn primary","aria-label":o("integrations.explore.openAria",{label:p.label}),onClick:()=>h(()=>n(p.kind)),children:o("integrations.explore.open")}):f?i.jsx("button",{type:"button",className:"btn","aria-label":o("integrations.form.connect",{provider:p.label}),onClick:()=>h(()=>a(p.kind)),children:o("integrations.form.connectBtn")}):v?i.jsx("button",{type:"button",className:"explore-text-action","aria-label":o("integrations.manageProvider",{label:p.label}),onClick:()=>h(()=>s(v.id)),children:o("integrations.manage")}):i.jsx("span",{className:"explore-unavailable",children:o("integrations.explore.notAvailable")})})]},p.kind)})})]}),i.jsx("p",{className:"explore-footnote",children:o("integrations.explore.footer")})]}),i.jsxs("div",{className:"explore-footer",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>h(()=>s()),children:o("integrations.explore.manageInSettings")}),i.jsx("button",{type:"button",className:"btn primary",onClick:t,children:o("shell.done")})]})]}),document.body)}const gOe="board.counts.working",mOe="board.counts.done";function fOe(e){const t={waiting:0,working:0,done:0};for(const n of e){if(n.kind!=="root")continue;const a=cu(n).tone;a==="waiting"?t.waiting++:a==="active"?t.working++:a==="done"&&t.done++}return t}function cW(e,t=S){const n=Math.max(0,Math.floor(e));return t("board.pill.events",{count:n})}const lW=99;function bOe(e){const t=Math.max(0,Math.floor(e));return t>lW?`${lW}+`:String(t)}function kOe(e,t=S){return e.connected||!e.paused?null:t("board.pill.outage")}const I8=e=>e("board.pill.pausedFull"),vOe=(e,t,n)=>t>0?I8(n):e>0?n("board.pill.pausedCount",{held:bOe(e)}):n("board.pill.paused");function wOe(e,t=S){const n=Math.max(0,Math.floor(e.dropped??0)),a=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:vOe(e.held,n,t),widest:I8(t),title:bo(n>0?t("board.pill.title.connectedFull",{held:cW(e.held,t)}):e.held>0?t("board.pill.title.connectedHeld",{held:cW(e.held,t)}):t("board.pill.title.connectedNone"),"Space",a)}:{tone:"live",resting:!0,label:t("board.pill.live"),widest:t("board.pill.live"),title:t("board.pill.title.live")}:{tone:"dead",resting:!1,label:t("board.pill.offline"),widest:t("board.pill.offline"),title:e.paused?t("board.pill.title.offlinePaused"):t("board.pill.title.offline")}}function yOe(e,t=S){return e.tool?e.tool.name:e.kind==="asked"?t("board.queue.question"):t("board.queue.permission")}const xOe=20;function COe(e,t=xOe){if(e.length<=t)return e;const n=Math.floor((t-1)*.4),a=t-1-n;return`${e.slice(0,a)}…${e.slice(e.length-n)}`}function SOe(e,t=S){const n=Math.floor(Math.max(0,e)/6e4);if(n<1)return t("board.queue.lessThanMinute");if(n<60)return t("board.queue.minutes",{count:n});const a=Math.floor(n/60),s=n%60;return s===0?t("board.queue.hours",{count:a}):t("board.queue.hoursMinutes",{h:t("board.queue.hours",{count:a}),m:t("board.queue.minutes",{count:s})})}function TOe(e,t,n,a=S){var r;const s=SOe(n,a),o=t.tool?"board.queue.entry.tool":t.kind==="asked"?"board.queue.entry.answer":"board.queue.entry.permission";return a(o,{label:e,wait:s,tool:((r=t.tool)==null?void 0:r.name)??""})}const NOe=new Set(["idle","checking","current","downloading","ready","error"]);function dW(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!NOe.has(t.status))return null;const n=typeof t.version=="string"&&t.version.trim()?t.version.trim():null;return t.status==="ready"&&!n?null:{status:t.status,version:n}}function AOe(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function D8(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const jOe="shell.desktop.restartToUpdate",Rk=()=>S(jOe),F8=3e4;function B8(e=typeof navigator>"u"?"":navigator.userAgent){return/\bMac OS X\b|\bMacintosh\b/.test(e)?S("shell.desktop.menuMac"):S("shell.desktop.menuTray")}const EOe="shell.desktop.restartToFinish";function ROe(e,t,n=!1){return{text:S(n?"shell.notes.restarting":EOe),title:`v${e} → v${t} · ${S("shell.desktop.restartTitle",{to:t})}`}}function zOe(e,t=!1){return{text:t?S("shell.notes.restarting"):Rk(),label:t?void 0:S("shell.desktop.restartLabel",{action:Rk(),to:e}),title:S("shell.desktop.restartTitle",{to:e})}}function qOe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function U8(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const a=B8(n),s=Rk(),o=S("shell.desktop.way",{action:s,menu:a});switch(e){case"app_disconnected":return S("shell.desktop.fail.app_disconnected",{way:o});case"update_not_ready":return S("shell.desktop.fail.update_not_ready",{version:t,action:s,menu:a});case"timeout":return S("shell.desktop.fail.timeout",{seconds:F8/1e3,way:o});case"refused":return S("shell.desktop.fail.refused",{way:o});case"unreachable":return S("shell.desktop.fail.unreachable",{way:o})}}function _Oe(e){const t=e.kind==="restart"?S("shell.chip.noticeRestart",{to:e.to}):S("shell.chip.noticeUpgrade",{to:e.to}),n=e.open?S("shell.chip.noticeShow"):S("shell.chip.noticeShowBanner");return S("shell.chip.noticeLabel",{text:W8(e),from:e.from,what:t,does:n})}function W8(e){return e.kind==="restart"?S("shell.chip.textRestart",{to:e.to}):S("shell.chip.textUpgrade",{to:e.to})}function H8(e){return e?`${e.kind}:${e.to}`:""}function LOe(e,t){return e!=null&&t!==H8(e)}function G8(e){return!!e.readyAppUpdate||!!e.notice}function POe({readyAppUpdate:e,notice:t,noticeOpen:n,chipVersion:a,openReleaseNotes:s,showNotice:o,restartToUpdate:r,updateRestarting:c=!1}){return Es(),G8({readyAppUpdate:e,notice:t})?i.jsx(i.Fragment,{children:e?(()=>{const l=ROe(D8()??a,e.version,c);return i.jsxs("button",{type:"button",className:"v ready",onClick:()=>r(e.version),"aria-busy":c||void 0,title:l.title,children:[i.jsx("span",{className:"v-icon","aria-hidden":!0,children:i.jsx(Ze,{name:"restart"})}),l.text]})})():t?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{s(),o()},"aria-haspopup":"dialog","aria-label":_Oe({...t,open:n}),title:t.kind==="restart"?S("shell.chip.runningRestart",{from:t.from,to:t.to}):S("shell.chip.runningUpgrade",{from:t.from,to:t.to}),children:[i.jsx("span",{className:"v-icon","aria-hidden":!0,children:i.jsx(Ze,{name:"update"})}),W8(t)]}):null}):null}function OOe({live:e,paused:t,pauseGate:n}){const a=se(),s=sa(),o=wOe({connected:e,paused:t,held:n.size,dropped:n.dropped,singleKeys:s},a);return i.jsx(uR,{show:!o.resting,className:"status",children:!o.resting&&i.jsx("span",{className:`pill ${o.tone}`,title:o.title,children:i.jsx("span",{className:"pill-label",children:o.label})})})}function MOe({w:e,now:t}){const n=se();return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"we-name",children:COe(e.name??e.label)}),i.jsx("span",{className:"we-wait",children:sde(e.waiting.since,void 0,t)}),i.jsxs("span",{className:"we-what",children:["· ",yOe(e.waiting,n)]})]})}function IOe(e){const[t,n]=Array.from(e.children);if(!t)return 0;const a=n?n.offsetTop-t.offsetTop:t.offsetHeight;return a<=0?e.children.length:Math.floor((e.clientHeight+a-t.offsetHeight)/a)}const hE="waiting-pill",V8="queue-pop",DOe=150;function K8(){return typeof document<"u"&&document.documentElement.dataset.motion==="instant"}function FOe({sessions:e,now:t,leaving:n,onPick:a,onClose:s}){const o=se(),r=sa(),[c,l]=m.useState(!1);m.useLayoutEffect(()=>{if(K8()){l(!0);return}let b=requestAnimationFrame(()=>{b=requestAnimationFrame(()=>l(!0))});return()=>cancelAnimationFrame(b)},[]);const u=m.useRef(null),h=m.useRef(0),[p,f]=m.useState(0);return m.useLayoutEffect(()=>{const b=u.current;if(b){if(b.scrollHeight<=b.clientHeight+1){f(0);return}b.scrollTop=h.current,f(Math.max(0,e.length-IOe(b)))}}),i.jsxs(Rs,{anchorId:hE,id:V8,role:"menu",labelledBy:hE,align:"start",className:n?"queue-pop queue-pop-leaving":c?"queue-pop queue-pop-open":"queue-pop",onClose:s,children:[i.jsx("div",{className:"queue-head","aria-hidden":!0,children:o("board.queue.title")}),i.jsx("div",{className:"queue-rows",ref:u,onScroll:b=>{h.current=b.currentTarget.scrollTop},children:e.map(b=>i.jsxs("button",{type:"button",role:"menuitem",className:"queue-row",onClick:()=>a(b.id),"aria-label":TOe(b.name??b.label,b.waiting,t-b.waiting.since,o),children:[i.jsx(ic,{size:14}),i.jsx(MOe,{w:b,now:t})]},b.id))}),p>0&&i.jsxs("div",{className:"queue-foot","aria-hidden":!0,children:[i.jsx("span",{children:o("board.queue.more",{n:p})}),r&&i.jsx(lu,{children:"n"})]})]})}const BOe={working:"count-pill count-working",done:"count-pill count-done"};function uW({kind:e,count:t,glyph:n,word:a}){return t===0?null:i.jsxs("span",{className:BOe[e],children:[n,i.jsx("b",{children:t}),i.jsx("span",{className:"count-word",children:a})]})}function UOe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:a}){const s=se(),o=sa(),r=qg("below"),c=e.length,[l,u]=m.useState("closed"),h=m.useRef(l);h.current=l;const p=m.useRef(void 0);m.useEffect(()=>()=>window.clearTimeout(p.current),[]);const f=m.useCallback(()=>{if(h.current==="open"){if(K8()){u("closed");return}u("leaving"),window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("closed"),DOe)}},[]);if(m.useEffect(()=>{c===0&&l!=="closed"&&u("closed")},[c,l]),c===0)return null;const b=s("board.queue.waitingForYou",{count:c});return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",id:hE,className:"count-pill waiting-stat",onClick:()=>{h.current==="closed"?u("open"):f()},onKeyDown:v=>{v.key==="ArrowDown"&&h.current==="closed"&&(v.preventDefault(),u("open"))},"aria-label":b,"aria-haspopup":"menu","aria-expanded":l==="open","aria-controls":l!=="closed"?V8:void 0,"aria-keyshortcuts":o?"W":void 0,...r.bind({label:b,keys:o?"W":void 0}),children:[i.jsx(ic,{size:14}),i.jsx("b",{children:c}),i.jsx("span",{className:"count-word",children:s("board.queue.waiting")})]}),r.node,l!=="closed"&&i.jsx(FOe,{sessions:e,now:a,leaving:l==="leaving",onClose:f,onPick:v=>{t.current=v,f(),n(v)}})]})}const WOe={on:"board.notify.means.on",blocked:"board.notify.means.blocked"};function HOe(e,t=S){return e==="on"?t("board.notify.said.on"):e==="blocked"?t("board.notify.said.blocked"):""}function GOe({notifySaid:e}){const t=se();return i.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:t(WOe[e]),children:t(e==="on"?"board.notify.on":"board.notify.blocked")})}function VOe({versionCheck:e,welcome:t,desktopUpdate:n,pause:a,announcements:s,notify:o,waitingSessions:r,waitingCursorRef:c,focusSession:l,live:u,now:h,incidents:p,counts:f,asksSaid:b,children:v}){const{notice:w,noticeOpen:T,showNotice:y}=e,{chipVersion:x,openReleaseNotes:C}=t,{readyAppUpdate:A,desktopUpdateRestarting:E,desktopUpdateFailure:R,askDesktopUpdateRestart:z}=n,I=m.useRef(!1);m.useEffect(()=>{E||!I.current||(I.current=!1,R&&C())},[E,R,C]);const _=H=>{I.current=!0,z(H)},{paused:D,pauseGate:L}=a,P=se(),{blockedSaid:O,watchSaid:j,incidentSaid:M}=s,{notifySaid:F}=o,U=Tg();return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"readout",children:[i.jsxs("div",{className:"brand",children:[i.jsx("img",{className:"logo logo-on-dark",src:Eke,width:19,height:16,alt:""}),i.jsx("img",{className:"logo logo-on-light",src:Rke,width:19,height:16,alt:""}),i.jsx("h1",{children:an})]}),!U&&r.length+f.working+f.done>0&&i.jsxs("div",{className:"counts",children:[i.jsx(UOe,{waitingSessions:r,waitingCursorRef:c,focusSession:l,now:h}),i.jsx(uW,{kind:"working",count:f.working,glyph:i.jsx(yi,{kind:"live",size:14}),word:P(gOe,{count:f.working})}),i.jsx(uW,{kind:"done",count:f.done,glyph:i.jsx(yi,{kind:"done",size:14}),word:P(mOe,{count:f.done})})]}),i.jsx(OOe,{live:u,paused:D,pauseGate:L}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:j}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:HOe(F,P)}),b!=null&&i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:b}),i.jsx(Uke,{incidents:p}),F&&i.jsx(GOe,{notifySaid:F})]}),i.jsxs("div",{className:"tb-end",children:[i.jsx(uR,{show:G8({readyAppUpdate:A,notice:w}),children:i.jsx("span",{className:"v-group",children:i.jsx(POe,{readyAppUpdate:A,notice:w,noticeOpen:T,chipVersion:x,openReleaseNotes:C,showNotice:y,restartToUpdate:_,updateRestarting:E})})}),v]})]})}function KOe(e,t,n={},a=S){var r;const s=[];for(const c of uv(e,t,n.watching)){const l=e.agents.get(c.sessionId);if(!l||(r=n.removed)!=null&&r.has(c.sessionId)||!Ng(l,t))continue;const u={...c};delete u.twin,s.push({row:u,group:Eu(u),status:Eg(l,a)})}const o=ov(s.map(c=>({id:c.row.sessionId,title:c.row.label,task:c.row.task,startedAt:c.row.startedAt})));for(const c of s){const l=o.get(c.row.sessionId);l&&(c.row.twin=l)}return s}function $Oe(e,t,n){return{model:e.modelId?Rg(e.modelId,e.effort):null,time:k5(e,t,n)}}function JOe({state:e,now:t,watching:n,removedIds:a,selectedIds:s,onOpen:o}){const r=se(),c=Es(),l=lG(),u=n?[...n].sort().join(`
|
|
154
|
+
`):"",h=m.useMemo(()=>KOe(e,t,{watching:n,removed:a},r),[e,e.revision,t,l,u,a,c]),[p,f]=m.useState(!1),b=m.useRef([]),v=h.map(y=>({id:y.row.sessionId,group:y.group})),w=p&&b.current.length>0?X4(b.current,v).order:v;if(b.current=w,h.length===0)return null;const T=new Map(h.map(y=>[y.row.sessionId,y]));return i.jsx("ul",{className:"phone-board",role:"list","aria-label":r("board.phone.stack"),onPointerEnter:()=>f(!0),onPointerLeave:()=>f(!1),children:w.map(y=>i.jsx("li",{className:"pb-item",children:i.jsx(YOe,{card:T.get(y.id),now:t,selected:(s==null?void 0:s.has(y.id))??!1,onOpen:o})},y.id))})}function YOe({card:e,now:t,selected:n,onOpen:a}){const{row:s,group:o,status:r}=e,c=b5(s,o),{model:l,time:u}=$Oe(s,o,t),h=[l,u&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"vis-hidden",children:[u.spoken," "]}),u.text]}),s.twin&&i.jsx("span",{className:"pb-start",children:Nu(s.startedAt,s.twin)})].filter(Boolean);return i.jsxs("button",{type:"button",className:`pb-card${n?" selected":""}`,"data-session":s.sessionId,"data-tone":r.tone,"aria-current":n?"true":void 0,onClick:()=>a(s.sessionId),children:[i.jsxs("span",{className:"pb-head",children:[r.mark==="alert"?i.jsx(ic,{}):i.jsx(yi,{kind:r.mark}),i.jsx("span",{className:"pb-name",children:s.label}),i.jsx("span",{className:"pb-state",children:r.word})]}),c&&i.jsx("span",{className:`pb-line${c.kind==="tool"?" mono":""}`,children:c.kind==="tool"?i.jsxs(i.Fragment,{children:[i.jsx("b",{className:"pb-tool",children:c.name}),c.rest?` · ${c.rest}`:""]}):c.text}),h.length>0&&i.jsx("span",{className:"pb-meta",children:h.map((p,f)=>i.jsxs(m.Fragment,{children:[f>0?" · ":"",p]},f))}),i.jsx("span",{className:"vis-hidden",children:v5(s)})]})}const ZOe=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function XOe(e){var n,a;const t=e.target;!(t!=null&&t.closest)||t.closest(ZOe)!==e.currentTarget||(e.preventDefault(),(a=(n=document.activeElement)==null?void 0:n.blur)==null||a.call(n))}function QOe({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:a}){const s=se(),o=sa();return i.jsx("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:i.jsxs("span",{className:"drag-trash-copy",children:[i.jsx("span",{className:"drag-trash-text",children:t==="over"?i.jsxs(i.Fragment,{children:[s("board.trash.release")," ",i.jsx("strong",{className:"drag-trash-name",children:a||s("board.trash.thisCard")})]}):s("board.trash.drop")}),i.jsx("span",{className:"drag-trash-hint",children:t==="over"?s("board.trash.bringsBack",{list:bo(s("board.detail.listUpper"),"L",o)}):s("board.trash.keepsRunning")})]})})}function eMe({canvasRef:e,bubbling:t,dragging:n,trash:a,zoom:s,viewport:o,stateRef:r,peek:c,stagePhase:l,joins:u,closing:h,children:p}){const{trashDragging:f,trashState:b,trashPhase:v,trashZoneRef:w,trashLabel:T}=a,{lod:y,lodRef:x}=s,{markCanvasInput:C}=o,{peekAgent:A,peekLabel:E,peekPeers:R,peekRecap:z,peekBounds:I}=c,_=Tg();return i.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${h?" closing":""}${n?" dragging-any":""}${f&&b==="over"?" trash-hover":""}`,"data-lod":y,"data-live":u?"":void 0,"data-stage":l,"data-empty":_?"":void 0,ref:e,onMouseDownCapture:XOe,onPointerDownCapture:C,onPointerUpCapture:C,onWheelCapture:C,onFocusCapture:D=>{const L=D.target;if(!Zv(L)||x.current==null||x.current==="detail")return;const P=L.getAttribute("data-id");P&&r.current.agents.has(P)&&L.matches(":focus-visible")&&bz(P,L,"focus")},onBlurCapture:D=>{var P,O;const L=(O=(P=D.target).getAttribute)==null?void 0:O.call(P,"data-id");L&&Zs(L)},children:[p,no(v)&&i.jsx(QOe,{trashZoneRef:w,trashState:b,trashPhase:v,trashLabel:T}),i.jsx(Vze,{agentFor:A,recapFor:z,labelFor:E,peers:R,bounds:I})]})}function Fs(...e){const t=e.filter(n=>typeof n=="string"&&n.length>0);return t.length===0?"":t.reduce((n,a)=>S("board.stage.twoSentences",{first:n,second:a}))}const tMe="shell.banner.unreachableTitle",nMe="shell.banner.unreachableSub";function aMe(e,t=Date.now()){const n=new Date(e),a=Me(),s=n.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"});return n.toDateString()===new Date(t).toDateString()?s:`${n.toLocaleDateString(a,{month:"short",day:"numeric"})} ${s}`}function sMe(e,t=Date.now()){return e==null?S(nMe):S("shell.banner.unreachableSubAt",{time:aMe(e,t)})}function $8({lastNewsAt:e}){const t=se();return i.jsxs("div",{className:"conn-banner conn-banner-phone",role:"alert",children:[i.jsx("span",{className:"conn-unreachable",children:i.jsx(w6,{})}),i.jsxs("span",{className:"conn-phone-text",children:[i.jsx("span",{className:"conn-phone-title",children:t(tMe)}),i.jsx("span",{className:"conn-phone-sub",children:sMe(e)})]})]})}function iMe({restarting:e,restartMode:t,live:n,paused:a,phone:s=!1,lastNewsAt:o=null}){const r=se();return s&&!e?i.jsx($8,{lastNewsAt:o}):i.jsxs("div",{className:"conn-banner",role:"alert",children:[e?i.jsx(Ol,{glyph:"info",tone:"info"}):i.jsx(Ol,{glyph:"unreachable",tone:"err"}),e?t==="npx"?r("shell.banner.fetchingNpx"):r("shell.banner.restartingProduct",{product:an}):(()=>{const c=kOe({connected:n,paused:a});return c?Fs(r("shell.banner.lostShort"),c):r("shell.banner.lost",{product:an})})()]})}function oMe({oldName:e,version:t,dismissOldName:n}){const a=se();return i.jsxs("div",{className:"ver-banner",role:"status",children:[i.jsx(Ol,{glyph:"info",tone:"info"}),i.jsx("strong",{children:Fs(a("shell.banner.oldName",{old:e,product:an}),t==null?void 0:t.renameFix)}),i.jsx("button",{type:"button","aria-label":a("shell.dismiss"),className:"ver-close",onClick:n,children:i.jsx(Ze,{name:"close"})})]})}const pE=()=>S("shell.rating.thanks"),rMe=Array.from({length:11},(e,t)=>t);function cMe(e){return e===0?S("shell.rating.score0"):e===10?S("shell.rating.score10"):S("shell.rating.score",{n:e})}const lMe=6;function dMe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function uMe({phase:e,score:t,onAnswer:n,onLater:a,onClose:s,onFeedback:o,onHold:r}){se();const c=m.useRef(null),l=m.useRef(null),u=m.useRef(null),h=m.useRef(!1);m.useEffect(()=>{var f,b;e!=="thanks"||!h.current||(h.current=!1,fa(((f=document.activeElement)==null?void 0:f.tagName)??null)&&((b=l.current??u.current)==null||b.focus()))},[e]);const p=f=>{var b;(b=c.current)!=null&&b.contains(document.activeElement)&&dMe(),f()};if(e==="thanks"){const f=t!==null&&t<=lMe;return i.jsxs("div",{ref:c,className:"ver-banner rating-banner",onFocus:()=>r(!0),onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||r(!1)},children:[i.jsx(Ol,{glyph:"done",tone:"ok"}),i.jsx("strong",{children:f?Fs(pE(),S("shell.rating.better")):pE()}),f?i.jsx("button",{ref:l,type:"button",className:"ver-act",onClick:o,"aria-label":S("shell.rating.better"),children:S("shell.rating.tellUs")}):null,i.jsx("button",{ref:u,type:"button","aria-label":S("shell.dismiss"),className:"ver-close",onClick:()=>p(s),children:i.jsx(Ze,{name:"close"})})]})}return i.jsxs("div",{ref:c,className:"ver-banner rating-banner rating-ask",role:"group","aria-labelledby":"rating-question",children:[i.jsx("strong",{id:"rating-question",children:S("shell.rating.question")}),i.jsx("span",{className:"rating-scale",children:rMe.map(f=>i.jsx("button",{type:"button",className:f===10?"rating-pick ten":"rating-pick","aria-label":cMe(f),onClick:b=>{h.current=b.detail===0||b.currentTarget.matches(":focus-visible"),n(f)},children:f},f))}),i.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:S("shell.rating.ends")}),i.jsx("button",{type:"button",className:"rating-later",onClick:()=>p(a),children:S("shell.rating.later")})]})}const hMe=".app > .banner-strip:has(.ver-banner, .conn-banner > .banner-mark)";function pMe(){let e=null,t=null,n=null;const a=()=>{n==null||n.disconnect(),n=null,t==null||t.style.removeProperty("--rating-h"),e=null,t=null};return{sync(s){var c;if(s===e)return;a();const o=(s==null?void 0:s.closest(".app"))??null;if(!s||!o)return;e=s,t=o;const r=()=>o.style.setProperty("--rating-h",`${Math.ceil(s.getBoundingClientRect().height)}px`);r(),n=typeof ResizeObserver>"u"?null:new ResizeObserver(r),(c=n==null?void 0:n.observe)==null||c.call(n,s)},release:a}}function gMe(){const e=m.useRef(null);e.current||(e.current=pMe()),m.useLayoutEffect(()=>{e.current.sync(document.querySelector(hMe))}),m.useLayoutEffect(()=>()=>{var t;return(t=e.current)==null?void 0:t.release()},[])}function mMe(){return gMe(),null}const fMe=3e4;function bMe({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function kMe({bundle:e,running:t,pending:n,lastTried:a}){return t?bMe({bundle:e,running:t,lastTried:a})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function vMe(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function wMe({asked:e,reported:t}){return t?t!==e:!1}function J8(e){const t=e.thresholdMs??fMe;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function yMe(e){return S("shell.banner.restartingIn",{seconds:Math.max(0,Math.ceil(e/1e3))})}function hW(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function xMe(e,t=!1){return e<=0&&t?{label:S("shell.banner.restartAnyway"),clause:S("shell.banner.clausePaused"),risky:!0}:e<=0?{label:S("shell.banner.restartNow"),clause:S("shell.banner.clauseIdle"),risky:!1}:{label:S("shell.banner.restartAnyway"),clause:S("shell.banner.clauseAgents",{count:e}),risky:!0}}function CMe(e){const t=J8(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}const SMe={get git_checkout(){return S("shell.banner.block.git_checkout")},get npx(){return S("shell.banner.block.npx")},get one_off(){return S("shell.banner.block.one_off")},get not_writable(){return S("shell.banner.block.not_writable")},get opted_out(){return S("shell.banner.block.opted_out")},get retired_name(){return S("shell.banner.block.retired_name")}},pW={get git_checkout(){return S("shell.banner.blockSentence.git_checkout")},get npx(){return S("shell.banner.blockSentence.npx")},get one_off(){return S("shell.banner.blockSentence.one_off")},get not_writable(){return S("shell.banner.blockSentence.not_writable")},get opted_out(){return S("shell.banner.blockSentence.opted_out")},get retired_name(){return S("shell.banner.blockSentence.retired_name")}};function TMe({notice:e,version:t,dismissNotice:n,upgradeState:a,startUpgrade:s,copyCommand:o,cmdCopied:r,askRestart:c,restartCopy:l,restartFuseMs:u,restarting:h}){var I,_;const p=se(),f=e.kind!=="restart",b=f&&a==="failed",v=f&&(t==null?void 0:t.upgradeMode)==="npx",w=f&&(t==null?void 0:t.upgradeMode)==="install"&&!b,T=f&&!w?t==null?void 0:t.command:void 0,y=e.kind==="restart"&&(t==null?void 0:t.canRestart)===!0&&l.risky,x=p("shell.banner.failedLine",{what:(t==null?void 0:t.upgradeMode)==="npx"?p("shell.banner.updateFailed"):p("shell.banner.installFailed"),error:((I=t==null?void 0:t.upgrade)==null?void 0:I.error)??p("shell.banner.unknownError")}),C=p("shell.banner.isOutShort",{product:an,to:e.to});let A,E=null;if(e.kind==="restart"){const D=p("shell.banner.isInstalled",{to:e.to}),L=p("shell.banner.installedStale",{to:e.to,from:e.from});if(!(t!=null&&t.canRestart))A=Fs(L,p("shell.banner.restartNeeded"));else if(h)A=L;else if(u!=null){const P=Fs(D,y&&l.clause);A=Fs(P,p("shell.banner.restartingWhenIdle")),E=Fs(P,yMe(u))}else y?A=Fs(D,l.clause):A=Fs(L,l.clause)}else if(b)A=x;else if(v)A=Fs(C,t!=null&&t.canRestart?p("shell.banner.npxRerun"):pW.npx);else if(t!=null&&t.upgradeBlocked){const D=On(pW,t.upgradeBlocked)??p("shell.banner.cannotInstall");A=t.upgradeBlocked==="git_checkout"?D:Fs(C,D)}else A=p("shell.banner.isOut",{product:an,to:e.to,from:e.from});const R=()=>{var D;(D=window.getSelection())!=null&&D.toString()||o()},z=i.jsxs(i.Fragment,{children:[i.jsx(Ol,{glyph:b?"unreachable":y?"warning":"info",tone:b?"err":y?"warn":"info",armed:u!=null}),E!=null?i.jsxs("strong",{children:[i.jsx("span",{"aria-hidden":"true",children:E}),i.jsx("span",{className:"vis-hidden",children:A})]}):i.jsx("strong",{title:b?A:void 0,children:A}),e.kind==="restart"&&(t==null?void 0:t.canRestart)&&i.jsx("button",{type:"button",className:"ver-act",onClick:()=>c(),...gs(h),title:p("shell.banner.restartTitle"),children:h?p("shell.banner.restarting"):l.label}),w&&i.jsx("button",{type:"button",className:"ver-act",onClick:s,...gs(a==="running",a==="done"),title:p("shell.banner.installTitle",{command:((_=t==null?void 0:t.upgrade)==null?void 0:_.command)??(t==null?void 0:t.command)??"npm i -g"}),children:p(a==="running"?"shell.banner.installing":a==="done"?"shell.banner.installed":"shell.update.now")}),v&&(t==null?void 0:t.canRestart)&&i.jsx("button",{type:"button",className:"ver-act",onClick:()=>c({upgrade:!0}),...gs(h),title:p("shell.banner.npxTitle",{command:(t==null?void 0:t.command)??""}),children:p(h?"shell.banner.fetching":a==="failed"?"shell.update.retry":"shell.update.andRestart")}),i.jsx("button",{type:"button","aria-label":p("shell.dismiss"),className:"ver-close",onClick:n,children:i.jsx(Ze,{name:"close"})})]});return T?i.jsxs("div",{className:`ver-banner ver-stack ${e.kind}`,role:"status",children:[i.jsx("div",{className:"ver-row",children:z}),i.jsx("div",{className:"ver-cmdrow",children:i.jsxs("div",{className:"ver-cmd",onClick:R,title:p("shell.banner.copyTitle"),children:[i.jsx("code",{children:T}),i.jsx("button",{type:"button",className:"ver-copy","aria-label":p("shell.banner.copyTitle"),children:r?i.jsx(Ys,{name:"done"}):i.jsx(Ze,{name:"copy"})}),i.jsx("span",{className:"vis-hidden",children:r?p("shell.banner.copiedHint"):""})]})})]}):i.jsx("div",{className:`ver-banner ${e.kind}`,role:"status",children:z})}function NMe({children:e}){const t=m.useRef(null),n=e!=null;n&&(t.current=e);const[a,s]=m.useState(()=>V4(n)),o=K4(a,n,{instant:!1,hasContent:t.current!=null});o!==a&&s(o);const r=o.closing,c=m.useCallback(()=>s($4),[]);if(m.useEffect(()=>{if(!r)return;const h=window.setTimeout(c,zn("--dur-exit")+Y4);return()=>window.clearTimeout(h)},[r,c]),!J4(o))return t.current=null,null;const l=h=>{r&&h.target===h.currentTarget&&h.propertyName==="opacity"&&c()},u=r?{inert:""}:{};return i.jsx("div",{className:"banner-strip","data-open":r?void 0:"",...u,onTransitionEnd:l,children:i.jsx("div",{className:"banner-strip-in",children:n?e:t.current})})}function AMe({restart:e,versionCheck:t,upgrade:n,oldNameNotice:a,rating:s,onFeedback:o,everConnected:r,live:c,paused:l,phone:u=!1,lastNewsAt:h=null,cardInList:p=!1}){const f=se(),{restarting:b,restartMode:v,restartedTo:w,dismissRestarted:T,askRestart:y,restartCopy:x,restartFuseMs:C}=e,{version:A,notice:E,noticeOpen:R,dismissNotice:z}=t,{upgradeState:I,startUpgrade:_,copyCommand:D,cmdCopied:L}=n,{oldName:P,oldNameOpen:O,dismissOldName:j}=a,{ratingPhase:M,ratingScore:F,answerRating:U,rateLater:H,closeRating:$,holdThanks:Y}=s,W=w?i.jsxs("div",{className:"ver-banner done",role:"status",children:[i.jsx(Ol,{glyph:"done",tone:"ok"}),i.jsx("strong",{children:Fs(f("shell.banner.restartedTo",{version:w}),f("shell.banner.replayed"))}),i.jsx("button",{type:"button","aria-label":f("shell.dismiss"),className:"ver-close",onClick:T,children:i.jsx(Ze,{name:"close"})})]}):r&&!c?u&&p&&!b?null:i.jsx(iMe,{restarting:b,restartMode:v,live:c,paused:l,phone:u,lastNewsAt:h}):R&&E?i.jsx(TMe,{notice:E,version:A,dismissNotice:z,upgradeState:I,startUpgrade:_,copyCommand:D,cmdCopied:L,askRestart:y,restartCopy:x,restartFuseMs:C,restarting:b}):O&&P?i.jsx(oMe,{oldName:P,version:A,dismissOldName:j}):M!=="hidden"?i.jsx(uMe,{phase:M,score:F,onAnswer:U,onLater:H,onClose:$,onFeedback:o,onHold:Y}):null;return i.jsxs(i.Fragment,{children:[i.jsx(NMe,{children:W}),i.jsx(mMe,{}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?pE():""})]})}const jMe=.11,EMe=12,RMe=8,zMe=.4,qMe=44,au=["accounts","usage","machine","inspector"],_Me=()=>zn("--dur-stage-in"),Gp=()=>zn("--dur-stage-out"),LMe=()=>zn("--dur-base"),Y8=()=>fo("--ease-stage");function PMe(e,t,n,a){return e>=EMe&&a>0&&n/a>jMe?!0:t>0&&e>zMe*t}function OMe(e){return Math.abs(e)>=RMe}function $A(e){if(e>=0)return e;const t=-e;return-(t*24)/(t+24)}function Z8(e){const t=au.filter(n=>e[n]);return t.length>0?t[t.length-1]:null}function gW(e,t){const n=au.filter(s=>t[s]);if(n.length===0)return null;const a=n.filter(s=>!e[s]);return a.length>0?a[a.length-1]:Z8(t)}function MMe(e){return e.phone&&e.accountsOpen&&!e.accountsWasOpen&&e.paneOpen}function mW(e){if(e.sheet==null){e.toggleList();return}e.closeSheet(),e.listOpen||e.toggleList()}const IMe={accounts:".accounts-panel:not([hidden]):not(.leaving)",usage:".usage-panel:not(.leaving)",machine:".sysdetail:not(.leaving)",inspector:".app > .right-col > .detail:not(.leaving)"},DMe="button, a, input, select, textarea, label, summary, [role='button'], [role='tab'], [role='switch'], [role='menuitem']",FMe=".anchored-popover, .modal-backdrop, [role='dialog'], [role='alertdialog']",BMe=".topbar, .left-column, main, .stage-dock, .ver-banner, .conn-banner, .skip-link",UMe=12,WMe={accounts:!1,usage:!1,machine:!1,inspector:!1};function fW(e,t=document){return t.querySelector(IMe[e])}function Rz(e){e.style.transform="",e.style.transition="",e.removeAttribute("data-sheet-dragging")}function HMe(e,t){return Rz(e),typeof e.animate!="function"||Ya()?null:e.animate([{transform:`translateY(${t}px)`},{transform:"translateY(100%)"}],{duration:Gp(),easing:Y8(),fill:"forwards"})}function GMe(e,t){Rz(e),!(typeof e.animate!="function"||Ya()||t===0)&&e.animate([{transform:`translateY(${t}px)`},{transform:"translateY(0)"}],{duration:_Me(),easing:Y8()})}function VMe({phone:e,open:t,close:n,openers:a,modalOpenRef:s,onLeavePhone:o,hold:r,home:c}){const l=m.useRef(WMe),u=m.useRef(n);u.current=n;const h=m.useRef(a);h.current=a;const p=m.useRef(o);p.current=o;const f=m.useRef(r);f.current=r;const b=m.useRef(c);b.current=c;const v=m.useRef(e),w=m.useRef(null),T=m.useRef({}),y=e?gW(l.current,t):null,x=au.map(D=>t[D]).join();m.useLayoutEffect(()=>{var L,P,O,j;const D=v.current!==e;v.current=e;for(const M of au)t[M]!==l.current[M]&&(w.current===M&&(w.current=null),t[M]&&((L=T.current[M])==null||L.cancel(),delete T.current[M]));if(D){if(e){const M=Z8(t);for(const F of au)t[F]&&F!==M&&((O=(P=f.current)==null?void 0:P[F])==null||O.call(P))}l.current={...t},e||(j=p.current)==null||j.call(p);return}if(e){const M=gW(l.current,t);for(const F of au)t[F]&&F!==M&&u.current[F]()}l.current={...t}},[e,x]);const C=y,A=m.useRef(C);A.current=C;const E=m.useCallback(D=>{const L=D??A.current;!L||w.current===L||(w.current=L,window.setTimeout(()=>{w.current===L&&(w.current=null)},Gp()+200),u.current[L]())},[]),R=m.useRef(()=>{});R.current=()=>{s!=null&&s.current||document.querySelector(FMe)||E()},m.useEffect(()=>{if(!e||!C)return;const D=Rn.push(()=>R.current(),0,"popover");return()=>{window.setTimeout(D,Gp()+50)}},[e,C]),m.useEffect(()=>{if(!e||!C)return;const D=[],L=()=>{for(const j of Array.from(document.querySelectorAll(BMe)))j.hasAttribute("inert")||(j.setAttribute("inert",""),D.push(j))};L();const P=document.querySelector(".app"),O=P&&typeof MutationObserver=="function"?new MutationObserver(L):null;return P&&(O==null||O.observe(P,{childList:!0})),()=>{O==null||O.disconnect();for(const j of D)j.removeAttribute("inert")}},[e,C]);const z=m.useRef(null),I=m.useRef(null),_=m.useRef(null);return m.useEffect(()=>{var L,P,O;const D=z.current;if(z.current=e?C:null,e&&C&&C!==D){const j=document.activeElement,M=I.current!=null&&j!=null&&I.current.contains(j);_.current=j&&j!==document.body&&!M?j:_.current;let F=0,U=0;const H=()=>{const $=fW(C);if(!$){++F<UMe&&(U=window.requestAnimationFrame(H));return}I.current&&I.current!==$&&I.current.removeAttribute("tabindex"),I.current=$,$.tabIndex=-1,$.focus({preventScroll:!0})};return H(),()=>{U&&window.cancelAnimationFrame(U)}}if(D&&!(e&&C)){const j=I.current;if(I.current=null,j==null||j.removeAttribute("tabindex"),!e)return;const M=document.activeElement;if(!(!M||M===document.body||!M.isConnected||j!=null&&j.contains(M)))return;const U=((P=(L=h.current)==null?void 0:L[D])==null?void 0:P.call(L))??_.current,H=U&&U.isConnected?U:((O=b.current)==null?void 0:O.call(b))??null;H&&H.isConnected&&H.focus({preventScroll:!0})}},[e,C]),m.useEffect(()=>{if(!e)return;let D=null;const L=j=>{const M=A.current;if(!M||D||j.pointerType==="mouse"&&j.button!==0)return;const F=fW(M),U=j.target;if(!F||!U||!F.contains(U))return;const H=F.getBoundingClientRect();j.clientY-H.top>qMe||U.closest(DMe)||(D={id:j.pointerId,el:F,name:M,y0:j.clientY,height:H.height,engaged:!1,dy:0,base:0,samples:[[j.timeStamp,j.clientY]]})},P=j=>{if(!D||j.pointerId!==D.id)return;const M=j.clientY-D.y0;if(D.samples.push([j.timeStamp,j.clientY]),D.samples.length>6&&D.samples.shift(),!D.engaged){if(!OMe(M))return;D.engaged=!0,D.base=$A(M);try{D.el.setPointerCapture(j.pointerId)}catch{}}D.dy=M,D.el.setAttribute("data-sheet-dragging",""),D.el.style.transition="none",D.el.style.transform=`translateY(${$A(M)-D.base}px)`,j.preventDefault()},O=j=>{var G;if(!D||j.pointerId!==D.id)return;const M=D;if(D=null,!M.engaged)return;try{M.el.releasePointerCapture(j.pointerId)}catch{}const F=M.samples[M.samples.length-1],U=M.samples.find(([Q])=>j.timeStamp-Q<=100),H=U&&U!==F?U:M.samples[Math.max(0,M.samples.length-2)],$=F[0]-H[0],Y=F[1]-H[1],W=$A(M.dy)-M.base;if(j.type==="pointerup"&&PMe(M.dy,M.height,Y,$)){const Q=HMe(M.el,W);Q&&((G=T.current[M.name])==null||G.cancel(),T.current[M.name]=Q,window.setTimeout(()=>{Q.cancel(),T.current[M.name]===Q&&delete T.current[M.name]},Gp()+200)),E(M.name)}else GMe(M.el,W)};return document.addEventListener("pointerdown",L),document.addEventListener("pointermove",P,{passive:!1}),document.addEventListener("pointerup",O),document.addEventListener("pointercancel",O),()=>{if(document.removeEventListener("pointerdown",L),document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",O),document.removeEventListener("pointercancel",O),D){try{D.el.releasePointerCapture(D.id)}catch{}Rz(D.el)}}},[e,E]),{sheet:C,closeSheet:E}}function KMe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function $Me(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 JMe(e,t){return e<=0?null:t("board.clear.goes.agents",{count:e})}function YMe(e,t,n=S){const a=JMe(e,n),s=(...l)=>[a,...l,n("board.clear.goes.view")].filter(u=>u!==null),o=n("board.clear.final"),r=n("board.clear.confirmAll");if(!t)return{goes:s(n("board.clear.goes.logUnknown")),stays:[],final:o,confirm:r};if(!t.path)return{goes:s(),stays:[],final:n("board.clear.final.noLog",{final:o}),confirm:r};if(!t.mine){const l=t.ownerPort===null?n("board.clear.owner.other"):n("board.clear.owner.port",{port:t.ownerPort}),u=t.decks>2?n("board.clear.owner.shared",{decks:t.decks}):"";return{goes:s(),stays:[n("board.clear.stays.log",{owner:l,shared:u}),n("board.clear.stays.replay")],final:null,confirm:n("board.clear.confirmCanvas")}}if(t.decks<=1)return{goes:s(n("board.clear.goes.logOwn")),stays:[],final:o,confirm:r};const c=t.decks-1;return{goes:s(n("board.clear.goes.logShared",{count:c})),stays:[n("board.clear.stays.shared",{count:c})],final:o,confirm:r}}function ZMe({agentCount:e,onConfirm:t,onCancel:n}){const a=se(),s=m.useRef(null),o=Zt(n,{focusRef:s,layer:ole}),r=tn(n),[c,l]=m.useState(null);m.useEffect(()=>{let b=!1;return fetch("/api/clear").then(v=>v.ok?v.json():null).then(v=>{b||l($Me(v))}).catch(()=>{}),()=>{b=!0}},[]);const{goes:u,stays:h,final:p,confirm:f}=YMe(e,c,a);return i.jsxs(dn,{scrim:r,dialogRef:o,className:"clear-confirm",labelledBy:"clear-confirm-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:a("board.clear.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:n,label:a("board.clear.cancelEsc")})})]}),i.jsxs("section",{className:"modal-body cc-body",children:[i.jsxs("dl",{className:"cc-plan",children:[i.jsxs("div",{className:"cc-col",children:[i.jsx("dt",{children:a("board.clear.goes")}),i.jsx("dd",{children:u.map(b=>i.jsx("span",{children:b},b))})]}),i.jsxs("div",{className:"cc-col",children:[i.jsx("dt",{children:a("board.clear.stays")}),i.jsx("dd",{children:h.length>0?h.map(b=>i.jsx("span",{children:b},b)):i.jsx("span",{className:"cc-none",children:a("board.clear.nothing")})})]})]}),p&&i.jsx("p",{className:"cc-final",children:p})]}),i.jsxs("footer",{className:"modal-foot",children:[i.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:a("board.clear.cancel")}),i.jsx("button",{type:"button",className:"btn danger",onClick:t,children:f})]})]})}function XMe({kind:e,onChange:t}){const n=se();return i.jsxs("fieldset",{className:"fb-kinds",children:[i.jsx("legend",{className:"vis-hidden",children:n("shell.feedback.kinds")}),Tk.map(a=>i.jsxs("label",{className:"fb-kind",children:[i.jsx("input",{type:"radio",name:"feedback-kind",value:a.value,checked:e===a.value,onChange:()=>t(a.value),onKeyDown:s=>{Nz(s.nativeEvent)&&s.preventDefault()}}),a.label]},a.value))]})}const X8="fb-details";function QMe({open:e,onToggle:t}){return se(),i.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":X8,onClick:t,children:[i.jsx("svg",{className:"fb-chev",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"M5.25 3.5 8.75 7l-3.5 3.5"})}),iPe()]})}function eIe({open:e,contact:t,onContact:n,account:a=!1,mail:s=!0}){const o=se(),r=m.useId();return i.jsx("div",{id:X8,className:"fb-details","data-open":e||void 0,children:i.jsx("div",{className:"fb-details-clip",children:i.jsxs("div",{className:"fb-details-body",children:[!a&&i.jsxs("div",{className:"fb-field",children:[i.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[oPe(),i.jsx("span",{className:"fb-optional",children:o("shell.feedback.optional")})]}),i.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:j8,autoComplete:"email",placeholder:rPe(),"aria-describedby":r,onChange:c=>n(c.target.value),onKeyDown:c=>{Nz(c.nativeEvent)&&c.preventDefault()}}),i.jsx("p",{id:r,className:"fb-hint",children:cPe()})]}),a?i.jsx("div",{className:"fb-where",children:bPe(s).map(c=>i.jsx("p",{children:c},c))}):i.jsx("div",{className:"fb-where",children:lPe().map(c=>i.jsx("p",{children:c},c))})]})})})}const cl=3,tIe=5*1024*1024,nIe=12*1024*1024,gE=8192,aIe=64*1024,sIe=256*1024,iIe=.92,oIe=640,Q8=.9,rIe=.85,cIe=6,lIe=512*1024,zk={png:"image/png",jpeg:"image/jpeg"},dIe={png:"png",jpeg:"jpg"},uIe=[137,80,78,71,13,10,26,10],hIe=[255,216,255];function e7(e){const t=n=>e.length>=n.length&&n.every((a,s)=>e[s]===a);return t(uIe)?"png":t(hIe)?"jpeg":null}function pIe(e){const t=e7(e);return t==="png"?gIe(e):t==="jpeg"?fIe(e):null}function gIe(e){const t=[73,72,68,82];if(e.length<24||!t.every((a,s)=>e[12+s]===a))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function mIe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function fIe(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const a=e[t]<<8|e[t+1];if(a<2)return null;if(mIe(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=a}return null}function bW(e,t){return e.bytes>t||e.width>gE||e.height>gE}function bIe(e){return Math.min(tIe,nIe-aIe-e)}function t7(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function kIe(e,t){const n=gE/Math.max(e.width,e.height),a=e.bytes>t?Math.sqrt(t/e.bytes)*Q8:1;return t7(e,Math.min(1,n,a))}async function vIe(e,t,n){let a=kIe(e,t),s=e.format;for(let o=0;o<cIe;o++){const r=await n(a,s,s==="jpeg"?iIe:void 0);if(!r)return null;if(r.size<=t)return{...a,blob:r,format:s};if(s==="png"){s="jpeg";continue}if(a=t7(a,Math.min(rIe,Math.sqrt(t/r.size)*Q8)),Math.max(a.width,a.height)<oIe)return null}return null}async function wIe(e,t,n){const a=new Uint8Array(await e.slice(0,lIe).arrayBuffer()),s=e7(a);if(!s)return{ok:!1,problem:"type"};if(t<sIe)return{ok:!1,problem:"no_room"};const o=e.type===zk[s]?e:new Blob([e],{type:zk[s]}),r=pIe(a);if(r&&!bW({...r,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const l={width:c.width,height:c.height,bytes:e.size,format:s};if(!bW(l,t))return{ok:!0,blob:o,resized:null};const u=await vIe(l,t,c.encoder);return u?{ok:!0,blob:u.blob,resized:{width:u.width,height:u.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function yIe(e){return({width:t,height:n},a,s)=>new Promise(o=>{const r=document.createElement("canvas");r.width=t,r.height=n;const c=r.getContext("2d");if(!c)return o(null);a==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),r.toBlob(l=>{r.width=0,r.height=0,o(l)},zk[a],s)})}const xIe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:yIe(t),release:()=>t.close()}};function CIe(e){return e.includes("Files")}function SIe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function TIe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function kW(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((a,s)=>{const o=a.type===zk.jpeg?"jpeg":"png";n.append("images",a,`image-${s+1}.${dIe[o]}`)}),{method:"POST",body:n}}const NIe=()=>S("shell.feedback.addShot"),vW=()=>S("shell.feedback.addHint"),AIe=()=>S("shell.feedback.shotsNote"),wW=()=>S("shell.feedback.full"),jIe=()=>S("shell.feedback.refusedWhileSending");function EIe(e,t,n){const a=n?S("shell.feedback.resized",{width:n.width,height:n.height}):"";return S("shell.feedback.replaceLabel",{n:e+1,name:t,fit:a})}function RIe(e,t){const n=S("shell.feedback.shotsCount",{count:e,max:cl});return t>0?S("shell.feedback.shotsResized",{of:n,resized:t}):n}function zIe(e){return S("shell.feedback.leftOut",{count:e})}function qIe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function _Ie(e,t){const n=qIe(t);return e==="type"?S("shell.feedback.problem.type",{file:n}):e==="no_room"?S("shell.feedback.problem.noRoom",{file:n}):e==="unreadable"?S("shell.feedback.problem.unreadable",{file:n}):S("shell.feedback.problem.tooLarge",{file:n})}const n7="image/png,image/jpeg";function a7({className:e="fb-glyph"}){return i.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),i.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),i.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function LIe({images:e,buttonRef:t}){se();const n=m.useRef(null),a=e.shots.length>=cl;return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:vW(),"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return a?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[i.jsx(a7,{}),NIe()]}),i.jsx("span",{id:"fb-attach-hint",hidden:!0,children:vW()}),i.jsx("input",{ref:n,type:"file",accept:n7,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function PIe({images:e,addRef:t}){const n=se(),a=m.useRef(new Map),s=m.useRef(null),o=m.useRef(null),r=m.useRef(null),[c,l]=m.useState(null),{shots:u}=e,h=RIe(u.length,u.filter(b=>b.resized).length);m.useLayoutEffect(()=>{var b;c!==null&&((b=c==="add"?t.current:a.current.get(c))==null||b.focus(),l(null))},[c,t]),m.useEffect(()=>{var b;e.problem&&((b=s.current)==null||b.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function p(b){l(TIe(u.map(v=>v.id),b)??"add"),e.remove(b)}function f(b){var v;r.current=b,(v=o.current)==null||v.click()}return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),i.jsx("input",{ref:o,type:"file",accept:n7,hidden:!0,onChange:b=>{const v=r.current;v!==null&&e.replace(v,Array.from(b.target.files??[])),r.current=null,b.target.value=""}}),u.length>0&&i.jsxs("div",{className:"fb-shots",children:[i.jsxs("div",{className:"fb-shots-row",children:[i.jsx("ul",{className:"fb-shots-list",children:u.map((b,v)=>i.jsxs("li",{className:"fb-shot","data-fitting":b.blob?void 0:!0,children:[i.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":EIe(v,b.name,b.resized),onClick:()=>f(b.id),children:[i.jsx("img",{className:"fb-shot-img",src:b.url,alt:""}),b.blob?i.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:n("shell.feedback.replace")}):i.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:n("shell.feedback.resizing")})]}),i.jsx("button",{ref:w=>{w?a.current.set(b.id,w):a.current.delete(b.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":n("shell.feedback.removeImage",{n:v+1}),title:n("shell.feedback.removeImage",{n:v+1}),onClick:()=>p(b.id),children:i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},b.id))}),i.jsx("span",{className:"fb-shots-count",children:h})]}),i.jsx("p",{className:"fb-hint",children:AIe()})]}),e.problem&&i.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}const JA=["write","conversations"],OIe="shell.feedback.didNotLoad";function s7(){const e=se();return i.jsxs("div",{className:"fc-missing",children:[i.jsx("p",{className:"fc-note",children:e(OIe)}),i.jsx("button",{type:"button",className:"btn",onClick:()=>window.location.reload(),children:e("shell.reload")})]})}const MIe=m.lazy(()=>Xs(()=>import("./FeedbackConversations-Bqqn0VaM.js"),__vite__mapDeps([4,5])).catch(e=>(console.warn("ccdeck could not load your conversations",e),{default:s7})));class IIe extends m.Component{constructor(){super(...arguments);Ss(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n,a){console.error("ccdeck could not draw your conversations",n,a.componentStack)}render(){return this.state.failed?i.jsx(s7,{}):this.props.children}}function DIe(e){return i.jsx(IIe,{children:i.jsx(m.Suspense,{fallback:null,children:i.jsx(MIe,{...e})})})}function FIe(e){return e>0?S("shell.feedback.tabConversationsUnread",{count:e}):void 0}function BIe({tab:e,onTab:t,unread:n,conversationsTabRef:a,write:s,conversations:o}){const r=m.useRef(null),c=m.useRef(null),l=se(),u=a??c,h=[r,u];return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"fc-tabs",role:"tablist","aria-label":l("shell.feedback.tabs"),onKeyDown:p=>{var b;const f=Fu(p.nativeEvent,JA.indexOf(e),JA.length);f.kind==="select"&&(p.preventDefault(),t(JA[f.index]),(b=h[f.index].current)==null||b.focus())},children:[i.jsx("button",{ref:r,type:"button",id:"fc-tab-write",className:"fc-tab",role:"tab","aria-selected":e==="write","aria-controls":"fc-panel-write",tabIndex:e==="write"?0:-1,onClick:()=>t("write"),children:l(uPe)}),i.jsxs("button",{ref:u,type:"button",id:"fc-tab-conversations",className:"fc-tab",role:"tab","aria-selected":e==="conversations","aria-controls":"fc-panel-conversations",tabIndex:e==="conversations"?0:-1,"aria-label":FIe(n),onClick:()=>t("conversations"),children:[l(hPe),n>0&&i.jsx("span",{className:"fc-tab-count","aria-hidden":"true",children:n})]})]}),i.jsx("div",{className:"fc-panel",id:"fc-panel-write",role:"tabpanel","aria-labelledby":"fc-tab-write",hidden:e!=="write",children:s}),i.jsx("div",{className:"fc-panel",id:"fc-panel-conversations",role:"tabpanel","aria-labelledby":"fc-tab-conversations",hidden:e!=="conversations",children:o})]})}function UIe(e,t){return e.map((n,a)=>({id:t+a,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function WIe(e,t,n){return n?e.map(a=>a.id===t.id?t:a):[...e,t]}function HIe(e,t,n){return n?e.map(a=>a.id===t?n:a):e.filter(a=>a.id!==t)}function GIe(e){const[t,n]=m.useState(()=>UIe((e==null?void 0:e.ready)??[],1)),[a,s]=m.useState({problem:"",id:0}),o=m.useRef(0),r=m.useCallback(P=>{P&&o.current++,s(O=>P?{problem:P,id:O.id+1}:O.problem?{problem:"",id:O.id}:O)},[]),[c,l]=m.useState(""),u=m.useRef(t),h=m.useRef(null),p=m.useRef(t.length),f=m.useRef(!0),b=m.useRef(new Map),v=m.useRef([]),w=m.useRef(0),T=m.useCallback(P=>{u.current=P(u.current),n(u.current)},[]);m.useEffect(()=>(f.current=!0,()=>{f.current=!1;for(const P of u.current)URL.revokeObjectURL(P.url)}),[]);const y=m.useCallback(async(P,O)=>{const j=u.current.reduce((Q,J)=>{var X;return Q+(J.id===(O==null?void 0:O.id)?0:((X=J.blob)==null?void 0:X.size)??0)},0),M=(O==null?void 0:O.id)??++p.current,F=URL.createObjectURL(P),U={id:M,name:P.name||"image",url:F,blob:null,resized:null},H=w.current;b.current.set(M,P);let $=!1;const Y=()=>{$||($=!0,T(Q=>WIe(Q,U,O!==void 0)))},W=await wIe(P,bIe(j),async Q=>(Y(),xIe(Q))).catch(()=>({ok:!1,problem:"unreadable"})),G=u.current.some(Q=>Q.id===M);return!f.current||w.current!==H||!G&&($||O)?(URL.revokeObjectURL(F),O&&URL.revokeObjectURL(O.url),f.current&&b.current.delete(M),""):(b.current.delete(M),W.ok?(Y(),O&&URL.revokeObjectURL(O.url),T(Q=>Q.map(J=>J.id===M?{...J,blob:W.blob,resized:W.resized}:J)),""):(URL.revokeObjectURL(F),$&&T(Q=>HIe(Q,M,O)),_Ie(W.problem,P.name||"image")))},[T]),x=m.useCallback(async P=>{r("");const O=w.current,j=[];let M=0,F=0;for(const H of P){if(!f.current||w.current!==O)return;const $=v.current.indexOf(H);if($!==-1&&v.current.splice($,1),u.current.length>=cl){M++;continue}const Y=u.current.length,W=await y(H);W&&j.push(W),u.current.length>Y&&F++}if(!f.current||w.current!==O)return;M>0&&j.push(F===0&&j.length===0?wW():zIe(M)),r(j.join(" "));const U=u.current.length;F>0&&l(S("shell.feedback.imagesAdded",{count:F,total:U,max:cl}))},[y,r]),C=m.useCallback(async(P,O)=>{r("");const j=u.current.find(U=>U.id===P);if(!j)return x([O]);const M=await y(O,j);if(!f.current)return;r(M);const F=u.current.findIndex(U=>U.id===P);!M&&F!==-1&&l(S("shell.feedback.imageReplaced",{n:F+1,total:u.current.length,max:cl}))},[x,y,r]),A=m.useCallback(P=>{const O=w.current;h.current=(h.current??Promise.resolve()).then(()=>w.current===O?P():void 0).catch(()=>{})},[]),E=m.useCallback(P=>{P.length!==0&&(v.current.push(...P),A(()=>x(P)))},[x,A]);m.useEffect(()=>{e&&e.waiting.length>0&&E(e.waiting)},[]);const R=m.useCallback((P,O)=>{const j=O[0];j&&A(()=>C(P,j))},[A,C]),z=m.useCallback(P=>{const O=u.current.find(j=>j.id===P);O&&(URL.revokeObjectURL(O.url),b.current.delete(P),T(j=>j.filter(M=>M.id!==P)),r(""),l(S("shell.feedback.imageRemoved",{count:u.current.length,max:cl})))},[T,r]),I=m.useCallback(()=>r(wW()),[r]),_=m.useCallback(async()=>{const P=o.current;return await h.current,o.current!==P?null:u.current.flatMap(O=>O.blob?[O.blob]:[])},[]),D=m.useCallback(()=>({ready:u.current.flatMap(P=>P.blob&&!b.current.has(P.id)?[{name:P.name,blob:P.blob,resized:P.resized}]:[]),waiting:[...b.current.values(),...v.current]}),[]),L=m.useCallback(()=>{w.current++;for(const P of u.current)URL.revokeObjectURL(P.url);b.current.clear(),v.current=[],T(()=>[]),r("")},[T,r]);return{shots:t,problem:a.problem,problemId:a.id,announcement:c,add:E,replace:R,remove:z,sayFull:I,ready:_,kept:D,clear:L}}function VIe(){const[e,t]=m.useState(null);return m.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(a=>a.ok?a.json():null).then(a=>{n&&t(QLe(a))}).catch(()=>{}),()=>{n=!1}},[]),e}const KIe="/api/account/feedback/threads";function $Ie(e,{asAccount:t=!1}={}){const[n,a]=m.useState({state:"idle"}),[s,o]=m.useState(!1),r=m.useRef(!1),c=m.useRef(null);m.useEffect(()=>()=>{var h;return(h=c.current)==null?void 0:h.abort()},[]);async function l(h){if(!$a(r.current))return;r.current=!0;const{signal:p}=c.current=new AbortController,f=t;o(f),a({state:"sending"});try{const b=await e.ready();if(p.aborted)return;if(!b){a({state:"failed",message:jIe()});return}const v=kW(XU(f?{...h,contact:""}:h),b),w=await fetch(f?KIe:"/api/feedback",{...v,signal:p}),T=await w.json().catch(()=>null),y=w.ok&&(f?(T==null?void 0:T.thread)!=null:T==null?void 0:T.ok);a(y?{state:"sent"}:{state:"failed",message:f?QU(w.status,T):lE(w.status,T==null?void 0:T.reason,T==null?void 0:T.errors)})}catch{p.aborted||a({state:"failed",message:f?QU(0,null):lE(0,null)})}finally{r.current=!1}}const u=()=>a(h=>h.state==="failed"?{state:"idle"}:h);return{outcome:n,sending:n.state==="sending",sentAsAccount:s,send:l,clearFailure:u}}function JIe(e,t){const[n,a]=m.useState(!1),s=m.useRef(t);return s.current=t,m.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>a(!0),eW),r=window.setTimeout(()=>s.current(),eW+jPe);return()=>{window.clearTimeout(o),window.clearTimeout(r)}},[e]),n}const YA="agent-dag.feedbackDrafts",yW=4;function YIe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function ZIe(e){return JSON.stringify([e.kind,e.body])}function XIe(e){return e.ready.length+e.waiting.length}function i7(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function QIe(e){return S("shell.feedback.lost",{count:e})}const eDe=()=>S("shell.feedback.discard"),tDe=()=>S("shell.feedback.discardConfirm"),nDe=()=>S("shell.feedback.discardTitle"),xW=()=>S("shell.feedback.discardArmed"),aDe={ready:[],waiting:[]};function sDe(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:a,contact:s,images:o,anonymous:r}=t;return!Tk.some(c=>c.value===n)||typeof a!="string"||a.length>A8||typeof s!="string"||s.length>j8||typeof o!="number"||!Number.isInteger(o)||o<0||o>cl||r!==void 0&&typeof r!="boolean"?null:[e[0],{kind:n,body:a,contact:s,images:o,...r?{anonymous:r}:{}}]}function iDe(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const r=(o=e())==null?void 0:o.getItem(YA),c=r?JSON.parse(r):[];if(Array.isArray(c))for(const l of c.slice(-yW)){const u=sDe(l);u&&t.set(u[0],{...u[1],anonymous:u[1].anonymous===!0,images:null,imageCount:u[1].images})}}catch{}return t}function a(){try{const o=e();if(!o)return;const r=[...n()].map(([c,l])=>[c,{kind:l.kind,body:l.body,contact:l.contact,images:l.imageCount,...l.anonymous?{anonymous:!0}:{}}]);r.length===0?o.removeItem(YA):o.setItem(YA,JSON.stringify(r))}catch{}}function s(o){n().delete(o)&&a()}return{read(o){const r=n().get(o);return r?{kind:r.kind,body:r.body,contact:r.contact,...r.anonymous?{anonymous:!0}:{},images:r.images??aDe,imagesLost:r.images?0:r.imageCount}:null},keep(o,r,c){const l=XIe(r.images);if(!i7({body:r.body,contact:r.contact,images:l},c)){s(o);return}const u=n();u.delete(o),u.set(o,{kind:r.kind,body:r.body,contact:r.contact,anonymous:r.anonymous===!0,images:r.images,imageCount:l});for(const h of u.keys()){if(u.size<=yW)break;u.delete(h)}a()},forget:s}}function oDe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const mE=iDe(oDe),rDe=4e3;function cDe(e,t,n,a,s){const o=m.useRef(null);o.current={key:e,seed:t,words:n,images:a,sent:s};const r=m.useCallback(()=>{const c=o.current;!c||c.sent||mE.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);m.useEffect(r,[r,n.kind,n.body,n.contact,n.anonymous,a.shots]),m.useEffect(()=>r,[r]),m.useEffect(()=>{s&&mE.forget(e)},[s,e])}const CW="draft";function lDe(e){const[t,n]=m.useState(!1),a=m.useRef(0);m.useEffect(()=>{if(!t)return;const r=window.setTimeout(()=>n(!1),rDe);return()=>window.clearTimeout(r)},[t]);function s(){const r=Date.now(),c=zl({armedFor:t?CW:null,target:CW,armedAt:a.current,now:r,gapMs:Rl});if(c==="arm"){n(!0),a.current=r;return}c!=="ignore"&&(n(!1),e())}const o=m.useCallback(()=>n(!1),[]);return{armed:t,press:s,disarm:o}}function o7({onClose:e,initialKind:t,initialBody:n,initialTab:a,account:s}){const o=se(),r=m.useRef(null),c=m.useRef(null),l=m.useRef(null),u=m.useRef(null),h=m.useRef(null),p=m.useRef(null),f=m.useRef(null),b=m.useRef(null),v=m.useRef(0),w=m.useRef(null),T=Zt(e,{focusRef:r}),y=T8(),x=s!==void 0?s:y,C=(x==null?void 0:x.connected)===!0,A=HLe(x),[E,R]=m.useState(C&&a==="conversations"?"conversations":"write"),[z,I]=m.useState(E==="conversations"),_=Le=>{R(Le),Le==="conversations"&&I(!0)},D=C&&E==="conversations",[L,P]=m.useState(""),O=Le=>{P(""),window.setTimeout(()=>P(Le),50)},j=tn(e),M=YIe({initialKind:t,initialBody:n}),F=ZIe(M),[U]=m.useState(()=>mE.read(F)),[H,$]=m.useState((U==null?void 0:U.kind)??M.kind),[Y,W]=m.useState((U==null?void 0:U.body)??M.body),[G,Q]=m.useState((U==null?void 0:U.contact)??""),[J,X]=m.useState((U==null?void 0:U.imagesLost)??0),[te,K]=m.useState((U==null?void 0:U.anonymous)===!0),V=C&&!te,[ee,de]=m.useState(!1),[he,me]=m.useState(!1),[be,ie]=m.useState(!1),ne=GIe(U==null?void 0:U.images),ke=nPe(VIe()),{outcome:Se,sending:ve,sentAsAccount:xe,send:Ee,clearFailure:Ge}=$Ie(ne,{asAccount:V}),Qe=Se.state==="sent",Je=JIe(Qe,e);cDe(F,M,{kind:H,body:Y,contact:G,anonymous:te},ne,Qe);const He=i7({body:Y,contact:G,images:ne.shots.length},M),_e=lDe(()=>{var Le;$(M.kind),W(M.body),Q(""),X(0),K(!1),me(!1),ne.clear(),Ge(),(Le=r.current)==null||Le.focus()}),{armed:le,disarm:Re}=_e;m.useEffect(()=>{le&&Re()},[Y,G]);const ge=N8(H),Pe=he&&!YU(Y),Fe=J>0&&ne.shots.length===0,Ve=[Pe&&"fb-body-error",Fe&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ot,ce]=SPe(js());m.useEffect(()=>{var Le;E==="conversations"&&((Le=w.current)==null||Le.focus())},[]),m.useEffect(()=>{var Mt,yn;const Le=u.current;if(!Le)return;const Ht=Le.contains(document.activeElement)||fa(((Mt=document.activeElement)==null?void 0:Mt.tagName)??null);Le.inert=Qe,Qe&&Ht&&((yn=c.current)==null||yn.focus())},[Qe]),m.useEffect(()=>{var mn,xn;const Le=h.current;if(!Le)return;const Ht=f.current;if(ve){const Gt=document.activeElement,tt=Gt!=null&&(Le.contains(Gt)||Gt===Ht);b.current=tt?Gt:null,Le.inert=!0,Ht&&(Ht.inert=!0),b.current&&((mn=p.current)==null||mn.focus());return}Le.inert=!1,Ht&&(Ht.inert=!1);const Mt=b.current;b.current=null;const yn=document.activeElement===p.current||fa(((xn=document.activeElement)==null?void 0:xn.tagName)??null);!Qe&&Mt&&yn&&Mt.focus()},[ve,Qe]);function Ce(Le){var Ht;if(Le.preventDefault(),!YU(Y)){me(!0),(Ht=r.current)==null||Ht.focus();return}Ee({kind:H,body:Y,contact:G})}const Ke=!Qe&&!ve&&!D,Oe=Le=>CIe(Array.from(Le.dataTransfer.types));function at(Le){!Oe(Le)||!Ke||(Le.preventDefault(),v.current++,ie(!0))}function ut(Le){Oe(Le)&&(Le.preventDefault(),Le.dataTransfer.dropEffect=Ke?"copy":"none")}function vt(Le){Oe(Le)&&(v.current=Math.max(0,v.current-1),v.current===0&&ie(!1))}function qe(Le){Oe(Le)&&(Le.preventDefault(),v.current=0,ie(!1),Ke&&ne.add(Array.from(Le.dataTransfer.files)))}function dt(Le){Le.target!==Le.currentTarget||!Oe(Le)||(Le.preventDefault(),Le.dataTransfer.dropEffect="none")}function et(Le){Oe(Le)&&Le.preventDefault()}function Ie(Le){if(!Ke)return;const Ht=Array.from(Le.clipboardData.files),Mt=Le.target,yn=Mt instanceof HTMLTextAreaElement||Mt instanceof HTMLInputElement,mn=Array.from(Le.clipboardData.types).includes("text/plain");SIe({files:Ht.length,hasText:mn,intoTextField:yn})&&(Le.preventDefault(),ne.add(Ht))}const ct=Nt();return i.jsxs(dn,{scrim:j,dialogRef:T,backdropProps:{onDragOver:dt,onDrop:et,"data-leaving":Je||void 0},className:"feedback-dialog","data-account":C||void 0,onDragEnter:at,onDragOver:ut,onDragLeave:vt,onDrop:qe,onPaste:Ie,labelledBy:"feedback-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:o(C?dPe:"shell.feedback.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:e,"aria-label":o("shell.closeEsc"),title:o("shell.closeEsc"),children:"×"})})]}),i.jsx("p",{className:"vis-hidden",role:"status",children:_e.armed?xW():D?L:APe(Se.state,xe,A)}),C&&x?i.jsx(BIe,{tab:E,onTab:_,unread:x.unread,conversationsTabRef:w,write:ct,conversations:z?i.jsx(DIe,{account:x,active:D,announce:O}):null}):ct,i.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":be||void 0,children:i.jsxs("div",{className:"fb-drop-frame",children:[i.jsx(a7,{className:"fb-drop-glyph"}),i.jsx("p",{className:"fb-drop-title",children:o("shell.feedback.dropTitle")}),i.jsx("p",{className:"fb-drop-note",children:o("shell.feedback.dropNote")})]})})]});function Nt(){return i.jsxs("div",{className:"fb-stage",children:[i.jsxs("form",{ref:u,className:"fb-form",onSubmit:Ce,onKeyDown:Le=>{CPe(Le.nativeEvent)&&(Le.preventDefault(),Le.currentTarget.requestSubmit())},noValidate:!0,children:[i.jsxs("section",{ref:h,className:"modal-body fb-body",children:[i.jsx(XMe,{kind:H,onChange:$}),i.jsxs("div",{className:"fb-compose",children:[i.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:ge.question}),i.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:Y,maxLength:A8,rows:5,placeholder:ge.placeholder,onChange:Le=>W(Le.target.value),"aria-invalid":Pe||void 0,"aria-describedby":Ve,required:!0}),Pe&&i.jsx("p",{id:"fb-body-error",className:"fb-error",children:JLe()}),i.jsx(PIe,{images:ne,addRef:l}),Fe&&i.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:QIe(J)}),i.jsxs("div",{className:"fb-tools",children:[i.jsx(LIe,{images:ne,buttonRef:l}),i.jsx(QMe,{open:ee,onToggle:()=>de(Le=>!Le)})]}),C&&i.jsxs("div",{className:"fc-account",children:[i.jsxs("label",{className:"fc-anon",children:[i.jsx(_g,{checked:te,onChange:Le=>K(Le.target.checked)}),o(pPe)]}),!te&&i.jsx("p",{className:"fc-sent-as",children:gPe((x==null?void 0:x.email)??null,A)})]}),i.jsx(eIe,{open:ee,contact:G,onContact:Q,account:V,mail:A})]}),i.jsxs("p",{className:"fb-facts",children:[i.jsx("span",{className:"fb-facts-text",children:ke?ck(aPe(),"facts",i.jsx("span",{className:"fb-facts-value",children:ke})):sPe()}),i.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[i.jsx("kbd",{"data-symbol":TPe(ot)||void 0,children:ot}),i.jsx("kbd",{children:ce})," ",o("shell.feedback.toSend")]})]}),Se.state==="failed"&&i.jsx("p",{className:"fb-error",role:"alert",children:Se.message})]}),i.jsxs("div",{className:"fb-foot",children:[He&&i.jsx("button",{ref:f,type:"button",className:`btn danger fb-discard${_e.armed?" armed":""}`,onKeyDown:Le=>{Le.repeat&&Le.preventDefault()},onClick:_e.press,title:_e.armed?xW():nDe(),children:_e.armed?tDe():eDe()}),i.jsx("button",{type:"button",className:"btn",onClick:e,children:o("shell.cancel")}),i.jsx("button",{ref:p,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...gs(ve),children:i.jsxs("span",{className:"fb-send-label",children:[i.jsx("span",{className:"fb-send-idle",children:o("shell.feedback.send")}),i.jsx("span",{className:"fb-send-busy",children:o("shell.feedback.sending")})]})})]})]}),Qe&&i.jsxs("div",{className:"fb-done",children:[i.jsx(gg,{}),i.jsx("p",{className:"fb-done-line",children:E8(xe,A)})]})]})}}const nb=[{id:"deck",get title(){return S("settings.key.group.deck")},rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",get action(){return S("settings.key.all")},binds:[","],chord:!0},{cap:"?",get action(){return S("settings.key.sheet")},binds:["?"]},{cap:"C",get action(){return S("settings.key.clear")},binds:["c","C"]},{cap:"R",get action(){return S("settings.key.rearrange")},binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",get action(){return S("settings.key.undo")},binds:["z","Z"],chord:!0},{cap:"V",get action(){return S("settings.key.sound")},binds:["v","V"]},{cap:"M",get action(){return S("settings.key.mute")},binds:["m","M"]},{cap:"T",get action(){return S("settings.key.theme")},binds:["t","T"]},{cap:"Esc",get action(){return S("settings.key.esc")},binds:["Escape"]}]},{id:"question",get title(){return S("settings.key.group.question")},rows:[{cap:"W",get action(){return S("settings.key.waiting")},binds:["w","W"]},{cap:"N",get action(){return S("settings.key.nextWaiting")},binds:["n","N"]},{cap:"Shift + N",get action(){return S("settings.key.prevWaiting")},binds:["N"]}]},{id:"canvas",get title(){return S("settings.key.group.canvas")},rows:[{cap:"J",get action(){return S("settings.key.next")},binds:["j","J"]},{cap:"K",get action(){return S("settings.key.prev")},binds:["k","K"]},{cap:"P",get action(){return S("settings.key.peek")},binds:["p","P"]},{cap:"F",get action(){return S("settings.key.fit")},binds:["f","F"]},{cap:"Z",get action(){return S("settings.key.zoom")},binds:["z","Z"]},{cap:"Delete",get action(){return S("settings.key.delete")},binds:["Delete"]},{cap:"Tab",get action(){return S("settings.key.tab")},binds:[]},{cap:"Enter",get action(){return S("settings.key.enter")},binds:["Enter"]},{cap:"Shift + Enter",get action(){return S("settings.key.shiftEnter")},binds:["Enter"]},{get cap(){return S("settings.key.cap.drag")},get action(){return S("settings.key.drag")},binds:[]},{get cap(){return S("settings.key.cap.shiftClick")},get action(){return S("settings.key.shiftClick")},binds:[]},{get cap(){return S("settings.key.cap.click")},get action(){return S("settings.key.click")},get panelAction(){return S("settings.key.clickPanel")},binds:[]},{get cap(){return S("settings.key.cap.doubleClick")},get action(){return S("settings.key.doubleClick")},binds:[]},{get cap(){return S("settings.key.cap.hover")},get action(){return S("settings.key.hover")},binds:[]}]},{id:"panels",get title(){return S("settings.key.group.panels")},rows:[{cap:"Ctrl + K",macCap:"⌘ K",get action(){return S("settings.key.quick")},binds:["k","K"],chord:!0},{cap:"U",get action(){return S("settings.key.usage")},binds:["u","U"]},{cap:"L",get action(){return S("settings.key.sessions")},binds:["l","L"]},{cap:"F2",get action(){return S("settings.key.rename")},binds:["F2"]},{cap:"D",get action(){return S("settings.key.detail")},binds:["d","D"]},{cap:"H",get action(){return S("settings.key.history")},binds:["h","H"]},{cap:"A",get action(){return S("settings.key.accounts")},binds:["a","A"]},{cap:"S",get action(){return S("settings.key.machine")},binds:["s","S"]},{cap:"B",get action(){return S("settings.key.bw")},binds:["b","B"]},{cap:"I",get action(){return S("settings.key.jira")},binds:["i","I"],integration:"jira"}]}],dDe={cap:"Ctrl + `",get action(){return S("settings.key.workspace")},binds:["`"],chord:!0},uDe={id:"workspace",get title(){return S("settings.key.group.workspace")},rows:[dDe,{get cap(){return S("settings.key.cap.click")},get action(){return S("settings.key.wsClick")},binds:[]},{cap:"Enter",get action(){return S("settings.key.wsEnter")},binds:["Enter"]},{cap:"Shift + Enter",get action(){return S("settings.key.wsBeside")},binds:["Enter"]},{get cap(){return S("settings.key.cap.drag")},get action(){return S("settings.key.wsDrag")},binds:[]},{cap:"1 – 4",get action(){return S("settings.key.wsPanes")},binds:["1","2","3","4"]}]},hDe={id:"terminal",get title(){return S("settings.key.group.terminal")},rows:[{cap:"Esc",get action(){return S("settings.key.paneEsc")},binds:["Escape"]},{cap:"Ctrl + Shift + X",macCap:"⌃ ⇧ X",get action(){return S("settings.key.release")},binds:["x","X"],chord:!0},{cap:"Ctrl + =",macCap:"⌘ =",get action(){return S("settings.key.textLarger")},binds:["=","+"],chord:!0},{cap:"Ctrl + -",macCap:"⌘ -",get action(){return S("settings.key.textSmaller")},binds:["-"],chord:!0},{cap:"Ctrl + 0",macCap:"⌘ 0",get action(){return S("settings.key.textReset")},binds:["0"],chord:!0}]};function pDe(e){const t=e.findIndex(n=>n.id==="canvas");return[...e.slice(0,t),uDe,hDe,...e.slice(t)].map(n=>n.rows.some(a=>a.panelAction!==void 0)?{...n,rows:n.rows.map(a=>a.panelAction!==void 0?{...a,action:a.panelAction}:a)}:n)}const gDe=/ ?\([A-Z?]\)/g;function r7(e,t=()=>!0,n=!1){const a=s=>s.integration===void 0||t(s.integration);return e&&!n&&nb.every(s=>s.rows.every(a))?nb:(n?pDe(nb):nb).map(s=>({...s,rows:s.rows.filter(a).filter(o=>e||o.chord||!o.binds.some(O1)).map(o=>e?o:{...o,action:o.action.replace(gDe,"")})})).filter(s=>s.rows.length>0)}function mDe(e,t){return e.split(/\{(\w+)\}/g).map((a,s)=>s%2===1&&a in t?i.jsx(m.Fragment,{children:t[a]},s):a===""?null:i.jsx(m.Fragment,{children:s%2===1?`{${a}}`:a},s))}const ZA=["deck","question"],fDe=["workspace","terminal","canvas","panels"];function bDe(e){const t=[],n=[],a=o=>o.reduce((r,c)=>r+c.rows.length+1,0),s=e.some(o=>o.id==="workspace")?[...ZA,"panels"]:ZA;for(const o of e)((ZA.includes(o.id)||fDe.includes(o.id)?s.includes(o.id):a(t)<a(n))?t:n).push(o);return[t,n].filter(o=>o.length>0)}function kDe(e){return e.includes(" + ")?e.split(" + "):/^[⌘⌃⌥⇧] /.test(e)?e.split(" "):[e]}function vDe({onClose:e,onTour:t,onSettings:n,workspace:a=!1,extraGroups:s}){const o=se(),r=Zt(e),c=tn(e),l=zs(js()),u=sa(),h=Xg(),p=r7(u,b=>Qo(h,b),a),f=s!=null&&s.length?[...p,...s]:p;return i.jsxs(dn,{scrim:c,dialogRef:r,className:"key-help",labelledBy:"key-help-title","aria-describedby":u?void 0:"key-help-off",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:o("settings.key.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:e,label:o("settings.key.close")})})]}),i.jsxs("section",{className:"modal-body",children:[!u&&i.jsxs("div",{className:"kh-off",children:[i.jsx("p",{className:"kh-off-text",id:"key-help-off",children:mDe(o("settings.key.offText",{title:"{title}",place:"{place}"}),{title:i.jsx("strong",{children:o("settings.key.offTitle")}),place:i.jsx("span",{className:"kh-place",children:o("settings.key.place")})})}),n&&i.jsx("button",{type:"button",className:"btn",onClick:n,children:o("settings.key.openSettings")})]}),t&&i.jsx("p",{className:"kh-intro",children:o("settings.key.tourText")}),i.jsx("div",{className:"kh-cols",children:bDe(f).map((b,v)=>i.jsx("div",{className:"kh-col",children:b.map(w=>i.jsxs("section",{className:"kh-block",children:[i.jsx("h3",{className:"kh-group",children:w.title}),w.rows.map(T=>i.jsxs("div",{className:"sc",children:[i.jsx("span",{className:"kh-action",children:T.action}),i.jsx("span",{className:"kh-keys",children:kDe(l&&T.macCap?T.macCap:T.cap).map((y,x)=>i.jsxs(m.Fragment,{children:[x>0&&i.jsx("span",{className:"kh-plus",children:"+"}),i.jsx("kbd",{children:y})]},x))})]},`${w.id}:${T.cap}:${T.action}`))]},w.id))},v))})]}),i.jsxs("footer",{className:"modal-foot kh-bottom",children:[u&&i.jsxs("p",{className:"kh-foot",children:[o("settings.key.note")," ",o("settings.key.switchNote",{place:o("settings.key.place")})]}),t&&i.jsx("button",{type:"button",className:"kh-tour",onClick:t,children:o("settings.key.tour")})]})]})}function wDe(e,t){return`${e}#${t}`}function yDe(e,{lan:t,now:n,closed:a}){if(t===void 0)return[];const s=[];for(const o of e??[]){const r=o.reauth;if(!r||r.dismissed||o.origin!=="ccdeck_signin")continue;const c=wDe(r.key,r.since);if(a.has(c)||Sxe(r.key,o.email,t,n))continue;const l=o.email??"";s.push({id:c,key:r.key,since:r.since,num:o.num,email:l,name:l||o.alias||S("accounts.accountN",{n:o.num}),alias:l&&o.alias?o.alias:null})}return s}function xDe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(a=>a.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(a.num)===String(t.num))).map(a=>a.id):[]}function c7({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function CDe(e,t=S){return t("accounts.reauth.title",{count:e})}function SDe(e,t=S){return t("accounts.reauth.lead",{count:e})}const TDe=(e=S)=>e("accounts.reauth.expired"),NDe=(e=S)=>e("accounts.reauth.singleNote"),ADe=(e=S)=>e("accounts.reauth.laterTip");function jDe(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const a=[...n].sort((s,o)=>(s.at??0)-(o.at??0));return{request:a[0],waiting:a.length-1}}function EDe({request:e,waiting:t,busy:n,now:a,onAccept:s,onDecline:o,onLater:r}){const c=se(),l=m.useRef(null),u=Zt(r,{focusRef:l}),h=tn(r),p=oc(n,"accept"),f=oc(n,"dismiss");return i.jsxs(dn,{scrim:h,dialogRef:u,className:"lan-ask",labelledBy:"lan-ask-title","aria-describedby":"lan-ask-who",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:c("lan.ask.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:r,label:c("lan.ask.later")})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{id:"lan-ask-who",className:"lan-ask-who",children:i.jsx(qu,{text:c("lan.ask.who",{when:xR(e.at,a)}),parts:{name:i.jsx("strong",{className:"lan-ask-name",children:e.name}),addr:i.jsx("code",{className:"ap-lan-code",children:e.addr})}})}),i.jsx("p",{className:"lan-ask-note",children:c("lan.ask.note")}),i.jsx("p",{className:"lan-ask-fp",children:c("lan.ask.fp")}),i.jsx("code",{className:"lan-ask-fp-box",children:e.fp}),t>0&&i.jsx("p",{className:"lan-ask-more",children:c("lan.ask.more",{count:t})})]}),i.jsxs("footer",{className:"modal-foot lan-ask-foot",children:[i.jsx("button",{type:"button",ref:l,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:o,title:c("lan.ask.declineTitle"),children:c(n==="dismiss"?"lan.ask.declining":"lan.ask.decline")}),i.jsx("button",{type:"button",className:"btn primary",disabled:p.disabled,"aria-busy":p.busy,onClick:s,title:c("lan.ask.acceptTitle"),children:c(n==="accept"?"lan.ask.accepting":"lan.ask.accept")})]})]})}function RDe(e){const t=m.useRef(!1),n=zDe(e),a=c7({rows:n?1:0,ours:t.current,dialogs:Rn.dialogDepth()});t.current=a;const s=a&&n?n:null;return{node:i.jsx(Ft,{when:s,children:o=>o}),pairing:s!=null}}function zDe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:a,deferLanPair:s}){const{request:o,waiting:r}=jDe(e,t.current);return o?i.jsx(EDe,{request:o,waiting:r,busy:n,now:Date.now(),onAccept:()=>void a("accept",o.fp),onDecline:()=>void a("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function qDe({rows:e,onSignIn:t,onLater:n,firstRef:a}){const s=se(),o=e.length===1?e[0]:null;return i.jsxs("section",{className:"modal-body",children:[o?i.jsxs(i.Fragment,{children:[i.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:SR(s,"accounts.reauth.leadOne",{name:i.jsxs(i.Fragment,{children:[i.jsx("strong",{className:"reauth-name",children:o.name}),o.alias?i.jsxs("span",{className:"reauth-alias",children:[" (",o.alias,")"]}):null]})})}),i.jsx("p",{className:"reauth-note",children:NDe(s)})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:SDe(e.length,s)}),i.jsx("ul",{className:"reauth-list",children:e.map((r,c)=>i.jsxs("li",{className:"reauth-row",children:[i.jsxs("span",{className:"reauth-who",title:r.alias?`${r.alias} — ${r.name}`:r.name,children:[r.name,r.alias?i.jsxs("span",{className:"reauth-alias",children:[" ",r.alias]}):null]}),i.jsx("span",{className:"reauth-what",children:TDe(s)}),i.jsx("button",{type:"button",className:"btn",ref:c===0?a:void 0,"aria-label":s("accounts.reauth.againAs",{name:r.name}),onClick:()=>t(r),children:s("accounts.reauth.again")})]},r.id))}),i.jsx("p",{className:"reauth-note",children:s("accounts.reauth.keeps")})]}),i.jsxs("div",{className:"reauth-acts",children:[i.jsx("button",{type:"button",className:"btn",title:ADe(s),onClick:n,children:s("accounts.reauth.later")}),o&&i.jsx("button",{type:"button",className:"btn primary",ref:a,onClick:()=>t(o),children:s("accounts.reauth.again")})]})]})}function _De({rows:e,onSignIn:t,onLater:n}){const a=se(),s=m.useRef(null),o=Zt(n,{focusRef:s}),r=tn(n);return i.jsxs(dn,{scrim:r,dialogRef:o,className:"reauth-ask",labelledBy:"reauth-title","aria-describedby":"reauth-lead",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:CDe(e.length,a)})}),i.jsx("div",{className:"modal-actions",children:i.jsx(Za,{onClick:n,label:a("accounts.reauth.laterEsc")})})]}),i.jsx(qDe,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})}function LDe({rows:e,signingIn:t,signIn:n,signedIn:a,refresh:s,closeSignIn:o,later:r,pairing:c=!1}){const l=m.useRef(!1),u=Rn.dialogDepth()+(c?1:0),h=t!=null||c7({rows:e.length,ours:l.current,dialogs:u});return l.current=h,i.jsxs(i.Fragment,{children:[i.jsx(Ft,{when:t,children:p=>i.jsx(yV,{email:p.email||null,onClose:o,onChanged:s,onSignedIn:a})}),i.jsx(Ft,{when:!t&&h,children:()=>i.jsx(_De,{rows:e,onSignIn:n,onLater:r},e.length===1?"one":"many")})]})}const PDe={"4.0.3":[{title:"🪟 Sessions start on Windows right after ccdeck starts",body:"On Windows, starting or opening a session in the first moments after ccdeck starts no longer fails with “The terminal engine is unavailable.” The deck now waits until the terminal engine has finished starting."}],"4.0.2":[{title:"🖱️ A click on a Board card opens the session in Workspace",body:"With the terminal on, clicking a session's card on the Board switches to Workspace with that session in the pane and the keys in it, and Sessions shows the same rows in both views."},{title:"🔍 The Inspector opens beside your Workspace session",body:"On a window 1320 px or wider, opening a session in Workspace unfolds the Inspector next to its terminal, with Usage and This machine at the window's edge, and its context and recap are easier to scan."},{title:"🗂️ Sessions appears whole when the deck loads",body:"The Sessions list waits for the session history to load and then shows every row at once, in its final order, instead of filling in and reshuffling."},{title:"🧰 Panes draw correctly with tmux 3.2 to 3.5",body:"Where the system's tmux is 3.2 to 3.5, as on Ubuntu 24.04, the deck now runs its own newer tmux, so a pane that reconnects no longer shows a line shifted by one character; sessions already running keep their tmux until they end."},{title:"🎨 Codex keeps its colours in terminal panes",body:"A Codex session started from the deck now shows its prompt and status line in colour, even where the deck itself runs with NO_COLOR set."},{title:"📡 Browser Watch's radar keeps turning",body:"The radar no longer stops with an error when its dialog has no room for it, and draws again as soon as there is space."}],"4.0.0":[{title:"🖥️ Your sessions' terminals, inside the deck",body:"Open, resume or attach to a Claude Code or Codex session in a terminal pane on the board or in Workspace, on Linux, macOS and Windows.",priority:"highlight",noticeLabel:"Setup change",notice:"The terminal is on by default; Settings › General › Experimental turns it off. It runs through ccdeck's terminal engine, a separate program under its own licence that comes with ccdeck (npm installs the one for this machine, the desktop app carries it) and is checked before every start. Windows on ARM has no terminal yet.",details:"In Workspace, a Claude Code or Codex session's pane offers Chat | Term: Chat shows the conversation, and you can reply from it while the session's terminal is open here. The terminal has its own text size, apart from the page's: Aa, or Ctrl+= / Ctrl+- / Ctrl+0 (⌘ on a Mac)."},{title:"🧭 A calmer deck that shows what needs you",body:"The Sessions list reads like an inbox, colour on the board means state, and the Inspector offers each session's next step under its title.",priority:"highlight",details:"Counters at zero and key hints you have learned step aside, and the board's tools sit in one ⋯ menu. Quotas moved from Sessions to Usage, and Codex's helper agents stay inside their main conversation. Every key works as before."},{title:"🪟 Up to four sessions side by side in Workspace",body:"Drag a session onto a pane's edge, or press ⇧↵ on its row, to open it beside the others; one pane has the keys while the rest keep running.",priority:"highlight",details:"Rename a session where its name is drawn (double click, F2 or the pencil), and that name shows everywhere in the deck; for a Codex session, Codex itself gets the new name too. The Sessions list's edge drags to resize it."},{title:"🔀 Move a Claude session here from Ghostty",body:"On a Mac, a Claude Code session running in Ghostty 1.4 or later offers Move session here in its ccdeck pane: one click continues the same conversation in that pane."},{title:"🔁 A Codex account switch keeps the turn going",body:"Switching Codex accounts lets the running tool call finish first, and a turn stopped by a usage limit in the minutes before the switch continues on the new account."},{title:"🔔 A notification when a session finishes",body:"If Settings › Notifications › While the deck is closed is on, a session that ends its turn now notifies you too, as a waiting one already did."},{title:"🚪 A pane closes when its agent exits",body:"Ending an agent yourself (/exit or Ctrl+D) closes its pane, and the session stays in the list. After a crash or a kill, the pane keeps its last frame and offers Reopen here."},{title:"▶️ The board always stays live",body:"Pause is gone from the board's menu and the keyboard help, and Space no longer freezes the board."},{title:"👥 Accounts you can switch to now come first",body:"Other accounts are grouped by whether you can use them now, and the sort menu is gone. Rows stay put while your pointer is in the list."},{title:"📂 New session finds its folder by search",body:"One field searches your projects, remembered folders and Git repositories, and takes a full path; Worktrees groups each repository's worktrees. The deck says before starting if an agent cannot open that folder."},{title:"🎨 Ink, a new light theme",body:"Settings › Appearance now has Ink: warm paper surfaces with charcoal text."},{title:"📱 The board as a card stack on a phone",body:"On a phone, the board is a full-width stack of readable cards, and More opens the Command Panel."},{title:"🌡️ CPU temperature on Intel Macs",body:"This machine now shows the CPU temperature on Intel Macs too."},{title:"⌨️ ccdeck tui stays current after a deck restart",body:"The account screen in ccdeck tui keeps updating when the deck restarts underneath it."}],"3.82.4":[{title:"🪟 Start at login works on Windows without administrator rights",body:'Turning on Start at login now works on ordinary Windows accounts too. Before, Windows answered "Access is denied" unless ccdeck ran as an administrator.',priority:"highlight"},{title:"🧹 No error at login after removing ccdeck",body:"If Start at login is on and you remove ccdeck with npm uninstall, the login item now ends quietly instead of failing at every login.",notice:"On Windows, a login item turned on before this version keeps its old form until you turn Start at login off and on again."}],"3.82.3":[{title:"🖥️ Windows CPU performance limits",body:"Machine now shows CPU performance limits reported by Windows, even when no CPU temperature sensor is available.",priority:"highlight",notice:"The reading includes power-policy and firmware limits. It does not identify overheating or rule out every hardware thermal restriction."},{title:"🎯 More reliable session status",body:"Failed turns stop appearing active, and background scans no longer create phantom sessions.",priority:"highlight"},{title:"🔁 Usage history recovers from temporary errors",body:"Project usage, quota history and tool history recover more reliably after temporary read or save failures.",priority:"highlight"},{title:"🧹 No hook errors in Claude Code after uninstalling the desktop app",body:"From this version on, the hook the desktop app leaves in Claude Code's settings ends quietly once the app is uninstalled, instead of showing an error on every tool call."}],"//":["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.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is","author metadata and never a release.","","Editorial metadata: optional //summaries maps a release version to one","specific, verified headline (1–120 characters). No generic marketing claims.","A note may have priority: highlight or required. Choose at most 3 highlights,","only when warranted. Unmarked notes go under More improvements when highlights","exist. Legacy notes stay unabridged; legacy upgrade notes stay visible.","Use required for breaking changes, changed settings, privacy/security impact,","compatibility requirements or mandatory actions. A highlight with any such","impact must also carry a notice with all essential qualifications: highlight","alone is editorial placement, not an instruction to surface it across upgrades.","Required notes and notices stay visible across upgrades, never in a closed section.","Write a short benefit-led title and one useful sentence where possible; keep","opt-outs and limits. Avoid inflated adjectives, filler and generic claims.","Preserve original factual meaning. Never invent capabilities or results.","Retain setup instructions and compatibility minimums. Say only what a user","sees in the app: usage reports, telemetry and environment variables are for","README to explain, not for a note.","Verify each claim against the released diff and tests. No promotion","for invisible fixes. Do not rewrite historical releases to fit the layout.","","Keep highlight titles within 72 characters (excluding a leading emoji) and","benefit descriptions within 240 characters. These limits are validated.","Put essential compatibility, privacy or configuration details in optional","notice text, outside More improvements. Current/upgrade notices stay visible and","have no truncation limit. A notice also keeps its change visible across upgrades.","Optional noticeLabel gives it a short factual heading (1–32 characters), such","as Setup change or Compatibility. It requires notice text; default is Important.","Optional details holds secondary context, shown under the same improvements","disclosure for highlights and beside other notes. Keep the body to one useful","sentence. Never move setup, safety, privacy or compatibility conditions into","details: use notice for those, so they remain visible across upgrades.","The disclosure counts other improvements, not extra details of highlights.","Mark any other mandatory action as required. The manual digest shows only the","running release; Release history opens the full changelog. Upgrade notes keep","required/noticed changes visible and disclose the other notes in that range.","Unclassified legacy upgrade notes stay visible rather than guessing safety.","Before adding editorial metadata to a release, review every note: unmarked","changes will be treated as optional in later upgrades. Never infer safety","from a title, keyword, emoji, position or a shortened description.","","Optional icon is a semantic key: plans, accounts or skills. Use it only when","it matches the change; do not infer icons from versions, titles or emoji.","The modal shows a title's leading emoji; the glyph stands in only for a title","without one."],"//summaries":{"4.0.3":"Sessions start on Windows right after ccdeck starts","4.0.2":"Board cards open in Workspace, the Inspector opens with the session, and panes draw right on tmux 3.2–3.5","4.0.0":"A calmer deck, with your sessions' terminals inside it","3.82.3":"Windows CPU limits and more reliable session and usage history","3.82.2":"Arrow keys show the selected row on ccdeck tui's Network tab","3.82.1":"Clearer network shortcuts, accurate account capacity and Codex recovery fixes","3.82.0":"Steadier Codex switching, and uninstall cleans up Codex's terminal selection","3.81.4":"Codex account switching works with Windows sandbox logins","3.81.3":"More reliable Codex switching and quieter account rows","3.81.2":"Codex account switches wait through activity changes","3.81.1":"Codex reconnection and Windows fixes","3.81.0":"Codex accounts on a par with Claude's, Codex over Local network, and ccdeck tui for the whole deck","3.80.0":"Codex account switching, continuation and sharing","3.53.0":"Codex accounts, with sign-in, switching and Auto-switch","3.52.0":"ccdeck in nine more languages","3.51.0":"Jira integration updates","3.46.0":"Plans, accounts and skills at a glance"},"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4","3.40.1","3.41.3","3.43.1","3.43.3","3.48.1","3.49.1","3.53.1","3.53.3","4.0.1"],"3.82.2":[{title:"⌨️ Arrow keys show where you are on ccdeck tui's Network tab",body:"In ccdeck tui, ↑ and ↓ on the Network tab now highlight the row you are on and scroll the list to it."}],"3.82.1":[{title:"Local network controls, easier to find",body:"Open this deck’s network settings or the network graph directly from the Local network row.",priority:"highlight"},{title:"More accurate account capacity",body:"Accounts at their weekly limit no longer inflate the average remaining five-hour capacity.",priority:"highlight",icon:"accounts"},{title:"Codex account recovery fixes",body:"Codex account control can recover after temporary startup timeouts and checks account changes again when reconnecting.",priority:"highlight",icon:"accounts"}],"3.82.0":[{title:"🔄 Codex switching recovers instead of staying stuck",body:"A failed reconnect or manual switch no longer leaves Codex account control disconnected, and turning Auto-switch off stops a switch it had already queued.",priority:"highlight",icon:"accounts",details:"On Windows, a Codex connection that never answers now fails after 30 seconds instead of waiting forever."},{title:"⏱️ Slow Codex logins get more time and a Retry button",body:"ccdeck now gives Codex more time to read a login during a switch, and if it still runs out, the panel says why and offers Retry selected account.",priority:"highlight",icon:"accounts"},{title:"🧹 Uninstall also removes Codex's terminal selection",body:"ccdeck --uninstall now takes the codex block that Enable terminal selection added out of your shell profiles, and names any file it could not clean.",priority:"highlight"},{title:"⌨️ A opens Codex accounts on a Codex-only deck",body:"With Codex alone, the Codex accounts door now shows its A key, and its name follows your interface language."},{title:"🔑 Jira token help names the permission for comments and statuses",body:"A scoped Jira Cloud token needs write:jira-work to add comments and change statuses, and the token help and Settings › Integrations now say so."},{title:"🌍 Codex messages read correctly in every language",body:"The message about a Codex login folder that is not private enough had lost its accented and non-Latin letters; it is whole again, and the new timeout message is translated."}],"3.81.4":[{title:"🔄 Switch Codex accounts without another sign-in",body:"On Windows, Switch can use your existing native Codex login while keeping its sandbox permissions unchanged.",priority:"highlight",icon:"accounts"},{title:"🔐 New Windows accounts are ready for switching",body:"Accounts added through + now get private folders from the start, and older native login files are recognized."},{title:"💬 Clearer account-switching errors",body:"If a login cannot be used safely, ccdeck explains the folder-permission problem and how to continue."}],"3.81.3":[{title:"🔄 More reliable Codex account switching",body:"ccdeck retries temporary connection failures before switching the open Codex app.",priority:"highlight",icon:"accounts"},{title:"✨ Quieter account switching",body:"Successful switches no longer leave an extra message under the account row."},{title:"⌨️ Arrow-key navigation in ccdeck tui",body:"The footer and help now show the left and right arrow keys for moving between tabs."}],"3.81.2":[{title:"🔄 Codex account switches wait through activity changes",body:"If new work starts while a switch is being prepared, ccdeck now waits and retries safely instead of leaving the switch failed.",priority:"highlight",icon:"accounts"}],"3.81.1":[{title:"🔐 Fix Codex sharing on Windows",body:"Codex logins blocked by Windows folder permissions can now be prepared for sharing from the Share dialog.",priority:"highlight",icon:"accounts",noticeLabel:"Folder permissions",notice:"Secure permissions and share is optional and restricts the selected Codex folders and auth.json to your Windows user, including changes to inherited access for their contents. Your login, settings and active account stay in place. Automatic network sync never changes folder permissions."},{title:"🪟 Windows updates reach the copy you use",body:"Global npm updates now target the active installation and confirm that newer files arrived before showing installed.",priority:"highlight",noticeLabel:"Already stuck?",notice:"An older Windows installation already stuck at installed may need one manual update to receive this fix. For the desktop app, run the latest Windows installer. For npm, follow the Windows recovery steps in README, then restart ccdeck. Accounts and settings are kept."},{title:"🔄 Reconnect Codex without a false login-change warning",body:"Connecting to an unchanged Codex account no longer pauses control because of its initial account update.",priority:"highlight",icon:"accounts"},{title:"📡 See why a shared login did not arrive",body:"The network map now shows a failed transfer instead of promising that the login will arrive next round."}],"3.81.0":[{title:"👥 Codex accounts work the way Claude's do",body:"A Codex account's menu now has Set as home, Share and Projects, and Auto-switch shows even when you have only one Codex account.",priority:"highlight",icon:"accounts",details:"Auto-switch moves back to the home account once it has room again, and a notification says each move it makes. Projects shows where that account's work went, per project and per day."},{title:"📡 Share Codex logins with your paired decks",body:"Local network now lists Codex logins beside Claude's, and a paired deck adds a login you tick as a Codex account of its own.",priority:"highlight",icon:"accounts",noticeLabel:"Login privacy",notice:"Only the logins you tick are sent, and the one this deck is using stays here unless Send the login this deck is using too is on. A copy another deck renewed is repaired in place; a separate sign-in is never replaced.",details:"Codex rows show which paired decks a login is offered to, as Claude rows do, and Local network opens from the Codex side too."},{title:"⌨️ ccdeck tui looks after the whole deck over SSH",body:"The terminal view now draws the machine live, manages Claude and Codex accounts from a menu, and pairs and shares decks on a Local network tab.",priority:"highlight",details:"A Codex account signs in with a link and a code you type into any browser."},{title:"➕ Paste a Codex share from the + button",body:"Import Codex accounts is now the Paste a share tab under + in the Codex accounts panel, as on Claude's side."},{title:"🪟 The desktop window comes back the way you closed it",body:"Reopened from the tray, the Dock or a second launch, the window keeps its size and place, and stays maximized or full screen if it was.",details:"On macOS, a window reopened after an update or at login never enters full screen."}],"3.80.0":[{title:"Switch Codex accounts without losing your place",body:"Move supported running Codex conversations and their subagents to another account, then continue the same work.",priority:"highlight",icon:"accounts",noticeLabel:"Compatibility",notice:"Requires Codex 0.166.0 or newer and a private auth.json login on a supported shared native server. Conversations connected to that server switch together. ccdeck waits for tools and approvals, and must stay open to renew the selected login. After a lost connection or restart, a server that cannot confirm the workspace identity requires Reconnect selected account. If continuation is unconfirmed, check the conversation before continuing manually; uncertain sends are never repeated automatically."},{title:"Share Codex logins between your machines",body:"Choose accounts to export, then paste the code into Import Codex accounts on another machine, including Windows.",priority:"highlight",icon:"accounts",noticeLabel:"Login privacy",notice:"Sharing is optional and exports live ChatGPT credentials, including the renewal token, from file-backed logins. The code is encoded, not encrypted, and has no automatic expiry or ccdeck revocation. Use a trusted private channel and delete clipboard or message copies afterward. Renewal on one machine can invalidate the other copy and require signing in again. Configuration and conversation history are not transferred."},{title:"See your available Codex resets",body:"Usage shows saved rate-limit resets and their nearest expiry when the selected account provides them.",priority:"highlight",noticeLabel:"Availability",notice:"Reset inventory requires a validated file-backed login and an available provider reading. Checking the inventory never spends a reset."},{title:"Continue managed terminal tasks on another account",body:"With Codex Auto-switch enabled, supported terminal tasks can resume the same conversation on an account with quota after a usage-limit failure.",priority:"required",noticeLabel:"Terminal setup",notice:"Update an existing setup with Enable in terminal, then open a new terminal. Interactive continuation requires Codex 0.166.0 or newer with the native remote transport. Only supported commands launched through ccdeck terminal selection are covered; explicit CODEX_HOME pins, independent sessions and incompatible profile settings require manual handling."},{title:"Help us improve Codex support",body:"We are continuing to improve Codex support, and feedback on switching, subagents and sharing is welcome through the Feedback button in ccdeck."}],"3.53.2":[{title:"🔁 The deck stays up on machines without Codex",body:"Since 3.53.0 a deck with no Codex restarted itself every few seconds, and it now stays up."}],"3.53.0":[{title:"👥 Codex accounts: sign in, switch and Auto-switch",body:"Add Codex accounts from ccdeck with the official sign-in, see each one's usage, choose the default for new sessions and, if you turn it on, let Auto-switch move to the account with room.",priority:"highlight",noticeLabel:"Codex accounts",notice:"Each account keeps its own Codex folder, and ccdeck never copies, logs or refreshes its tokens. Removing an account moves its folder to codex-profiles-removed instead of deleting it. Auto-switch is off by default and acts only on a reading taken now."},{title:"🔀 One Accounts panel for Claude and Codex",body:"With both CLIs installed, a Claude | Codex switch in the panel's header changes the view, never the account in use, and ccdeck remembers it."},{title:"🕐 Reset times fit in every language",body:"The time until a reset beside each quota bar is no longer cut where a language's words run longer."},{title:"🛠️ Tool and Skill activity work when the deck's folder is gone",body:"Both open again when the folder ccdeck was started from has been deleted."}],"3.52.0":[{title:"🌍 ccdeck in your language",body:"Choose Traditional or Simplified Chinese, German, Japanese, Korean, French, Spanish, Brazilian Portuguese or Romanian in Settings › General › Language. Until you choose, ccdeck follows your browser's language.",priority:"highlight",noticeLabel:"Language",notice:"What's new and text written by Jira, GitHub or GitLab stay as they were written, and anything without a translation shows in English."},{title:"📅 Codex 30-day windows say what a day may cost",body:"A Codex window reported as 30 days is paced over its real length, and its pace note says what a day may cost to last until the reset."}],"3.51.0":[{title:"✏️ Comment and change status in Jira",body:"Add a comment or change an issue’s status from its details in ccdeck.",priority:"highlight",noticeLabel:"Jira edits",notice:"Changes are sent to your connected Jira account and follow its permissions. Jira edits require a supported native build and filesystem; if safe coordination is unavailable, ccdeck refuses the edit and you can still browse your board."},{title:"📍 Jira moves follow your selection",body:"Drag the issue you select, move completed issues between sprints, and place issues at the end by default.",priority:"highlight"},{title:"🛠️ Reduced memory use during long sessions",body:"ccdeck releases more unused memory, and Jira edits recover more reliably when a connection is interrupted."}],"3.50.0":[{title:"🤝 Paired decks no longer each read a shared account's usage",body:"No more rate limits from every machine reading it: one deck reads the account and passes the numbers to the others. Hover the reading's age to see which deck read it."}],"3.49.0":[{title:"🗞️ What's new is shorter and easier to scan",body:"Up to three main changes come first and the rest wait under Show details; Check for updates moved to the dialog's More options menu."},{title:"👥 No warning when one account is in use on several decks",body:"The account row and the desktop no longer flag it, and the Login active on another deck switch is gone from Settings › Notifications; expired logins are still shown.",priority:"required"},{title:"📍 Auto-hidden sessions come back where they were",body:"With Hide finished sessions after on, a session that works again returns to its place, with its new subagents beside it rather than further down the board."},{title:"💻 Windows: About flags an outdated terminal CLI",body:"When the npm ccdeck on PATH is older than the desktop app, Settings › About shows the command that updates it."},{title:"✏️ Texts that fell behind are up to date",body:"Explore integrations says Jira can move issues, and the Radar and Where the time went tips match what the app does."}],"3.48.0":[{title:"🗂️ Jira: move issues between sprints and the backlog",body:"On a Scrum board ordered by Rank, drag issues or use Move to reorder them or send them to another sprint or the backlog, one at a time or up to 50 together. Browsing still only reads."},{title:"🔎 The Jira list is easier to scan",body:"Titles keep more room, a row's preview no longer covers the next row, the issue key shows once in the detail, and Clear filters stays in reach on a phone."},{title:"⌨️ ccdeck tui keeps your Claude accounts on one screen over SSH",body:"Switch accounts, turn Auto-switch on or off, and sign an account in with a link you open in any browser, all from the terminal."},{title:"🎮 Machine shows NVIDIA GPU readings",body:"On Linux and Windows with nvidia-smi: each GPU's utilization, video memory, temperature and power."},{title:"👤 Claude accounts are quieter, and an expired login has a Sign in button",body:"Telemetry is a small shield explained on hover or focus, and an account whose login expired shows Sign in on its own row."},{title:"🩹 Fewer page errors from browser extensions and translation",body:"The Accounts panel recovers when an extension breaks its requests, and Local network keeps working while the browser translates the page."}],"3.47.0":[{title:"⌨️ Quick open: Cmd/Ctrl+K reaches any panel, setting, session or theme by name",body:"Type a few letters to open a panel, land on a setting inside Settings, jump to a session or switch the theme. It is also Search on the bar."},{title:"⚙️ Settings › Claude Code changes Claude Code's own settings from the deck",body:"Twelve settings in five groups, from auto memory and compaction to the Co-Authored-By credit and the update channel, written to your settings.json on this computer."},{title:"📡 Radar monitors all the time, and packet capture is one explained step",body:"There is no Start or Stop any more: Radar finds Claude Code's collector by itself. Where capture needs a permission, Allow packet capture once asks for it on your press only."},{title:"⏱️ Tool activity shows where the time went, and Skill activity who starts your skills",body:"Tool activity splits the turns' time between Claude, this machine and you. Skill activity shows how many skill uses Claude, Codex or you started, overall and per skill."},{title:"📊 Usage remembers how full each quota week ended, and names your Claude plan",body:"Under each 7-day bar a line says how full the last weeks were at their reset. The Claude quota card shows your plan beside its title, as the Codex card does."},{title:"🗂️ Stripes, dialogs and floating panels are organized more evenly",body:"The doors on both edge stripes sit in named groups, dialogs share one frame, and T switches the theme inside any dialog too."},{title:"🪟 The desktop app works on a first run without Node, and integrations got fixes",body:"Usage no longer needs npm, and Claude Code installed while the app is open is picked up. Jira and GitLab avatars load, and panels reopen where you left them."}],"3.46.0":[{title:"🔗 Jira, GitHub and GitLab panels are easier to read and navigate",body:"Jira rows show each issue's status, lists answer the arrow keys and fit a phone, and a failed refresh says “Not updated”."},{title:"📡 Radar finds more Claude Code processes on Linux",body:"It now sees Claude Code started from its versioned install folder, plus connection attempts that got no reply and the telemetry variables it was launched with."},{title:"🗺️ Follow plans at any zoom",body:"See plan progress on session notes and directly on the canvas.",priority:"highlight",icon:"plans",details:"Subagents stay in one column beside their parent."},{title:"✅ Keep your Claude account in sync",body:"After `/login`, Accounts, Switch, Auto-switch and Usage follow your active Claude Code account.",priority:"highlight",icon:"accounts",details:"Auto-switch can also be set up while it is off."},{title:"📊 Account capacity and the Reset calendar have their own buttons",body:"Both open from the left stripe, under Claude accounts, instead of from the small gauge in the accounts panel's header."},{title:"🧩 See which skills your agents use",body:"Review skill activity from the right sidebar, including typed slash commands.",priority:"highlight",notice:"Counting typed slash commands adds a `UserPromptExpansion` hook to Claude Code's `settings.json` on supported versions (2.1.116+). Set `AGENTS_DECK_SKILL_HOOK=0` to opt out.",icon:"skills",noticeLabel:"Setup change"},{title:"📈 Load history keeps the reading you click",body:"Click a minute on a chart to keep its reading. Saved limit resets now show their expiry time, and Tool activity has a clearer icon."}],"3.45.0":[{title:"🔗 Read-only Jira, GitHub and GitLab panels beside your agents",body:"Settings › Integrations connects Jira (Cloud, Server or Data Center), GitHub, and GitLab.com or your own GitLab, each with a token, and a control on the left stripe opens its panel: a Jira board's backlog in Jira's own order, or a project's branches, pull or merge requests, pipelines and issues, with the item beside the list. The panels only read: they never comment, merge, re-run a job or change an issue. The token stays on this machine, in a file only you can read, and goes only to that connection's own API. Nothing is read until you connect a tracker, and then only while its panel is open."},{title:"📤 Each account says what its organization's telemetry sends",body:"A Team or Enterprise organization can turn on Claude Code's telemetry for every member, and Claude Code applies it without asking. Each account of such an organization now carries a line under its name: “Telemetry · usage data”, or “Telemetry · prompts, tool details” in the warning colour when your prompts and tool details are sent too. Its tooltip names the organization and where the data goes. After a switch, Auto-switch's notification and the row's “Now active” note say it too. The deck changes nothing; it learns what the organization turns on from a Claude Code session run on one of its accounts, and until then that account shows no line."},{title:"⚠️ A warning when a paired deck is on the same Claude login",body:"A Claude login renews once, so when two machines use one copied login, the one that renews second is signed out. When a paired deck on Local network says it is on the login this deck is using, the live account's row now says “Also active on” and names that deck, with what to do: use a different account on one of the machines, or sign in on each one separately. A switch onto such a login says so too, and so does one desktop notification per incident, “Login active on another deck” in Settings › Notifications, which is on by default."},{title:"📱 A phone opens one panel at most when the deck loads",body:"On a window 640 px wide or less, a reload used to open Accounts, Usage and the machine panel on top of each other, with none of the board in sight. It now opens at most one of them, preferring Usage over the machine panel, and Accounts and the session list open from the dock. A wider window loads exactly as before, and nothing you chose is forgotten."}],"3.44.0":[{title:"⛔ A turn that stops on an error now shows as stopped",body:"When Claude Code ends a turn on an API error, such as an expired login or a usage limit, it sends StopFailure instead of Stop. The deck now adds StopFailure to the hooks it writes in Claude Code's settings.json, but only when every Claude Code it finds is 2.1.78 or newer; with an older one, or one whose version it cannot read, nothing changes. The card then says “Stopped · login expired”, “Stopped · usage limit” or “Stopped · API error”, and the sessions one expired login stops together arrive as one notification that names them. Each needs a “continue” once a working login is active."},{title:"🔑 Auto-switch leaves an expired login, and nothing switches onto one",body:"When Claude Code has signed a login out and claude-swap's saved copy is dead too, Auto-switch now moves to another account under your home and weekly-reset rules, and its notification says why. Neither Auto-switch nor Switch moves onto a login that is already known to be expired: that account's row says its login expired, with Sign in again, and nothing moves."},{title:"💲 Usage totals say how complete they are",body:"The usage headline is always shown now, by the rule History and the model table already used: an exact total when every cost is known, a known $0 included; the known part with “+” when some tokens could not be priced; and “not priced”, never a bare $0, when no cost is known. Sessions whose cost is a known zero show it too."},{title:"📡 Radar: a resizable inspector, prompt previews and a JSON view",body:"Radar's inspector can be resized and shows prompt previews, highlights and each record as a JSON tree, beside the File view. Settings › Radar has a new Monitor automatically switch. It is off, so Radar still watches only after you press Start, as before; turn it on to have the deck start monitoring by itself."},{title:"🧰 Tool activity opens over the deck, with the first tool's details open",body:"Tool activity now opens as a dialog over the deck instead of a page of its own, with the first tool selected and its details beside the list. Escape closes the details first, then the dialog. On a phone the details open as a sheet."},{title:"🧩 Tool activity counts skills, and the slash commands you type if you opt in",body:"Tool activity's Skills tab ranks the skills your Claude Code and Codex agents used. Counting the slash commands you type needs Claude Code's UserPromptExpansion hook, which the deck adds to settings.json only when you start it with AGENTS_DECK_SKILL_HOOK=1 and every Claude Code it finds is 2.1.116 or newer. Without that variable nothing in settings.json changes."},{title:"▶️ Continue a background session that stopped",body:"A background session that stopped on an error has a Continue button on its card and panel: the deck stops it if Claude Code still lists it, then resumes it in its own folder with “Continue from where you left off.” Continue stopped background sessions, in Settings › General, presses it for you once per stop. It is off until you turn it on."},{title:"⌨️ ccdeck commands for your terminal",body:"ccdeck accounts, ccdeck switch, ccdeck usage, ccdeck sessions and ccdeck open work from any terminal. ccdeck switch --best goes where Auto-switch would, and every switch follows the deck's own rules. Over SSH, ccdeck open prints the line that opens the deck on your own computer. Each command takes --json for scripts."}],"3.43.4":[{title:"🔐 Local network no longer sends the login a deck is signed in to",body:`Two machines on one Claude login race to renew it, and the one that renews second is signed out with “Login expired”. So paired decks no longer receive the login a deck is signed in to right now. Every other login you tick is shared as before, and this one goes out once the deck switches to another account.
|
|
155
155
|
|
|
156
156
|
Update every paired deck: an older deck still sends the login it is using, and the decks paired with it still take it. To send it anyway, as before, turn on Send the login this deck is using too in the Local network dialog. Not covered yet: a paired deck that already holds a copy of that login, from before this deck switched to it, can still renew it first and sign this deck out. Auto-switch can also still move a deck onto a login another paired deck is using, if the deck already holds a copy of it.`}],"3.43.0":[{title:"🏠 Auto-switch can come back to a home account",body:"Choose Set as home in an account’s ⋯ menu. With Auto-switch on, Next account › Soonest weekly reset uses up quota that resets within 4 days first."},{title:"🔄 Sessions already running appear when ccdeck starts",body:"Busy Codex sessions, and Claude ones on macOS and Linux, show up again after a restart. Restore unfinished sessions, in Settings › General, turns it off."},{title:"⚙️ Settings, reorganized and searchable",body:"Search every setting from the top of the list. Keyboard, Data and About have sections of their own."},{title:"📋 Plan progress and reasoning effort on agent cards",body:"Cards show how far an agent is through its plan, and the effort beside the model. Finished sessions can hide themselves after a delay you choose."},{title:"✨ Calmer desktop updates, marked shared accounts, Codex sub-agents kept together",body:"The desktop app installs an update only when no agent is working or waiting. Accounts shared on Local network are marked."}],"3.42.0":[{title:"🔠 Text size and density, in Settings",body:"Five text sizes and five spacing levels, under Settings › Text & density."},{title:"🛠️ Tool activity: which tools your agents use, how long they take and what fails",body:"A new page on the stripe on the right. Its history is kept on this device only."},{title:"🎨 Gruvbox Dark, Light and Material themes",body:"Pick one in Settings › General. Switching themes now fades instead of snapping."},{title:"✨ A session-list drawer on phones, whole dates in usage history, the waiting session in the minimap",body:"Smaller fixes for the phone layout, the usage history chart and the canvas minimap."}],"3.41.1":[{title:"🪟 More reliable Windows updates",body:"Restart to update stops the app’s background server before installation begins."},{title:"📊 More accurate account capacity",body:"Elapsed resets and older readings no longer imply newly available quota. Account refreshes keep the latest valid readings."},{title:"🖥️ Better layouts on portrait displays",body:"Sessions fill the right columns, and the canvas starts near the top. Usage history controls stay reachable in narrow windows."},{title:"✨ Clearer load history and consistent icons",body:"Load history includes the current core-capacity multiplier below the charts. Refresh and external-link icons look consistent across system fonts."}],"3.41.0":[{title:"📅 Plan account resets",body:"See the next seven days of resets, account capacity and which readings need refreshing."},{title:"📊 Follow quota history",body:"Inspect recorded Claude and Codex quota readings to see how remaining capacity changes over time."},{title:"♻️ See cached input reuse",body:"Session usage details now show the percentage of measured input reused from cache."},{title:"📻 A more polished Radio Explorer",body:"Find radio stations with compact search and filters, explore workspace streams separately, and save favorites from either source. Playback and keyboard navigation are more reliable."},{title:"🌍 Radio flags on Windows",body:"Country flags now display correctly in the radio station list on Windows."},{title:"🔧 Clearer Telemetry Radar controls",body:"Change individual telemetry flags and use a simpler Monitor view."}],"3.40.2":[{title:"📻 Music is in Radio now, not in Settings",body:"Settings no longer has a Music section. Claude FM, Lofi Girl and the streams you added are under Workspace streams in Radio, on the right sidebar, and Radio’s player has the volume and mute. Your station, volume and streams are kept. Adding, renaming or removing a stream link is no longer offered."}],"3.40.0":[{title:"📻 Explore radio around the world",body:"Open Radio from the right sidebar to discover stations on a world map, filter by country, sound or language, and save your favorites. Recent listening, a daily pick and Surprise me make it easier to find something to play. Music keeps playing when you close the explorer. Volume now adjusts in 1% steps, and an unavailable stream automatically advances to the next station after one second."},{title:"🦊 Choose your canvas companion",body:"Choose Deck companion, Fox or Penguin in Settings › General. Your companion shares the existing canvas movements and music controls, and your choice stays saved."},{title:"📊 See what each session used",body:"Open a session’s usage details to inspect tokens, models and estimated cost. For Codex, compare Automatic, Standard, Fast and Flex pricing estimates without changing your Codex settings or billing."},{title:"A clearer canvas",body:"Session cards, tool traces and connections are easier to scan. The canvas reframes more reliably when resizing to portrait or rearranging sessions, and model cost estimates use updated pricing."}],"3.39.3":[{title:"A cleaner desktop window",body:"The desktop app now has one compact toolbar that follows your theme, with native window controls and an application menu. Wider side rails give icons more room; the Local network footer and unread badges are more compact."},{title:"Clearer account usage and Telemetry Radar",body:"Account usage shows reset times together with capacity. Telemetry Radar has a clearer monitoring workspace and keeps history for up to 24 hours. Radar remains Beta."},{title:"🔎 Telemetry Radar on Linux and Windows, with no Terminal step",body:"Radar now works on macOS, Linux and Windows. Press Start monitoring and ccdeck runs the capture itself, with no command to paste into Terminal, and keeps listening until you stop it. Capture needs a one-time setup for your user: Wireshark’s ChmodBPF helper on macOS, tcpdump with capture permission on Linux, or Wireshark with Npcap on Windows. Radar says what is missing, and once permission is granted it starts listening by itself."}],"3.39.1":[{title:"🎨 More themes, with clearer contrast",body:"Choose Omarchy, Matrix, Black Contrast, White Contrast or Catppuccin Mocha in Settings › General. Fresh installations start with Rider Black; your saved theme choice is preserved."},{title:"A little more room on the canvas",body:"The minimap is smaller, leaving more room for the character and your sessions. Undo and Resume now sit beside each other at the bottom of the canvas. Telemetry Radar is marked Beta while it is being tested and improved."}],"3.39.0":[{title:"🔎 Inspect Claude Code telemetry on macOS",body:"Telemetry Radar shows Claude Code's configured telemetry and can inspect traffic at destinations you choose. When settings are absent, it can show observed connections separately; a connection alone does not prove telemetry or reveal message contents. Captured telemetry can contain prompt or response content, and other apps sending to the same destination may appear too. Captured messages stay in ccdeck's memory, and no capture file is written."},{title:"🧭 Open panels from the edges",body:"Open the session list, Claude accounts, Usage, This machine, Usage history and Browser Watch from the window edges. You can keep several panels open beside the canvas; on a phone, the same controls sit in a bottom dock."},{title:"More control while you work",body:"Turn off single-key shortcuts if typed letters should not control the deck, see each stage while adding a Claude account, and undo a recent rearrangement. The topbar also names the Claude Code session waiting on you."},{title:"🎨 Two new dark themes",body:"Choose Rider Black or VS Code Black in Settings › General. Both add a darker canvas with flatter panels and distinct focus accents; your existing Light or Dark choice stays as it was."}],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). V opens it at Sounds, with each tone's volume and sound, and M turns sounds off or on from anywhere. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in Settings › Notifications, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:"Feedback, beside Settings at the right of the topbar (under More on a phone), opens a short form: pick what kind it is, write a few lines, and add a way to reach you under Add details if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why."}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The desktop app can also restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"Settings › General shows a small preview of the deck in each theme. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
|
|
157
157
|
|
|
@@ -347,15 +347,15 @@ While it is open it polls this machine once every few seconds, and it stops the
|
|
|
347
347
|
|
|
348
348
|
It marks that work now. A chart with bars in it means the agent is doing something, whether or not it has called a tool in the last minute; a flat chart means it genuinely is not. Hover it for the split — how many tool calls and how many blocks of thinking and writing landed in the last 60 seconds.
|
|
349
349
|
|
|
350
|
-
Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},zz="agent-dag.releaseNotesSeen";function SW(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function lc(e,t){const n=SW(e),a=SW(t);for(let s=0;s<Math.max(n.length,a.length);s++){const o=(n[s]??0)-(a[s]??0);if(o!==0)return o<0?-1:1}return 0}function vo(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function ODe(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function MDe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,a]of Object.entries(e)){if(!vo(n)||!Array.isArray(a))continue;const s=a.filter(ODe).map(c=>({title:c.title,body:c.body,...typeof c.details=="string"&&c.details.trim()?{details:c.details}:{},...c.priority==="highlight"||c.priority==="required"?{priority:c.priority}:{},...typeof c.notice=="string"&&c.notice.trim()?{notice:c.notice}:{},...typeof c.notice=="string"&&c.notice.trim()&&typeof c.noticeLabel=="string"&&c.noticeLabel.trim()&&c.noticeLabel.length<=32?{noticeLabel:c.noticeLabel}:{},...c.icon==="plans"||c.icon==="accounts"||c.icon==="skills"?{icon:c.icon}:{}})),o=e["//summaries"],r=o&&typeof o=="object"&&Object.hasOwn(o,n)?o[n]:void 0;s.length&&t.push({version:n,notes:s,...typeof r=="string"&&r.trim()?{summary:r}:{}})}return t.sort((n,a)=>lc(a.version,n.version))}function IDe(e){const t=e.filter(o=>o.priority==="highlight").slice(0,3),n=t.length>0,a=e.filter(o=>!t.includes(o)&&(!n||o.priority==="required"||o.priority==="highlight"||!!o.notice)),s=e.filter(o=>!t.includes(o)&&!a.includes(o));return{highlights:t,visible:a,more:s}}function DDe(e,t,n){const[a,...s]=e;if(!t)return{latest:vo(n)?e.find(c=>lc(c.version,n)===0):a,visiblePrevious:[],history:[]};const o=[],r=[];for(const c of s){const l=c.notes.some(p=>p.priority==="highlight"||p.priority==="required"||!!p.notice),u=c.notes.filter(p=>!l||p.priority==="required"||!!p.notice);u.length&&o.push({version:c.version,notes:u});const h=c.notes.filter(p=>!u.includes(p));h.length&&r.push({...c,notes:h})}return{latest:a,visiblePrevious:o,history:r}}const TW=MDe(PDe);function l7(e,t,n){return e.filter(a=>lc(a.version,n)<=0&&(t===null||lc(a.version,t)>0))}function FDe(e,t){return e.filter(n=>lc(n.version,t)===0)}const BDe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function d7(e){const t=BDe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function UDe(e){if(!e)return null;let t=null;try{t=e.getItem(zz)}catch{return null}return vo(t)?t:null}function WDe(e){if(!e)return!1;try{return e.getItem(zz),!0}catch{return!1}}function HDe(e,t){if(!e)return!1;try{return e.setItem(zz,t),!0}catch{return!1}}const GDe="agent-dag.tourSeen",fE="agent-dag.tourEdition",bg=2;function qz(e){const t=typeof e=="number"?e:typeof e=="string"&&/^\d{1,4}$/.test(e)?Number(e):0;return Number.isInteger(t)&&t>0?t:0}function VDe(e){if(!e)return!1;try{return qz(e.getItem(fE))>=bg}catch{return!1}}function KDe(e){if(!e)return!1;try{return e.setItem(GDe,"1"),qz(e.getItem(fE))<bg&&e.setItem(fE,String(bg)),!0}catch{return!1}}function $De({tourSeen:e,decision:t,phone:n=!1}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};const a=!e&&!n;if(t.reason==="welcome"||t.reason==="first-run")return{tour:a,notes:"none"};const s=t.show.length>0;return a?{tour:!0,notes:s?"after":"none"}:{tour:!1,notes:s?"now":"none"}}function JDe({stored:e,running:t,notes:n,remembers:a=!0}){if(!vo(t))return{show:[],record:null,reason:"no-version"};if(!vo(e)){if(!a)return{show:[],record:t,reason:"cannot-remember"};const r=FDe(n,t);return r.length?{show:r,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=lc(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=l7(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function YDe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const a=e.indexOf("`",n+1);if(a<0)break;n=a+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function Vp(e,t=!0){const n=[];let a="";const s=()=>{a&&(n.push({kind:"text",text:a}),a="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const r=e.indexOf("`",o+1);if(r>o+1){s(),n.push({kind:"code",text:e.slice(o+1,r)}),o=r+1;continue}}else if(t&&e.startsWith("**",o)){const r=YDe(e,o);if(r>0){s(),n.push({kind:"bold",kids:Vp(e.slice(o+2,r),!1)}),o=r+2;continue}}a+=e[o],o+=1}return s(),n}function lr(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function ZDe(e){const t=Math.max(0,Math.round(e/1e3));if(t<5)return S("shell.ago.now");if(t<60)return S("shell.ago.sec",{n:t});const n=Math.round(t/60);return n<60?S("shell.ago.min",{n}):S("shell.ago.hrSpelled",{n:Math.round(n/60)})}const XDe=()=>S("shell.update.checkWhy"),NW=()=>S("shell.update.checking"),QDe=()=>S("shell.update.npmUnreachable"),eFe=()=>S("shell.update.deckUnreachable"),tFe=()=>S(aFe),nFe=()=>S("shell.update.pendingRetry"),aFe="shell.update.checksOff";function sFe(e,t,n,a){const s=a?t.npx:n?On(t,n):void 0;return s?S("shell.update.outBlocked",{to:e,reason:s}):S("shell.update.outRun",{to:e})}const hs=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),tl=e=>hs(e,{tone:"note"});function AW(e,t){return ZDe(t-e)}function iFe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?tl(S("shell.update.appReady",{version:n.version??""})):(n==null?void 0:n.status)==="checking"?tl(S("shell.update.appChecking")):(n==null?void 0:n.status)==="downloading"?tl(n.version?S("shell.update.appDownloadingVersion",{version:n.version}):S("shell.update.appDownloading")):(n==null?void 0:n.status)==="current"?tl(S("shell.update.appCurrent",{version:e.version??t})):(n==null?void 0:n.status)==="error"?tl(S("shell.update.appError")):tl(S("shell.update.appIdle"))}function oFe(e,t,n){var r;const a=e.version;if((a==null?void 0:a.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return hs(S("shell.update.installed",{to:t}));const c=e.upgradeState==="running",l=S("shell.update.installWhy",{command:((r=a.upgrade)==null?void 0:r.command)??a.command});return hs(c?S("shell.update.installing",{to:t}):S("shell.update.out",{to:t}),{action:{kind:"install",label:S("shell.update.now"),busy:c,why:l}})}if((a==null?void 0:a.upgradeMode)==="npx"&&a.canRestart){const c=e.upgradeState==="failed";return hs(c?S("shell.update.npxFailedBack",{to:t,running:e.running}):S("shell.update.out",{to:t}),{action:{kind:"npx",label:S(c?"shell.update.retry":"shell.update.andRestart"),busy:e.restarting,why:S("shell.update.npxWhy",{command:a.command})}})}const s=e.upgradeState==="failed"?S("shell.update.installFailed",{to:t}):sFe(t,n,a==null?void 0:a.upgradeBlocked,(a==null?void 0:a.upgradeMode)==="npx"),o=(a==null?void 0:a.command)??null;return hs(s,{command:o,action:o?{kind:"copy",label:e.copied?S("shell.copied"):S("shell.copy"),busy:!1}:null})}function rFe(e){const t=e.version;if(e.unreachable)return hs(eFe(),{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return hs(QDe(),{tone:"warn",age:e.answered?null:S("shell.update.lastTried",{ago:AW(n,e.now)})});const a=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(a)return hs(S("shell.update.pending",{pending:a,retry:nFe()}));const s=t!=null&&t.checkedAt?AW(t.checkedAt,e.now):null;if((t==null?void 0:t.checkedAt)&&e.now>=t.checkedAt&&e.now-t.checkedAt<=60*6e4&&(t!=null&&t.latest)&&vo(t.latest)&&vo(e.running)){const r=lc(t.latest,e.running),c=r===0?S("shell.update.latest",{version:e.running}):r<0?S("shell.update.ahead",{running:e.running,latest:t.latest}):S("shell.update.out",{to:t.latest});return hs(c,{age:s?S("shell.update.checkedAgo",{ago:s}):null})}return hs(S(s?"shell.update.mayHaveChanged":"shell.update.noneYet"),{age:s?S("shell.update.lastChecked",{ago:s}):null})}function cFe(e,t){var s,o;const n=e.version;if((s=e.app)!=null&&s.inApp&&(n!=null&&n.checkDisabled)){const r=iFe(e.app,e.running);return r&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?hs(S("shell.update.appRefused"),{tone:"warn"}):e.checking?hs(NW()):r}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:tl(tFe())};const a=(n==null?void 0:n.notice)??null;if((a==null?void 0:a.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:oFe(e,a.to,t)};if((a==null?void 0:a.kind)==="restart"){const r=n!=null&&n.canRestart?S("shell.update.restartDeck",{to:a.to}):S("shell.update.restartApp",{to:a.to});return{canCheck:!0,checking:e.checking,line:hs(r)}}return e.checking?{canCheck:!0,checking:!0,line:hs(NW())}:{canCheck:!0,checking:!1,line:rFe(e)}}const u7=450;async function lFe(e,t=n=>new Promise(a=>setTimeout(a,n))){const[n]=await Promise.all([e(!0),t(u7)]);return n?"answered":"unreachable"}async function dFe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,u7))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const uFe=()=>S("shell.notes.restartWhy");function hFe(e){var z,I,_;Es();const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=xo(3e4),[a,s]=m.useState(!1),o=m.useRef(!1),[r,c]=m.useState(!1),[l,u]=m.useState(!1),h=m.useRef(t);if(m.useEffect(()=>{h.current&&!t&&u(!0),h.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:f,restart:b,desktopUpdate:v,running:w,onHandOff:T}=e,y=cFe({version:p.version,running:w,checking:a||t,answered:l,unreachable:r,now:Math.max(n,Date.now()),upgradeState:f.upgradeState,copied:f.cmdCopied,restarting:b.restarting,app:{inApp:lr(),update:v.appUpdate,version:D8(),menu:B8()}},SMe);if(!y)return null;const x=lr()&&((z=p.version)==null?void 0:z.checkDisabled),C=x?S("shell.update.checkWhyApp"):XDe(),A=async()=>{var L;if(!$a(o.current||t)||x&&((L=v.appUpdate)==null?void 0:L.status)==="checking")return;o.current=!0,s(!0);const D=x?await dFe():await lFe(p.loadVersion);o.current=!1,s(!1),c(D==="unreachable"),u(!0)},E=D=>{if(D.kind==="copy")return void f.copyCommand();T(),p.showNotice(),D.kind==="install"?f.startUpgrade():b.askRestart({upgrade:!0})},R=y.line.tone==="warn"||!!y.line.action||!!((I=p.version)!=null&&I.notice)||((_=v.appUpdate)==null?void 0:_.status)==="downloading";return{state:y,check:A,act:E,checkWhy:C,needsAttention:R}}function pFe({update:e}){const t=qg("above","dialog"),n=m.useId();return Es(),i.jsxs("div",{className:"rn-status-row",children:[e?i.jsx(gFe,{line:e.state.line,onAct:e.act,bindHint:t.bind,whyId:`${n}-action`,announce:!1}):i.jsx("p",{className:"rn-update-line",children:i.jsx("span",{role:"status",children:S("shell.notes.statusUnavailable")})}),t.node]})}function gFe({line:e,onAct:t,bindHint:n,whyId:a,announce:s=!0}){const{action:o}=e,r=o&&i.jsx(mFe,{action:o,onAct:t,bindHint:n,whyId:a});return i.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[i.jsx("span",{className:"rn-update-what",role:s?"status":void 0,children:e.said}),e.age&&i.jsx("span",{className:"rn-update-age",children:e.age}),e.command?i.jsxs("span",{className:"rn-update-cmd",children:[i.jsx("code",{className:"rn-code",children:e.command}),r]}):r]})}function mFe({action:e,onAct:t,bindHint:n,whyId:a}){const s=e.kind==="copy"?null:e.why;return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:s?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":s&&a?a:void 0,...s&&n?n({label:s}):{},children:e.label}),s&&a&&i.jsx("span",{hidden:!0,id:a,children:s})]})}function fFe({entries:e,since:t,running:n,firstRun:a,onClose:s,onTour:o,updateVersion:r,updateBusy:c,onUpdateRestart:l,updateFailure:u,onRestart:h,updateCheck:p}){var M,F,U;const f=se(),b=uFe(),v=Zt(s),w=m.useRef(null),T=tn(s),y=m.useId(),[x,C]=m.useState(null),A=hFe(p),E=((M=A==null?void 0:A.state.line.action)==null?void 0:M.kind)==="install"||((F=A==null?void 0:A.state.line.action)==null?void 0:F.kind)==="npx",R=h&&!r&&!E,{latest:z,visiblePrevious:I,history:_}=DDe(e,t!==null,n),D=`${y}-history`,L=!!R||!!(A!=null&&A.state.canCheck)&&!r;m.useEffect(()=>{var H;!L&&x&&(C(null),document.activeElement===document.body&&((H=w.current)==null||H.focus()))},[L,x]);const P=vo(n)?n:((U=e[0])==null?void 0:U.version)??"",O=a&&n?f("shell.notes.contextFirst",{version:n}):t?f("shell.notes.contextSince",{since:t}):null,j=I.some(H=>H.notes.some($=>!$.priority&&!$.notice));return i.jsxs(dn,{scrim:T,dialogRef:v,className:"release-notes",id:`${y}-dialog`,labelledBy:"release-notes-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:f("shell.notes.title")}),P&&i.jsx("span",{className:"modal-tool-id rn-pill",children:P})]}),i.jsxs("div",{className:"modal-actions",children:[L&&i.jsx("button",{id:`${y}-options`,type:"button",className:"glyph-btn","aria-label":f("shell.notes.moreOptions"),"aria-haspopup":"menu","aria-expanded":x!==null,"aria-controls":x?`${y}-menu`:void 0,onClick:()=>C(x?null:"first"),onKeyDown:H=>{(H.key==="ArrowDown"||H.key==="ArrowUp")&&(H.preventDefault(),C(H.key==="ArrowUp"?"last":"first"))},children:i.jsxs("svg",{className:"glyph",viewBox:"0 0 14 14",width:"14",height:"14",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"3",cy:"7",r:"1"}),i.jsx("circle",{cx:"7",cy:"7",r:"1"}),i.jsx("circle",{cx:"11",cy:"7",r:"1"})]})}),i.jsx("button",{ref:w,type:"button",className:"glyph-btn",onClick:s,"aria-label":f("shell.closeEsc"),title:f("shell.closeEsc"),children:"×"})]})]}),i.jsx("span",{className:"rn-live-status",role:"status",children:r?f("shell.notes.downloaded",{version:r}):A==null?void 0:A.state.line.said}),i.jsxs("section",{className:"modal-body",role:"region","aria-label":f("shell.notes.region"),tabIndex:0,children:[r?i.jsxs("div",{className:"rn-ready",children:[i.jsx("p",{children:f("shell.notes.downloaded",{version:r})}),i.jsx("p",{className:"rn-update-said",role:"status",children:u})]}):i.jsxs(i.Fragment,{children:[(A==null?void 0:A.needsAttention)&&i.jsx(pFe,{update:A}),i.jsx("p",{className:"rn-update-said",role:"status",children:u})]}),O&&i.jsx("p",{className:"rn-context",children:O}),!(z!=null&&z.notes.length)&&!I.length&&i.jsx("p",{className:"rn-empty",children:f("shell.notes.empty")}),z&&i.jsx(XA,{entry:z,showVersion:t!==null&&e.length>1},z.version),I.length>0&&i.jsxs("section",{className:"rn-upgrade-history","aria-label":f("shell.notes.earlierLabel"),children:[i.jsx("h2",{className:"rn-group-title",children:f("shell.notes.earlierTitle")}),j&&i.jsx("p",{className:"rn-context",children:f("shell.notes.legacy")}),I.map(H=>i.jsx(XA,{entry:H,showVersion:!0},H.version))]}),_.length>0&&i.jsxs("details",{className:"rn-history",children:[i.jsx("summary",{"aria-controls":D,children:f("shell.notes.otherSince",{since:t??""})}),i.jsx("div",{id:D,children:_.map(H=>i.jsx(XA,{entry:H,showVersion:!0},H.version))})]}),i.jsx("p",{className:"rn-history-link",children:i.jsxs("a",{href:"https://ccdeck.dev/changelog/",target:"_blank",rel:"noopener noreferrer","aria-label":f("shell.notes.historyLabel"),children:[f("shell.notes.history")," ",i.jsx(dR,{})]})})]}),i.jsxs("footer",{className:"rn-footer",children:[i.jsx("div",{className:"rn-footer-links",children:o&&!r&&i.jsx("button",{className:"btn rn-tour",type:"button",onClick:o,children:f("shell.notes.tour")})}),r&&l?i.jsx("button",{className:"btn primary",type:"button",onClick:l,"aria-busy":c||void 0,children:c?f("shell.notes.restarting"):Rk()}):i.jsx("button",{className:"btn primary",type:"button",onClick:s,children:f("shell.done")})]}),x&&L&&i.jsxs(Rs,{anchorId:`${y}-options`,portalRootId:`${y}-dialog`,id:`${y}-menu`,role:"menu",labelledBy:`${y}-options`,start:x,className:"ap-pop rn-options-menu",onClose:()=>C(null),children:[A&&i.jsxs("p",{className:"rn-menu-status",id:`${y}-check-status`,children:[A.state.line.said,A.state.line.age&&i.jsx("span",{children:A.state.line.age})]}),(A==null?void 0:A.state.canCheck)&&i.jsxs("button",{type:"button",className:"ap-menu-item rn-act",role:"menuitem",title:A.checkWhy,"aria-describedby":`${y}-check-status`,"aria-busy":A.state.checking||void 0,onClick:()=>void A.check(),children:[i.jsx(hge,{}),f("shell.notes.check")]}),(A==null?void 0:A.state.canCheck)&&R&&i.jsx("div",{className:"rn-menu-separator",role:"separator"}),R&&i.jsxs("button",{type:"button",className:"ap-menu-item",role:"menuitem",title:b,"aria-describedby":`${y}-restart-why`,onClick:()=>{C(null),h==null||h()},children:[i.jsx(pge,{}),f("shell.notes.restart")]}),i.jsx("span",{hidden:!0,id:`${y}-restart-why`,children:b})]})]})}function XA({entry:e,showVersion:t}){const n=se(),{highlights:a,visible:s,more:o}=IDe(e.notes),r=a.filter(l=>l.details),c=m.useId();return i.jsxs("section",{className:"rn-release",children:[t&&i.jsxs("h2",{className:"rn-version",children:["v",e.version]}),e.summary&&i.jsx("h2",{className:"rn-summary",children:e.summary}),i.jsxs("ul",{className:"rn-notes",children:[a.map((l,u)=>i.jsx(QA,{note:l,highlight:!0},`h${u}`)),s.map((l,u)=>i.jsx(QA,{note:l},`v${u}`))]}),(o.length>0||r.length>0)&&i.jsxs("details",{className:"rn-more",children:[i.jsxs("summary",{"aria-controls":c,children:[i.jsxs("span",{className:"rn-more-start",children:[i.jsx("span",{className:"rn-chevron","aria-hidden":"true",children:"›"}),i.jsx("span",{className:"rn-more-label",children:o.length?n("shell.notes.more",{count:o.length}):n("shell.notes.moreDetails")})]}),i.jsxs("span",{className:"rn-more-hint",children:[i.jsx("span",{className:"rn-show-details",children:n("shell.notes.show")}),i.jsx("span",{className:"rn-hide-details",children:n("shell.notes.hide")})]})]}),i.jsxs("div",{id:c,children:[i.jsx("ul",{className:"rn-notes",children:o.map((l,u)=>i.jsx(QA,{note:l},u))}),r.length>0&&i.jsxs("div",{className:"rn-highlight-details",role:"group","aria-labelledby":`${c}-highlights`,children:[i.jsx("h3",{id:`${c}-highlights`,className:"rn-details-title",children:n("shell.notes.aboutHighlights")}),r.map((l,u)=>i.jsxs("p",{className:"rn-note-body",children:[i.jsxs("strong",{className:"rn-strong",children:[d7(l.title).rest.trimStart(),": "]}),Kp(Vp(l.details))]},u))]})]})]})]})}const bFe={plans:dG,accounts:uG,skills:hG};function QA({note:e,highlight:t}){const n=se(),{icon:a,rest:s}=d7(e.title),o=!a&&e.icon?On(bFe,e.icon):void 0;return i.jsxs("li",{className:"rn-note","data-highlight":t||void 0,"data-required":e.priority==="required"||void 0,"data-has-icon":!!o||void 0,children:[o&&i.jsx("span",{className:"rn-title-icon","aria-hidden":"true",children:i.jsx(o,{})}),i.jsxs("div",{children:[i.jsxs("h3",{className:"rn-note-title",children:[a&&i.jsx("span",{className:"rn-note-icon",children:a}),a?s:s.trimStart()]}),i.jsx("p",{className:"rn-note-body",children:Kp(Vp(e.body))}),!t&&e.details&&i.jsx("p",{className:"rn-note-body rn-extra-detail",children:Kp(Vp(e.details))}),e.notice&&i.jsxs("p",{className:"rn-note-notice",children:[i.jsxs("strong",{children:[e.noticeLabel??n("shell.notes.important"),": "]}),Kp(Vp(e.notice))]})]})]})}function Kp(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?i.jsx("code",{className:"rn-code",children:t.text},n):i.jsx("strong",{className:"rn-strong",children:Kp(t.kids)},n))}function kFe({state:e,sessionId:t,onClose:n}){const a=se(),s=m.useMemo(()=>vFe(e,t),[e,e.revision,t]),o=m.useRef(null),r=Zt(n,{focusRef:o}),c=tn(n);return s?i.jsxs(dn,{scrim:c,dialogRef:r,className:"session-summary",labelledBy:"ss-title ss-who-name",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"ss-title",className:"modal-tool-name",children:a("insights.summary.title")})}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",title:a("insights.summary.wall"),children:s.durationLabel}),i.jsx("button",{type:"button",ref:o,className:"glyph-btn",onClick:n,"aria-label":a("insights.audit.closeEsc"),title:a("insights.audit.closeEsc"),children:"×"})]})]}),i.jsxs("div",{className:"modal-body",children:[i.jsxs("div",{className:"ss-who",title:s.cwd??s.sessionId,children:[i.jsx(yi,{kind:s.mark}),i.jsx("span",{id:"ss-who-name",className:"ss-who-name",children:s.label}),i.jsxs("span",{className:"ss-who-id",children:["· ",s.sessionId.slice(0,8)]})]}),i.jsxs("section",{className:"ss-stats",children:[i.jsx(Zc,{label:a("insights.summary.spend"),value:Ut(s.cost.total),title:T1()}),i.jsx(Zc,{label:a("insights.summary.agents"),value:s.agentCount}),i.jsx(Zc,{label:a("insights.summary.subagents"),value:s.subagentCount}),i.jsx(Zc,{label:a("insights.summary.toolCalls"),value:s.toolCount}),i.jsx(Zc,{label:a("insights.summary.prompts"),value:s.promptCount}),i.jsx(Zc,{label:a("insights.summary.errors"),value:s.errCount,tone:s.errCount>0?"err":void 0}),i.jsx(Zc,{label:a("insights.usage.tokens"),value:s.tokensSum.toLocaleString(Me())})]}),(s.modelChips.length>0||s.cost.total>0)&&i.jsxs("section",{className:"ss-hero",children:[s.modelChips.length>0&&i.jsx("div",{className:"ss-models",children:s.modelChips.map(l=>i.jsx("span",{className:"model-chip","data-family":M4(l),title:l,children:sc(l)},l))}),s.cost.total>0&&i.jsxs(i.Fragment,{children:[i.jsx(rR,{cost:s.cost,size:"lg"}),i.jsxs("div",{className:"ss-cost-legend",children:[i.jsxs("span",{className:"ssl ssl-in",children:[a("insights.cost.input")," ",i.jsx("b",{children:Ut(s.cost.input)})]}),i.jsxs("span",{className:"ssl ssl-out",children:[a("insights.cost.output")," ",i.jsx("b",{children:Ut(s.cost.output)})]}),i.jsxs("span",{className:"ssl ssl-cr",children:[a("insights.summary.cacheR")," ",i.jsx("b",{children:Ut(s.cost.cacheRead)})]}),i.jsxs("span",{className:"ssl ssl-cw",children:[a("insights.summary.cacheW")," ",i.jsx("b",{children:Ut(s.cost.cacheWrite)})]})]})]})]}),s.topTools.length>0&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:a("insights.summary.topTools")}),i.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([l,u])=>i.jsxs("span",{className:"ss-tt",children:[l," ",i.jsx("b",{children:u})]},l))})]}),s.firstPrompt&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:a("insights.summary.opening")}),i.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]}),i.jsx("footer",{className:"modal-foot",children:i.jsx("button",{type:"button",className:"btn primary",onClick:n,children:a("shell.done")})})]}):null}function Zc({label:e,value:t,tone:n,title:a}){return i.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,title:a,children:[i.jsx("div",{className:"ss-stat-value",children:t}),i.jsx("div",{className:"ss-stat-label",children:e})]})}function vFe(e,t){const n=e.agents.get(t);if(!n)return null;const a=[];for(const C of e.agents.values())C.sessionId===t&&a.push(C);if(a.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,r=new Map;let c=0,l=0,u=0,h=0,p=0,f,b=1/0,v=0;for(const C of a){const A=fs(C);s.input+=A.input,s.output+=A.output,s.cacheRead+=A.cacheRead,s.cacheWrite+=A.cacheWrite,s.total+=A.total;for(const R of q4(C))o.add(R);C.model&&o.add(C.model),C.kind==="subagent"&&p++;const E=h5(C.prompts);l+=E.length,!f&&E.length>0&&(f=E[0].text),u+=C.usage.inputTokens+C.usage.outputTokens,c+=C.toolCount,h+=C.toolErrorCount??0;for(const[R,z]of C.toolCountByName??[])r.set(R,(r.get(R)??0)+z);b=Math.min(b,C.startedAt),v=Math.max(v,C.endedAt??Date.now())}const w=Math.max(0,v-b),T=Math.floor(w/1e3),y=T<60?`${T}s`:T<3600?`${Math.floor(T/60)}m ${String(T%60).padStart(2,"0")}s`:`${Math.floor(T/3600)}h ${Math.floor(T%3600/60)}m`,x=Array.from(r.entries()).sort((C,A)=>A[1]-C[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||S("insights.summary.session"),cwd:n.cwd,durationLabel:y,cost:s,modelChips:Array.from(o),agentCount:a.length,subagentCount:p,toolCount:c,promptCount:l,tokensSum:u,errCount:h,topTools:x,firstPrompt:f,mark:Jk(n)}}function _z({id:e,children:t}){return i.jsxs("span",{className:"settings-info",id:e,children:[i.jsx(Ze,{name:"info"}),i.jsx("span",{children:t})]})}function gn({id:e,title:t,note:n,noteId:a,info:s,infoId:o,aside:r,list:c=!0,settingId:l,className:u,children:h}){const p=u?`settings-group ${u}`:"settings-group",f=c?i.jsx("div",{className:"settings-list",children:h}):h;return t===void 0?i.jsx("div",{className:p,"data-setting":l,children:f}):i.jsxs("section",{className:p,"aria-labelledby":e,"data-setting":l,children:[i.jsxs("div",{className:"settings-caption",children:[i.jsxs("div",{className:"settings-caption-text",children:[i.jsx("h3",{id:e,children:t}),n&&i.jsx("p",{className:"settings-caption-note",id:a,children:n}),s&&i.jsx(_z,{id:o,children:s})]}),r]}),f]})}function Ot({name:e,nameId:t,note:n,noteId:a,control:s,as:o="label",settingId:r,className:c,details:l,children:u}){const h=se(),p=o,f=i.jsxs(p,{className:c?`settings-row ${c}`:"settings-row","data-setting":r,children:[i.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&i.jsx("span",{className:"settings-row-note",id:a,children:n}),s!==void 0&&i.jsx("span",{className:"settings-row-control",children:s}),u]});return l?i.jsxs("div",{className:"settings-row-with-details",children:[f,i.jsxs("details",{className:"settings-row-details",children:[i.jsxs("summary",{children:[h("common.details"),i.jsxs("span",{className:"vis-hidden",children:[h("common.aboutBefore"),e,h("common.aboutAfter")]})]}),i.jsx("div",{children:l})]})]}):f}function wFe(){return i.jsx("svg",{className:"v4-select-chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"m3 4.5 3 3 3-3"})})}function dc({children:e}){return i.jsxs("span",{className:"v4-select",children:[e,i.jsx(wFe,{})]})}function yFe(){const e=se(),t=Es();return i.jsx(gn,{children:i.jsx(Ot,{settingId:"language",name:e("settings.language.name"),nameId:"settings-language-label",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",value:t,"aria-labelledby":"settings-language-label",onChange:n=>ire(n.target.value),children:Pu.map(n=>i.jsx("option",{value:n.code,lang:n.code,dir:n.dir,children:ere(n)},n.code))})})})})}function h7(e,t){const[n,a]=m.useState(null),[s,o]=m.useState(!1),r=m.useRef(!1),c=n??e===!0;return{checked:c,busy:n!==null,failed:s,flip:async()=>{if(e===null||r.current)return;r.current=!0;const u=!c;a(u),o(!1);let h=!1;try{h=await t(u)}catch{h=!1}r.current=!1,a(null),h||o(!0)}}}let ll=null,p7=0;const qk=new Set;function xFe(e){return qk.add(e),()=>{qk.delete(e)}}function jW(){return ll}function Ai(e){if(!(e===null&&ll===null)){ll=e===null?null:{line:e,serial:++p7};for(const t of qk)t()}}function CFe(e){ll={line:e,serial:(ll==null?void 0:ll.serial)??++p7};for(const t of qk)t()}function Dl(e,t=S){Ai(Ds(t("settings.failure.save"),e))}function SFe(){return m.useSyncExternalStore(xFe,jW,jW)}function g7(e,t,n){const[a,s]=m.useState(null),[o,r]=m.useState(""),c=m.useRef(!1),l=f=>typeof f=="boolean"?f:t;m.useEffect(()=>{let f=!0;return fetch("/api/prefs").then(b=>{if(!b.ok)throw new Error;return b.json()}).then(b=>{var v;if(!b.ok)throw new Error;f&&s(l((v=b.prefs)==null?void 0:v[e]))}).catch(()=>{f&&r(n("settings.recover.readFail"))}),()=>{f=!1}},[e]);const h=h7(a,async f=>{var b;c.current=!0;try{const v=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:f})}),w=await v.json().catch(()=>null);return!v.ok||!(w!=null&&w.ok)?(Dl(w,n),!1):(s(l((b=w.prefs)==null?void 0:b[e])),Ai(null),!0)}catch{return Dl(null,n),!1}finally{c.current=!1}}),p=()=>{a===null||!$a(c.current)||h.flip()};return{enabled:h.checked,ready:a!==null,error:o,change:p}}function EW({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,a=se(),s=g7(t,!0,a),o=`settings-${n}-name`,r=`settings-${n}-note`;return i.jsxs(i.Fragment,{children:[i.jsx(Ot,{settingId:n,name:a(e==="Codex"?"settings.recover.codexName":"settings.recover.claudeName"),nameId:o,note:a(e==="Codex"?"settings.recover.codexNote":"settings.recover.claudeNote"),noteId:r,control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-labelledby":o,"aria-describedby":r,"aria-checked":s.enabled,...gs(!1,!s.ready),onClick:s.change,children:i.jsx("span",{className:"switch-knob"})})}),s.error&&i.jsx("p",{role:"alert",children:s.error})]})}function TFe(){const e=se(),t=g7("continueStopped",!1,e);return i.jsxs(i.Fragment,{children:[i.jsx(Ot,{settingId:"claude-continue-stopped",name:e("settings.recover.continueName"),note:e("settings.recover.continueNote"),details:e("settings.recover.continueDetails"),control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":e("settings.recover.continueAria"),"aria-checked":t.enabled,...gs(!1,!t.ready),onClick:t.change,children:i.jsx("span",{className:"switch-knob"})})}),t.error&&i.jsx("p",{role:"alert",children:t.error})]})}function NFe({children:e}){const t=se(),n=d8();return i.jsxs(gn,{id:"settings-sessions-caption",title:t("settings.sessions.group"),children:[i.jsx(Ot,{settingId:"hide-finished",name:t("settings.board.hideLabel"),nameId:"settings-hide-finished-label",note:t("settings.board.hideNote"),noteId:"settings-hide-finished-note",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",value:n,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:a=>c8(Number(a.target.value)),children:i8.map(a=>i.jsx("option",{value:a,children:a===0?t("settings.board.never"):t("settings.board.minutes",{n:a})},a))})})}),e]})}const AFe="Codex accounts",jFe="Your Codex profiles and what each has left, and which one new sessions use.";function EFe({claudeHere:e,codexHere:t=!1,singleKeys:n,doors:a}){const s=se();return i.jsxs(gn,{id:"settings-elsewhere-caption",title:s("lan.ew.group"),children:[(e||t)&&i.jsx(ej,{settingId:"accounts",name:e?s("lan.ew.accounts"):AFe,note:e?s("lan.ew.accountsNote"):jFe,onOpen:a.accounts,shortcut:n?"A":null}),e&&i.jsx(ej,{settingId:"local-network",name:s("lan.ew.lan"),note:s("lan.ew.lanNote"),onOpen:a.localNetwork,shortcut:null}),i.jsx(ej,{settingId:"browser-watch",name:s("lan.ew.watch"),note:s("lan.ew.watchNote"),onOpen:a.browserWatch,dialog:!0,shortcut:n?"B":null})]})}function ej({settingId:e,name:t,note:n,onOpen:a,shortcut:s,dialog:o=!1}){const r=se(),c=`settings-${e}`;return i.jsx(Ot,{as:"div",settingId:e,name:t,nameId:`${c}-name`,note:n,control:i.jsx("button",{type:"button",className:"settings-link",id:`${c}-open`,"aria-labelledby":`${c}-open ${c}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":s??void 0,onClick:a,children:r("lan.ew.open")})})}function RFe(e){const t=e.binds.includes("?")?S("settings.keyboard.sheetName"):e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function zFe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(a=>a.toLowerCase().includes(n)):!0}function qFe({singleKeys:e,onToggleSingleKeys:t,workspace:n=!1}){const a=se(),s=zs(js()),[o,r]=m.useState(""),c=m.useId(),l=Xg(),u=r7(e,h=>Qo(l,h),n).map(h=>({...h,rows:h.rows.filter(p=>zFe(p,o))})).filter(h=>h.rows.length>0);return i.jsxs(i.Fragment,{children:[i.jsx(gn,{id:"settings-shortcuts-caption",title:a("settings.keyboard.group"),children:i.jsx(Ot,{settingId:"single-keys",name:a("settings.keyboard.singleKeys"),nameId:"settings-single-keys-label",note:a("settings.keyboard.singleKeysNote"),noteId:"settings-single-keys-note",control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-single-keys-label","aria-describedby":"settings-single-keys-note",onClick:t,children:i.jsx("span",{className:"switch-knob"})})})}),i.jsxs("div",{className:"settings-filter",children:[i.jsx("label",{className:"settings-filter-label",htmlFor:c,children:a("settings.keyboard.filter")}),i.jsx("input",{id:c,type:"search",className:"settings-filter-field",placeholder:a("settings.keyboard.filter"),autoComplete:"off",spellCheck:!1,value:o,onChange:h=>r(h.target.value),onKeyDown:h=>{ev(h.key)&&o&&(h.stopPropagation(),r(""))}})]}),u.map(h=>{const p=`settings-keys-${h.id}`;return i.jsx(gn,{id:p,title:h.title,className:"settings-keys",children:h.rows.map(f=>i.jsx(Ot,{as:"div",name:RFe(f),control:i.jsx("kbd",{className:"settings-key",children:s&&f.macCap?f.macCap:f.cap})},`${f.cap}:${f.action}`))},h.id)}),u.length===0&&i.jsx("p",{className:"settings-empty",role:"status",children:a("settings.keyboard.noMatch",{query:o.trim()})}),o.trim()===""&&i.jsx("p",{className:"settings-foot",children:a("settings.key.note")})]})}function _Fe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:a,onAskNotify:s,accountNotify:o,onToggleAccountNotify:r}){const c=se(),l=Kme(a,c),u=lr(),h=e&&!n&&!u,p=m.useRef(null),f=so(!l.ask,p);return i.jsxs(i.Fragment,{children:[i.jsxs(gn,{id:"sm-closed-caption",title:c("settings.notify.closedGroup"),children:[i.jsx(Ot,{settingId:"notify-closed",name:c("settings.notify.closedName"),nameId:"sm-notify-label",note:Wme(u,c),noteId:"sm-notify-note",control:i.jsx("button",{ref:p,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":n?"sm-notify-note sm-notify-veto":"sm-notify-note",className:"switch",onClick:t,children:i.jsx("span",{className:"switch-knob"})}),children:n&&i.jsx(_z,{id:"sm-notify-veto",children:c(Hme)})}),h&&i.jsx(Ot,{as:"div",name:c("settings.notify.browserName"),nameId:"sm-channel-name",note:l.note,control:l.ask?i.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{f(),s()},children:c("settings.notify.enable")}):i.jsxs("span",{className:"sm-channel-state","data-ok":l.ok||void 0,children:[l.ok&&i.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),l.status]})})]}),i.jsx(gn,{id:"sm-accounts-caption",title:c("settings.notify.accountsGroup"),note:c(Gme),info:n?c(Vme):void 0,children:o0.map(({kind:b,label:v,title:w})=>i.jsx(Ot,{settingId:b,name:v,nameId:`sm-${b}-label`,note:w??void 0,noteId:w?`sm-${b}-note`:void 0,control:i.jsx("button",{type:"button",role:"switch","aria-checked":o[b],"aria-labelledby":`sm-${b}-label`,"aria-describedby":w?`sm-${b}-note`:void 0,className:"switch",onClick:()=>r(b),children:i.jsx("span",{className:"switch-knob"})})},b))})]})}const LFe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function PFe(e){return LFe.find(t=>e(t))}const OFe=4400;function MFe(e){const t=e.split(";")[0],n=t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm";return{name:`${S("radio.rec.name")}.${n}`,type:t}}function IFe({full:e,setCustomError:t,runCustom:n,onImportCustom:a}){const[s,o]=m.useState(!1),r=m.useRef(null),c=m.useRef(null),l=m.useRef(!1),u=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=r.current)==null?void 0:p.state)==="recording"&&r.current.stop()},h=async()=>{var f;if(e)return;if(t(""),!((f=navigator.mediaDevices)!=null&&f.getUserMedia)||typeof MediaRecorder>"u"){t(S("radio.rec.noMic"));return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{l.current||t(S("radio.rec.denied"));return}if(l.current||r.current){p.getTracks().forEach(b=>b.stop());return}try{const b=PFe(T=>MediaRecorder.isTypeSupported(T)),v=new MediaRecorder(p,b?{mimeType:b}:void 0),w=[];r.current=v,v.ondataavailable=T=>{T.data.size&&w.push(T.data)},v.onerror=()=>t(S("radio.rec.failed")),v.onstop=()=>{p.getTracks().forEach(C=>C.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const T=r.current===v;if(T&&(r.current=null),o(!1),!T||!w.length)return;const y=MFe(v.mimeType),x=new File(w,y.name,{type:y.type});n(()=>a(x))},v.start(200),o(!0),c.current=setTimeout(u,OFe)}catch{r.current=null,p.getTracks().forEach(b=>b.stop()),t(S("radio.rec.format"))}};return m.useEffect(()=>(l.current=!1,()=>{l.current=!0,c.current!==null&&clearTimeout(c.current);const p=r.current;r.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:h,stopRecording:u}}function DFe({full:e,fullProps:t,runCustom:n,onCreateVoice:a}){const s=se(),[o,r]=m.useState(()=>s("settings.sounds.voice.defaultName")),[c,l]=m.useState(()=>s("settings.sounds.voice.defaultText")),[u,h]=m.useState(""),[p,f]=m.useState("1"),[b,v]=m.useState("1"),[w,T]=m.useState([]);return m.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const y=()=>{T(window.speechSynthesis.getVoices())};return y(),window.speechSynthesis.addEventListener("voiceschanged",y),()=>window.speechSynthesis.removeEventListener("voiceschanged",y)},[]),i.jsxs("details",{className:"sm-voice",children:[i.jsxs("summary",{className:"settings-row",...t,onClick:y=>{const x=y.currentTarget.parentElement;e&&x&&!x.open&&y.preventDefault()},children:[i.jsx("span",{className:"settings-row-name",children:s("settings.sounds.voice.title")}),i.jsx("span",{className:"settings-row-note",children:s("settings.sounds.voice.note")}),i.jsx("span",{className:"settings-row-control",children:i.jsx("svg",{className:"sm-voice-chevron",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),i.jsxs("div",{className:"sm-voice-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.name")}),i.jsx("input",{className:"ap-manage-input",value:o,maxLength:80,onChange:y=>r(y.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.text")}),i.jsx("input",{className:"ap-manage-input",value:c,maxLength:180,onChange:y=>l(y.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.voice")}),i.jsx(dc,{children:i.jsxs("select",{className:"sm-select",value:u,onChange:y=>h(y.target.value),children:[i.jsx("option",{value:"",children:s("settings.sounds.voice.default")}),w.map(y=>i.jsx("option",{value:y.voiceURI,children:y.name},y.voiceURI))]})})]}),i.jsxs("div",{className:"sm-voice-pair",children:[i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.rate")}),i.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:p,onChange:y=>f(y.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.pitch")}),i.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:b,onChange:y=>v(y.target.value)})]})]}),i.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await a({name:o,text:c,voiceURI:u,rate:parseFloat(p),pitch:parseFloat(b)}),l(s("settings.sounds.voice.defaultText"))})},children:s("settings.sounds.voice.add")})]})]})}function FFe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:a,onPreviewCustom:s,onDeleteCustom:o}){const r=se(),[c,l]=m.useState(""),u=e.length,h=c0(u),p=h!==null,f=p?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[b,v]=m.useState(null),w=m.useRef(0),T=m.useRef(new Map),y=m.useRef(null),x=m.useRef(null);m.useEffect(()=>{if(!b)return;const I=window.setTimeout(()=>v(null),4e3);return()=>window.clearTimeout(I)},[b]);const C=async I=>{l("");try{await I()}catch(_){l(rr(_,r("settings.sounds.custom.saveFail")))}},A=(I,_)=>{const D=Date.now(),L=zl({armedFor:b,target:I,armedAt:w.current,now:D,gapMs:Rl});if(L==="arm"){v(I),w.current=D;return}if(L==="ignore")return;v(null);const P=tfe(e.map(O=>O.id),I);C(async()=>{var j;await o(I);const O=document.activeElement;O!==_&&!fa((O==null?void 0:O.tagName)??null)||(j=P?T.current.get(P):y.current)==null||j.focus()})},{recording:E,startRecording:R,stopRecording:z}=IFe({full:p,setCustomError:l,runCustom:C,onImportCustom:t});return i.jsxs(gn,{id:"sm-custom-title",title:r("settings.sounds.custom.group"),note:r("settings.sounds.custom.note"),aside:i.jsx("span",{className:"settings-caption-count",children:r("settings.sounds.custom.count",{count:u,max:r0})}),className:"sm-custom",settingId:"custom-sounds",children:[p&&i.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:h}),i.jsx(Ot,{as:"div",settingId:"custom-import",name:r("settings.sounds.custom.import"),note:r("settings.sounds.custom.importNote"),control:i.jsx("button",{ref:y,type:"button",className:"btn sm-custom-action",...f,onClick:()=>{var I;p||(I=x.current)==null||I.click()},children:r("settings.sounds.custom.chooseFile")}),children:i.jsx("input",{ref:x,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:I=>{var D;const _=(D=I.target.files)==null?void 0:D[0];I.currentTarget.value="",_&&!p&&C(()=>t(_))}})}),i.jsx(Ot,{as:"div",settingId:"custom-record",name:r("settings.sounds.custom.record"),note:r(E?"settings.sounds.custom.recording":"settings.sounds.custom.upTo5"),control:E?i.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:z,children:r("settings.sounds.custom.stopSave")}):i.jsx("button",{type:"button",className:"btn sm-custom-action",...f,onClick:()=>void R(),children:r("settings.sounds.custom.recordBtn")})}),i.jsx(DFe,{full:p,fullProps:f,runCustom:C,onCreateVoice:n}),e.map(I=>i.jsxs("div",{className:"sm-custom-item",children:[i.jsx("input",{className:"ap-manage-input","aria-label":r("settings.sounds.custom.rename",{name:I.name}),defaultValue:I.name,maxLength:80,onBlur:_=>{if(!_.target.value.trim()){_.target.value=I.name;return}C(()=>a(I.id,_.target.value))},onKeyDown:_=>{_.key==="Enter"&&_.currentTarget.blur()}}),i.jsx("span",{children:I.kind==="audio"?`${U4(I.duration,1)}s`:r("settings.sounds.custom.voice")}),i.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":r("settings.sounds.custom.playName",{name:I.name}),onClick:()=>s(I.id),children:r("settings.sounds.custom.play")}),i.jsx("button",{type:"button",ref:_=>{_?T.current.set(I.id,_):T.current.delete(I.id)},className:`btn sm-custom-icon${b===I.id?" armed":""}`,onKeyDown:_=>{_.repeat&&_.preventDefault()},onClick:_=>A(I.id,_.currentTarget),"aria-label":b===I.id?r("settings.sounds.custom.confirmName",{name:I.name}):r("settings.sounds.custom.deleteName",{name:I.name}),title:b===I.id?r("settings.sounds.custom.deleteAgain"):r("settings.sounds.custom.deleteTip"),children:b===I.id?r("settings.sounds.custom.confirm"):r("settings.sounds.custom.delete")})]},I.id)),c&&i.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:c})]})}function BFe({soundOn:e,onToggleSound:t}){const n=se(),a=m.useId(),s=sa();return i.jsx(gn,{id:"sm-sound-caption",title:n("settings.sounds.group"),children:i.jsx(Ot,{settingId:"play-sounds",name:n("radio.sound.name"),nameId:a,control:i.jsxs(i.Fragment,{children:[s&&i.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:n("radio.sound.keyTitle"),children:"M"}),i.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":a,"aria-keyshortcuts":s?"M":void 0,className:"switch",onClick:t,children:i.jsx("span",{className:"switch-knob"})})]})})})}const bE="custom:";function RW(e){return`${bE}${e}`}function UFe(e){return e.startsWith(bE)?e.slice(bE.length):null}function WFe({id:e,label:t,value:n,step:a=Y1,onLevel:s,"aria-describedby":o}){const r=se();return i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:e,children:t??r("radio.volume")}),i.jsx("input",{id:e,type:"range",min:fb,max:nk,step:a,value:n,"aria-describedby":o,onChange:c=>s(Number(c.target.value)),style:{"--sm-level":`${(n-fb)/(nk-fb)*100}%`}}),i.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const zW={get done(){return S("settings.sounds.tone.done")},get"needs-input"(){return S("settings.sounds.tone.needsInput")}},HFe={get done(){return S("settings.sounds.tone.doneNote")},get"needs-input"(){return S("settings.sounds.tone.needsInputNote")}};function GFe({chime:e,tone:t,soundOn:n,customAssets:a,customSelections:s,onLevel:o,onFigure:r,onPreview:c,onBuiltInSelected:l,onCustomSelected:u}){const h=se(),p=`sm-level-${e}`,f=`sm-figure-${e}`,b=s[e];return i.jsxs(gn,{id:`sm-name-${e}`,title:zW[e],note:HFe[e],settingId:`tone-${e}`,aside:i.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":h("settings.sounds.hearAria",{tone:zW[e]}),title:h(n?"settings.sounds.hearTip":"settings.sounds.hearTipMuted"),"aria-describedby":n?void 0:"sm-preview-note",children:[i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:i.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),h("settings.sounds.hear")]}),children:[i.jsx(WFe,{id:p,value:t.level,onLevel:v=>o(e,v)}),i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:f,children:h("settings.sounds.toneLabel")}),i.jsx(dc,{children:i.jsxs("select",{id:f,className:"sm-select",value:b?RW(b):t.figure,onChange:v=>{const w=v.target.value,T=UFe(w);T!==null?u(e,T):(l(e),r(e,w))},children:[J1[e].map(v=>i.jsx("option",{value:v.id,children:v.label},v.id)),a.length>0&&i.jsx("optgroup",{label:h("settings.sounds.customGroup"),children:a.map(v=>i.jsx("option",{value:RW(v.id),children:v.name},v.id))})]})})]})]})}function VFe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:a,onLevel:s,onFigure:o,onPreview:r,customAssets:c,customSelections:l,onBuiltInSelected:u,onCustomSelected:h,onImportCustom:p,onCreateVoice:f,onRenameCustom:b,onPreviewCustom:v,onDeleteCustom:w}){var A;const T=se(),y=Qme(l),x=((A=c.find(E=>E.id===y))==null?void 0:A.name)??T("settings.sounds.sharedName"),C=y?T("settings.sounds.sharedNote",{name:x}):"";return i.jsxs("div",{className:"sm-sounds",children:[i.jsx(BFe,{soundOn:e,onToggleSound:t}),!a&&i.jsx("p",{className:"sm-note",children:T("settings.sounds.codexOnly")}),!e&&i.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:T("settings.sounds.previewNote")}),i.jsx("div",{className:"sm-tones",children:Lp.map(E=>i.jsx(GFe,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:l,onLevel:s,onFigure:o,onPreview:r,onBuiltInSelected:u,onCustomSelected:h},E))}),C&&i.jsx("p",{className:"sm-note","aria-hidden":!0,children:C}),i.jsx("p",{className:"vis-hidden",role:"status",children:C}),i.jsx(FFe,{customAssets:c,onImportCustom:p,onCreateVoice:f,onRenameCustom:b,onPreviewCustom:v,onDeleteCustom:w})]})}function KFe({onOpen:e}){const t=se();return i.jsx(gn,{children:i.jsx(Ot,{as:"div",settingId:"radar-open",name:t("radar.name"),nameId:"settings-radar-open-name",note:t("radar.note"),control:i.jsx("button",{type:"button",className:"btn",id:"settings-radar-open","aria-labelledby":"settings-radar-open settings-radar-open-name","aria-haspopup":"dialog",onClick:e,children:t("radar.open")})})})}const $Fe=6500,JFe=1e4;let xl={reading:null,saving:null,error:"",undone:null};const Sb=new Set;let sp=null,ip=null,sr=null,tj=!1,Tb=0;const su=e=>{xl={...xl,...e},Sb.forEach(t=>t(xl))};function m7(e){const t=e;return!!t&&t.ok===!0&&Array.isArray(t.settings)&&typeof t.present=="object"}async function f7(e){const t=await fetch("/api/claude-settings",{signal:e}),n=await t.json();if(!t.ok||!m7(n))throw new Error;return n}async function kE(){if(tj||xl.saving)return;tj=!0;const e=Tb,t=new AbortController;sr=t;let n=!1;const a=setTimeout(()=>{n=!0,t.abort()},5e3);try{const s=await f7(t.signal);e===Tb&&!t.signal.aborted&&su({reading:s,error:""})}catch{e===Tb&&(n||!t.signal.aborted)&&su({error:S("settings.claude.readFail")})}finally{clearTimeout(a),tj=!1,sr===t&&(sr=null)}}function qW(e,t){var n;return(n=e==null?void 0:e.settings.find(a=>a.id===t))==null?void 0:n.value}async function b7(e,t){if(xl.saving)return!1;Tb++,sr==null||sr.abort(),ip&&(clearTimeout(ip),ip=null),su({saving:e,error:"",undone:null});const n=new AbortController,a=setTimeout(()=>n.abort(),15e3);try{const s=await fetch("/api/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,value:t}),signal:n.signal}),o=await s.json().catch(()=>null);if(!s.ok||!m7(o))throw new $n(typeof(o==null?void 0:o.error)=="string"&&o.error?Nb(o.error):S("settings.failure.save"));su({reading:o}),Ai(null);const r=qW(o,e);return ip=setTimeout(()=>{ip=null;const c=new AbortController,l=setTimeout(()=>c.abort(),5e3);f7(c.signal).then(u=>{su({reading:u,undone:qW(u,e)===r?null:{id:e}})}).catch(()=>{}).finally(()=>clearTimeout(l))},$Fe),!0}catch(s){return Ai({text:rr(s,S("settings.failure.save")),giveBack:!1,done:!1}),!1}finally{clearTimeout(a),su({saving:null})}}const YFe={"Your settings.json is not valid JSON, so Claude Code skips all of it, hooks included. Fix it in an editor; this section reads it again by itself.":"settings.claude.reason.invalid","Your settings.json could not be read here, so nothing is shown or changed until it can.":"settings.claude.reason.unreadable","Your organization's settings could not be read, so nothing here can be changed until they can.":"settings.claude.reason.othersUnknown","Set by your organization. Ask your administrator to change it.":"settings.claude.reason.locked","Your settings.json holds a custom value. Edit it there.":"settings.claude.reason.custom","Choose a setting this section offers and one of its values.":"settings.claude.reason.choose","Your settings.json could not be read as JSON. No changes were saved.":"settings.claude.reason.parse","Your settings.json changed while saving. Nothing was written. Try again.":"settings.claude.reason.changed","Claude Code settings can be changed on this computer only.":"settings.claude.reason.localOnly","Could not read Claude Code settings. Try again.":"settings.claude.reason.readFail","Could not save the change. Your settings.json was not modified.":"settings.claude.reason.notSaved","Your settings.json has a permissions value that is not an object. No changes were saved.":"settings.claude.reason.permissionsShape","Your settings.json has a permissions.deny value that is not a list. No changes were saved.":"settings.claude.reason.denyShape","Your settings.json holds a custom attribution. Edit it there.":"settings.claude.reason.attribution"};function Nb(e,t=S){const n=YFe[e];if(n)return t(n);const a=k7(e);return a?t(a.unread?"settings.claude.reason.needsUnread":"settings.claude.reason.needs",{version:a.version}):j6(e,t)}function k7(e){const t=/^Needs Claude Code (\S+) or newer(, and the version installed here could not be read)?\.$/.exec(e??"");return t?{version:t[1],unread:!!t[2]}:null}function ZFe(){const[e,t]=m.useState(xl);return m.useEffect(()=>(Sb.add(t),t(xl),sp||(kE(),sp=setInterval(()=>void kE(),JFe)),()=>{Sb.delete(t),Sb.size||(sp&&clearInterval(sp),sp=null,sr==null||sr.abort())}),[]),e}const nj=40,XFe=(e,t)=>{const n=`settings.claudeTopic.${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`,a=t(n);return a===n?e:a},QFe={boolean:"settings.claudeIndex.kind.boolean",choice:"settings.claudeIndex.kind.choice",number:"settings.claudeIndex.kind.number",text:"settings.claudeIndex.kind.text",structured:"settings.claudeIndex.kind.structured"};function e2e(e,t=S){const n=e.scope==="Global config"?t("settings.claudeIndex.globalConfig"):e.scope==="Managed"?t("settings.claudeIndex.managedOnly"):null;return[e.topic?XFe(e.topic,t):e.topic,t(QFe[e.kind]),n,e.since?t("settings.claudeIndex.since",{since:e.since}):null].filter(Boolean).join(" · ")}function t2e(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=e.filter(o=>o.key.toLowerCase().includes(n)),s=e.filter(o=>!a.includes(o)&&(o.topic??"").toLowerCase().includes(n));return[...a,...s]}let v7=null;const n2e=()=>v7??=Xs(()=>import("./claude-settings-index-1Qg1AUda.js"),[]).then(e=>e.default.keys);function a2e({present:e,noFile:t=!1}){const n=se(),a=Es(),[s,o]=m.useState(null),[r,c]=m.useState(""),l=m.useId();m.useEffect(()=>{let f=!0;return n2e().then(b=>{f&&o(b)},()=>{v7=null}),()=>{f=!1}},[]);const u=m.useMemo(()=>{if(!s)return[];if(r.trim())return t2e(s,r);if(!e)return[];const f=s.filter(v=>Object.hasOwn(e,v.key)),b=Object.keys(e).filter(v=>!s.some(w=>w.key===v)).sort().map(v=>({key:v,topic:S("settings.claudeIndex.notInRef"),scope:null,kind:"structured",default:null,since:null,anchor:""}));return[...f,...b]},[s,e,r,a]),h=u.slice(0,nj),p=r.trim()!=="";return i.jsxs(gn,{id:"claude-group-all",settingId:"claude-all-settings",title:n("settings.claudeIndex.title"),note:p?void 0:n(e&&!t?"settings.claudeIndex.notePresent":"settings.claudeIndex.noteAll"),aside:s?i.jsx("span",{className:"settings-caption-count",children:s.length}):void 0,list:!1,children:[i.jsxs("div",{className:"settings-filter",children:[i.jsx("label",{className:"vis-hidden",htmlFor:l,children:n("settings.claudeIndex.filterLabel")}),i.jsx("input",{id:l,type:"search",className:"settings-filter-field",placeholder:s?n("settings.claudeIndex.filterCount",{count:s.length}):n("settings.claudeIndex.filter"),autoComplete:"off",spellCheck:!1,value:r,onChange:f=>c(f.target.value),onKeyDown:f=>{ev(f.key)&&r&&(f.stopPropagation(),c(""))}})]}),h.length>0&&i.jsx("div",{className:"settings-list settings-keys",children:h.map(f=>{const b=e&&Object.hasOwn(e,f.key)?e[f.key]:null;return i.jsx(Ot,{as:"div",name:i.jsx("code",{className:"claude-key",children:f.key}),note:e2e(f,n),control:i.jsxs(i.Fragment,{children:[b!==null&&i.jsx("span",{className:"settings-read",title:n("settings.claudeIndex.inFile"),children:b}),f.anchor&&i.jsx("a",{className:"settings-link",href:`${Ome}#${f.anchor}`,target:"_blank",rel:"noreferrer","aria-label":n("settings.claudeIndex.referenceAria",{key:f.key}),children:n("settings.claudeIndex.reference")})]})},f.key)})}),p&&u.length===0&&s&&i.jsx("p",{className:"settings-empty",role:"status",children:n("settings.claudeIndex.noMatch",{query:r.trim()})}),u.length>nj&&i.jsx("p",{className:"settings-foot",role:"status",children:n("settings.claudeIndex.more",{count:u.length-nj})}),!p&&e&&!t&&s&&u.length===0&&i.jsx("p",{className:"settings-empty",children:n("settings.claudeIndex.empty")})]})}function s2e(e,t=S){return t("settings.claude.foot",{file:e??t("settings.claude.footDefault")})}const _W={Off:"settings.claude.effect.off",On:"settings.claude.effect.on","Updates are off":"settings.claude.effect.updatesOff","Background updates are off":"settings.claude.effect.bgUpdatesOff"};function i2e(e,t=S){const n=`${e.env}=${e.value}`,a=_W[e.effect]?t(_W[e.effect]):e.effect;return e.where==="environment"?t("settings.claude.overrideEnv",{effect:a,set:n}):t(e.where==="user"?"settings.claude.overrideUser":"settings.claude.overrideOrg",{effect:a,set:n})}const LW="\0custom";function o2e({entry:e,row:t,saving:n,nameId:a,noteId:s,flip:o}){const r=se(),c=!!t&&t.editable&&!n,l=!t||n===e.id,u=t?!t.editable:void 0;if(e.kind==="choice"||e.kind==="days"){const p=e.kind==="days"?e.options.map(v=>({value:String(v),label:JP(v,r)})):e.options.map(v=>({...v,label:Ime(e.id,v.value,v.label,r)})),f=t?t.custom?LW:t.value===null?"":String(t.value):"",b=e.kind==="days"&&t&&!t.custom&&!p.some(v=>v.value===f)?[...p,{value:f,label:JP(Number(f),r)}].sort((v,w)=>Number(v.value)-Number(w.value)):p;return i.jsx(dc,{children:i.jsxs("select",{className:"sm-select","aria-labelledby":a,"aria-describedby":s,"aria-busy":l,disabled:u,value:f,onChange:v=>{if(!c)return;const w=v.target.value;b7(e.id,e.kind==="days"?Number(w):w===""?null:w)},children:[(t==null?void 0:t.custom)&&i.jsx("option",{value:LW,disabled:!0,children:r("settings.claude.customValue")}),b.map(v=>i.jsx("option",{value:v.value??"",children:v.label},v.value??""))]})})}const h=o.checked;return i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":h,"aria-labelledby":a,"aria-describedby":s,"aria-busy":l,disabled:u,onClick:()=>{c&&o.flip()},children:i.jsx("span",{className:"switch-knob"})})}function r2e({entry:e,row:t,saving:n,said:a}){const s=se(),o=h7(t?t.value===!0:null,l=>b7(e.id,l)),r=`claude-${e.id}-label`,c=`claude-${e.id}-note`;return i.jsx(Ot,{settingId:`claude-${e.id}`,name:LG(e,s),nameId:r,note:Mme(e,s),noteId:c,control:i.jsx(o2e,{entry:e,row:t,saving:n,nameId:r,noteId:c,flip:o}),children:i.jsx("span",{className:"settings-row-said settings-row-said-quiet",role:"status",children:a})})}function c2e(e,t=S){if(e.length<2||e.some(s=>!s||s.editable))return null;const n=new Set(e.map(s=>s.reason));if(n.size!==1)return null;const a=k7([...n][0]);return a?t(a.unread?"settings.claude.groupNeedsUnread":"settings.claude.groupNeeds",{version:a.version}):null}function l2e(e){if(!(e!=null&&e.settings.length)||e.settings.some(n=>n.editable))return null;const t=new Set(e.settings.map(n=>n.reason));return t.size===1?[...t][0]??null:null}function d2e(){return i.jsx(u2e,{state:ZFe()})}function u2e({state:e}){const t=se(),{reading:n,saving:a,error:s,undone:o}=e,r=l2e(n),c=(n==null?void 0:n.userFile)==="absent",l=n?n.userFile!=="invalid"&&n.userFile!=="unreadable":!s;return i.jsxs(i.Fragment,{children:[(n===null||s||r||c)&&i.jsxs(gn,{children:[n===null&&!s&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.reading")}),r&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:Nb(r,t)}),c&&!r&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.noFile")}),s&&i.jsxs("div",{className:"settings-row",role:"alert",children:[i.jsx("span",{className:"settings-row-name",children:Nb(s,t)}),i.jsx("span",{className:"settings-row-control",children:i.jsx("button",{type:"button",className:"btn","aria-busy":!!a,onClick:()=>void kE(),children:t("settings.claude.retry")})})]})]}),l&&zG.map(u=>{const h=qG.filter(b=>b.group===u.id),p=h.map(b=>n==null?void 0:n.settings.find(v=>v.id===b.id)),f=r?null:c2e(p,t);return i.jsx(gn,{id:`claude-group-${u.id}`,title:_G(u.id,u.title,t),info:f??void 0,infoId:`claude-group-${u.id}-info`,children:h.map((b,v)=>{const w=p[v],T=w&&!w.editable&&!r&&!f?Nb(w.reason??"",t):(o==null?void 0:o.id)===b.id?t("settings.claude.undone"):w!=null&&w.override?i2e(w.override,t):"";return i.jsx(r2e,{entry:b,row:w,saving:a,said:T},b.id)})},u.id)}),l&&i.jsx("p",{className:"settings-foot",children:s2e(n==null?void 0:n.fileShown,t)}),i.jsx(a2e,{present:(n==null?void 0:n.present)??null,noFile:c})]})}function h2e(){const e=se(),[t,n]=m.useState(null),[a,s]=m.useState(""),[o,r]=m.useState(!1),[c,l]=m.useState(null),[u,h]=m.useState(""),p=m.useRef(!1),f=m.useRef(!0),b=async()=>{if(p.current)return;p.current=!0,r(!0),s("");const T=new AbortController,y=window.setTimeout(()=>T.abort(),12e3);try{const x=await fetch("/api/tool-audit/storage",{signal:T.signal}),C=await x.json();if(!x.ok||!C.ok)throw new Error;f.current&&n(C)}catch{f.current&&s(e("settings.tools.readFail"))}finally{window.clearTimeout(y),p.current=!1,f.current&&r(!1)}};m.useEffect(()=>(f.current=!0,b(),()=>{f.current=!1}),[]);const v=async(T,y)=>{if(p.current)return;p.current=!0,r(!0),s(""),h("");let x=!1;const C=new AbortController,A=window.setTimeout(()=>C.abort(),15e3);try{const E=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T==="clear"?{action:T,confirm:!0}:{action:T,days:y}),signal:C.signal}),R=await E.json();if(!E.ok||!R.ok)throw new Error;x=!0,f.current&&(l(null),h(T==="clear"?e("settings.tools.cleared"):e("settings.tools.retentionChanged",{days:y??0})))}catch{f.current&&s(e("settings.tools.updateFail"))}finally{window.clearTimeout(A),p.current=!1,f.current&&(r(!1),x&&b())}},w=c!==null&&i.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":e("settings.tools.confirm"),children:[i.jsx("p",{children:c==="clear"?e("settings.tools.confirmClear"):e("settings.tools.confirmKeep",{days:c})}),i.jsxs("div",{children:[i.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{v(c==="clear"?"clear":"retention",typeof c=="number"?c:void 0)},children:e(c==="clear"?"settings.tools.deleteBtn":"settings.tools.applyBtn")}),i.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{p.current||l(null)},children:e("settings.tools.cancel")})]})]});return i.jsxs(gn,{id:"tool-history-settings-title",title:e("settings.tools.title"),note:e("settings.tools.note"),className:"ta-settings",children:[t?i.jsxs(i.Fragment,{children:[i.jsx(Ot,{settingId:"tool-history-retention",name:e("settings.tools.keep"),nameId:"ta-keep-label",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:t.retentionDays,"aria-busy":o,onChange:T=>{if(p.current)return;const y=Number(T.target.value);y<t.retentionDays?l(y):v("retention",y)},children:[30,60,90].map(T=>i.jsx("option",{value:T,children:e("settings.tools.days",{count:T})},T))})})}),typeof c=="number"&&w,i.jsx(Ot,{as:"div",settingId:"tool-history-size",name:e("settings.tools.space"),note:e("settings.tools.since",{date:$fe(t.startedAt)}),control:i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"settings-read",children:Kfe(t.bytes)}),i.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{b()},children:e("settings.tools.refresh")})]})}),i.jsx(Ot,{as:"div",settingId:"tool-history-clear",name:e("settings.tools.clear"),note:e("settings.tools.clearNote"),control:i.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{p.current||l("clear")},children:e("settings.tools.clearBtn")})}),c==="clear"&&w,!t.storageOk&&i.jsx(Ot,{as:"div",name:e("settings.tools.unsaved"),note:e("settings.tools.unsavedNote")})]}):i.jsx(Ot,{as:"div",name:e(o?"settings.tools.reading":"settings.tools.unavailable")}),a&&i.jsxs("div",{className:"settings-row",role:"alert",children:[i.jsx("span",{className:"settings-row-name",children:a}),i.jsx("span",{className:"settings-row-control",children:i.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{b()},children:e("settings.tools.retry")})})]}),u&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:u})]})}const vE="agent-dag.integrations.active",Lz=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,p2e=32e3;function PW(e,t){const n=gt(Lz(e,t));if(!n)return{};try{const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}}function z4e(e,t){return{read(n,a){const s=PW(e,t)[n];return a(s)?s:void 0},write(n,a){const s=PW(e,t);a===void 0?delete s[n]:s[n]=a;const o=JSON.stringify(s);o.length<=p2e&&yt(Lz(e,t),o)}}}function g2e(e,t){Ja(Lz(e,t))}function q4e(e){const t=gt(vE);if(!t)return null;try{const n=JSON.parse(t),a=n&&typeof n=="object"?n[e]:null;return typeof a=="string"&&a.length<=80?a:null}catch{return null}}function _4e(e,t){let n={};try{const a=gt(vE),s=a?JSON.parse(a):{};s&&typeof s=="object"&&!Array.isArray(s)&&(n=Object.fromEntries(Object.entries(s).filter(([,o])=>typeof o=="string").slice(0,20)))}catch{}n[e]=t,yt(vE,JSON.stringify(n))}function wE(e){var a;const t=(a=e.meta)==null?void 0:a.checkedAt;if(!t)return null;const n=new Date(String(t));return Number.isNaN(n.getTime())?null:n.toLocaleString(Me(),{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...n.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}function yE(e){const t=e.meta??{};return e.kind==="gitlab"?typeof t.serverVersion=="string"&&t.serverVersion?`GitLab ${t.serverVersion}`:null:e.kind!=="jira"?null:t.deploymentType==="Cloud"?"Jira Cloud":t.deploymentType?`Jira ${t.deploymentType==="DataCenter"?"Data Center":String(t.deploymentType)}${t.serverVersion?` ${t.serverVersion}`:""}`:null}function m2e({connection:e,provider:t,available:n,busy:a,armed:s,note:o,headingRef:r,onTest:c,onEdit:l,onDisconnect:u,onCancelDisconnect:h}){var E;const p=se(),f=m.useRef(null),b=(t==null?void 0:t.label)??e.kind,v=e.account.name||e.account.login||p("integrations.conn.noAccount"),w=e.account.name&&e.account.login!==e.account.name?e.account.login:"",T=wE(e),y=yE(e),x=Array.isArray((E=e.meta)==null?void 0:E.warnings)?e.meta.warnings.filter(R=>typeof R=="string"):[],C=a===`test:${e.id}`,A=a===`delete:${e.id}`;return i.jsxs("section",{className:"ig-connection-details","aria-labelledby":"ig-managed-title",children:[i.jsxs("header",{className:"ig-managed-header",children:[t&&i.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:i.jsx(t.Glyph,{})}),i.jsxs("div",{className:"ig-managed-identity",children:[i.jsx("h2",{ref:r,tabIndex:-1,id:"ig-managed-title",className:"ig-managed-title",children:e.name||e.baseUrl}),i.jsx("p",{children:p("integrations.conn.saved",{label:b})})]})]}),i.jsxs("dl",{className:"ig-detail-facts",children:[i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.host")}),i.jsx("dd",{children:e.baseUrl})]}),i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.account")}),i.jsxs("dd",{children:[v,w?` (${w})`:""]})]}),i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.lastVerified")}),i.jsx("dd",{children:T??p("integrations.conn.noVerificationTime")})]}),i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.credentials")}),i.jsx("dd",{children:e.tokenSaved?p("integrations.conn.storedLocally"):p("integrations.conn.noToken")})]}),y&&i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.server")}),i.jsx("dd",{children:y})]})]}),!n&&i.jsx("p",{className:"ig-stranded",children:p("integrations.conn.strandedDisconnect",{label:b})}),x.length>0&&i.jsx("ul",{className:"ig-warnings",children:x.map(R=>i.jsx("li",{children:R},R))}),n&&i.jsxs("div",{className:"ig-manage-actions",children:[i.jsx("button",{type:"button",className:"btn","aria-busy":C,"aria-disabled":a!==null||void 0,onClick:c,children:p(C?"integrations.conn.testing":"integrations.conn.test")}),i.jsx("button",{type:"button",className:"btn","aria-disabled":a!==null||void 0,onClick:R=>{a===null&&l(R.currentTarget)},children:p("integrations.conn.edit")})]}),o&&o.scope!=="disconnect"&&i.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text}),i.jsxs("div",{className:"ig-disconnect-section",children:[i.jsx("h3",{children:p("integrations.conn.removeTitle")}),i.jsx("p",{children:p("integrations.conn.removeBody")}),i.jsxs("div",{className:"ig-manage-actions","data-integration-disconnect-actions":!0,onBlur:R=>{s&&!R.currentTarget.contains(R.relatedTarget)&&h()},children:[i.jsx("button",{ref:f,type:"button","data-integration-disconnect":!0,className:`btn danger${s?" armed":""}`,"aria-busy":A,"aria-disabled":a!==null||void 0,onKeyDown:R=>{R.repeat&&R.preventDefault()},"aria-label":s?p("integrations.conn.confirmAria",{name:e.name}):p("integrations.conn.disconnectAria",{name:e.name}),onClick:R=>u(R.currentTarget),children:p(A?"integrations.conn.disconnecting":s?"integrations.conn.confirmDisconnect":"integrations.conn.disconnect")}),s&&i.jsx("button",{type:"button",className:"btn","data-integration-cancel-disconnect":!0,"aria-disabled":a!==null||void 0,"aria-label":p("integrations.conn.cancelDisconnect"),onClick:()=>{var R;a===null&&(h(),(R=f.current)==null||R.focus())},children:p("integrations.cancel")})]}),s&&i.jsx("p",{className:"ig-note",role:"status",children:p("integrations.conn.pressConfirm")}),(o==null?void 0:o.scope)==="disconnect"&&i.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text})]})]})}function f2e({onBeforeLeaveChange:e}={}){var ot;const t=se(),n=Xg(),{connections:a,error:s}=n,[o,r]=m.useState(null),c=m.useRef(null),l=m.useRef(new Map),u=m.useRef(null),h=m.useRef(0),[p,f]=m.useState(null),[b,v]=m.useState(""),w=m.useRef(null),T=m.useRef(null),[y,x]=m.useState(null),[C,A]=m.useState(null),E=m.useRef(null),[R,z]=m.useState(null),[I,_]=m.useState([]),[D,L]=m.useState(null),P=m.useRef(0),[O,j]=m.useState(null),M=m.useRef(null),F=m.useRef(new Map),U=m.useRef(null),H=m.useRef(0),[$,Y]=m.useState(!1),[W,G]=m.useState(null),Q=m.useRef(null),J=m.useRef(new Map),X=m.useRef(new Map);m.useEffect(()=>{const ce=lOe();ce&&(U.current=J.current.get(ce)??null,f(ce),j(ce),x({mode:"edit",id:ce}));const Ce=cOe();Ce&&x({mode:"add",kind:Ce})},[]),m.useEffect(()=>{var ce,Ce;!O||!a||(Ce=(ce=X.current.get(O))==null?void 0:ce.scrollIntoView)==null||Ce.call(ce,{block:"nearest"})},[O,a]),m.useEffect(()=>{if(!D)return;const ce=()=>{var Oe,at;(Oe=document.activeElement)!=null&&Oe.hasAttribute("data-integration-cancel-disconnect")&&((at=document.querySelector(".ig-manage-view [data-integration-disconnect]"))==null||at.focus()),L(null)},Ce=()=>{document.hidden&&ce()},Ke=window.setTimeout(()=>{var Oe;(Oe=document.querySelector("[data-integration-disconnect-actions]"))!=null&&Oe.contains(document.activeElement)||ce()},4e3);return window.addEventListener("blur",ce),document.addEventListener("visibilitychange",Ce),()=>{window.clearTimeout(Ke),window.removeEventListener("blur",ce),document.removeEventListener("visibilitychange",Ce)}},[D]);const te=(ce,Ce,Ke,Oe)=>_(at=>[...at.filter(ut=>ut.id!==ce),{id:ce,tone:Ce,text:Ke,scope:Oe}]),K=ce=>_(Ce=>Ce.filter(Ke=>Ke.id!==ce)),V=async(ce,Ce)=>{if(!E.current){E.current=ce,A(ce);try{await Ce()}finally{E.current=null,A(null)}}},ee=ce=>(Ce,Ke)=>void V("form",async()=>{z(null);try{const Oe=await aOe(ce,Ce,Ke||void 0);x(null),G(null),Y(!1),f(null),r(null),v(t("integrations.settings.added")),te(Oe.id,"ok",t("integrations.settings.savedTested",{name:Oe.account.name||Oe.account.login})),j(Oe.id),M.current=()=>{var ut;const at=l.current.get(Oe.kind)??J.current.get(Oe.id);return(ut=at==null?void 0:at.scrollIntoView)==null||ut.call(at,{block:"nearest"}),at}}catch(Oe){z(Oe instanceof Ks?Oe:new Ks("upstream",t("integrations.settings.saveFailed")))}}),de=ce=>(Ce,Ke)=>void V("form",async()=>{z(null);try{const{connection:Oe,validated:at}=await sOe(ce.id,{name:Ke,input:Ce});x(null),G(null),Y(!1),M.current=()=>T.current??(p?w.current:J.current.get(Oe.id)),te(Oe.id,"ok",at?t("integrations.settings.savedPassed",{name:Oe.account.name||Oe.account.login}):t("integrations.settings.saved"))}catch(Oe){z(Oe instanceof Ks?Oe:new Ks("upstream",t("integrations.settings.changeFailed")))}}),he=ce=>void V(`test:${ce.id}`,async()=>{L(null),K(ce.id);try{const Ce=await iOe(ce.id);te(ce.id,"ok",t("integrations.settings.testPassed",{name:Ce.account.name||Ce.account.login}))}catch(Ce){te(ce.id,"err",rr(Ce,t("integrations.settings.testFailed")))}}),me=(ce,Ce)=>{if(E.current)return;const Ke=Date.now(),Oe=zl({armedFor:D,target:ce.id,armedAt:P.current,now:Ke,gapMs:Rl});if(Oe==="arm"){Ce.focus({preventScroll:!0}),L(ce.id),P.current=Ke;return}Oe!=="ignore"&&(L(null),V(`delete:${ce.id}`,async()=>{try{await oOe(ce.id),g2e(ce.kind,ce.id),K(ce.id),(y==null?void 0:y.mode)==="edit"&&y.id===ce.id&&x(null),f(null);const at=(a??[]).filter(vt=>vt.kind===ce.kind&&vt.id!==ce.id);(!o||at.length===0)&&r(null),v(t("integrations.settings.disconnected"));const ut=document.activeElement;(ut===Ce||fa((ut==null?void 0:ut.tagName)??null))&&(M.current=()=>{var qe;const vt=(o&&at[0]?J.current.get(at[0].id):l.current.get(ce.kind))??F.current.get(ce.kind)??document.getElementById("settings-tab-integrations");return(qe=vt==null?void 0:vt.scrollIntoView)==null||qe.call(vt,{block:"nearest"}),vt})}catch(at){te(ce.id,"err",rr(at,t("integrations.settings.removeFailed")),"disconnect")}}))};m.useEffect(()=>{if(C!==null||W||!M.current)return;const ce=M.current();M.current=null,ce!=null&&ce.isConnected&&(ce.checkVisibility?ce.checkVisibility():ce.getClientRects().length>0)&&ce.focus({preventScroll:!0})},[a,p,o,y,C,W]);const be=a??[],ie=Qg(n),ne=["github","gitlab","jira"],ke=Az().filter(ce=>ie.has(ce.kind)||be.some(Ce=>Ce.kind===ce.kind)).sort((ce,Ce)=>ne.indexOf(ce.kind)-ne.indexOf(Ce.kind)),Se=Ez(n),ve=m.useCallback(()=>{x(null),f(null),r(null),Y(!1),G(null),z(null),L(null),M.current=()=>{const ce=U.current,Ce=ce==null?void 0:ce.closest(".settings-pane");return Ce&&(Ce.scrollTop=H.current),ce!=null&&ce.isConnected?ce:document.getElementById("settings-tab-integrations")}},[]),xe=m.useCallback(()=>{if(!o){ve();return}f(null),x(null),Y(!1),G(null),z(null),L(null),M.current=()=>{var Ke;const ce=(Ke=u.current)!=null&&Ke.isConnected?u.current:c.current,Ce=ce==null?void 0:ce.closest(".settings-pane");return Ce&&(Ce.scrollTop=ce===c.current?0:h.current),ce}},[o,ve]),Ee=m.useCallback(()=>{if(!p&&!o){ve();return}x(null),Y(!1),G(null),z(null),M.current=()=>T.current??(p?w.current:c.current)},[p,o,ve]),Ge=m.useCallback((ce,Ce=!1)=>{if(E.current)return;if(W&&Ce){G(null),requestAnimationFrame(()=>{var Oe;return(Oe=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:Oe.focus()});return}const Ke=Ce?y?Ee:p?xe:ve:()=>{x(null),f(null),r(null),ce()};$?G(()=>Ke):(Y(!1),Ke())},[$,W,y,p,Ee,xe,ve]);m.useEffect(()=>(e==null||e(y||p||o?Ge:null),()=>e==null?void 0:e(null)),[y,p,o,Ge,e]),m.useEffect(()=>{var ce;W&&((ce=Q.current)==null||ce.focus())},[W]),m.useEffect(()=>{var ce;p&&((ce=w.current)==null||ce.focus())},[p]),m.useEffect(()=>{var ce;o&&((ce=c.current)==null||ce.focus())},[o]);const Qe=(ce,Ce)=>{var Oe;if(E.current)return;M.current=null,G(null),v(""),L(null),p||o?T.current=Ce:(H.current=((Oe=Ce.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0,U.current=Ce,T.current=null),Y(!1),z(null),x(ce);const Ke=Ce.closest(".settings-pane");Ke&&(Ke.scrollTop=0)},Je=(ce,Ce)=>{var Oe,at;if(E.current)return;M.current=null,o?(u.current=Ce,h.current=((Oe=Ce.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0):(H.current=((at=Ce.closest(".settings-pane"))==null?void 0:at.scrollTop)??0,U.current=Ce),T.current=null,v(""),L(null),f(ce.id);const Ke=Ce.closest(".settings-pane");Ke&&(Ke.scrollTop=0)},He=(ce,Ce)=>{var at;const Ke=be.filter(ut=>ut.kind===ce);if(Ke.length===1){Je(Ke[0],Ce);return}if(E.current)return;M.current=null,H.current=((at=Ce.closest(".settings-pane"))==null?void 0:at.scrollTop)??0,U.current=Ce,u.current=null,h.current=0,v(""),L(null),r(ce);const Oe=Ce.closest(".settings-pane");Oe&&(Oe.scrollTop=0)},_e=(ce,Ce=!1)=>{const Ke=Ep(ce.kind),Oe=!Qo(n,ce.kind),at=wE(ce),ut=ce.account.login||ce.account.name,vt=ce.kind==="jira"?yE(ce):null;return i.jsx("div",{className:"ig-conn",ref:qe=>{qe?X.current.set(ce.id,qe):X.current.delete(ce.id)},children:i.jsxs("div",{className:"ig-summary-row",children:[i.jsxs("div",{className:"ig-summary-text",children:[i.jsx("span",{className:"ig-conn-name",children:Ce&&ce.name||Yc(ce)}),i.jsx("span",{className:"ig-conn-line",children:[Ce&&ce.name!==Yc(ce)?Yc(ce):"",ut,vt||(at?t("integrations.conn.lastVerifiedAt",{when:at}):t("integrations.conn.notVerified"))].filter(Boolean).join(" · ")||t("integrations.conn.noAccount")}),!ce.tokenSaved&&i.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")}),Oe&&i.jsx("span",{className:"ig-stranded",children:t("integrations.conn.strandedManage",{label:(Ke==null?void 0:Ke.label)??ce.kind})})]}),i.jsxs("button",{type:"button",className:"btn ig-manage",ref:qe=>{qe?J.current.set(ce.id,qe):J.current.delete(ce.id)},"aria-label":t("integrations.settings.manageAria",{label:(Ke==null?void 0:Ke.label)??ce.kind,name:ce.name,account:ut||Yc(ce)}),onClick:qe=>Je(ce,qe.currentTarget),children:[t("integrations.manage")," ",i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m6 4 4 4-4 4"})})]})]})},ce.id)},le=be.filter(ce=>!ke.some(Ce=>Ce.kind===ce.kind)),Re=o?Ep(o):null,ge=be.filter(ce=>ce.kind===o),Pe=be.find(ce=>ce.id===p),Fe=(y==null?void 0:y.mode)==="edit"?be.find(ce=>ce.id===y.id):void 0,Ve=(y==null?void 0:y.mode)==="add"?ke.find(ce=>ie.has(ce.kind)&&ce.kind===y.kind):Fe&&ke.find(ce=>ie.has(ce.kind)&&ce.kind===Fe.kind);return i.jsxs("div",{className:"ig-settings","data-view":y?"form":p?"connection":o?"provider":"overview",children:[y&&i.jsxs("div",{className:"ig-config-view",children:[i.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":C!==null||void 0,onClick:()=>Ge(Ee,!0),children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),p?t("integrations.settings.backToConn"):o?t("integrations.settings.backToList",{label:(Re==null?void 0:Re.label)??o}):t("integrations.settings.all")]}),W&&i.jsxs("div",{className:"ig-leave-confirm",role:"group","aria-labelledby":"ig-leave-title",children:[i.jsx("strong",{id:"ig-leave-title",children:t("integrations.settings.discardTitle")}),i.jsx("p",{children:t("integrations.settings.discardBody")}),i.jsxs("div",{className:"ig-form-actions",children:[i.jsx("button",{ref:Q,type:"button",className:"btn",onClick:()=>{G(null),requestAnimationFrame(()=>{var ce;return(ce=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:ce.focus()})},children:t("integrations.settings.keepEditing")}),i.jsx("button",{type:"button",className:"btn danger",onClick:()=>{const ce=W;G(null),Y(!1),x(null),ce()},children:t("integrations.settings.discard")})]})]}),i.jsx("div",{hidden:!!W,children:Ve?i.jsx(RPe,{def:Ve,existing:Fe,busy:C==="form",error:R,onDirtyChange:Y,onSubmit:y.mode==="add"?ee(y.kind):de(Fe),onCancel:()=>Ge(Ee,!0)},y.mode==="add"?y.kind:y.id):i.jsxs("div",{role:"status",children:[i.jsx("p",{children:t("integrations.settings.gone")}),i.jsx("button",{type:"button",className:"btn",onClick:Ee,children:t("integrations.settings.backToIntegrations")})]})})]}),o&&i.jsxs("div",{className:"ig-provider-view",hidden:y!==null||p!==null,children:[i.jsxs("div",{className:"ig-manage-navigation",children:[i.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":C!==null||void 0,onClick:()=>Ge(ve,!0),children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),t("integrations.settings.all")]}),Qo(n,o)&&i.jsx("button",{type:"button",className:"btn","aria-disabled":C!==null||void 0,onClick:ce=>Qe({mode:"add",kind:o},ce.currentTarget),children:t("integrations.settings.addConn",{label:(Re==null?void 0:Re.label)??o})})]}),i.jsx("h2",{ref:c,tabIndex:-1,className:"ig-managed-title",children:t("integrations.settings.connsTitle",{label:(Re==null?void 0:Re.label)??o})}),b&&i.jsx("p",{className:"ig-note",role:"status",children:b}),ge.length?i.jsx("div",{className:"ig-provider-connections",children:ge.map(ce=>_e(ce,!0))}):i.jsx("p",{role:"status",children:t("integrations.settings.noSaved")})]}),p&&i.jsxs("div",{className:"ig-manage-view",hidden:y!==null,children:[i.jsxs("div",{className:"ig-manage-navigation",children:[i.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":C!==null||void 0,onClick:()=>Ge(xe,!0),children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),o?t("integrations.settings.backToList",{label:(Re==null?void 0:Re.label)??o}):t("integrations.settings.all")]}),Pe&&Qo(n,Pe.kind)&&i.jsx("button",{type:"button",className:"btn","aria-disabled":C!==null||void 0,onClick:ce=>Qe({mode:"add",kind:Pe.kind},ce.currentTarget),children:t("integrations.settings.addConn",{label:((ot=Ep(Pe.kind))==null?void 0:ot.label)??Pe.kind})})]}),Pe?i.jsx(m2e,{connection:Pe,provider:Ep(Pe.kind),available:Qo(n,Pe.kind),busy:C,armed:D===p,note:I.find(ce=>ce.id===p),headingRef:w,onTest:()=>he(Pe),onEdit:ce=>Qe({mode:"edit",id:Pe.id},ce),onDisconnect:ce=>me(Pe,ce),onCancelDisconnect:()=>L(null)}):i.jsx("p",{role:"status",children:t("integrations.settings.noLongerSaved")})]}),i.jsxs("div",{className:"ig-overview",hidden:y!==null||p!==null||o!==null,children:[s&&i.jsxs("div",{className:"ig-list-error",role:"alert",children:[i.jsx("p",{children:s}),i.jsx("button",{type:"button",className:"btn",onClick:()=>void Qv(),children:t("integrations.retry")})]}),a===null&&!s&&i.jsxs("p",{className:"loader-line",role:"status",children:[i.jsx(Fg,{busy:!0}),t("integrations.settings.reading")]}),b&&i.jsx("p",{className:"ig-note",role:"status",children:b}),i.jsxs("div",{className:"ig-connection-list","data-setting":"integrations-connections",children:[a!==null&&i.jsx("div",{className:"ig-providers","data-setting":"integrations-add",id:Se==="all"?"integrations-add-title":void 0,children:[{id:"connected",title:t("integrations.settings.connectedGroup"),providers:ke.filter(ce=>be.some(Ce=>Ce.kind===ce.kind))},{id:"not-connected",title:t("integrations.settings.notConnectedGroup"),providers:ke.filter(ce=>!be.some(Ce=>Ce.kind===ce.kind))}].filter(ce=>ce.providers.length>0).map(ce=>i.jsx(gn,{id:`ig-group-${ce.id}`,title:ce.title,children:ce.providers.map(Ce=>{const Ke=be.filter(et=>et.kind===Ce.kind),Oe=Ke.length===1?Ke[0]:null,at=[...new Set(Ke.map(Yc))],ut=Oe&&wE(Oe),vt=(Oe==null?void 0:Oe.kind)==="jira"?yE(Oe):null,qe=Ke.length===0?t("integrations.settings.notConnected"):Oe?vt||(ut?t("integrations.conn.lastVerifiedAt",{when:ut}):t("integrations.conn.notVerified")):t("integrations.settings.count",{count:Ke.length}),dt=Ke.length===0?"":Oe?[Yc(Oe),Oe.account.login||Oe.account.name].filter(Boolean).join(" · "):`${at.slice(0,2).join(" · ")}${at.length>2?` · ${t("integrations.settings.moreInstances",{n:at.length-2})}`:""}`;return i.jsxs("section",{className:"ig-provider",id:`ig-provider-${Ce.kind}`,"aria-labelledby":`ig-provider-name-${Ce.kind}`,"data-setting":`integration-${Ce.kind}`,children:[i.jsxs("div",{className:"ig-summary-text ig-provider-content",children:[i.jsx("h3",{id:`ig-provider-name-${Ce.kind}`,children:Ce.label}),dt&&i.jsx("span",{className:"ig-conn-line",children:dt}),Oe&&!Oe.tokenSaved&&i.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")}),!ie.has(Ce.kind)&&i.jsx("span",{className:"ig-stranded",children:t("integrations.conn.unavailable",{label:Ce.label})})]}),i.jsx("span",{className:"ig-provider-state",children:qe}),i.jsx("button",{type:"button",className:`btn ig-manage${Ke.length?"":" primary"}`,"aria-disabled":C!==null||void 0,ref:et=>{const Ie=Ke.length?l.current:F.current;et?Ie.set(Ce.kind,et):Ie.delete(Ce.kind)},"aria-label":Ke.length?t("integrations.manageProvider",{label:Ce.label}):t("integrations.form.connect",{provider:Ce.label}),onClick:et=>Ke.length?He(Ce.kind,et.currentTarget):Qe({mode:"add",kind:Ce.kind},et.currentTarget),children:Ke.length?i.jsxs(i.Fragment,{children:[t("integrations.manage")," ",i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m6 4 4 4-4 4"})})]}):t("integrations.form.connectBtn")})]},Ce.kind)})},ce.id))}),(le.length>0||ke.length===0&&Se!=="all"&&a!==null)&&i.jsxs(gn,{id:"integrations-list-title",title:t("integrations.settings.connections"),aside:i.jsx("span",{className:"settings-caption-count",children:le.length}),children:[le.map(ce=>_e(ce,!0)),be.length===0&&i.jsx("p",{className:"settings-row settings-row-status",children:t("integrations.settings.nothing")})]})]}),Se==="all"&&i.jsx(i.Fragment,{children:i.jsx("div",{className:"ig-overview-info",children:i.jsxs("details",{className:"ig-access",children:[i.jsx("summary",{children:t("integrations.settings.accessSummary")}),i.jsx("p",{children:t("integrations.settings.accessBody")})]})})})]})]})}function b2e({theme:e}){return i.jsx("span",{className:"appearance-preview","data-swatch":e,children:i.jsxs("svg",{viewBox:"0 0 112 56",preserveAspectRatio:"xMidYMid slice","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),i.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),i.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),i.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),i.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),i.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),i.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),i.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),i.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),i.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function k2e({theme:e,onTheme:t,singleKeys:n}){const a=se(),s=c=>{var p,f;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(c.key))return;c.preventDefault();const l=(p=c.target.closest("[data-theme-choice]"))==null?void 0:p.dataset.themeChoice,h=(io.indexOf(l??e)+(c.key==="ArrowLeft"||c.key==="ArrowUp"?-1:1)+io.length)%io.length;t(io[h]),(f=c.currentTarget.querySelectorAll('[role="radio"]')[h])==null||f.focus()},o=m.useRef(null),r=m.useRef(e);return m.useEffect(()=>{var u,h;const c=r.current;r.current=e;const l=document.activeElement;c===e||!l||!((u=o.current)!=null&&u.contains(l))||l.dataset.themeChoice!==c||(h=o.current.querySelector(`[data-theme-choice="${e}"]`))==null||h.focus()},[e]),i.jsx(gn,{id:"appearance-theme-caption",title:a("settings.theme.title"),list:!1,settingId:"theme",aside:n&&i.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:a("settings.theme.keyTip"),children:"T"}),children:i.jsx("div",{ref:o,className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:io.map(c=>i.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":c,"data-setting":`theme-${c}`,"aria-checked":e===c,tabIndex:e===c?0:-1,onClick:()=>t(c),children:[i.jsx(b2e,{theme:c}),i.jsxs("span",{className:"appearance-theme-name",children:[GG(c,a),i.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},c))})})}const v2e=[["smallest","settings.reading.size.smallest","11 px"],["smaller","settings.reading.size.smaller","12 px"],["default","settings.reading.size.default","13 px"],["larger","settings.reading.size.larger","15 px"],["largest","settings.reading.size.largest","17 px"]],w2e=[["tightest","settings.reading.density.tightest","30%"],["tighter","settings.reading.density.tighter","50%"],["compact","settings.reading.density.compact","70%"],["default","settings.reading.density.default","100%"],["comfortable","settings.reading.density.comfortable","140%"]];function y2e({textSize:e,density:t,onTextSize:n,onDensity:a}){const s=se(),o=e!=="default"||t!==ok;return i.jsx("button",{type:"button",className:"btn",disabled:!o,onClick:()=>{n("default"),a(ok)},children:s("settings.reading.reset")})}function x2e({textSize:e,density:t,onTextSize:n,onDensity:a}){const s=se();return i.jsxs(i.Fragment,{children:[i.jsxs(gn,{children:[i.jsx(Ot,{settingId:"text-size",name:s("settings.reading.sizeTitle"),nameId:"reading-size-label",note:s("settings.reading.sizeHelp"),noteId:"reading-size-help",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",name:"text-size","aria-labelledby":"reading-size-label","aria-describedby":"reading-size-help",value:e,onChange:o=>n(fbe.find(r=>r===o.target.value)??"default"),children:v2e.map(([o,r,c])=>i.jsxs("option",{value:o,children:[s(r)," ",c]},o))})})}),i.jsx(Ot,{settingId:"density",name:s("settings.reading.densityTitle"),nameId:"reading-density-label",note:s("settings.reading.densityHelp"),noteId:"reading-density-help",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",name:"density","aria-labelledby":"reading-density-label","aria-describedby":"reading-density-help",value:t,onChange:o=>a(bbe.find(r=>r===o.target.value)??ok),children:w2e.map(([o,r,c])=>i.jsxs("option",{value:o,children:[s(r)," ",c]},o))})})})]}),i.jsx(gn,{id:"reading-preview-title",title:s("settings.reading.preview"),list:!1,children:i.jsxs("div",{className:"reading-preview",children:[i.jsxs("div",{className:"reading-preview-row",children:[i.jsxs("div",{children:[i.jsx("strong",{children:s("settings.reading.sample1")}),i.jsx("span",{children:s("settings.reading.sample1State")})]}),i.jsx("span",{className:"reading-preview-time",children:"4m"})]}),i.jsxs("div",{className:"reading-preview-row",children:[i.jsxs("div",{children:[i.jsx("strong",{children:s("settings.reading.sample2")}),i.jsx("span",{children:s("settings.reading.sample2State")})]}),i.jsx("span",{className:"reading-preview-time",children:"12m"})]})]})}),i.jsx("p",{className:"settings-foot",children:s("settings.reading.foot")})]})}function C2e({cli:e,running:t}){const n=se(),a=n("shell.terminal.versions",{product:an,cli:e.version,running:t}),s=i.jsx("code",{children:e.command});return e.auto==="pending"||e.auto==="running"?i.jsx(Ot,{as:"div",name:n("shell.terminal.name"),note:a,control:i.jsx("span",{className:"settings-read",children:e.auto==="running"?n("shell.terminal.updating"):n("shell.terminal.updatingSoon")}),children:i.jsx("span",{className:"settings-row-said",children:e.auto==="running"?n("shell.terminal.updatingNow"):ck(n("shell.terminal.soon"),"cmd",s)})}):i.jsx(Ot,{as:"div",name:n("shell.terminal.name"),note:e.auto==="failed"?a:n("shell.terminal.notUpdated",{versions:a}),control:i.jsx("span",{className:"settings-read",children:n("shell.terminal.needed")}),children:i.jsxs("span",{className:"settings-row-said",children:[e.auto==="failed"&&i.jsxs(i.Fragment,{children:[e.error?n("shell.terminal.failedWith",{error:e.error}):n("shell.terminal.failed")," "]}),ck(n("shell.terminal.run"),"cmd",s)]})})}const S2e="AGPL-3.0-only",T2e="https://github.com/BarganConstantin/ccdeck",N2e="https://github.com/sponsors/BarganConstantin";function A2e(e,t=S){return t("settings.about.pageBehind",{bundle:e})}function j2e(e,t){return vo(e)&&vo(t)&&lc(e,t)<0}function E2e(e,t,n=S){return e?{kind:"ready",to:e.version,name:n("settings.about.updateReady"),note:n("settings.about.updateReadyNote",{product:an,version:e.version})}:t?t.kind==="restart"?{kind:"notice",name:n("settings.about.updateInstalled"),note:n("settings.about.updateInstalledNote",{to:t.to,from:t.from})}:{kind:"notice",name:n("settings.about.updateAvailable"),note:n("settings.about.updateAvailableNote",{product:an,to:t.to,from:t.from})}:null}function R2e({version:e,notice:t,readyAppUpdate:n,updateRestarting:a,updateFailure:s,onUpdateRestart:o,doors:r,bundle:c="4.0.2"}){const l=se(),u=(e==null?void 0:e.running)??c,h=E2e(n,t,l);return i.jsxs(i.Fragment,{children:[i.jsxs(gn,{id:"settings-about-caption",title:l("settings.about.version"),children:[i.jsx(Ot,{as:"div",settingId:"version",name:l("settings.about.version"),note:j2e(c,e==null?void 0:e.running)?A2e(c,l):void 0,control:i.jsx("span",{className:"settings-read",children:u})}),(e==null?void 0:e.terminalCli)&&i.jsx(C2e,{cli:e.terminalCli,running:u}),h&&i.jsx(z2e,{offer:h,restarting:a,failure:s,onRestart:o,onUpdate:r.update}),i.jsx(Ot,{as:"div",settingId:"whats-new",name:l("settings.about.whatsNew"),control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":l("settings.about.openWhatsNew"),onClick:r.whatsNew,children:l("settings.about.open")})})]}),i.jsxs(gn,{id:"settings-about-help-caption",title:l("settings.about.helpGroup"),children:[i.jsx(Ot,{as:"div",settingId:"tour",name:l("settings.about.tour"),control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":l("settings.about.startTour"),onClick:r.tour,children:l("settings.about.start")})}),i.jsx(Ot,{as:"div",settingId:"feedback",name:l("settings.about.feedback"),control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":l("settings.about.openFeedback"),onClick:r.feedback,children:l("settings.about.open")})})]}),i.jsxs(gn,{id:"settings-about-project-caption",title:l("settings.about.projectGroup"),children:[i.jsx(Ot,{as:"div",settingId:"licence",name:l("settings.about.licence"),note:l("settings.about.licenceNote"),control:i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"settings-read",children:S2e}),i.jsxs("a",{className:"settings-link",href:T2e,target:"_blank",rel:"noreferrer",children:[l("settings.about.source"),i.jsx("span",{className:"vis-hidden",children:l("settings.about.sourceHidden")})]})]})}),i.jsx(Ot,{as:"div",settingId:"sponsor",name:l("settings.about.sponsor"),note:l("settings.about.sponsorNote"),control:i.jsxs("a",{className:"settings-link",href:N2e,target:"_blank",rel:"noreferrer",children:[l("settings.about.sponsorLink"),i.jsx("span",{className:"vis-hidden",children:l("settings.about.sponsorHidden")})]})})]})]})}function z2e({offer:e,restarting:t,failure:n,onRestart:a,onUpdate:s}){const o=se();if(e.kind==="notice")return i.jsx(Ot,{as:"div",name:e.name,note:e.note,control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:s,children:o("settings.about.updateBtn")})});const r=zOe(e.to,t),c=n&&n.version===e.to?U8(n.failure,n.version):"";return i.jsx(Ot,{as:"div",name:e.name,note:e.note,control:i.jsx("button",{type:"button",className:"btn",onClick:()=>a(e.to),"aria-busy":t||void 0,"aria-label":r.label,title:r.title,children:r.text}),children:i.jsx("span",{className:"settings-row-said",role:"status",children:c})})}function q2e(e,t){return t&&(e!=null&&e.checkDisabled)?"app":(e==null?void 0:e.canRestart)===!1?"no-restart":e!=null&&e.checkDisabled?"checks-off":"plain"}const _2e={plain:"settings.updates.plainDetails","checks-off":"settings.updates.checksOffDetails","no-restart":"settings.updates.noRestartDetails"};function L2e({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:a=lr()}){const s=se(),o=q2e(n,a),r=o==="no-restart"?s("settings.updates.noRestartNote"):o==="checks-off"?s("settings.updates.checksOffNote"):null;return i.jsx(gn,{id:o==="app"?void 0:"settings-updates-caption",title:o==="app"?void 0:s("settings.updates.title"),children:o==="app"?i.jsx(Ot,{as:"div",settingId:"auto-update",name:s("settings.updates.title"),note:s("settings.updates.appNote")}):i.jsx(Ot,{settingId:"auto-update",name:s("settings.updates.label"),nameId:"settings-auto-update-label",note:s("settings.updates.plainNote"),details:s(_2e[o]),noteId:"settings-auto-update-note",control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-auto-update-label","aria-describedby":r?"settings-auto-update-note settings-auto-update-info":"settings-auto-update-note",onClick:t,children:i.jsx("span",{className:"switch-knob"})}),children:r&&i.jsx(_z,{id:"settings-auto-update-info",children:r})})})}function P2e({character:e,onCharacter:t}){const n=se(),a=m.useRef([]);function s(o,r){var l;const c=Fu(o,r,mb.length,"vertical");c.kind==="select"&&(o.preventDefault(),t(mb[c.index].id),(l=a.current[c.index])==null||l.focus())}return i.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":n("settings.character.choose"),"data-setting":"character-choice",children:mb.map((o,r)=>i.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===o.id,tabIndex:e===o.id?0:-1,ref:c=>{a.current[r]=c},onClick:()=>t(o.id),onKeyDown:c=>s(c,r),children:[i.jsx("span",{className:"character-preview",children:i.jsx(X5,{character:o.id,act:null,facing:"right"})}),i.jsx("span",{children:o.name}),i.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},o.id))})}function O2e({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:a}){const s=se();return i.jsxs(gn,{id:"appearance-character-caption",title:s("settings.character.title"),list:!1,children:[i.jsx("div",{className:"settings-list",children:i.jsx(Ot,{settingId:"character",name:s("settings.character.show"),nameId:"appearance-character-label",note:s("settings.character.note"),noteId:"appearance-character-note",control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:i.jsx("span",{className:"switch-knob"})})})}),i.jsx(P2e,{character:n,onCharacter:a})]})}const w7="agent-dag.view";function _k(e=gt){return e(w7)==="workspace"?"workspace":"board"}function y7(e,t=yt){t(w7,e)}function x7(e,t){return e.enabled&&e.supported!==!1&&!t}function M2e(){const[e,t]=m.useState(()=>_k()),n=m.useCallback(a=>{t(a),y7(a)},[]);return{stored:e,set:n}}const em={status:"/api/terminal/engine",install:"/api/terminal/engine/install",installFile:"/api/terminal/engine/install-file",cancel:"/api/terminal/engine/cancel",remove:"/api/terminal/engine/remove"},dl=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function I2e(e){if(!dl(e)||typeof e.platform!="string"||typeof e.supported!="boolean")return null;const t=dl(e.installed)&&typeof e.installed.version=="string"?{version:e.installed.version,bytes:typeof e.installed.bytes=="number"?e.installed.bytes:0}:null,n=dl(e.job)&&typeof e.job.id=="string"&&typeof e.job.phase=="string"?{id:e.job.id,phase:e.job.phase,received:typeof e.job.received=="number"?e.job.received:0,total:typeof e.job.total=="number"?e.job.total:null,source:e.job.source==="file"?"file":"download",startedAt:typeof e.job.startedAt=="number"?e.job.startedAt:0}:null,a=dl(e.last)&&typeof e.last.id=="string"&&typeof e.last.outcome=="string"?e.last:null;return{platform:e.platform,app:typeof e.app=="string"?e.app:null,fixPath:typeof e.fixPath=="string"?e.fixPath:null,supported:e.supported,blocked:typeof e.blocked=="string"?e.blocked:null,canInstallFile:e.canInstallFile===!0,installed:t,present:e.present===!0,pinned:typeof e.pinned=="string"?e.pinned:null,job:n,last:a,recovered:e.recovered===!0,elsewhere:e.elsewhere===!0}}const tm=(e,t)=>fetch(e,t);async function D2e(e=tm){try{const t=await e(em.status,{method:"GET"});if(!t.ok)return null;const n=await t.json().catch(()=>null);return dl(n)&&n.ok===!0?I2e(n.engine):null}catch{return null}}async function ew(e,t,n){try{const a=await n(e,{method:"POST",...t}),s=await a.json().catch(()=>null);return dl(s)&&s.ok===!0?{ok:!0,...typeof s.id=="string"?{id:s.id}:{}}:{ok:!1,code:dl(s)&&typeof s.code=="string"?s.code:a.status===404?"turned-off":"failed"}}catch{return{ok:!1,code:"unreachable"}}}const Pz=()=>({headers:{"Content-Type":"application/json"},body:"{}"}),F2e=(e=tm)=>ew(em.install,Pz(),e),B2e=(e=tm)=>ew(em.cancel,Pz(),e),U2e=(e=tm)=>ew(em.remove,Pz(),e),W2e=(e,t=tm)=>ew(em.installFile,{headers:{"Content-Type":"application/octet-stream"},body:e},t);function H2e(e){const[t,n]=e.split("-"),a=t==="darwin"?"macOS":t==="win32"?"Windows":t==="linux"?"Linux":t,s=t==="darwin"?n==="arm64"?"Apple silicon":n==="x64"?"Intel":n:n==="arm64"?"ARM64":n==="arm"?"ARM 32-bit":n==="ia32"?"x86 32-bit":n;return s?`${a} · ${s}`:a}function C7(e,t){const n=o=>{const r=/^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(o);return r?[Number(r[1]),Number(r[2]),Number(r[3]),r[4]?0:1]:null};if(!e||!t)return!1;const a=n(e),s=n(t);if(!a||!s)return!1;for(let o=0;o<4;o++)if(a[o]!==s[o])return a[o]<s[o];return!1}const ab=e=>(e/1e6).toFixed(1),G2e=400,V2e=1500,L4e=15e3,K2e=3e3,xE="agent-dag.engineInstall.job";function $2e(){try{return sessionStorage.getItem(xE)}catch{return null}}function J2e(e){try{e?sessionStorage.setItem(xE,e):sessionStorage.removeItem(xE)}catch{}}const Y2e=new Set(["check-failed","wrong-machine","downgrade"]);function P4e({status:e,code:t,mine:n,watched:a,retried:s=!1}){if(e===void 0)return{state:"checking"};if(e===null)return{state:"plain"};const{job:o,last:r}=e;if(o)return o.id!==n?{state:"elsewhere",job:o}:o.phase==="downloading"?{state:"downloading",job:o}:{state:"verifying",job:o};if(e.elsewhere)return{state:"elsewhere",job:null};if(r&&a.has(r.id)){if(r.outcome==="done")return s?{state:"start-failed"}:{state:"ready",version:r.version};if(r.outcome==="failed"){const u=r.code;return u==="offline"?{state:"offline",received:r.received??0,total:r.total??null}:u==="no-permission"?{state:"permission",fixPath:e.fixPath}:Y2e.has(u)?{state:"check",code:u,step:r.step}:u==="unsafe-folder"?{state:"folder",install:!0}:u==="no-space"?{state:"no-space"}:u==="not-published"?{state:"unavailable",file:e.canInstallFile}:u==="elsewhere"?{state:"elsewhere",job:null}:{state:"failed",step:r.step}}}if(!e.supported||t==="unsupported")return{state:"unsupported"};const c=e.blocked===null,l=e.canInstallFile;return e.installed?e.recovered?{state:"recovered",version:e.installed.version}:t==="failed"||s?{state:"start-failed"}:e.pinned&&C7(e.installed.version,e.pinned)?{state:"update",installed:e.installed.version,pinned:e.pinned,download:c,file:l}:{state:"ready",version:e.installed.version}:t==="unsafe-folder"?{state:"folder",install:!1}:e.blocked==="no-keys"||e.blocked==="not-published"||e.blocked==="unsupported"?{state:"unavailable",file:l}:{state:"ask",download:c,file:l,downloadOff:e.blocked==="download-disabled"}}function O4e(e,t,n){const a=m.useRef(n);m.useEffect(()=>{a.current=n}),m.useEffect(()=>{if(!e)return;const s=setTimeout(()=>a.current(),t);return()=>clearTimeout(s)},[e,t])}function Z2e(e){if(e.length<2)return null;const t=e[0],n=e[e.length-1],a=n.at-t.at;return a<500?null:Math.max(0,(n.received-t.received)/(a/1e3))}function X2e(e=!0){const[t,n]=m.useState(void 0),[a,s]=m.useState(()=>$2e()),[o,r]=m.useState(!1),[c,l]=m.useState(null),u=m.useRef(new Set),h=m.useRef([]),[p,f]=m.useState(null),b=m.useRef(!0);m.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const v=m.useCallback(z=>{if(!b.current)return;const I=z==null?void 0:z.job;if(I){if(u.current.add(I.id),I.phase==="downloading"){const _=Date.now();h.current=[...h.current.filter(D=>_-D.at<=K2e),{at:_,received:I.received}],f(Z2e(h.current))}}else h.current=[],f(null);n(z)},[]),w=m.useCallback(async()=>{const z=await D2e();return v(z),z},[v]);m.useEffect(()=>{e&&w()},[e,w]);const T=!!t&&(!!t.job||t.elsewhere),y=!!(t!=null&&t.job)&&t.job.id===a;m.useEffect(()=>{if(!e||!T)return;const z=setTimeout(()=>{w()},y?G2e:V2e);return()=>clearTimeout(z)},[e,T,y,t,w]);const x=m.useCallback(async z=>{r(!0),l(null);const I=await z();b.current&&(I.ok&&I.id?(u.current.add(I.id),s(I.id),J2e(I.id)):I.ok||l(I.code),await w(),b.current&&r(!1))},[w]),C=m.useCallback(()=>x(()=>F2e()),[x]),A=m.useCallback(z=>x(()=>W2e(z)),[x]),E=m.useCallback(async()=>{r(!0),await B2e(),await w(),b.current&&r(!1)},[w]),R=m.useCallback(async()=>{r(!0),l(null);const z=await U2e();return!z.ok&&b.current&&l(z.code),await w(),b.current&&r(!1),z.ok},[w]);return{status:t,mine:a,watched:u.current,speed:p,pending:o,refused:c,refresh:w,install:C,installFile:A,cancel:E,remove:R}}function S7(e){return e!=null&&x7({enabled:e.on,supported:e.supported},e.phone===!0)&&e.failed!==!0}function Q2e(e,t){return e("settings.terminal.short")}function eBe(e,t=!1){return e(t?"settings.terminal.offDetailsWindows":"settings.terminal.offDetails")}function tBe(){var b;const e=se(),t=X2e(!0),[n,a]=m.useState(!1),s=t.status;if(!s||!s.supported)return null;const o=H2e(s.platform),r=s.job,c=s.blocked===null,l=!!s.installed&&!!s.pinned&&C7(s.installed.version,s.pinned),u=((b=s.last)==null?void 0:b.outcome)==="failed"&&t.watched.has(s.last.id);let h,p=null,f=null;if(r){const v=r.id===t.mine;if(h=v?s.installed&&s.pinned?e("settings.terminal.engine.updating",{from:s.installed.version,to:s.pinned}):e("settings.terminal.engine.installing",{version:s.pinned??""}):e("settings.terminal.engine.elsewhere"),r.phase==="downloading"){const w=r.total?Math.min(1,r.received/r.total):null,T=r.total?e("board.stage.setupProgress",{received:ab(r.received),total:ab(r.total)}):e("board.stage.setupReceived",{received:ab(r.received)});f=i.jsxs("span",{className:"settings-engine-progress",children:[i.jsx("span",{className:"ts-setup-bar ts-eng-bar",role:"progressbar","aria-label":h,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":w==null?void 0:Math.round(w*100),"aria-valuetext":T,"data-unknown":w==null||void 0,children:i.jsx("i",{className:"ts-setup-fill",style:w==null?void 0:{transform:`scaleX(${w})`}})}),i.jsx("span",{className:"ts-eng-line",children:T})]}),v&&(p=i.jsx("button",{type:"button",className:"btn","aria-busy":t.pending||void 0,onClick:()=>{t.cancel()},children:e("common.cancel")}))}}else s.elsewhere?h=e("settings.terminal.engine.elsewhere"):s.installed?(h=e("settings.terminal.engine.verified",{version:s.installed.version,platform:o}),p=i.jsx("button",{type:"button",className:"btn","aria-busy":t.pending||void 0,onClick:()=>{if(l&&c){t.install();return}t.refresh().then(()=>{a(!0),setTimeout(()=>a(!1),2e3)})},children:e(n?"settings.terminal.engine.upToDate":"settings.terminal.engine.checkUpdate")})):s.blocked==="no-keys"||s.blocked==="not-published"?h=e("settings.terminal.engine.notAvailable"):(h=e("settings.terminal.engine.notInstalled"),c&&(p=i.jsx("button",{type:"button",className:"btn primary","aria-busy":t.pending||void 0,onClick:()=>{t.install()},children:e("settings.terminal.engine.install")})));return u&&!r&&(h=`${h} ${e("settings.terminal.engine.failed")}`),i.jsxs(i.Fragment,{children:[i.jsx(Ot,{as:"div",settingId:"terminal-engine",name:e("settings.terminal.engine.name"),nameId:"settings-engine-label",note:h,noteId:"settings-engine-note",control:p,children:f}),s.installed&&!r&&i.jsx(Ot,{as:"div",settingId:"terminal-engine-remove",name:e("settings.terminal.engine.removeName"),note:e("settings.terminal.engine.removeNote",{size:ab(s.installed.bytes)}),control:i.jsx("button",{type:"button",className:"btn","aria-busy":t.pending||void 0,onClick:()=>{t.remove()},children:e("settings.terminal.engine.remove")})})]})}function nBe({terminal:e}){const t=se(),n=e.supported===!1&&!e.on,a=e.supported===!1;return i.jsxs(gn,{id:"settings-experimental-caption",title:t("settings.experimental.group"),list:!1,children:[i.jsxs("div",{className:"settings-list",children:[i.jsx(Ot,{settingId:"terminal",name:t("settings.search.commandPanel"),nameId:"settings-terminal-label",note:Q2e(t),noteId:"settings-terminal-note",details:a?void 0:eBe(t,e.windows),control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e.on,"aria-labelledby":"settings-terminal-label","aria-describedby":a?"settings-terminal-note settings-terminal-unavailable":"settings-terminal-note",disabled:n,onClick:e.toggle,children:i.jsx("span",{className:"switch-knob"})})}),e.on&&!a&&i.jsx(tBe,{})]}),a&&i.jsx("p",{className:"settings-note",id:"settings-terminal-unavailable",children:t("settings.terminal.unsupported")})]})}const OW="settings-search-field",T7="settings-search-results",CE=e=>`settings-result-${e}`;function aBe({inputRef:e,query:t,onQuery:n,results:a,active:s,onActive:o,onOpen:r}){const c=se(),l=t.trim()!=="",u=l&&a.length>0,h=p=>{if(p.nativeEvent.isComposing)return;const f=Ife(p.key,t,l?a.length:0,s);f.kind!=="pass"&&(p.preventDefault(),f.kind==="move"?o(f.index):f.kind==="open"?r(a[f.index]):(p.stopPropagation(),n("")))};return i.jsxs("div",{className:"settings-search",children:[i.jsx("label",{className:"vis-hidden",htmlFor:OW,children:c("settings.search.label")}),i.jsx(Ze,{name:"search",className:"settings-search-glyph"}),i.jsx("input",{ref:e,id:OW,type:"search",className:"settings-filter-field settings-search-field",placeholder:c("settings.search.label"),autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":u,"aria-controls":u?T7:void 0,"aria-activedescendant":u?CE(Math.min(s,a.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:p=>n(p.target.value),onKeyDown:h})]})}function sBe({query:e,results:t,active:n,onOpen:a}){const s=se(),o=JG(t.length,e);return m.useEffect(()=>{var r,c;(c=(r=document.getElementById(CE(n)))==null?void 0:r.scrollIntoView)==null||c.call(r,{block:"nearest"})},[n]),i.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[i.jsx("div",{className:"settings-pane-head",children:i.jsxs("div",{className:"settings-pane-heading",children:[i.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:s("settings.search.title")}),i.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:o})]})}),t.length>0&&i.jsx("div",{className:"settings-group",children:i.jsx("div",{className:"settings-list",id:T7,role:"listbox","aria-label":s("settings.search.results"),children:t.map((r,c)=>i.jsxs("button",{type:"button",role:"option",id:CE(c),className:"settings-result",tabIndex:-1,"aria-selected":c===n,"aria-label":Lfe(r),"data-highlighted":c===n,onMouseDown:l=>l.preventDefault(),onClick:()=>a(r),children:[i.jsx(eR,{section:r.section}),i.jsxs("span",{className:"settings-result-text",children:[i.jsx("span",{className:"settings-result-name",children:r.label}),i.jsx("span",{className:"settings-result-place",children:Q1(r)})]})]},r.id))})})]})}function iBe({query:e,count:t}){return i.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?JG(t,e):""})}const oBe=1500,rBe=3e3,cBe=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function lBe(e){if(e.matches(Gb)&&!e.disabled)return e;const t=e.querySelector('input[type="radio"]:checked, [role="radio"][aria-checked="true"]');if(t)return t;const n=Array.from(e.querySelectorAll(Gb)).filter(a=>i5({disabled:a.disabled,tabIndex:a.tabIndex,rendered:cBe(a)}));return n.find(a=>a.closest(".settings-list")!=null)??n[0]??null}function dBe(e,t,n){const[a,s]=m.useState(null),o=m.useRef(void 0),r=m.useRef(null);return m.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=r.current)==null||c.removeAttribute("data-jumped")},[]),m.useEffect(()=>{const c=e.current;if(!a||!t||!c)return;const l=()=>c.querySelector(`[data-setting="${CSS.escape(a)}"]`),u=b=>{var w,T;s(null);const v=b.offsetHeight>c.clientHeight-48;b.scrollIntoView({block:v?"start":"center"}),(w=lBe(b))==null||w.focus({preventScroll:!0}),window.clearTimeout(o.current),(T=r.current)==null||T.removeAttribute("data-jumped"),b.offsetWidth,b.setAttribute("data-jumped",""),r.current=b,o.current=window.setTimeout(()=>{b.removeAttribute("data-jumped"),r.current===b&&(r.current=null)},oBe)},h=l();if(h){u(h);return}const p=new MutationObserver(()=>{const b=l();b&&(p.disconnect(),window.clearTimeout(f),u(b))});p.observe(c,{childList:!0,subtree:!0});const f=window.setTimeout(()=>{p.disconnect(),s(null)},rBe);return()=>{p.disconnect(),window.clearTimeout(f)}},[e,a,t,n]),s}const uBe=m.lazy(()=>Xs(()=>import("./AccountSection-crq1VjX0.js"),__vite__mapDeps([6,5])));function hBe({section:e,landOn:t,onSection:n,onClose:a,providers:s,sound:o,tones:r,customTones:c,notify:l,appearance:u,versionCheck:h,desktopUpdate:p,restart:f,doors:b,terminal:v,account:w}){const T=(w==null?void 0:w.on)===!0||(w==null?void 0:w.vetoed)===!0,y=se(),x=m.useRef(null),C=m.useCallback(Ie=>{x.current=Ie},[]);function A(Ie,ct=!1){x.current?(X(""),x.current(Ie,ct),requestAnimationFrame(()=>{var Nt,Le;return(Le=(Nt=R.current)==null?void 0:Nt.scrollIntoView)==null?void 0:Le.call(Nt,{block:"nearest",inline:"nearest"})})):Ie()}const E=()=>A(a,!0),R=m.useRef(null),z=Zt(E,{focusRef:R}),I=tn(()=>A(a)),_=m.useRef([]),D=Xg(),L=Ez(D),P=Eme(L,e,s.claude),O=Ame({account:T,drawn:P}),j=jme(e,O),M=Ws("(max-width: 640px)"),[F,U]=m.useState(""),[H,$]=m.useState(0),Y=m.useRef(null),W=m.useRef(null),G=F.trim()!=="",Q=m.useMemo(()=>Mfe(F,$G(s.claude,L,Qg(D))),[F,s.claude,L,D,y]),J=dBe(W,!G,e),X=Ie=>{U(Ie),$(0)};m.useEffect(()=>{t&&J(t)},[t,J]);const te=Ie=>{A(()=>{X(""),n(Ie),requestAnimationFrame(()=>{var ct;return(ct=document.getElementById(`settings-tab-${Ie}`))==null?void 0:ct.focus()})})},K=Ie=>{A(()=>{X(""),n(Ie.section),gv(Ie)||J(Ie.id)})};m.useEffect(()=>{const Ie=ct=>{var Ht,Mt;if(!Pme(ct))return;const Nt=z.current,Le=ct.target;!Nt||!(Le===document.body||Le===document.documentElement||Le&&Nt.contains(Le))||(ct.preventDefault(),(Ht=Y.current)==null||Ht.focus(),(Mt=Y.current)==null||Mt.select())};return window.addEventListener("keydown",Ie),()=>window.removeEventListener("keydown",Ie)},[z]),m.useEffect(()=>{var Ie,ct,Nt,Le;Rme((Ie=document.activeElement)==null?void 0:Ie.id,e)&&((ct=R.current)==null||ct.focus()),(Le=(Nt=R.current)==null?void 0:Nt.scrollIntoView)==null||Le.call(Nt,{block:"nearest",inline:"nearest"})},[e]);const V=SFe();m.useEffect(()=>{Ai(null)},[e]),m.useEffect(()=>()=>Ai(null),[]);const{theme:ee,setTheme:de,characterEnabled:he,setCharacterEnabled:me,character:be,setCharacter:ie}=u,ne=sa(),ke=Ie=>{const ct=Fu(Ie,j,O.length,"vertical");ct.kind!=="pass"&&(Ie.preventDefault(),A(()=>{var Nt;X(""),n(O[ct.index].id),(Nt=_.current[ct.index])==null||Nt.focus()}))},Se=Ie=>{Ie.key===" "&&Ie.stopPropagation()},{soundOn:ve,toggleSound:xe}=o,{tonePrefs:Ee,previewTone:Ge,changeTone:Qe}=r,{customSelections:Je,customAssets:He,clearCustomOnly:_e,selectCustomTone:le,importNotificationAudio:Re,createNotificationVoice:ge,renameCustomAsset:Pe,deleteCustomAsset:Fe,previewCustomAsset:Ve}=c,{notifyPermission:ot,notifyOn:ce,notifyVetoed:Ce,toggleNotify:Ke,notifySupported:Oe,askForNotifications:at,accountNotify:ut,toggleAccountNotify:vt}=l,qe=O[j].id,dt=(()=>{switch(qe){case"radar":return i.jsx(KFe,{onOpen:b.radar});case"claude":return i.jsx(d2e,{});case"appearance":return i.jsxs(i.Fragment,{children:[i.jsx(k2e,{theme:ee,onTheme:de,singleKeys:ne}),i.jsx(O2e,{characterEnabled:he,character:be,onCharacter:ie,onToggleCharacter:()=>me(Ie=>!Ie)})]});case"reading":return i.jsx(x2e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity});case"keyboard":return i.jsx(qFe,{singleKeys:ne,onToggleSingleKeys:()=>O5(!ne),workspace:S7(v)});case"notifications":return i.jsx(_Fe,{notifyOn:ce,onToggleNotify:Ke,notifyVetoed:Ce,notifyPermission:Oe?ot:"unsupported",onAskNotify:at,accountNotify:ut,onToggleAccountNotify:vt});case"sounds":return i.jsx(VFe,{soundOn:ve===!0,onToggleSound:xe,prefs:Ee,claudeHere:s.claude,onLevel:(Ie,ct)=>Qe(Ie,{level:ct}),onFigure:(Ie,ct)=>Qe(Ie,{figure:ct}),onPreview:Ie=>Ge(Ie),customAssets:He,customSelections:Je,onBuiltInSelected:_e,onCustomSelected:le,onImportCustom:Re,onCreateVoice:ge,onRenameCustom:Pe,onPreviewCustom:Ve,onDeleteCustom:Fe});case"integrations":return i.jsx(f2e,{onBeforeLeaveChange:C});case"data":return i.jsx(h2e,{});case"account":return i.jsx(m.Suspense,{fallback:null,children:i.jsx(uBe,{vetoed:(w==null?void 0:w.on)!==!0})});case"about":return i.jsx(R2e,{version:h.version,notice:h.notice,readyAppUpdate:p.readyAppUpdate,updateRestarting:p.desktopUpdateRestarting,updateFailure:p.desktopUpdateFailure,onUpdateRestart:Ie=>{p.askDesktopUpdateRestart(Ie)},doors:b});default:return i.jsxs(i.Fragment,{children:[i.jsx(yFe,{}),i.jsxs(NFe,{children:[s.claude&&i.jsx(EW,{provider:"Claude"}),i.jsx(EW,{provider:"Codex"}),s.claude&&i.jsx(TFe,{})]}),i.jsx(L2e,{autoRestart:f.autoRestart,onToggleAutoRestart:f.toggleAutoRestart,version:h.version}),i.jsx(EFe,{claudeHere:s.claude,codexHere:s.codex,singleKeys:ne,doors:b}),v&&i.jsx(nBe,{terminal:v})]})}})(),et=e==="reading"?i.jsx(y2e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity}):e==="integrations"&&D.connections!==null?i.jsx("span",{className:"ig-total",children:y("settings.savedConnections",{count:D.connections.length})}):null;return i.jsxs(dn,{scrim:I,dialogRef:z,id:"settings",className:"settings-modal",labelledBy:"settings-title",onKeyDown:Se,children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"settings-title",className:"modal-tool-name",children:y("settings.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>A(a),"aria-label":y("settings.close"),title:y("settings.closeTip"),children:"×"})})]}),i.jsxs("div",{className:"settings-body",children:[i.jsxs("div",{className:"settings-side",children:[i.jsx(aBe,{inputRef:Y,query:F,onQuery:X,results:Q,active:H,onActive:$,onOpen:K}),i.jsx(iBe,{query:F,count:Q.length}),i.jsx("div",{className:"settings-nav",role:"tablist","aria-label":y("settings.sections"),"aria-orientation":M?"horizontal":"vertical",onKeyDown:ke,children:O.map((Ie,ct)=>i.jsx("button",{ref:Nt=>{_.current[ct]=Nt,Ie.id===e&&(R.current=Nt)},type:"button",role:"tab",id:`settings-tab-${Ie.id}`,className:"settings-tab","aria-selected":Ie.id===e,"aria-controls":"settings-pane",tabIndex:Ie.id===e?0:-1,onClick:()=>te(Ie.id),children:i.jsx("span",{className:"settings-tab-label",children:Ie.label})},Ie.id))})]}),i.jsxs("div",{ref:W,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:G||void 0,children:[i.jsxs("div",{className:"settings-pane-head",children:[i.jsxs("div",{className:"settings-pane-heading",children:[i.jsx("h2",{className:"settings-pane-title",children:O[j].label}),i.jsx("p",{className:"settings-pane-note",children:O[j].note})]}),et]}),V&&i.jsx(jR,{banner:!0,line:V.line,onDismiss:()=>Ai(null),onAnswer:CFe},V.serial),dt]},e),G&&i.jsx(sBe,{query:F,results:Q,active:H,onOpen:K})]})]})}function pBe({tool:e,cwd:t,onClose:n}){const a=se(),s=Zt(n),o=tn(n),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",c=m.useRef({of:null});c.current.of!==e&&(c.current={of:e}),e.input!==void 0&&(c.current.input=e.input),e.response!==void 0&&(c.current.response=e.response);const l=c.current.input??e.inputPreview,u=c.current.response??e.errorPreview,h=e.trimmed===!0&&c.current.input===void 0&&c.current.response===void 0,p=m.useMemo(()=>{const f=bje(e.name,l,u);return{input:f.input.map((b,v)=>i.jsx(MW,{block:b,cwd:t},v)),response:f.response.map((b,v)=>i.jsx(MW,{block:b,cwd:t},v)),copyInput:KM(e.name,"input",l),copyResponse:KM(e.name,"response",u)}},[e.name,l,u,t]);return i.jsxs(dn,{scrim:o,dialogRef:s,className:"tool-modal",labelledBy:"tool-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),i.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",children:Sce(e,a("insights.tool.inflight"))}),i.jsx(Za,{onClick:n,label:a("insights.audit.closeEsc")})]})]}),i.jsxs("section",{className:"modal-body",children:[h&&i.jsx("div",{className:"modal-section",children:i.jsx("p",{className:"modal-note",children:a("insights.tool.released")})}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("div",{className:"tm-head",children:[i.jsx("h4",{children:a("insights.cost.inputTitle")}),i.jsx(IW,{text:p.copyInput,what:"input"})]}),p.input]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("div",{className:"tm-head",children:[i.jsxs("h4",{children:[a("insights.tool.response"),r==="err"&&i.jsx("span",{className:"err-tag",children:a("insights.tool.error")})]}),e.endedAt!=null&&i.jsx(IW,{text:p.copyResponse,what:"response"})]}),e.endedAt==null?i.jsx("pre",{children:a("insights.tool.waiting")}):p.response]})]})]})}const gBe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function MW({block:e,cwd:t}){const[n,a]=m.useState(!1);if(e.inline)return i.jsxs("p",{className:"tm-inline",children:[e.label&&i.jsx("span",{className:"tm-label",children:e.label}),e.path?i.jsx(zg,{path:e.text,cwd:t}):i.jsx("code",{children:e.text})]});const s=m.useMemo(()=>dje(e),[e]),{shown:o}=zK(s,n),r=uje(s,n);return i.jsxs("div",{className:"tm-block",children:[e.label&&i.jsx("span",{className:"tm-label",children:e.label}),i.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?o.map((c,l)=>i.jsxs("span",{className:c.tone?gBe[c.tone]:void 0,children:[c.text,l<o.length-1?`
|
|
350
|
+
Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},zz="agent-dag.releaseNotesSeen";function SW(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function lc(e,t){const n=SW(e),a=SW(t);for(let s=0;s<Math.max(n.length,a.length);s++){const o=(n[s]??0)-(a[s]??0);if(o!==0)return o<0?-1:1}return 0}function vo(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function ODe(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function MDe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,a]of Object.entries(e)){if(!vo(n)||!Array.isArray(a))continue;const s=a.filter(ODe).map(c=>({title:c.title,body:c.body,...typeof c.details=="string"&&c.details.trim()?{details:c.details}:{},...c.priority==="highlight"||c.priority==="required"?{priority:c.priority}:{},...typeof c.notice=="string"&&c.notice.trim()?{notice:c.notice}:{},...typeof c.notice=="string"&&c.notice.trim()&&typeof c.noticeLabel=="string"&&c.noticeLabel.trim()&&c.noticeLabel.length<=32?{noticeLabel:c.noticeLabel}:{},...c.icon==="plans"||c.icon==="accounts"||c.icon==="skills"?{icon:c.icon}:{}})),o=e["//summaries"],r=o&&typeof o=="object"&&Object.hasOwn(o,n)?o[n]:void 0;s.length&&t.push({version:n,notes:s,...typeof r=="string"&&r.trim()?{summary:r}:{}})}return t.sort((n,a)=>lc(a.version,n.version))}function IDe(e){const t=e.filter(o=>o.priority==="highlight").slice(0,3),n=t.length>0,a=e.filter(o=>!t.includes(o)&&(!n||o.priority==="required"||o.priority==="highlight"||!!o.notice)),s=e.filter(o=>!t.includes(o)&&!a.includes(o));return{highlights:t,visible:a,more:s}}function DDe(e,t,n){const[a,...s]=e;if(!t)return{latest:vo(n)?e.find(c=>lc(c.version,n)===0):a,visiblePrevious:[],history:[]};const o=[],r=[];for(const c of s){const l=c.notes.some(p=>p.priority==="highlight"||p.priority==="required"||!!p.notice),u=c.notes.filter(p=>!l||p.priority==="required"||!!p.notice);u.length&&o.push({version:c.version,notes:u});const h=c.notes.filter(p=>!u.includes(p));h.length&&r.push({...c,notes:h})}return{latest:a,visiblePrevious:o,history:r}}const TW=MDe(PDe);function l7(e,t,n){return e.filter(a=>lc(a.version,n)<=0&&(t===null||lc(a.version,t)>0))}function FDe(e,t){return e.filter(n=>lc(n.version,t)===0)}const BDe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function d7(e){const t=BDe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function UDe(e){if(!e)return null;let t=null;try{t=e.getItem(zz)}catch{return null}return vo(t)?t:null}function WDe(e){if(!e)return!1;try{return e.getItem(zz),!0}catch{return!1}}function HDe(e,t){if(!e)return!1;try{return e.setItem(zz,t),!0}catch{return!1}}const GDe="agent-dag.tourSeen",fE="agent-dag.tourEdition",bg=2;function qz(e){const t=typeof e=="number"?e:typeof e=="string"&&/^\d{1,4}$/.test(e)?Number(e):0;return Number.isInteger(t)&&t>0?t:0}function VDe(e){if(!e)return!1;try{return qz(e.getItem(fE))>=bg}catch{return!1}}function KDe(e){if(!e)return!1;try{return e.setItem(GDe,"1"),qz(e.getItem(fE))<bg&&e.setItem(fE,String(bg)),!0}catch{return!1}}function $De({tourSeen:e,decision:t,phone:n=!1}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};const a=!e&&!n;if(t.reason==="welcome"||t.reason==="first-run")return{tour:a,notes:"none"};const s=t.show.length>0;return a?{tour:!0,notes:s?"after":"none"}:{tour:!1,notes:s?"now":"none"}}function JDe({stored:e,running:t,notes:n,remembers:a=!0}){if(!vo(t))return{show:[],record:null,reason:"no-version"};if(!vo(e)){if(!a)return{show:[],record:t,reason:"cannot-remember"};const r=FDe(n,t);return r.length?{show:r,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=lc(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=l7(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function YDe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const a=e.indexOf("`",n+1);if(a<0)break;n=a+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function Vp(e,t=!0){const n=[];let a="";const s=()=>{a&&(n.push({kind:"text",text:a}),a="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const r=e.indexOf("`",o+1);if(r>o+1){s(),n.push({kind:"code",text:e.slice(o+1,r)}),o=r+1;continue}}else if(t&&e.startsWith("**",o)){const r=YDe(e,o);if(r>0){s(),n.push({kind:"bold",kids:Vp(e.slice(o+2,r),!1)}),o=r+2;continue}}a+=e[o],o+=1}return s(),n}function lr(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function ZDe(e){const t=Math.max(0,Math.round(e/1e3));if(t<5)return S("shell.ago.now");if(t<60)return S("shell.ago.sec",{n:t});const n=Math.round(t/60);return n<60?S("shell.ago.min",{n}):S("shell.ago.hrSpelled",{n:Math.round(n/60)})}const XDe=()=>S("shell.update.checkWhy"),NW=()=>S("shell.update.checking"),QDe=()=>S("shell.update.npmUnreachable"),eFe=()=>S("shell.update.deckUnreachable"),tFe=()=>S(aFe),nFe=()=>S("shell.update.pendingRetry"),aFe="shell.update.checksOff";function sFe(e,t,n,a){const s=a?t.npx:n?On(t,n):void 0;return s?S("shell.update.outBlocked",{to:e,reason:s}):S("shell.update.outRun",{to:e})}const hs=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),tl=e=>hs(e,{tone:"note"});function AW(e,t){return ZDe(t-e)}function iFe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?tl(S("shell.update.appReady",{version:n.version??""})):(n==null?void 0:n.status)==="checking"?tl(S("shell.update.appChecking")):(n==null?void 0:n.status)==="downloading"?tl(n.version?S("shell.update.appDownloadingVersion",{version:n.version}):S("shell.update.appDownloading")):(n==null?void 0:n.status)==="current"?tl(S("shell.update.appCurrent",{version:e.version??t})):(n==null?void 0:n.status)==="error"?tl(S("shell.update.appError")):tl(S("shell.update.appIdle"))}function oFe(e,t,n){var r;const a=e.version;if((a==null?void 0:a.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return hs(S("shell.update.installed",{to:t}));const c=e.upgradeState==="running",l=S("shell.update.installWhy",{command:((r=a.upgrade)==null?void 0:r.command)??a.command});return hs(c?S("shell.update.installing",{to:t}):S("shell.update.out",{to:t}),{action:{kind:"install",label:S("shell.update.now"),busy:c,why:l}})}if((a==null?void 0:a.upgradeMode)==="npx"&&a.canRestart){const c=e.upgradeState==="failed";return hs(c?S("shell.update.npxFailedBack",{to:t,running:e.running}):S("shell.update.out",{to:t}),{action:{kind:"npx",label:S(c?"shell.update.retry":"shell.update.andRestart"),busy:e.restarting,why:S("shell.update.npxWhy",{command:a.command})}})}const s=e.upgradeState==="failed"?S("shell.update.installFailed",{to:t}):sFe(t,n,a==null?void 0:a.upgradeBlocked,(a==null?void 0:a.upgradeMode)==="npx"),o=(a==null?void 0:a.command)??null;return hs(s,{command:o,action:o?{kind:"copy",label:e.copied?S("shell.copied"):S("shell.copy"),busy:!1}:null})}function rFe(e){const t=e.version;if(e.unreachable)return hs(eFe(),{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return hs(QDe(),{tone:"warn",age:e.answered?null:S("shell.update.lastTried",{ago:AW(n,e.now)})});const a=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(a)return hs(S("shell.update.pending",{pending:a,retry:nFe()}));const s=t!=null&&t.checkedAt?AW(t.checkedAt,e.now):null;if((t==null?void 0:t.checkedAt)&&e.now>=t.checkedAt&&e.now-t.checkedAt<=60*6e4&&(t!=null&&t.latest)&&vo(t.latest)&&vo(e.running)){const r=lc(t.latest,e.running),c=r===0?S("shell.update.latest",{version:e.running}):r<0?S("shell.update.ahead",{running:e.running,latest:t.latest}):S("shell.update.out",{to:t.latest});return hs(c,{age:s?S("shell.update.checkedAgo",{ago:s}):null})}return hs(S(s?"shell.update.mayHaveChanged":"shell.update.noneYet"),{age:s?S("shell.update.lastChecked",{ago:s}):null})}function cFe(e,t){var s,o;const n=e.version;if((s=e.app)!=null&&s.inApp&&(n!=null&&n.checkDisabled)){const r=iFe(e.app,e.running);return r&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?hs(S("shell.update.appRefused"),{tone:"warn"}):e.checking?hs(NW()):r}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:tl(tFe())};const a=(n==null?void 0:n.notice)??null;if((a==null?void 0:a.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:oFe(e,a.to,t)};if((a==null?void 0:a.kind)==="restart"){const r=n!=null&&n.canRestart?S("shell.update.restartDeck",{to:a.to}):S("shell.update.restartApp",{to:a.to});return{canCheck:!0,checking:e.checking,line:hs(r)}}return e.checking?{canCheck:!0,checking:!0,line:hs(NW())}:{canCheck:!0,checking:!1,line:rFe(e)}}const u7=450;async function lFe(e,t=n=>new Promise(a=>setTimeout(a,n))){const[n]=await Promise.all([e(!0),t(u7)]);return n?"answered":"unreachable"}async function dFe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,u7))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const uFe=()=>S("shell.notes.restartWhy");function hFe(e){var z,I,_;Es();const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=xo(3e4),[a,s]=m.useState(!1),o=m.useRef(!1),[r,c]=m.useState(!1),[l,u]=m.useState(!1),h=m.useRef(t);if(m.useEffect(()=>{h.current&&!t&&u(!0),h.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:f,restart:b,desktopUpdate:v,running:w,onHandOff:T}=e,y=cFe({version:p.version,running:w,checking:a||t,answered:l,unreachable:r,now:Math.max(n,Date.now()),upgradeState:f.upgradeState,copied:f.cmdCopied,restarting:b.restarting,app:{inApp:lr(),update:v.appUpdate,version:D8(),menu:B8()}},SMe);if(!y)return null;const x=lr()&&((z=p.version)==null?void 0:z.checkDisabled),C=x?S("shell.update.checkWhyApp"):XDe(),A=async()=>{var L;if(!$a(o.current||t)||x&&((L=v.appUpdate)==null?void 0:L.status)==="checking")return;o.current=!0,s(!0);const D=x?await dFe():await lFe(p.loadVersion);o.current=!1,s(!1),c(D==="unreachable"),u(!0)},E=D=>{if(D.kind==="copy")return void f.copyCommand();T(),p.showNotice(),D.kind==="install"?f.startUpgrade():b.askRestart({upgrade:!0})},R=y.line.tone==="warn"||!!y.line.action||!!((I=p.version)!=null&&I.notice)||((_=v.appUpdate)==null?void 0:_.status)==="downloading";return{state:y,check:A,act:E,checkWhy:C,needsAttention:R}}function pFe({update:e}){const t=qg("above","dialog"),n=m.useId();return Es(),i.jsxs("div",{className:"rn-status-row",children:[e?i.jsx(gFe,{line:e.state.line,onAct:e.act,bindHint:t.bind,whyId:`${n}-action`,announce:!1}):i.jsx("p",{className:"rn-update-line",children:i.jsx("span",{role:"status",children:S("shell.notes.statusUnavailable")})}),t.node]})}function gFe({line:e,onAct:t,bindHint:n,whyId:a,announce:s=!0}){const{action:o}=e,r=o&&i.jsx(mFe,{action:o,onAct:t,bindHint:n,whyId:a});return i.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[i.jsx("span",{className:"rn-update-what",role:s?"status":void 0,children:e.said}),e.age&&i.jsx("span",{className:"rn-update-age",children:e.age}),e.command?i.jsxs("span",{className:"rn-update-cmd",children:[i.jsx("code",{className:"rn-code",children:e.command}),r]}):r]})}function mFe({action:e,onAct:t,bindHint:n,whyId:a}){const s=e.kind==="copy"?null:e.why;return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:s?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":s&&a?a:void 0,...s&&n?n({label:s}):{},children:e.label}),s&&a&&i.jsx("span",{hidden:!0,id:a,children:s})]})}function fFe({entries:e,since:t,running:n,firstRun:a,onClose:s,onTour:o,updateVersion:r,updateBusy:c,onUpdateRestart:l,updateFailure:u,onRestart:h,updateCheck:p}){var M,F,U;const f=se(),b=uFe(),v=Zt(s),w=m.useRef(null),T=tn(s),y=m.useId(),[x,C]=m.useState(null),A=hFe(p),E=((M=A==null?void 0:A.state.line.action)==null?void 0:M.kind)==="install"||((F=A==null?void 0:A.state.line.action)==null?void 0:F.kind)==="npx",R=h&&!r&&!E,{latest:z,visiblePrevious:I,history:_}=DDe(e,t!==null,n),D=`${y}-history`,L=!!R||!!(A!=null&&A.state.canCheck)&&!r;m.useEffect(()=>{var H;!L&&x&&(C(null),document.activeElement===document.body&&((H=w.current)==null||H.focus()))},[L,x]);const P=vo(n)?n:((U=e[0])==null?void 0:U.version)??"",O=a&&n?f("shell.notes.contextFirst",{version:n}):t?f("shell.notes.contextSince",{since:t}):null,j=I.some(H=>H.notes.some($=>!$.priority&&!$.notice));return i.jsxs(dn,{scrim:T,dialogRef:v,className:"release-notes",id:`${y}-dialog`,labelledBy:"release-notes-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:f("shell.notes.title")}),P&&i.jsx("span",{className:"modal-tool-id rn-pill",children:P})]}),i.jsxs("div",{className:"modal-actions",children:[L&&i.jsx("button",{id:`${y}-options`,type:"button",className:"glyph-btn","aria-label":f("shell.notes.moreOptions"),"aria-haspopup":"menu","aria-expanded":x!==null,"aria-controls":x?`${y}-menu`:void 0,onClick:()=>C(x?null:"first"),onKeyDown:H=>{(H.key==="ArrowDown"||H.key==="ArrowUp")&&(H.preventDefault(),C(H.key==="ArrowUp"?"last":"first"))},children:i.jsxs("svg",{className:"glyph",viewBox:"0 0 14 14",width:"14",height:"14",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"3",cy:"7",r:"1"}),i.jsx("circle",{cx:"7",cy:"7",r:"1"}),i.jsx("circle",{cx:"11",cy:"7",r:"1"})]})}),i.jsx("button",{ref:w,type:"button",className:"glyph-btn",onClick:s,"aria-label":f("shell.closeEsc"),title:f("shell.closeEsc"),children:"×"})]})]}),i.jsx("span",{className:"rn-live-status",role:"status",children:r?f("shell.notes.downloaded",{version:r}):A==null?void 0:A.state.line.said}),i.jsxs("section",{className:"modal-body",role:"region","aria-label":f("shell.notes.region"),tabIndex:0,children:[r?i.jsxs("div",{className:"rn-ready",children:[i.jsx("p",{children:f("shell.notes.downloaded",{version:r})}),i.jsx("p",{className:"rn-update-said",role:"status",children:u})]}):i.jsxs(i.Fragment,{children:[(A==null?void 0:A.needsAttention)&&i.jsx(pFe,{update:A}),i.jsx("p",{className:"rn-update-said",role:"status",children:u})]}),O&&i.jsx("p",{className:"rn-context",children:O}),!(z!=null&&z.notes.length)&&!I.length&&i.jsx("p",{className:"rn-empty",children:f("shell.notes.empty")}),z&&i.jsx(XA,{entry:z,showVersion:t!==null&&e.length>1},z.version),I.length>0&&i.jsxs("section",{className:"rn-upgrade-history","aria-label":f("shell.notes.earlierLabel"),children:[i.jsx("h2",{className:"rn-group-title",children:f("shell.notes.earlierTitle")}),j&&i.jsx("p",{className:"rn-context",children:f("shell.notes.legacy")}),I.map(H=>i.jsx(XA,{entry:H,showVersion:!0},H.version))]}),_.length>0&&i.jsxs("details",{className:"rn-history",children:[i.jsx("summary",{"aria-controls":D,children:f("shell.notes.otherSince",{since:t??""})}),i.jsx("div",{id:D,children:_.map(H=>i.jsx(XA,{entry:H,showVersion:!0},H.version))})]}),i.jsx("p",{className:"rn-history-link",children:i.jsxs("a",{href:"https://ccdeck.dev/changelog/",target:"_blank",rel:"noopener noreferrer","aria-label":f("shell.notes.historyLabel"),children:[f("shell.notes.history")," ",i.jsx(dR,{})]})})]}),i.jsxs("footer",{className:"rn-footer",children:[i.jsx("div",{className:"rn-footer-links",children:o&&!r&&i.jsx("button",{className:"btn rn-tour",type:"button",onClick:o,children:f("shell.notes.tour")})}),r&&l?i.jsx("button",{className:"btn primary",type:"button",onClick:l,"aria-busy":c||void 0,children:c?f("shell.notes.restarting"):Rk()}):i.jsx("button",{className:"btn primary",type:"button",onClick:s,children:f("shell.done")})]}),x&&L&&i.jsxs(Rs,{anchorId:`${y}-options`,portalRootId:`${y}-dialog`,id:`${y}-menu`,role:"menu",labelledBy:`${y}-options`,start:x,className:"ap-pop rn-options-menu",onClose:()=>C(null),children:[A&&i.jsxs("p",{className:"rn-menu-status",id:`${y}-check-status`,children:[A.state.line.said,A.state.line.age&&i.jsx("span",{children:A.state.line.age})]}),(A==null?void 0:A.state.canCheck)&&i.jsxs("button",{type:"button",className:"ap-menu-item rn-act",role:"menuitem",title:A.checkWhy,"aria-describedby":`${y}-check-status`,"aria-busy":A.state.checking||void 0,onClick:()=>void A.check(),children:[i.jsx(hge,{}),f("shell.notes.check")]}),(A==null?void 0:A.state.canCheck)&&R&&i.jsx("div",{className:"rn-menu-separator",role:"separator"}),R&&i.jsxs("button",{type:"button",className:"ap-menu-item",role:"menuitem",title:b,"aria-describedby":`${y}-restart-why`,onClick:()=>{C(null),h==null||h()},children:[i.jsx(pge,{}),f("shell.notes.restart")]}),i.jsx("span",{hidden:!0,id:`${y}-restart-why`,children:b})]})]})}function XA({entry:e,showVersion:t}){const n=se(),{highlights:a,visible:s,more:o}=IDe(e.notes),r=a.filter(l=>l.details),c=m.useId();return i.jsxs("section",{className:"rn-release",children:[t&&i.jsxs("h2",{className:"rn-version",children:["v",e.version]}),e.summary&&i.jsx("h2",{className:"rn-summary",children:e.summary}),i.jsxs("ul",{className:"rn-notes",children:[a.map((l,u)=>i.jsx(QA,{note:l,highlight:!0},`h${u}`)),s.map((l,u)=>i.jsx(QA,{note:l},`v${u}`))]}),(o.length>0||r.length>0)&&i.jsxs("details",{className:"rn-more",children:[i.jsxs("summary",{"aria-controls":c,children:[i.jsxs("span",{className:"rn-more-start",children:[i.jsx("span",{className:"rn-chevron","aria-hidden":"true",children:"›"}),i.jsx("span",{className:"rn-more-label",children:o.length?n("shell.notes.more",{count:o.length}):n("shell.notes.moreDetails")})]}),i.jsxs("span",{className:"rn-more-hint",children:[i.jsx("span",{className:"rn-show-details",children:n("shell.notes.show")}),i.jsx("span",{className:"rn-hide-details",children:n("shell.notes.hide")})]})]}),i.jsxs("div",{id:c,children:[i.jsx("ul",{className:"rn-notes",children:o.map((l,u)=>i.jsx(QA,{note:l},u))}),r.length>0&&i.jsxs("div",{className:"rn-highlight-details",role:"group","aria-labelledby":`${c}-highlights`,children:[i.jsx("h3",{id:`${c}-highlights`,className:"rn-details-title",children:n("shell.notes.aboutHighlights")}),r.map((l,u)=>i.jsxs("p",{className:"rn-note-body",children:[i.jsxs("strong",{className:"rn-strong",children:[d7(l.title).rest.trimStart(),": "]}),Kp(Vp(l.details))]},u))]})]})]})]})}const bFe={plans:dG,accounts:uG,skills:hG};function QA({note:e,highlight:t}){const n=se(),{icon:a,rest:s}=d7(e.title),o=!a&&e.icon?On(bFe,e.icon):void 0;return i.jsxs("li",{className:"rn-note","data-highlight":t||void 0,"data-required":e.priority==="required"||void 0,"data-has-icon":!!o||void 0,children:[o&&i.jsx("span",{className:"rn-title-icon","aria-hidden":"true",children:i.jsx(o,{})}),i.jsxs("div",{children:[i.jsxs("h3",{className:"rn-note-title",children:[a&&i.jsx("span",{className:"rn-note-icon",children:a}),a?s:s.trimStart()]}),i.jsx("p",{className:"rn-note-body",children:Kp(Vp(e.body))}),!t&&e.details&&i.jsx("p",{className:"rn-note-body rn-extra-detail",children:Kp(Vp(e.details))}),e.notice&&i.jsxs("p",{className:"rn-note-notice",children:[i.jsxs("strong",{children:[e.noticeLabel??n("shell.notes.important"),": "]}),Kp(Vp(e.notice))]})]})]})}function Kp(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?i.jsx("code",{className:"rn-code",children:t.text},n):i.jsx("strong",{className:"rn-strong",children:Kp(t.kids)},n))}function kFe({state:e,sessionId:t,onClose:n}){const a=se(),s=m.useMemo(()=>vFe(e,t),[e,e.revision,t]),o=m.useRef(null),r=Zt(n,{focusRef:o}),c=tn(n);return s?i.jsxs(dn,{scrim:c,dialogRef:r,className:"session-summary",labelledBy:"ss-title ss-who-name",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"ss-title",className:"modal-tool-name",children:a("insights.summary.title")})}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",title:a("insights.summary.wall"),children:s.durationLabel}),i.jsx("button",{type:"button",ref:o,className:"glyph-btn",onClick:n,"aria-label":a("insights.audit.closeEsc"),title:a("insights.audit.closeEsc"),children:"×"})]})]}),i.jsxs("div",{className:"modal-body",children:[i.jsxs("div",{className:"ss-who",title:s.cwd??s.sessionId,children:[i.jsx(yi,{kind:s.mark}),i.jsx("span",{id:"ss-who-name",className:"ss-who-name",children:s.label}),i.jsxs("span",{className:"ss-who-id",children:["· ",s.sessionId.slice(0,8)]})]}),i.jsxs("section",{className:"ss-stats",children:[i.jsx(Zc,{label:a("insights.summary.spend"),value:Ut(s.cost.total),title:T1()}),i.jsx(Zc,{label:a("insights.summary.agents"),value:s.agentCount}),i.jsx(Zc,{label:a("insights.summary.subagents"),value:s.subagentCount}),i.jsx(Zc,{label:a("insights.summary.toolCalls"),value:s.toolCount}),i.jsx(Zc,{label:a("insights.summary.prompts"),value:s.promptCount}),i.jsx(Zc,{label:a("insights.summary.errors"),value:s.errCount,tone:s.errCount>0?"err":void 0}),i.jsx(Zc,{label:a("insights.usage.tokens"),value:s.tokensSum.toLocaleString(Me())})]}),(s.modelChips.length>0||s.cost.total>0)&&i.jsxs("section",{className:"ss-hero",children:[s.modelChips.length>0&&i.jsx("div",{className:"ss-models",children:s.modelChips.map(l=>i.jsx("span",{className:"model-chip","data-family":M4(l),title:l,children:sc(l)},l))}),s.cost.total>0&&i.jsxs(i.Fragment,{children:[i.jsx(rR,{cost:s.cost,size:"lg"}),i.jsxs("div",{className:"ss-cost-legend",children:[i.jsxs("span",{className:"ssl ssl-in",children:[a("insights.cost.input")," ",i.jsx("b",{children:Ut(s.cost.input)})]}),i.jsxs("span",{className:"ssl ssl-out",children:[a("insights.cost.output")," ",i.jsx("b",{children:Ut(s.cost.output)})]}),i.jsxs("span",{className:"ssl ssl-cr",children:[a("insights.summary.cacheR")," ",i.jsx("b",{children:Ut(s.cost.cacheRead)})]}),i.jsxs("span",{className:"ssl ssl-cw",children:[a("insights.summary.cacheW")," ",i.jsx("b",{children:Ut(s.cost.cacheWrite)})]})]})]})]}),s.topTools.length>0&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:a("insights.summary.topTools")}),i.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([l,u])=>i.jsxs("span",{className:"ss-tt",children:[l," ",i.jsx("b",{children:u})]},l))})]}),s.firstPrompt&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:a("insights.summary.opening")}),i.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]}),i.jsx("footer",{className:"modal-foot",children:i.jsx("button",{type:"button",className:"btn primary",onClick:n,children:a("shell.done")})})]}):null}function Zc({label:e,value:t,tone:n,title:a}){return i.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,title:a,children:[i.jsx("div",{className:"ss-stat-value",children:t}),i.jsx("div",{className:"ss-stat-label",children:e})]})}function vFe(e,t){const n=e.agents.get(t);if(!n)return null;const a=[];for(const C of e.agents.values())C.sessionId===t&&a.push(C);if(a.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,r=new Map;let c=0,l=0,u=0,h=0,p=0,f,b=1/0,v=0;for(const C of a){const A=fs(C);s.input+=A.input,s.output+=A.output,s.cacheRead+=A.cacheRead,s.cacheWrite+=A.cacheWrite,s.total+=A.total;for(const R of q4(C))o.add(R);C.model&&o.add(C.model),C.kind==="subagent"&&p++;const E=h5(C.prompts);l+=E.length,!f&&E.length>0&&(f=E[0].text),u+=C.usage.inputTokens+C.usage.outputTokens,c+=C.toolCount,h+=C.toolErrorCount??0;for(const[R,z]of C.toolCountByName??[])r.set(R,(r.get(R)??0)+z);b=Math.min(b,C.startedAt),v=Math.max(v,C.endedAt??Date.now())}const w=Math.max(0,v-b),T=Math.floor(w/1e3),y=T<60?`${T}s`:T<3600?`${Math.floor(T/60)}m ${String(T%60).padStart(2,"0")}s`:`${Math.floor(T/3600)}h ${Math.floor(T%3600/60)}m`,x=Array.from(r.entries()).sort((C,A)=>A[1]-C[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||S("insights.summary.session"),cwd:n.cwd,durationLabel:y,cost:s,modelChips:Array.from(o),agentCount:a.length,subagentCount:p,toolCount:c,promptCount:l,tokensSum:u,errCount:h,topTools:x,firstPrompt:f,mark:Jk(n)}}function _z({id:e,children:t}){return i.jsxs("span",{className:"settings-info",id:e,children:[i.jsx(Ze,{name:"info"}),i.jsx("span",{children:t})]})}function gn({id:e,title:t,note:n,noteId:a,info:s,infoId:o,aside:r,list:c=!0,settingId:l,className:u,children:h}){const p=u?`settings-group ${u}`:"settings-group",f=c?i.jsx("div",{className:"settings-list",children:h}):h;return t===void 0?i.jsx("div",{className:p,"data-setting":l,children:f}):i.jsxs("section",{className:p,"aria-labelledby":e,"data-setting":l,children:[i.jsxs("div",{className:"settings-caption",children:[i.jsxs("div",{className:"settings-caption-text",children:[i.jsx("h3",{id:e,children:t}),n&&i.jsx("p",{className:"settings-caption-note",id:a,children:n}),s&&i.jsx(_z,{id:o,children:s})]}),r]}),f]})}function Ot({name:e,nameId:t,note:n,noteId:a,control:s,as:o="label",settingId:r,className:c,details:l,children:u}){const h=se(),p=o,f=i.jsxs(p,{className:c?`settings-row ${c}`:"settings-row","data-setting":r,children:[i.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&i.jsx("span",{className:"settings-row-note",id:a,children:n}),s!==void 0&&i.jsx("span",{className:"settings-row-control",children:s}),u]});return l?i.jsxs("div",{className:"settings-row-with-details",children:[f,i.jsxs("details",{className:"settings-row-details",children:[i.jsxs("summary",{children:[h("common.details"),i.jsxs("span",{className:"vis-hidden",children:[h("common.aboutBefore"),e,h("common.aboutAfter")]})]}),i.jsx("div",{children:l})]})]}):f}function wFe(){return i.jsx("svg",{className:"v4-select-chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"m3 4.5 3 3 3-3"})})}function dc({children:e}){return i.jsxs("span",{className:"v4-select",children:[e,i.jsx(wFe,{})]})}function yFe(){const e=se(),t=Es();return i.jsx(gn,{children:i.jsx(Ot,{settingId:"language",name:e("settings.language.name"),nameId:"settings-language-label",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",value:t,"aria-labelledby":"settings-language-label",onChange:n=>ire(n.target.value),children:Pu.map(n=>i.jsx("option",{value:n.code,lang:n.code,dir:n.dir,children:ere(n)},n.code))})})})})}function h7(e,t){const[n,a]=m.useState(null),[s,o]=m.useState(!1),r=m.useRef(!1),c=n??e===!0;return{checked:c,busy:n!==null,failed:s,flip:async()=>{if(e===null||r.current)return;r.current=!0;const u=!c;a(u),o(!1);let h=!1;try{h=await t(u)}catch{h=!1}r.current=!1,a(null),h||o(!0)}}}let ll=null,p7=0;const qk=new Set;function xFe(e){return qk.add(e),()=>{qk.delete(e)}}function jW(){return ll}function Ai(e){if(!(e===null&&ll===null)){ll=e===null?null:{line:e,serial:++p7};for(const t of qk)t()}}function CFe(e){ll={line:e,serial:(ll==null?void 0:ll.serial)??++p7};for(const t of qk)t()}function Dl(e,t=S){Ai(Ds(t("settings.failure.save"),e))}function SFe(){return m.useSyncExternalStore(xFe,jW,jW)}function g7(e,t,n){const[a,s]=m.useState(null),[o,r]=m.useState(""),c=m.useRef(!1),l=f=>typeof f=="boolean"?f:t;m.useEffect(()=>{let f=!0;return fetch("/api/prefs").then(b=>{if(!b.ok)throw new Error;return b.json()}).then(b=>{var v;if(!b.ok)throw new Error;f&&s(l((v=b.prefs)==null?void 0:v[e]))}).catch(()=>{f&&r(n("settings.recover.readFail"))}),()=>{f=!1}},[e]);const h=h7(a,async f=>{var b;c.current=!0;try{const v=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:f})}),w=await v.json().catch(()=>null);return!v.ok||!(w!=null&&w.ok)?(Dl(w,n),!1):(s(l((b=w.prefs)==null?void 0:b[e])),Ai(null),!0)}catch{return Dl(null,n),!1}finally{c.current=!1}}),p=()=>{a===null||!$a(c.current)||h.flip()};return{enabled:h.checked,ready:a!==null,error:o,change:p}}function EW({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,a=se(),s=g7(t,!0,a),o=`settings-${n}-name`,r=`settings-${n}-note`;return i.jsxs(i.Fragment,{children:[i.jsx(Ot,{settingId:n,name:a(e==="Codex"?"settings.recover.codexName":"settings.recover.claudeName"),nameId:o,note:a(e==="Codex"?"settings.recover.codexNote":"settings.recover.claudeNote"),noteId:r,control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-labelledby":o,"aria-describedby":r,"aria-checked":s.enabled,...gs(!1,!s.ready),onClick:s.change,children:i.jsx("span",{className:"switch-knob"})})}),s.error&&i.jsx("p",{role:"alert",children:s.error})]})}function TFe(){const e=se(),t=g7("continueStopped",!1,e);return i.jsxs(i.Fragment,{children:[i.jsx(Ot,{settingId:"claude-continue-stopped",name:e("settings.recover.continueName"),note:e("settings.recover.continueNote"),details:e("settings.recover.continueDetails"),control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":e("settings.recover.continueAria"),"aria-checked":t.enabled,...gs(!1,!t.ready),onClick:t.change,children:i.jsx("span",{className:"switch-knob"})})}),t.error&&i.jsx("p",{role:"alert",children:t.error})]})}function NFe({children:e}){const t=se(),n=d8();return i.jsxs(gn,{id:"settings-sessions-caption",title:t("settings.sessions.group"),children:[i.jsx(Ot,{settingId:"hide-finished",name:t("settings.board.hideLabel"),nameId:"settings-hide-finished-label",note:t("settings.board.hideNote"),noteId:"settings-hide-finished-note",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",value:n,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:a=>c8(Number(a.target.value)),children:i8.map(a=>i.jsx("option",{value:a,children:a===0?t("settings.board.never"):t("settings.board.minutes",{n:a})},a))})})}),e]})}const AFe="Codex accounts",jFe="Your Codex profiles and what each has left, and which one new sessions use.";function EFe({claudeHere:e,codexHere:t=!1,singleKeys:n,doors:a}){const s=se();return i.jsxs(gn,{id:"settings-elsewhere-caption",title:s("lan.ew.group"),children:[(e||t)&&i.jsx(ej,{settingId:"accounts",name:e?s("lan.ew.accounts"):AFe,note:e?s("lan.ew.accountsNote"):jFe,onOpen:a.accounts,shortcut:n?"A":null}),e&&i.jsx(ej,{settingId:"local-network",name:s("lan.ew.lan"),note:s("lan.ew.lanNote"),onOpen:a.localNetwork,shortcut:null}),i.jsx(ej,{settingId:"browser-watch",name:s("lan.ew.watch"),note:s("lan.ew.watchNote"),onOpen:a.browserWatch,dialog:!0,shortcut:n?"B":null})]})}function ej({settingId:e,name:t,note:n,onOpen:a,shortcut:s,dialog:o=!1}){const r=se(),c=`settings-${e}`;return i.jsx(Ot,{as:"div",settingId:e,name:t,nameId:`${c}-name`,note:n,control:i.jsx("button",{type:"button",className:"settings-link",id:`${c}-open`,"aria-labelledby":`${c}-open ${c}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":s??void 0,onClick:a,children:r("lan.ew.open")})})}function RFe(e){const t=e.binds.includes("?")?S("settings.keyboard.sheetName"):e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function zFe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(a=>a.toLowerCase().includes(n)):!0}function qFe({singleKeys:e,onToggleSingleKeys:t,workspace:n=!1}){const a=se(),s=zs(js()),[o,r]=m.useState(""),c=m.useId(),l=Xg(),u=r7(e,h=>Qo(l,h),n).map(h=>({...h,rows:h.rows.filter(p=>zFe(p,o))})).filter(h=>h.rows.length>0);return i.jsxs(i.Fragment,{children:[i.jsx(gn,{id:"settings-shortcuts-caption",title:a("settings.keyboard.group"),children:i.jsx(Ot,{settingId:"single-keys",name:a("settings.keyboard.singleKeys"),nameId:"settings-single-keys-label",note:a("settings.keyboard.singleKeysNote"),noteId:"settings-single-keys-note",control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-single-keys-label","aria-describedby":"settings-single-keys-note",onClick:t,children:i.jsx("span",{className:"switch-knob"})})})}),i.jsxs("div",{className:"settings-filter",children:[i.jsx("label",{className:"settings-filter-label",htmlFor:c,children:a("settings.keyboard.filter")}),i.jsx("input",{id:c,type:"search",className:"settings-filter-field",placeholder:a("settings.keyboard.filter"),autoComplete:"off",spellCheck:!1,value:o,onChange:h=>r(h.target.value),onKeyDown:h=>{ev(h.key)&&o&&(h.stopPropagation(),r(""))}})]}),u.map(h=>{const p=`settings-keys-${h.id}`;return i.jsx(gn,{id:p,title:h.title,className:"settings-keys",children:h.rows.map(f=>i.jsx(Ot,{as:"div",name:RFe(f),control:i.jsx("kbd",{className:"settings-key",children:s&&f.macCap?f.macCap:f.cap})},`${f.cap}:${f.action}`))},h.id)}),u.length===0&&i.jsx("p",{className:"settings-empty",role:"status",children:a("settings.keyboard.noMatch",{query:o.trim()})}),o.trim()===""&&i.jsx("p",{className:"settings-foot",children:a("settings.key.note")})]})}function _Fe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:a,onAskNotify:s,accountNotify:o,onToggleAccountNotify:r}){const c=se(),l=Kme(a,c),u=lr(),h=e&&!n&&!u,p=m.useRef(null),f=so(!l.ask,p);return i.jsxs(i.Fragment,{children:[i.jsxs(gn,{id:"sm-closed-caption",title:c("settings.notify.closedGroup"),children:[i.jsx(Ot,{settingId:"notify-closed",name:c("settings.notify.closedName"),nameId:"sm-notify-label",note:Wme(u,c),noteId:"sm-notify-note",control:i.jsx("button",{ref:p,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":n?"sm-notify-note sm-notify-veto":"sm-notify-note",className:"switch",onClick:t,children:i.jsx("span",{className:"switch-knob"})}),children:n&&i.jsx(_z,{id:"sm-notify-veto",children:c(Hme)})}),h&&i.jsx(Ot,{as:"div",name:c("settings.notify.browserName"),nameId:"sm-channel-name",note:l.note,control:l.ask?i.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{f(),s()},children:c("settings.notify.enable")}):i.jsxs("span",{className:"sm-channel-state","data-ok":l.ok||void 0,children:[l.ok&&i.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),l.status]})})]}),i.jsx(gn,{id:"sm-accounts-caption",title:c("settings.notify.accountsGroup"),note:c(Gme),info:n?c(Vme):void 0,children:o0.map(({kind:b,label:v,title:w})=>i.jsx(Ot,{settingId:b,name:v,nameId:`sm-${b}-label`,note:w??void 0,noteId:w?`sm-${b}-note`:void 0,control:i.jsx("button",{type:"button",role:"switch","aria-checked":o[b],"aria-labelledby":`sm-${b}-label`,"aria-describedby":w?`sm-${b}-note`:void 0,className:"switch",onClick:()=>r(b),children:i.jsx("span",{className:"switch-knob"})})},b))})]})}const LFe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function PFe(e){return LFe.find(t=>e(t))}const OFe=4400;function MFe(e){const t=e.split(";")[0],n=t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm";return{name:`${S("radio.rec.name")}.${n}`,type:t}}function IFe({full:e,setCustomError:t,runCustom:n,onImportCustom:a}){const[s,o]=m.useState(!1),r=m.useRef(null),c=m.useRef(null),l=m.useRef(!1),u=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=r.current)==null?void 0:p.state)==="recording"&&r.current.stop()},h=async()=>{var f;if(e)return;if(t(""),!((f=navigator.mediaDevices)!=null&&f.getUserMedia)||typeof MediaRecorder>"u"){t(S("radio.rec.noMic"));return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{l.current||t(S("radio.rec.denied"));return}if(l.current||r.current){p.getTracks().forEach(b=>b.stop());return}try{const b=PFe(T=>MediaRecorder.isTypeSupported(T)),v=new MediaRecorder(p,b?{mimeType:b}:void 0),w=[];r.current=v,v.ondataavailable=T=>{T.data.size&&w.push(T.data)},v.onerror=()=>t(S("radio.rec.failed")),v.onstop=()=>{p.getTracks().forEach(C=>C.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const T=r.current===v;if(T&&(r.current=null),o(!1),!T||!w.length)return;const y=MFe(v.mimeType),x=new File(w,y.name,{type:y.type});n(()=>a(x))},v.start(200),o(!0),c.current=setTimeout(u,OFe)}catch{r.current=null,p.getTracks().forEach(b=>b.stop()),t(S("radio.rec.format"))}};return m.useEffect(()=>(l.current=!1,()=>{l.current=!0,c.current!==null&&clearTimeout(c.current);const p=r.current;r.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:h,stopRecording:u}}function DFe({full:e,fullProps:t,runCustom:n,onCreateVoice:a}){const s=se(),[o,r]=m.useState(()=>s("settings.sounds.voice.defaultName")),[c,l]=m.useState(()=>s("settings.sounds.voice.defaultText")),[u,h]=m.useState(""),[p,f]=m.useState("1"),[b,v]=m.useState("1"),[w,T]=m.useState([]);return m.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const y=()=>{T(window.speechSynthesis.getVoices())};return y(),window.speechSynthesis.addEventListener("voiceschanged",y),()=>window.speechSynthesis.removeEventListener("voiceschanged",y)},[]),i.jsxs("details",{className:"sm-voice",children:[i.jsxs("summary",{className:"settings-row",...t,onClick:y=>{const x=y.currentTarget.parentElement;e&&x&&!x.open&&y.preventDefault()},children:[i.jsx("span",{className:"settings-row-name",children:s("settings.sounds.voice.title")}),i.jsx("span",{className:"settings-row-note",children:s("settings.sounds.voice.note")}),i.jsx("span",{className:"settings-row-control",children:i.jsx("svg",{className:"sm-voice-chevron",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),i.jsxs("div",{className:"sm-voice-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.name")}),i.jsx("input",{className:"ap-manage-input",value:o,maxLength:80,onChange:y=>r(y.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.text")}),i.jsx("input",{className:"ap-manage-input",value:c,maxLength:180,onChange:y=>l(y.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.voice")}),i.jsx(dc,{children:i.jsxs("select",{className:"sm-select",value:u,onChange:y=>h(y.target.value),children:[i.jsx("option",{value:"",children:s("settings.sounds.voice.default")}),w.map(y=>i.jsx("option",{value:y.voiceURI,children:y.name},y.voiceURI))]})})]}),i.jsxs("div",{className:"sm-voice-pair",children:[i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.rate")}),i.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:p,onChange:y=>f(y.target.value)})]}),i.jsxs("label",{children:[i.jsx("span",{children:s("settings.sounds.voice.pitch")}),i.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:b,onChange:y=>v(y.target.value)})]})]}),i.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await a({name:o,text:c,voiceURI:u,rate:parseFloat(p),pitch:parseFloat(b)}),l(s("settings.sounds.voice.defaultText"))})},children:s("settings.sounds.voice.add")})]})]})}function FFe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:a,onPreviewCustom:s,onDeleteCustom:o}){const r=se(),[c,l]=m.useState(""),u=e.length,h=c0(u),p=h!==null,f=p?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[b,v]=m.useState(null),w=m.useRef(0),T=m.useRef(new Map),y=m.useRef(null),x=m.useRef(null);m.useEffect(()=>{if(!b)return;const I=window.setTimeout(()=>v(null),4e3);return()=>window.clearTimeout(I)},[b]);const C=async I=>{l("");try{await I()}catch(_){l(rr(_,r("settings.sounds.custom.saveFail")))}},A=(I,_)=>{const D=Date.now(),L=zl({armedFor:b,target:I,armedAt:w.current,now:D,gapMs:Rl});if(L==="arm"){v(I),w.current=D;return}if(L==="ignore")return;v(null);const P=tfe(e.map(O=>O.id),I);C(async()=>{var j;await o(I);const O=document.activeElement;O!==_&&!fa((O==null?void 0:O.tagName)??null)||(j=P?T.current.get(P):y.current)==null||j.focus()})},{recording:E,startRecording:R,stopRecording:z}=IFe({full:p,setCustomError:l,runCustom:C,onImportCustom:t});return i.jsxs(gn,{id:"sm-custom-title",title:r("settings.sounds.custom.group"),note:r("settings.sounds.custom.note"),aside:i.jsx("span",{className:"settings-caption-count",children:r("settings.sounds.custom.count",{count:u,max:r0})}),className:"sm-custom",settingId:"custom-sounds",children:[p&&i.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:h}),i.jsx(Ot,{as:"div",settingId:"custom-import",name:r("settings.sounds.custom.import"),note:r("settings.sounds.custom.importNote"),control:i.jsx("button",{ref:y,type:"button",className:"btn sm-custom-action",...f,onClick:()=>{var I;p||(I=x.current)==null||I.click()},children:r("settings.sounds.custom.chooseFile")}),children:i.jsx("input",{ref:x,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:I=>{var D;const _=(D=I.target.files)==null?void 0:D[0];I.currentTarget.value="",_&&!p&&C(()=>t(_))}})}),i.jsx(Ot,{as:"div",settingId:"custom-record",name:r("settings.sounds.custom.record"),note:r(E?"settings.sounds.custom.recording":"settings.sounds.custom.upTo5"),control:E?i.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:z,children:r("settings.sounds.custom.stopSave")}):i.jsx("button",{type:"button",className:"btn sm-custom-action",...f,onClick:()=>void R(),children:r("settings.sounds.custom.recordBtn")})}),i.jsx(DFe,{full:p,fullProps:f,runCustom:C,onCreateVoice:n}),e.map(I=>i.jsxs("div",{className:"sm-custom-item",children:[i.jsx("input",{className:"ap-manage-input","aria-label":r("settings.sounds.custom.rename",{name:I.name}),defaultValue:I.name,maxLength:80,onBlur:_=>{if(!_.target.value.trim()){_.target.value=I.name;return}C(()=>a(I.id,_.target.value))},onKeyDown:_=>{_.key==="Enter"&&_.currentTarget.blur()}}),i.jsx("span",{children:I.kind==="audio"?`${U4(I.duration,1)}s`:r("settings.sounds.custom.voice")}),i.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":r("settings.sounds.custom.playName",{name:I.name}),onClick:()=>s(I.id),children:r("settings.sounds.custom.play")}),i.jsx("button",{type:"button",ref:_=>{_?T.current.set(I.id,_):T.current.delete(I.id)},className:`btn sm-custom-icon${b===I.id?" armed":""}`,onKeyDown:_=>{_.repeat&&_.preventDefault()},onClick:_=>A(I.id,_.currentTarget),"aria-label":b===I.id?r("settings.sounds.custom.confirmName",{name:I.name}):r("settings.sounds.custom.deleteName",{name:I.name}),title:b===I.id?r("settings.sounds.custom.deleteAgain"):r("settings.sounds.custom.deleteTip"),children:b===I.id?r("settings.sounds.custom.confirm"):r("settings.sounds.custom.delete")})]},I.id)),c&&i.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:c})]})}function BFe({soundOn:e,onToggleSound:t}){const n=se(),a=m.useId(),s=sa();return i.jsx(gn,{id:"sm-sound-caption",title:n("settings.sounds.group"),children:i.jsx(Ot,{settingId:"play-sounds",name:n("radio.sound.name"),nameId:a,control:i.jsxs(i.Fragment,{children:[s&&i.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:n("radio.sound.keyTitle"),children:"M"}),i.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":a,"aria-keyshortcuts":s?"M":void 0,className:"switch",onClick:t,children:i.jsx("span",{className:"switch-knob"})})]})})})}const bE="custom:";function RW(e){return`${bE}${e}`}function UFe(e){return e.startsWith(bE)?e.slice(bE.length):null}function WFe({id:e,label:t,value:n,step:a=Y1,onLevel:s,"aria-describedby":o}){const r=se();return i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:e,children:t??r("radio.volume")}),i.jsx("input",{id:e,type:"range",min:fb,max:nk,step:a,value:n,"aria-describedby":o,onChange:c=>s(Number(c.target.value)),style:{"--sm-level":`${(n-fb)/(nk-fb)*100}%`}}),i.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const zW={get done(){return S("settings.sounds.tone.done")},get"needs-input"(){return S("settings.sounds.tone.needsInput")}},HFe={get done(){return S("settings.sounds.tone.doneNote")},get"needs-input"(){return S("settings.sounds.tone.needsInputNote")}};function GFe({chime:e,tone:t,soundOn:n,customAssets:a,customSelections:s,onLevel:o,onFigure:r,onPreview:c,onBuiltInSelected:l,onCustomSelected:u}){const h=se(),p=`sm-level-${e}`,f=`sm-figure-${e}`,b=s[e];return i.jsxs(gn,{id:`sm-name-${e}`,title:zW[e],note:HFe[e],settingId:`tone-${e}`,aside:i.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":h("settings.sounds.hearAria",{tone:zW[e]}),title:h(n?"settings.sounds.hearTip":"settings.sounds.hearTipMuted"),"aria-describedby":n?void 0:"sm-preview-note",children:[i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:i.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),h("settings.sounds.hear")]}),children:[i.jsx(WFe,{id:p,value:t.level,onLevel:v=>o(e,v)}),i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:f,children:h("settings.sounds.toneLabel")}),i.jsx(dc,{children:i.jsxs("select",{id:f,className:"sm-select",value:b?RW(b):t.figure,onChange:v=>{const w=v.target.value,T=UFe(w);T!==null?u(e,T):(l(e),r(e,w))},children:[J1[e].map(v=>i.jsx("option",{value:v.id,children:v.label},v.id)),a.length>0&&i.jsx("optgroup",{label:h("settings.sounds.customGroup"),children:a.map(v=>i.jsx("option",{value:RW(v.id),children:v.name},v.id))})]})})]})]})}function VFe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:a,onLevel:s,onFigure:o,onPreview:r,customAssets:c,customSelections:l,onBuiltInSelected:u,onCustomSelected:h,onImportCustom:p,onCreateVoice:f,onRenameCustom:b,onPreviewCustom:v,onDeleteCustom:w}){var A;const T=se(),y=Qme(l),x=((A=c.find(E=>E.id===y))==null?void 0:A.name)??T("settings.sounds.sharedName"),C=y?T("settings.sounds.sharedNote",{name:x}):"";return i.jsxs("div",{className:"sm-sounds",children:[i.jsx(BFe,{soundOn:e,onToggleSound:t}),!a&&i.jsx("p",{className:"sm-note",children:T("settings.sounds.codexOnly")}),!e&&i.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:T("settings.sounds.previewNote")}),i.jsx("div",{className:"sm-tones",children:Lp.map(E=>i.jsx(GFe,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:l,onLevel:s,onFigure:o,onPreview:r,onBuiltInSelected:u,onCustomSelected:h},E))}),C&&i.jsx("p",{className:"sm-note","aria-hidden":!0,children:C}),i.jsx("p",{className:"vis-hidden",role:"status",children:C}),i.jsx(FFe,{customAssets:c,onImportCustom:p,onCreateVoice:f,onRenameCustom:b,onPreviewCustom:v,onDeleteCustom:w})]})}function KFe({onOpen:e}){const t=se();return i.jsx(gn,{children:i.jsx(Ot,{as:"div",settingId:"radar-open",name:t("radar.name"),nameId:"settings-radar-open-name",note:t("radar.note"),control:i.jsx("button",{type:"button",className:"btn",id:"settings-radar-open","aria-labelledby":"settings-radar-open settings-radar-open-name","aria-haspopup":"dialog",onClick:e,children:t("radar.open")})})})}const $Fe=6500,JFe=1e4;let xl={reading:null,saving:null,error:"",undone:null};const Sb=new Set;let sp=null,ip=null,sr=null,tj=!1,Tb=0;const su=e=>{xl={...xl,...e},Sb.forEach(t=>t(xl))};function m7(e){const t=e;return!!t&&t.ok===!0&&Array.isArray(t.settings)&&typeof t.present=="object"}async function f7(e){const t=await fetch("/api/claude-settings",{signal:e}),n=await t.json();if(!t.ok||!m7(n))throw new Error;return n}async function kE(){if(tj||xl.saving)return;tj=!0;const e=Tb,t=new AbortController;sr=t;let n=!1;const a=setTimeout(()=>{n=!0,t.abort()},5e3);try{const s=await f7(t.signal);e===Tb&&!t.signal.aborted&&su({reading:s,error:""})}catch{e===Tb&&(n||!t.signal.aborted)&&su({error:S("settings.claude.readFail")})}finally{clearTimeout(a),tj=!1,sr===t&&(sr=null)}}function qW(e,t){var n;return(n=e==null?void 0:e.settings.find(a=>a.id===t))==null?void 0:n.value}async function b7(e,t){if(xl.saving)return!1;Tb++,sr==null||sr.abort(),ip&&(clearTimeout(ip),ip=null),su({saving:e,error:"",undone:null});const n=new AbortController,a=setTimeout(()=>n.abort(),15e3);try{const s=await fetch("/api/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,value:t}),signal:n.signal}),o=await s.json().catch(()=>null);if(!s.ok||!m7(o))throw new $n(typeof(o==null?void 0:o.error)=="string"&&o.error?Nb(o.error):S("settings.failure.save"));su({reading:o}),Ai(null);const r=qW(o,e);return ip=setTimeout(()=>{ip=null;const c=new AbortController,l=setTimeout(()=>c.abort(),5e3);f7(c.signal).then(u=>{su({reading:u,undone:qW(u,e)===r?null:{id:e}})}).catch(()=>{}).finally(()=>clearTimeout(l))},$Fe),!0}catch(s){return Ai({text:rr(s,S("settings.failure.save")),giveBack:!1,done:!1}),!1}finally{clearTimeout(a),su({saving:null})}}const YFe={"Your settings.json is not valid JSON, so Claude Code skips all of it, hooks included. Fix it in an editor; this section reads it again by itself.":"settings.claude.reason.invalid","Your settings.json could not be read here, so nothing is shown or changed until it can.":"settings.claude.reason.unreadable","Your organization's settings could not be read, so nothing here can be changed until they can.":"settings.claude.reason.othersUnknown","Set by your organization. Ask your administrator to change it.":"settings.claude.reason.locked","Your settings.json holds a custom value. Edit it there.":"settings.claude.reason.custom","Choose a setting this section offers and one of its values.":"settings.claude.reason.choose","Your settings.json could not be read as JSON. No changes were saved.":"settings.claude.reason.parse","Your settings.json changed while saving. Nothing was written. Try again.":"settings.claude.reason.changed","Claude Code settings can be changed on this computer only.":"settings.claude.reason.localOnly","Could not read Claude Code settings. Try again.":"settings.claude.reason.readFail","Could not save the change. Your settings.json was not modified.":"settings.claude.reason.notSaved","Your settings.json has a permissions value that is not an object. No changes were saved.":"settings.claude.reason.permissionsShape","Your settings.json has a permissions.deny value that is not a list. No changes were saved.":"settings.claude.reason.denyShape","Your settings.json holds a custom attribution. Edit it there.":"settings.claude.reason.attribution"};function Nb(e,t=S){const n=YFe[e];if(n)return t(n);const a=k7(e);return a?t(a.unread?"settings.claude.reason.needsUnread":"settings.claude.reason.needs",{version:a.version}):j6(e,t)}function k7(e){const t=/^Needs Claude Code (\S+) or newer(, and the version installed here could not be read)?\.$/.exec(e??"");return t?{version:t[1],unread:!!t[2]}:null}function ZFe(){const[e,t]=m.useState(xl);return m.useEffect(()=>(Sb.add(t),t(xl),sp||(kE(),sp=setInterval(()=>void kE(),JFe)),()=>{Sb.delete(t),Sb.size||(sp&&clearInterval(sp),sp=null,sr==null||sr.abort())}),[]),e}const nj=40,XFe=(e,t)=>{const n=`settings.claudeTopic.${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`,a=t(n);return a===n?e:a},QFe={boolean:"settings.claudeIndex.kind.boolean",choice:"settings.claudeIndex.kind.choice",number:"settings.claudeIndex.kind.number",text:"settings.claudeIndex.kind.text",structured:"settings.claudeIndex.kind.structured"};function e2e(e,t=S){const n=e.scope==="Global config"?t("settings.claudeIndex.globalConfig"):e.scope==="Managed"?t("settings.claudeIndex.managedOnly"):null;return[e.topic?XFe(e.topic,t):e.topic,t(QFe[e.kind]),n,e.since?t("settings.claudeIndex.since",{since:e.since}):null].filter(Boolean).join(" · ")}function t2e(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=e.filter(o=>o.key.toLowerCase().includes(n)),s=e.filter(o=>!a.includes(o)&&(o.topic??"").toLowerCase().includes(n));return[...a,...s]}let v7=null;const n2e=()=>v7??=Xs(()=>import("./claude-settings-index-1Qg1AUda.js"),[]).then(e=>e.default.keys);function a2e({present:e,noFile:t=!1}){const n=se(),a=Es(),[s,o]=m.useState(null),[r,c]=m.useState(""),l=m.useId();m.useEffect(()=>{let f=!0;return n2e().then(b=>{f&&o(b)},()=>{v7=null}),()=>{f=!1}},[]);const u=m.useMemo(()=>{if(!s)return[];if(r.trim())return t2e(s,r);if(!e)return[];const f=s.filter(v=>Object.hasOwn(e,v.key)),b=Object.keys(e).filter(v=>!s.some(w=>w.key===v)).sort().map(v=>({key:v,topic:S("settings.claudeIndex.notInRef"),scope:null,kind:"structured",default:null,since:null,anchor:""}));return[...f,...b]},[s,e,r,a]),h=u.slice(0,nj),p=r.trim()!=="";return i.jsxs(gn,{id:"claude-group-all",settingId:"claude-all-settings",title:n("settings.claudeIndex.title"),note:p?void 0:n(e&&!t?"settings.claudeIndex.notePresent":"settings.claudeIndex.noteAll"),aside:s?i.jsx("span",{className:"settings-caption-count",children:s.length}):void 0,list:!1,children:[i.jsxs("div",{className:"settings-filter",children:[i.jsx("label",{className:"vis-hidden",htmlFor:l,children:n("settings.claudeIndex.filterLabel")}),i.jsx("input",{id:l,type:"search",className:"settings-filter-field",placeholder:s?n("settings.claudeIndex.filterCount",{count:s.length}):n("settings.claudeIndex.filter"),autoComplete:"off",spellCheck:!1,value:r,onChange:f=>c(f.target.value),onKeyDown:f=>{ev(f.key)&&r&&(f.stopPropagation(),c(""))}})]}),h.length>0&&i.jsx("div",{className:"settings-list settings-keys",children:h.map(f=>{const b=e&&Object.hasOwn(e,f.key)?e[f.key]:null;return i.jsx(Ot,{as:"div",name:i.jsx("code",{className:"claude-key",children:f.key}),note:e2e(f,n),control:i.jsxs(i.Fragment,{children:[b!==null&&i.jsx("span",{className:"settings-read",title:n("settings.claudeIndex.inFile"),children:b}),f.anchor&&i.jsx("a",{className:"settings-link",href:`${Ome}#${f.anchor}`,target:"_blank",rel:"noreferrer","aria-label":n("settings.claudeIndex.referenceAria",{key:f.key}),children:n("settings.claudeIndex.reference")})]})},f.key)})}),p&&u.length===0&&s&&i.jsx("p",{className:"settings-empty",role:"status",children:n("settings.claudeIndex.noMatch",{query:r.trim()})}),u.length>nj&&i.jsx("p",{className:"settings-foot",role:"status",children:n("settings.claudeIndex.more",{count:u.length-nj})}),!p&&e&&!t&&s&&u.length===0&&i.jsx("p",{className:"settings-empty",children:n("settings.claudeIndex.empty")})]})}function s2e(e,t=S){return t("settings.claude.foot",{file:e??t("settings.claude.footDefault")})}const _W={Off:"settings.claude.effect.off",On:"settings.claude.effect.on","Updates are off":"settings.claude.effect.updatesOff","Background updates are off":"settings.claude.effect.bgUpdatesOff"};function i2e(e,t=S){const n=`${e.env}=${e.value}`,a=_W[e.effect]?t(_W[e.effect]):e.effect;return e.where==="environment"?t("settings.claude.overrideEnv",{effect:a,set:n}):t(e.where==="user"?"settings.claude.overrideUser":"settings.claude.overrideOrg",{effect:a,set:n})}const LW="\0custom";function o2e({entry:e,row:t,saving:n,nameId:a,noteId:s,flip:o}){const r=se(),c=!!t&&t.editable&&!n,l=!t||n===e.id,u=t?!t.editable:void 0;if(e.kind==="choice"||e.kind==="days"){const p=e.kind==="days"?e.options.map(v=>({value:String(v),label:JP(v,r)})):e.options.map(v=>({...v,label:Ime(e.id,v.value,v.label,r)})),f=t?t.custom?LW:t.value===null?"":String(t.value):"",b=e.kind==="days"&&t&&!t.custom&&!p.some(v=>v.value===f)?[...p,{value:f,label:JP(Number(f),r)}].sort((v,w)=>Number(v.value)-Number(w.value)):p;return i.jsx(dc,{children:i.jsxs("select",{className:"sm-select","aria-labelledby":a,"aria-describedby":s,"aria-busy":l,disabled:u,value:f,onChange:v=>{if(!c)return;const w=v.target.value;b7(e.id,e.kind==="days"?Number(w):w===""?null:w)},children:[(t==null?void 0:t.custom)&&i.jsx("option",{value:LW,disabled:!0,children:r("settings.claude.customValue")}),b.map(v=>i.jsx("option",{value:v.value??"",children:v.label},v.value??""))]})})}const h=o.checked;return i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":h,"aria-labelledby":a,"aria-describedby":s,"aria-busy":l,disabled:u,onClick:()=>{c&&o.flip()},children:i.jsx("span",{className:"switch-knob"})})}function r2e({entry:e,row:t,saving:n,said:a}){const s=se(),o=h7(t?t.value===!0:null,l=>b7(e.id,l)),r=`claude-${e.id}-label`,c=`claude-${e.id}-note`;return i.jsx(Ot,{settingId:`claude-${e.id}`,name:LG(e,s),nameId:r,note:Mme(e,s),noteId:c,control:i.jsx(o2e,{entry:e,row:t,saving:n,nameId:r,noteId:c,flip:o}),children:i.jsx("span",{className:"settings-row-said settings-row-said-quiet",role:"status",children:a})})}function c2e(e,t=S){if(e.length<2||e.some(s=>!s||s.editable))return null;const n=new Set(e.map(s=>s.reason));if(n.size!==1)return null;const a=k7([...n][0]);return a?t(a.unread?"settings.claude.groupNeedsUnread":"settings.claude.groupNeeds",{version:a.version}):null}function l2e(e){if(!(e!=null&&e.settings.length)||e.settings.some(n=>n.editable))return null;const t=new Set(e.settings.map(n=>n.reason));return t.size===1?[...t][0]??null:null}function d2e(){return i.jsx(u2e,{state:ZFe()})}function u2e({state:e}){const t=se(),{reading:n,saving:a,error:s,undone:o}=e,r=l2e(n),c=(n==null?void 0:n.userFile)==="absent",l=n?n.userFile!=="invalid"&&n.userFile!=="unreadable":!s;return i.jsxs(i.Fragment,{children:[(n===null||s||r||c)&&i.jsxs(gn,{children:[n===null&&!s&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.reading")}),r&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:Nb(r,t)}),c&&!r&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.noFile")}),s&&i.jsxs("div",{className:"settings-row",role:"alert",children:[i.jsx("span",{className:"settings-row-name",children:Nb(s,t)}),i.jsx("span",{className:"settings-row-control",children:i.jsx("button",{type:"button",className:"btn","aria-busy":!!a,onClick:()=>void kE(),children:t("settings.claude.retry")})})]})]}),l&&zG.map(u=>{const h=qG.filter(b=>b.group===u.id),p=h.map(b=>n==null?void 0:n.settings.find(v=>v.id===b.id)),f=r?null:c2e(p,t);return i.jsx(gn,{id:`claude-group-${u.id}`,title:_G(u.id,u.title,t),info:f??void 0,infoId:`claude-group-${u.id}-info`,children:h.map((b,v)=>{const w=p[v],T=w&&!w.editable&&!r&&!f?Nb(w.reason??"",t):(o==null?void 0:o.id)===b.id?t("settings.claude.undone"):w!=null&&w.override?i2e(w.override,t):"";return i.jsx(r2e,{entry:b,row:w,saving:a,said:T},b.id)})},u.id)}),l&&i.jsx("p",{className:"settings-foot",children:s2e(n==null?void 0:n.fileShown,t)}),i.jsx(a2e,{present:(n==null?void 0:n.present)??null,noFile:c})]})}function h2e(){const e=se(),[t,n]=m.useState(null),[a,s]=m.useState(""),[o,r]=m.useState(!1),[c,l]=m.useState(null),[u,h]=m.useState(""),p=m.useRef(!1),f=m.useRef(!0),b=async()=>{if(p.current)return;p.current=!0,r(!0),s("");const T=new AbortController,y=window.setTimeout(()=>T.abort(),12e3);try{const x=await fetch("/api/tool-audit/storage",{signal:T.signal}),C=await x.json();if(!x.ok||!C.ok)throw new Error;f.current&&n(C)}catch{f.current&&s(e("settings.tools.readFail"))}finally{window.clearTimeout(y),p.current=!1,f.current&&r(!1)}};m.useEffect(()=>(f.current=!0,b(),()=>{f.current=!1}),[]);const v=async(T,y)=>{if(p.current)return;p.current=!0,r(!0),s(""),h("");let x=!1;const C=new AbortController,A=window.setTimeout(()=>C.abort(),15e3);try{const E=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T==="clear"?{action:T,confirm:!0}:{action:T,days:y}),signal:C.signal}),R=await E.json();if(!E.ok||!R.ok)throw new Error;x=!0,f.current&&(l(null),h(T==="clear"?e("settings.tools.cleared"):e("settings.tools.retentionChanged",{days:y??0})))}catch{f.current&&s(e("settings.tools.updateFail"))}finally{window.clearTimeout(A),p.current=!1,f.current&&(r(!1),x&&b())}},w=c!==null&&i.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":e("settings.tools.confirm"),children:[i.jsx("p",{children:c==="clear"?e("settings.tools.confirmClear"):e("settings.tools.confirmKeep",{days:c})}),i.jsxs("div",{children:[i.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{v(c==="clear"?"clear":"retention",typeof c=="number"?c:void 0)},children:e(c==="clear"?"settings.tools.deleteBtn":"settings.tools.applyBtn")}),i.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{p.current||l(null)},children:e("settings.tools.cancel")})]})]});return i.jsxs(gn,{id:"tool-history-settings-title",title:e("settings.tools.title"),note:e("settings.tools.note"),className:"ta-settings",children:[t?i.jsxs(i.Fragment,{children:[i.jsx(Ot,{settingId:"tool-history-retention",name:e("settings.tools.keep"),nameId:"ta-keep-label",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:t.retentionDays,"aria-busy":o,onChange:T=>{if(p.current)return;const y=Number(T.target.value);y<t.retentionDays?l(y):v("retention",y)},children:[30,60,90].map(T=>i.jsx("option",{value:T,children:e("settings.tools.days",{count:T})},T))})})}),typeof c=="number"&&w,i.jsx(Ot,{as:"div",settingId:"tool-history-size",name:e("settings.tools.space"),note:e("settings.tools.since",{date:$fe(t.startedAt)}),control:i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"settings-read",children:Kfe(t.bytes)}),i.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{b()},children:e("settings.tools.refresh")})]})}),i.jsx(Ot,{as:"div",settingId:"tool-history-clear",name:e("settings.tools.clear"),note:e("settings.tools.clearNote"),control:i.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{p.current||l("clear")},children:e("settings.tools.clearBtn")})}),c==="clear"&&w,!t.storageOk&&i.jsx(Ot,{as:"div",name:e("settings.tools.unsaved"),note:e("settings.tools.unsavedNote")})]}):i.jsx(Ot,{as:"div",name:e(o?"settings.tools.reading":"settings.tools.unavailable")}),a&&i.jsxs("div",{className:"settings-row",role:"alert",children:[i.jsx("span",{className:"settings-row-name",children:a}),i.jsx("span",{className:"settings-row-control",children:i.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{b()},children:e("settings.tools.retry")})})]}),u&&i.jsx("p",{className:"settings-row settings-row-status",role:"status",children:u})]})}const vE="agent-dag.integrations.active",Lz=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,p2e=32e3;function PW(e,t){const n=gt(Lz(e,t));if(!n)return{};try{const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}}function z4e(e,t){return{read(n,a){const s=PW(e,t)[n];return a(s)?s:void 0},write(n,a){const s=PW(e,t);a===void 0?delete s[n]:s[n]=a;const o=JSON.stringify(s);o.length<=p2e&&yt(Lz(e,t),o)}}}function g2e(e,t){Ja(Lz(e,t))}function q4e(e){const t=gt(vE);if(!t)return null;try{const n=JSON.parse(t),a=n&&typeof n=="object"?n[e]:null;return typeof a=="string"&&a.length<=80?a:null}catch{return null}}function _4e(e,t){let n={};try{const a=gt(vE),s=a?JSON.parse(a):{};s&&typeof s=="object"&&!Array.isArray(s)&&(n=Object.fromEntries(Object.entries(s).filter(([,o])=>typeof o=="string").slice(0,20)))}catch{}n[e]=t,yt(vE,JSON.stringify(n))}function wE(e){var a;const t=(a=e.meta)==null?void 0:a.checkedAt;if(!t)return null;const n=new Date(String(t));return Number.isNaN(n.getTime())?null:n.toLocaleString(Me(),{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...n.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}function yE(e){const t=e.meta??{};return e.kind==="gitlab"?typeof t.serverVersion=="string"&&t.serverVersion?`GitLab ${t.serverVersion}`:null:e.kind!=="jira"?null:t.deploymentType==="Cloud"?"Jira Cloud":t.deploymentType?`Jira ${t.deploymentType==="DataCenter"?"Data Center":String(t.deploymentType)}${t.serverVersion?` ${t.serverVersion}`:""}`:null}function m2e({connection:e,provider:t,available:n,busy:a,armed:s,note:o,headingRef:r,onTest:c,onEdit:l,onDisconnect:u,onCancelDisconnect:h}){var E;const p=se(),f=m.useRef(null),b=(t==null?void 0:t.label)??e.kind,v=e.account.name||e.account.login||p("integrations.conn.noAccount"),w=e.account.name&&e.account.login!==e.account.name?e.account.login:"",T=wE(e),y=yE(e),x=Array.isArray((E=e.meta)==null?void 0:E.warnings)?e.meta.warnings.filter(R=>typeof R=="string"):[],C=a===`test:${e.id}`,A=a===`delete:${e.id}`;return i.jsxs("section",{className:"ig-connection-details","aria-labelledby":"ig-managed-title",children:[i.jsxs("header",{className:"ig-managed-header",children:[t&&i.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:i.jsx(t.Glyph,{})}),i.jsxs("div",{className:"ig-managed-identity",children:[i.jsx("h2",{ref:r,tabIndex:-1,id:"ig-managed-title",className:"ig-managed-title",children:e.name||e.baseUrl}),i.jsx("p",{children:p("integrations.conn.saved",{label:b})})]})]}),i.jsxs("dl",{className:"ig-detail-facts",children:[i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.host")}),i.jsx("dd",{children:e.baseUrl})]}),i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.account")}),i.jsxs("dd",{children:[v,w?` (${w})`:""]})]}),i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.lastVerified")}),i.jsx("dd",{children:T??p("integrations.conn.noVerificationTime")})]}),i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.credentials")}),i.jsx("dd",{children:e.tokenSaved?p("integrations.conn.storedLocally"):p("integrations.conn.noToken")})]}),y&&i.jsxs("div",{children:[i.jsx("dt",{children:p("integrations.conn.server")}),i.jsx("dd",{children:y})]})]}),!n&&i.jsx("p",{className:"ig-stranded",children:p("integrations.conn.strandedDisconnect",{label:b})}),x.length>0&&i.jsx("ul",{className:"ig-warnings",children:x.map(R=>i.jsx("li",{children:R},R))}),n&&i.jsxs("div",{className:"ig-manage-actions",children:[i.jsx("button",{type:"button",className:"btn","aria-busy":C,"aria-disabled":a!==null||void 0,onClick:c,children:p(C?"integrations.conn.testing":"integrations.conn.test")}),i.jsx("button",{type:"button",className:"btn","aria-disabled":a!==null||void 0,onClick:R=>{a===null&&l(R.currentTarget)},children:p("integrations.conn.edit")})]}),o&&o.scope!=="disconnect"&&i.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text}),i.jsxs("div",{className:"ig-disconnect-section",children:[i.jsx("h3",{children:p("integrations.conn.removeTitle")}),i.jsx("p",{children:p("integrations.conn.removeBody")}),i.jsxs("div",{className:"ig-manage-actions","data-integration-disconnect-actions":!0,onBlur:R=>{s&&!R.currentTarget.contains(R.relatedTarget)&&h()},children:[i.jsx("button",{ref:f,type:"button","data-integration-disconnect":!0,className:`btn danger${s?" armed":""}`,"aria-busy":A,"aria-disabled":a!==null||void 0,onKeyDown:R=>{R.repeat&&R.preventDefault()},"aria-label":s?p("integrations.conn.confirmAria",{name:e.name}):p("integrations.conn.disconnectAria",{name:e.name}),onClick:R=>u(R.currentTarget),children:p(A?"integrations.conn.disconnecting":s?"integrations.conn.confirmDisconnect":"integrations.conn.disconnect")}),s&&i.jsx("button",{type:"button",className:"btn","data-integration-cancel-disconnect":!0,"aria-disabled":a!==null||void 0,"aria-label":p("integrations.conn.cancelDisconnect"),onClick:()=>{var R;a===null&&(h(),(R=f.current)==null||R.focus())},children:p("integrations.cancel")})]}),s&&i.jsx("p",{className:"ig-note",role:"status",children:p("integrations.conn.pressConfirm")}),(o==null?void 0:o.scope)==="disconnect"&&i.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text})]})]})}function f2e({onBeforeLeaveChange:e}={}){var ot;const t=se(),n=Xg(),{connections:a,error:s}=n,[o,r]=m.useState(null),c=m.useRef(null),l=m.useRef(new Map),u=m.useRef(null),h=m.useRef(0),[p,f]=m.useState(null),[b,v]=m.useState(""),w=m.useRef(null),T=m.useRef(null),[y,x]=m.useState(null),[C,A]=m.useState(null),E=m.useRef(null),[R,z]=m.useState(null),[I,_]=m.useState([]),[D,L]=m.useState(null),P=m.useRef(0),[O,j]=m.useState(null),M=m.useRef(null),F=m.useRef(new Map),U=m.useRef(null),H=m.useRef(0),[$,Y]=m.useState(!1),[W,G]=m.useState(null),Q=m.useRef(null),J=m.useRef(new Map),X=m.useRef(new Map);m.useEffect(()=>{const ce=lOe();ce&&(U.current=J.current.get(ce)??null,f(ce),j(ce),x({mode:"edit",id:ce}));const Ce=cOe();Ce&&x({mode:"add",kind:Ce})},[]),m.useEffect(()=>{var ce,Ce;!O||!a||(Ce=(ce=X.current.get(O))==null?void 0:ce.scrollIntoView)==null||Ce.call(ce,{block:"nearest"})},[O,a]),m.useEffect(()=>{if(!D)return;const ce=()=>{var Oe,at;(Oe=document.activeElement)!=null&&Oe.hasAttribute("data-integration-cancel-disconnect")&&((at=document.querySelector(".ig-manage-view [data-integration-disconnect]"))==null||at.focus()),L(null)},Ce=()=>{document.hidden&&ce()},Ke=window.setTimeout(()=>{var Oe;(Oe=document.querySelector("[data-integration-disconnect-actions]"))!=null&&Oe.contains(document.activeElement)||ce()},4e3);return window.addEventListener("blur",ce),document.addEventListener("visibilitychange",Ce),()=>{window.clearTimeout(Ke),window.removeEventListener("blur",ce),document.removeEventListener("visibilitychange",Ce)}},[D]);const te=(ce,Ce,Ke,Oe)=>_(at=>[...at.filter(ut=>ut.id!==ce),{id:ce,tone:Ce,text:Ke,scope:Oe}]),K=ce=>_(Ce=>Ce.filter(Ke=>Ke.id!==ce)),V=async(ce,Ce)=>{if(!E.current){E.current=ce,A(ce);try{await Ce()}finally{E.current=null,A(null)}}},ee=ce=>(Ce,Ke)=>void V("form",async()=>{z(null);try{const Oe=await aOe(ce,Ce,Ke||void 0);x(null),G(null),Y(!1),f(null),r(null),v(t("integrations.settings.added")),te(Oe.id,"ok",t("integrations.settings.savedTested",{name:Oe.account.name||Oe.account.login})),j(Oe.id),M.current=()=>{var ut;const at=l.current.get(Oe.kind)??J.current.get(Oe.id);return(ut=at==null?void 0:at.scrollIntoView)==null||ut.call(at,{block:"nearest"}),at}}catch(Oe){z(Oe instanceof Ks?Oe:new Ks("upstream",t("integrations.settings.saveFailed")))}}),de=ce=>(Ce,Ke)=>void V("form",async()=>{z(null);try{const{connection:Oe,validated:at}=await sOe(ce.id,{name:Ke,input:Ce});x(null),G(null),Y(!1),M.current=()=>T.current??(p?w.current:J.current.get(Oe.id)),te(Oe.id,"ok",at?t("integrations.settings.savedPassed",{name:Oe.account.name||Oe.account.login}):t("integrations.settings.saved"))}catch(Oe){z(Oe instanceof Ks?Oe:new Ks("upstream",t("integrations.settings.changeFailed")))}}),he=ce=>void V(`test:${ce.id}`,async()=>{L(null),K(ce.id);try{const Ce=await iOe(ce.id);te(ce.id,"ok",t("integrations.settings.testPassed",{name:Ce.account.name||Ce.account.login}))}catch(Ce){te(ce.id,"err",rr(Ce,t("integrations.settings.testFailed")))}}),me=(ce,Ce)=>{if(E.current)return;const Ke=Date.now(),Oe=zl({armedFor:D,target:ce.id,armedAt:P.current,now:Ke,gapMs:Rl});if(Oe==="arm"){Ce.focus({preventScroll:!0}),L(ce.id),P.current=Ke;return}Oe!=="ignore"&&(L(null),V(`delete:${ce.id}`,async()=>{try{await oOe(ce.id),g2e(ce.kind,ce.id),K(ce.id),(y==null?void 0:y.mode)==="edit"&&y.id===ce.id&&x(null),f(null);const at=(a??[]).filter(vt=>vt.kind===ce.kind&&vt.id!==ce.id);(!o||at.length===0)&&r(null),v(t("integrations.settings.disconnected"));const ut=document.activeElement;(ut===Ce||fa((ut==null?void 0:ut.tagName)??null))&&(M.current=()=>{var qe;const vt=(o&&at[0]?J.current.get(at[0].id):l.current.get(ce.kind))??F.current.get(ce.kind)??document.getElementById("settings-tab-integrations");return(qe=vt==null?void 0:vt.scrollIntoView)==null||qe.call(vt,{block:"nearest"}),vt})}catch(at){te(ce.id,"err",rr(at,t("integrations.settings.removeFailed")),"disconnect")}}))};m.useEffect(()=>{if(C!==null||W||!M.current)return;const ce=M.current();M.current=null,ce!=null&&ce.isConnected&&(ce.checkVisibility?ce.checkVisibility():ce.getClientRects().length>0)&&ce.focus({preventScroll:!0})},[a,p,o,y,C,W]);const be=a??[],ie=Qg(n),ne=["github","gitlab","jira"],ke=Az().filter(ce=>ie.has(ce.kind)||be.some(Ce=>Ce.kind===ce.kind)).sort((ce,Ce)=>ne.indexOf(ce.kind)-ne.indexOf(Ce.kind)),Se=Ez(n),ve=m.useCallback(()=>{x(null),f(null),r(null),Y(!1),G(null),z(null),L(null),M.current=()=>{const ce=U.current,Ce=ce==null?void 0:ce.closest(".settings-pane");return Ce&&(Ce.scrollTop=H.current),ce!=null&&ce.isConnected?ce:document.getElementById("settings-tab-integrations")}},[]),xe=m.useCallback(()=>{if(!o){ve();return}f(null),x(null),Y(!1),G(null),z(null),L(null),M.current=()=>{var Ke;const ce=(Ke=u.current)!=null&&Ke.isConnected?u.current:c.current,Ce=ce==null?void 0:ce.closest(".settings-pane");return Ce&&(Ce.scrollTop=ce===c.current?0:h.current),ce}},[o,ve]),Ee=m.useCallback(()=>{if(!p&&!o){ve();return}x(null),Y(!1),G(null),z(null),M.current=()=>T.current??(p?w.current:c.current)},[p,o,ve]),Ge=m.useCallback((ce,Ce=!1)=>{if(E.current)return;if(W&&Ce){G(null),requestAnimationFrame(()=>{var Oe;return(Oe=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:Oe.focus()});return}const Ke=Ce?y?Ee:p?xe:ve:()=>{x(null),f(null),r(null),ce()};$?G(()=>Ke):(Y(!1),Ke())},[$,W,y,p,Ee,xe,ve]);m.useEffect(()=>(e==null||e(y||p||o?Ge:null),()=>e==null?void 0:e(null)),[y,p,o,Ge,e]),m.useEffect(()=>{var ce;W&&((ce=Q.current)==null||ce.focus())},[W]),m.useEffect(()=>{var ce;p&&((ce=w.current)==null||ce.focus())},[p]),m.useEffect(()=>{var ce;o&&((ce=c.current)==null||ce.focus())},[o]);const Qe=(ce,Ce)=>{var Oe;if(E.current)return;M.current=null,G(null),v(""),L(null),p||o?T.current=Ce:(H.current=((Oe=Ce.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0,U.current=Ce,T.current=null),Y(!1),z(null),x(ce);const Ke=Ce.closest(".settings-pane");Ke&&(Ke.scrollTop=0)},Je=(ce,Ce)=>{var Oe,at;if(E.current)return;M.current=null,o?(u.current=Ce,h.current=((Oe=Ce.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0):(H.current=((at=Ce.closest(".settings-pane"))==null?void 0:at.scrollTop)??0,U.current=Ce),T.current=null,v(""),L(null),f(ce.id);const Ke=Ce.closest(".settings-pane");Ke&&(Ke.scrollTop=0)},He=(ce,Ce)=>{var at;const Ke=be.filter(ut=>ut.kind===ce);if(Ke.length===1){Je(Ke[0],Ce);return}if(E.current)return;M.current=null,H.current=((at=Ce.closest(".settings-pane"))==null?void 0:at.scrollTop)??0,U.current=Ce,u.current=null,h.current=0,v(""),L(null),r(ce);const Oe=Ce.closest(".settings-pane");Oe&&(Oe.scrollTop=0)},_e=(ce,Ce=!1)=>{const Ke=Ep(ce.kind),Oe=!Qo(n,ce.kind),at=wE(ce),ut=ce.account.login||ce.account.name,vt=ce.kind==="jira"?yE(ce):null;return i.jsx("div",{className:"ig-conn",ref:qe=>{qe?X.current.set(ce.id,qe):X.current.delete(ce.id)},children:i.jsxs("div",{className:"ig-summary-row",children:[i.jsxs("div",{className:"ig-summary-text",children:[i.jsx("span",{className:"ig-conn-name",children:Ce&&ce.name||Yc(ce)}),i.jsx("span",{className:"ig-conn-line",children:[Ce&&ce.name!==Yc(ce)?Yc(ce):"",ut,vt||(at?t("integrations.conn.lastVerifiedAt",{when:at}):t("integrations.conn.notVerified"))].filter(Boolean).join(" · ")||t("integrations.conn.noAccount")}),!ce.tokenSaved&&i.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")}),Oe&&i.jsx("span",{className:"ig-stranded",children:t("integrations.conn.strandedManage",{label:(Ke==null?void 0:Ke.label)??ce.kind})})]}),i.jsxs("button",{type:"button",className:"btn ig-manage",ref:qe=>{qe?J.current.set(ce.id,qe):J.current.delete(ce.id)},"aria-label":t("integrations.settings.manageAria",{label:(Ke==null?void 0:Ke.label)??ce.kind,name:ce.name,account:ut||Yc(ce)}),onClick:qe=>Je(ce,qe.currentTarget),children:[t("integrations.manage")," ",i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m6 4 4 4-4 4"})})]})]})},ce.id)},le=be.filter(ce=>!ke.some(Ce=>Ce.kind===ce.kind)),Re=o?Ep(o):null,ge=be.filter(ce=>ce.kind===o),Pe=be.find(ce=>ce.id===p),Fe=(y==null?void 0:y.mode)==="edit"?be.find(ce=>ce.id===y.id):void 0,Ve=(y==null?void 0:y.mode)==="add"?ke.find(ce=>ie.has(ce.kind)&&ce.kind===y.kind):Fe&&ke.find(ce=>ie.has(ce.kind)&&ce.kind===Fe.kind);return i.jsxs("div",{className:"ig-settings","data-view":y?"form":p?"connection":o?"provider":"overview",children:[y&&i.jsxs("div",{className:"ig-config-view",children:[i.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":C!==null||void 0,onClick:()=>Ge(Ee,!0),children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),p?t("integrations.settings.backToConn"):o?t("integrations.settings.backToList",{label:(Re==null?void 0:Re.label)??o}):t("integrations.settings.all")]}),W&&i.jsxs("div",{className:"ig-leave-confirm",role:"group","aria-labelledby":"ig-leave-title",children:[i.jsx("strong",{id:"ig-leave-title",children:t("integrations.settings.discardTitle")}),i.jsx("p",{children:t("integrations.settings.discardBody")}),i.jsxs("div",{className:"ig-form-actions",children:[i.jsx("button",{ref:Q,type:"button",className:"btn",onClick:()=>{G(null),requestAnimationFrame(()=>{var ce;return(ce=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:ce.focus()})},children:t("integrations.settings.keepEditing")}),i.jsx("button",{type:"button",className:"btn danger",onClick:()=>{const ce=W;G(null),Y(!1),x(null),ce()},children:t("integrations.settings.discard")})]})]}),i.jsx("div",{hidden:!!W,children:Ve?i.jsx(RPe,{def:Ve,existing:Fe,busy:C==="form",error:R,onDirtyChange:Y,onSubmit:y.mode==="add"?ee(y.kind):de(Fe),onCancel:()=>Ge(Ee,!0)},y.mode==="add"?y.kind:y.id):i.jsxs("div",{role:"status",children:[i.jsx("p",{children:t("integrations.settings.gone")}),i.jsx("button",{type:"button",className:"btn",onClick:Ee,children:t("integrations.settings.backToIntegrations")})]})})]}),o&&i.jsxs("div",{className:"ig-provider-view",hidden:y!==null||p!==null,children:[i.jsxs("div",{className:"ig-manage-navigation",children:[i.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":C!==null||void 0,onClick:()=>Ge(ve,!0),children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),t("integrations.settings.all")]}),Qo(n,o)&&i.jsx("button",{type:"button",className:"btn","aria-disabled":C!==null||void 0,onClick:ce=>Qe({mode:"add",kind:o},ce.currentTarget),children:t("integrations.settings.addConn",{label:(Re==null?void 0:Re.label)??o})})]}),i.jsx("h2",{ref:c,tabIndex:-1,className:"ig-managed-title",children:t("integrations.settings.connsTitle",{label:(Re==null?void 0:Re.label)??o})}),b&&i.jsx("p",{className:"ig-note",role:"status",children:b}),ge.length?i.jsx("div",{className:"ig-provider-connections",children:ge.map(ce=>_e(ce,!0))}):i.jsx("p",{role:"status",children:t("integrations.settings.noSaved")})]}),p&&i.jsxs("div",{className:"ig-manage-view",hidden:y!==null,children:[i.jsxs("div",{className:"ig-manage-navigation",children:[i.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":C!==null||void 0,onClick:()=>Ge(xe,!0),children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),o?t("integrations.settings.backToList",{label:(Re==null?void 0:Re.label)??o}):t("integrations.settings.all")]}),Pe&&Qo(n,Pe.kind)&&i.jsx("button",{type:"button",className:"btn","aria-disabled":C!==null||void 0,onClick:ce=>Qe({mode:"add",kind:Pe.kind},ce.currentTarget),children:t("integrations.settings.addConn",{label:((ot=Ep(Pe.kind))==null?void 0:ot.label)??Pe.kind})})]}),Pe?i.jsx(m2e,{connection:Pe,provider:Ep(Pe.kind),available:Qo(n,Pe.kind),busy:C,armed:D===p,note:I.find(ce=>ce.id===p),headingRef:w,onTest:()=>he(Pe),onEdit:ce=>Qe({mode:"edit",id:Pe.id},ce),onDisconnect:ce=>me(Pe,ce),onCancelDisconnect:()=>L(null)}):i.jsx("p",{role:"status",children:t("integrations.settings.noLongerSaved")})]}),i.jsxs("div",{className:"ig-overview",hidden:y!==null||p!==null||o!==null,children:[s&&i.jsxs("div",{className:"ig-list-error",role:"alert",children:[i.jsx("p",{children:s}),i.jsx("button",{type:"button",className:"btn",onClick:()=>void Qv(),children:t("integrations.retry")})]}),a===null&&!s&&i.jsxs("p",{className:"loader-line",role:"status",children:[i.jsx(Fg,{busy:!0}),t("integrations.settings.reading")]}),b&&i.jsx("p",{className:"ig-note",role:"status",children:b}),i.jsxs("div",{className:"ig-connection-list","data-setting":"integrations-connections",children:[a!==null&&i.jsx("div",{className:"ig-providers","data-setting":"integrations-add",id:Se==="all"?"integrations-add-title":void 0,children:[{id:"connected",title:t("integrations.settings.connectedGroup"),providers:ke.filter(ce=>be.some(Ce=>Ce.kind===ce.kind))},{id:"not-connected",title:t("integrations.settings.notConnectedGroup"),providers:ke.filter(ce=>!be.some(Ce=>Ce.kind===ce.kind))}].filter(ce=>ce.providers.length>0).map(ce=>i.jsx(gn,{id:`ig-group-${ce.id}`,title:ce.title,children:ce.providers.map(Ce=>{const Ke=be.filter(et=>et.kind===Ce.kind),Oe=Ke.length===1?Ke[0]:null,at=[...new Set(Ke.map(Yc))],ut=Oe&&wE(Oe),vt=(Oe==null?void 0:Oe.kind)==="jira"?yE(Oe):null,qe=Ke.length===0?t("integrations.settings.notConnected"):Oe?vt||(ut?t("integrations.conn.lastVerifiedAt",{when:ut}):t("integrations.conn.notVerified")):t("integrations.settings.count",{count:Ke.length}),dt=Ke.length===0?"":Oe?[Yc(Oe),Oe.account.login||Oe.account.name].filter(Boolean).join(" · "):`${at.slice(0,2).join(" · ")}${at.length>2?` · ${t("integrations.settings.moreInstances",{n:at.length-2})}`:""}`;return i.jsxs("section",{className:"ig-provider",id:`ig-provider-${Ce.kind}`,"aria-labelledby":`ig-provider-name-${Ce.kind}`,"data-setting":`integration-${Ce.kind}`,children:[i.jsxs("div",{className:"ig-summary-text ig-provider-content",children:[i.jsx("h3",{id:`ig-provider-name-${Ce.kind}`,children:Ce.label}),dt&&i.jsx("span",{className:"ig-conn-line",children:dt}),Oe&&!Oe.tokenSaved&&i.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")}),!ie.has(Ce.kind)&&i.jsx("span",{className:"ig-stranded",children:t("integrations.conn.unavailable",{label:Ce.label})})]}),i.jsx("span",{className:"ig-provider-state",children:qe}),i.jsx("button",{type:"button",className:`btn ig-manage${Ke.length?"":" primary"}`,"aria-disabled":C!==null||void 0,ref:et=>{const Ie=Ke.length?l.current:F.current;et?Ie.set(Ce.kind,et):Ie.delete(Ce.kind)},"aria-label":Ke.length?t("integrations.manageProvider",{label:Ce.label}):t("integrations.form.connect",{provider:Ce.label}),onClick:et=>Ke.length?He(Ce.kind,et.currentTarget):Qe({mode:"add",kind:Ce.kind},et.currentTarget),children:Ke.length?i.jsxs(i.Fragment,{children:[t("integrations.manage")," ",i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:i.jsx("path",{d:"m6 4 4 4-4 4"})})]}):t("integrations.form.connectBtn")})]},Ce.kind)})},ce.id))}),(le.length>0||ke.length===0&&Se!=="all"&&a!==null)&&i.jsxs(gn,{id:"integrations-list-title",title:t("integrations.settings.connections"),aside:i.jsx("span",{className:"settings-caption-count",children:le.length}),children:[le.map(ce=>_e(ce,!0)),be.length===0&&i.jsx("p",{className:"settings-row settings-row-status",children:t("integrations.settings.nothing")})]})]}),Se==="all"&&i.jsx(i.Fragment,{children:i.jsx("div",{className:"ig-overview-info",children:i.jsxs("details",{className:"ig-access",children:[i.jsx("summary",{children:t("integrations.settings.accessSummary")}),i.jsx("p",{children:t("integrations.settings.accessBody")})]})})})]})]})}function b2e({theme:e}){return i.jsx("span",{className:"appearance-preview","data-swatch":e,children:i.jsxs("svg",{viewBox:"0 0 112 56",preserveAspectRatio:"xMidYMid slice","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),i.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),i.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),i.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),i.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),i.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),i.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),i.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),i.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),i.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function k2e({theme:e,onTheme:t,singleKeys:n}){const a=se(),s=c=>{var p,f;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(c.key))return;c.preventDefault();const l=(p=c.target.closest("[data-theme-choice]"))==null?void 0:p.dataset.themeChoice,h=(io.indexOf(l??e)+(c.key==="ArrowLeft"||c.key==="ArrowUp"?-1:1)+io.length)%io.length;t(io[h]),(f=c.currentTarget.querySelectorAll('[role="radio"]')[h])==null||f.focus()},o=m.useRef(null),r=m.useRef(e);return m.useEffect(()=>{var u,h;const c=r.current;r.current=e;const l=document.activeElement;c===e||!l||!((u=o.current)!=null&&u.contains(l))||l.dataset.themeChoice!==c||(h=o.current.querySelector(`[data-theme-choice="${e}"]`))==null||h.focus()},[e]),i.jsx(gn,{id:"appearance-theme-caption",title:a("settings.theme.title"),list:!1,settingId:"theme",aside:n&&i.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:a("settings.theme.keyTip"),children:"T"}),children:i.jsx("div",{ref:o,className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:io.map(c=>i.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":c,"data-setting":`theme-${c}`,"aria-checked":e===c,tabIndex:e===c?0:-1,onClick:()=>t(c),children:[i.jsx(b2e,{theme:c}),i.jsxs("span",{className:"appearance-theme-name",children:[GG(c,a),i.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},c))})})}const v2e=[["smallest","settings.reading.size.smallest","11 px"],["smaller","settings.reading.size.smaller","12 px"],["default","settings.reading.size.default","13 px"],["larger","settings.reading.size.larger","15 px"],["largest","settings.reading.size.largest","17 px"]],w2e=[["tightest","settings.reading.density.tightest","30%"],["tighter","settings.reading.density.tighter","50%"],["compact","settings.reading.density.compact","70%"],["default","settings.reading.density.default","100%"],["comfortable","settings.reading.density.comfortable","140%"]];function y2e({textSize:e,density:t,onTextSize:n,onDensity:a}){const s=se(),o=e!=="default"||t!==ok;return i.jsx("button",{type:"button",className:"btn",disabled:!o,onClick:()=>{n("default"),a(ok)},children:s("settings.reading.reset")})}function x2e({textSize:e,density:t,onTextSize:n,onDensity:a}){const s=se();return i.jsxs(i.Fragment,{children:[i.jsxs(gn,{children:[i.jsx(Ot,{settingId:"text-size",name:s("settings.reading.sizeTitle"),nameId:"reading-size-label",note:s("settings.reading.sizeHelp"),noteId:"reading-size-help",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",name:"text-size","aria-labelledby":"reading-size-label","aria-describedby":"reading-size-help",value:e,onChange:o=>n(fbe.find(r=>r===o.target.value)??"default"),children:v2e.map(([o,r,c])=>i.jsxs("option",{value:o,children:[s(r)," ",c]},o))})})}),i.jsx(Ot,{settingId:"density",name:s("settings.reading.densityTitle"),nameId:"reading-density-label",note:s("settings.reading.densityHelp"),noteId:"reading-density-help",control:i.jsx(dc,{children:i.jsx("select",{className:"sm-select",name:"density","aria-labelledby":"reading-density-label","aria-describedby":"reading-density-help",value:t,onChange:o=>a(bbe.find(r=>r===o.target.value)??ok),children:w2e.map(([o,r,c])=>i.jsxs("option",{value:o,children:[s(r)," ",c]},o))})})})]}),i.jsx(gn,{id:"reading-preview-title",title:s("settings.reading.preview"),list:!1,children:i.jsxs("div",{className:"reading-preview",children:[i.jsxs("div",{className:"reading-preview-row",children:[i.jsxs("div",{children:[i.jsx("strong",{children:s("settings.reading.sample1")}),i.jsx("span",{children:s("settings.reading.sample1State")})]}),i.jsx("span",{className:"reading-preview-time",children:"4m"})]}),i.jsxs("div",{className:"reading-preview-row",children:[i.jsxs("div",{children:[i.jsx("strong",{children:s("settings.reading.sample2")}),i.jsx("span",{children:s("settings.reading.sample2State")})]}),i.jsx("span",{className:"reading-preview-time",children:"12m"})]})]})}),i.jsx("p",{className:"settings-foot",children:s("settings.reading.foot")})]})}function C2e({cli:e,running:t}){const n=se(),a=n("shell.terminal.versions",{product:an,cli:e.version,running:t}),s=i.jsx("code",{children:e.command});return e.auto==="pending"||e.auto==="running"?i.jsx(Ot,{as:"div",name:n("shell.terminal.name"),note:a,control:i.jsx("span",{className:"settings-read",children:e.auto==="running"?n("shell.terminal.updating"):n("shell.terminal.updatingSoon")}),children:i.jsx("span",{className:"settings-row-said",children:e.auto==="running"?n("shell.terminal.updatingNow"):ck(n("shell.terminal.soon"),"cmd",s)})}):i.jsx(Ot,{as:"div",name:n("shell.terminal.name"),note:e.auto==="failed"?a:n("shell.terminal.notUpdated",{versions:a}),control:i.jsx("span",{className:"settings-read",children:n("shell.terminal.needed")}),children:i.jsxs("span",{className:"settings-row-said",children:[e.auto==="failed"&&i.jsxs(i.Fragment,{children:[e.error?n("shell.terminal.failedWith",{error:e.error}):n("shell.terminal.failed")," "]}),ck(n("shell.terminal.run"),"cmd",s)]})})}const S2e="AGPL-3.0-only",T2e="https://github.com/BarganConstantin/ccdeck",N2e="https://github.com/sponsors/BarganConstantin";function A2e(e,t=S){return t("settings.about.pageBehind",{bundle:e})}function j2e(e,t){return vo(e)&&vo(t)&&lc(e,t)<0}function E2e(e,t,n=S){return e?{kind:"ready",to:e.version,name:n("settings.about.updateReady"),note:n("settings.about.updateReadyNote",{product:an,version:e.version})}:t?t.kind==="restart"?{kind:"notice",name:n("settings.about.updateInstalled"),note:n("settings.about.updateInstalledNote",{to:t.to,from:t.from})}:{kind:"notice",name:n("settings.about.updateAvailable"),note:n("settings.about.updateAvailableNote",{product:an,to:t.to,from:t.from})}:null}function R2e({version:e,notice:t,readyAppUpdate:n,updateRestarting:a,updateFailure:s,onUpdateRestart:o,doors:r,bundle:c="4.0.3"}){const l=se(),u=(e==null?void 0:e.running)??c,h=E2e(n,t,l);return i.jsxs(i.Fragment,{children:[i.jsxs(gn,{id:"settings-about-caption",title:l("settings.about.version"),children:[i.jsx(Ot,{as:"div",settingId:"version",name:l("settings.about.version"),note:j2e(c,e==null?void 0:e.running)?A2e(c,l):void 0,control:i.jsx("span",{className:"settings-read",children:u})}),(e==null?void 0:e.terminalCli)&&i.jsx(C2e,{cli:e.terminalCli,running:u}),h&&i.jsx(z2e,{offer:h,restarting:a,failure:s,onRestart:o,onUpdate:r.update}),i.jsx(Ot,{as:"div",settingId:"whats-new",name:l("settings.about.whatsNew"),control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":l("settings.about.openWhatsNew"),onClick:r.whatsNew,children:l("settings.about.open")})})]}),i.jsxs(gn,{id:"settings-about-help-caption",title:l("settings.about.helpGroup"),children:[i.jsx(Ot,{as:"div",settingId:"tour",name:l("settings.about.tour"),control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":l("settings.about.startTour"),onClick:r.tour,children:l("settings.about.start")})}),i.jsx(Ot,{as:"div",settingId:"feedback",name:l("settings.about.feedback"),control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":l("settings.about.openFeedback"),onClick:r.feedback,children:l("settings.about.open")})})]}),i.jsxs(gn,{id:"settings-about-project-caption",title:l("settings.about.projectGroup"),children:[i.jsx(Ot,{as:"div",settingId:"licence",name:l("settings.about.licence"),note:l("settings.about.licenceNote"),control:i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"settings-read",children:S2e}),i.jsxs("a",{className:"settings-link",href:T2e,target:"_blank",rel:"noreferrer",children:[l("settings.about.source"),i.jsx("span",{className:"vis-hidden",children:l("settings.about.sourceHidden")})]})]})}),i.jsx(Ot,{as:"div",settingId:"sponsor",name:l("settings.about.sponsor"),note:l("settings.about.sponsorNote"),control:i.jsxs("a",{className:"settings-link",href:N2e,target:"_blank",rel:"noreferrer",children:[l("settings.about.sponsorLink"),i.jsx("span",{className:"vis-hidden",children:l("settings.about.sponsorHidden")})]})})]})]})}function z2e({offer:e,restarting:t,failure:n,onRestart:a,onUpdate:s}){const o=se();if(e.kind==="notice")return i.jsx(Ot,{as:"div",name:e.name,note:e.note,control:i.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:s,children:o("settings.about.updateBtn")})});const r=zOe(e.to,t),c=n&&n.version===e.to?U8(n.failure,n.version):"";return i.jsx(Ot,{as:"div",name:e.name,note:e.note,control:i.jsx("button",{type:"button",className:"btn",onClick:()=>a(e.to),"aria-busy":t||void 0,"aria-label":r.label,title:r.title,children:r.text}),children:i.jsx("span",{className:"settings-row-said",role:"status",children:c})})}function q2e(e,t){return t&&(e!=null&&e.checkDisabled)?"app":(e==null?void 0:e.canRestart)===!1?"no-restart":e!=null&&e.checkDisabled?"checks-off":"plain"}const _2e={plain:"settings.updates.plainDetails","checks-off":"settings.updates.checksOffDetails","no-restart":"settings.updates.noRestartDetails"};function L2e({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:a=lr()}){const s=se(),o=q2e(n,a),r=o==="no-restart"?s("settings.updates.noRestartNote"):o==="checks-off"?s("settings.updates.checksOffNote"):null;return i.jsx(gn,{id:o==="app"?void 0:"settings-updates-caption",title:o==="app"?void 0:s("settings.updates.title"),children:o==="app"?i.jsx(Ot,{as:"div",settingId:"auto-update",name:s("settings.updates.title"),note:s("settings.updates.appNote")}):i.jsx(Ot,{settingId:"auto-update",name:s("settings.updates.label"),nameId:"settings-auto-update-label",note:s("settings.updates.plainNote"),details:s(_2e[o]),noteId:"settings-auto-update-note",control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-auto-update-label","aria-describedby":r?"settings-auto-update-note settings-auto-update-info":"settings-auto-update-note",onClick:t,children:i.jsx("span",{className:"switch-knob"})}),children:r&&i.jsx(_z,{id:"settings-auto-update-info",children:r})})})}function P2e({character:e,onCharacter:t}){const n=se(),a=m.useRef([]);function s(o,r){var l;const c=Fu(o,r,mb.length,"vertical");c.kind==="select"&&(o.preventDefault(),t(mb[c.index].id),(l=a.current[c.index])==null||l.focus())}return i.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":n("settings.character.choose"),"data-setting":"character-choice",children:mb.map((o,r)=>i.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===o.id,tabIndex:e===o.id?0:-1,ref:c=>{a.current[r]=c},onClick:()=>t(o.id),onKeyDown:c=>s(c,r),children:[i.jsx("span",{className:"character-preview",children:i.jsx(X5,{character:o.id,act:null,facing:"right"})}),i.jsx("span",{children:o.name}),i.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:i.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},o.id))})}function O2e({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:a}){const s=se();return i.jsxs(gn,{id:"appearance-character-caption",title:s("settings.character.title"),list:!1,children:[i.jsx("div",{className:"settings-list",children:i.jsx(Ot,{settingId:"character",name:s("settings.character.show"),nameId:"appearance-character-label",note:s("settings.character.note"),noteId:"appearance-character-note",control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:i.jsx("span",{className:"switch-knob"})})})}),i.jsx(P2e,{character:n,onCharacter:a})]})}const w7="agent-dag.view";function _k(e=gt){return e(w7)==="workspace"?"workspace":"board"}function y7(e,t=yt){t(w7,e)}function x7(e,t){return e.enabled&&e.supported!==!1&&!t}function M2e(){const[e,t]=m.useState(()=>_k()),n=m.useCallback(a=>{t(a),y7(a)},[]);return{stored:e,set:n}}const em={status:"/api/terminal/engine",install:"/api/terminal/engine/install",installFile:"/api/terminal/engine/install-file",cancel:"/api/terminal/engine/cancel",remove:"/api/terminal/engine/remove"},dl=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function I2e(e){if(!dl(e)||typeof e.platform!="string"||typeof e.supported!="boolean")return null;const t=dl(e.installed)&&typeof e.installed.version=="string"?{version:e.installed.version,bytes:typeof e.installed.bytes=="number"?e.installed.bytes:0}:null,n=dl(e.job)&&typeof e.job.id=="string"&&typeof e.job.phase=="string"?{id:e.job.id,phase:e.job.phase,received:typeof e.job.received=="number"?e.job.received:0,total:typeof e.job.total=="number"?e.job.total:null,source:e.job.source==="file"?"file":"download",startedAt:typeof e.job.startedAt=="number"?e.job.startedAt:0}:null,a=dl(e.last)&&typeof e.last.id=="string"&&typeof e.last.outcome=="string"?e.last:null;return{platform:e.platform,app:typeof e.app=="string"?e.app:null,fixPath:typeof e.fixPath=="string"?e.fixPath:null,supported:e.supported,blocked:typeof e.blocked=="string"?e.blocked:null,canInstallFile:e.canInstallFile===!0,installed:t,present:e.present===!0,pinned:typeof e.pinned=="string"?e.pinned:null,job:n,last:a,recovered:e.recovered===!0,elsewhere:e.elsewhere===!0}}const tm=(e,t)=>fetch(e,t);async function D2e(e=tm){try{const t=await e(em.status,{method:"GET"});if(!t.ok)return null;const n=await t.json().catch(()=>null);return dl(n)&&n.ok===!0?I2e(n.engine):null}catch{return null}}async function ew(e,t,n){try{const a=await n(e,{method:"POST",...t}),s=await a.json().catch(()=>null);return dl(s)&&s.ok===!0?{ok:!0,...typeof s.id=="string"?{id:s.id}:{}}:{ok:!1,code:dl(s)&&typeof s.code=="string"?s.code:a.status===404?"turned-off":"failed"}}catch{return{ok:!1,code:"unreachable"}}}const Pz=()=>({headers:{"Content-Type":"application/json"},body:"{}"}),F2e=(e=tm)=>ew(em.install,Pz(),e),B2e=(e=tm)=>ew(em.cancel,Pz(),e),U2e=(e=tm)=>ew(em.remove,Pz(),e),W2e=(e,t=tm)=>ew(em.installFile,{headers:{"Content-Type":"application/octet-stream"},body:e},t);function H2e(e){const[t,n]=e.split("-"),a=t==="darwin"?"macOS":t==="win32"?"Windows":t==="linux"?"Linux":t,s=t==="darwin"?n==="arm64"?"Apple silicon":n==="x64"?"Intel":n:n==="arm64"?"ARM64":n==="arm"?"ARM 32-bit":n==="ia32"?"x86 32-bit":n;return s?`${a} · ${s}`:a}function C7(e,t){const n=o=>{const r=/^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(o);return r?[Number(r[1]),Number(r[2]),Number(r[3]),r[4]?0:1]:null};if(!e||!t)return!1;const a=n(e),s=n(t);if(!a||!s)return!1;for(let o=0;o<4;o++)if(a[o]!==s[o])return a[o]<s[o];return!1}const ab=e=>(e/1e6).toFixed(1),G2e=400,V2e=1500,L4e=15e3,K2e=3e3,xE="agent-dag.engineInstall.job";function $2e(){try{return sessionStorage.getItem(xE)}catch{return null}}function J2e(e){try{e?sessionStorage.setItem(xE,e):sessionStorage.removeItem(xE)}catch{}}const Y2e=new Set(["check-failed","wrong-machine","downgrade"]);function P4e({status:e,code:t,mine:n,watched:a,retried:s=!1}){if(e===void 0)return{state:"checking"};if(e===null)return{state:"plain"};const{job:o,last:r}=e;if(o)return o.id!==n?{state:"elsewhere",job:o}:o.phase==="downloading"?{state:"downloading",job:o}:{state:"verifying",job:o};if(e.elsewhere)return{state:"elsewhere",job:null};if(r&&a.has(r.id)){if(r.outcome==="done")return s?{state:"start-failed"}:{state:"ready",version:r.version};if(r.outcome==="failed"){const u=r.code;return u==="offline"?{state:"offline",received:r.received??0,total:r.total??null}:u==="no-permission"?{state:"permission",fixPath:e.fixPath}:Y2e.has(u)?{state:"check",code:u,step:r.step}:u==="unsafe-folder"?{state:"folder",install:!0}:u==="no-space"?{state:"no-space"}:u==="not-published"?{state:"unavailable",file:e.canInstallFile}:u==="elsewhere"?{state:"elsewhere",job:null}:{state:"failed",step:r.step}}}if(!e.supported||t==="unsupported")return{state:"unsupported"};const c=e.blocked===null,l=e.canInstallFile;return e.installed?e.recovered?{state:"recovered",version:e.installed.version}:t==="failed"||s?{state:"start-failed"}:e.pinned&&C7(e.installed.version,e.pinned)?{state:"update",installed:e.installed.version,pinned:e.pinned,download:c,file:l}:{state:"ready",version:e.installed.version}:t==="unsafe-folder"?{state:"folder",install:!1}:e.blocked==="no-keys"||e.blocked==="not-published"||e.blocked==="unsupported"?{state:"unavailable",file:l}:{state:"ask",download:c,file:l,downloadOff:e.blocked==="download-disabled"}}function O4e(e,t,n){const a=m.useRef(n);m.useEffect(()=>{a.current=n}),m.useEffect(()=>{if(!e)return;const s=setTimeout(()=>a.current(),t);return()=>clearTimeout(s)},[e,t])}function Z2e(e){if(e.length<2)return null;const t=e[0],n=e[e.length-1],a=n.at-t.at;return a<500?null:Math.max(0,(n.received-t.received)/(a/1e3))}function X2e(e=!0){const[t,n]=m.useState(void 0),[a,s]=m.useState(()=>$2e()),[o,r]=m.useState(!1),[c,l]=m.useState(null),u=m.useRef(new Set),h=m.useRef([]),[p,f]=m.useState(null),b=m.useRef(!0);m.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const v=m.useCallback(z=>{if(!b.current)return;const I=z==null?void 0:z.job;if(I){if(u.current.add(I.id),I.phase==="downloading"){const _=Date.now();h.current=[...h.current.filter(D=>_-D.at<=K2e),{at:_,received:I.received}],f(Z2e(h.current))}}else h.current=[],f(null);n(z)},[]),w=m.useCallback(async()=>{const z=await D2e();return v(z),z},[v]);m.useEffect(()=>{e&&w()},[e,w]);const T=!!t&&(!!t.job||t.elsewhere),y=!!(t!=null&&t.job)&&t.job.id===a;m.useEffect(()=>{if(!e||!T)return;const z=setTimeout(()=>{w()},y?G2e:V2e);return()=>clearTimeout(z)},[e,T,y,t,w]);const x=m.useCallback(async z=>{r(!0),l(null);const I=await z();b.current&&(I.ok&&I.id?(u.current.add(I.id),s(I.id),J2e(I.id)):I.ok||l(I.code),await w(),b.current&&r(!1))},[w]),C=m.useCallback(()=>x(()=>F2e()),[x]),A=m.useCallback(z=>x(()=>W2e(z)),[x]),E=m.useCallback(async()=>{r(!0),await B2e(),await w(),b.current&&r(!1)},[w]),R=m.useCallback(async()=>{r(!0),l(null);const z=await U2e();return!z.ok&&b.current&&l(z.code),await w(),b.current&&r(!1),z.ok},[w]);return{status:t,mine:a,watched:u.current,speed:p,pending:o,refused:c,refresh:w,install:C,installFile:A,cancel:E,remove:R}}function S7(e){return e!=null&&x7({enabled:e.on,supported:e.supported},e.phone===!0)&&e.failed!==!0}function Q2e(e,t){return e("settings.terminal.short")}function eBe(e,t=!1){return e(t?"settings.terminal.offDetailsWindows":"settings.terminal.offDetails")}function tBe(){var b;const e=se(),t=X2e(!0),[n,a]=m.useState(!1),s=t.status;if(!s||!s.supported)return null;const o=H2e(s.platform),r=s.job,c=s.blocked===null,l=!!s.installed&&!!s.pinned&&C7(s.installed.version,s.pinned),u=((b=s.last)==null?void 0:b.outcome)==="failed"&&t.watched.has(s.last.id);let h,p=null,f=null;if(r){const v=r.id===t.mine;if(h=v?s.installed&&s.pinned?e("settings.terminal.engine.updating",{from:s.installed.version,to:s.pinned}):e("settings.terminal.engine.installing",{version:s.pinned??""}):e("settings.terminal.engine.elsewhere"),r.phase==="downloading"){const w=r.total?Math.min(1,r.received/r.total):null,T=r.total?e("board.stage.setupProgress",{received:ab(r.received),total:ab(r.total)}):e("board.stage.setupReceived",{received:ab(r.received)});f=i.jsxs("span",{className:"settings-engine-progress",children:[i.jsx("span",{className:"ts-setup-bar ts-eng-bar",role:"progressbar","aria-label":h,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":w==null?void 0:Math.round(w*100),"aria-valuetext":T,"data-unknown":w==null||void 0,children:i.jsx("i",{className:"ts-setup-fill",style:w==null?void 0:{transform:`scaleX(${w})`}})}),i.jsx("span",{className:"ts-eng-line",children:T})]}),v&&(p=i.jsx("button",{type:"button",className:"btn","aria-busy":t.pending||void 0,onClick:()=>{t.cancel()},children:e("common.cancel")}))}}else s.elsewhere?h=e("settings.terminal.engine.elsewhere"):s.installed?(h=e("settings.terminal.engine.verified",{version:s.installed.version,platform:o}),p=i.jsx("button",{type:"button",className:"btn","aria-busy":t.pending||void 0,onClick:()=>{if(l&&c){t.install();return}t.refresh().then(()=>{a(!0),setTimeout(()=>a(!1),2e3)})},children:e(n?"settings.terminal.engine.upToDate":"settings.terminal.engine.checkUpdate")})):s.blocked==="no-keys"||s.blocked==="not-published"?h=e("settings.terminal.engine.notAvailable"):(h=e("settings.terminal.engine.notInstalled"),c&&(p=i.jsx("button",{type:"button",className:"btn primary","aria-busy":t.pending||void 0,onClick:()=>{t.install()},children:e("settings.terminal.engine.install")})));return u&&!r&&(h=`${h} ${e("settings.terminal.engine.failed")}`),i.jsxs(i.Fragment,{children:[i.jsx(Ot,{as:"div",settingId:"terminal-engine",name:e("settings.terminal.engine.name"),nameId:"settings-engine-label",note:h,noteId:"settings-engine-note",control:p,children:f}),s.installed&&!r&&i.jsx(Ot,{as:"div",settingId:"terminal-engine-remove",name:e("settings.terminal.engine.removeName"),note:e("settings.terminal.engine.removeNote",{size:ab(s.installed.bytes)}),control:i.jsx("button",{type:"button",className:"btn","aria-busy":t.pending||void 0,onClick:()=>{t.remove()},children:e("settings.terminal.engine.remove")})})]})}function nBe({terminal:e}){const t=se(),n=e.supported===!1&&!e.on,a=e.supported===!1;return i.jsxs(gn,{id:"settings-experimental-caption",title:t("settings.experimental.group"),list:!1,children:[i.jsxs("div",{className:"settings-list",children:[i.jsx(Ot,{settingId:"terminal",name:t("settings.search.commandPanel"),nameId:"settings-terminal-label",note:Q2e(t),noteId:"settings-terminal-note",details:a?void 0:eBe(t,e.windows),control:i.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e.on,"aria-labelledby":"settings-terminal-label","aria-describedby":a?"settings-terminal-note settings-terminal-unavailable":"settings-terminal-note",disabled:n,onClick:e.toggle,children:i.jsx("span",{className:"switch-knob"})})}),e.on&&!a&&i.jsx(tBe,{})]}),a&&i.jsx("p",{className:"settings-note",id:"settings-terminal-unavailable",children:t("settings.terminal.unsupported")})]})}const OW="settings-search-field",T7="settings-search-results",CE=e=>`settings-result-${e}`;function aBe({inputRef:e,query:t,onQuery:n,results:a,active:s,onActive:o,onOpen:r}){const c=se(),l=t.trim()!=="",u=l&&a.length>0,h=p=>{if(p.nativeEvent.isComposing)return;const f=Ife(p.key,t,l?a.length:0,s);f.kind!=="pass"&&(p.preventDefault(),f.kind==="move"?o(f.index):f.kind==="open"?r(a[f.index]):(p.stopPropagation(),n("")))};return i.jsxs("div",{className:"settings-search",children:[i.jsx("label",{className:"vis-hidden",htmlFor:OW,children:c("settings.search.label")}),i.jsx(Ze,{name:"search",className:"settings-search-glyph"}),i.jsx("input",{ref:e,id:OW,type:"search",className:"settings-filter-field settings-search-field",placeholder:c("settings.search.label"),autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":u,"aria-controls":u?T7:void 0,"aria-activedescendant":u?CE(Math.min(s,a.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:p=>n(p.target.value),onKeyDown:h})]})}function sBe({query:e,results:t,active:n,onOpen:a}){const s=se(),o=JG(t.length,e);return m.useEffect(()=>{var r,c;(c=(r=document.getElementById(CE(n)))==null?void 0:r.scrollIntoView)==null||c.call(r,{block:"nearest"})},[n]),i.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[i.jsx("div",{className:"settings-pane-head",children:i.jsxs("div",{className:"settings-pane-heading",children:[i.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:s("settings.search.title")}),i.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:o})]})}),t.length>0&&i.jsx("div",{className:"settings-group",children:i.jsx("div",{className:"settings-list",id:T7,role:"listbox","aria-label":s("settings.search.results"),children:t.map((r,c)=>i.jsxs("button",{type:"button",role:"option",id:CE(c),className:"settings-result",tabIndex:-1,"aria-selected":c===n,"aria-label":Lfe(r),"data-highlighted":c===n,onMouseDown:l=>l.preventDefault(),onClick:()=>a(r),children:[i.jsx(eR,{section:r.section}),i.jsxs("span",{className:"settings-result-text",children:[i.jsx("span",{className:"settings-result-name",children:r.label}),i.jsx("span",{className:"settings-result-place",children:Q1(r)})]})]},r.id))})})]})}function iBe({query:e,count:t}){return i.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?JG(t,e):""})}const oBe=1500,rBe=3e3,cBe=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function lBe(e){if(e.matches(Gb)&&!e.disabled)return e;const t=e.querySelector('input[type="radio"]:checked, [role="radio"][aria-checked="true"]');if(t)return t;const n=Array.from(e.querySelectorAll(Gb)).filter(a=>i5({disabled:a.disabled,tabIndex:a.tabIndex,rendered:cBe(a)}));return n.find(a=>a.closest(".settings-list")!=null)??n[0]??null}function dBe(e,t,n){const[a,s]=m.useState(null),o=m.useRef(void 0),r=m.useRef(null);return m.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=r.current)==null||c.removeAttribute("data-jumped")},[]),m.useEffect(()=>{const c=e.current;if(!a||!t||!c)return;const l=()=>c.querySelector(`[data-setting="${CSS.escape(a)}"]`),u=b=>{var w,T;s(null);const v=b.offsetHeight>c.clientHeight-48;b.scrollIntoView({block:v?"start":"center"}),(w=lBe(b))==null||w.focus({preventScroll:!0}),window.clearTimeout(o.current),(T=r.current)==null||T.removeAttribute("data-jumped"),b.offsetWidth,b.setAttribute("data-jumped",""),r.current=b,o.current=window.setTimeout(()=>{b.removeAttribute("data-jumped"),r.current===b&&(r.current=null)},oBe)},h=l();if(h){u(h);return}const p=new MutationObserver(()=>{const b=l();b&&(p.disconnect(),window.clearTimeout(f),u(b))});p.observe(c,{childList:!0,subtree:!0});const f=window.setTimeout(()=>{p.disconnect(),s(null)},rBe);return()=>{p.disconnect(),window.clearTimeout(f)}},[e,a,t,n]),s}const uBe=m.lazy(()=>Xs(()=>import("./AccountSection-C0_ISsSw.js"),__vite__mapDeps([6,5])));function hBe({section:e,landOn:t,onSection:n,onClose:a,providers:s,sound:o,tones:r,customTones:c,notify:l,appearance:u,versionCheck:h,desktopUpdate:p,restart:f,doors:b,terminal:v,account:w}){const T=(w==null?void 0:w.on)===!0||(w==null?void 0:w.vetoed)===!0,y=se(),x=m.useRef(null),C=m.useCallback(Ie=>{x.current=Ie},[]);function A(Ie,ct=!1){x.current?(X(""),x.current(Ie,ct),requestAnimationFrame(()=>{var Nt,Le;return(Le=(Nt=R.current)==null?void 0:Nt.scrollIntoView)==null?void 0:Le.call(Nt,{block:"nearest",inline:"nearest"})})):Ie()}const E=()=>A(a,!0),R=m.useRef(null),z=Zt(E,{focusRef:R}),I=tn(()=>A(a)),_=m.useRef([]),D=Xg(),L=Ez(D),P=Eme(L,e,s.claude),O=Ame({account:T,drawn:P}),j=jme(e,O),M=Ws("(max-width: 640px)"),[F,U]=m.useState(""),[H,$]=m.useState(0),Y=m.useRef(null),W=m.useRef(null),G=F.trim()!=="",Q=m.useMemo(()=>Mfe(F,$G(s.claude,L,Qg(D))),[F,s.claude,L,D,y]),J=dBe(W,!G,e),X=Ie=>{U(Ie),$(0)};m.useEffect(()=>{t&&J(t)},[t,J]);const te=Ie=>{A(()=>{X(""),n(Ie),requestAnimationFrame(()=>{var ct;return(ct=document.getElementById(`settings-tab-${Ie}`))==null?void 0:ct.focus()})})},K=Ie=>{A(()=>{X(""),n(Ie.section),gv(Ie)||J(Ie.id)})};m.useEffect(()=>{const Ie=ct=>{var Ht,Mt;if(!Pme(ct))return;const Nt=z.current,Le=ct.target;!Nt||!(Le===document.body||Le===document.documentElement||Le&&Nt.contains(Le))||(ct.preventDefault(),(Ht=Y.current)==null||Ht.focus(),(Mt=Y.current)==null||Mt.select())};return window.addEventListener("keydown",Ie),()=>window.removeEventListener("keydown",Ie)},[z]),m.useEffect(()=>{var Ie,ct,Nt,Le;Rme((Ie=document.activeElement)==null?void 0:Ie.id,e)&&((ct=R.current)==null||ct.focus()),(Le=(Nt=R.current)==null?void 0:Nt.scrollIntoView)==null||Le.call(Nt,{block:"nearest",inline:"nearest"})},[e]);const V=SFe();m.useEffect(()=>{Ai(null)},[e]),m.useEffect(()=>()=>Ai(null),[]);const{theme:ee,setTheme:de,characterEnabled:he,setCharacterEnabled:me,character:be,setCharacter:ie}=u,ne=sa(),ke=Ie=>{const ct=Fu(Ie,j,O.length,"vertical");ct.kind!=="pass"&&(Ie.preventDefault(),A(()=>{var Nt;X(""),n(O[ct.index].id),(Nt=_.current[ct.index])==null||Nt.focus()}))},Se=Ie=>{Ie.key===" "&&Ie.stopPropagation()},{soundOn:ve,toggleSound:xe}=o,{tonePrefs:Ee,previewTone:Ge,changeTone:Qe}=r,{customSelections:Je,customAssets:He,clearCustomOnly:_e,selectCustomTone:le,importNotificationAudio:Re,createNotificationVoice:ge,renameCustomAsset:Pe,deleteCustomAsset:Fe,previewCustomAsset:Ve}=c,{notifyPermission:ot,notifyOn:ce,notifyVetoed:Ce,toggleNotify:Ke,notifySupported:Oe,askForNotifications:at,accountNotify:ut,toggleAccountNotify:vt}=l,qe=O[j].id,dt=(()=>{switch(qe){case"radar":return i.jsx(KFe,{onOpen:b.radar});case"claude":return i.jsx(d2e,{});case"appearance":return i.jsxs(i.Fragment,{children:[i.jsx(k2e,{theme:ee,onTheme:de,singleKeys:ne}),i.jsx(O2e,{characterEnabled:he,character:be,onCharacter:ie,onToggleCharacter:()=>me(Ie=>!Ie)})]});case"reading":return i.jsx(x2e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity});case"keyboard":return i.jsx(qFe,{singleKeys:ne,onToggleSingleKeys:()=>O5(!ne),workspace:S7(v)});case"notifications":return i.jsx(_Fe,{notifyOn:ce,onToggleNotify:Ke,notifyVetoed:Ce,notifyPermission:Oe?ot:"unsupported",onAskNotify:at,accountNotify:ut,onToggleAccountNotify:vt});case"sounds":return i.jsx(VFe,{soundOn:ve===!0,onToggleSound:xe,prefs:Ee,claudeHere:s.claude,onLevel:(Ie,ct)=>Qe(Ie,{level:ct}),onFigure:(Ie,ct)=>Qe(Ie,{figure:ct}),onPreview:Ie=>Ge(Ie),customAssets:He,customSelections:Je,onBuiltInSelected:_e,onCustomSelected:le,onImportCustom:Re,onCreateVoice:ge,onRenameCustom:Pe,onPreviewCustom:Ve,onDeleteCustom:Fe});case"integrations":return i.jsx(f2e,{onBeforeLeaveChange:C});case"data":return i.jsx(h2e,{});case"account":return i.jsx(m.Suspense,{fallback:null,children:i.jsx(uBe,{vetoed:(w==null?void 0:w.on)!==!0})});case"about":return i.jsx(R2e,{version:h.version,notice:h.notice,readyAppUpdate:p.readyAppUpdate,updateRestarting:p.desktopUpdateRestarting,updateFailure:p.desktopUpdateFailure,onUpdateRestart:Ie=>{p.askDesktopUpdateRestart(Ie)},doors:b});default:return i.jsxs(i.Fragment,{children:[i.jsx(yFe,{}),i.jsxs(NFe,{children:[s.claude&&i.jsx(EW,{provider:"Claude"}),i.jsx(EW,{provider:"Codex"}),s.claude&&i.jsx(TFe,{})]}),i.jsx(L2e,{autoRestart:f.autoRestart,onToggleAutoRestart:f.toggleAutoRestart,version:h.version}),i.jsx(EFe,{claudeHere:s.claude,codexHere:s.codex,singleKeys:ne,doors:b}),v&&i.jsx(nBe,{terminal:v})]})}})(),et=e==="reading"?i.jsx(y2e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity}):e==="integrations"&&D.connections!==null?i.jsx("span",{className:"ig-total",children:y("settings.savedConnections",{count:D.connections.length})}):null;return i.jsxs(dn,{scrim:I,dialogRef:z,id:"settings",className:"settings-modal",labelledBy:"settings-title",onKeyDown:Se,children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"settings-title",className:"modal-tool-name",children:y("settings.title")})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>A(a),"aria-label":y("settings.close"),title:y("settings.closeTip"),children:"×"})})]}),i.jsxs("div",{className:"settings-body",children:[i.jsxs("div",{className:"settings-side",children:[i.jsx(aBe,{inputRef:Y,query:F,onQuery:X,results:Q,active:H,onActive:$,onOpen:K}),i.jsx(iBe,{query:F,count:Q.length}),i.jsx("div",{className:"settings-nav",role:"tablist","aria-label":y("settings.sections"),"aria-orientation":M?"horizontal":"vertical",onKeyDown:ke,children:O.map((Ie,ct)=>i.jsx("button",{ref:Nt=>{_.current[ct]=Nt,Ie.id===e&&(R.current=Nt)},type:"button",role:"tab",id:`settings-tab-${Ie.id}`,className:"settings-tab","aria-selected":Ie.id===e,"aria-controls":"settings-pane",tabIndex:Ie.id===e?0:-1,onClick:()=>te(Ie.id),children:i.jsx("span",{className:"settings-tab-label",children:Ie.label})},Ie.id))})]}),i.jsxs("div",{ref:W,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:G||void 0,children:[i.jsxs("div",{className:"settings-pane-head",children:[i.jsxs("div",{className:"settings-pane-heading",children:[i.jsx("h2",{className:"settings-pane-title",children:O[j].label}),i.jsx("p",{className:"settings-pane-note",children:O[j].note})]}),et]}),V&&i.jsx(jR,{banner:!0,line:V.line,onDismiss:()=>Ai(null),onAnswer:CFe},V.serial),dt]},e),G&&i.jsx(sBe,{query:F,results:Q,active:H,onOpen:K})]})]})}function pBe({tool:e,cwd:t,onClose:n}){const a=se(),s=Zt(n),o=tn(n),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",c=m.useRef({of:null});c.current.of!==e&&(c.current={of:e}),e.input!==void 0&&(c.current.input=e.input),e.response!==void 0&&(c.current.response=e.response);const l=c.current.input??e.inputPreview,u=c.current.response??e.errorPreview,h=e.trimmed===!0&&c.current.input===void 0&&c.current.response===void 0,p=m.useMemo(()=>{const f=bje(e.name,l,u);return{input:f.input.map((b,v)=>i.jsx(MW,{block:b,cwd:t},v)),response:f.response.map((b,v)=>i.jsx(MW,{block:b,cwd:t},v)),copyInput:KM(e.name,"input",l),copyResponse:KM(e.name,"response",u)}},[e.name,l,u,t]);return i.jsxs(dn,{scrim:o,dialogRef:s,className:"tool-modal",labelledBy:"tool-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),i.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",children:Sce(e,a("insights.tool.inflight"))}),i.jsx(Za,{onClick:n,label:a("insights.audit.closeEsc")})]})]}),i.jsxs("section",{className:"modal-body",children:[h&&i.jsx("div",{className:"modal-section",children:i.jsx("p",{className:"modal-note",children:a("insights.tool.released")})}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("div",{className:"tm-head",children:[i.jsx("h4",{children:a("insights.cost.inputTitle")}),i.jsx(IW,{text:p.copyInput,what:"input"})]}),p.input]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("div",{className:"tm-head",children:[i.jsxs("h4",{children:[a("insights.tool.response"),r==="err"&&i.jsx("span",{className:"err-tag",children:a("insights.tool.error")})]}),e.endedAt!=null&&i.jsx(IW,{text:p.copyResponse,what:"response"})]}),e.endedAt==null?i.jsx("pre",{children:a("insights.tool.waiting")}):p.response]})]})]})}const gBe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function MW({block:e,cwd:t}){const[n,a]=m.useState(!1);if(e.inline)return i.jsxs("p",{className:"tm-inline",children:[e.label&&i.jsx("span",{className:"tm-label",children:e.label}),e.path?i.jsx(zg,{path:e.text,cwd:t}):i.jsx("code",{children:e.text})]});const s=m.useMemo(()=>dje(e),[e]),{shown:o}=zK(s,n),r=uje(s,n);return i.jsxs("div",{className:"tm-block",children:[e.label&&i.jsx("span",{className:"tm-label",children:e.label}),i.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?o.map((c,l)=>i.jsxs("span",{className:c.tone?gBe[c.tone]:void 0,children:[c.text,l<o.length-1?`
|
|
351
351
|
`:""]},l)):o.map(c=>c.text).join(`
|
|
352
|
-
`)}),r&&i.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":r.expanded,onClick:()=>a(c=>!c),children:r.label})]})}function IW({text:e,what:t}){const n=se(),[a,s]=m.useState(!1),o=m.useRef(!0);m.useEffect(()=>()=>{o.current=!1},[]);const r=n(a?`insights.tool.copied.${t}`:`insights.tool.copy.${t}`);return i.jsx("button",{type:"button",className:"glyph-btn tm-copy",disabled:!e,"data-copied":a||void 0,"aria-label":r,title:r,onClick:()=>void Qs(e).then(c=>{!c||!o.current||(s(!0),window.setTimeout(()=>{o.current&&s(!1)},1600))}),children:a?i.jsx(Ys,{name:"done"}):i.jsx(Ze,{name:"copy"})})}const mBe=Xv(()=>Xs(()=>import("./UsageHistoryModal-
|
|
352
|
+
`)}),r&&i.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":r.expanded,onClick:()=>a(c=>!c),children:r.label})]})}function IW({text:e,what:t}){const n=se(),[a,s]=m.useState(!1),o=m.useRef(!0);m.useEffect(()=>()=>{o.current=!1},[]);const r=n(a?`insights.tool.copied.${t}`:`insights.tool.copy.${t}`);return i.jsx("button",{type:"button",className:"glyph-btn tm-copy",disabled:!e,"data-copied":a||void 0,"aria-label":r,title:r,onClick:()=>void Qs(e).then(c=>{!c||!o.current||(s(!0),window.setTimeout(()=>{o.current&&s(!1)},1600))}),children:a?i.jsx(Ys,{name:"done"}):i.jsx(Ze,{name:"copy"})})}const mBe=Xv(()=>Xs(()=>import("./UsageHistoryModal-C2IDurbk.js"),[]),()=>S("shell.lazy.usageHistory")),fBe=Xv(()=>Xs(()=>import("./BrowserWatchModal-C4G5G12x.js"),[]),()=>S("shell.lazy.browserWatch")),bBe=Xv(()=>Xs(()=>import("./TrafficRadar-CTGz345C.js"),[]),()=>S("shell.lazy.radar"));function kBe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:a,restart:s,upgrade:o,lanPairs:r,attention:c,clearFlow:l,watchBadge:u,announcements:h,appearance:p,providers:f,stateRef:b,agentCount:v,menus:w,sound:T,tones:y,customTones:x,notify:C,panelDoors:A,terminal:E,account:R}){Es();const{openedTool:z,setOpenedToolKey:I,usageHistoryOpen:_,setUsageHistoryOpen:D,browserWatchOpen:L,setBrowserWatchOpen:P,contextAgent:O,setContextFor:j,summaryFor:M,setSummaryFor:F,keyHelpOpen:U,setKeyHelpOpen:H,feedbackOpen:$,setFeedbackOpen:Y,feedbackPrefill:W,setFeedbackPrefill:G,openFeedback:Q}=e,{trafficRadarOpen:J,setTrafficRadarOpen:X,openedToolCwd:te}=e,{tourOpen:K,openTour:V,closeTour:ee,releaseNotes:de,closeReleaseNotes:he,chipVersion:me,openReleaseNotes:be}=t,{desktopUpdateRestarting:ie,desktopUpdateFailure:ne,readyAppUpdate:ke,askDesktopUpdateRestart:Se}=n,{version:ve,showNotice:xe}=a,{askRestart:Ee}=s,{clearConfirmOpen:Ge,setClearConfirmOpen:Qe,requestClear:Je}=l,{setWatchOn:He,markWatchSeen:_e}=u,{setWatchSaid:le}=h,{palette:Re}=p,{settingsOpen:ge,settingsSection:Pe,settingsLandOn:Fe,showSection:Ve,closeSettings:ot,openSettings:ce}=w;return i.jsxs(i.Fragment,{children:[i.jsx(Ft,{when:z,children:Ce=>i.jsx(pBe,{tool:Ce,cwd:te,onClose:()=>I(null)})}),i.jsx(Ft,{when:_,children:()=>i.jsx(m.Suspense,{fallback:null,children:i.jsx(mBe,{providers:f,onClose:()=>D(!1)})})}),i.jsx(Ft,{when:L,children:()=>i.jsx(m.Suspense,{fallback:null,children:i.jsx(fBe,{onClose:()=>P(!1),onSeen:Ce=>{le(""),_e(Ce)},onWatching:He,palette:Re})})}),i.jsx(Ft,{when:O,children:Ce=>i.jsx(jle,{agent:Ce,onClose:()=>j(null)})}),i.jsx(Ft,{when:J,children:()=>i.jsx(m.Suspense,{fallback:null,children:i.jsx(bBe,{sessions:[...b.current.agents.values()].filter(Ce=>Ce.kind==="root"&&Ce.provider!=="codex").map(Ce=>({id:Ce.sessionId,label:Vk(Ce.sessionName,Ce.sessionTitle).face??Ce.cwdBasename??Ce.label,project:Ce.cwdBasename??Ce.label,workspace:Ce.cwd})),onClose:()=>X(!1)})})}),i.jsx(Ft,{when:$,children:()=>i.jsx(o7,{initialKind:W==null?void 0:W.initialKind,initialBody:W==null?void 0:W.initialBody,initialTab:W==null?void 0:W.initialTab,onClose:()=>{Y(!1),G(null)}})}),i.jsx(Ft,{when:M,children:Ce=>i.jsx(kFe,{state:b.current,sessionId:Ce,onClose:()=>F(null)})}),i.jsx(Ft,{when:ge,children:()=>i.jsx(hBe,{section:Pe,landOn:Fe,onSection:Ve,onClose:ot,providers:f,sound:T,tones:y,customTones:x,notify:C,appearance:p,terminal:E,versionCheck:a,desktopUpdate:n,restart:s,account:R,doors:{whatsNew:Or(ot,be),update:Or(ot,()=>{be(),xe()}),tour:Or(ot,V),feedback:Or(ot,()=>Q()),accounts:Or(ot,A.accounts),localNetwork:Or(ot,A.localNetwork),browserWatch:Or(ot,()=>P(!0)),radar:Or(ot,()=>X(!0))}})}),i.jsx(Ft,{when:de,children:Ce=>i.jsx(fFe,{entries:Ce.entries,since:Ce.since,firstRun:Ce.firstRun,running:me,onClose:he,onTour:()=>{he(),V()},updateVersion:ke==null?void 0:ke.version,updateBusy:ie,updateFailure:ne&&(!ke||ke.version===ne.version)?U8(ne.failure,ne.version):void 0,onUpdateRestart:ke?()=>{Se(ke.version)}:void 0,onRestart:!ke&&(ve!=null&&ve.canRestart)?()=>{he(),Ee()}:void 0,updateCheck:{versionCheck:a,upgrade:o,restart:s,desktopUpdate:n,running:me,onHandOff:he}})}),i.jsx(vBe,{lanPairs:r,attention:c}),i.jsx(Ft,{when:U,children:()=>i.jsx(vDe,{onClose:()=>H(!1),onTour:()=>{H(!1),V()},onSettings:()=>{H(!1),ce("keyboard")},workspace:S7(E)})}),i.jsx(Ft,{when:K,children:()=>i.jsx(NV,{title:S("shell.guide.welcome.title"),steps:sSe,onClose:ee})}),i.jsx(Ft,{when:Ge,children:()=>i.jsx(ZMe,{agentCount:v,onConfirm:()=>Je("confirmation"),onCancel:()=>Qe(!1)})})]})}function vBe({lanPairs:e,attention:t}){const{node:n,pairing:a}=RDe(e);return i.jsxs(i.Fragment,{children:[n,i.jsx(LDe,{...t,pairing:a})]})}const wBe=()=>S("board.status.controlBacktick"),er=(e,t)=>({text:e,spoken:t}),N7={text:"↵",get spoken(){return S("board.keys.enterSpoken")}},yBe=[{caps:[er("j"),er("k")],get word(){return S("board.status.cards")},binds:["j","k"],learn:"cards"},{caps:[N7],get word(){return S("board.status.select")},binds:["Enter"],onCard:!0,learn:"select"},{caps:[er("p")],get word(){return S("board.status.peek")},binds:["p"],zoomedOut:!0,learn:"peek"},{caps:[er("n")],get word(){return S("board.status.nextWaiting")},binds:["n"],waiting:!0,learn:"nextWaiting"}],xBe=[{caps:[er("j"),er("k")],get word(){return S("board.status.sessions")},binds:["j","k"],learn:"sessions"},{caps:[N7],get word(){return S("board.status.openAndType")},binds:["Enter"],learn:"openAndType"},{caps:[er("n")],get word(){return S("board.status.nextWaiting")},binds:["n"],waiting:!0,learn:"nextWaiting"}];function CBe({stageOpen:e,pane:t,onCard:n,zoomedOut:a,singleKeys:s,platform:o,viewChord:r=null,waiting:c=!0,empty:l=!1}){const u=r?[{caps:[er(z0e,wBe())],word:S(r==="workspace"?"board.status.viewWorkspace":"board.status.viewBoard"),binds:[],learn:"view"}]:[];if(t!=null)return{layer:"terminal",label:t?S("board.status.keysIn",{name:t}):S("board.status.keysInSession"),hints:[{caps:[er(q0e(o),S(_0e))],word:S("board.status.keysBack"),binds:[]},...u]};const h=e;if(l)return{layer:h?"deck":"board",label:"",hints:[]};const p=h?xBe:yBe;return{layer:h?"deck":"board",label:S(h?"board.status.deckLabel":"board.status.boardLabel"),hints:[...p.filter(f=>(s||!f.binds.some(O1))&&(n||!f.onCard)&&(!n||!f.offCard)&&(a||!f.zoomedOut)&&(c||!f.waiting)),...u]}}function SBe(e,t){const n=e.hints.filter(a=>!a.learn||!m8(a.learn,t));return{...e,label:n.length>0?e.label:"",hints:n}}const DW=e=>({pane:L0e(e),onCard:Zv(e)}),TBe=(e,t)=>e.pane===t.pane&&e.onCard===t.onCard;function NBe(e){const[t,n]=m.useState(()=>typeof document>"u"?{pane:null,onCard:!1}:DW(document.activeElement));return m.useEffect(()=>{let a=null;const s=new MutationObserver(()=>o(document.activeElement)),o=l=>{var p;const u=DW(l);n(f=>TBe(f,u)?f:u);const h=((p=l==null?void 0:l.closest)==null?void 0:p.call(l,YR))??null;h!==a&&(s.disconnect(),a=h,h&&s.observe(h,{attributes:!0,attributeFilter:[WK]}))},r=l=>o(l.target),c=l=>o(l.relatedTarget);return o(document.activeElement),document.addEventListener("focusin",r),document.addEventListener("focusout",c),()=>{s.disconnect(),document.removeEventListener("focusin",r),document.removeEventListener("focusout",c)}},[e]),t}const ABe=m.memo(function({stageOpen:t,zoomedOut:n,viewChord:a=null,waiting:s=!0,extra:o,version:r=null,onVersion:c,setKeyHelpOpen:l}){const u=se(),h=sa(),{pane:p,onCard:f}=NBe(t),b=Tg(),v=N_e(),w=CBe({stageOpen:t,pane:p,onCard:f,zoomedOut:n,singleKeys:h,platform:js(),viewChord:a,empty:b,waiting:s}),T=o&&p==null?o:SBe(w,v),y=a?w.hints.at(-1):null;return i.jsxs("footer",{className:"statusbar","aria-label":u("board.keys.statusBar"),"data-layer":T.layer,children:[i.jsx("div",{id:"ccdeck-stage-status",className:"statusbar-stage"}),i.jsxs("div",{className:"statusbar-start",children:[T.label&&i.jsxs("span",{className:"statusbar-who",children:[i.jsx("span",{className:"statusbar-dot","aria-hidden":!0}),T.label]}),T.hints.map(x=>i.jsxs("span",{className:"statusbar-hint",children:[i.jsx("span",{className:"statusbar-caps",children:x.caps.map(C=>i.jsx(lu,{label:C.spoken,children:C.text},C.text))}),x.word]},x.word)),T.hints.length===0&&l&&i.jsxs("button",{type:"button",className:"statusbar-keys",onClick:()=>l(x=>!x),"aria-label":u("board.controls.keysLabel"),"aria-haspopup":"dialog","aria-keyshortcuts":h?"?":void 0,title:h?bo(u("board.controls.keys"),"?",!0):u("board.controls.keysOff"),children:[h&&i.jsx(lu,{children:"?"}),u("board.keys.statusBar")]})]}),y&&i.jsxs("span",{className:"statusbar-hint statusbar-view",children:[i.jsx("span",{className:"statusbar-caps",children:y.caps.map(x=>i.jsx(lu,{label:x.spoken,children:x.text},x.text))}),y.word]}),r&&i.jsxs("button",{type:"button",className:"statusbar-version",onClick:c,"aria-label":u("shell.chip.label",{running:r}),title:u("shell.chip.label",{running:r}),"aria-haspopup":"dialog",children:["v",r]})]})}),jBe=10,A7=500,j7=4e3,EBe=[/ResizeObserver loop/i,/^Script error\.?$/i],FW=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,E7=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function RBe(e,t){const n=typeof e=="string"?e.split(`
|
|
353
353
|
`):[],a=n.some(o=>/^\s*at\s/.test(o)),s=n.flatMap(o=>!a||/^\s*at\s/.test(o)?o.match(E7)??[]:[]);return s.length?s.every(o=>FW.test(o)):typeof t=="string"&&FW.test(t)}const zBe=/\bpptr:|__puppeteer_evaluation_script__|\bUtilityScript\./,qBe=/<anonymous>:\d+:\d+/;function _Be(e){const t=typeof e=="string"?e.split(`
|
|
354
354
|
`).filter(a=>/^\s*at\s/.test(a)):[],n=t[t.length-1];return n?zBe.test(n)||qBe.test(n)&&!n.match(E7):!1}const Lk=String.raw`[^\s\\/:'"\`<>|?*;,]`,LBe=String.raw`${Lk}(?:[^\\/\r\n:'"\`<>|?*;,]*${Lk})?[\\/]`,PBe=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,op=String.raw`(?:${LBe})*(?:${PBe})?`,OBe=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${op}|[A-Za-z]:[\\/]${op}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${op}|/(?=${Lk})${op}|(?<!:)//(?=${Lk})${op})`,MBe=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,IBe=new Set([".claude",".codex"]);function DBe(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...a]=e.slice(2).split(/[\\/]/);return n?IBe.has(n)?a.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const FBe=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function BBe(e,t,n){return n?"<deck>":`${t}://<host>`}const BW=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,R7=String.raw`${BW}(?:\.${BW}){3}`,aj=String.raw`[0-9A-Fa-f]{1,4}`,UW=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${aj}:){7})(?:(?:${aj})?:)+(?:${R7}|${aj})?`,WW=String.raw`%[\w-]+(?:\.[\w-]+)*`,HW=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,UBe=String.raw`(?<![\w:.%-])(?:\[(?!${HW}\])${UW}(?:${WW})?\]|(?!${HW}(?::\d{1,5})?(?![\w:%]|\.\d))${UW}(?:${WW})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${R7}(?![\w-]|\.\d)`,sj=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,WBe=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${sj}|${sj}(?=:\d{1,5}(?![\w:-]|\.\w))|${sj}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`,HBe=/[\s"\x60<>|?;,]/g;function GBe(e){return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return decodeURIComponent(t).replace(HBe,n=>encodeURIComponent(n))}catch{return t}})}function GW(e){return GBe(String(e??"")).replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(OBe,"g"),DBe).replace(new RegExp(MBe,"g"),"<project>").replace(new RegExp(FBe,"g"),BBe).replace(new RegExp(UBe,"g"),"<host>").replace(new RegExp(WBe,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|gl(?:pat|dt|rt|cbt|ptt|ft|imt|agent|oas|soat)-[A-Za-z0-9_.-]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const z7=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function VBe(e,t,n=z7){const a=String(e??"").slice(0,A7).trim();a&&n({message:a,stack:typeof t=="string"?t.slice(0,j7):void 0})}function KBe(e,t=window,n=z7){let a=0;const s=new Set,o=(l,u,h)=>{const p=String(l??"").slice(0,A7).trim();!e()||!p||a>=jBe||s.has(p)||EBe.some(f=>f.test(p))||RBe(u,h)||_Be(u)||(s.add(p),a++,n({message:p,stack:typeof u=="string"?u.slice(0,j7):void 0}))},r=l=>{var u,h;return o(((u=l.error)==null?void 0:u.message)??l.message,(h=l.error)==null?void 0:h.stack,l.filename)},c=l=>typeof l.reason=="object"&&l.reason!==null?o(l.reason.message,l.reason.stack):o(l.reason,void 0);return t.addEventListener("error",r),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",r),t.removeEventListener("unhandledrejection",c)}}const $Be=12;function JBe(e,t){const n=[GW(e).trim()||S("shell.error.noMessage")],a=t==null?void 0:t.trim();if(a){const s=a.split(`
|
|
355
355
|
`).slice(0,$Be).join(`
|
|
356
356
|
`);n.push("",GW(s).trim())}return n.join(`
|
|
357
357
|
`)}class YBe extends m.Component{constructor(){super(...arguments);Ss(this,"state",{error:null,componentStack:null,reportOpen:!1});Ss(this,"onKey",n=>{ev(n.key)&&Rn.dismissTop()})}static getDerivedStateFromError(n){return{error:n,account:rE()}}componentDidCatch(n,a){console.error("ccdeck hit a render error it could not draw past",n,a.componentStack),this.setState({componentStack:a.componentStack??null}),VBe(n.message,n.stack),p8("offline")}componentDidUpdate(n,a){this.state.reportOpen!==a.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:a,reportOpen:s,account:o=null}=this.state;return n?i.jsxs("div",{className:"error-fallback",children:[i.jsxs("div",{className:"error-fallback-card",role:"alert",children:[i.jsx("span",{className:"error-fallback-icon","aria-hidden":!0,children:i.jsx(w6,{})}),i.jsx("p",{className:"error-fallback-title",children:S("shell.error.title")}),i.jsx("p",{className:"error-fallback-note",children:S("shell.error.note")}),i.jsxs("div",{className:"error-fallback-actions",children:[i.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:S("shell.reload")}),i.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:S("shell.error.report")})]})]}),i.jsx(Ft,{when:s,children:()=>i.jsx(o7,{initialKind:"bug",initialBody:JBe(n.message,a),account:o,onClose:()=>this.setState({reportOpen:!1})})})]}):this.props.children}}const ZBe=1e3;function XBe(e={}){const t=Math.max(1,Math.floor(e.limit??ZBe)),n=e.protect;let a=!1,s=[],o=new Set,r=0,c=0,l=null;return{get paused(){return a},get size(){return s.length},get dropped(){return r},get overflowed(){return r>0},get through(){return c},accept(u){const h=typeof(u==null?void 0:u.seq)=="number"?u.seq:null,p=(u==null?void 0:u.epoch)??null,f=p!==null&&p!==l;f&&(l=p,c=0);const b=h!==null&&!f&&h<=c;if(h!==null&&h>c&&(c=h),!a)return!0;if(b)return!1;if(s.push(u),n!=null&&n(u)&&o.add(u),s.length>t){let v=0;if(o.size<s.length)for(;o.has(s[v]);)v++;const[w]=s.splice(v,1);o.delete(w),r++}return!1},setPaused(u){if(a=e.enabled!==!1&&u,a)return[];const h=s;return s=[],o=new Set,r=0,h}}}function QBe(e){const t=m.useState(()=>XBe({enabled:!1,protect:o=>xje(e.current,o)}))[0],[n,a]=m.useState(!1),s=m.useCallback(()=>{const o=t.paused&&t.dropped>0,r=t.setPaused(!t.paused);o&&c0e(e.current);for(const c of r)e.current=UK(e.current,c);a(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const VW="agent-dag.accountPanelProvider",eUe=400,tUe={claude:!1,codex:!1};function nUe(e,t){const[n,a]=m.useState(()=>gt(VW)==="codex"?"codex":"claude"),s=e.claude&&!!e.codex,o=s?n:e.codex?"codex":"claude",[r,c]=m.useState(!1);m.useEffect(()=>{if(!s||!t){c(!1);return}const w=setTimeout(()=>c(!0),eUe);return()=>clearTimeout(w)},[s,t]);const l=m.useCallback(w=>{a(w),yt(VW,w)},[]),u=m.useRef(!1),h=m.useCallback(w=>{w!==o&&(u.current=!0,c(!0),l(w))},[l,o]);m.useLayoutEffect(()=>{var w;u.current&&(u.current=!1,(w=document.querySelector(`#${q7(o)} [role="radio"][aria-checked="true"]`))==null||w.focus())},[o]);const[p,f]=m.useState(tUe),b=m.useCallback(w=>f(T=>({...T,claude:w})),[]),v=m.useCallback(w=>f(T=>({...T,codex:w})),[]);return{both:s,shown:o,bothMounted:r,remember:l,pick:h,notices:p,noteClaude:b,noteCodex:v}}function q7(e){return e==="codex"?"codex-accounts-panel":"accounts-panel"}const SE={kind:"assumed",claude:!0,codex:!0};function aUe(e){if(!e||typeof e!="object")return SE;const t=e.providers;if(!t||typeof t!="object")return SE;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function sUe(e){const[t,n]=m.useState(null),[a,s]=m.useState(SE);m.useEffect(()=>{let r=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{r||(s(aUe(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{r=!0}},[e]);const o=Pt(a);return{workspace:t,providers:a,providersRef:o}}const _7=3*6e4,iUe=2e4;function oUe({fetchReport:e,visible:t,now:n,onReport:a}){let s=0,o=!0;const r=async()=>{if(!t())return;const c=await e();!o||!c||(s=n(),a(c))};return{tick:r,wake:async()=>{t()&&n()-s>=_7&&await r()},stop:()=>{o=!1}}}async function rUe(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(iUe)});return e.ok?await e.json():null}catch{return null}}function cUe(e){const[t,n]=m.useState(null);return m.useEffect(()=>{if(!e){n(null);return}const a=oUe({fetchReport:rUe,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});a.tick();const s=window.setInterval(a.tick,_7),o=()=>{a.wake()};return document.addEventListener("visibilitychange",o),()=>{a.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const lUe={degraded:"shell.incident.words.degraded",partial_outage:"shell.incident.words.partial_outage",major_outage:"shell.incident.words.major_outage",maintenance:"shell.incident.words.maintenance"},dUe={degraded:"shell.incident.chip.degraded",partial_outage:"shell.incident.chip.partial_outage",major_outage:"shell.incident.chip.major_outage",maintenance:"shell.incident.chip.maintenance"},uUe={degraded:"shell.incident.short.degraded",partial_outage:"shell.incident.short.partial_outage",major_outage:"shell.incident.short.major_outage",maintenance:"shell.incident.short.maintenance"},hUe={claude:"Claude",codex:"Codex"},pUe=new Set(["status.claude.com","status.openai.com"]),gUe=30*6e4,mUe=10*6e4;function fUe(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&pUe.has(t.hostname)?t:null}catch{return null}}function ij(e){return new Date(e).toLocaleTimeString(Me(),{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function bUe(e){const t=Math.floor(e/6e4);return t<1?S("shell.ago.now"):t<60?S("shell.ago.min",{n:t}):S("shell.ago.hr",{n:Math.floor(t/60)})}function kUe(e,t){if(!e||typeof e!="object")return null;const n=On(lUe,e.state),a=n&&S(n),s=On(hUe,e.provider);if(!a||!s||typeof e.checkedAt!="number"||t-e.checkedAt>gUe)return null;const o=fUe(e.statusPageUrl);if(!o)return null;const r=Array.isArray(e.components)?e.components:[],c=e.stale===!0||t-e.checkedAt>mUe,l=[`${s}: ${a}${e.summary?` — ${e.summary}`:""}`,r.length>0?S("shell.incident.affected",{components:r.join(", ")}):null,e.scope==="page"?S("shell.incident.scopePage",{name:s}):null,c?S("shell.incident.lastRead",{host:o.hostname,time:ij(e.checkedAt)}):S("shell.incident.reported",{host:o.hostname,ago:bUe(t-e.checkedAt)}),S("shell.incident.opensPage")],u=c?ij(e.checkedAt):null,h=On(dUe,e.state),p=On(uUe,e.state);return{provider:e.provider,state:e.state,name:s,label:`${s} · ${a}${u?` · ${S("shell.incident.asOf",{time:u})}`:""}`,words:a,chipWords:h?S(h):a,shortWords:p?S(p):a,asOf:u,readAt:ij(e.checkedAt),what:e.summary||(r.length>0?r.join(", "):null),href:o.href,host:o.hostname,stale:c,detail:l.filter(Boolean).join(`
|
|
358
|
-
`)}}function vUe(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>kUe(n,t)).filter(n=>n!==null)}function wUe(e){return e.map(t=>S(t.state.endsWith("outage")?"shell.incident.sentenceA":"shell.incident.sentence",{name:t.name,words:t.words})).join(" ")}const yUe=()=>S("shell.incident.clear");function xUe({version:e,loadVersion:t}){var u;const[n,a]=m.useState(!1),s=((u=e==null?void 0:e.upgrade)==null?void 0:u.state)??"idle",o=vMe(e==null?void 0:e.upgrade),r=m.useRef(!1),c=m.useCallback(async()=>{if($a(r.current||s==="running")){r.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),r.current=!1}},[s,t]);m.useEffect(()=>{if(s!=="running")return;const h=window.setInterval(t,3e3);return()=>window.clearInterval(h)},[s,t]);const l=m.useCallback(async()=>{const h=e==null?void 0:e.command;!h||!await Qs(h)||(a(!0),window.setTimeout(()=>a(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:l,cmdCopied:n}}const KW="agent-dag.browserWatch.seenMs";function CUe(e,t){return e.filter(n=>n.startMs>t)}function SUe(){const[e,t]=m.useState(()=>Number(gt(KW))||0),[n,a]=m.useState([]),[s,o]=m.useState(!1);m.useEffect(()=>{let l=!0;const u=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var f;!l||!(p!=null&&p.ok)||(a(p.episodes??[]),o(((f=p.settings)==null?void 0:f.enabled)===!0))}).catch(()=>{})};u();const h=setInterval(u,5*6e4);return()=>{l=!1,clearInterval(h)}},[]);const r=m.useMemo(()=>CUe(n,e).length,[n,e]),c=m.useCallback(l=>{t(l),yt(KW,String(l))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:r,markWatchSeen:c}}const L7="agent-dag.character-enabled",P7="agent-dag.fm-volume",TUe=1,$W="agent-dag.fm-source",M4e=[{value:"claude-fm",label:"🎧 Claude FM"},{group:"📻 Lofi Girl",value:"lofi-relax",label:"📚 Relax / study"},{group:"📻 Lofi Girl",value:"lofi-game",label:"🎮 Chill / game"},{group:"📻 Lofi Girl",value:"lofi-vibe",label:"🌅 Vibe / chill"},{group:"📻 Lofi Girl",value:"lofi-sleep",label:"💤 Sleep / chill"},{group:"📻 Radio Mix",value:"radio-mix",label:"📡 Live radio mix"},{group:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"}];function NUe(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function AUe(e){return e!=="0"}function jUe(){return AUe(gt(L7))}function EUe(e){return UG(e,TUe)}function RUe(){return EUe(gt(P7))}const O7=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg","--text","--text-secondary","--sunken","--accent-dim","--cat-shell","--cat-agent","--cat-web","--usage-indigo","--usage-pink","--usage-cyan","--usage-lime","--usage-orange","--usage-purple","--font-mono"];function JW(e){const t={};for(const n of O7)t[n]=e(n);return t}function zUe(e){return t=>e[t]??""}function qUe(e,t){return O7.every(n=>e[n]===t[n])}function _Ue(e,t){let n=null,a=0;function s(){a++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:s,run(o){s();const r=a;let c=!1;const l=()=>{r!==a||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){l();return}e.documentElement.dataset.themeTransition="true";try{const u=e.startViewTransition(l);n=u,u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{l()}),u.finished.then(()=>{n===u&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===u&&(l(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,l()}}}}function YW(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function LUe(){const[e,t]=m.useState(kbe),[n,a]=m.useState(vbe),[s,o]=m.useState(Efe),r=m.useRef(s),[c]=m.useState(()=>_Ue(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),l=m.useCallback(y=>{const x=typeof y=="function"?y(r.current):y;x!==r.current&&(r.current=x,c.run(()=>$t.flushSync(()=>o(x))))},[c]);m.useEffect(()=>()=>c.cancel(),[c]);const[u,h]=m.useState(jUe),[p,f]=m.useState(Fme),[b,v]=m.useState(()=>JW(YW)),w=m.useMemo(()=>zUe(b),[b]),T=m.useCallback(y=>yre(y,w),[w]);return m.useEffect(()=>{document.documentElement.dataset.textSize=e,yt(h0,e)},[e]),m.useEffect(()=>{document.documentElement.dataset.density=n,yt(p0,n)},[n]),m.useEffect(()=>{const y=x=>{x.storageArea===Gs()&&((x.key===h0||x.key===null)&&t(sR(x.newValue)),(x.key===p0||x.key===null)&&a(s6(x.newValue)))};return window.addEventListener("storage",y),()=>window.removeEventListener("storage",y)},[]),m.useLayoutEffect(()=>{document.documentElement.dataset.theme=s,document.documentElement.dataset.colorScheme=Og[s].colorScheme,yt(HG,s),v(y=>{const x=JW(YW);return qUe(y,x)?y:x})},[s]),m.useEffect(()=>{yt(L7,u?"1":"0")},[u]),m.useEffect(()=>{yt(PG,p)},[p]),m.useEffect(()=>{const y=document.querySelector('meta[name="theme-color"]'),x=b["--panel"];y&&x&&y.setAttribute("content",x)},[b]),{textSize:e,setTextSize:t,density:n,setDensity:a,theme:s,setTheme:l,characterEnabled:u,setCharacterEnabled:h,character:p,setCharacter:f,palette:b,minimapNodeFill:T}}function PUe(e){const[t,n]=m.useState(()=>new Set),a=m.useMemo(()=>{const o=new Set;for(const r of e.current.agents.values())for(const c of r.tools)o.add(aE(c.name));return Object.keys(K_e).filter(r=>o.has(r))},[e.current,e.current.revision]),s=m.useCallback(o=>{n(r=>{const c=new Set(r);return c.has(o)?c.delete(o):c.add(o),c})},[]);return{presentCats:a,hiddenCats:t,toggleCat:s}}function OUe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const a=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,s())};function r(){var f,b;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(f=n.addEventListener)==null||f.call(n,"statechange",o)),(b=n.resume)==null||b.call(n).then(o,()=>{}),o()}catch{}}function c(f,b,v=b.figure){if(!n||n.state!=="running")return!1;const w=l0(f,v),T=gfe(b.level,w),y=n.currentTime;for(const x of w.notes){const C=n.createOscillator(),A=n.createGain();C.type=w.type??"sine",C.frequency.value=x.hz;const E=y+x.at,R=E+x.ms/1e3;A.gain.setValueAtTime(tO,E),A.gain.exponentialRampToValueAtTime(T,E+mfe),A.gain.exponentialRampToValueAtTime(tO,R),C.connect(A).connect(n.destination),C.start(E),C.stop(R+.02)}return!0}async function l(f,b){var T;if(!e.loadCustom)return"unavailable";let v;try{v=await e.loadCustom(f)}catch{return"unavailable"}if(!v)return"missing";if(v.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const y=new SpeechSynthesisUtterance(v.text),x=window.speechSynthesis.getVoices();y.voice=x.find(C=>C.voiceURI===v.voiceURI)??null,y.rate=v.rate,y.pitch=v.pitch,y.volume=ffe(b.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(y),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let w;try{w=await n.decodeAudioData(v.bytes.slice(0))}catch{return"broken"}try{const y=n.createBufferSource(),x=n.createGain();return y.buffer=w,x.gain.setValueAtTime(bfe(v.normalizationGain,b.level),n.currentTime),y.connect(x).connect(n.destination),a.add(y),(T=y.addEventListener)==null||T.call(y,"ended",()=>a.delete(y)),y.start(n.currentTime),"played"}catch{return"unavailable"}}function u(f,b=!1){var T,y;if(!b&&!e.enabled())return!1;const v=Sfe((T=e.prefs)==null?void 0:T.call(e),f),w=((y=e.customSelection)==null?void 0:y.call(e)[f])??null;return w&&e.loadCustom?(l(w,v).then(x=>{var C;x==="played"||x==="locked"||((x==="missing"||x==="broken")&&((C=e.onCustomFailure)==null||C.call(e,f,w)),c(f,{...v,figure:Ns},Ns))}),!0):!n||n.state!=="running"?!1:c(f,v)}function h(f,b=_l){return l(f,{level:pv(b),figure:Ns}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const f of a)try{f.stop()}catch{}a.clear()}return{unlock:r,play:u,previewCustom:h,silence:p,state:s,get context(){return n}}}function MUe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:a,fallbackCustomRef:s}){m.useEffect(()=>{const o=OUe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>a.current,loadCustom:lfe,onCustomFailure:(u,h)=>s.current(u,h)});e.current=o;const r=["pointerdown","pointerup","keydown"],c=()=>{for(const u of r)window.removeEventListener(u,l,{capture:!0})},l=()=>{var u;o.unlock(),((u=o.context)==null?void 0:u.state)==="running"&&c()};for(const u of r)window.addEventListener(u,l,{capture:!0});return c},[])}function IUe(){const[e,t]=m.useState(RUe),[n,a]=m.useState(()=>Sue(gt(cP))),[s,o]=m.useState(()=>Cue(gt(lP))),[r,c]=m.useState(()=>Tue(gt($W),n,NUe)),[l,u]=m.useState(()=>new Set),[h,p]=m.useState(0);m.useEffect(()=>{yt(P7,String(e))},[e]),m.useEffect(()=>{yt(lP,s?"1":"0")},[s]),m.useEffect(()=>{yt(cP,JSON.stringify(n))},[n]),m.useEffect(()=>{yt($W,r)},[r]);const f=m.useCallback((y,x=!1)=>{a(C=>{const A=C.find(E=>E.id===y.id);return A?!x||!y.radio||!A.radio||A.url===y.url&&JSON.stringify(A.radio)===JSON.stringify(y.radio)?C:C.map(E=>E.id===y.id?{...E,url:y.url,radio:y.radio}:E):[...C,y]}),u(C=>{if(!C.has(y.id))return C;const A=new Set(C);return A.delete(y.id),A})},[]),b=m.useCallback((y,x)=>{const C=x.trim();!C||C.length>B5||a(A=>A.map(E=>E.id===y?{...E,name:C}:E))},[]),v=m.useCallback(y=>{a(x=>x.filter(C=>C.id!==y)),c(x=>Nue(x,y)),u(x=>{if(!x.has(y))return x;const C=new Set(x);return C.delete(y),C})},[]),w=m.useCallback((y,x=!1)=>{const C=dP(y),A=l.has(C);y===r&&!A&&!x||(A&&u(E=>{const R=new Set(E);return R.delete(C),R}),c(y),p(E=>E+1))},[r,l]),T=m.useCallback((y,x)=>{const C=dP(y);u(A=>{if(A.has(C)===x)return A;const R=new Set(A);return x?R.add(C):R.delete(C),R})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:r,customFmStations:n,unavailableFmStations:l,fmPlayRequest:h,addFmStation:f,renameFmStation:b,removeFmStation:v,pickFmSource:w,markFmStationAvailability:T}}function DUe(e){const[t,n]=m.useState(null),[a,s]=m.useState(!1),[o,r]=m.useState(null),c=m.useRef(0);m.useEffect(()=>{if(!e||!lr())return;let v=!1;const w=c.current;return fetch("/api/desktop-update").then(T=>T.ok?T.json():null).then(T=>{if(v||c.current!==w)return;const y=dW(T);y&&n(y)}).catch(()=>{}),()=>{v=!0}},[e]);const l=AOe(t),u=m.useRef(!1),h=m.useRef(0),p=m.useRef(0);m.useEffect(()=>()=>window.clearTimeout(h.current),[]);const f=m.useCallback(async v=>{if(!$a(u.current))return;const w=++p.current;window.clearTimeout(h.current),u.current=!0,s(!0),r(null);const T=y=>{w===p.current&&(window.clearTimeout(h.current),u.current=!1,s(!1),r({failure:y,version:v}))};try{const y=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:v})});if(!y.ok)return T(qOe(await y.json().catch(()=>null)))}catch{return T("unreachable")}w===p.current&&(h.current=window.setTimeout(()=>T("timeout"),F8))},[]),b=m.useCallback(v=>{if(lr())try{const w=dW(JSON.parse(v));w&&(c.current++,n(w),w.status!=="ready"&&(p.current++,window.clearTimeout(h.current),u.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:a,desktopUpdateFailure:o,readyAppUpdate:l,appUpdate:t,askDesktopUpdateRestart:f,onDesktopUpdateEvent:b}}let M7=!1;function FUe(){M7=!0}const ZW=["focus","keydown","pointerdown"],XW={capture:!0},BUe=400;function I4e(e,t){if(typeof window>"u"||lr(t))return()=>{};let n=null;const a=s=>{if(M7||(s.preventDefault(),s.returnValue="",!e||n))return;const o=()=>{n==null||n(),e()},r=setTimeout(()=>{var c;typeof document<"u"&&((c=document.hasFocus)!=null&&c.call(document))&&o()},BUe);for(const c of ZW)window.addEventListener(c,o,XW);n=()=>{clearTimeout(r);for(const c of ZW)window.removeEventListener(c,o,XW);n=null}};return window.addEventListener("beforeunload",a),()=>window.removeEventListener("beforeunload",a)}const sb="agent-dag.autoRestart",QW="agent-dag.bundleReloadedFor";function UUe({now:e,stateRef:t,version:n,notice:a,noticeOpen:s,upgradeFailure:o,paused:r}){const[c,l]=m.useState(()=>gt(sb)!=="0"),u=m.useRef(!1),h=m.useCallback(()=>{const L=!c;u.current=!0,Ja(sb),l(L);const P=O=>{l(j=>j===L?!L:j),Dl(O)};fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:L})}).then(async O=>{var M;const j=await O.json().catch(()=>null);if(!O.ok||!(j!=null&&j.ok))return P(j);Ai(null),l(((M=j.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>P(null))},[c]),[p,f]=m.useState(!1),[b,v]=m.useState("restart"),[w,T]=m.useState(null),y=m.useRef(!1),x=m.useRef(null),C=m.useRef(0),A=m.useRef(null),E=m.useCallback(async L=>{if(!$a(y.current))return;const P=(L==null?void 0:L.upgrade)===!0,O=(L==null?void 0:L.whenIdle)===!0;y.current=!0,x.current=o;const j=++C.current,M=()=>{v(P?"npx":"restart"),f(!0)};O||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(a==null?void 0:a.to)??"")}catch{}let F=!1;try{const U=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O?{upgrade:P,whenIdle:O}:{upgrade:P})});F=O&&U.status===409}catch{}if(F){y.current=!1,A.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}O&&M(),window.setTimeout(()=>{if(C.current===j&&y.current){y.current=!1,f(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[a==null?void 0:a.to,o]);m.useEffect(()=>{const L=hW(t.current.agents.values())>0,P=CMe({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:L,idleSince:A.current,now:e});A.current=P.idleSince,P.restart&&E({whenIdle:!0})},[c,a==null?void 0:a.kind,n==null?void 0:n.canRestart,s,e,E]);const R=hW(t.current.agents.values()),z=xMe(R,r),I=J8({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:R>0,idleSince:A.current,now:e});m.useEffect(()=>{const L=n==null?void 0:n.running;let P=null,O=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),O=window.sessionStorage.getItem(QW)}catch{return}const j=kMe({bundle:"4.0.2",running:L,pending:P,lastTried:O});if(j==="reload"){try{window.sessionStorage.setItem(QW,L??"")}catch{return}FUe(),window.location.reload();return}if(j!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}y.current=!1,f(!1),T(L??null);const M=window.setTimeout(()=>T(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]);const _=m.useCallback(()=>T(null),[]);m.useEffect(()=>{if(p&&wMe({asked:x.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}y.current=!1,f(!1)}},[p,o]);const D=m.useCallback(L=>{var P,O;if(!u.current){const j=gt(sb)==="0";Ja(sb),j&&((P=L.prefs)==null?void 0:P.autoUpdate)!==!1?(l(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):l(((O=L.prefs)==null?void 0:O.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:h,restarting:p,restartMode:b,restartedTo:w,dismissRestarted:_,askRestart:E,restartCopy:z,restartFuseMs:I,loadAutoRestartPrefs:D}}function WUe(){const[e,t]=m.useState([]),n=m.useRef(new Set),[a,s]=m.useState(null),[o,r]=m.useState(void 0);m.useEffect(()=>{let u=!0,h=0;const p=()=>{fetch("/api/lan").then(f=>f.ok?f.json():null).then(f=>u?(f!=null&&f.ok&&t(GO(Array.isArray(f.pending)?f.pending:[],f.aliases)),f):null).catch(()=>null).then(f=>{u&&(r(b=>f!=null&&f.ok?f:b===void 0?null:b),h=window.setTimeout(p,(f==null?void 0:f.enabled)===!0?D0:TV))})};return p(),()=>{u=!1,window.clearTimeout(h)}},[]);const c=m.useCallback(async(u,h)=>{if(!a){s(u);try{const f=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:u,fp:h})})).json().catch(()=>null);f&&Array.isArray(f.pending)?t(GO(f.pending,f.aliases)):t(b=>b.filter(v=>v.fp!==h))}catch{}finally{s(null)}}},[a]),l=m.useCallback(u=>{a||(n.current.add(u),t(h=>[...h]))},[a]);return{lanPending:e,lanDeferred:n,lanBusy:a,answerLanPair:c,deferLanPair:l,lanStatus:o}}const HUe=6e4;function GUe({enabled:e,lanStatus:t,now:n}){const[a,s]=m.useState(null),[o,r]=m.useState(()=>new Set),[c,l]=m.useState(null),u=m.useCallback(y=>{y!=null&&y.ok&&Array.isArray(y.accounts)&&s(y.accounts)},[]),h=m.useCallback(async y=>{try{const x=await fetch(`/api/claude-accounts${y?"?refresh=1":""}`);x.ok&&u(await x.json())}catch{}},[u]);m.useEffect(()=>{e&&h(!1)},[e,h]),m.useEffect(()=>{if(!e)return;let y=Date.now();const x=()=>{document.visibilityState!=="visible"||Date.now()-y<HUe||(y=Date.now(),h(!1))};return document.addEventListener("visibilitychange",x),window.addEventListener("focus",x),()=>{document.removeEventListener("visibilitychange",x),window.removeEventListener("focus",x)}},[e,h]);const p=m.useMemo(()=>e?yDe(a,{lan:t,now:n,closed:o}):[],[e,a,t,n,o]),f=m.useRef(p);f.current=p;const b=m.useCallback(y=>{y.length&&r(x=>new Set([...x,...y]))},[]),v=m.useCallback(()=>{const y=f.current;y.length&&(b(y.map(x=>x.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:y.map(x=>({key:x.key,since:x.since}))})}).catch(()=>{}))},[b]),w=m.useRef(c);w.current=c;const T=m.useCallback(y=>{const x=w.current;b(xDe(x?[x,...f.current]:f.current,y))},[b]);return{rows:p,accounts:a,signingIn:c,observe:u,signIn:l,signedIn:T,refresh:m.useCallback(()=>{h(!0)},[h]),closeSignIn:m.useCallback(()=>l(null),[]),later:v}}const VUe=288,Oz=VUe;function KUe(){const e=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--rail-w"));return Number.isFinite(e)&&e>0?e:Oz}function $Ue(){const[e,t]=m.useState(Oz);return m.useLayoutEffect(()=>{const n=()=>t(KUe());n();const a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-density"]}),()=>a.disconnect()},[]),e}function JUe(e,t,n){return e?"session-list":t||n?"accounts":null}function eH(e,t=Oz,n=t){return e==="session-list"||e==="accounts"?n:0}const YUe=240,ZUe=20;function XUe(e){const t=m.useRef(0),n=m.useRef(e);return m.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=Ya()?0:performance.now()+YUe+ZUe)},[e]),t}const I7="agent-dag.sessionListOpen",TE="agent-dag.accountsPanelOpen";function QUe(){return gt(I7)==="1"}function tH(e){yt(I7,e?"1":"0")}function eWe(){return gt(TE)==="1"}function tWe(){const e=m.useRef(!1),t=m.useRef(!1),n=m.useRef(!1),[a,s]=m.useState(()=>{const A=QUe();return Gr()?(n.current=!A,!0):A});m.useEffect(()=>{if(n.current){n.current=!1;return}t.current||tH(a)},[a]);const o=m.useRef(!1),[r,c]=m.useState(()=>{const A=eWe();return A&&Gr()?(e.current=!0,!1):A&&a?(o.current=!0,!1):A});m.useEffect(()=>{if(r)e.current=!1;else if(e.current)return;t.current||!r&&o.current||yt(TE,r?"1":"0")},[r]),m.useEffect(()=>{!a&&o.current&&(o.current=!1,c(!0))},[a]);const l=m.useCallback(()=>{s(A=>(!A&&!Gr()&&c(E=>(E&&(o.current=!0),!1)),!A))},[]),u=m.useCallback(()=>{o.current=!1,c(A=>(!A&&!Gr()&&s(!1),!A))},[]),h=m.useCallback(()=>{o.current=!1,c(A=>(!A&&!Gr()&&s(!1),!0))},[]),p=m.useCallback(()=>s(!1),[]),f=m.useCallback(()=>{o.current=!1,s(!1)},[]),b=m.useCallback(()=>c(!1),[]),v=m.useCallback(()=>{o.current=!1,s(!1),c(!1)},[]),w=JUe(a,r,o.current),T=m.useRef(null);T.current={sessionListOpen:a,accountsPanelOpen:r};const y=m.useCallback(()=>{const A=T.current;!A||!A.sessionListOpen||!A.accountsPanelOpen||(o.current=!0,c(!1))},[]),x=m.useCallback(()=>{e.current=!0,c(!1)},[]),C=m.useMemo(()=>({hold:()=>{t.current=!0},release:(A,E)=>{t.current=!1;const R=T.current;!A||!R||((!E||R.sessionListOpen!==E.list)&&tH(R.sessionListOpen),(!E||R.accountsPanelOpen!==E.accounts)&&(R.accountsPanelOpen||!o.current)&&yt(TE,R.accountsPanelOpen?"1":"0"))}}),[]);return{sessionListOpen:a,accountsPanelOpen:r,panel:w,toggleSessionList:l,toggleAccountsPanel:u,openAccountsPanel:h,closeSessionList:p,closeSessionListToCanvas:f,closeAccountsPanel:b,dismissColumn:v,leavePhone:y,holdAccounts:x,storeHold:C}}function nWe({active:e,wide:t,column:n}){const a=m.useRef(null),s=m.useRef(!1),o=m.useRef(!1),{sessionListOpen:r,accountsPanelOpen:c,toggleSessionList:l,closeSessionList:u,openAccountsPanel:h,dismissColumn:p,storeHold:f}=n;m.useLayoutEffect(()=>{const b=o.current;if(o.current=e,e&&!b){s.current=!1,t&&!r?(a.current={kind:"list"},f==null||f.hold(),l()):!t&&(r||c)&&(a.current={kind:"dismissed",held:r?"list":"accounts"},f==null||f.hold(),p());return}const v=a.current;if(!e&&b){a.current=null,f==null||f.release(!1),(v==null?void 0:v.kind)==="list"&&r?u():(v==null?void 0:v.kind)==="dismissed"&&!r&&!c&&(v.held==="list"?l():h());return}if(!e||!v)return;(v.kind==="list"?r:!r&&!c)?s.current=!0:s.current&&(a.current=null,f==null||f.release(!0,v.kind==="list"?{list:!0,accounts:!1}:{list:!1,accounts:!1}))},[e,r,c])}const aWe="(min-width: 641px) and (max-width: 839px)";function sWe({narrow:e,leftOpen:t,rightOpen:n,lastOpened:a}){return!e||!t||!n?{left:t,right:n}:a==="left"?{left:!0,right:!1}:{left:!1,right:!0}}function iWe(e,t){return t.right&&!e.right?"right":t.left&&!e.left?"left":e.last}function oj(e,t,n){return a=>{if(!t()){e(a);return}const s=typeof a=="function"?a(!1):a;s&&n(),e(s)}}function nH(e,t){return()=>{if(!t.folded()){e();return}t.raise(),t.holds()||e()}}function oWe(e){const t=Ws(aWe),[n,a]=m.useState(()=>({...e,last:e.right?"right":"left"})),s=sWe({narrow:t&&n.board,leftOpen:n.left,rightOpen:n.right,lastOpened:n.last}),o={left:n.left&&!s.left,right:n.right&&!s.right},r=Pt(o),c=m.useCallback(u=>a(h=>h.last===u?h:{...h,last:u}),[]);return{fold:o,foldRef:r,raise:c,settle:u=>{u.left===n.left&&u.right===n.right&&u.board===n.board||a({...u,last:iWe(n,u)})}}}function rWe(e,t){const n=new Set;for(const a of t){if(a==null)continue;const s=e.agents.get(a);s?n.add(s.sessionId):n.add(a)}return n}const cWe=typeof window>"u"?m.useEffect:m.useLayoutEffect;function lWe(e,t,n){cWe(()=>{const s=[];for(const o of e.current.agents.values())o.kind==="root"&&s.push([o.sessionId,tk(o)]);nge(s)},[n,e]);const a=t.join(`
|
|
358
|
+
`)}}function vUe(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>kUe(n,t)).filter(n=>n!==null)}function wUe(e){return e.map(t=>S(t.state.endsWith("outage")?"shell.incident.sentenceA":"shell.incident.sentence",{name:t.name,words:t.words})).join(" ")}const yUe=()=>S("shell.incident.clear");function xUe({version:e,loadVersion:t}){var u;const[n,a]=m.useState(!1),s=((u=e==null?void 0:e.upgrade)==null?void 0:u.state)??"idle",o=vMe(e==null?void 0:e.upgrade),r=m.useRef(!1),c=m.useCallback(async()=>{if($a(r.current||s==="running")){r.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),r.current=!1}},[s,t]);m.useEffect(()=>{if(s!=="running")return;const h=window.setInterval(t,3e3);return()=>window.clearInterval(h)},[s,t]);const l=m.useCallback(async()=>{const h=e==null?void 0:e.command;!h||!await Qs(h)||(a(!0),window.setTimeout(()=>a(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:l,cmdCopied:n}}const KW="agent-dag.browserWatch.seenMs";function CUe(e,t){return e.filter(n=>n.startMs>t)}function SUe(){const[e,t]=m.useState(()=>Number(gt(KW))||0),[n,a]=m.useState([]),[s,o]=m.useState(!1);m.useEffect(()=>{let l=!0;const u=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var f;!l||!(p!=null&&p.ok)||(a(p.episodes??[]),o(((f=p.settings)==null?void 0:f.enabled)===!0))}).catch(()=>{})};u();const h=setInterval(u,5*6e4);return()=>{l=!1,clearInterval(h)}},[]);const r=m.useMemo(()=>CUe(n,e).length,[n,e]),c=m.useCallback(l=>{t(l),yt(KW,String(l))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:r,markWatchSeen:c}}const L7="agent-dag.character-enabled",P7="agent-dag.fm-volume",TUe=1,$W="agent-dag.fm-source",M4e=[{value:"claude-fm",label:"🎧 Claude FM"},{group:"📻 Lofi Girl",value:"lofi-relax",label:"📚 Relax / study"},{group:"📻 Lofi Girl",value:"lofi-game",label:"🎮 Chill / game"},{group:"📻 Lofi Girl",value:"lofi-vibe",label:"🌅 Vibe / chill"},{group:"📻 Lofi Girl",value:"lofi-sleep",label:"💤 Sleep / chill"},{group:"📻 Radio Mix",value:"radio-mix",label:"📡 Live radio mix"},{group:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"}];function NUe(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function AUe(e){return e!=="0"}function jUe(){return AUe(gt(L7))}function EUe(e){return UG(e,TUe)}function RUe(){return EUe(gt(P7))}const O7=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg","--text","--text-secondary","--sunken","--accent-dim","--cat-shell","--cat-agent","--cat-web","--usage-indigo","--usage-pink","--usage-cyan","--usage-lime","--usage-orange","--usage-purple","--font-mono"];function JW(e){const t={};for(const n of O7)t[n]=e(n);return t}function zUe(e){return t=>e[t]??""}function qUe(e,t){return O7.every(n=>e[n]===t[n])}function _Ue(e,t){let n=null,a=0;function s(){a++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:s,run(o){s();const r=a;let c=!1;const l=()=>{r!==a||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){l();return}e.documentElement.dataset.themeTransition="true";try{const u=e.startViewTransition(l);n=u,u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{l()}),u.finished.then(()=>{n===u&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===u&&(l(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,l()}}}}function YW(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function LUe(){const[e,t]=m.useState(kbe),[n,a]=m.useState(vbe),[s,o]=m.useState(Efe),r=m.useRef(s),[c]=m.useState(()=>_Ue(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),l=m.useCallback(y=>{const x=typeof y=="function"?y(r.current):y;x!==r.current&&(r.current=x,c.run(()=>$t.flushSync(()=>o(x))))},[c]);m.useEffect(()=>()=>c.cancel(),[c]);const[u,h]=m.useState(jUe),[p,f]=m.useState(Fme),[b,v]=m.useState(()=>JW(YW)),w=m.useMemo(()=>zUe(b),[b]),T=m.useCallback(y=>yre(y,w),[w]);return m.useEffect(()=>{document.documentElement.dataset.textSize=e,yt(h0,e)},[e]),m.useEffect(()=>{document.documentElement.dataset.density=n,yt(p0,n)},[n]),m.useEffect(()=>{const y=x=>{x.storageArea===Gs()&&((x.key===h0||x.key===null)&&t(sR(x.newValue)),(x.key===p0||x.key===null)&&a(s6(x.newValue)))};return window.addEventListener("storage",y),()=>window.removeEventListener("storage",y)},[]),m.useLayoutEffect(()=>{document.documentElement.dataset.theme=s,document.documentElement.dataset.colorScheme=Og[s].colorScheme,yt(HG,s),v(y=>{const x=JW(YW);return qUe(y,x)?y:x})},[s]),m.useEffect(()=>{yt(L7,u?"1":"0")},[u]),m.useEffect(()=>{yt(PG,p)},[p]),m.useEffect(()=>{const y=document.querySelector('meta[name="theme-color"]'),x=b["--panel"];y&&x&&y.setAttribute("content",x)},[b]),{textSize:e,setTextSize:t,density:n,setDensity:a,theme:s,setTheme:l,characterEnabled:u,setCharacterEnabled:h,character:p,setCharacter:f,palette:b,minimapNodeFill:T}}function PUe(e){const[t,n]=m.useState(()=>new Set),a=m.useMemo(()=>{const o=new Set;for(const r of e.current.agents.values())for(const c of r.tools)o.add(aE(c.name));return Object.keys(K_e).filter(r=>o.has(r))},[e.current,e.current.revision]),s=m.useCallback(o=>{n(r=>{const c=new Set(r);return c.has(o)?c.delete(o):c.add(o),c})},[]);return{presentCats:a,hiddenCats:t,toggleCat:s}}function OUe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const a=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,s())};function r(){var f,b;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(f=n.addEventListener)==null||f.call(n,"statechange",o)),(b=n.resume)==null||b.call(n).then(o,()=>{}),o()}catch{}}function c(f,b,v=b.figure){if(!n||n.state!=="running")return!1;const w=l0(f,v),T=gfe(b.level,w),y=n.currentTime;for(const x of w.notes){const C=n.createOscillator(),A=n.createGain();C.type=w.type??"sine",C.frequency.value=x.hz;const E=y+x.at,R=E+x.ms/1e3;A.gain.setValueAtTime(tO,E),A.gain.exponentialRampToValueAtTime(T,E+mfe),A.gain.exponentialRampToValueAtTime(tO,R),C.connect(A).connect(n.destination),C.start(E),C.stop(R+.02)}return!0}async function l(f,b){var T;if(!e.loadCustom)return"unavailable";let v;try{v=await e.loadCustom(f)}catch{return"unavailable"}if(!v)return"missing";if(v.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const y=new SpeechSynthesisUtterance(v.text),x=window.speechSynthesis.getVoices();y.voice=x.find(C=>C.voiceURI===v.voiceURI)??null,y.rate=v.rate,y.pitch=v.pitch,y.volume=ffe(b.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(y),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let w;try{w=await n.decodeAudioData(v.bytes.slice(0))}catch{return"broken"}try{const y=n.createBufferSource(),x=n.createGain();return y.buffer=w,x.gain.setValueAtTime(bfe(v.normalizationGain,b.level),n.currentTime),y.connect(x).connect(n.destination),a.add(y),(T=y.addEventListener)==null||T.call(y,"ended",()=>a.delete(y)),y.start(n.currentTime),"played"}catch{return"unavailable"}}function u(f,b=!1){var T,y;if(!b&&!e.enabled())return!1;const v=Sfe((T=e.prefs)==null?void 0:T.call(e),f),w=((y=e.customSelection)==null?void 0:y.call(e)[f])??null;return w&&e.loadCustom?(l(w,v).then(x=>{var C;x==="played"||x==="locked"||((x==="missing"||x==="broken")&&((C=e.onCustomFailure)==null||C.call(e,f,w)),c(f,{...v,figure:Ns},Ns))}),!0):!n||n.state!=="running"?!1:c(f,v)}function h(f,b=_l){return l(f,{level:pv(b),figure:Ns}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const f of a)try{f.stop()}catch{}a.clear()}return{unlock:r,play:u,previewCustom:h,silence:p,state:s,get context(){return n}}}function MUe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:a,fallbackCustomRef:s}){m.useEffect(()=>{const o=OUe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>a.current,loadCustom:lfe,onCustomFailure:(u,h)=>s.current(u,h)});e.current=o;const r=["pointerdown","pointerup","keydown"],c=()=>{for(const u of r)window.removeEventListener(u,l,{capture:!0})},l=()=>{var u;o.unlock(),((u=o.context)==null?void 0:u.state)==="running"&&c()};for(const u of r)window.addEventListener(u,l,{capture:!0});return c},[])}function IUe(){const[e,t]=m.useState(RUe),[n,a]=m.useState(()=>Sue(gt(cP))),[s,o]=m.useState(()=>Cue(gt(lP))),[r,c]=m.useState(()=>Tue(gt($W),n,NUe)),[l,u]=m.useState(()=>new Set),[h,p]=m.useState(0);m.useEffect(()=>{yt(P7,String(e))},[e]),m.useEffect(()=>{yt(lP,s?"1":"0")},[s]),m.useEffect(()=>{yt(cP,JSON.stringify(n))},[n]),m.useEffect(()=>{yt($W,r)},[r]);const f=m.useCallback((y,x=!1)=>{a(C=>{const A=C.find(E=>E.id===y.id);return A?!x||!y.radio||!A.radio||A.url===y.url&&JSON.stringify(A.radio)===JSON.stringify(y.radio)?C:C.map(E=>E.id===y.id?{...E,url:y.url,radio:y.radio}:E):[...C,y]}),u(C=>{if(!C.has(y.id))return C;const A=new Set(C);return A.delete(y.id),A})},[]),b=m.useCallback((y,x)=>{const C=x.trim();!C||C.length>B5||a(A=>A.map(E=>E.id===y?{...E,name:C}:E))},[]),v=m.useCallback(y=>{a(x=>x.filter(C=>C.id!==y)),c(x=>Nue(x,y)),u(x=>{if(!x.has(y))return x;const C=new Set(x);return C.delete(y),C})},[]),w=m.useCallback((y,x=!1)=>{const C=dP(y),A=l.has(C);y===r&&!A&&!x||(A&&u(E=>{const R=new Set(E);return R.delete(C),R}),c(y),p(E=>E+1))},[r,l]),T=m.useCallback((y,x)=>{const C=dP(y);u(A=>{if(A.has(C)===x)return A;const R=new Set(A);return x?R.add(C):R.delete(C),R})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:r,customFmStations:n,unavailableFmStations:l,fmPlayRequest:h,addFmStation:f,renameFmStation:b,removeFmStation:v,pickFmSource:w,markFmStationAvailability:T}}function DUe(e){const[t,n]=m.useState(null),[a,s]=m.useState(!1),[o,r]=m.useState(null),c=m.useRef(0);m.useEffect(()=>{if(!e||!lr())return;let v=!1;const w=c.current;return fetch("/api/desktop-update").then(T=>T.ok?T.json():null).then(T=>{if(v||c.current!==w)return;const y=dW(T);y&&n(y)}).catch(()=>{}),()=>{v=!0}},[e]);const l=AOe(t),u=m.useRef(!1),h=m.useRef(0),p=m.useRef(0);m.useEffect(()=>()=>window.clearTimeout(h.current),[]);const f=m.useCallback(async v=>{if(!$a(u.current))return;const w=++p.current;window.clearTimeout(h.current),u.current=!0,s(!0),r(null);const T=y=>{w===p.current&&(window.clearTimeout(h.current),u.current=!1,s(!1),r({failure:y,version:v}))};try{const y=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:v})});if(!y.ok)return T(qOe(await y.json().catch(()=>null)))}catch{return T("unreachable")}w===p.current&&(h.current=window.setTimeout(()=>T("timeout"),F8))},[]),b=m.useCallback(v=>{if(lr())try{const w=dW(JSON.parse(v));w&&(c.current++,n(w),w.status!=="ready"&&(p.current++,window.clearTimeout(h.current),u.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:a,desktopUpdateFailure:o,readyAppUpdate:l,appUpdate:t,askDesktopUpdateRestart:f,onDesktopUpdateEvent:b}}let M7=!1;function FUe(){M7=!0}const ZW=["focus","keydown","pointerdown"],XW={capture:!0},BUe=400;function I4e(e,t){if(typeof window>"u"||lr(t))return()=>{};let n=null;const a=s=>{if(M7||(s.preventDefault(),s.returnValue="",!e||n))return;const o=()=>{n==null||n(),e()},r=setTimeout(()=>{var c;typeof document<"u"&&((c=document.hasFocus)!=null&&c.call(document))&&o()},BUe);for(const c of ZW)window.addEventListener(c,o,XW);n=()=>{clearTimeout(r);for(const c of ZW)window.removeEventListener(c,o,XW);n=null}};return window.addEventListener("beforeunload",a),()=>window.removeEventListener("beforeunload",a)}const sb="agent-dag.autoRestart",QW="agent-dag.bundleReloadedFor";function UUe({now:e,stateRef:t,version:n,notice:a,noticeOpen:s,upgradeFailure:o,paused:r}){const[c,l]=m.useState(()=>gt(sb)!=="0"),u=m.useRef(!1),h=m.useCallback(()=>{const L=!c;u.current=!0,Ja(sb),l(L);const P=O=>{l(j=>j===L?!L:j),Dl(O)};fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:L})}).then(async O=>{var M;const j=await O.json().catch(()=>null);if(!O.ok||!(j!=null&&j.ok))return P(j);Ai(null),l(((M=j.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>P(null))},[c]),[p,f]=m.useState(!1),[b,v]=m.useState("restart"),[w,T]=m.useState(null),y=m.useRef(!1),x=m.useRef(null),C=m.useRef(0),A=m.useRef(null),E=m.useCallback(async L=>{if(!$a(y.current))return;const P=(L==null?void 0:L.upgrade)===!0,O=(L==null?void 0:L.whenIdle)===!0;y.current=!0,x.current=o;const j=++C.current,M=()=>{v(P?"npx":"restart"),f(!0)};O||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(a==null?void 0:a.to)??"")}catch{}let F=!1;try{const U=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O?{upgrade:P,whenIdle:O}:{upgrade:P})});F=O&&U.status===409}catch{}if(F){y.current=!1,A.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}O&&M(),window.setTimeout(()=>{if(C.current===j&&y.current){y.current=!1,f(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[a==null?void 0:a.to,o]);m.useEffect(()=>{const L=hW(t.current.agents.values())>0,P=CMe({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:L,idleSince:A.current,now:e});A.current=P.idleSince,P.restart&&E({whenIdle:!0})},[c,a==null?void 0:a.kind,n==null?void 0:n.canRestart,s,e,E]);const R=hW(t.current.agents.values()),z=xMe(R,r),I=J8({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:R>0,idleSince:A.current,now:e});m.useEffect(()=>{const L=n==null?void 0:n.running;let P=null,O=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),O=window.sessionStorage.getItem(QW)}catch{return}const j=kMe({bundle:"4.0.3",running:L,pending:P,lastTried:O});if(j==="reload"){try{window.sessionStorage.setItem(QW,L??"")}catch{return}FUe(),window.location.reload();return}if(j!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}y.current=!1,f(!1),T(L??null);const M=window.setTimeout(()=>T(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]);const _=m.useCallback(()=>T(null),[]);m.useEffect(()=>{if(p&&wMe({asked:x.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}y.current=!1,f(!1)}},[p,o]);const D=m.useCallback(L=>{var P,O;if(!u.current){const j=gt(sb)==="0";Ja(sb),j&&((P=L.prefs)==null?void 0:P.autoUpdate)!==!1?(l(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):l(((O=L.prefs)==null?void 0:O.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:h,restarting:p,restartMode:b,restartedTo:w,dismissRestarted:_,askRestart:E,restartCopy:z,restartFuseMs:I,loadAutoRestartPrefs:D}}function WUe(){const[e,t]=m.useState([]),n=m.useRef(new Set),[a,s]=m.useState(null),[o,r]=m.useState(void 0);m.useEffect(()=>{let u=!0,h=0;const p=()=>{fetch("/api/lan").then(f=>f.ok?f.json():null).then(f=>u?(f!=null&&f.ok&&t(GO(Array.isArray(f.pending)?f.pending:[],f.aliases)),f):null).catch(()=>null).then(f=>{u&&(r(b=>f!=null&&f.ok?f:b===void 0?null:b),h=window.setTimeout(p,(f==null?void 0:f.enabled)===!0?D0:TV))})};return p(),()=>{u=!1,window.clearTimeout(h)}},[]);const c=m.useCallback(async(u,h)=>{if(!a){s(u);try{const f=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:u,fp:h})})).json().catch(()=>null);f&&Array.isArray(f.pending)?t(GO(f.pending,f.aliases)):t(b=>b.filter(v=>v.fp!==h))}catch{}finally{s(null)}}},[a]),l=m.useCallback(u=>{a||(n.current.add(u),t(h=>[...h]))},[a]);return{lanPending:e,lanDeferred:n,lanBusy:a,answerLanPair:c,deferLanPair:l,lanStatus:o}}const HUe=6e4;function GUe({enabled:e,lanStatus:t,now:n}){const[a,s]=m.useState(null),[o,r]=m.useState(()=>new Set),[c,l]=m.useState(null),u=m.useCallback(y=>{y!=null&&y.ok&&Array.isArray(y.accounts)&&s(y.accounts)},[]),h=m.useCallback(async y=>{try{const x=await fetch(`/api/claude-accounts${y?"?refresh=1":""}`);x.ok&&u(await x.json())}catch{}},[u]);m.useEffect(()=>{e&&h(!1)},[e,h]),m.useEffect(()=>{if(!e)return;let y=Date.now();const x=()=>{document.visibilityState!=="visible"||Date.now()-y<HUe||(y=Date.now(),h(!1))};return document.addEventListener("visibilitychange",x),window.addEventListener("focus",x),()=>{document.removeEventListener("visibilitychange",x),window.removeEventListener("focus",x)}},[e,h]);const p=m.useMemo(()=>e?yDe(a,{lan:t,now:n,closed:o}):[],[e,a,t,n,o]),f=m.useRef(p);f.current=p;const b=m.useCallback(y=>{y.length&&r(x=>new Set([...x,...y]))},[]),v=m.useCallback(()=>{const y=f.current;y.length&&(b(y.map(x=>x.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:y.map(x=>({key:x.key,since:x.since}))})}).catch(()=>{}))},[b]),w=m.useRef(c);w.current=c;const T=m.useCallback(y=>{const x=w.current;b(xDe(x?[x,...f.current]:f.current,y))},[b]);return{rows:p,accounts:a,signingIn:c,observe:u,signIn:l,signedIn:T,refresh:m.useCallback(()=>{h(!0)},[h]),closeSignIn:m.useCallback(()=>l(null),[]),later:v}}const VUe=288,Oz=VUe;function KUe(){const e=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--rail-w"));return Number.isFinite(e)&&e>0?e:Oz}function $Ue(){const[e,t]=m.useState(Oz);return m.useLayoutEffect(()=>{const n=()=>t(KUe());n();const a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-density"]}),()=>a.disconnect()},[]),e}function JUe(e,t,n){return e?"session-list":t||n?"accounts":null}function eH(e,t=Oz,n=t){return e==="session-list"||e==="accounts"?n:0}const YUe=240,ZUe=20;function XUe(e){const t=m.useRef(0),n=m.useRef(e);return m.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=Ya()?0:performance.now()+YUe+ZUe)},[e]),t}const I7="agent-dag.sessionListOpen",TE="agent-dag.accountsPanelOpen";function QUe(){return gt(I7)==="1"}function tH(e){yt(I7,e?"1":"0")}function eWe(){return gt(TE)==="1"}function tWe(){const e=m.useRef(!1),t=m.useRef(!1),n=m.useRef(!1),[a,s]=m.useState(()=>{const A=QUe();return Gr()?(n.current=!A,!0):A});m.useEffect(()=>{if(n.current){n.current=!1;return}t.current||tH(a)},[a]);const o=m.useRef(!1),[r,c]=m.useState(()=>{const A=eWe();return A&&Gr()?(e.current=!0,!1):A&&a?(o.current=!0,!1):A});m.useEffect(()=>{if(r)e.current=!1;else if(e.current)return;t.current||!r&&o.current||yt(TE,r?"1":"0")},[r]),m.useEffect(()=>{!a&&o.current&&(o.current=!1,c(!0))},[a]);const l=m.useCallback(()=>{s(A=>(!A&&!Gr()&&c(E=>(E&&(o.current=!0),!1)),!A))},[]),u=m.useCallback(()=>{o.current=!1,c(A=>(!A&&!Gr()&&s(!1),!A))},[]),h=m.useCallback(()=>{o.current=!1,c(A=>(!A&&!Gr()&&s(!1),!0))},[]),p=m.useCallback(()=>s(!1),[]),f=m.useCallback(()=>{o.current=!1,s(!1)},[]),b=m.useCallback(()=>c(!1),[]),v=m.useCallback(()=>{o.current=!1,s(!1),c(!1)},[]),w=JUe(a,r,o.current),T=m.useRef(null);T.current={sessionListOpen:a,accountsPanelOpen:r};const y=m.useCallback(()=>{const A=T.current;!A||!A.sessionListOpen||!A.accountsPanelOpen||(o.current=!0,c(!1))},[]),x=m.useCallback(()=>{e.current=!0,c(!1)},[]),C=m.useMemo(()=>({hold:()=>{t.current=!0},release:(A,E)=>{t.current=!1;const R=T.current;!A||!R||((!E||R.sessionListOpen!==E.list)&&tH(R.sessionListOpen),(!E||R.accountsPanelOpen!==E.accounts)&&(R.accountsPanelOpen||!o.current)&&yt(TE,R.accountsPanelOpen?"1":"0"))}}),[]);return{sessionListOpen:a,accountsPanelOpen:r,panel:w,toggleSessionList:l,toggleAccountsPanel:u,openAccountsPanel:h,closeSessionList:p,closeSessionListToCanvas:f,closeAccountsPanel:b,dismissColumn:v,leavePhone:y,holdAccounts:x,storeHold:C}}function nWe({active:e,wide:t,column:n}){const a=m.useRef(null),s=m.useRef(!1),o=m.useRef(!1),{sessionListOpen:r,accountsPanelOpen:c,toggleSessionList:l,closeSessionList:u,openAccountsPanel:h,dismissColumn:p,storeHold:f}=n;m.useLayoutEffect(()=>{const b=o.current;if(o.current=e,e&&!b){s.current=!1,t&&!r?(a.current={kind:"list"},f==null||f.hold(),l()):!t&&(r||c)&&(a.current={kind:"dismissed",held:r?"list":"accounts"},f==null||f.hold(),p());return}const v=a.current;if(!e&&b){a.current=null,f==null||f.release(!1),(v==null?void 0:v.kind)==="list"&&r?u():(v==null?void 0:v.kind)==="dismissed"&&!r&&!c&&(v.held==="list"?l():h());return}if(!e||!v)return;(v.kind==="list"?r:!r&&!c)?s.current=!0:s.current&&(a.current=null,f==null||f.release(!0,v.kind==="list"?{list:!0,accounts:!1}:{list:!1,accounts:!1}))},[e,r,c])}const aWe="(min-width: 641px) and (max-width: 839px)";function sWe({narrow:e,leftOpen:t,rightOpen:n,lastOpened:a}){return!e||!t||!n?{left:t,right:n}:a==="left"?{left:!0,right:!1}:{left:!1,right:!0}}function iWe(e,t){return t.right&&!e.right?"right":t.left&&!e.left?"left":e.last}function oj(e,t,n){return a=>{if(!t()){e(a);return}const s=typeof a=="function"?a(!1):a;s&&n(),e(s)}}function nH(e,t){return()=>{if(!t.folded()){e();return}t.raise(),t.holds()||e()}}function oWe(e){const t=Ws(aWe),[n,a]=m.useState(()=>({...e,last:e.right?"right":"left"})),s=sWe({narrow:t&&n.board,leftOpen:n.left,rightOpen:n.right,lastOpened:n.last}),o={left:n.left&&!s.left,right:n.right&&!s.right},r=Pt(o),c=m.useCallback(u=>a(h=>h.last===u?h:{...h,last:u}),[]);return{fold:o,foldRef:r,raise:c,settle:u=>{u.left===n.left&&u.right===n.right&&u.board===n.board||a({...u,last:iWe(n,u)})}}}function rWe(e,t){const n=new Set;for(const a of t){if(a==null)continue;const s=e.agents.get(a);s?n.add(s.sessionId):n.add(a)}return n}const cWe=typeof window>"u"?m.useEffect:m.useLayoutEffect;function lWe(e,t,n){cWe(()=>{const s=[];for(const o of e.current.agents.values())o.kind==="root"&&s.push([o.sessionId,tk(o)]);nge(s)},[n,e]);const a=t.join(`
|
|
359
359
|
`);m.useEffect(()=>{const s=()=>{for(const o of t){if(o==null)continue;const r=e.current.agents.get(o),c=r&&e.current.agents.get(r.sessionId);c&&tge(c.sessionId,tk(c))}};return s(),document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[a,n,e])}const D7="agent-dag.detailOpen",F7="agent-dag.usagePanelOpen",B7="agent-dag.systemPanelOpen";function dWe(){return gt(D7)==="1"}function uWe(e){yt(D7,e?"1":"0")}function hWe(){return gt(F7)==="1"}function pWe(e){yt(F7,e?"1":"0")}function gWe(){return gt(B7)==="1"}function mWe(e){yt(B7,e?"1":"0")}function fWe(e=0,t=!1){const[n,a]=m.useState(dWe),s=m.useRef(!1);m.useEffect(()=>{if(n)s.current=!1;else if(s.current)return;uWe(n)},[n]);const o=m.useRef(!1),[r,c]=m.useState(()=>{const f=hWe();return f&&Gr()?(o.current=!0,!1):f});m.useEffect(()=>{if(r)o.current=!1;else if(o.current)return;pWe(r)},[r]);const l=m.useRef(!1),[u,h]=m.useState(()=>{const f=gWe();return f&&Gr()||f&&r&&!t&&Gre(e)?(l.current=!0,!1):f});return m.useEffect(()=>{if(u)l.current=!1;else if(l.current)return;mWe(u)},[u]),na("usage-panel",r),na("machine-panel",u),{detailOpen:n,setDetailOpen:a,usagePanelOpen:r,setUsagePanelOpen:c,machinePanelOpen:u,setMachinePanelOpen:h,hold:{detail:()=>{s.current=!0,a(!1)},usage:()=>{o.current=!0,c(!1)},machine:()=>{l.current=!0,h(!1)}}}}const bWe={permission:"permission",asked:"answer"},kWe=()=>S("shell.announce.allClear");function vWe(e){if(e.length===0)return"";const[t,...n]=e,a=t.waiting.kind,s=n.every(o=>o.waiting.kind===a)?bWe[a]??"you":"you";return n.length===0?S(`shell.announce.block.${s}`,{label:t.label}):S(`shell.announce.blockMore.${s}`,{label:t.label,count:n.length})}function Ab(e,t,n=kWe()){return t!==""?t:e===""?"":n}function wWe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[a,s]=m.useState(""),o=vWe(e);m.useEffect(()=>{s(f=>Ab(f,o))},[o]);const[r,c]=m.useState(""),l=t>0?S("shell.announce.watch",{count:t}):"";m.useEffect(()=>{c(f=>Ab(f,l,S("shell.announce.watchNone")))},[l]);const[u,h]=m.useState(""),p=wUe(n);return m.useEffect(()=>{h(f=>Ab(f,p,yUe()))},[p]),{blockedSaid:a,watchSaid:r,setWatchSaid:c,incidentSaid:u}}function yWe(e,t){return`${e}#done@${t}`}function xWe(e){var n;const t=[];for(const a of e){if(a.kind!=="root")continue;const s=tk(a);if(s==null||a.prompts.length===0&&a.toolCount===0||a.closedAt!=null)continue;const o=bs(a.waiting)?"block":a.job&&(a.job.state==="working"||a.job.state==="blocked")?"job":null;t.push({id:a.sessionId,label:a.label,endedAt:s,startedAt:((n=a.prompts.at(-1))==null?void 0:n.at)??a.startedAt,key:yWe(a.sessionId,s),held:o,facts:a})}return t}function CWe(e,t=S){const n=Jk(e),a=n==="err"?t("board.card.stateFailed"):n==="partial"?`${t("board.card.stateDone")} · ${t("board.failedCount",{n:e.toolErrorCount??0})}`:t("board.card.stateDone"),s=Wl(e),o=s.folder&&!El(s.folder,e.label)?s.folder:void 0,r=iv({...s,folder:o});return r?`${a}
|
|
360
|
-
${r}`:a}function Mz(e,t){const n=t.get(e.id);return n!=null&&(n.key===e.key||n.startedAt===e.startedAt)}function SWe(e,t,n,a=!0){if(!a)return[];if(n)return[];const s=[];for(const o of e)o.held||Mz(o,t)||s.push({key:o.key,title:o.label,body:CWe(o.facts),sessionId:o.id});return s}function TWe(e,t,n){const a=new Set(t.map(o=>o.key)),s=new Map;for(const o of e)(a.has(o.key)||o.held==="block"||Mz(o,n))&&s.set(o.id,{key:o.key,startedAt:o.startedAt});return s}function ib(e,t=new Map){const n=new Map;for(const a of e)(a.held!=="job"||Mz(a,t))&&n.set(a.id,{key:a.key,startedAt:a.startedAt});return n}const NWe="/icon-192.png",AWe=[];function aH(e,t){try{const n=new Notification(e.title,{body:e.body,tag:e.key,icon:NWe});n.onclick=()=>{window.focus(),t(e.sessionId),n.close()}}catch{}}const U7=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0});function sH(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:U7[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped")}}function jWe({waitingSessions:e,liveSince:t,focusSession:n,stateRef:a}){const[s,o]=m.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[r,c]=m.useState(null),[l,u]=m.useState(!1),[h,p]=m.useState(!1),[f,b]=m.useState(U7),v=m.useCallback(j=>{const M=!f[j];b(U=>({...U,[j]:M}));const F=U=>{b(H=>H[j]===M?{...H,[j]:!M}:H),Dl(U)};fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[j]:M})}).then(async U=>{const H=await U.json().catch(()=>null);if(!U.ok||!(H!=null&&H.ok))return F(H);Ai(null),b(sH(H.prefs))}).catch(()=>F(null))},[f]),w=m.useRef(()=>{}),T=m.useRef(new Set),y=Pt(e),x=m.useRef({graph:null,revision:-1,turns:AWe}),C=(a==null?void 0:a.current)??null;C&&(x.current.graph!==C||x.current.revision!==C.revision)&&(x.current={graph:C,revision:C.revision,turns:xWe(C.agents.values())});const A=x.current.turns,E=m.useRef(new Map),R=m.useCallback(()=>{const j=!l;u(j),j&&(T.current=Sf(y.current),E.current=ib(x.current.turns,E.current)),j&&typeof Notification<"u"&&Notification.permission==="default"&&w.current();const M=F=>{u(U=>U===j?!j:U),Dl(F)};fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:j})}).then(async F=>{var H;const U=await F.json().catch(()=>null);if(!F.ok||!(U!=null&&U.ok))return M(U);Ai(null),u(((H=U.prefs)==null?void 0:H.notifications)===!0),p(U.notificationsVetoed===!0)}).catch(()=>M(null))},[l]),z=typeof Notification<"u";m.useEffect(()=>{if(!r)return;const M=setTimeout(()=>c(null),r==="blocked"?8e3:4e3);return()=>clearTimeout(M)},[r]);const I=m.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(j=>{const M=j;o(M),M==="granted"?c("on"):M==="denied"&&c("blocked")})},[]);w.current=I;const _=m.useRef(null),D=e.map(j=>Qk(j.id,j.waiting)).join("|"),L=A.map(j=>j.held?`${j.key}~${j.held}`:j.key).join("|");m.useEffect(()=>{yce(_.current,s)&&(_.current=s,E.current=ib(A,E.current),T.current=Sf(e))},[s]);const P=m.useRef(!1);m.useEffect(()=>{xce(P.current,t)&&(P.current=!0,E.current=ib(A,E.current),T.current=Sf(e))},[t]),m.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!OL(_.current,t))return;const j=typeof document>"u"||!document.hidden,M=vce(e,T.current,j,l);for(const F of M)aH(F,n);T.current=j?Sf(e):wce(e,M,T.current)},[D,t]),m.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!OL(_.current,t))return;const j=typeof document>"u"||!document.hidden,M=SWe(A,E.current,j,l);for(const F of M)aH(F,n);E.current=j?ib(A,E.current):TWe(A,M,E.current)},[L,t]);const O=m.useCallback(j=>{var M;u(((M=j.prefs)==null?void 0:M.notifications)===!0),p(j.notificationsVetoed===!0),b(sH(j.prefs))},[]);return{notifyPermission:s,notifySaid:r,notifyOn:l,notifyVetoed:h,toggleNotify:R,notifySupported:z,askForNotifications:I,loadNotifyPrefs:O,accountNotify:f,toggleAccountNotify:v}}function EWe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:a,summaryFor:s,browserWatchOpen:o,keyHelpOpen:r,releaseNotes:c,feedbackOpen:l,trafficRadarOpen:u=!1}){const h=Pt(r),p=m.useRef(!1);return p.current=e!=null||t||n!=null||a||s!=null||o||r||c!=null||l||u,{keyHelpOpenRef:h,modalOpenRef:p}}function RWe({stateRef:e,tourOpen:t,releaseNotes:n}){var O;const[a,s]=m.useState(null),o=m.useCallback((j,M)=>s({agentId:j,toolId:M}),[]),[r,c]=m.useState(null),[l,u]=m.useState(null),h=m.useCallback(j=>u(j),[]),[p,f]=m.useState(!1),[b,v]=m.useState(!1),[w,T]=m.useState(!1),[y,x]=m.useState(!1),[C,A]=m.useState(!1),[E,R]=m.useState(null),z=m.useCallback(j=>{R(j??null),A(!0)},[]);na("tool-detail",a!==null),na("session-summary",r!==null),na("context-window",l!==null),na("keyboard-help",p),na("usage-history",b),na("browser-watch",w),na("feedback",C);const I=a?kje(e.current.agents,a.agentId,a.toolId):null,_=a?(O=e.current.agents.get(a.agentId))==null?void 0:O.cwd:void 0,D=l?e.current.agents.get(l):void 0,{keyHelpOpenRef:L,modalOpenRef:P}=EWe({openedTool:I,usageHistoryOpen:b,contextFor:l,tourOpen:t,summaryFor:r,browserWatchOpen:w,keyHelpOpen:p,releaseNotes:n,feedbackOpen:C,trafficRadarOpen:y});return{setOpenedToolKey:s,openTool:o,openedTool:I,openedToolCwd:_,summaryFor:r,setSummaryFor:c,contextFor:l,setContextFor:u,openContext:h,contextAgent:D,keyHelpOpen:p,setKeyHelpOpen:f,usageHistoryOpen:b,setUsageHistoryOpen:v,browserWatchOpen:w,setBrowserWatchOpen:T,trafficRadarOpen:y,setTrafficRadarOpen:x,feedbackOpen:C,setFeedbackOpen:A,feedbackPrefill:E,setFeedbackPrefill:R,openFeedback:z,keyHelpOpenRef:L,modalOpenRef:P}}function zWe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:a,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:r,rerender:c,modalOpenRef:l}){const[u,h]=m.useState(!1),p=m.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=IR(),t.current.clear(),n.current.clear(),a.current.clear(),s.current="",n8(),o(),r(),c()},[c,r,o]),f=Pt(u),b=m.useCallback(v=>{const w=KMe(v,{confirmOpen:f.current,modalOpen:l.current});w==="confirm"?h(!0):w==="clear"&&(h(!1),p())},[p]);return{clearConfirmOpen:u,setClearConfirmOpen:h,requestClear:b}}const iH="agent-dag.oldNameNoticeDismissed";function qWe(e){const[t,n]=m.useState(()=>gt(iH)??""),a=e!=null&&e.invokedAs&&e.invokedAs!==an?e.invokedAs:null,s=a!=null&&t!==a,o=m.useCallback(()=>{a&&(n(a),yt(iH,a))},[a]);return{oldName:a,oldNameOpen:s,dismissOldName:o}}const _We=300*1e3,LWe=1800*1e3,PWe=8e3,OWe=3e4;function oH(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function MWe({modalOpenRef:e}){const t=m.useCallback(()=>Fr({appModal:e.current,dialogDepth:Rn.dialogDepth()}),[e]),[n,a]=m.useState("hidden"),[s,o]=m.useState(null),[r,c]=m.useState(!1),l=m.useRef(n);l.current=n,m.useEffect(()=>{let b=!1;const v=async()=>{if(l.current==="thanks"||l.current==="hidden"&&(document.hidden||t()))return;const y=await fetch("/api/rating").then(x=>x.ok?x.json():null).catch(()=>null);b||!y||a(x=>x==="thanks"?x:y.ask===!0?"asking":"hidden")},w=window.setTimeout(v,_We),T=window.setInterval(v,LWe);return()=>{b=!0,window.clearTimeout(w),window.clearInterval(T)}},[t]),m.useEffect(()=>{if(n!=="thanks"||r)return;const b=s!==null&&s<=6?OWe:PWe;let v=0;const w=()=>{t()?v=window.setTimeout(w,b):a("hidden")};return v=window.setTimeout(w,b),()=>window.clearTimeout(v)},[n,s,r,t]);const u=m.useCallback(b=>{o(b),c(!1),a("thanks"),oH({score:b})},[]),h=m.useCallback(b=>c(b),[]),p=m.useCallback(()=>{a("hidden"),oH({later:!0})},[]),f=m.useCallback(()=>a("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:u,rateLater:p,closeRating:f,holdThanks:h}}function IWe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:a}){const[s,o]=m.useState(()=>Zme(gt)),r=Pt(s),[c,l]=m.useState([]),u=m.useCallback(x=>{o(C=>{const A={...C,[x]:null};return r.current=A,A}),Ja(_p[x])},[]),h=m.useCallback((x,C)=>{const A=r.current[x];C&&A!==C||(u(x),t(E=>{const R={...E,[x]:{...E[x],figure:Ns}};return n.current=R,R}),yt(ak[x],Ns))},[u]),p=Pt(h);m.useEffect(()=>{let x=!0;return cfe().then(C=>{if(!x)return;l(C);const A=new Set(C.map(E=>E.id));for(const E of Lp){const R=r.current[E];R&&!A.has(R)&&p.current(E,R)}},()=>{}),()=>{x=!1}},[]);const f=m.useCallback((x,C)=>{if(!c.some(E=>E.id===C))return;const A={...r.current,[x]:C};r.current=A,o(A),yt(_p[x],C),a(x,!0)},[c,a]),b=m.useCallback(async x=>{var R;const C=c0(c.length);if(C)throw new $n(C);const A=window.AudioContext??window.webkitAudioContext;if(!A)throw new $n(S("settings.sounds.custom.decodeFail"));const E=new A;try{const z=await afe(x,_=>E.decodeAudioData(_));await QP(z);const I=rg(z);l(_=>[..._.filter(D=>D.id!==I.id),I])}finally{(R=E.close)==null||R.call(E)}},[c.length]),v=m.useCallback(async x=>{const C=c0(c.length);if(C)throw new $n(C);const A=sfe(x);await QP(A);const E=rg(A);l(R=>[...R.filter(z=>z.id!==E.id),E])},[c.length]),w=m.useCallback(async(x,C)=>{const A=c.find(R=>R.id===x),E=C.trim().slice(0,80);!A||!E||E===A.name||(await dfe(x,E),l(R=>R.map(z=>z.id===x?{...z,name:E}:z)))},[c]),T=m.useCallback(async x=>{await ufe(x),l(R=>R.filter(z=>z.id!==x));const C=r.current,A=Xme(C,x);r.current=A,o(A);const E=Lp.filter(R=>C[R]===x);for(const R of E)Ja(_p[R]),yt(ak[R],Ns);E.length>0&&t(R=>{const z={...R};for(const I of E)z[I]={...z[I],figure:Ns};return n.current=z,z})},[]),y=m.useCallback(x=>{var E,R;const C=Lp.find(z=>r.current[z]===x),A=C?n.current[C].level:_l;(E=e.current)==null||E.unlock(),(R=e.current)==null||R.previewCustom(x,A)},[]);return{customSelections:s,customSelectionsRef:r,customAssets:c,clearCustomOnly:u,fallbackCustomRef:p,selectCustomTone:f,importNotificationAudio:b,createNotificationVoice:v,renameCustomAsset:w,deleteCustomAsset:T,previewCustomAsset:y}}function DWe(e){const[t,n]=m.useState(()=>Cfe(gt)),a=Pt(t),s=m.useRef(null),o=m.useCallback((c,l=!1)=>{var u,h;if((u=e.current)==null||u.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!l){(h=e.current)==null||h.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},kfe)},[]),r=m.useCallback((c,l)=>{n(u=>{const h={level:pv(l.level??u[c].level),figure:FG(c,l.figure??u[c].figure)};return yt(WG[c],String(h.level)),yt(ak[c],h.figure),{...u,[c]:h}}),o(c,!0)},[o]);return m.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:a,previewTone:o,changeTone:r}}const FWe=15e3;function BWe(e){return e.visibilityState==="visible"&&e.hasFocus()}function UWe(e,t){return t||e===!0}function WWe(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function HWe(){m.useEffect(()=>{const e=WWe();let t=null;const n=r=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:r}),keepalive:!0}).catch(()=>{})},a=()=>{const r=BWe(document);UWe(t,r)&&n(r),t=r},s=()=>{t&&n(!1),t=!1};a();const o=window.setInterval(a,FWe);return window.addEventListener("focus",a),window.addEventListener("blur",a),document.addEventListener("visibilitychange",a),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",a),window.removeEventListener("blur",a),document.removeEventListener("visibilitychange",a),window.removeEventListener("pagehide",s),s()}},[])}function GWe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n,loadTerminalPrefs:a,loadAccountPrefs:s}){m.useEffect(()=>{let o=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!o||!(r!=null&&r.ok)||(e(r),t(r),n(r),a==null||a(r),s==null||s(r))}).catch(()=>{}),()=>{o=!1}},[])}const rj="agent-dag.versionNoticeDismissed",VWe=15*6e4;function KWe(e){const[t,n]=m.useState(null),[a,s]=m.useState(()=>gt(rj)??""),o=m.useRef(0),[r,c]=m.useState(!1),l=m.useCallback((w=!1)=>(w&&(o.current=Date.now(),c(!0)),fetch(w?"/api/version?refresh=1":"/api/version").then(T=>T.ok?T.json():null).then(T=>(T&&n(T),T??null)).catch(()=>null).finally(()=>{w&&c(!1)})),[]),u=m.useCallback(()=>{l(Date.now()-o.current>=VWe)},[l]);m.useEffect(()=>{l();const w=window.setInterval(u,5*6e4),T=()=>{document.visibilityState==="visible"&&u()};return document.addEventListener("visibilitychange",T),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",T)}},[l,u]),m.useEffect(()=>{e&&l()},[e,l]);const h=(t==null?void 0:t.notice)??null,p=H8(h),f=LOe(h,a),b=m.useCallback(()=>{s(""),yt(rj,"")},[]),v=m.useCallback(()=>{h&&(s(p),yt(rj,p))},[h,p]);return{version:t,notice:h,noticeOpen:f,showNotice:b,dismissNotice:v,versionChecking:r,loadVersion:l}}const rH={tourSeen:!0,tourEdition:bg};function $We({version:e,readyAppUpdate:t}){const[n,a]=m.useState(!1),s=m.useRef(null),[o,r]=m.useState(null),c=o&&t?t.version:null,l=m.useRef(null);m.useEffect(()=>{!c||l.current===c||(l.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const u=m.useRef(!1);m.useEffect(()=>{if(u.current)return;const T=Gs(),y=UDe(T),x=JDe({stored:y,running:(e==null?void 0:e.running)??null,notes:TW,remembers:WDe(T)});if(x.reason==="no-version")return;u.current=!0,x.record&&HDe(T,x.record);let C=!0;return(async()=>{var I;let E=VDe(T);if(lr())try{const _=await fetch("/api/prefs");if(!_.ok)throw new Error("desktop tour preferences unavailable");const D=await _.json();if(!(D!=null&&D.ok))throw new Error("desktop tour preferences unavailable");const L=qz((I=D.prefs)==null?void 0:I.tourEdition)>=bg;E&&!L&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(rH),keepalive:!0}).catch(()=>{}),E=E||L}catch{E=!0}if(!C)return;const R=$De({tourSeen:E,decision:x,phone:Gr()}),z=x.show.length?{entries:x.show,since:y,firstRun:!1}:null;R.tour&&a(!0),R.notes==="now"?r(z):R.notes==="after"&&(s.current=z)})(),()=>{C=!1}},[e==null?void 0:e.running]);const h=(e==null?void 0:e.running)??"4.0.2",p=m.useMemo(()=>l7(TW,null,h),[h]),f=m.useCallback(()=>{r({entries:p,since:null,firstRun:!1})},[p]),b=m.useCallback(()=>a(!0),[]),v=m.useCallback(()=>r(null),[]),w=m.useCallback(()=>{a(!1),KDe(Gs()),lr()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(rH),keepalive:!0}).catch(()=>{});const T=s.current;s.current=null,T&&r(T)},[]);return{tourOpen:n,openTour:b,closeTour:w,releaseNotes:o,closeReleaseNotes:v,chipVersion:h,openReleaseNotes:f}}function JWe(){const[e,t]=m.useState(void 0),[n,a]=m.useState(!1),s=m.useRef(!1);return s.current=e===!0&&!n,m.useEffect(()=>KBe(()=>s.current),[]),{loadReportsPrefs:m.useCallback(r=>{var c;t(((c=r.prefs)==null?void 0:c.reports)!==!1),a(r.reportsVetoed===!0)},[])}}function YWe(e){const[t,n]=m.useState(null);m.useEffect(()=>{const l=gt("agent-dag.sound");n(l===null?!0:l==="on")},[]);const a=m.useCallback(()=>{n(l=>{var h,p;const u=l!==!0;return yt("agent-dag.sound",u?"on":"off"),u?(h=e.current)==null||h.unlock():(p=e.current)==null||p.silence(),u})},[]),s=m.useCallback(l=>{a()},[a]),o=Pt(s),r=Pt(t),c=m.useCallback(l=>{r.current!==null&&r.current!==l&&a()},[a]);return{soundOn:t,toggleSound:a,setSound:c,activateSoundRef:o,soundOnRef:r}}function ZWe(){const[e,t]=m.useState(zme),n=m.useCallback((o,r)=>{t(c=>qme(c,o,r))},[]),a=m.useCallback(()=>t(o=>({...o,open:!1})),[]),s=m.useCallback(o=>t(r=>({...r,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,settingsLandOn:e.landOn,openSettings:n,closeSettings:a,showSection:s}}const XWe="agent-dag.autoFitDisabled";function QWe(e){const t=m.useRef(!1),[n,a]=m.useState(!1);m.useEffect(()=>{Ja(XWe)},[]);const s=m.useCallback(()=>{t.current||(t.current=!0,a(!0))},[]),o=m.useCallback(()=>{t.current=!1,a(!1),e()},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}const eHe=[80,100,120,160],tHe=3,cH=80,nHe=24,Iz=20,tw=nHe+Iz,W7=14,aHe=12,lH=320,cj=168,sHe=400,iHe=1100,NE=44,Dz=36,oHe=new Set(["compact","tighter","tightest"]);function rHe(e){return e&&oHe.has(e)?Dz:NE}const nc=32,cHe=36,lHe=56,dHe=52,uHe=55,Fz=12,H7=5,G7=20,uc={w:8,h:18},uo=(e,t)=>Number.isFinite(e)&&e>0?e:t;function V7(e,t){return Math.ceil(e*uo(t,uc.w))+tw}function hHe(e,t,n){return Math.floor((e-n-tw)/uo(t,uc.w))}function dH(e,t,n){const a=hHe(e,t,n);return{min:cH,max:a,detents:eHe.filter(s=>s>=cH&&s<=a)}}function pHe(e,t){if(!Number.isFinite(e))return t.min;const n=Math.max(t.min,Math.min(t.max,Math.round(e)));let a=null;for(const s of t.detents)Math.abs(s-e)>tHe||(a===null||Math.abs(s-e)<Math.abs(a-e))&&(a=s);return a??n}function D4e(e,t,n){return(t-e-tw)/uo(n,uc.w)}function F4e(e,t,n){if(t==="widest")return n.max;if(t==="narrowest")return n.min;if(t==="wider")return n.detents.find(s=>s>e)??n.max;const a=n.detents.filter(s=>s<e);return a.length?a[a.length-1]:n.min}function gHe(e,t,n,a){const s=e.detents.filter(o=>t-V7(o,n)>=a);return s.length?s[s.length-1]:e.detents[0]??e.min}function mHe(e,t){return e>t.max?t.detents.length?t.detents[t.detents.length-1]:t.max:pHe(e,t)}function fHe(e,t,n,a,s){const o=Math.max(G7,Math.floor((t-W7-Iz)/n)),r=e.externalBar?0:Math.max(nc,uo(e.barH??nc,nc)),c=Math.max(0,e.bodyH-s-r),l=Math.max(H7,Math.floor((c-Fz)/a));return{cols:o,rows:l,stageW:t,navW:0,density:"rail",takeover:!1,headH:s,termTop:aHe,range:{min:o,max:o,detents:[]},fill:!0}}function uH(e){const t=uo(e.cellW,uc.w),n=uo(e.cellH,uc.h),a=Math.max(0,e.appW),s=Math.max(Dz,uo(e.headH??NE,NE));if(e.fill)return fHe(e,a,t,n,s);const o=e.narrow||e.expanded;let c=dH(a,t,o?cj:lH);c.max<c.min&&!o&&(c=dH(a,t,cj));const l=c.max<c.min;let u;l?(u=Math.max(G7,Math.floor((a-tw)/t)),c={min:u,max:u,detents:[]}):e.expanded?u=c.max:e.storedCols!=null&&Number.isFinite(e.storedCols)?u=mHe(e.storedCols,c):u=gHe(c,a,t,e.narrow?cj:sHe);const h=l?a:V7(u,t),p=l?0:a-h,f=e.externalBar?0:Math.max(nc,uo(e.barH??nc,nc)),b=Math.max(0,e.bodyH-s-f),v=Math.max(H7,Math.floor((b-Fz)/n)),w=Math.max(6,Math.floor((b-v*n)/2)),T=o||p<lH?"rail":"tiles";return{cols:u,rows:v,stageW:h,navW:p,density:T,takeover:l,headH:s,termTop:w,range:c}}const Bz="agent-dag.terminal.cols";function bHe(e=gt){const t=e(Bz);if(t==null||!/^\d{1,3}$/.test(t.trim()))return null;const n=Number(t.trim());return n>=20&&n<=500?n:null}function kHe(e,t=yt){Number.isInteger(e)&&e>0&&t(Bz,String(e))}function vHe(e,t,n,a,s,o=!1){const r=uo(n.w,uc.w),c=uo(n.h,uc.h);return{w:Math.ceil(e*r+W7+Iz),h:Math.ceil(t*c+Math.max(Dz,a)+(o?0:Math.max(nc,s))+Fz)}}function wHe(){return{phase:"closed",target:null,origin:null,originName:null,grace:!1,focusRequest:null,popover:null,last:null}}function yHe(e,t){return e===t?!0:!e||!t||e.kind!==t.kind?!1:e.kind==="session"&&t.kind==="session"?e.id===t.id:e.kind==="launch"&&t.kind==="launch"?e.key===t.key:e.kind==="empty"}function ma(e){return(e==null?void 0:e.kind)==="session"?e.id:null}function ac(e){return e==="waiting"||e==="opening"||e==="open"}function xHe(e){return(e.phase==="opening"||e.phase==="open")&&!e.grace}function CHe(e){return e==="opening"||e==="open"||e==="closing"}const hH={phase:"closed",target:null,origin:null,originName:null,grace:!1,focusRequest:null,popover:null};function SHe(e,t){switch(t.type){case"open":{const n=t.target.kind==="session"?t.target.id:e.last;if(e.phase==="closed")return{...e,phase:"waiting",target:t.target,origin:t.origin??null,originName:t.origin?t.originName??null:null,grace:!!t.grace,focusRequest:t.focus??null,popover:null,last:n};const a=t.focus??e.focusRequest;return yHe(e.target,t.target)&&a===e.focusRequest&&e.phase!=="closing"?e:{...e,phase:e.phase==="closing"?"open":e.phase,target:t.target,focusRequest:a,last:n}}case"focus":return e.phase==="closed"?e:{...e,focusRequest:t.token};case"reveal":return e.phase==="waiting"?{...e,phase:"opening"}:e;case"revealed":return e.phase==="opening"?{...e,phase:"open"}:e;case"close":return e.phase==="closed"?e:e.phase==="waiting"||t.instant?{...hH,last:e.last}:e.phase==="closing"?e:{...e,phase:"closing",popover:null,grace:!1};case"closed":return e.phase==="closing"?{...hH,last:e.last}:e;case"grace-over":return e.grace?{...e,grace:!1}:e;case"popover":return e.phase==="closed"||e.popover===t.anchor?e:{...e,popover:t.anchor};case"launched":{const n=e.target;return(n==null?void 0:n.kind)!=="launch"||n.key!==t.key||!t.sessionId?e:{...e,target:{kind:"session",id:t.sessionId,launch:n.key},last:t.sessionId}}case"remember":return t.sessionId&&e.last!==t.sessionId?{...e,last:t.sessionId}:e}}function pH(e,t,n){return e?{kind:"session",id:e}:t&&n(t)?{kind:"session",id:t}:{kind:"empty"}}const THe="ts-empty-new-session";function gH(e,t){return!e||!t||!(e.w>0)||!(e.h>0)?null:e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y?e:null}function NHe(e){return e?[...e.querySelectorAll(".board-nav [data-nav-session]")].map(t=>t.getAttribute("data-nav-session")??"").filter(Boolean):[]}function AHe(e){var n,a;const t=e;return((a=(n=t==null?void 0:t.closest)==null?void 0:n.call(t,"[data-nav-session]"))==null?void 0:a.getAttribute("data-nav-session"))??null}const mH="agent-dag.terminal.firstRunDone",jHe=1e4,EHe=256,RHe=new Set(["Shift","Control","Alt","AltGraph","Meta","OS","Super","Hyper","Fn","FnLock","CapsLock","NumLock","ScrollLock","Dead"]);function fH(e){return{text:"",until:e+jHe}}function zHe(e){return e.text||e.spoiled?"typed":"empty"}function qHe(e){return e.spoiled?"":e.text}function _He(e,t,n=zs(js())){var o;if(RHe.has(t.key))return null;if(t.key==="Escape")return"end";const a={key:t.key,code:t.code??"",ctrlKey:t.ctrlKey,shiftKey:t.shiftKey===!0,metaKey:t.metaKey,altKey:t.altKey,repeat:t.repeat,isComposing:t.isComposing,keyCode:t.keyCode,getModifierState:(o=t.getModifierState)==null?void 0:o.bind(t)};if(JR(a))return"end";if($R(a))return null;if(t.isComposing||t.keyCode===229)return{ahead:{...e,spoiled:!0},swallow:!1};if(a.repeat&&a.key==="Enter")return{ahead:e,swallow:!0};const s=LHe({...a,type:"keydown"},n);return s==null||s==="\x1B"?{ahead:{...e,spoiled:!0},swallow:!1}:[...e.text].length+[...s].length>EHe?{ahead:{...e,spoiled:!0},swallow:!0}:{ahead:{...e,text:e.text+s},swallow:!0}}function LHe(e,t){var o;const n=I0e(e,t);return n==="newline"||n==="send"||n==="meta"?D0e(e,n,t):n!=="pass"||!(((o=e.getModifierState)==null?void 0:o.call(e,"AltGraph"))===!0||!e.ctrlKey&&!e.metaKey&&(!e.altKey||t))?null:e.key==="Enter"?e.altKey||e.shiftKey?null:"\r":e.key==="Backspace"?e.altKey?null:"":[...e.key].length===1?e.key:null}function PHe(e){if(!e||K7(e))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?!0:e.isContentEditable===!0}function K7(e){var t;return((t=e==null?void 0:e.classList)==null?void 0:t.contains("xterm-helper-textarea"))===!0}const OHe=8e3,MHe=3200,IHe="board.asks.noMoreSaid";function DHe(){return{run:null,arrival:null,waiting:null,stageOpen:!1,said:""}}const bH=(e,t)=>e!=null&&e.length===t.length&&e.every((n,a)=>n===t[a]);function FHe(e,t,n){let a=e;for(const s of n)!t.includes(s.id)||e[s.id]===s.label||(a===e&&(a={...e}),a[s.id]=s.label);return a}function BHe(e,{waiting:t,stageOpen:n,current:a,now:s}){const o=t.map(v=>v.id);if(e.waiting===null)return{...e,waiting:o,stageOpen:n};const r=new Set(e.waiting),c=new Set(o),l=(v,w=v)=>{var T;return((T=t.find(y=>y.id===v))==null?void 0:T.label)??w},u=t.filter(v=>!r.has(v.id)),h=[];let p=e.run,f=e.arrival;if(e.stageOpen&&!n&&(p=null,f=null),p){const v=p,w=v.ids.filter(z=>!v.done.includes(z)&&!c.has(z));for(const z of w)h.push(S("board.asks.resumedSaid",{name:v.labels[z]??z}));let T=w.length>0?[...v.done,...w]:v.done,y=v.ids,x=v.fresh;for(const z of u){if(T.includes(z.id))T=T.filter(I=>I!==z.id);else if(!y.includes(z.id))y=[...y,z.id];else continue;x=z.id,h.push(S("board.asks.waitingSaid",{name:z.label}))}let C=FHe(v.labels,y,t);for(const z of y)C[z]===void 0&&(C={...C,[z]:l(z)});const A=y.every(z=>T.includes(z));let E=v.endsAt;A&&E===null?(E=s+MHe,h.push(S(IHe))):A||(E=null),(y!==v.ids||T!==v.done||x!==v.fresh||C!==v.labels||E!==v.endsAt)&&(p={ids:y,done:T,fresh:x,labels:C,endsAt:E})}else if(n){const v=u.filter(T=>T.id!==a);for(const T of v)h.push(S("board.asks.waitingSaid",{name:T.label}));const w=v[v.length-1];w&&(f={id:w.id,label:w.label,until:s+OHe})}f&&(!c.has(f.id)||f.id===a)&&(f=null);const b=h.length>0?Ab(e.said,h.join(" "),e.said):e.said;return p===e.run&&f===e.arrival&&bH(e.waiting,o)&&n===e.stageOpen&&b===e.said?e:{run:p,arrival:f,waiting:bH(e.waiting,o)?e.waiting:o,stageOpen:n,said:b}}function rp(e,t){switch(t.type){case"observe":return BHe(e,t);case"start":{if(e.run||t.waiting.length===0)return e;const n={};for(const a of t.waiting)n[a.id]=a.label;return{...e,run:{ids:t.waiting.map(a=>a.id),done:[],fresh:null,labels:n,endsAt:null},arrival:null}}case"take-arrival":return e.arrival?{...e,arrival:null}:e;case"expire":{const n=e.arrival&&e.arrival.until<=t.now?null:e.arrival,a=e.run&&e.run.endsAt!==null&&e.run.endsAt<=t.now?null:e.run;return n===e.arrival&&a===e.run?e:{...e,arrival:n,run:a}}}}function UHe(e){return(e==null?void 0:e.ids.find(t=>!e.done.includes(t)))??null}function $7(e,t){if(e.arrival)return e.arrival.id;const n=e.run;return(n==null?void 0:n.ids.find(a=>!n.done.includes(a)&&a!==t))??null}function WHe(e){var n,a;const t=[(n=e.arrival)==null?void 0:n.until,(a=e.run)==null?void 0:a.endsAt].filter(s=>typeof s=="number");return t.length>0?Math.min(...t):null}function HHe(e,t){const n=e.run;if(!n)return{track:[],position:null,resumed:null,next:null,clear:!1,arrival:e.arrival};const a=l=>n.done.includes(l),s=n.ids.map(l=>({id:l,state:a(l)?"done":l===t?"now":"todo",fresh:l===n.fresh})),o=t==null?-1:n.ids.indexOf(t),r=o>=0&&!a(t),c=$7({...e,arrival:null},t);return{track:s,position:r?{index:o+1,total:n.ids.length}:null,resumed:o>=0&&!r?{id:t,label:n.labels[t]??t}:null,next:r||c==null?null:{id:c,label:n.labels[c]??c},clear:n.ids.every(a),arrival:null}}function GHe({waitingSessions:e,stageOpen:t,currentId:n,switchTo:a}){const[s,o]=m.useState(DHe),r=Pt(s),c=Pt(e),l=Pt(n),u=Pt(a),h=e.map(v=>`${v.id} ${v.label}`).join(`
|
|
361
|
-
`);m.useEffect(()=>{o(v=>rp(v,{type:"observe",waiting:c.current,stageOpen:t,current:n,now:Date.now()}))},[h,t,n,c]);const p=WHe(s);m.useEffect(()=>{if(p===null)return;const v=setTimeout(()=>o(w=>rp(w,{type:"expire",now:Date.now()})),Math.max(0,p-Date.now()));return()=>clearTimeout(v)},[p]);const f=m.useCallback(()=>{var y;const v=c.current,w=rp(r.current,{type:"start",waiting:v}),T=UHe(w.run)??((y=v[0])==null?void 0:y.id)??null;T!==null&&(o(x=>rp(x,{type:"start",waiting:v})),u.current(T,{focusPane:!0}))},[r,c,u]),b=m.useCallback(()=>{const v=r.current;if(!v.run&&!v.arrival){f();return}const w=$7(v,l.current);w!==null&&(v.arrival&&o(T=>rp(T,{type:"take-arrival"})),u.current(w,{focusPane:!0}))},[r,l,u,f]);return{view:HHe(s,n),said:s.said,startAsks:f,nextAsk:b}}const J7=4,VHe=40,KHe=8,nw=1,$He=.3,AE="agent-dag.workspace.split",Uz={kind:"empty"};function JHe(e="p0"){return{root:{kind:"leaf",id:e},targets:{[e]:Uz},focused:e,max:null,next:Number(e.slice(1))+1||1}}function aa(e){return e.kind==="leaf"?[e.id]:[...aa(e.a),...aa(e.b)]}function ob(e){return aa(e.root).length}function kg(e,t,n){return t===e.focused&&n?n:e.targets[t]??Uz}function YHe(e,t,n=aa(e.root)){const a=new Map;return n.length<2||n.forEach((s,o)=>{const r=kg(e,s,t);r.kind==="session"&&a.set(r.id,{number:o+1,active:s===e.focused})}),a}function lj(e,t,n,a){for(const s of aa(e.root)){if(s===a)continue;const o=kg(e,s,n);if(o.kind==="session"&&o.id===t)return s}return null}function vg(e,t,n=nw){if(e.kind==="leaf")return t;const a=vg(e.a,t,n),s=vg(e.b,t,n);return e.dir==="row"?{w:a.w+n+s.w,h:Math.max(a.h,s.h)}:{w:Math.max(a.w,s.w),h:a.h+n+s.h}}function ZHe(e,t,n,a=nw){const s=vg(e,n,a);return s.w<=t.w&&s.h<=t.h}function kH(e,t,n,a){const s=Math.max(0,e),o=Math.round(s*t);return n+a>s?o:Math.min(s-a,Math.max(n,o))}function XHe(e,t,n,a=nw){const s=new Map,o=[],r=(c,l,u)=>{if(c.kind==="leaf"){s.set(c.id,l);return}const h=vg(c.a,n,a),p=vg(c.b,n,a);if(c.dir==="row"){const f=l.w-a,b=kH(f,c.ratio,h.w,p.w);r(c.a,{x:l.x,y:l.y,w:b,h:l.h},u+"a"),r(c.b,{x:l.x+b+a,y:l.y,w:f-b,h:l.h},u+"b"),o.push({path:u,dir:"row",rect:{x:l.x+b,y:l.y,w:a,h:l.h},start:l.x,length:f,minA:h.w,minB:p.w,ratio:c.ratio})}else{const f=l.h-a,b=kH(f,c.ratio,h.h,p.h);r(c.a,{x:l.x,y:l.y,w:l.w,h:b},u+"a"),r(c.b,{x:l.x,y:l.y+b+a,w:l.w,h:f-b},u+"b"),o.push({path:u,dir:"col",rect:{x:l.x,y:l.y+b,w:l.w,h:a},start:l.y,length:f,minA:h.h,minB:p.h,ratio:c.ratio})}};return r(e,t,""),{panes:s,dividers:o}}function QHe(e){return[...e.entries()].sort(([,t],[,n])=>Math.abs(t.y-n.y)>2?t.y-n.y:t.x-n.x).map(([t])=>t)}const dj=32;function e3e(e,t,n,a=nw){const s={x:0,y:0,w:Math.max(0,t.w),h:Math.max(0,t.h)},o=aa(e.root);if(o.length<2)return{mode:"one",why:null,rects:new Map([[e.focused,s]]),dividers:[],order:o,strip:0};const r=XHe(e.root,s,n,a),c=QHe(r.panes),l=e.max&&o.includes(e.max)?"max":ZHe(e.root,s,n,a)?null:"narrow";if(!l)return{mode:"split",why:null,rects:r.panes,dividers:r.dividers,order:c,strip:0};const u={x:0,y:dj,w:s.w,h:Math.max(0,s.h-dj)};return{mode:"strip",why:l,rects:new Map(o.map(h=>[h,u])),dividers:[],order:c,strip:dj}}function B4e(e,t){if(!(e.length>0))return .5;let n=t-e.start;return e.minA+e.minB<=e.length&&(n=Math.min(e.length-e.minB,Math.max(e.minA,n))),Math.min(.95,Math.max(.05,n/e.length))}function U4e(e,t,n,a){if(!a||!(e.w>0)||!(e.h>0))return"here";const s=(t-e.x)/e.w,o=(n-e.y)/e.h,r=[["left",s],["right",1-s],["top",o],["bottom",1-o]],[c,l]=r.reduce((u,h)=>h[1]<u[1]?h:u);return l<$He?c:"here"}function W4e(e,t){const n=Math.round(e.w/2),a=Math.round(e.h/2);switch(t){case"left":return{...e,w:n};case"right":return{...e,x:e.x+e.w-n,w:n};case"top":return{...e,h:a};case"bottom":return{...e,y:e.y+e.h-a,h:a};default:return e}}function Pk(e,t,n){if(e.kind==="leaf")return e.id===t?n(e):e;const a=Pk(e.a,t,n),s=Pk(e.b,t,n);return a===e.a&&s===e.b?e:{...e,a,b:s}}function Y7(e,t,n){const a=t==="left"||t==="right"?"row":"col",s=t==="left"||t==="top";return{kind:"split",dir:a,ratio:.5,a:s?n:e,b:s?e:n}}function t3e(e,t,n,a){const s=aa(e.root);if(s.length>=J7||!s.includes(t))return null;let o=e.next;for(;s.includes(`p${o}`);)o++;const r=`p${o}`,c=Pk(e.root,t,l=>Y7(l,n,{kind:"leaf",id:r}));return{state:{...e,root:c,targets:{...e.targets,[r]:a},next:o+1,max:null},id:r}}function jE(e,t){return e.kind==="leaf"?null:e.a.kind==="leaf"&&e.a.id===t?aa(e.b)[0]??null:e.b.kind==="leaf"&&e.b.id===t?aa(e.a).slice(-1)[0]??null:jE(e.a,t)??jE(e.b,t)}function Ok(e,t){if(e.kind==="leaf")return e.id===t?null:e;const n=Ok(e.a,t),a=Ok(e.b,t);return n?a?n===e.a&&a===e.b?e:{...e,a:n,b:a}:n:a}function vH(e,t){const n=aa(e.root);if(n.length<=1||!n.includes(t))return e;const a=Ok(e.root,t)??e.root,s={...e.targets};delete s[t];const o=e.focused===t?jE(e.root,t)??aa(a)[0]:e.focused,r=e.max===t||aa(a).length<2?null:e.max;return{...e,root:a,targets:s,focused:o,max:r}}function n3e(e,t,n,a){const s=aa(e.root);if(t===n||!s.includes(t)||!s.includes(n))return e;if(a==="here"){const r=c=>c.kind==="leaf"?c.id===t?{kind:"leaf",id:n}:c.id===n?{kind:"leaf",id:t}:c:{...c,a:r(c.a),b:r(c.b)};return{...e,root:r(e.root)}}const o=Ok(e.root,t);return o?{...e,root:Pk(o,n,r=>Y7(r,a,{kind:"leaf",id:t})),max:null}:e}function EE(e,t,n){if(e.kind==="leaf")return e;if(!t)return n(e);const[a,s]=[t[0],t.slice(1)];return a==="a"?{...e,a:EE(e.a,s,n)}:{...e,b:EE(e.b,s,n)}}function a3e(e,t,n){if(!Number.isFinite(n))return e;const a=Math.min(.95,Math.max(.05,n));return{...e,root:EE(e.root,t,s=>s.ratio===a?s:{...s,ratio:a})}}function cp(e,t,n){if(!aa(e.root).includes(t))return e;const a=n?{...e.targets,[e.focused]:n}:e.targets;return{...e,targets:a,focused:t,max:e.max&&e.max!==t?t:e.max}}function uj(e,t){const n=e.targets[e.focused];return n&&s3e(n,t)?e:{...e,targets:{...e.targets,[e.focused]:t}}}function s3e(e,t){return e.kind!==t.kind?!1:e.kind==="session"&&t.kind==="session"?e.id===t.id&&e.launch===t.launch:e.kind==="launch"&&t.kind==="launch"?e.key===t.key:!0}function i3e(e,t,n){let a=!1;const s={};for(const[o,r]of Object.entries(e.targets))r.kind==="launch"&&r.key===t&&o!==e.focused?(s[o]={kind:"session",id:n,launch:t},a=!0):s[o]=r;return a?{...e,targets:s}:e}const o3e=/^p\d{1,4}$/;function r3e(e,t){const n=aa(e.root);if(n.length<2)return null;const a={};for(const o of n){const r=kg(e,o,t);a[o]=r.kind==="session"?r.id:null}const s={v:1,root:e.root,panes:a,focused:e.focused,next:e.next};return JSON.stringify(s)}function RE(e,t,n){if(!e||typeof e!="object"||n>4)return!1;const a=e;return a.kind==="leaf"?typeof a.id!="string"||!o3e.test(a.id)||t.has(a.id)?!1:(t.add(a.id),!0):a.kind==="split"&&(a.dir==="row"||a.dir==="col")&&typeof a.ratio=="number"&&a.ratio>=.05&&a.ratio<=.95&&RE(a.a,t,n+1)&&RE(a.b,t,n+1)}function c3e(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}const n=t;if(!n||n.v!==1||!n.panes||typeof n.panes!="object")return null;const a=new Set;if(!RE(n.root,a,0)||a.size<2||a.size>J7)return null;const s={};for(const c of a){const l=n.panes[c];s[c]=typeof l=="string"&&l.length>0&&l.length<=200?{kind:"session",id:l}:Uz}const o=typeof n.focused=="string"&&a.has(n.focused)?n.focused:[...a][0],r=Number.isInteger(n.next)&&n.next>0?n.next:a.size;return{root:n.root,targets:s,focused:o,max:null,next:r}}function l3e(e=gt){return c3e(e(AE))}function d3e(e,t,n=yt,a=Ja){const s=r3e(e,t);s?n(AE,s):a(AE)}const Wz=()=>Xs(()=>import("./StageShell-Dn1RGcsF.js").then(e=>e.a),__vite__mapDeps([7,1])),u3e=3e3,h3e=6e3,p3e="board.stage.shellUnavailable",rb={kind:"empty"},lp=e=>({x:e.left,y:e.top,w:e.width,h:e.height});function wH(e,t){try{return(e==null?void 0:e.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`))??null}catch{return null}}function g3e(e){const t=e.querySelector(".lod-name");return t&&t.getBoundingClientRect().width>0?t:e.querySelector(".title .label")}function m3e(){var e,t;return jb()?lHe:rHe(typeof document>"u"||(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.density)}function jb(){return typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches}function f3e(){return typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches}function b3e(e){return e?[...e.querySelectorAll(".session-list .sl-row[data-session]")].filter(t=>t.getClientRects().length>0&&!t.closest("[inert]")).map(t=>t.getAttribute("data-session")??"").filter(Boolean):[]}function k3e(e){var n,a;const t=e;return((a=(n=t==null?void 0:t.closest)==null?void 0:n.call(t,".session-list [data-session]"))==null?void 0:a.getAttribute("data-session"))??null}function Z7(e){try{return document.querySelector(`.session-list .sl-row[data-session="${CSS.escape(e)}"]`)}catch{return null}}function v3e({stateRef:e,canvasRef:t,detailOpen:n,detailShown:a,setDetailOpen:s,primarySelectedIdRef:o,selectAgent:r,view:c="board",phone:l=!1,clearSelection:u,ready:h=!1}){const[p,f]=m.useState(!1),[b,v]=m.useState(null),[w,T]=m.useState(!1),y=Pt(p),[x,C]=m.useState(!1),[A,E]=m.useState(!1),R=Pt(l),z=m.useCallback(ae=>{f(ae.terminalOn===!0),v(typeof ae.terminalSupported=="boolean"?ae.terminalSupported:null),T(ae.terminalWindows===!0),C(!0),(ae.terminalOn!==!0||ae.terminalSupported===!1)&&!R.current&&_k()==="workspace"&&y7("board")},[R]);m.useEffect(()=>{if(x||c!=="workspace")return;const ae=window.setTimeout(()=>C(!0),u3e);return()=>window.clearTimeout(ae)},[x,c]);const I=x7({enabled:p,supported:b},l),_=I&&!A,D=c==="workspace"&&!l&&!A&&(I||!x),[L,P]=m.useState(wHe),O=Pt(L),j=m.useCallback(ae=>{const ye=SHe(O.current,ae);O.current=ye,P(ye)},[O]),M=Pt(n),F=Pt(D),U=L.phase!=="closed",[H,$]=m.useState(uc),[Y,W]=m.useState(()=>bHe()),[G,Q]=m.useState(!1),J=m.useRef(D);m.useLayoutEffect(()=>{J.current!==D&&(J.current=D,Q(!1))},[D]);const[X,te]=m.useState(null),[K,V]=m.useState(()=>jb()?dHe+uHe:f3e()?cHe:nc),[ee,de]=m.useState(m3e),he=m.useCallback(()=>(F.current&&typeof document<"u"?document.querySelector(".ws-cell"):null)??t.current,[t]),me=m.useCallback(()=>{const ae=he();if(!ae)return;const ye=ae.getBoundingClientRect(),Ue=Math.floor(Math.min(ae.clientWidth,ye.width)),lt=Math.floor(Math.min(ae.clientHeight,ye.height)),nt=window.innerWidth<iHe;te(bt=>bt&&bt.w===Ue&&bt.h===lt&&bt.narrow===nt?bt:{w:Ue,h:lt,narrow:nt})},[he]);m.useLayoutEffect(()=>{if(!U)return;me();const ae=he();if(!ae||typeof ResizeObserver>"u")return;const ye=new ResizeObserver(me);return ye.observe(ae),window.addEventListener("resize",me),()=>{ye.disconnect(),window.removeEventListener("resize",me)}},[U,me,he,D]);const be=X&&U?uH({appW:X.w,bodyH:X.h,cellW:H.w,cellH:H.h,expanded:G,narrow:X.narrow,storedCols:Y,fill:D,barH:K,headH:ee,externalBar:!jb()}):null,ie=Pt(be),ne=m.useRef(void 0);ne.current===void 0&&(ne.current=l3e());const[ke,Se]=m.useState(()=>{var ae;return JHe(((ae=ne.current)==null?void 0:ae.focused)??"p0")}),ve=Pt(ke),xe=m.useCallback(ae=>{ae!==ve.current&&(ve.current=ae,Se(ae))},[ve]),Ee=!jb(),Ge=m.useMemo(()=>vHe(VHe,KHe,H,ee,K,Ee),[H,ee,K,Ee]),Qe=D&&X&&U?e3e(ke,X,Ge):null,Je=Pt(Qe),He=m.useCallback((ae,ye)=>uH({appW:Math.floor(ae),bodyH:Math.floor(ye),cellW:H.w,cellH:H.h,expanded:!1,narrow:(X==null?void 0:X.narrow)??!1,storedCols:null,fill:!0,barH:K,headH:ee,externalBar:Ee}),[H,K,ee,X==null?void 0:X.narrow,Ee]),_e=m.useRef(null),le=m.useRef(new Map),[Re,ge]=m.useState(()=>gt(mH)!=="1"),[Pe,Fe]=m.useState(""),[Ve,ot]=m.useState(null);m.useEffect(()=>{if(!Ve)return;const ae=setTimeout(()=>ot(null),h3e);return()=>clearTimeout(ae)},[Ve]);const ce=m.useRef(null),Ce=m.useRef(null),Ke=m.useRef(0),Oe=m.useRef(0),at=m.useRef(null),ut=m.useRef(new Set),vt=m.useRef(null),qe=m.useRef(null),dt=m.useRef(null),et=m.useCallback((ae,ye={})=>{if(!y.current)return;if(ae.kind==="session"&&(ae={...ae,id:gp(e.current.agents,ae.id)}),F.current&&ae.kind==="session"){const Bt=ve.current,Sn=O.current.phase!=="closed"?O.current.target:null,Tn=ob(Bt)>1?lj(Bt,ae.id,Sn,Bt.focused):null;Tn&&(xe(cp(Bt,Tn,Sn)),ae=kg(Bt,Tn,null))}const Ue=ye.focusPane?++Ke.current:null;if(Ue!=null&&(_e.current={token:Ue,pane:ve.current.focused},dt.current=ae.kind==="session"?{token:Ue,session:ae.id,from:document.activeElement,ahead:fH(Date.now())}:null),O.current.phase!=="closed"){j({type:"open",target:ae,focus:Ue});return}const lt=t.current,nt=ye.el??(ae.kind==="session"?wH(lt,ae.id):null),bt=lt?lp(fg(lt)):null,qt=gH(nt?lp(nt.getBoundingClientRect()):null,bt),sn=qt&&(nt!=null&&nt.classList.contains("react-flow__node"))?g3e(nt):null;me(),Zs(),M.current&&!F.current&&s(!1),j({type:"open",target:ae,origin:qt,originName:sn?lp(sn.getBoundingClientRect()):null,grace:!!ye.grace,focus:Ue})},[y,O,t,M,me,s,F,ve,xe,e]),Ie=Pt(r),ct=Pt(u),Nt=m.useRef(null),Le=m.useCallback(ae=>{var ye;if(e.current.agents.has(ae)){Ie.current(ae,!1,!1);return}F.current&&(Nt.current=ae,(ye=ct.current)==null||ye.call(ct))},[e,Ie,F,ct]),Ht=m.useCallback((ae,ye)=>{if(!y.current)return!1;const Ue=gp(e.current.agents,ae);return et({kind:"session",id:Ue},{el:ye,grace:O.current.phase==="closed",focusPane:!0}),!0},[y,e,O,et]),Mt=m.useCallback(ae=>!y.current||!ac(O.current.phase)?!1:(et({kind:"session",id:ae}),Le(ae),!0),[y,O,et,Le]),yn=m.useCallback((ae,ye)=>{y.current&&(et({kind:"session",id:ae},{focusPane:ye.focusPane}),Le(ae))},[y,et,Le]),mn=m.useCallback((ae,ye={})=>{y.current&&(et({kind:"session",id:ae},{focusPane:ye.focusPane===!0}),Le(ae))},[y,et,Le]),xn=m.useCallback(()=>{var ae;y.current&&(et({kind:"empty"},{focusPane:!0}),Nt.current=null,(ae=ct.current)==null||ae.call(ct))},[y,et,ct]),Gt=m.useCallback(ae=>{var sn;const ye=o.current,Ue=ye?((sn=e.current.agents.get(ye))==null?void 0:sn.sessionId)??null:null,lt=pH(Ue,O.current.last,Bt=>e.current.agents.has(Bt)||ut.current.has(Bt)),nt=lt.kind==="session"?wH(t.current,lt.id):null,bt=t.current?lp(fg(t.current)):null,qt=nt&&gH(lp(nt.getBoundingClientRect()),bt);et(lt,{el:qt?nt:ae,focusPane:!0}),qe.current=ae&&typeof ae.focus=="function"?ae:null},[o,e,O,t,et]),tt=m.useRef(null),rt=m.useCallback(ae=>{y.current&&(tt.current="asked",et(rb,{el:ae,focusPane:!0}),qe.current=ae)},[y,et]),Ye=m.useCallback(()=>{if(!ac(O.current.phase))return;const ae=++Ke.current;_e.current={token:ae,pane:ve.current.focused};const ye=ma(O.current.target);dt.current=ye?{token:ae,session:ye,from:document.activeElement,ahead:fH(Date.now())}:null,j({type:"focus",token:ae})},[O,ve]),Vt=m.useCallback((ae,ye)=>{if(!(ye!=null&&ye.keyboard)){et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}if(ae===ma(O.current.target)){Ye();return}et({kind:"session",id:ae}),Le(ae)},[O,et,Le,Ye]),Rt=m.useCallback((ae,ye={})=>{var bt;if(!y.current||!F.current)return!1;const Ue=ve.current;if(!aa(Ue.root).includes(ae))return!1;if(ae===Ue.focused)return ye.keys&&Ye(),!0;const lt=cp(Ue,ae,O.current.phase!=="closed"?O.current.target:null);xe(lt);const nt=lt.targets[ae]??rb;return et(nt,{focusPane:ye.keys===!0}),nt.kind==="session"?Le(nt.id):(Nt.current=nt.kind==="launch"?"launch":null,(bt=ct.current)==null||bt.call(ct)),!0},[y,F,ve,O,xe,Ye,et,Le,ct]),_n=m.useCallback(ae=>{const ye=Je.current;if(!ye||ye.mode==="one")return!1;const Ue=ye.order[ae-1];return Ue?Rt(Ue,{keys:!0}):!1},[Je,Rt]),Xa=m.useCallback((ae,ye={})=>{var Sn;if(!y.current)return;if(ae=gp(e.current.agents,ae),!F.current){et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}const Ue=ve.current,lt=O.current.phase!=="closed"?O.current.target:null,nt=lj(Ue,ae,lt);if(nt){Rt(nt,{keys:!0});return}const bt=ye.at??Ue.focused;if(kg(Ue,bt,lt).kind==="empty"){bt!==Ue.focused&&xe(cp(Ue,bt,lt)),et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}const qt=(Sn=Je.current)==null?void 0:Sn.rects.get(bt),sn=ye.zone??(qt&&qt.h>qt.w?"bottom":"right"),Bt=t3e(lt?uj(Ue,lt):Ue,bt,sn,{kind:"session",id:ae});if(!Bt){ot(Tn=>({text:S("board.stage.split.full"),n:((Tn==null?void 0:Tn.n)??0)+1})),et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}Q(!1),xe(cp(Bt.state,Bt.id,lt)),et({kind:"session",id:ae},{focusPane:!0}),Le(ae)},[y,F,ve,O,Je,xe,et,Le,Rt,e]),fn=m.useCallback((ae,ye)=>{if(!y.current||!F.current)return;ye=gp(e.current.agents,ye);const Ue=ve.current,lt=O.current.phase!=="closed"?O.current.target:null,nt=lj(Ue,ye,lt);if(nt){Rt(nt,{keys:!0});return}ae!==Ue.focused&&xe(cp(Ue,ae,lt)),et({kind:"session",id:ye},{focusPane:!0}),Le(ye)},[y,F,ve,O,xe,et,Le,Rt,e]),cn=m.useCallback((ae,ye,Ue)=>{xe(n3e(ve.current,ae,ye,Ue))},[ve,xe]),ka=m.useCallback((ae,ye)=>{xe(a3e(ve.current,ae,ye))},[ve,xe]),Cn=m.useCallback(ae=>{if(ve.current.max===ae){xe({...ve.current,max:null});return}ae!==ve.current.focused&&Rt(ae),xe({...ve.current,max:ae})},[ve,xe,Rt]),qa=m.useCallback(()=>{ve.current.max&&xe({...ve.current,max:null})},[ve,xe]),ia=m.useCallback(ae=>{var bt;if(!y.current)return;const ye=ve.current;if(!F.current||ob(ye)<=1||!aa(ye.root).includes(ae)){xn();return}const Ue=ye.focused===ae,lt=vH(ye,ae);if(xe(lt),!Ue)return;const nt=lt.targets[lt.focused]??rb;et(nt,{focusPane:!0}),nt.kind==="session"?Le(nt.id):(Nt.current=nt.kind==="launch"?"launch":null,(bt=ct.current)==null||bt.call(ct))},[y,F,ve,xe,xn,et,Le,ct]),_a=m.useCallback(ae=>{const ye=L.phase==="waiting"?null:L.focusRequest,Ue=_e.current;return ye!=null&&(Ue==null?void 0:Ue.token)===ye&&Ue.pane===ae?ye:null},[L.phase,L.focusRequest]),La=m.useCallback((ae,ye,Ue)=>{var nt;const lt=`launch-${Date.now().toString(36)}-${++Oe.current}-${Math.random().toString(36).slice(2,10)}`;et({kind:"launch",agent:ae,cwd:ye,key:lt,...Ue?{options:Ue}:{}},{focusPane:!0}),F.current&&y.current&&(Nt.current="launch",(nt=ct.current)==null||nt.call(ct))},[et,F,y,ct]),Qa=m.useCallback(ae=>{var Ue;const ye=O.current.target;if((ye==null?void 0:ye.kind)!=="launch"||ae.key!==void 0&&ae.key!==ye.key){!!ae.key&&!!ae.sessionId&&Object.entries(ve.current.targets).some(([nt,bt])=>nt!==ve.current.focused&&bt.kind==="launch"&&bt.key===ae.key)&&ae.key&&(le.current.set(ae.key,ae.sessionId),ut.current.add(ae.sessionId),ZM(e.current,ae.sessionId,ae.key));return}!ae.sessionId&&((Ue=at.current)==null?void 0:Ue.key)===ye.key&&at.current.sessionId||(at.current={key:ye.key,sessionId:ae.sessionId},ae.sessionId&&le.current.set(ye.key,ae.sessionId),ae.sessionId&&(ut.current.add(ae.sessionId),j({type:"remember",sessionId:ae.sessionId}),ZM(e.current,ae.sessionId,ye.key)))},[O,e,ve]);m.useEffect(()=>{const ae=L.target;if((ae==null?void 0:ae.kind)!=="launch")return;const ye=at.current,Ue=ye&&ye.key===ae.key?ye.sessionId:le.current.get(ae.key);Ue&&e.current.agents.has(Ue)&&j({type:"launched",key:ae.key,sessionId:Ue})}),m.useEffect(()=>{const ae=ve.current;let ye=ae;for(const[Ue,lt]of Object.entries(ae.targets)){if(Ue===ae.focused||lt.kind!=="launch")continue;const nt=le.current.get(lt.key);nt&&e.current.agents.has(nt)&&(ye=i3e(ye,lt.key,nt))}xe(ye)}),m.useEffect(()=>{!D||L.phase==="closed"||!L.target||xe(uj(ve.current,L.target))},[D,L.phase,L.target,ve,xe]);const Pa=m.useRef(0);m.useEffect(()=>{const ae=ne.current;if(!ae||!p||!D||L.phase==="closed")return;const ye=ve.current;if(ob(ye)>1){ne.current=null;return}Pa.current||(Pa.current=Date.now()+CH);const Ue=Sn=>e.current.agents.has(Sn)||ut.current.has(Sn),lt=Object.values(ae.targets).flatMap(Sn=>Sn.kind==="session"?[Sn.id]:[]);if(!h&&!lt.every(Ue)&&Date.now()<=Pa.current)return;ne.current=null;const nt=O.current.target,bt=ae.targets[ae.focused],qt=(nt==null?void 0:nt.kind)==="empty"&&(bt==null?void 0:bt.kind)==="session"&&Ue(bt.id)?bt.id:null,sn=(nt==null?void 0:nt.kind)==="session"?nt.id:qt;let Bt={...ae,focused:ye.focused,max:null,next:Math.max(ae.next,ye.next)};for(const Sn of aa(ae.root)){if(Sn===Bt.focused)continue;const Tn=Bt.targets[Sn];(!Tn||Tn.kind!=="session"||Tn.id===sn||!Ue(Tn.id))&&(Bt=vH(Bt,Sn))}ob(Bt)<2||(xe(qt?Bt:uj(Bt,nt??rb)),qt&&(et({kind:"session",id:qt}),Le(qt)))}),m.useEffect(()=>{ne.current||!p||!D||d3e(ke,L.phase!=="closed"?L.target:null)},[ke,L.phase,L.target,p,D]),m.useEffect(()=>{const ae=Nt.current;if(ae===null)return;const ye=L.phase==="closed"?null:L.target;if(!F.current||!ye||ye.kind==="empty"){Nt.current=null;return}if(ye.kind==="launch"){ae!=="launch"&&(Nt.current=null);return}if(ae!=="launch"&&ye.id!==ae){Nt.current=null;return}if(!e.current.agents.has(ye.id)){Nt.current=ye.id;return}Nt.current=null,Ie.current(ye.id,!1,!1)});const oa=m.useCallback(()=>{var sn,Bt,Sn;const ae=ma(O.current.target),ye=ie.current,Ue=t.current;if(F.current){const Tn=ae?Z7(ae):null;if(Tn&&Tn.getClientRects().length>0){Tn.focus();return}}let lt=null;try{lt=ae&&Ue?Ue.querySelector(`.board-nav [data-nav-session="${CSS.escape(ae)}"]`):null}catch{}if(ae&<&&ce.current&&ye&&!ye.takeover){ce.current.focusTile(ae);return}const nt=document.querySelector(".stage-dock .wsp-pane[data-focused] .ts-head")??document.querySelector(".stage-dock .ts-head"),bt=nt==null?void 0:nt.querySelector("button[aria-pressed]"),qt=(bt&&((sn=bt.dataset)==null?void 0:sn.zoom)===void 0?bt:null)??(nt==null?void 0:nt.querySelector("button[data-stage-close]"));qt?qt.focus():(Sn=(Bt=document.activeElement)==null?void 0:Bt.blur)==null||Sn.call(Bt)},[O,ie,t,F]),Xt=m.useCallback(()=>j({type:"close"}),[]),es=m.useCallback(ae=>{var lt;const ye=document.activeElement,Ue=!ye||ye===document.body||!!((lt=ye.closest)!=null&<.call(ye,".stage-dock, .stage-nav"));vt.current=Ue?{card:ma(O.current.target)}:null,ae&&Fe(ae),j({type:"closed"})},[O]),In=m.useCallback(()=>{var ye,Ue;const ae=O.current;ae.phase!=="closed"&&((Ue=(ye=document.activeElement)==null?void 0:ye.closest)!=null&&Ue.call(ye,".stage-dock, .stage-nav")&&(vt.current={card:ma(ae.target)}),j({type:"close",instant:!0}))},[O]),Oa=m.useCallback(()=>{Q(!1),In()},[In]),Dn=m.useCallback(()=>{Fe(S(p3e)),E(!0),j({type:"close",instant:!0})},[]),Ma=m.useCallback(()=>j({type:"reveal"}),[]),va=m.useCallback(()=>j({type:"revealed"}),[]),wa=m.useCallback(ae=>Fe(ae),[]),nn=m.useCallback(ae=>j({type:"popover",anchor:ae}),[]),ts=m.useCallback(ae=>{ae.id&&j({type:"popover",anchor:ae.id})},[]),un=m.useCallback(()=>j({type:"popover",anchor:null}),[]),Ia=m.useCallback((ae,ye)=>{W(ae),ye&&kHe(ae)},[]),_i=m.useCallback(()=>{W(null),Ja(Bz)},[]),Fn=m.useCallback(()=>Q(ae=>!ae),[]),ra=m.useCallback(()=>Q(!1),[]),ns=m.useCallback(()=>{ge(!1),yt(mH,"1")},[]),ya=m.useCallback(ae=>$(ye=>ye.w===ae.w&&ye.h===ae.h?ye:ae),[]),fe=m.useCallback(ae=>V(ae),[]),re=m.useCallback(ae=>de(ae),[]);m.useEffect(()=>{p&&Wz().catch(()=>{})},[p]),m.useEffect(()=>{var ye;const ae=tt.current;ae&&(L.phase==="closed"||((ye=L.target)==null?void 0:ye.kind)!=="empty"?tt.current=null:ae==="asked"&&L.phase==="open"?(tt.current="shown",j({type:"popover",anchor:THe})):ae==="shown"&&L.popover===null&&(tt.current=null,j({type:"close"})))},[L.phase,L.target,L.popover,j]);const je=m.useRef(null);m.useEffect(()=>{if(!p||je.current)return;const ae=y3e(Date.now());je.current=ae?{id:ae,until:Date.now()+CH}:"done"},[p]),m.useEffect(()=>{var lt;const ae=je.current;if(!p||!ae||ae==="done")return;const ye=O.current,Ue=F.current&&ye.phase!=="closed"&&((lt=ye.target)==null?void 0:lt.kind)==="empty";if(ye.phase!=="closed"&&!Ue||Date.now()>ae.until){je.current="done";return}e.current.agents.has(ae.id)&&(je.current="done",yn(ae.id,{focusPane:!1}))});const We=L.phase==="closed"?null:ma(L.target),st=je.current==="done";m.useEffect(()=>{if(!p||je.current!=="done"||(hj(We,Date.now()),!We))return;const ae=()=>hj(We,Date.now());return window.addEventListener("pagehide",ae),()=>window.removeEventListener("pagehide",ae)},[p,We,st]),m.useEffect(()=>{if(!L.grace)return;const ae=window.setTimeout(()=>j({type:"grace-over"}),sG);return()=>window.clearTimeout(ae)},[L.grace]),m.useEffect(()=>{a&&!F.current&&In()},[a,In,F]);const Ct=m.useRef(!1);m.useLayoutEffect(()=>{var lt;if(!D){if(!Ct.current)return;Ct.current=!1,Q(!1),O.current.phase!=="closed"&&In();return}if(Ct.current||!p||O.current.phase==="closing"||(Ct.current=!0,O.current.phase!=="closed"))return;const ae=o.current,ye=ae?((lt=e.current.agents.get(ae))==null?void 0:lt.sessionId)??null:null,Ue=pH(ye,O.current.last,nt=>e.current.agents.has(nt)||ut.current.has(nt));et(Ue),Ue.kind==="session"&&Le(Ue.id)},[D,p,L.phase,O,o,e,et,Le,In]);const Et=xHe(L);m.useEffect(()=>{var ye;const ae=(ye=t.current)==null?void 0:ye.querySelector(":scope > .react-flow");if(!p){ae!=null&&ae.hasAttribute("inert")&&ae.removeAttribute("inert");return}ae==null||ae.toggleAttribute("inert",Et)},[p,Et,t]),m.useEffect(()=>{var lt,nt;const ae=vt.current;if(U||!ae)return;vt.current=null;const ye=qe.current;qe.current=null,ae.card?fz(ae.card):ye!=null&&ye.isConnected&&ye.focus();const Ue=document.activeElement;(!Ue||Ue===document.body)&&((nt=(lt=t.current)==null?void 0:lt.focus)==null||nt.call(lt,{preventScroll:!0}))},[U,t]);const xa=m.useCallback(()=>{const ae=dt.current;dt.current=null,ae&&O.current.focusRequest===ae.token&&j({type:"focus",token:null})},[O]);m.useEffect(()=>{if(!p){dt.current=null;return}const ae=(nt,bt)=>!nt||nt===document.body||nt===document.documentElement||nt===bt.from,ye=nt=>{const bt=dt.current;if(!bt)return;const qt=nt.target;if(Date.now()>bt.ahead.until){dt.current=null;return}if(!ae(qt,bt)&&!K7(qt)){xa();return}if(PHe(qt))return;const sn=_He(bt.ahead,nt);sn==="end"&&xa(),!(!sn||sn==="end")&&(dt.current={...bt,ahead:sn.ahead},sn.swallow&&(nt.preventDefault(),nt.stopImmediatePropagation()))},Ue=nt=>{var bt,qt;dt.current&&!((qt=(bt=nt.target)==null?void 0:bt.closest)!=null&&qt.call(bt,".stage-dock"))&&xa()},lt=nt=>{var sn;const bt=dt.current,qt=nt.target;bt&&!ae(qt,bt)&&!((sn=qt==null?void 0:qt.closest)!=null&&sn.call(qt,".stage-dock"))&&xa()};return window.addEventListener("keydown",ye,!0),window.addEventListener("pointerdown",Ue,!0),window.addEventListener("focusin",lt,!0),()=>{window.removeEventListener("keydown",ye,!0),window.removeEventListener("pointerdown",Ue,!0),window.removeEventListener("focusin",lt,!0)}},[p,xa]);const Bn=ac(L.phase)?ma(L.target):null;m.useEffect(()=>{dt.current&&dt.current.session!==Bn&&(dt.current=null)},[Bn]);const zt=m.useCallback(ae=>{const ye=dt.current;return ye&&ye.token===ae&&Date.now()<=ye.ahead.until?zHe(ye.ahead):null},[]),ks=m.useCallback(ae=>{const ye=dt.current;return!ye||ye.token!==ae?"":(dt.current=null,Date.now()>ye.ahead.until?"":qHe(ye.ahead))},[]),Li=m.useRef(0),ni=m.useCallback((ae,ye)=>{fetch("/api/prefs").then(Ue=>Ue.ok?Ue.json():null).then(Ue=>{ae===Li.current&&(Ue!=null&&Ue.ok?z(Ue):f(ye))}).catch(()=>{ae===Li.current&&f(ye)})},[z]),Yl=m.useCallback(()=>{const ae=!y.current,ye=++Li.current;f(ae),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({terminal:ae})}).then(async Ue=>{const lt=await Ue.json().catch(()=>null);Ue.ok&&(lt!=null&<.ok)?(Ai(null),ye===Li.current&&z(lt),yt(xH,String(Date.now()))):(Dl(lt),ni(ye,!ae))}).catch(()=>{Dl(null),ni(ye,!ae)})},[y,z,ni]);m.useEffect(()=>{const ae=ye=>{ye.storageArea!==Gs()||ye.key!==xH||ni(++Li.current,y.current)};return window.addEventListener("storage",ae),()=>window.removeEventListener("storage",ae)},[ni,y]);const fc=m.useRef(!1);return m.useEffect(()=>{var ye;const ae=fc.current;if(fc.current=p,!(p||!ae)){if(O.current.phase!=="closed"){const Ue=document.activeElement;(!Ue||Ue===document.body||!!((ye=Ue.closest)!=null&&ye.call(Ue,".stage-dock, .stage-nav")))&&(vt.current={card:ma(O.current.target)})}j({type:"close",instant:!0}),hj(null,Date.now())}},[p,O]),{enabled:p,supported:b,windows:w,toggleTerminal:Yl,loadTerminalPrefs:z,shell:L,geometry:be,cell:H,expanded:G,firstRun:Re,said:Pe,navRef:ce,keysRef:Ce,workspace:D,workspaceOffered:_,chunkFailed:A,openInPane:mn,emptyPane:xn,leaveWorkspace:Oa,onNodeClick:Ht,followSession:Mt,switchTo:yn,openFromButton:Gt,newSessionFromBoard:rt,openTile:Vt,launch:La,onLaunched:Qa,focusPane:Ye,release:oa,takeTypeAhead:ks,holdsTypeAhead:zt,close:Xt,closed:es,failed:Dn,giveRightBack:In,reveal:Ma,revealed:va,announce:wa,openPopover:nn,newSessionFrom:ts,closePopover:un,onCols:Ia,onColsReset:_i,toggleExpand:Fn,unzoom:ra,firstRunDone:ns,onCell:ya,onBarH:fe,onHeadH:re,split:ke,arrangement:Qe,paneMin:Ge,geometryFor:He,requestFor:_a,focusPaneId:Rt,focusPaneAt:_n,openBeside:Xa,dropHere:fn,movePaneTo:cn,closePane:ia,setSplitRatio:ka,toggleMax:Cn,showAll:qa,splitNote:(Ve==null?void 0:Ve.text)??null}}function yH(e,t,n){const a=e.enabled&&e.shell.phase!=="closed"&&e.workspace!==!0,s=e.workspace===!0&&e.expanded===!0,o=t&&!(a&&CHe(e.shell.phase))&&!s,r=Pt(a),c=Pt(o),l=Pt(s),{giveRightBack:u,unzoom:h}=e,p=m.useCallback(f=>{if(!r.current){if(!l.current){n(f);return}const v=typeof f=="function"?f(c.current):f;v&&(h==null||h()),n(v);return}const b=typeof f=="function"?f(c.current):f;b&&u(),n(b)},[r,c,l,u,h,n]);return{shown:o,set:p}}const xH="agent-dag.terminal.switched",zE="agent-dag.terminal.onStage",w3e=30*6e4,CH=15e3;function y3e(e){try{const t=window.sessionStorage.getItem(zE);if(!t)return null;const n=JSON.parse(t);return typeof n.id!="string"||!n.id||typeof n.at!="number"?null:e-n.at>=0&&e-n.at<w3e?n.id:null}catch{return null}}function hj(e,t){try{e?window.sessionStorage.setItem(zE,JSON.stringify({id:e,at:t})):window.sessionStorage.removeItem(zE)}catch{}}const x3e=[];function C3e(e,t,n){const{enabled:a,shell:s,switchTo:o,navRef:r,focusPane:c,release:l,keysRef:u,workspace:h,expanded:p,focusPaneAt:f}=e,b=GHe({waitingSessions:a?t:x3e,stageOpen:a&&ac(s.phase),currentId:ma(s.target),switchTo:o});return u.current=a?{open:ac(s.phase),current:ma(s.target),get order(){return h?p?[]:b3e(document):NHe(n.current)},sessionAt:h?k3e:AHe,focusTile:v=>{var w,T;h?(w=Z7(v))==null||w.focus():(T=r.current)==null||T.focusTile(v)},...h?{mode:"rail"}:{},switchTo:o,focusPane:c,nextAsk:b.nextAsk,release:l,...h?{focusPaneAt:f}:{}}:null,b}function S3e(e){return null}function T3e({stage:e}){const{failed:t}=e;return m.useEffect(()=>{t()},[t]),null}const N3e=m.lazy(()=>Wz().then(e=>({default:e.StageNavigator}),()=>({default:S3e}))),A3e=m.lazy(()=>Wz().then(e=>({default:e.StageDock}),()=>({default:T3e})));function j3e(e){return!e.stage.enabled||e.stage.workspace||e.stage.shell.phase==="closed"?null:i.jsx(m.Suspense,{fallback:null,children:i.jsx(N3e,{...e})})}function E3e(e){return!e.stage.enabled||e.stage.shell.phase==="closed"?null:i.jsx(m.Suspense,{fallback:null,children:i.jsx(A3e,{...e})})}const R3e="board.view.group",z3e="board.view.board",q3e="board.view.workspace",_3e=()=>i.jsx(Ze,{name:"board",className:"glyph"}),L3e=()=>i.jsx(Ze,{name:"workspace",className:"glyph"});function P3e({view:e,onChange:t}){const n=se(),a=s=>o=>{s!==e&&t(s,o.detail===0?"key":"pointer")};return i.jsxs("div",{className:"view-switch",role:"group","aria-label":n(R3e),children:[i.jsxs("button",{type:"button",className:"view-opt","aria-pressed":e==="board",onClick:a("board"),children:[i.jsx(_3e,{}),n(z3e)]}),i.jsxs("button",{type:"button",className:"view-opt","aria-pressed":e==="workspace",onClick:a("workspace"),children:[i.jsx(L3e,{}),n(q3e)]})]})}function O3e({active:e,detailOpen:t,fold:n,hold:a,restore:s}){const o=m.useRef(null),r=m.useRef(!1),c=m.useRef(!0),l=m.useRef(!1);m.useLayoutEffect(()=>{const u=r.current,h=c.current;if(r.current=e,c.current=!1,e&&!u)o.current=t,n(),t&&(h?l.current=!0:a());else if(!e&&u){const p=o.current;o.current=null,p!==null&&s(p)}},[e]),m.useEffect(()=>{l.current&&(l.current=!1,a())},[])}const X7="workspace-pane",M3e="board.stage.skipToPane";function I3e(e=t=>document.getElementById(t)){const t=e(X7);return t?(t.focus({preventScroll:!0}),!0):!1}function D3e(){return zn(Ya()?"--dur-xfade":"--dur-move")}function F3e(){return typeof document<"u"&&document.documentElement.dataset.motion==="instant"}function B3e(e){const[t,n]=m.useState(e),[a,s]=m.useState(!1);return t!==e&&(n(e),s(!e&&!F3e())),m.useEffect(()=>{if(!a)return;const o=window.setTimeout(()=>s(!1),D3e());return()=>window.clearTimeout(o)},[a]),e?"fold":a&&t===e?"unfold":void 0}const SH="data-view-switch",Q7="data-pin",U3e=["--board-l","--board-t","--board-w","--board-h"];function W3e(e,t){if(!e||!t)return;const n=t.getBoundingClientRect();n.width>0&&n.height>0&&(e.style.setProperty("--board-l",`${n.left}px`),e.style.setProperty("--board-t",`${n.top}px`),e.style.setProperty("--board-w",`${n.width}px`),e.style.setProperty("--board-h",`${n.height}px`),e.setAttribute(Q7,""))}function TH(e){if(e){e.removeAttribute(Q7);for(const t of U3e)e.style.removeProperty(t)}}function H3e(e=document){return typeof e.startViewTransition=="function"&&!e.hidden}let NH=0,dp;function G3e(e,t,n=document){const a=n.documentElement,s=++NH;dp!==void 0&&(clearTimeout(dp),dp=void 0),a.setAttribute(SH,"");const o=()=>{s===NH&&a.removeAttribute(SH)};if(e==="pointer"&&H3e(n)){n.startViewTransition.call(n,()=>{$t.flushSync(t)}).finished.then(o,o);return}$t.flushSync(t),dp=setTimeout(()=>{dp=void 0,o()},60)}let up=null;function AH(e=document){return e.documentElement.dataset.motion==="instant"}function V3e(e=document){if(up)return up;const t=e.documentElement,n=()=>{t.dataset.motion="instant"},a=()=>{delete t.dataset.motion};return e.addEventListener("keydown",n,{capture:!0,passive:!0}),e.addEventListener("pointerdown",a,{capture:!0,passive:!0}),up=()=>{e.removeEventListener("keydown",n,{capture:!0}),e.removeEventListener("pointerdown",a,{capture:!0}),delete t.dataset.motion,up=null},up}const K3e="(max-width: 1319px)",$3e="(max-width: 1099px)",J3e="(max-width: 1023px)",Y3e="(prefers-reduced-motion: reduce)",Z3e=m.lazy(()=>Xs(()=>import("./AccountBridge-BWSoT0Lr.js"),__vite__mapDeps([8,5])));function X3e(){return i.jsx(YE,{children:i.jsx(YBe,{children:i.jsx(Q3e,{})})})}function Q3e(){var yd,xd,Cd;const e=se(),t=Sg(),n=m.useState(IR)[0],a=m.useRef(n),[,s]=m.useState(0),o=m.useCallback(()=>s(Ne=>Ne+1),[]),r=tWe(),{sessionListOpen:c,accountsPanelOpen:l,panel:u,toggleSessionList:h,toggleAccountsPanel:p,openAccountsPanel:f,closeSessionList:b,closeSessionListToCanvas:v,closeAccountsPanel:w,leavePhone:T,holdAccounts:y}=r,x=$Ue(),C=mAe(),A=fAe(x),E=pAe(C.chosen,x,A),{detailOpen:R,setDetailOpen:z,usagePanelOpen:I,setUsagePanelOpen:_,machinePanelOpen:D,setMachinePanelOpen:L,hold:P}=fWe(eH(u,x,E),_k()==="workspace"),O=oWe({left:u!==null,right:I||D,board:_k()!=="workspace"}),{fold:j,foldRef:M,raise:F}=O,U=m.useCallback(()=>M.current.right,[M]),H=m.useCallback(()=>F("right"),[F]),$=m.useMemo(()=>oj(z,U,H),[z,U,H]),Y=Pt(u),W=m.useMemo(()=>nH(h,{folded:()=>M.current.left,holds:()=>Y.current==="session-list",raise:()=>F("left")}),[h,M,Y,F]),G=m.useMemo(()=>nH(p,{folded:()=>M.current.left,holds:()=>Y.current==="accounts",raise:()=>F("left")}),[p,M,Y,F]),Q=c&&!j.left,J=l&&!j.left,{selectedIds:X,primarySelectedId:te,selectAgent:K,clearSelection:V,pruneSelectionToBoard:ee}=T0e(a,$),de=m.useCallback(Ne=>K(Ne,!1,!1),[K]),he=Vd(J,200),me=Vd(Q,200),be=mL(Q,me),ie=Ws(Y3e),ne=Ws(Bl),ke=m.useMemo(()=>ne?ie?LMe():Gp():zn(ie?"--dur-xfade":"--dur-fast"),[ie,ne]),Se=Vd(I&&!j.right,ke),ve=Vd(D&&!j.right,ke),xe=m.useRef(null),Ee=YWe(xe),{activateSoundRef:Ge,soundOnRef:Qe}=Ee,Je=DWe(xe),{setTonePrefs:He,tonePrefsRef:_e,previewTone:le}=Je,Re=IWe({chimesRef:xe,setTonePrefs:He,tonePrefsRef:_e,previewTone:le}),{customSelectionsRef:ge,fallbackCustomRef:Pe}=Re,Fe=ZWe(),{openSettings:Ve}=Fe;MUe({chimesRef:xe,soundOnRef:Qe,tonePrefsRef:_e,customSelectionsRef:ge,fallbackCustomRef:Pe});const ot=QBe(a),{pauseGate:ce,paused:Ce,togglePause:Ke}=ot,Oe=m.useRef(()=>{}),{live:at,tabCapped:ut,everConnected:vt,liveSince:qe,lastNewsAt:dt}=m0e({stateRef:a,rerender:o,pauseGate:ce,chimesRef:xe,desktopUpdateRef:Oe}),et=KWe(at),{version:Ie,notice:ct,noticeOpen:Nt,loadVersion:Le}=et,Ht=DUe(at),{readyAppUpdate:Mt,onDesktopUpdateEvent:yn}=Ht;Oe.current=yn,HWe();const mn=$We({version:Ie,readyAppUpdate:Mt}),{tourOpen:xn,openTour:Gt,releaseNotes:tt}=mn,{workspace:rt,providers:Ye,providersRef:Vt}=sUe(at),Rt=nUe(Ye,l),_n=Rt.shown,Xa=Ne=>{if(Rt.remember(Ne),j.left){F("left"),l||p();return}(!l||_n===Ne)&&p()},fn=eH(ne?c?"session-list":null:u==="accounts"&&!(Ye.claude||Ye.codex)?null:u,x,ne?x:E),cn=j.left?0:fn,ka=XUe(cn),Cn=mL(J,he)&&(Ye.claude||Ye.codex),[qa,ia]=m.useState(!1),_a=Rt.remember,La=m.useCallback(()=>{F("left"),f()},[F,f]),Qa=m.useCallback(()=>{_a(Ye.claude?"claude":"codex"),La()},[La,Ye.claude,_a]),Pa=m.useCallback(()=>{La(),ia(!0)},[La]),[oa,Xt]=m.useState(null),[es,In]=m.useState([]),Oa=m.useMemo(()=>[...oa??[],...es],[oa,es]);m.useEffect(()=>{l||ia(!1)},[l]);const Dn=m.useCallback(()=>ia(!1),[]),Ma=qWe(Ie),va=xUe({version:Ie,loadVersion:Le}),{upgradeFailure:wa}=va,nn=RWe({stateRef:a,tourOpen:xn,releaseNotes:tt}),ts=MWe({modalOpenRef:nn.modalOpenRef}),{openTool:un,setSummaryFor:Ia,setContextFor:_i,openContext:Fn,setKeyHelpOpen:ra,setUsageHistoryOpen:ns,setBrowserWatchOpen:ya,keyHelpOpenRef:fe,modalOpenRef:re}=nn,je=JWe(),We=SUe(),{watchOn:st,watchUnseen:Ct}=We,Et=Xg(),[xa,Bn]=m.useState(null),[zt,ks]=m.useState(!1),Li=m.useCallback(()=>ks(!1),[]),ni=Ne=>{rOe(Ne),Ve("integrations")},Yl=Ne=>{Ne&&rW(Ne),Ve("integrations")},fc=m.useCallback(()=>Bn(null),[]),ae=Az().filter(Ne=>uE(Et,Ne.kind)),ye=Pt(Ne=>{const Lt=ae.find(Na=>Na.kind===Ne);Lt&&Bn(Lt.kind)}),Ue=m.useCallback(Ne=>{rW(Ne),Ve("integrations")},[Ve]),lt=ae.length>0;m.useEffect(()=>{lt&&VPe()},[lt]);const nt=WUe(),[bt,qt]=m.useState(0),{presentCats:sn,hiddenCats:Bt,toggleCat:Sn}=PUe(a),Tn=m.useRef(null),[bc,aw]=m.useState(0),Yn=W0e({stateRef:a,rerender:o,pruneSelectionToBoard:ee,setContextFor:_i,setSummaryFor:Ia});Dde({stateRef:a,now:Yn,enabled:Ye.claude});const Zl=cUe(Ye.claude||Ye.codex),nm=wve(Cn&&Ye.claude),Ju=vUe(Zl,Yn),pr=GUe({enabled:Ye.claude,lanStatus:nt.lanStatus,now:Yn}),Pi=UUe({now:Yn,stateRef:a,version:Ie,notice:ct,noticeOpen:Nt,upgradeFailure:wa,paused:ot.paused}),{askRestart:kc,loadAutoRestartPrefs:Xl}=Pi,Oi=LUe(),{setTheme:Yu,palette:Zu}=Oi,vc=IUe(),ca=dqe(),{applyViewport:am,moveCamera:Mi,fitLeft:Xu,cameraEpochRef:Ql,lastFitTimeRef:Qu}=ca,ai=zqe(ca),{pinnedRef:So,positionsRef:wc,lastLayoutSigRef:Da,handleRelayout:To,rearrangeUndo:eh}=ai,gr=m.useRef(null),sm=m.useRef(()=>{}),No=qe!==null,ed=m.useRef(0),mr=m.useCallback(()=>{ed.current=Date.now()},[]),{canvasRef:Zn,canvasSize:im,paneSizeRef:sw}=w_e(ka),om=QWe(ca.fitAll),{autoFitDisabledRef:rm,disableAutoFit:fr}=om,th=m.useRef(!1),{measuredRef:br,measuredVersionRef:iw,sizeVersion:ow,domSizeVersion:rw}=y_e(th,a),{removedNodes:td,removedAgentIds:la,removeNode:cw,removeSelectedNode:nh,removalNotice:cm,hideSessions:ah,bringBack:vs,bringBackAll:lw,forgetRemovals:dw}=Qqe({stateRef:a,pinnedRef:So,positionsRef:wc,returningRef:ai.returningRef,canvasRef:Zn,clearSelection:V,primarySelectedId:te}),nd=Vqe({stateRef:a,now:Yn,removedAgentIds:la,sizeVersion:ow,domSizeVersion:rw}),{saveSoon:lm}=qqe(nd,ai),{fitSoon:dm}=Xqe({layoutSig:nd,rf:t,stateRef:a,measuredRef:br,pinnedRef:So,positionsRef:wc,paneSizeRef:sw,lastInteractRef:ed,autoFitDisabledRef:rm,lastFitTimeRef:Qu,fitLeft:Xu}),sh=x_e(),{bubbling:uw,endBubble:hw,onBubble:pw}=jAe(),[ih,oh]=m.useState(!1),kr=SAe(),{beginTrashDrag:gw,trackTrashDrag:um,endTrashDrag:hm}=kr,Ao=LAe({stateRef:a,measuredRef:br,measuredVersionRef:iw,canvasRef:Zn}),{lodRef:ad,applyZoom:pm}=Ao,{releaseFitAll:jo}=ca,mw=m.useCallback(()=>{fr(),jo()},[fr,jo]),gm=m.useRef(null),mm=m_e({applyViewport:am,takeOver:ca.takeOver,lastFitTimeRef:Qu,cameraEpochRef:Ql,disableAutoFit:mw,markInteract:mr,canvasRef:Zn,applyZoom:pm,zoomFocusRef:gm}),ws=te?a.current.agents.get(te):null,[fm,Ii]=m.useState(!1),Di=R&&(ws!=null||fm),da=Di&&!j.right,yc=m.useRef(ws);ws&&(yc.current=ws);const ua=R_e({sessionListShown:be,usageShown:no(Se),machineShown:no(ve),accountsShown:Cn&&Ye.claude,codexShown:Cn&&!Ye.claude,detailShown:da,primarySelectedId:te,canvasRef:Zn}),Fi=Xze(!ne&&Di,{usage:I,machine:D}),{railInsetRef:xc,availableWidth:sd,availableHeight:rh}=Qze({canvasRef:Zn,canvasSize:im,machinePhase:ve,usagePhase:Se,usagePanelOpen:I,detailShown:da,folds:Fi.folds}),bm=m.useCallback(()=>{dm(),lm()},[dm,lm]),Bi=Kqe({stateRef:a,now:Yn,availableWidth:sd,availableHeight:rh,layout:ai,measuredRef:br,onBubble:pw,settled:sh,dragging:ih,layoutSig:nd,selectedIds:X,openContext:Fn,historyReplayed:No,removedNodes:td,removedAgentIds:la,dragTick:bt,dragPatchRef:Tn,dragMoveTick:bc,onMoved:bm,packed:Ao.lod!=="detail"}),{nodes:id,edges:Hz}=Bi;ca.boardRef.current=id,f_e({packed:Ao.lod!=="detail",nodes:id,squeeze:Bi.squeeze,focusRef:gm,canvasRef:Zn,getViewport:ca.currentViewport,panBy:ca.panBy});const fw=AAe(Bi.visibleAgentIds),Ui=Pt(te);_qe({settled:sh,dragging:ih,availableWidth:sd,availableHeight:rh,layout:ai,camera:ca,lastFocusRef:gr,focusAgentRef:sm,autoFitDisabledRef:rm});const km=zWe({stateRef:a,pinnedRef:So,measuredRef:br,positionsRef:wc,lastLayoutSigRef:Da,forgetRemovals:dw,clearSelection:V,rerender:o,modalOpenRef:re}),{requestClear:Fa}=km,Cc=z_e({nodes:id,shown:Bi.shown,squeeze:Bi.squeeze,stateRef:a,pinnedRef:So,positionsRef:wc,draggingRef:th,dragPatchRef:Tn,setDragging:oh,setDragMoveTick:aw,setDragTick:qt,endBubble:hw,markInteract:mr,disableAutoFit:fr,beginTrashDrag:gw,trackTrashDrag:um,endTrashDrag:hm,removeNode:cw}),ch=ca.fitAll,od=Pt(id),vm=Pt(Bi.shown),[wm,lh]=m.useState(null),qs=m.useCallback(Ne=>lh(Lt=>({id:Ne,nonce:((Lt==null?void 0:Lt.nonce)??0)+1})),[]),{focusAgent:dh,revealAgent:vr,stepAgent:Eo,focusSession:as}=uqe({canvasRef:Zn,stateRef:a,measuredRef:br,nodesRef:od,shownRef:vm,lodRef:ad,railInsetRef:xc,moveCamera:Mi,currentViewport:ca.currentViewport,disableAutoFit:fr,lastFocusRef:gr,focusAgentRef:sm,selectAgent:K,primarySelectedIdRef:Ui,onLand:qs}),Sc=M2e(),it=v3e({stateRef:a,canvasRef:Zn,detailOpen:R,detailShown:Di,setDetailOpen:$,primarySelectedIdRef:Ui,selectAgent:K,view:Sc.stored,phone:ne,clearSelection:V,ready:No}),_t=it.workspace,Ro=B3e(_t&&it.expanded),rd=!Ws($3e);nWe({active:_t&&it.enabled,wide:rd,column:r});const Ba=!Ws(K3e),Un=yLe({workspace:_t&&it.enabled,wide:rd,column:Ba}),uh=Un&&!ie&&!AH()?zn("--dur-stage-out"):0,ym=Vd(da,ne?ke:uh),Tc=(ne||uh>0)&&wf(da,ym),cd=m.useRef(!1);da&&(cd.current=ws==null);const xm=!(_t&&Ba)&&(da?ws==null:Tc&&cd.current),hh=da?ws:Tc&&!cd.current?yc.current:null;m.useLayoutEffect(()=>{Un&&P.detail()},[Un]);const[si,zo]=m.useState(!1),ld=m.useRef(R);m.useEffect(()=>{R&&!ld.current&&zo(!1),ld.current=R},[R]),O3e({active:_t,detailOpen:R,fold:()=>zo(!0),hold:P.detail,restore:z});const Cm=_t&&Ba&&it.shell.phase!=="closed"?ma(it.shell.target):null;m.useLayoutEffect(()=>{Cm&&zo(!1)},[Cm]),m.useLayoutEffect(()=>{Fre(_t)},[_t]);const Nc=m.useCallback(()=>{zo(!0),$(!1),requestAnimationFrame(()=>{JU(document)})},[$]),qo=m.useRef(!1);m.useEffect(()=>{const Ne=qo.current;qo.current=Un&&da,!(!Ne||qo.current||!Un)&&requestAnimationFrame(()=>{const Lt=document.activeElement;(!Lt||Lt===document.body||Lt.closest(".detail"))&&JU(document)})},[Un,da]);const bw=_t&&(Ro!==void 0||it.expanded),Ac=xLe({workspace:_t,column:Ba,folded:si,shown:da,zoomed:bw}),jc=m.useCallback(()=>{Ii(!0),$(!0)},[$]),hn=m.useCallback(()=>{V(),Ii(!1)},[V]);m.useEffect(()=>{(!R||te||_t&&Ba)&&Ii(!1)},[R,te,_t,Ba]);const dd=m.useCallback(()=>{zo(!1),Ui.current?$(!0):!nE(a.current,as,Eo)&&Un&&jc(),requestAnimationFrame(()=>{var Ne;(Ne=document.querySelector('.detail .insp-tab[aria-selected="true"]'))==null||Ne.focus()})},[$,Ui,a,as,Eo,Un,jc]),Ec=m.useCallback(()=>{const Ne=CLe({workspace:_t,column:Ba,sheet:Un,open:Ac});Ne==="fold"?Nc():Ne==="show"?dd():Ui.current?$(Lt=>!Lt):Ac?Ii(!1):nE(a.current,as,Eo)||jc()},[_t,Ba,Un,Ac,Nc,dd,$,Ui,a,as,Eo,jc]),Rc=Pt(Ec),Sm=Pt(Un&&da?Nc:null),ph=Ws(J3e),Ln=ewe({workspace:_t&&!ne,open:{usage:I,machine:D},mounted:{usage:no(Se),machine:no(ve)},narrow:ph}),zc=Ne=>Fi.on?()=>Fi.fold(Ne):void 0,_o={usage:qU(Ln.dock.usage,Fi.folds.usage,()=>Fi.unfold("usage"),zc("usage")),machine:qU(Ln.dock.machine,Fi.folds.machine,()=>Fi.unfold("machine"),zc("machine"))},qc=m.useRef(!1);m.useLayoutEffect(()=>{if(!_t||Ba){qc.current=!1;return}Ln.on&&da?(qc.current=!0,P.detail()):!Ln.on&&qc.current&&(qc.current=!1,Ui.current&&$(!0))},[Ln.on,_t,Ba]);const ud=m.useRef(null);m.useEffect(()=>{_t||TH(ud.current)},[_t]);const{leaveWorkspace:Tm,openInPane:ys}=it,Lo=m.useCallback((Ne,Lt,Na)=>{G3e(Lt,()=>{Ne==="workspace"?(ii.current||W3e(ud.current,Zn.current),Na&&(ys(Na,{focusPane:!0}),qs(Na))):(TH(ud.current),Tm()),Sc.set(Ne)})},[Tm,ys,qs,Sc.set]),_c=Pt(Lo),ii=Pt(_t),gh=m.useCallback(()=>_c.current(ii.current?"board":"workspace","key"),[_c,ii]),mh=Pt({available:it.workspaceOffered,toggle:gh});lWe(a,[...X,it.enabled&&it.shell.phase!=="closed"?ma(it.shell.target):null],a.current.revision);const hd=rWe(a.current,[...X,it.enabled&&it.shell.phase!=="closed"?ma(it.shell.target):null]),kw=_t&&it.enabled&&it.shell.phase!=="closed"?YHe(it.split,it.shell.target,(yd=it.arrangement)==null?void 0:yd.order):void 0;c_e({stateRef:a,removedNodes:td,hideSessions:ah,ready:No,keepSessionId:te?((xd=a.current.agents.get(te))==null?void 0:xd.sessionId)??te:null,stageSessionId:it.enabled&&it.shell.phase!=="closed"?ma(it.shell.target):null});const Lc=yH(it,I,_),pd=yH(it,D,L),vw=m.useMemo(()=>oj(Lc.set,U,H),[Lc.set,U,H]),fh=m.useMemo(()=>oj(pd.set,U,H),[pd.set,U,H]),Ua={shown:Lc.shown&&!j.right,set:vw},Po={shown:pd.shown&&!j.right,set:fh},Oo=(Ne,Lt)=>Ne?no(Lt):Lt==="leaving",_s=!ne&&!_t&&(da||Oo(Ua.shown,Se)||Oo(Po.shown,ve));O.settle({left:fn>0,right:!ne&&(Di||Lc.shown||pd.shown),board:!_t});const oi=b_e({clearSelection:V,selectAgent:K,detailOpen:R,setDetailOpen:$,detailShown:da,focusAgent:dh,revealAgent:vr,draggingRef:th,lodRef:ad,stage:{onNodeClick:(Ne,Lt)=>it.workspaceOffered?(Lo("workspace","pointer",gp(a.current.agents,Ne)),!0):it.onNodeClick(Ne,Lt)}}),bh=hqe({nodesRef:od,stateRef:a,canvasRef:Zn,railInsetRef:xc}),ww=Pt(nh),kh=m.useRef(null),{followSession:Wi}=it,ri=m.useCallback(Ne=>{if(ii.current&&it.enabled){ys(Ne),qs(Ne);return}as(Ne)},[ii,it.enabled,ys,qs,as]),ci=m.useCallback(Ne=>{if(ii.current&&it.enabled){la.has(Ne)&&vs([Ne]),ys(Ne),qs(Ne);return}if(Wi(Ne)){qs(Ne),la.has(Ne)&&vs([Ne]);return}la.has(Ne)&&vs([Ne]),as(Ne)},[la,vs,as,Wi,qs,ii,it.enabled,ys]),wr=m.useCallback(Ne=>{la.has(Ne)&&vs([Ne]),ys(Ne,{focusPane:!0})},[la,vs,ys]),vh=m.useCallback(Ne=>{la.has(Ne)&&vs([Ne]),it.openBeside(Ne)},[la,vs,it.openBeside]),yr=C_e(),[Hi,on]=m.useState(!1),rn=m.useCallback(()=>on(!0),[]),Gi=m.useCallback(()=>on(!1),[]),Xn=m.useCallback(Ne=>{on(!1),Ne.run()},[]),Ca=m.useCallback(()=>f8(a.current,kh,ri),[a,ri]),Mo=()=>{var Sd;if(!it.enabled)return;const Ne=it.shell.phase!=="closed"?ma(it.shell.target):null,Lt=te?((Sd=a.current.agents.get(te))==null?void 0:Sd.sessionId)??null:null,Na=Gfe(a.current.agents.values(),Ne??Lt);return Na?{folder:Na,launch:it.launch}:void 0},xr=sa(),ha=m.useRef(W),md=m.useCallback(()=>ha.current(),[]);j_e({pointerFocusRef:yr,nodesRef:od,stateRef:a,primarySelectedIdRef:Ui,providersRef:Vt,soundOnRef:Qe,keyHelpOpenRef:fe,modalOpenRef:re,waitingCursorRef:kh,removeSelectedRef:ww,activateSoundRef:Ge,viewRef:mh,stageRef:it.keysRef,lodRef:ad,inspectorSheetFoldRef:Sm,inspectorDoorRef:Rc,clearSelection:hn,selectAgent:K,focusAgent:dh,stepAgent:Eo,focusSession:ri,requestClear:Fa,handleRelayout:To,undoRearrange:eh.undo,handleFit:ch,togglePause:Ke,toggleSessionList:md,toggleAccountsPanel:G,setDetailOpen:$,setUsageHistoryOpen:ns,setUsagePanelOpen:Ua.set,setMachinePanelOpen:Po.set,setBrowserWatchOpen:ya,setKeyHelpOpen:ra,setTheme:Yu,openSettings:Ve,openIntegrationRef:ye,openQuickOpen:rn});const Nm=a.current.agents.size,fd=Vee(a.current),xs=m.useMemo(()=>ku(a.current.agents.values()),[a.current,a.current.revision]),Am=m.useMemo(()=>fOe(a.current.agents.values()),[a.current,a.current.revision]);e_e({stateRef:a,waitingSessions:xs,removedAgentIds:la,removedNodes:td,bringBack:vs}),p_e({stateRef:a,waitingSessions:xs,live:at});const Ls=wWe({waitingSessions:xs,watchUnseen:Ct,incidents:Ju}),Cr=jWe({waitingSessions:xs,liveSince:qe,focusSession:ri,stateRef:a}),{loadNotifyPrefs:wh}=Cr,yh=C3e(it,xs,Zn),[jm,Vi]=m.useState({on:!1,vetoed:!1});GWe({loadAutoRestartPrefs:Xl,loadNotifyPrefs:wh,loadReportsPrefs:je.loadReportsPrefs,loadTerminalPrefs:it.loadTerminalPrefs,loadAccountPrefs:Ne=>Vi({on:Ne.accountOn===!0,vetoed:Ne.accountVetoed===!0})});const Sr={theme:Ne=>Yu(Ne),textSize:Ne=>Oi.setTextSize(Ne),density:Ne=>Oi.setDensity(Ne),"panels.sessionList":Ne=>{Ne?c||h():b()},"panels.accounts":Ne=>{Ne?f():w()},"panels.detail":Ne=>z(Ne===!0),"panels.usage":Ne=>_(Ne===!0),"panels.machine":Ne=>L(Ne===!0),singleKeyShortcuts:Ne=>O5(Ne===!0),hideFinishedAfter:Ne=>c8(Number(Ne)),character:Ne=>Oi.setCharacterEnabled(Ne===!0),sound:Ne=>Ee.setSound(Ne===!0)},[Io,Pc]=m.useState(!1),[bd,Sa]=m.useState(null),ss=m.useCallback(()=>Sa(null),[]),Do=m.useCallback(Ne=>{const Lt=a.current.agents.get(Ne);return Lt?bu(Lt)??"session":null},[]),li=m.useCallback(Ne=>{Sa(null),ci(Ne)},[ci]),Ps=m.useCallback(()=>Pc(!1),[]),[Fo,xh]=m.useState(null),Ch=m.useCallback(()=>xh(null),[]),Sh=GLe(T8()),Wa=m.useCallback(()=>nn.openFeedback({initialTab:"conversations"}),[nn.openFeedback]),Qt=FLe({providers:Ye,sessionListOpen:Q,toggleSessionList:W,accountsPanelOpen:J,toggleAccountsPanel:G,accountsPanelId:q7(_n),codexPanelOpen:J&&_n==="codex",toggleCodexPanel:()=>Xa("codex"),usagePanelOpen:Ua.shown,setUsagePanelOpen:Ua.set,machinePanelOpen:Po.shown,setMachinePanelOpen:Po.set,setUsageHistoryOpen:ns,watchOn:st,watchUnseen:Ct,setBrowserWatchOpen:ya,setTrafficRadarOpen:nn.setTrafficRadarOpen,openSettings:Ve,onFeedback:nn.openFeedback,setRadioOpen:Pc,openToolActivity:Sa,openCapacity:xh,toggles:ua.toggles,integrations:ae.map(Ne=>({provider:Ne,onPress:()=>Bn(Ne.kind)})),openExploreIntegrations:()=>ks(!0),openQuickOpen:rn,feedbackUnread:Sh,openFeedbackConversations:Wa,inspectorOpen:Ac,toggleInspector:Ec}),en=m.useRef(!1),Ta=m.useCallback(Ne=>{if(ne&&it.enabled){la.has(Ne)&&vs([Ne]),ys(Ne),qs(Ne),en.current=!0,v();return}ci(Ne)},[ci,ne,v,it.enabled,ys,qs,la,vs]),Em=m.useCallback(Ne=>{Ta(Ne),en.current=!1},[Ta]),Tr=it.enabled&&it.shell.phase!=="closed",kd=m.useRef(!1);m.useEffect(()=>{if(kd.current&&!Tr){const Ne=ne&&en.current;en.current=!1,Ne&&!c&&h()}kd.current=Tr},[ne,Tr]);const{openFromButton:vd}=it,Rm=m.useCallback(Ne=>{vd(Ne),ne&&c&&(en.current=!0,v())},[vd,ne,c,v]),Oc=m.useRef(l),{giveRightBack:Th}=it;m.useLayoutEffect(()=>{const Ne=MMe({phone:ne,accountsOpen:l,accountsWasOpen:Oc.current,paneOpen:Tr});Oc.current=l,Ne&&Th()},[ne,l,Tr,Th]);const Ki=()=>{(Ye.claude?ua.accounts:ua.codex)(),w()},Nh=it.enabled&&it.supported!==!1&&!it.chunkFailed,{newSessionFromBoard:zm}=it,Mc=m.useCallback(Ne=>{zm(Ne),ne&&c&&(en.current=!0,v())},[zm,ne,c,v]),Ic=Ne=>fd?!at&&ut?i.jsx(__e,{reservedRight:Ne}):i.jsx(L_e,{live:at,everConnected:vt,providers:Ye,workspace:rt,onTour:Gt,onNewSession:Nh?Mc:void 0,reservedRight:Ne}):null,Ah=ne&&be&&!(vt&&!at),di=VMe({phone:ne,open:{accounts:Cn&&l,usage:Ua.shown,machine:Po.shown,inspector:da},close:{accounts:Ki,usage:()=>{ua.usage(),Ua.set(!1)},machine:()=>{ua.machine(),Po.set(!1)},inspector:()=>{ua.detail(),$(!1)}},openers:{accounts:()=>{var Ne;return((Ne=Ye.claude?ua.toggles.accounts:ua.toggles.codex)==null?void 0:Ne.current)??null},usage:()=>ua.toggles.usage.current,machine:()=>ua.toggles.machine.current,inspector:()=>te?document.querySelector(`.session-list .sl-row[data-session="${CSS.escape(te)}"], .phone-board .pb-card[data-session="${CSS.escape(te)}"]`):null},modalOpenRef:re,onLeavePhone:T,hold:{accounts:y,usage:P.usage,machine:P.machine},home:()=>ua.toggles.sessionList.current}),$i=Ne=>Ne.id==="session-list"&&di.sheet!=null?{...Ne,open:!1,onPress:()=>mW({sheet:di.sheet,listOpen:c,closeSheet:di.closeSheet,toggleList:Ne.onPress})}:Ne;ha.current=()=>mW({sheet:di.sheet,listOpen:c,closeSheet:di.closeSheet,toggleList:W});const qm={...Qt,left:Qt.left.map($i),right:Qt.right.map(Ne=>Ne.map($i))},Ji=(Ne,Lt)=>ne?()=>di.closeSheet(Ne):Lt,Dc=Rt.both?i.jsx(ANe,{shown:_n,notices:Rt.notices,onPick:Rt.pick}):void 0,Bo=Ne=>Rt.bothMounted?Ne===_n?"shown":"hidden":void 0,wd=i.jsxs(i.Fragment,{children:[Cn&&(_n==="claude"||Rt.bothMounted)&&i.jsx(TNe,{leaving:wf(J,he),onReport:nn.openFeedback,onRoster:pr.observe,onClose:Ji("accounts",Ki),lanWanted:qa,onLanShown:Dn,onLanAccounts:Xt,codexLanAccounts:es,switcher:Dc,side:Bo("claude"),onNotice:Rt.noteClaude,planLabel:((Cd=nm.reading)==null?void 0:Cd.planLabel)??null}),Cn&&(_n==="codex"||Rt.bothMounted)&&i.jsx(iAe,{leaving:wf(J,he),onClose:Ji("accounts",Ki),switcher:Dc,side:Bo("codex"),onNotice:Rt.noteCodex,lanAccounts:Oa,lanReady:!Ye.claude||oa!=null,lanWanted:qa,onLanShown:Dn,onLanAccounts:In})]});return i.jsxs("div",{ref:ud,className:"app","data-view":_t?"workspace":void 0,"data-zoom":Ro,"data-side":Ln.on?"":void 0,"data-right-col":_s?"":void 0,style:Ln.on?{"--workspace-side-w":`${Ln.width}px`}:void 0,children:[i.jsxs(X3.Provider,{value:fd,children:[_t?i.jsx("a",{className:"skip-link",href:`#${X7}`,onClick:Ne=>{I3e()&&Ne.preventDefault()},children:e(M3e)}):i.jsx("a",{className:"skip-link",href:"#canvas",children:e("shell.skipToCanvas")}),i.jsxs("header",{className:"topbar",children:[i.jsx(Zpe,{}),i.jsxs(VOe,{versionCheck:et,welcome:mn,desktopUpdate:Ht,pause:ot,announcements:Ls,notify:Cr,waitingSessions:xs,waitingCursorRef:kh,focusSession:ri,live:at,now:Yn,incidents:Ju,counts:Am,asksSaid:it.enabled?yh.said:void 0,children:[!ne&&it.workspaceOffered&&i.jsx(P3e,{view:_t?"workspace":"board",onChange:Lo}),!ne&&i.jsx("div",{className:"actions",children:i.jsx(VP,{items:[Qt.search]})})]}),i.jsx("div",{className:"tb-corner",children:i.jsx(VP,{items:[Qt.corner]})})]}),ne?i.jsx(Sme,{items:[...Qt.left,...Qt.right[0]].map($i),more:[Qt.search,...BLe(it.enabled?Rm:void 0),...Qt.capacity,...Qt.right.slice(1).flat(),...Qt.integrations,...Qt.explore,...Qt.utilities.filter(Ne=>Ne!==Qt.corner)],offline:vt&&!at}):i.jsx(HP,{side:"left",label:e("board.rail.tools"),groups:Qt.leftStripe,foot:Qt.leftFoot}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:cm?e("shell.board.removed",{label:cm.label}):""}),it.enabled&&i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:it.said}),i.jsx(AMe,{restart:Pi,versionCheck:et,upgrade:va,oldNameNotice:Ma,rating:ts,onFeedback:nn.openFeedback,everConnected:vt,live:at,paused:Ce,phone:ne,lastNewsAt:dt,cardInList:be}),ne&&wd,(be||Cn)&&i.jsxs(oAe,{width:cn,listWidth:ne?void 0:E,edge:ne?void 0:i.jsx(bAe,{width:E,cap:A,onWidth:C.choose,onReset:C.reset}),children:[!ne&&wd,be&&i.jsx(Jge,{historyReady:No,leaving:wf(Q,me),state:a.current,now:Yn,selectedIds:X,onSelect:Ta,onClose:()=>{ua.sessionList(),b()},removedIds:la,onBringBackAll:lw,landed:wm,watching:hd,openPanes:kw,onOpenKeys:_t?wr:void 0,onOpenBeside:_t&&it.enabled?vh:void 0,onNewSession:_t&&it.enabled?it.newSessionFrom:void 0,offline:ne&&vt&&!at&&!Pi.restarting?i.jsx($8,{lastNewsAt:dt}):void 0,emptyNotice:Ah?Ic(0):void 0})]}),_t&&i.jsx("div",{className:"ws-cell","aria-hidden":"true"}),i.jsxs(eMe,{canvasRef:Zn,bubbling:uw,dragging:ih,trash:kr,zoom:Ao,viewport:mm,stateRef:a,peek:bh,stagePhase:it.enabled&&it.shell.phase!=="closed"?it.shell.phase:void 0,joins:No&&sh,closing:fw,children:[!Ah&&Ic(ne?0:xc.current),ne?i.jsxs(i.Fragment,{children:[i.jsx(JOe,{state:a.current,now:Yn,watching:hd,removedIds:la,selectedIds:X,onOpen:Em}),i.jsx(eG,{fm:vc,character:Oi.character,characterEnabled:!1,open:Io,onClose:Ps})]}):i.jsx(Ype,{graph:Bi,layout:ai,viewport:mm,clicks:oi,drag:Cc,appearance:Oi,fm:vc,radioOpen:Io,onRadioClose:Ps,autoFit:om,pause:ot,stateRef:a,measuredRef:br,hiddenCats:Bt,now:Yn,openTool:un,focusAgent:dh,requestClear:Fa,setKeyHelpOpen:ra,zoomBy:ca.zoomBy,zoomReset:ca.zoomReset,onTerminal:it.enabled?it.openFromButton:void 0,notesDrawn:Ao.lod==="detail",presentCats:sn,toggleCat:Sn}),i.jsx(j3e,{stage:it})]}),i.jsx(E3e,{stage:it,stateRef:a,canvasRef:Zn,now:Yn,palette:Zu,asks:yh,waitingSessions:xs,onBoard:()=>Lo("board",AH()?"key":"pointer")}),i.jsx(Ft,{when:bd,children:Ne=>i.jsx(uke,{view:Ne,onClose:ss,sessionLabel:Do,onOpenSession:li})}),i.jsx(Ft,{when:Fo,children:Ne=>i.jsx(FNe,{view:Ne,onClose:Ch})}),i.jsx(Ft,{when:xa,children:Ne=>i.jsx(JPe,{kind:Ne,connections:Qo(Et,Ne)?Ak(Et,Ne):[],onClose:fc,onReconnect:Ue})}),i.jsx(Ft,{when:zt,children:()=>i.jsx(pOe,{integrations:Et,onClose:Li,onOpen:Bn,onConnect:ni,onManage:Yl})}),Hi&&i.jsx(hme,{onClose:Gi,onRun:Xn,items:Vfe({rails:qm,sessions:uv(a.current,Yn),openSession:Ta,settings:$G(Ye.claude,Ez(Et),Qg(Et)),openSettings:Ve,singleKeys:xr,fit:ch,rearrange:To,phone:ne,paused:Ce,togglePause:Ke,clear:fd?void 0:()=>Fa("button"),nextWaiting:ku(a.current.agents.values()).length>0?Ca:void 0,start:Mo(),keyHelp:()=>ra(!0),tour:Gt,theme:Oi.theme,setTheme:Yu})}),!ne&&i.jsx(HP,{side:"right",label:e("shell.rail.right"),groups:Qt.rightStripe}),i.jsxs("div",{className:"right-col",children:[i.jsxs(twe,{on:Ln.on,split:Ln.split,width:Ln.width,share:Ln.share,onWidth:Ln.setWidth,onShare:Ln.setShare,children:[no(Se)&&i.jsx(awe,{state:a.current,now:Yn,providers:Ye,incidents:Ju,liveSince:qe,leaving:Se==="leaving",dock:_o.usage,onClose:Ji("usage",()=>{ua.usage(),_(!1)})}),no(ve)&&i.jsx(Uwe,{usageOpen:I,leaving:ve==="leaving",dock:_o.machine,onClose:Ji("machine",()=>{ua.machine(),L(!1)})})]}),_t&&Ba&&!si&&!(R&&ws)?ws?i.jsx($U,{selected:ws,now:Yn,openTool:un,setSummaryFor:Ia,stateRef:a,removeSelectedNode:nh,onSelectAgent:de,onOpenSession:it.enabled?wr:void 0,stageSession:it.enabled&&ac(it.shell.phase)?ma(it.shell.target):null,workspace:!0,onClose:Nc}):i.jsx(KU,{}):null,hh?i.jsx($U,{workspace:_t,leaving:Tc,sheet:Un,selected:hh,now:Yn,openTool:un,setSummaryFor:Ia,stateRef:a,removeSelectedNode:nh,onSelectAgent:de,onOpenSession:it.enabled?wr:void 0,stageSession:it.enabled&&ac(it.shell.phase)?ma(it.shell.target):null,onClose:_t&&(Ba||Un)?Nc:Ji("inspector",()=>{ua.detail(),$(!1)})}):xm?i.jsx(KU,{leaving:Tc,sheet:Un}):null]}),ne&&i.jsx("div",{className:"phone-scrim","data-open":di.sheet?"":void 0,"aria-hidden":"true",onClick:()=>di.closeSheet()}),jm.on&&i.jsx(m.Suspense,{fallback:null,children:i.jsx(Z3e,{appliers:Sr})}),!ne&&i.jsx(ABe,{stageOpen:it.enabled&&ac(it.shell.phase),zoomedOut:Ao.lod!=="detail",viewChord:it.workspaceOffered?_t?"board":"workspace":null,waiting:xs.length>0,version:(Ie==null?void 0:Ie.running)??null,onVersion:mn.openReleaseNotes,setKeyHelpOpen:ra})]}),i.jsx(kBe,{dialogs:nn,welcome:mn,desktopUpdate:Ht,versionCheck:et,restart:Pi,upgrade:va,lanPairs:nt,attention:pr,clearFlow:km,watchBadge:We,announcements:Ls,appearance:Oi,providers:Ye,stateRef:a,agentCount:Nm,menus:Fe,sound:Ee,tones:Je,customTones:Re,notify:Cr,terminal:{on:it.enabled,supported:it.supported,windows:it.windows,phone:ne,failed:it.chunkFailed,toggle:it.toggleTerminal},panelDoors:{accounts:Qa,localNetwork:Pa},account:jm})]})}function jH(){try{fetch("/api/ui-language",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:Me()})}).catch(()=>null)}catch{}}function e4e(){jH();try{return b4(jH)}catch{return()=>{}}}try{rne(window.localStorage)}catch{}Ore();try{ine(window.localStorage)}catch{}try{lne(window.localStorage)}catch{}m4();e4e();const t4e=UJ.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);V3e();t4e.render(i.jsx(X3e,{}));export{p4e as $,Rs as A,Ze as B,A4e as C,Fu as D,dR as E,i5 as F,Zt as G,hR as H,Ks as I,tn as J,Ys as K,na as L,q4e as M,z4e as N,N4e as O,T4e as P,dn as Q,v6 as R,Ep as S,Gb as T,_4e as U,ope as V,Fg as W,M4e as X,M1 as Y,Au as Z,Oue as _,gt as a,Rce as a$,u4e as a0,h4e as a1,lv as a2,ule as a3,WFe as a4,TUe as a5,d4e as a6,rpe as a7,C1 as a8,Ut as a9,yi as aA,Jk as aB,ic as aC,$k as aD,f5 as aE,xo as aF,Cu as aG,iv as aH,D4 as aI,Ape as aJ,aG as aK,Gs as aL,dc as aM,zs as aN,js as aO,B4e as aP,Pt as aQ,I0e as aR,j0e as aS,x4e as aT,D0e as aU,Xs as aV,v4e as aW,k4e as aX,Tce as aY,wk as aZ,y4e as a_,f0 as aa,hO as ab,b0 as ac,f4e as ad,sc as ae,Yt as af,so as ag,b4e as ah,l4e as ai,hg as aj,fa as ak,tfe as al,us as am,mDe as an,ck as ao,$n as ap,Za as aq,rv as ar,j6 as as,ze as at,zl as au,oc as av,ibe as aw,Wt as ax,bs as ay,Wl as az,Ja as b,gn as b$,Py as b0,zce as b1,Oge as b2,kG as b3,qge as b4,zle as b5,G4 as b6,X2e as b7,P4e as b8,O4e as b9,zn as bA,aa as bB,kg as bC,fg as bD,m4e as bE,J7 as bF,U4e as bG,W4e as bH,g4e as bI,_ge as bJ,s0 as bK,Sz as bL,Hj as bM,a4e as bN,a4 as bO,c4e as bP,g5 as bQ,gp as bR,E1 as bS,fG as bT,h5 as bU,S1 as bV,El as bW,m5 as bX,du as bY,sv as bZ,r4e as b_,L4e as ba,H2e as bb,ab as bc,Xke as bd,hle as be,THe as bf,sa as bg,lu as bh,lr as bi,_0e as bj,F4e as bk,pHe as bl,D4e as bm,ole as bn,A5 as bo,q0e as bp,C4e as bq,w4e as br,bG as bs,I4e as bt,X7 as bu,Ft as bv,zUe as bw,Sg as bx,qn as by,ma as bz,Ya as c,Ot as c0,xPe as c1,A8 as c2,CPe as c3,i4e as c4,o4e as c5,s4e as c6,ene as c7,PAe as c8,OAe as c9,sne as ca,io as cb,O1 as cc,Vp as cd,Ws as d,E4e as e,P8 as f,Me as g,U4 as h,XPe as i,i as j,gs as k,$t as l,Rn as m,R4e as n,rr as o,S4e as p,j4e as q,m as r,$a as s,S as t,se as u,ZPe as v,yt as w,Yc as x,Qs as y,Es as z};
|
|
360
|
+
${r}`:a}function Mz(e,t){const n=t.get(e.id);return n!=null&&(n.key===e.key||n.startedAt===e.startedAt)}function SWe(e,t,n,a=!0){if(!a)return[];if(n)return[];const s=[];for(const o of e)o.held||Mz(o,t)||s.push({key:o.key,title:o.label,body:CWe(o.facts),sessionId:o.id});return s}function TWe(e,t,n){const a=new Set(t.map(o=>o.key)),s=new Map;for(const o of e)(a.has(o.key)||o.held==="block"||Mz(o,n))&&s.set(o.id,{key:o.key,startedAt:o.startedAt});return s}function ib(e,t=new Map){const n=new Map;for(const a of e)(a.held!=="job"||Mz(a,t))&&n.set(a.id,{key:a.key,startedAt:a.startedAt});return n}const NWe="/icon-192.png",AWe=[];function aH(e,t){try{const n=new Notification(e.title,{body:e.body,tag:e.key,icon:NWe});n.onclick=()=>{window.focus(),t(e.sessionId),n.close()}}catch{}}const U7=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0});function sH(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:U7[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped")}}function jWe({waitingSessions:e,liveSince:t,focusSession:n,stateRef:a}){const[s,o]=m.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[r,c]=m.useState(null),[l,u]=m.useState(!1),[h,p]=m.useState(!1),[f,b]=m.useState(U7),v=m.useCallback(j=>{const M=!f[j];b(U=>({...U,[j]:M}));const F=U=>{b(H=>H[j]===M?{...H,[j]:!M}:H),Dl(U)};fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[j]:M})}).then(async U=>{const H=await U.json().catch(()=>null);if(!U.ok||!(H!=null&&H.ok))return F(H);Ai(null),b(sH(H.prefs))}).catch(()=>F(null))},[f]),w=m.useRef(()=>{}),T=m.useRef(new Set),y=Pt(e),x=m.useRef({graph:null,revision:-1,turns:AWe}),C=(a==null?void 0:a.current)??null;C&&(x.current.graph!==C||x.current.revision!==C.revision)&&(x.current={graph:C,revision:C.revision,turns:xWe(C.agents.values())});const A=x.current.turns,E=m.useRef(new Map),R=m.useCallback(()=>{const j=!l;u(j),j&&(T.current=Sf(y.current),E.current=ib(x.current.turns,E.current)),j&&typeof Notification<"u"&&Notification.permission==="default"&&w.current();const M=F=>{u(U=>U===j?!j:U),Dl(F)};fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:j})}).then(async F=>{var H;const U=await F.json().catch(()=>null);if(!F.ok||!(U!=null&&U.ok))return M(U);Ai(null),u(((H=U.prefs)==null?void 0:H.notifications)===!0),p(U.notificationsVetoed===!0)}).catch(()=>M(null))},[l]),z=typeof Notification<"u";m.useEffect(()=>{if(!r)return;const M=setTimeout(()=>c(null),r==="blocked"?8e3:4e3);return()=>clearTimeout(M)},[r]);const I=m.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(j=>{const M=j;o(M),M==="granted"?c("on"):M==="denied"&&c("blocked")})},[]);w.current=I;const _=m.useRef(null),D=e.map(j=>Qk(j.id,j.waiting)).join("|"),L=A.map(j=>j.held?`${j.key}~${j.held}`:j.key).join("|");m.useEffect(()=>{yce(_.current,s)&&(_.current=s,E.current=ib(A,E.current),T.current=Sf(e))},[s]);const P=m.useRef(!1);m.useEffect(()=>{xce(P.current,t)&&(P.current=!0,E.current=ib(A,E.current),T.current=Sf(e))},[t]),m.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!OL(_.current,t))return;const j=typeof document>"u"||!document.hidden,M=vce(e,T.current,j,l);for(const F of M)aH(F,n);T.current=j?Sf(e):wce(e,M,T.current)},[D,t]),m.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!OL(_.current,t))return;const j=typeof document>"u"||!document.hidden,M=SWe(A,E.current,j,l);for(const F of M)aH(F,n);E.current=j?ib(A,E.current):TWe(A,M,E.current)},[L,t]);const O=m.useCallback(j=>{var M;u(((M=j.prefs)==null?void 0:M.notifications)===!0),p(j.notificationsVetoed===!0),b(sH(j.prefs))},[]);return{notifyPermission:s,notifySaid:r,notifyOn:l,notifyVetoed:h,toggleNotify:R,notifySupported:z,askForNotifications:I,loadNotifyPrefs:O,accountNotify:f,toggleAccountNotify:v}}function EWe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:a,summaryFor:s,browserWatchOpen:o,keyHelpOpen:r,releaseNotes:c,feedbackOpen:l,trafficRadarOpen:u=!1}){const h=Pt(r),p=m.useRef(!1);return p.current=e!=null||t||n!=null||a||s!=null||o||r||c!=null||l||u,{keyHelpOpenRef:h,modalOpenRef:p}}function RWe({stateRef:e,tourOpen:t,releaseNotes:n}){var O;const[a,s]=m.useState(null),o=m.useCallback((j,M)=>s({agentId:j,toolId:M}),[]),[r,c]=m.useState(null),[l,u]=m.useState(null),h=m.useCallback(j=>u(j),[]),[p,f]=m.useState(!1),[b,v]=m.useState(!1),[w,T]=m.useState(!1),[y,x]=m.useState(!1),[C,A]=m.useState(!1),[E,R]=m.useState(null),z=m.useCallback(j=>{R(j??null),A(!0)},[]);na("tool-detail",a!==null),na("session-summary",r!==null),na("context-window",l!==null),na("keyboard-help",p),na("usage-history",b),na("browser-watch",w),na("feedback",C);const I=a?kje(e.current.agents,a.agentId,a.toolId):null,_=a?(O=e.current.agents.get(a.agentId))==null?void 0:O.cwd:void 0,D=l?e.current.agents.get(l):void 0,{keyHelpOpenRef:L,modalOpenRef:P}=EWe({openedTool:I,usageHistoryOpen:b,contextFor:l,tourOpen:t,summaryFor:r,browserWatchOpen:w,keyHelpOpen:p,releaseNotes:n,feedbackOpen:C,trafficRadarOpen:y});return{setOpenedToolKey:s,openTool:o,openedTool:I,openedToolCwd:_,summaryFor:r,setSummaryFor:c,contextFor:l,setContextFor:u,openContext:h,contextAgent:D,keyHelpOpen:p,setKeyHelpOpen:f,usageHistoryOpen:b,setUsageHistoryOpen:v,browserWatchOpen:w,setBrowserWatchOpen:T,trafficRadarOpen:y,setTrafficRadarOpen:x,feedbackOpen:C,setFeedbackOpen:A,feedbackPrefill:E,setFeedbackPrefill:R,openFeedback:z,keyHelpOpenRef:L,modalOpenRef:P}}function zWe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:a,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:r,rerender:c,modalOpenRef:l}){const[u,h]=m.useState(!1),p=m.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=IR(),t.current.clear(),n.current.clear(),a.current.clear(),s.current="",n8(),o(),r(),c()},[c,r,o]),f=Pt(u),b=m.useCallback(v=>{const w=KMe(v,{confirmOpen:f.current,modalOpen:l.current});w==="confirm"?h(!0):w==="clear"&&(h(!1),p())},[p]);return{clearConfirmOpen:u,setClearConfirmOpen:h,requestClear:b}}const iH="agent-dag.oldNameNoticeDismissed";function qWe(e){const[t,n]=m.useState(()=>gt(iH)??""),a=e!=null&&e.invokedAs&&e.invokedAs!==an?e.invokedAs:null,s=a!=null&&t!==a,o=m.useCallback(()=>{a&&(n(a),yt(iH,a))},[a]);return{oldName:a,oldNameOpen:s,dismissOldName:o}}const _We=300*1e3,LWe=1800*1e3,PWe=8e3,OWe=3e4;function oH(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function MWe({modalOpenRef:e}){const t=m.useCallback(()=>Fr({appModal:e.current,dialogDepth:Rn.dialogDepth()}),[e]),[n,a]=m.useState("hidden"),[s,o]=m.useState(null),[r,c]=m.useState(!1),l=m.useRef(n);l.current=n,m.useEffect(()=>{let b=!1;const v=async()=>{if(l.current==="thanks"||l.current==="hidden"&&(document.hidden||t()))return;const y=await fetch("/api/rating").then(x=>x.ok?x.json():null).catch(()=>null);b||!y||a(x=>x==="thanks"?x:y.ask===!0?"asking":"hidden")},w=window.setTimeout(v,_We),T=window.setInterval(v,LWe);return()=>{b=!0,window.clearTimeout(w),window.clearInterval(T)}},[t]),m.useEffect(()=>{if(n!=="thanks"||r)return;const b=s!==null&&s<=6?OWe:PWe;let v=0;const w=()=>{t()?v=window.setTimeout(w,b):a("hidden")};return v=window.setTimeout(w,b),()=>window.clearTimeout(v)},[n,s,r,t]);const u=m.useCallback(b=>{o(b),c(!1),a("thanks"),oH({score:b})},[]),h=m.useCallback(b=>c(b),[]),p=m.useCallback(()=>{a("hidden"),oH({later:!0})},[]),f=m.useCallback(()=>a("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:u,rateLater:p,closeRating:f,holdThanks:h}}function IWe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:a}){const[s,o]=m.useState(()=>Zme(gt)),r=Pt(s),[c,l]=m.useState([]),u=m.useCallback(x=>{o(C=>{const A={...C,[x]:null};return r.current=A,A}),Ja(_p[x])},[]),h=m.useCallback((x,C)=>{const A=r.current[x];C&&A!==C||(u(x),t(E=>{const R={...E,[x]:{...E[x],figure:Ns}};return n.current=R,R}),yt(ak[x],Ns))},[u]),p=Pt(h);m.useEffect(()=>{let x=!0;return cfe().then(C=>{if(!x)return;l(C);const A=new Set(C.map(E=>E.id));for(const E of Lp){const R=r.current[E];R&&!A.has(R)&&p.current(E,R)}},()=>{}),()=>{x=!1}},[]);const f=m.useCallback((x,C)=>{if(!c.some(E=>E.id===C))return;const A={...r.current,[x]:C};r.current=A,o(A),yt(_p[x],C),a(x,!0)},[c,a]),b=m.useCallback(async x=>{var R;const C=c0(c.length);if(C)throw new $n(C);const A=window.AudioContext??window.webkitAudioContext;if(!A)throw new $n(S("settings.sounds.custom.decodeFail"));const E=new A;try{const z=await afe(x,_=>E.decodeAudioData(_));await QP(z);const I=rg(z);l(_=>[..._.filter(D=>D.id!==I.id),I])}finally{(R=E.close)==null||R.call(E)}},[c.length]),v=m.useCallback(async x=>{const C=c0(c.length);if(C)throw new $n(C);const A=sfe(x);await QP(A);const E=rg(A);l(R=>[...R.filter(z=>z.id!==E.id),E])},[c.length]),w=m.useCallback(async(x,C)=>{const A=c.find(R=>R.id===x),E=C.trim().slice(0,80);!A||!E||E===A.name||(await dfe(x,E),l(R=>R.map(z=>z.id===x?{...z,name:E}:z)))},[c]),T=m.useCallback(async x=>{await ufe(x),l(R=>R.filter(z=>z.id!==x));const C=r.current,A=Xme(C,x);r.current=A,o(A);const E=Lp.filter(R=>C[R]===x);for(const R of E)Ja(_p[R]),yt(ak[R],Ns);E.length>0&&t(R=>{const z={...R};for(const I of E)z[I]={...z[I],figure:Ns};return n.current=z,z})},[]),y=m.useCallback(x=>{var E,R;const C=Lp.find(z=>r.current[z]===x),A=C?n.current[C].level:_l;(E=e.current)==null||E.unlock(),(R=e.current)==null||R.previewCustom(x,A)},[]);return{customSelections:s,customSelectionsRef:r,customAssets:c,clearCustomOnly:u,fallbackCustomRef:p,selectCustomTone:f,importNotificationAudio:b,createNotificationVoice:v,renameCustomAsset:w,deleteCustomAsset:T,previewCustomAsset:y}}function DWe(e){const[t,n]=m.useState(()=>Cfe(gt)),a=Pt(t),s=m.useRef(null),o=m.useCallback((c,l=!1)=>{var u,h;if((u=e.current)==null||u.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!l){(h=e.current)==null||h.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},kfe)},[]),r=m.useCallback((c,l)=>{n(u=>{const h={level:pv(l.level??u[c].level),figure:FG(c,l.figure??u[c].figure)};return yt(WG[c],String(h.level)),yt(ak[c],h.figure),{...u,[c]:h}}),o(c,!0)},[o]);return m.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:a,previewTone:o,changeTone:r}}const FWe=15e3;function BWe(e){return e.visibilityState==="visible"&&e.hasFocus()}function UWe(e,t){return t||e===!0}function WWe(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function HWe(){m.useEffect(()=>{const e=WWe();let t=null;const n=r=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:r}),keepalive:!0}).catch(()=>{})},a=()=>{const r=BWe(document);UWe(t,r)&&n(r),t=r},s=()=>{t&&n(!1),t=!1};a();const o=window.setInterval(a,FWe);return window.addEventListener("focus",a),window.addEventListener("blur",a),document.addEventListener("visibilitychange",a),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",a),window.removeEventListener("blur",a),document.removeEventListener("visibilitychange",a),window.removeEventListener("pagehide",s),s()}},[])}function GWe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n,loadTerminalPrefs:a,loadAccountPrefs:s}){m.useEffect(()=>{let o=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!o||!(r!=null&&r.ok)||(e(r),t(r),n(r),a==null||a(r),s==null||s(r))}).catch(()=>{}),()=>{o=!1}},[])}const rj="agent-dag.versionNoticeDismissed",VWe=15*6e4;function KWe(e){const[t,n]=m.useState(null),[a,s]=m.useState(()=>gt(rj)??""),o=m.useRef(0),[r,c]=m.useState(!1),l=m.useCallback((w=!1)=>(w&&(o.current=Date.now(),c(!0)),fetch(w?"/api/version?refresh=1":"/api/version").then(T=>T.ok?T.json():null).then(T=>(T&&n(T),T??null)).catch(()=>null).finally(()=>{w&&c(!1)})),[]),u=m.useCallback(()=>{l(Date.now()-o.current>=VWe)},[l]);m.useEffect(()=>{l();const w=window.setInterval(u,5*6e4),T=()=>{document.visibilityState==="visible"&&u()};return document.addEventListener("visibilitychange",T),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",T)}},[l,u]),m.useEffect(()=>{e&&l()},[e,l]);const h=(t==null?void 0:t.notice)??null,p=H8(h),f=LOe(h,a),b=m.useCallback(()=>{s(""),yt(rj,"")},[]),v=m.useCallback(()=>{h&&(s(p),yt(rj,p))},[h,p]);return{version:t,notice:h,noticeOpen:f,showNotice:b,dismissNotice:v,versionChecking:r,loadVersion:l}}const rH={tourSeen:!0,tourEdition:bg};function $We({version:e,readyAppUpdate:t}){const[n,a]=m.useState(!1),s=m.useRef(null),[o,r]=m.useState(null),c=o&&t?t.version:null,l=m.useRef(null);m.useEffect(()=>{!c||l.current===c||(l.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const u=m.useRef(!1);m.useEffect(()=>{if(u.current)return;const T=Gs(),y=UDe(T),x=JDe({stored:y,running:(e==null?void 0:e.running)??null,notes:TW,remembers:WDe(T)});if(x.reason==="no-version")return;u.current=!0,x.record&&HDe(T,x.record);let C=!0;return(async()=>{var I;let E=VDe(T);if(lr())try{const _=await fetch("/api/prefs");if(!_.ok)throw new Error("desktop tour preferences unavailable");const D=await _.json();if(!(D!=null&&D.ok))throw new Error("desktop tour preferences unavailable");const L=qz((I=D.prefs)==null?void 0:I.tourEdition)>=bg;E&&!L&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(rH),keepalive:!0}).catch(()=>{}),E=E||L}catch{E=!0}if(!C)return;const R=$De({tourSeen:E,decision:x,phone:Gr()}),z=x.show.length?{entries:x.show,since:y,firstRun:!1}:null;R.tour&&a(!0),R.notes==="now"?r(z):R.notes==="after"&&(s.current=z)})(),()=>{C=!1}},[e==null?void 0:e.running]);const h=(e==null?void 0:e.running)??"4.0.3",p=m.useMemo(()=>l7(TW,null,h),[h]),f=m.useCallback(()=>{r({entries:p,since:null,firstRun:!1})},[p]),b=m.useCallback(()=>a(!0),[]),v=m.useCallback(()=>r(null),[]),w=m.useCallback(()=>{a(!1),KDe(Gs()),lr()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(rH),keepalive:!0}).catch(()=>{});const T=s.current;s.current=null,T&&r(T)},[]);return{tourOpen:n,openTour:b,closeTour:w,releaseNotes:o,closeReleaseNotes:v,chipVersion:h,openReleaseNotes:f}}function JWe(){const[e,t]=m.useState(void 0),[n,a]=m.useState(!1),s=m.useRef(!1);return s.current=e===!0&&!n,m.useEffect(()=>KBe(()=>s.current),[]),{loadReportsPrefs:m.useCallback(r=>{var c;t(((c=r.prefs)==null?void 0:c.reports)!==!1),a(r.reportsVetoed===!0)},[])}}function YWe(e){const[t,n]=m.useState(null);m.useEffect(()=>{const l=gt("agent-dag.sound");n(l===null?!0:l==="on")},[]);const a=m.useCallback(()=>{n(l=>{var h,p;const u=l!==!0;return yt("agent-dag.sound",u?"on":"off"),u?(h=e.current)==null||h.unlock():(p=e.current)==null||p.silence(),u})},[]),s=m.useCallback(l=>{a()},[a]),o=Pt(s),r=Pt(t),c=m.useCallback(l=>{r.current!==null&&r.current!==l&&a()},[a]);return{soundOn:t,toggleSound:a,setSound:c,activateSoundRef:o,soundOnRef:r}}function ZWe(){const[e,t]=m.useState(zme),n=m.useCallback((o,r)=>{t(c=>qme(c,o,r))},[]),a=m.useCallback(()=>t(o=>({...o,open:!1})),[]),s=m.useCallback(o=>t(r=>({...r,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,settingsLandOn:e.landOn,openSettings:n,closeSettings:a,showSection:s}}const XWe="agent-dag.autoFitDisabled";function QWe(e){const t=m.useRef(!1),[n,a]=m.useState(!1);m.useEffect(()=>{Ja(XWe)},[]);const s=m.useCallback(()=>{t.current||(t.current=!0,a(!0))},[]),o=m.useCallback(()=>{t.current=!1,a(!1),e()},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}const eHe=[80,100,120,160],tHe=3,cH=80,nHe=24,Iz=20,tw=nHe+Iz,W7=14,aHe=12,lH=320,cj=168,sHe=400,iHe=1100,NE=44,Dz=36,oHe=new Set(["compact","tighter","tightest"]);function rHe(e){return e&&oHe.has(e)?Dz:NE}const nc=32,cHe=36,lHe=56,dHe=52,uHe=55,Fz=12,H7=5,G7=20,uc={w:8,h:18},uo=(e,t)=>Number.isFinite(e)&&e>0?e:t;function V7(e,t){return Math.ceil(e*uo(t,uc.w))+tw}function hHe(e,t,n){return Math.floor((e-n-tw)/uo(t,uc.w))}function dH(e,t,n){const a=hHe(e,t,n);return{min:cH,max:a,detents:eHe.filter(s=>s>=cH&&s<=a)}}function pHe(e,t){if(!Number.isFinite(e))return t.min;const n=Math.max(t.min,Math.min(t.max,Math.round(e)));let a=null;for(const s of t.detents)Math.abs(s-e)>tHe||(a===null||Math.abs(s-e)<Math.abs(a-e))&&(a=s);return a??n}function D4e(e,t,n){return(t-e-tw)/uo(n,uc.w)}function F4e(e,t,n){if(t==="widest")return n.max;if(t==="narrowest")return n.min;if(t==="wider")return n.detents.find(s=>s>e)??n.max;const a=n.detents.filter(s=>s<e);return a.length?a[a.length-1]:n.min}function gHe(e,t,n,a){const s=e.detents.filter(o=>t-V7(o,n)>=a);return s.length?s[s.length-1]:e.detents[0]??e.min}function mHe(e,t){return e>t.max?t.detents.length?t.detents[t.detents.length-1]:t.max:pHe(e,t)}function fHe(e,t,n,a,s){const o=Math.max(G7,Math.floor((t-W7-Iz)/n)),r=e.externalBar?0:Math.max(nc,uo(e.barH??nc,nc)),c=Math.max(0,e.bodyH-s-r),l=Math.max(H7,Math.floor((c-Fz)/a));return{cols:o,rows:l,stageW:t,navW:0,density:"rail",takeover:!1,headH:s,termTop:aHe,range:{min:o,max:o,detents:[]},fill:!0}}function uH(e){const t=uo(e.cellW,uc.w),n=uo(e.cellH,uc.h),a=Math.max(0,e.appW),s=Math.max(Dz,uo(e.headH??NE,NE));if(e.fill)return fHe(e,a,t,n,s);const o=e.narrow||e.expanded;let c=dH(a,t,o?cj:lH);c.max<c.min&&!o&&(c=dH(a,t,cj));const l=c.max<c.min;let u;l?(u=Math.max(G7,Math.floor((a-tw)/t)),c={min:u,max:u,detents:[]}):e.expanded?u=c.max:e.storedCols!=null&&Number.isFinite(e.storedCols)?u=mHe(e.storedCols,c):u=gHe(c,a,t,e.narrow?cj:sHe);const h=l?a:V7(u,t),p=l?0:a-h,f=e.externalBar?0:Math.max(nc,uo(e.barH??nc,nc)),b=Math.max(0,e.bodyH-s-f),v=Math.max(H7,Math.floor((b-Fz)/n)),w=Math.max(6,Math.floor((b-v*n)/2)),T=o||p<lH?"rail":"tiles";return{cols:u,rows:v,stageW:h,navW:p,density:T,takeover:l,headH:s,termTop:w,range:c}}const Bz="agent-dag.terminal.cols";function bHe(e=gt){const t=e(Bz);if(t==null||!/^\d{1,3}$/.test(t.trim()))return null;const n=Number(t.trim());return n>=20&&n<=500?n:null}function kHe(e,t=yt){Number.isInteger(e)&&e>0&&t(Bz,String(e))}function vHe(e,t,n,a,s,o=!1){const r=uo(n.w,uc.w),c=uo(n.h,uc.h);return{w:Math.ceil(e*r+W7+Iz),h:Math.ceil(t*c+Math.max(Dz,a)+(o?0:Math.max(nc,s))+Fz)}}function wHe(){return{phase:"closed",target:null,origin:null,originName:null,grace:!1,focusRequest:null,popover:null,last:null}}function yHe(e,t){return e===t?!0:!e||!t||e.kind!==t.kind?!1:e.kind==="session"&&t.kind==="session"?e.id===t.id:e.kind==="launch"&&t.kind==="launch"?e.key===t.key:e.kind==="empty"}function ma(e){return(e==null?void 0:e.kind)==="session"?e.id:null}function ac(e){return e==="waiting"||e==="opening"||e==="open"}function xHe(e){return(e.phase==="opening"||e.phase==="open")&&!e.grace}function CHe(e){return e==="opening"||e==="open"||e==="closing"}const hH={phase:"closed",target:null,origin:null,originName:null,grace:!1,focusRequest:null,popover:null};function SHe(e,t){switch(t.type){case"open":{const n=t.target.kind==="session"?t.target.id:e.last;if(e.phase==="closed")return{...e,phase:"waiting",target:t.target,origin:t.origin??null,originName:t.origin?t.originName??null:null,grace:!!t.grace,focusRequest:t.focus??null,popover:null,last:n};const a=t.focus??e.focusRequest;return yHe(e.target,t.target)&&a===e.focusRequest&&e.phase!=="closing"?e:{...e,phase:e.phase==="closing"?"open":e.phase,target:t.target,focusRequest:a,last:n}}case"focus":return e.phase==="closed"?e:{...e,focusRequest:t.token};case"reveal":return e.phase==="waiting"?{...e,phase:"opening"}:e;case"revealed":return e.phase==="opening"?{...e,phase:"open"}:e;case"close":return e.phase==="closed"?e:e.phase==="waiting"||t.instant?{...hH,last:e.last}:e.phase==="closing"?e:{...e,phase:"closing",popover:null,grace:!1};case"closed":return e.phase==="closing"?{...hH,last:e.last}:e;case"grace-over":return e.grace?{...e,grace:!1}:e;case"popover":return e.phase==="closed"||e.popover===t.anchor?e:{...e,popover:t.anchor};case"launched":{const n=e.target;return(n==null?void 0:n.kind)!=="launch"||n.key!==t.key||!t.sessionId?e:{...e,target:{kind:"session",id:t.sessionId,launch:n.key},last:t.sessionId}}case"remember":return t.sessionId&&e.last!==t.sessionId?{...e,last:t.sessionId}:e}}function pH(e,t,n){return e?{kind:"session",id:e}:t&&n(t)?{kind:"session",id:t}:{kind:"empty"}}const THe="ts-empty-new-session";function gH(e,t){return!e||!t||!(e.w>0)||!(e.h>0)?null:e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y?e:null}function NHe(e){return e?[...e.querySelectorAll(".board-nav [data-nav-session]")].map(t=>t.getAttribute("data-nav-session")??"").filter(Boolean):[]}function AHe(e){var n,a;const t=e;return((a=(n=t==null?void 0:t.closest)==null?void 0:n.call(t,"[data-nav-session]"))==null?void 0:a.getAttribute("data-nav-session"))??null}const mH="agent-dag.terminal.firstRunDone",jHe=1e4,EHe=256,RHe=new Set(["Shift","Control","Alt","AltGraph","Meta","OS","Super","Hyper","Fn","FnLock","CapsLock","NumLock","ScrollLock","Dead"]);function fH(e){return{text:"",until:e+jHe}}function zHe(e){return e.text||e.spoiled?"typed":"empty"}function qHe(e){return e.spoiled?"":e.text}function _He(e,t,n=zs(js())){var o;if(RHe.has(t.key))return null;if(t.key==="Escape")return"end";const a={key:t.key,code:t.code??"",ctrlKey:t.ctrlKey,shiftKey:t.shiftKey===!0,metaKey:t.metaKey,altKey:t.altKey,repeat:t.repeat,isComposing:t.isComposing,keyCode:t.keyCode,getModifierState:(o=t.getModifierState)==null?void 0:o.bind(t)};if(JR(a))return"end";if($R(a))return null;if(t.isComposing||t.keyCode===229)return{ahead:{...e,spoiled:!0},swallow:!1};if(a.repeat&&a.key==="Enter")return{ahead:e,swallow:!0};const s=LHe({...a,type:"keydown"},n);return s==null||s==="\x1B"?{ahead:{...e,spoiled:!0},swallow:!1}:[...e.text].length+[...s].length>EHe?{ahead:{...e,spoiled:!0},swallow:!0}:{ahead:{...e,text:e.text+s},swallow:!0}}function LHe(e,t){var o;const n=I0e(e,t);return n==="newline"||n==="send"||n==="meta"?D0e(e,n,t):n!=="pass"||!(((o=e.getModifierState)==null?void 0:o.call(e,"AltGraph"))===!0||!e.ctrlKey&&!e.metaKey&&(!e.altKey||t))?null:e.key==="Enter"?e.altKey||e.shiftKey?null:"\r":e.key==="Backspace"?e.altKey?null:"":[...e.key].length===1?e.key:null}function PHe(e){if(!e||K7(e))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?!0:e.isContentEditable===!0}function K7(e){var t;return((t=e==null?void 0:e.classList)==null?void 0:t.contains("xterm-helper-textarea"))===!0}const OHe=8e3,MHe=3200,IHe="board.asks.noMoreSaid";function DHe(){return{run:null,arrival:null,waiting:null,stageOpen:!1,said:""}}const bH=(e,t)=>e!=null&&e.length===t.length&&e.every((n,a)=>n===t[a]);function FHe(e,t,n){let a=e;for(const s of n)!t.includes(s.id)||e[s.id]===s.label||(a===e&&(a={...e}),a[s.id]=s.label);return a}function BHe(e,{waiting:t,stageOpen:n,current:a,now:s}){const o=t.map(v=>v.id);if(e.waiting===null)return{...e,waiting:o,stageOpen:n};const r=new Set(e.waiting),c=new Set(o),l=(v,w=v)=>{var T;return((T=t.find(y=>y.id===v))==null?void 0:T.label)??w},u=t.filter(v=>!r.has(v.id)),h=[];let p=e.run,f=e.arrival;if(e.stageOpen&&!n&&(p=null,f=null),p){const v=p,w=v.ids.filter(z=>!v.done.includes(z)&&!c.has(z));for(const z of w)h.push(S("board.asks.resumedSaid",{name:v.labels[z]??z}));let T=w.length>0?[...v.done,...w]:v.done,y=v.ids,x=v.fresh;for(const z of u){if(T.includes(z.id))T=T.filter(I=>I!==z.id);else if(!y.includes(z.id))y=[...y,z.id];else continue;x=z.id,h.push(S("board.asks.waitingSaid",{name:z.label}))}let C=FHe(v.labels,y,t);for(const z of y)C[z]===void 0&&(C={...C,[z]:l(z)});const A=y.every(z=>T.includes(z));let E=v.endsAt;A&&E===null?(E=s+MHe,h.push(S(IHe))):A||(E=null),(y!==v.ids||T!==v.done||x!==v.fresh||C!==v.labels||E!==v.endsAt)&&(p={ids:y,done:T,fresh:x,labels:C,endsAt:E})}else if(n){const v=u.filter(T=>T.id!==a);for(const T of v)h.push(S("board.asks.waitingSaid",{name:T.label}));const w=v[v.length-1];w&&(f={id:w.id,label:w.label,until:s+OHe})}f&&(!c.has(f.id)||f.id===a)&&(f=null);const b=h.length>0?Ab(e.said,h.join(" "),e.said):e.said;return p===e.run&&f===e.arrival&&bH(e.waiting,o)&&n===e.stageOpen&&b===e.said?e:{run:p,arrival:f,waiting:bH(e.waiting,o)?e.waiting:o,stageOpen:n,said:b}}function rp(e,t){switch(t.type){case"observe":return BHe(e,t);case"start":{if(e.run||t.waiting.length===0)return e;const n={};for(const a of t.waiting)n[a.id]=a.label;return{...e,run:{ids:t.waiting.map(a=>a.id),done:[],fresh:null,labels:n,endsAt:null},arrival:null}}case"take-arrival":return e.arrival?{...e,arrival:null}:e;case"expire":{const n=e.arrival&&e.arrival.until<=t.now?null:e.arrival,a=e.run&&e.run.endsAt!==null&&e.run.endsAt<=t.now?null:e.run;return n===e.arrival&&a===e.run?e:{...e,arrival:n,run:a}}}}function UHe(e){return(e==null?void 0:e.ids.find(t=>!e.done.includes(t)))??null}function $7(e,t){if(e.arrival)return e.arrival.id;const n=e.run;return(n==null?void 0:n.ids.find(a=>!n.done.includes(a)&&a!==t))??null}function WHe(e){var n,a;const t=[(n=e.arrival)==null?void 0:n.until,(a=e.run)==null?void 0:a.endsAt].filter(s=>typeof s=="number");return t.length>0?Math.min(...t):null}function HHe(e,t){const n=e.run;if(!n)return{track:[],position:null,resumed:null,next:null,clear:!1,arrival:e.arrival};const a=l=>n.done.includes(l),s=n.ids.map(l=>({id:l,state:a(l)?"done":l===t?"now":"todo",fresh:l===n.fresh})),o=t==null?-1:n.ids.indexOf(t),r=o>=0&&!a(t),c=$7({...e,arrival:null},t);return{track:s,position:r?{index:o+1,total:n.ids.length}:null,resumed:o>=0&&!r?{id:t,label:n.labels[t]??t}:null,next:r||c==null?null:{id:c,label:n.labels[c]??c},clear:n.ids.every(a),arrival:null}}function GHe({waitingSessions:e,stageOpen:t,currentId:n,switchTo:a}){const[s,o]=m.useState(DHe),r=Pt(s),c=Pt(e),l=Pt(n),u=Pt(a),h=e.map(v=>`${v.id} ${v.label}`).join(`
|
|
361
|
+
`);m.useEffect(()=>{o(v=>rp(v,{type:"observe",waiting:c.current,stageOpen:t,current:n,now:Date.now()}))},[h,t,n,c]);const p=WHe(s);m.useEffect(()=>{if(p===null)return;const v=setTimeout(()=>o(w=>rp(w,{type:"expire",now:Date.now()})),Math.max(0,p-Date.now()));return()=>clearTimeout(v)},[p]);const f=m.useCallback(()=>{var y;const v=c.current,w=rp(r.current,{type:"start",waiting:v}),T=UHe(w.run)??((y=v[0])==null?void 0:y.id)??null;T!==null&&(o(x=>rp(x,{type:"start",waiting:v})),u.current(T,{focusPane:!0}))},[r,c,u]),b=m.useCallback(()=>{const v=r.current;if(!v.run&&!v.arrival){f();return}const w=$7(v,l.current);w!==null&&(v.arrival&&o(T=>rp(T,{type:"take-arrival"})),u.current(w,{focusPane:!0}))},[r,l,u,f]);return{view:HHe(s,n),said:s.said,startAsks:f,nextAsk:b}}const J7=4,VHe=40,KHe=8,nw=1,$He=.3,AE="agent-dag.workspace.split",Uz={kind:"empty"};function JHe(e="p0"){return{root:{kind:"leaf",id:e},targets:{[e]:Uz},focused:e,max:null,next:Number(e.slice(1))+1||1}}function aa(e){return e.kind==="leaf"?[e.id]:[...aa(e.a),...aa(e.b)]}function ob(e){return aa(e.root).length}function kg(e,t,n){return t===e.focused&&n?n:e.targets[t]??Uz}function YHe(e,t,n=aa(e.root)){const a=new Map;return n.length<2||n.forEach((s,o)=>{const r=kg(e,s,t);r.kind==="session"&&a.set(r.id,{number:o+1,active:s===e.focused})}),a}function lj(e,t,n,a){for(const s of aa(e.root)){if(s===a)continue;const o=kg(e,s,n);if(o.kind==="session"&&o.id===t)return s}return null}function vg(e,t,n=nw){if(e.kind==="leaf")return t;const a=vg(e.a,t,n),s=vg(e.b,t,n);return e.dir==="row"?{w:a.w+n+s.w,h:Math.max(a.h,s.h)}:{w:Math.max(a.w,s.w),h:a.h+n+s.h}}function ZHe(e,t,n,a=nw){const s=vg(e,n,a);return s.w<=t.w&&s.h<=t.h}function kH(e,t,n,a){const s=Math.max(0,e),o=Math.round(s*t);return n+a>s?o:Math.min(s-a,Math.max(n,o))}function XHe(e,t,n,a=nw){const s=new Map,o=[],r=(c,l,u)=>{if(c.kind==="leaf"){s.set(c.id,l);return}const h=vg(c.a,n,a),p=vg(c.b,n,a);if(c.dir==="row"){const f=l.w-a,b=kH(f,c.ratio,h.w,p.w);r(c.a,{x:l.x,y:l.y,w:b,h:l.h},u+"a"),r(c.b,{x:l.x+b+a,y:l.y,w:f-b,h:l.h},u+"b"),o.push({path:u,dir:"row",rect:{x:l.x+b,y:l.y,w:a,h:l.h},start:l.x,length:f,minA:h.w,minB:p.w,ratio:c.ratio})}else{const f=l.h-a,b=kH(f,c.ratio,h.h,p.h);r(c.a,{x:l.x,y:l.y,w:l.w,h:b},u+"a"),r(c.b,{x:l.x,y:l.y+b+a,w:l.w,h:f-b},u+"b"),o.push({path:u,dir:"col",rect:{x:l.x,y:l.y+b,w:l.w,h:a},start:l.y,length:f,minA:h.h,minB:p.h,ratio:c.ratio})}};return r(e,t,""),{panes:s,dividers:o}}function QHe(e){return[...e.entries()].sort(([,t],[,n])=>Math.abs(t.y-n.y)>2?t.y-n.y:t.x-n.x).map(([t])=>t)}const dj=32;function e3e(e,t,n,a=nw){const s={x:0,y:0,w:Math.max(0,t.w),h:Math.max(0,t.h)},o=aa(e.root);if(o.length<2)return{mode:"one",why:null,rects:new Map([[e.focused,s]]),dividers:[],order:o,strip:0};const r=XHe(e.root,s,n,a),c=QHe(r.panes),l=e.max&&o.includes(e.max)?"max":ZHe(e.root,s,n,a)?null:"narrow";if(!l)return{mode:"split",why:null,rects:r.panes,dividers:r.dividers,order:c,strip:0};const u={x:0,y:dj,w:s.w,h:Math.max(0,s.h-dj)};return{mode:"strip",why:l,rects:new Map(o.map(h=>[h,u])),dividers:[],order:c,strip:dj}}function B4e(e,t){if(!(e.length>0))return .5;let n=t-e.start;return e.minA+e.minB<=e.length&&(n=Math.min(e.length-e.minB,Math.max(e.minA,n))),Math.min(.95,Math.max(.05,n/e.length))}function U4e(e,t,n,a){if(!a||!(e.w>0)||!(e.h>0))return"here";const s=(t-e.x)/e.w,o=(n-e.y)/e.h,r=[["left",s],["right",1-s],["top",o],["bottom",1-o]],[c,l]=r.reduce((u,h)=>h[1]<u[1]?h:u);return l<$He?c:"here"}function W4e(e,t){const n=Math.round(e.w/2),a=Math.round(e.h/2);switch(t){case"left":return{...e,w:n};case"right":return{...e,x:e.x+e.w-n,w:n};case"top":return{...e,h:a};case"bottom":return{...e,y:e.y+e.h-a,h:a};default:return e}}function Pk(e,t,n){if(e.kind==="leaf")return e.id===t?n(e):e;const a=Pk(e.a,t,n),s=Pk(e.b,t,n);return a===e.a&&s===e.b?e:{...e,a,b:s}}function Y7(e,t,n){const a=t==="left"||t==="right"?"row":"col",s=t==="left"||t==="top";return{kind:"split",dir:a,ratio:.5,a:s?n:e,b:s?e:n}}function t3e(e,t,n,a){const s=aa(e.root);if(s.length>=J7||!s.includes(t))return null;let o=e.next;for(;s.includes(`p${o}`);)o++;const r=`p${o}`,c=Pk(e.root,t,l=>Y7(l,n,{kind:"leaf",id:r}));return{state:{...e,root:c,targets:{...e.targets,[r]:a},next:o+1,max:null},id:r}}function jE(e,t){return e.kind==="leaf"?null:e.a.kind==="leaf"&&e.a.id===t?aa(e.b)[0]??null:e.b.kind==="leaf"&&e.b.id===t?aa(e.a).slice(-1)[0]??null:jE(e.a,t)??jE(e.b,t)}function Ok(e,t){if(e.kind==="leaf")return e.id===t?null:e;const n=Ok(e.a,t),a=Ok(e.b,t);return n?a?n===e.a&&a===e.b?e:{...e,a:n,b:a}:n:a}function vH(e,t){const n=aa(e.root);if(n.length<=1||!n.includes(t))return e;const a=Ok(e.root,t)??e.root,s={...e.targets};delete s[t];const o=e.focused===t?jE(e.root,t)??aa(a)[0]:e.focused,r=e.max===t||aa(a).length<2?null:e.max;return{...e,root:a,targets:s,focused:o,max:r}}function n3e(e,t,n,a){const s=aa(e.root);if(t===n||!s.includes(t)||!s.includes(n))return e;if(a==="here"){const r=c=>c.kind==="leaf"?c.id===t?{kind:"leaf",id:n}:c.id===n?{kind:"leaf",id:t}:c:{...c,a:r(c.a),b:r(c.b)};return{...e,root:r(e.root)}}const o=Ok(e.root,t);return o?{...e,root:Pk(o,n,r=>Y7(r,a,{kind:"leaf",id:t})),max:null}:e}function EE(e,t,n){if(e.kind==="leaf")return e;if(!t)return n(e);const[a,s]=[t[0],t.slice(1)];return a==="a"?{...e,a:EE(e.a,s,n)}:{...e,b:EE(e.b,s,n)}}function a3e(e,t,n){if(!Number.isFinite(n))return e;const a=Math.min(.95,Math.max(.05,n));return{...e,root:EE(e.root,t,s=>s.ratio===a?s:{...s,ratio:a})}}function cp(e,t,n){if(!aa(e.root).includes(t))return e;const a=n?{...e.targets,[e.focused]:n}:e.targets;return{...e,targets:a,focused:t,max:e.max&&e.max!==t?t:e.max}}function uj(e,t){const n=e.targets[e.focused];return n&&s3e(n,t)?e:{...e,targets:{...e.targets,[e.focused]:t}}}function s3e(e,t){return e.kind!==t.kind?!1:e.kind==="session"&&t.kind==="session"?e.id===t.id&&e.launch===t.launch:e.kind==="launch"&&t.kind==="launch"?e.key===t.key:!0}function i3e(e,t,n){let a=!1;const s={};for(const[o,r]of Object.entries(e.targets))r.kind==="launch"&&r.key===t&&o!==e.focused?(s[o]={kind:"session",id:n,launch:t},a=!0):s[o]=r;return a?{...e,targets:s}:e}const o3e=/^p\d{1,4}$/;function r3e(e,t){const n=aa(e.root);if(n.length<2)return null;const a={};for(const o of n){const r=kg(e,o,t);a[o]=r.kind==="session"?r.id:null}const s={v:1,root:e.root,panes:a,focused:e.focused,next:e.next};return JSON.stringify(s)}function RE(e,t,n){if(!e||typeof e!="object"||n>4)return!1;const a=e;return a.kind==="leaf"?typeof a.id!="string"||!o3e.test(a.id)||t.has(a.id)?!1:(t.add(a.id),!0):a.kind==="split"&&(a.dir==="row"||a.dir==="col")&&typeof a.ratio=="number"&&a.ratio>=.05&&a.ratio<=.95&&RE(a.a,t,n+1)&&RE(a.b,t,n+1)}function c3e(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}const n=t;if(!n||n.v!==1||!n.panes||typeof n.panes!="object")return null;const a=new Set;if(!RE(n.root,a,0)||a.size<2||a.size>J7)return null;const s={};for(const c of a){const l=n.panes[c];s[c]=typeof l=="string"&&l.length>0&&l.length<=200?{kind:"session",id:l}:Uz}const o=typeof n.focused=="string"&&a.has(n.focused)?n.focused:[...a][0],r=Number.isInteger(n.next)&&n.next>0?n.next:a.size;return{root:n.root,targets:s,focused:o,max:null,next:r}}function l3e(e=gt){return c3e(e(AE))}function d3e(e,t,n=yt,a=Ja){const s=r3e(e,t);s?n(AE,s):a(AE)}const Wz=()=>Xs(()=>import("./StageShell-Bl0ddeiL.js").then(e=>e.a),__vite__mapDeps([7,1])),u3e=3e3,h3e=6e3,p3e="board.stage.shellUnavailable",rb={kind:"empty"},lp=e=>({x:e.left,y:e.top,w:e.width,h:e.height});function wH(e,t){try{return(e==null?void 0:e.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`))??null}catch{return null}}function g3e(e){const t=e.querySelector(".lod-name");return t&&t.getBoundingClientRect().width>0?t:e.querySelector(".title .label")}function m3e(){var e,t;return jb()?lHe:rHe(typeof document>"u"||(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.density)}function jb(){return typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches}function f3e(){return typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches}function b3e(e){return e?[...e.querySelectorAll(".session-list .sl-row[data-session]")].filter(t=>t.getClientRects().length>0&&!t.closest("[inert]")).map(t=>t.getAttribute("data-session")??"").filter(Boolean):[]}function k3e(e){var n,a;const t=e;return((a=(n=t==null?void 0:t.closest)==null?void 0:n.call(t,".session-list [data-session]"))==null?void 0:a.getAttribute("data-session"))??null}function Z7(e){try{return document.querySelector(`.session-list .sl-row[data-session="${CSS.escape(e)}"]`)}catch{return null}}function v3e({stateRef:e,canvasRef:t,detailOpen:n,detailShown:a,setDetailOpen:s,primarySelectedIdRef:o,selectAgent:r,view:c="board",phone:l=!1,clearSelection:u,ready:h=!1}){const[p,f]=m.useState(!1),[b,v]=m.useState(null),[w,T]=m.useState(!1),y=Pt(p),[x,C]=m.useState(!1),[A,E]=m.useState(!1),R=Pt(l),z=m.useCallback(ae=>{f(ae.terminalOn===!0),v(typeof ae.terminalSupported=="boolean"?ae.terminalSupported:null),T(ae.terminalWindows===!0),C(!0),(ae.terminalOn!==!0||ae.terminalSupported===!1)&&!R.current&&_k()==="workspace"&&y7("board")},[R]);m.useEffect(()=>{if(x||c!=="workspace")return;const ae=window.setTimeout(()=>C(!0),u3e);return()=>window.clearTimeout(ae)},[x,c]);const I=x7({enabled:p,supported:b},l),_=I&&!A,D=c==="workspace"&&!l&&!A&&(I||!x),[L,P]=m.useState(wHe),O=Pt(L),j=m.useCallback(ae=>{const ye=SHe(O.current,ae);O.current=ye,P(ye)},[O]),M=Pt(n),F=Pt(D),U=L.phase!=="closed",[H,$]=m.useState(uc),[Y,W]=m.useState(()=>bHe()),[G,Q]=m.useState(!1),J=m.useRef(D);m.useLayoutEffect(()=>{J.current!==D&&(J.current=D,Q(!1))},[D]);const[X,te]=m.useState(null),[K,V]=m.useState(()=>jb()?dHe+uHe:f3e()?cHe:nc),[ee,de]=m.useState(m3e),he=m.useCallback(()=>(F.current&&typeof document<"u"?document.querySelector(".ws-cell"):null)??t.current,[t]),me=m.useCallback(()=>{const ae=he();if(!ae)return;const ye=ae.getBoundingClientRect(),Ue=Math.floor(Math.min(ae.clientWidth,ye.width)),lt=Math.floor(Math.min(ae.clientHeight,ye.height)),nt=window.innerWidth<iHe;te(bt=>bt&&bt.w===Ue&&bt.h===lt&&bt.narrow===nt?bt:{w:Ue,h:lt,narrow:nt})},[he]);m.useLayoutEffect(()=>{if(!U)return;me();const ae=he();if(!ae||typeof ResizeObserver>"u")return;const ye=new ResizeObserver(me);return ye.observe(ae),window.addEventListener("resize",me),()=>{ye.disconnect(),window.removeEventListener("resize",me)}},[U,me,he,D]);const be=X&&U?uH({appW:X.w,bodyH:X.h,cellW:H.w,cellH:H.h,expanded:G,narrow:X.narrow,storedCols:Y,fill:D,barH:K,headH:ee,externalBar:!jb()}):null,ie=Pt(be),ne=m.useRef(void 0);ne.current===void 0&&(ne.current=l3e());const[ke,Se]=m.useState(()=>{var ae;return JHe(((ae=ne.current)==null?void 0:ae.focused)??"p0")}),ve=Pt(ke),xe=m.useCallback(ae=>{ae!==ve.current&&(ve.current=ae,Se(ae))},[ve]),Ee=!jb(),Ge=m.useMemo(()=>vHe(VHe,KHe,H,ee,K,Ee),[H,ee,K,Ee]),Qe=D&&X&&U?e3e(ke,X,Ge):null,Je=Pt(Qe),He=m.useCallback((ae,ye)=>uH({appW:Math.floor(ae),bodyH:Math.floor(ye),cellW:H.w,cellH:H.h,expanded:!1,narrow:(X==null?void 0:X.narrow)??!1,storedCols:null,fill:!0,barH:K,headH:ee,externalBar:Ee}),[H,K,ee,X==null?void 0:X.narrow,Ee]),_e=m.useRef(null),le=m.useRef(new Map),[Re,ge]=m.useState(()=>gt(mH)!=="1"),[Pe,Fe]=m.useState(""),[Ve,ot]=m.useState(null);m.useEffect(()=>{if(!Ve)return;const ae=setTimeout(()=>ot(null),h3e);return()=>clearTimeout(ae)},[Ve]);const ce=m.useRef(null),Ce=m.useRef(null),Ke=m.useRef(0),Oe=m.useRef(0),at=m.useRef(null),ut=m.useRef(new Set),vt=m.useRef(null),qe=m.useRef(null),dt=m.useRef(null),et=m.useCallback((ae,ye={})=>{if(!y.current)return;if(ae.kind==="session"&&(ae={...ae,id:gp(e.current.agents,ae.id)}),F.current&&ae.kind==="session"){const Bt=ve.current,Sn=O.current.phase!=="closed"?O.current.target:null,Tn=ob(Bt)>1?lj(Bt,ae.id,Sn,Bt.focused):null;Tn&&(xe(cp(Bt,Tn,Sn)),ae=kg(Bt,Tn,null))}const Ue=ye.focusPane?++Ke.current:null;if(Ue!=null&&(_e.current={token:Ue,pane:ve.current.focused},dt.current=ae.kind==="session"?{token:Ue,session:ae.id,from:document.activeElement,ahead:fH(Date.now())}:null),O.current.phase!=="closed"){j({type:"open",target:ae,focus:Ue});return}const lt=t.current,nt=ye.el??(ae.kind==="session"?wH(lt,ae.id):null),bt=lt?lp(fg(lt)):null,qt=gH(nt?lp(nt.getBoundingClientRect()):null,bt),sn=qt&&(nt!=null&&nt.classList.contains("react-flow__node"))?g3e(nt):null;me(),Zs(),M.current&&!F.current&&s(!1),j({type:"open",target:ae,origin:qt,originName:sn?lp(sn.getBoundingClientRect()):null,grace:!!ye.grace,focus:Ue})},[y,O,t,M,me,s,F,ve,xe,e]),Ie=Pt(r),ct=Pt(u),Nt=m.useRef(null),Le=m.useCallback(ae=>{var ye;if(e.current.agents.has(ae)){Ie.current(ae,!1,!1);return}F.current&&(Nt.current=ae,(ye=ct.current)==null||ye.call(ct))},[e,Ie,F,ct]),Ht=m.useCallback((ae,ye)=>{if(!y.current)return!1;const Ue=gp(e.current.agents,ae);return et({kind:"session",id:Ue},{el:ye,grace:O.current.phase==="closed",focusPane:!0}),!0},[y,e,O,et]),Mt=m.useCallback(ae=>!y.current||!ac(O.current.phase)?!1:(et({kind:"session",id:ae}),Le(ae),!0),[y,O,et,Le]),yn=m.useCallback((ae,ye)=>{y.current&&(et({kind:"session",id:ae},{focusPane:ye.focusPane}),Le(ae))},[y,et,Le]),mn=m.useCallback((ae,ye={})=>{y.current&&(et({kind:"session",id:ae},{focusPane:ye.focusPane===!0}),Le(ae))},[y,et,Le]),xn=m.useCallback(()=>{var ae;y.current&&(et({kind:"empty"},{focusPane:!0}),Nt.current=null,(ae=ct.current)==null||ae.call(ct))},[y,et,ct]),Gt=m.useCallback(ae=>{var sn;const ye=o.current,Ue=ye?((sn=e.current.agents.get(ye))==null?void 0:sn.sessionId)??null:null,lt=pH(Ue,O.current.last,Bt=>e.current.agents.has(Bt)||ut.current.has(Bt)),nt=lt.kind==="session"?wH(t.current,lt.id):null,bt=t.current?lp(fg(t.current)):null,qt=nt&&gH(lp(nt.getBoundingClientRect()),bt);et(lt,{el:qt?nt:ae,focusPane:!0}),qe.current=ae&&typeof ae.focus=="function"?ae:null},[o,e,O,t,et]),tt=m.useRef(null),rt=m.useCallback(ae=>{y.current&&(tt.current="asked",et(rb,{el:ae,focusPane:!0}),qe.current=ae)},[y,et]),Ye=m.useCallback(()=>{if(!ac(O.current.phase))return;const ae=++Ke.current;_e.current={token:ae,pane:ve.current.focused};const ye=ma(O.current.target);dt.current=ye?{token:ae,session:ye,from:document.activeElement,ahead:fH(Date.now())}:null,j({type:"focus",token:ae})},[O,ve]),Vt=m.useCallback((ae,ye)=>{if(!(ye!=null&&ye.keyboard)){et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}if(ae===ma(O.current.target)){Ye();return}et({kind:"session",id:ae}),Le(ae)},[O,et,Le,Ye]),Rt=m.useCallback((ae,ye={})=>{var bt;if(!y.current||!F.current)return!1;const Ue=ve.current;if(!aa(Ue.root).includes(ae))return!1;if(ae===Ue.focused)return ye.keys&&Ye(),!0;const lt=cp(Ue,ae,O.current.phase!=="closed"?O.current.target:null);xe(lt);const nt=lt.targets[ae]??rb;return et(nt,{focusPane:ye.keys===!0}),nt.kind==="session"?Le(nt.id):(Nt.current=nt.kind==="launch"?"launch":null,(bt=ct.current)==null||bt.call(ct)),!0},[y,F,ve,O,xe,Ye,et,Le,ct]),_n=m.useCallback(ae=>{const ye=Je.current;if(!ye||ye.mode==="one")return!1;const Ue=ye.order[ae-1];return Ue?Rt(Ue,{keys:!0}):!1},[Je,Rt]),Xa=m.useCallback((ae,ye={})=>{var Sn;if(!y.current)return;if(ae=gp(e.current.agents,ae),!F.current){et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}const Ue=ve.current,lt=O.current.phase!=="closed"?O.current.target:null,nt=lj(Ue,ae,lt);if(nt){Rt(nt,{keys:!0});return}const bt=ye.at??Ue.focused;if(kg(Ue,bt,lt).kind==="empty"){bt!==Ue.focused&&xe(cp(Ue,bt,lt)),et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}const qt=(Sn=Je.current)==null?void 0:Sn.rects.get(bt),sn=ye.zone??(qt&&qt.h>qt.w?"bottom":"right"),Bt=t3e(lt?uj(Ue,lt):Ue,bt,sn,{kind:"session",id:ae});if(!Bt){ot(Tn=>({text:S("board.stage.split.full"),n:((Tn==null?void 0:Tn.n)??0)+1})),et({kind:"session",id:ae},{focusPane:!0}),Le(ae);return}Q(!1),xe(cp(Bt.state,Bt.id,lt)),et({kind:"session",id:ae},{focusPane:!0}),Le(ae)},[y,F,ve,O,Je,xe,et,Le,Rt,e]),fn=m.useCallback((ae,ye)=>{if(!y.current||!F.current)return;ye=gp(e.current.agents,ye);const Ue=ve.current,lt=O.current.phase!=="closed"?O.current.target:null,nt=lj(Ue,ye,lt);if(nt){Rt(nt,{keys:!0});return}ae!==Ue.focused&&xe(cp(Ue,ae,lt)),et({kind:"session",id:ye},{focusPane:!0}),Le(ye)},[y,F,ve,O,xe,et,Le,Rt,e]),cn=m.useCallback((ae,ye,Ue)=>{xe(n3e(ve.current,ae,ye,Ue))},[ve,xe]),ka=m.useCallback((ae,ye)=>{xe(a3e(ve.current,ae,ye))},[ve,xe]),Cn=m.useCallback(ae=>{if(ve.current.max===ae){xe({...ve.current,max:null});return}ae!==ve.current.focused&&Rt(ae),xe({...ve.current,max:ae})},[ve,xe,Rt]),qa=m.useCallback(()=>{ve.current.max&&xe({...ve.current,max:null})},[ve,xe]),ia=m.useCallback(ae=>{var bt;if(!y.current)return;const ye=ve.current;if(!F.current||ob(ye)<=1||!aa(ye.root).includes(ae)){xn();return}const Ue=ye.focused===ae,lt=vH(ye,ae);if(xe(lt),!Ue)return;const nt=lt.targets[lt.focused]??rb;et(nt,{focusPane:!0}),nt.kind==="session"?Le(nt.id):(Nt.current=nt.kind==="launch"?"launch":null,(bt=ct.current)==null||bt.call(ct))},[y,F,ve,xe,xn,et,Le,ct]),_a=m.useCallback(ae=>{const ye=L.phase==="waiting"?null:L.focusRequest,Ue=_e.current;return ye!=null&&(Ue==null?void 0:Ue.token)===ye&&Ue.pane===ae?ye:null},[L.phase,L.focusRequest]),La=m.useCallback((ae,ye,Ue)=>{var nt;const lt=`launch-${Date.now().toString(36)}-${++Oe.current}-${Math.random().toString(36).slice(2,10)}`;et({kind:"launch",agent:ae,cwd:ye,key:lt,...Ue?{options:Ue}:{}},{focusPane:!0}),F.current&&y.current&&(Nt.current="launch",(nt=ct.current)==null||nt.call(ct))},[et,F,y,ct]),Qa=m.useCallback(ae=>{var Ue;const ye=O.current.target;if((ye==null?void 0:ye.kind)!=="launch"||ae.key!==void 0&&ae.key!==ye.key){!!ae.key&&!!ae.sessionId&&Object.entries(ve.current.targets).some(([nt,bt])=>nt!==ve.current.focused&&bt.kind==="launch"&&bt.key===ae.key)&&ae.key&&(le.current.set(ae.key,ae.sessionId),ut.current.add(ae.sessionId),ZM(e.current,ae.sessionId,ae.key));return}!ae.sessionId&&((Ue=at.current)==null?void 0:Ue.key)===ye.key&&at.current.sessionId||(at.current={key:ye.key,sessionId:ae.sessionId},ae.sessionId&&le.current.set(ye.key,ae.sessionId),ae.sessionId&&(ut.current.add(ae.sessionId),j({type:"remember",sessionId:ae.sessionId}),ZM(e.current,ae.sessionId,ye.key)))},[O,e,ve]);m.useEffect(()=>{const ae=L.target;if((ae==null?void 0:ae.kind)!=="launch")return;const ye=at.current,Ue=ye&&ye.key===ae.key?ye.sessionId:le.current.get(ae.key);Ue&&e.current.agents.has(Ue)&&j({type:"launched",key:ae.key,sessionId:Ue})}),m.useEffect(()=>{const ae=ve.current;let ye=ae;for(const[Ue,lt]of Object.entries(ae.targets)){if(Ue===ae.focused||lt.kind!=="launch")continue;const nt=le.current.get(lt.key);nt&&e.current.agents.has(nt)&&(ye=i3e(ye,lt.key,nt))}xe(ye)}),m.useEffect(()=>{!D||L.phase==="closed"||!L.target||xe(uj(ve.current,L.target))},[D,L.phase,L.target,ve,xe]);const Pa=m.useRef(0);m.useEffect(()=>{const ae=ne.current;if(!ae||!p||!D||L.phase==="closed")return;const ye=ve.current;if(ob(ye)>1){ne.current=null;return}Pa.current||(Pa.current=Date.now()+CH);const Ue=Sn=>e.current.agents.has(Sn)||ut.current.has(Sn),lt=Object.values(ae.targets).flatMap(Sn=>Sn.kind==="session"?[Sn.id]:[]);if(!h&&!lt.every(Ue)&&Date.now()<=Pa.current)return;ne.current=null;const nt=O.current.target,bt=ae.targets[ae.focused],qt=(nt==null?void 0:nt.kind)==="empty"&&(bt==null?void 0:bt.kind)==="session"&&Ue(bt.id)?bt.id:null,sn=(nt==null?void 0:nt.kind)==="session"?nt.id:qt;let Bt={...ae,focused:ye.focused,max:null,next:Math.max(ae.next,ye.next)};for(const Sn of aa(ae.root)){if(Sn===Bt.focused)continue;const Tn=Bt.targets[Sn];(!Tn||Tn.kind!=="session"||Tn.id===sn||!Ue(Tn.id))&&(Bt=vH(Bt,Sn))}ob(Bt)<2||(xe(qt?Bt:uj(Bt,nt??rb)),qt&&(et({kind:"session",id:qt}),Le(qt)))}),m.useEffect(()=>{ne.current||!p||!D||d3e(ke,L.phase!=="closed"?L.target:null)},[ke,L.phase,L.target,p,D]),m.useEffect(()=>{const ae=Nt.current;if(ae===null)return;const ye=L.phase==="closed"?null:L.target;if(!F.current||!ye||ye.kind==="empty"){Nt.current=null;return}if(ye.kind==="launch"){ae!=="launch"&&(Nt.current=null);return}if(ae!=="launch"&&ye.id!==ae){Nt.current=null;return}if(!e.current.agents.has(ye.id)){Nt.current=ye.id;return}Nt.current=null,Ie.current(ye.id,!1,!1)});const oa=m.useCallback(()=>{var sn,Bt,Sn;const ae=ma(O.current.target),ye=ie.current,Ue=t.current;if(F.current){const Tn=ae?Z7(ae):null;if(Tn&&Tn.getClientRects().length>0){Tn.focus();return}}let lt=null;try{lt=ae&&Ue?Ue.querySelector(`.board-nav [data-nav-session="${CSS.escape(ae)}"]`):null}catch{}if(ae&<&&ce.current&&ye&&!ye.takeover){ce.current.focusTile(ae);return}const nt=document.querySelector(".stage-dock .wsp-pane[data-focused] .ts-head")??document.querySelector(".stage-dock .ts-head"),bt=nt==null?void 0:nt.querySelector("button[aria-pressed]"),qt=(bt&&((sn=bt.dataset)==null?void 0:sn.zoom)===void 0?bt:null)??(nt==null?void 0:nt.querySelector("button[data-stage-close]"));qt?qt.focus():(Sn=(Bt=document.activeElement)==null?void 0:Bt.blur)==null||Sn.call(Bt)},[O,ie,t,F]),Xt=m.useCallback(()=>j({type:"close"}),[]),es=m.useCallback(ae=>{var lt;const ye=document.activeElement,Ue=!ye||ye===document.body||!!((lt=ye.closest)!=null&<.call(ye,".stage-dock, .stage-nav"));vt.current=Ue?{card:ma(O.current.target)}:null,ae&&Fe(ae),j({type:"closed"})},[O]),In=m.useCallback(()=>{var ye,Ue;const ae=O.current;ae.phase!=="closed"&&((Ue=(ye=document.activeElement)==null?void 0:ye.closest)!=null&&Ue.call(ye,".stage-dock, .stage-nav")&&(vt.current={card:ma(ae.target)}),j({type:"close",instant:!0}))},[O]),Oa=m.useCallback(()=>{Q(!1),In()},[In]),Dn=m.useCallback(()=>{Fe(S(p3e)),E(!0),j({type:"close",instant:!0})},[]),Ma=m.useCallback(()=>j({type:"reveal"}),[]),va=m.useCallback(()=>j({type:"revealed"}),[]),wa=m.useCallback(ae=>Fe(ae),[]),nn=m.useCallback(ae=>j({type:"popover",anchor:ae}),[]),ts=m.useCallback(ae=>{ae.id&&j({type:"popover",anchor:ae.id})},[]),un=m.useCallback(()=>j({type:"popover",anchor:null}),[]),Ia=m.useCallback((ae,ye)=>{W(ae),ye&&kHe(ae)},[]),_i=m.useCallback(()=>{W(null),Ja(Bz)},[]),Fn=m.useCallback(()=>Q(ae=>!ae),[]),ra=m.useCallback(()=>Q(!1),[]),ns=m.useCallback(()=>{ge(!1),yt(mH,"1")},[]),ya=m.useCallback(ae=>$(ye=>ye.w===ae.w&&ye.h===ae.h?ye:ae),[]),fe=m.useCallback(ae=>V(ae),[]),re=m.useCallback(ae=>de(ae),[]);m.useEffect(()=>{p&&Wz().catch(()=>{})},[p]),m.useEffect(()=>{var ye;const ae=tt.current;ae&&(L.phase==="closed"||((ye=L.target)==null?void 0:ye.kind)!=="empty"?tt.current=null:ae==="asked"&&L.phase==="open"?(tt.current="shown",j({type:"popover",anchor:THe})):ae==="shown"&&L.popover===null&&(tt.current=null,j({type:"close"})))},[L.phase,L.target,L.popover,j]);const je=m.useRef(null);m.useEffect(()=>{if(!p||je.current)return;const ae=y3e(Date.now());je.current=ae?{id:ae,until:Date.now()+CH}:"done"},[p]),m.useEffect(()=>{var lt;const ae=je.current;if(!p||!ae||ae==="done")return;const ye=O.current,Ue=F.current&&ye.phase!=="closed"&&((lt=ye.target)==null?void 0:lt.kind)==="empty";if(ye.phase!=="closed"&&!Ue||Date.now()>ae.until){je.current="done";return}e.current.agents.has(ae.id)&&(je.current="done",yn(ae.id,{focusPane:!1}))});const We=L.phase==="closed"?null:ma(L.target),st=je.current==="done";m.useEffect(()=>{if(!p||je.current!=="done"||(hj(We,Date.now()),!We))return;const ae=()=>hj(We,Date.now());return window.addEventListener("pagehide",ae),()=>window.removeEventListener("pagehide",ae)},[p,We,st]),m.useEffect(()=>{if(!L.grace)return;const ae=window.setTimeout(()=>j({type:"grace-over"}),sG);return()=>window.clearTimeout(ae)},[L.grace]),m.useEffect(()=>{a&&!F.current&&In()},[a,In,F]);const Ct=m.useRef(!1);m.useLayoutEffect(()=>{var lt;if(!D){if(!Ct.current)return;Ct.current=!1,Q(!1),O.current.phase!=="closed"&&In();return}if(Ct.current||!p||O.current.phase==="closing"||(Ct.current=!0,O.current.phase!=="closed"))return;const ae=o.current,ye=ae?((lt=e.current.agents.get(ae))==null?void 0:lt.sessionId)??null:null,Ue=pH(ye,O.current.last,nt=>e.current.agents.has(nt)||ut.current.has(nt));et(Ue),Ue.kind==="session"&&Le(Ue.id)},[D,p,L.phase,O,o,e,et,Le,In]);const Et=xHe(L);m.useEffect(()=>{var ye;const ae=(ye=t.current)==null?void 0:ye.querySelector(":scope > .react-flow");if(!p){ae!=null&&ae.hasAttribute("inert")&&ae.removeAttribute("inert");return}ae==null||ae.toggleAttribute("inert",Et)},[p,Et,t]),m.useEffect(()=>{var lt,nt;const ae=vt.current;if(U||!ae)return;vt.current=null;const ye=qe.current;qe.current=null,ae.card?fz(ae.card):ye!=null&&ye.isConnected&&ye.focus();const Ue=document.activeElement;(!Ue||Ue===document.body)&&((nt=(lt=t.current)==null?void 0:lt.focus)==null||nt.call(lt,{preventScroll:!0}))},[U,t]);const xa=m.useCallback(()=>{const ae=dt.current;dt.current=null,ae&&O.current.focusRequest===ae.token&&j({type:"focus",token:null})},[O]);m.useEffect(()=>{if(!p){dt.current=null;return}const ae=(nt,bt)=>!nt||nt===document.body||nt===document.documentElement||nt===bt.from,ye=nt=>{const bt=dt.current;if(!bt)return;const qt=nt.target;if(Date.now()>bt.ahead.until){dt.current=null;return}if(!ae(qt,bt)&&!K7(qt)){xa();return}if(PHe(qt))return;const sn=_He(bt.ahead,nt);sn==="end"&&xa(),!(!sn||sn==="end")&&(dt.current={...bt,ahead:sn.ahead},sn.swallow&&(nt.preventDefault(),nt.stopImmediatePropagation()))},Ue=nt=>{var bt,qt;dt.current&&!((qt=(bt=nt.target)==null?void 0:bt.closest)!=null&&qt.call(bt,".stage-dock"))&&xa()},lt=nt=>{var sn;const bt=dt.current,qt=nt.target;bt&&!ae(qt,bt)&&!((sn=qt==null?void 0:qt.closest)!=null&&sn.call(qt,".stage-dock"))&&xa()};return window.addEventListener("keydown",ye,!0),window.addEventListener("pointerdown",Ue,!0),window.addEventListener("focusin",lt,!0),()=>{window.removeEventListener("keydown",ye,!0),window.removeEventListener("pointerdown",Ue,!0),window.removeEventListener("focusin",lt,!0)}},[p,xa]);const Bn=ac(L.phase)?ma(L.target):null;m.useEffect(()=>{dt.current&&dt.current.session!==Bn&&(dt.current=null)},[Bn]);const zt=m.useCallback(ae=>{const ye=dt.current;return ye&&ye.token===ae&&Date.now()<=ye.ahead.until?zHe(ye.ahead):null},[]),ks=m.useCallback(ae=>{const ye=dt.current;return!ye||ye.token!==ae?"":(dt.current=null,Date.now()>ye.ahead.until?"":qHe(ye.ahead))},[]),Li=m.useRef(0),ni=m.useCallback((ae,ye)=>{fetch("/api/prefs").then(Ue=>Ue.ok?Ue.json():null).then(Ue=>{ae===Li.current&&(Ue!=null&&Ue.ok?z(Ue):f(ye))}).catch(()=>{ae===Li.current&&f(ye)})},[z]),Yl=m.useCallback(()=>{const ae=!y.current,ye=++Li.current;f(ae),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({terminal:ae})}).then(async Ue=>{const lt=await Ue.json().catch(()=>null);Ue.ok&&(lt!=null&<.ok)?(Ai(null),ye===Li.current&&z(lt),yt(xH,String(Date.now()))):(Dl(lt),ni(ye,!ae))}).catch(()=>{Dl(null),ni(ye,!ae)})},[y,z,ni]);m.useEffect(()=>{const ae=ye=>{ye.storageArea!==Gs()||ye.key!==xH||ni(++Li.current,y.current)};return window.addEventListener("storage",ae),()=>window.removeEventListener("storage",ae)},[ni,y]);const fc=m.useRef(!1);return m.useEffect(()=>{var ye;const ae=fc.current;if(fc.current=p,!(p||!ae)){if(O.current.phase!=="closed"){const Ue=document.activeElement;(!Ue||Ue===document.body||!!((ye=Ue.closest)!=null&&ye.call(Ue,".stage-dock, .stage-nav")))&&(vt.current={card:ma(O.current.target)})}j({type:"close",instant:!0}),hj(null,Date.now())}},[p,O]),{enabled:p,supported:b,windows:w,toggleTerminal:Yl,loadTerminalPrefs:z,shell:L,geometry:be,cell:H,expanded:G,firstRun:Re,said:Pe,navRef:ce,keysRef:Ce,workspace:D,workspaceOffered:_,chunkFailed:A,openInPane:mn,emptyPane:xn,leaveWorkspace:Oa,onNodeClick:Ht,followSession:Mt,switchTo:yn,openFromButton:Gt,newSessionFromBoard:rt,openTile:Vt,launch:La,onLaunched:Qa,focusPane:Ye,release:oa,takeTypeAhead:ks,holdsTypeAhead:zt,close:Xt,closed:es,failed:Dn,giveRightBack:In,reveal:Ma,revealed:va,announce:wa,openPopover:nn,newSessionFrom:ts,closePopover:un,onCols:Ia,onColsReset:_i,toggleExpand:Fn,unzoom:ra,firstRunDone:ns,onCell:ya,onBarH:fe,onHeadH:re,split:ke,arrangement:Qe,paneMin:Ge,geometryFor:He,requestFor:_a,focusPaneId:Rt,focusPaneAt:_n,openBeside:Xa,dropHere:fn,movePaneTo:cn,closePane:ia,setSplitRatio:ka,toggleMax:Cn,showAll:qa,splitNote:(Ve==null?void 0:Ve.text)??null}}function yH(e,t,n){const a=e.enabled&&e.shell.phase!=="closed"&&e.workspace!==!0,s=e.workspace===!0&&e.expanded===!0,o=t&&!(a&&CHe(e.shell.phase))&&!s,r=Pt(a),c=Pt(o),l=Pt(s),{giveRightBack:u,unzoom:h}=e,p=m.useCallback(f=>{if(!r.current){if(!l.current){n(f);return}const v=typeof f=="function"?f(c.current):f;v&&(h==null||h()),n(v);return}const b=typeof f=="function"?f(c.current):f;b&&u(),n(b)},[r,c,l,u,h,n]);return{shown:o,set:p}}const xH="agent-dag.terminal.switched",zE="agent-dag.terminal.onStage",w3e=30*6e4,CH=15e3;function y3e(e){try{const t=window.sessionStorage.getItem(zE);if(!t)return null;const n=JSON.parse(t);return typeof n.id!="string"||!n.id||typeof n.at!="number"?null:e-n.at>=0&&e-n.at<w3e?n.id:null}catch{return null}}function hj(e,t){try{e?window.sessionStorage.setItem(zE,JSON.stringify({id:e,at:t})):window.sessionStorage.removeItem(zE)}catch{}}const x3e=[];function C3e(e,t,n){const{enabled:a,shell:s,switchTo:o,navRef:r,focusPane:c,release:l,keysRef:u,workspace:h,expanded:p,focusPaneAt:f}=e,b=GHe({waitingSessions:a?t:x3e,stageOpen:a&&ac(s.phase),currentId:ma(s.target),switchTo:o});return u.current=a?{open:ac(s.phase),current:ma(s.target),get order(){return h?p?[]:b3e(document):NHe(n.current)},sessionAt:h?k3e:AHe,focusTile:v=>{var w,T;h?(w=Z7(v))==null||w.focus():(T=r.current)==null||T.focusTile(v)},...h?{mode:"rail"}:{},switchTo:o,focusPane:c,nextAsk:b.nextAsk,release:l,...h?{focusPaneAt:f}:{}}:null,b}function S3e(e){return null}function T3e({stage:e}){const{failed:t}=e;return m.useEffect(()=>{t()},[t]),null}const N3e=m.lazy(()=>Wz().then(e=>({default:e.StageNavigator}),()=>({default:S3e}))),A3e=m.lazy(()=>Wz().then(e=>({default:e.StageDock}),()=>({default:T3e})));function j3e(e){return!e.stage.enabled||e.stage.workspace||e.stage.shell.phase==="closed"?null:i.jsx(m.Suspense,{fallback:null,children:i.jsx(N3e,{...e})})}function E3e(e){return!e.stage.enabled||e.stage.shell.phase==="closed"?null:i.jsx(m.Suspense,{fallback:null,children:i.jsx(A3e,{...e})})}const R3e="board.view.group",z3e="board.view.board",q3e="board.view.workspace",_3e=()=>i.jsx(Ze,{name:"board",className:"glyph"}),L3e=()=>i.jsx(Ze,{name:"workspace",className:"glyph"});function P3e({view:e,onChange:t}){const n=se(),a=s=>o=>{s!==e&&t(s,o.detail===0?"key":"pointer")};return i.jsxs("div",{className:"view-switch",role:"group","aria-label":n(R3e),children:[i.jsxs("button",{type:"button",className:"view-opt","aria-pressed":e==="board",onClick:a("board"),children:[i.jsx(_3e,{}),n(z3e)]}),i.jsxs("button",{type:"button",className:"view-opt","aria-pressed":e==="workspace",onClick:a("workspace"),children:[i.jsx(L3e,{}),n(q3e)]})]})}function O3e({active:e,detailOpen:t,fold:n,hold:a,restore:s}){const o=m.useRef(null),r=m.useRef(!1),c=m.useRef(!0),l=m.useRef(!1);m.useLayoutEffect(()=>{const u=r.current,h=c.current;if(r.current=e,c.current=!1,e&&!u)o.current=t,n(),t&&(h?l.current=!0:a());else if(!e&&u){const p=o.current;o.current=null,p!==null&&s(p)}},[e]),m.useEffect(()=>{l.current&&(l.current=!1,a())},[])}const X7="workspace-pane",M3e="board.stage.skipToPane";function I3e(e=t=>document.getElementById(t)){const t=e(X7);return t?(t.focus({preventScroll:!0}),!0):!1}function D3e(){return zn(Ya()?"--dur-xfade":"--dur-move")}function F3e(){return typeof document<"u"&&document.documentElement.dataset.motion==="instant"}function B3e(e){const[t,n]=m.useState(e),[a,s]=m.useState(!1);return t!==e&&(n(e),s(!e&&!F3e())),m.useEffect(()=>{if(!a)return;const o=window.setTimeout(()=>s(!1),D3e());return()=>window.clearTimeout(o)},[a]),e?"fold":a&&t===e?"unfold":void 0}const SH="data-view-switch",Q7="data-pin",U3e=["--board-l","--board-t","--board-w","--board-h"];function W3e(e,t){if(!e||!t)return;const n=t.getBoundingClientRect();n.width>0&&n.height>0&&(e.style.setProperty("--board-l",`${n.left}px`),e.style.setProperty("--board-t",`${n.top}px`),e.style.setProperty("--board-w",`${n.width}px`),e.style.setProperty("--board-h",`${n.height}px`),e.setAttribute(Q7,""))}function TH(e){if(e){e.removeAttribute(Q7);for(const t of U3e)e.style.removeProperty(t)}}function H3e(e=document){return typeof e.startViewTransition=="function"&&!e.hidden}let NH=0,dp;function G3e(e,t,n=document){const a=n.documentElement,s=++NH;dp!==void 0&&(clearTimeout(dp),dp=void 0),a.setAttribute(SH,"");const o=()=>{s===NH&&a.removeAttribute(SH)};if(e==="pointer"&&H3e(n)){n.startViewTransition.call(n,()=>{$t.flushSync(t)}).finished.then(o,o);return}$t.flushSync(t),dp=setTimeout(()=>{dp=void 0,o()},60)}let up=null;function AH(e=document){return e.documentElement.dataset.motion==="instant"}function V3e(e=document){if(up)return up;const t=e.documentElement,n=()=>{t.dataset.motion="instant"},a=()=>{delete t.dataset.motion};return e.addEventListener("keydown",n,{capture:!0,passive:!0}),e.addEventListener("pointerdown",a,{capture:!0,passive:!0}),up=()=>{e.removeEventListener("keydown",n,{capture:!0}),e.removeEventListener("pointerdown",a,{capture:!0}),delete t.dataset.motion,up=null},up}const K3e="(max-width: 1319px)",$3e="(max-width: 1099px)",J3e="(max-width: 1023px)",Y3e="(prefers-reduced-motion: reduce)",Z3e=m.lazy(()=>Xs(()=>import("./AccountBridge-CmB2ClCh.js"),__vite__mapDeps([8,5])));function X3e(){return i.jsx(YE,{children:i.jsx(YBe,{children:i.jsx(Q3e,{})})})}function Q3e(){var yd,xd,Cd;const e=se(),t=Sg(),n=m.useState(IR)[0],a=m.useRef(n),[,s]=m.useState(0),o=m.useCallback(()=>s(Ne=>Ne+1),[]),r=tWe(),{sessionListOpen:c,accountsPanelOpen:l,panel:u,toggleSessionList:h,toggleAccountsPanel:p,openAccountsPanel:f,closeSessionList:b,closeSessionListToCanvas:v,closeAccountsPanel:w,leavePhone:T,holdAccounts:y}=r,x=$Ue(),C=mAe(),A=fAe(x),E=pAe(C.chosen,x,A),{detailOpen:R,setDetailOpen:z,usagePanelOpen:I,setUsagePanelOpen:_,machinePanelOpen:D,setMachinePanelOpen:L,hold:P}=fWe(eH(u,x,E),_k()==="workspace"),O=oWe({left:u!==null,right:I||D,board:_k()!=="workspace"}),{fold:j,foldRef:M,raise:F}=O,U=m.useCallback(()=>M.current.right,[M]),H=m.useCallback(()=>F("right"),[F]),$=m.useMemo(()=>oj(z,U,H),[z,U,H]),Y=Pt(u),W=m.useMemo(()=>nH(h,{folded:()=>M.current.left,holds:()=>Y.current==="session-list",raise:()=>F("left")}),[h,M,Y,F]),G=m.useMemo(()=>nH(p,{folded:()=>M.current.left,holds:()=>Y.current==="accounts",raise:()=>F("left")}),[p,M,Y,F]),Q=c&&!j.left,J=l&&!j.left,{selectedIds:X,primarySelectedId:te,selectAgent:K,clearSelection:V,pruneSelectionToBoard:ee}=T0e(a,$),de=m.useCallback(Ne=>K(Ne,!1,!1),[K]),he=Vd(J,200),me=Vd(Q,200),be=mL(Q,me),ie=Ws(Y3e),ne=Ws(Bl),ke=m.useMemo(()=>ne?ie?LMe():Gp():zn(ie?"--dur-xfade":"--dur-fast"),[ie,ne]),Se=Vd(I&&!j.right,ke),ve=Vd(D&&!j.right,ke),xe=m.useRef(null),Ee=YWe(xe),{activateSoundRef:Ge,soundOnRef:Qe}=Ee,Je=DWe(xe),{setTonePrefs:He,tonePrefsRef:_e,previewTone:le}=Je,Re=IWe({chimesRef:xe,setTonePrefs:He,tonePrefsRef:_e,previewTone:le}),{customSelectionsRef:ge,fallbackCustomRef:Pe}=Re,Fe=ZWe(),{openSettings:Ve}=Fe;MUe({chimesRef:xe,soundOnRef:Qe,tonePrefsRef:_e,customSelectionsRef:ge,fallbackCustomRef:Pe});const ot=QBe(a),{pauseGate:ce,paused:Ce,togglePause:Ke}=ot,Oe=m.useRef(()=>{}),{live:at,tabCapped:ut,everConnected:vt,liveSince:qe,lastNewsAt:dt}=m0e({stateRef:a,rerender:o,pauseGate:ce,chimesRef:xe,desktopUpdateRef:Oe}),et=KWe(at),{version:Ie,notice:ct,noticeOpen:Nt,loadVersion:Le}=et,Ht=DUe(at),{readyAppUpdate:Mt,onDesktopUpdateEvent:yn}=Ht;Oe.current=yn,HWe();const mn=$We({version:Ie,readyAppUpdate:Mt}),{tourOpen:xn,openTour:Gt,releaseNotes:tt}=mn,{workspace:rt,providers:Ye,providersRef:Vt}=sUe(at),Rt=nUe(Ye,l),_n=Rt.shown,Xa=Ne=>{if(Rt.remember(Ne),j.left){F("left"),l||p();return}(!l||_n===Ne)&&p()},fn=eH(ne?c?"session-list":null:u==="accounts"&&!(Ye.claude||Ye.codex)?null:u,x,ne?x:E),cn=j.left?0:fn,ka=XUe(cn),Cn=mL(J,he)&&(Ye.claude||Ye.codex),[qa,ia]=m.useState(!1),_a=Rt.remember,La=m.useCallback(()=>{F("left"),f()},[F,f]),Qa=m.useCallback(()=>{_a(Ye.claude?"claude":"codex"),La()},[La,Ye.claude,_a]),Pa=m.useCallback(()=>{La(),ia(!0)},[La]),[oa,Xt]=m.useState(null),[es,In]=m.useState([]),Oa=m.useMemo(()=>[...oa??[],...es],[oa,es]);m.useEffect(()=>{l||ia(!1)},[l]);const Dn=m.useCallback(()=>ia(!1),[]),Ma=qWe(Ie),va=xUe({version:Ie,loadVersion:Le}),{upgradeFailure:wa}=va,nn=RWe({stateRef:a,tourOpen:xn,releaseNotes:tt}),ts=MWe({modalOpenRef:nn.modalOpenRef}),{openTool:un,setSummaryFor:Ia,setContextFor:_i,openContext:Fn,setKeyHelpOpen:ra,setUsageHistoryOpen:ns,setBrowserWatchOpen:ya,keyHelpOpenRef:fe,modalOpenRef:re}=nn,je=JWe(),We=SUe(),{watchOn:st,watchUnseen:Ct}=We,Et=Xg(),[xa,Bn]=m.useState(null),[zt,ks]=m.useState(!1),Li=m.useCallback(()=>ks(!1),[]),ni=Ne=>{rOe(Ne),Ve("integrations")},Yl=Ne=>{Ne&&rW(Ne),Ve("integrations")},fc=m.useCallback(()=>Bn(null),[]),ae=Az().filter(Ne=>uE(Et,Ne.kind)),ye=Pt(Ne=>{const Lt=ae.find(Na=>Na.kind===Ne);Lt&&Bn(Lt.kind)}),Ue=m.useCallback(Ne=>{rW(Ne),Ve("integrations")},[Ve]),lt=ae.length>0;m.useEffect(()=>{lt&&VPe()},[lt]);const nt=WUe(),[bt,qt]=m.useState(0),{presentCats:sn,hiddenCats:Bt,toggleCat:Sn}=PUe(a),Tn=m.useRef(null),[bc,aw]=m.useState(0),Yn=W0e({stateRef:a,rerender:o,pruneSelectionToBoard:ee,setContextFor:_i,setSummaryFor:Ia});Dde({stateRef:a,now:Yn,enabled:Ye.claude});const Zl=cUe(Ye.claude||Ye.codex),nm=wve(Cn&&Ye.claude),Ju=vUe(Zl,Yn),pr=GUe({enabled:Ye.claude,lanStatus:nt.lanStatus,now:Yn}),Pi=UUe({now:Yn,stateRef:a,version:Ie,notice:ct,noticeOpen:Nt,upgradeFailure:wa,paused:ot.paused}),{askRestart:kc,loadAutoRestartPrefs:Xl}=Pi,Oi=LUe(),{setTheme:Yu,palette:Zu}=Oi,vc=IUe(),ca=dqe(),{applyViewport:am,moveCamera:Mi,fitLeft:Xu,cameraEpochRef:Ql,lastFitTimeRef:Qu}=ca,ai=zqe(ca),{pinnedRef:So,positionsRef:wc,lastLayoutSigRef:Da,handleRelayout:To,rearrangeUndo:eh}=ai,gr=m.useRef(null),sm=m.useRef(()=>{}),No=qe!==null,ed=m.useRef(0),mr=m.useCallback(()=>{ed.current=Date.now()},[]),{canvasRef:Zn,canvasSize:im,paneSizeRef:sw}=w_e(ka),om=QWe(ca.fitAll),{autoFitDisabledRef:rm,disableAutoFit:fr}=om,th=m.useRef(!1),{measuredRef:br,measuredVersionRef:iw,sizeVersion:ow,domSizeVersion:rw}=y_e(th,a),{removedNodes:td,removedAgentIds:la,removeNode:cw,removeSelectedNode:nh,removalNotice:cm,hideSessions:ah,bringBack:vs,bringBackAll:lw,forgetRemovals:dw}=Qqe({stateRef:a,pinnedRef:So,positionsRef:wc,returningRef:ai.returningRef,canvasRef:Zn,clearSelection:V,primarySelectedId:te}),nd=Vqe({stateRef:a,now:Yn,removedAgentIds:la,sizeVersion:ow,domSizeVersion:rw}),{saveSoon:lm}=qqe(nd,ai),{fitSoon:dm}=Xqe({layoutSig:nd,rf:t,stateRef:a,measuredRef:br,pinnedRef:So,positionsRef:wc,paneSizeRef:sw,lastInteractRef:ed,autoFitDisabledRef:rm,lastFitTimeRef:Qu,fitLeft:Xu}),sh=x_e(),{bubbling:uw,endBubble:hw,onBubble:pw}=jAe(),[ih,oh]=m.useState(!1),kr=SAe(),{beginTrashDrag:gw,trackTrashDrag:um,endTrashDrag:hm}=kr,Ao=LAe({stateRef:a,measuredRef:br,measuredVersionRef:iw,canvasRef:Zn}),{lodRef:ad,applyZoom:pm}=Ao,{releaseFitAll:jo}=ca,mw=m.useCallback(()=>{fr(),jo()},[fr,jo]),gm=m.useRef(null),mm=m_e({applyViewport:am,takeOver:ca.takeOver,lastFitTimeRef:Qu,cameraEpochRef:Ql,disableAutoFit:mw,markInteract:mr,canvasRef:Zn,applyZoom:pm,zoomFocusRef:gm}),ws=te?a.current.agents.get(te):null,[fm,Ii]=m.useState(!1),Di=R&&(ws!=null||fm),da=Di&&!j.right,yc=m.useRef(ws);ws&&(yc.current=ws);const ua=R_e({sessionListShown:be,usageShown:no(Se),machineShown:no(ve),accountsShown:Cn&&Ye.claude,codexShown:Cn&&!Ye.claude,detailShown:da,primarySelectedId:te,canvasRef:Zn}),Fi=Xze(!ne&&Di,{usage:I,machine:D}),{railInsetRef:xc,availableWidth:sd,availableHeight:rh}=Qze({canvasRef:Zn,canvasSize:im,machinePhase:ve,usagePhase:Se,usagePanelOpen:I,detailShown:da,folds:Fi.folds}),bm=m.useCallback(()=>{dm(),lm()},[dm,lm]),Bi=Kqe({stateRef:a,now:Yn,availableWidth:sd,availableHeight:rh,layout:ai,measuredRef:br,onBubble:pw,settled:sh,dragging:ih,layoutSig:nd,selectedIds:X,openContext:Fn,historyReplayed:No,removedNodes:td,removedAgentIds:la,dragTick:bt,dragPatchRef:Tn,dragMoveTick:bc,onMoved:bm,packed:Ao.lod!=="detail"}),{nodes:id,edges:Hz}=Bi;ca.boardRef.current=id,f_e({packed:Ao.lod!=="detail",nodes:id,squeeze:Bi.squeeze,focusRef:gm,canvasRef:Zn,getViewport:ca.currentViewport,panBy:ca.panBy});const fw=AAe(Bi.visibleAgentIds),Ui=Pt(te);_qe({settled:sh,dragging:ih,availableWidth:sd,availableHeight:rh,layout:ai,camera:ca,lastFocusRef:gr,focusAgentRef:sm,autoFitDisabledRef:rm});const km=zWe({stateRef:a,pinnedRef:So,measuredRef:br,positionsRef:wc,lastLayoutSigRef:Da,forgetRemovals:dw,clearSelection:V,rerender:o,modalOpenRef:re}),{requestClear:Fa}=km,Cc=z_e({nodes:id,shown:Bi.shown,squeeze:Bi.squeeze,stateRef:a,pinnedRef:So,positionsRef:wc,draggingRef:th,dragPatchRef:Tn,setDragging:oh,setDragMoveTick:aw,setDragTick:qt,endBubble:hw,markInteract:mr,disableAutoFit:fr,beginTrashDrag:gw,trackTrashDrag:um,endTrashDrag:hm,removeNode:cw}),ch=ca.fitAll,od=Pt(id),vm=Pt(Bi.shown),[wm,lh]=m.useState(null),qs=m.useCallback(Ne=>lh(Lt=>({id:Ne,nonce:((Lt==null?void 0:Lt.nonce)??0)+1})),[]),{focusAgent:dh,revealAgent:vr,stepAgent:Eo,focusSession:as}=uqe({canvasRef:Zn,stateRef:a,measuredRef:br,nodesRef:od,shownRef:vm,lodRef:ad,railInsetRef:xc,moveCamera:Mi,currentViewport:ca.currentViewport,disableAutoFit:fr,lastFocusRef:gr,focusAgentRef:sm,selectAgent:K,primarySelectedIdRef:Ui,onLand:qs}),Sc=M2e(),it=v3e({stateRef:a,canvasRef:Zn,detailOpen:R,detailShown:Di,setDetailOpen:$,primarySelectedIdRef:Ui,selectAgent:K,view:Sc.stored,phone:ne,clearSelection:V,ready:No}),_t=it.workspace,Ro=B3e(_t&&it.expanded),rd=!Ws($3e);nWe({active:_t&&it.enabled,wide:rd,column:r});const Ba=!Ws(K3e),Un=yLe({workspace:_t&&it.enabled,wide:rd,column:Ba}),uh=Un&&!ie&&!AH()?zn("--dur-stage-out"):0,ym=Vd(da,ne?ke:uh),Tc=(ne||uh>0)&&wf(da,ym),cd=m.useRef(!1);da&&(cd.current=ws==null);const xm=!(_t&&Ba)&&(da?ws==null:Tc&&cd.current),hh=da?ws:Tc&&!cd.current?yc.current:null;m.useLayoutEffect(()=>{Un&&P.detail()},[Un]);const[si,zo]=m.useState(!1),ld=m.useRef(R);m.useEffect(()=>{R&&!ld.current&&zo(!1),ld.current=R},[R]),O3e({active:_t,detailOpen:R,fold:()=>zo(!0),hold:P.detail,restore:z});const Cm=_t&&Ba&&it.shell.phase!=="closed"?ma(it.shell.target):null;m.useLayoutEffect(()=>{Cm&&zo(!1)},[Cm]),m.useLayoutEffect(()=>{Fre(_t)},[_t]);const Nc=m.useCallback(()=>{zo(!0),$(!1),requestAnimationFrame(()=>{JU(document)})},[$]),qo=m.useRef(!1);m.useEffect(()=>{const Ne=qo.current;qo.current=Un&&da,!(!Ne||qo.current||!Un)&&requestAnimationFrame(()=>{const Lt=document.activeElement;(!Lt||Lt===document.body||Lt.closest(".detail"))&&JU(document)})},[Un,da]);const bw=_t&&(Ro!==void 0||it.expanded),Ac=xLe({workspace:_t,column:Ba,folded:si,shown:da,zoomed:bw}),jc=m.useCallback(()=>{Ii(!0),$(!0)},[$]),hn=m.useCallback(()=>{V(),Ii(!1)},[V]);m.useEffect(()=>{(!R||te||_t&&Ba)&&Ii(!1)},[R,te,_t,Ba]);const dd=m.useCallback(()=>{zo(!1),Ui.current?$(!0):!nE(a.current,as,Eo)&&Un&&jc(),requestAnimationFrame(()=>{var Ne;(Ne=document.querySelector('.detail .insp-tab[aria-selected="true"]'))==null||Ne.focus()})},[$,Ui,a,as,Eo,Un,jc]),Ec=m.useCallback(()=>{const Ne=CLe({workspace:_t,column:Ba,sheet:Un,open:Ac});Ne==="fold"?Nc():Ne==="show"?dd():Ui.current?$(Lt=>!Lt):Ac?Ii(!1):nE(a.current,as,Eo)||jc()},[_t,Ba,Un,Ac,Nc,dd,$,Ui,a,as,Eo,jc]),Rc=Pt(Ec),Sm=Pt(Un&&da?Nc:null),ph=Ws(J3e),Ln=ewe({workspace:_t&&!ne,open:{usage:I,machine:D},mounted:{usage:no(Se),machine:no(ve)},narrow:ph}),zc=Ne=>Fi.on?()=>Fi.fold(Ne):void 0,_o={usage:qU(Ln.dock.usage,Fi.folds.usage,()=>Fi.unfold("usage"),zc("usage")),machine:qU(Ln.dock.machine,Fi.folds.machine,()=>Fi.unfold("machine"),zc("machine"))},qc=m.useRef(!1);m.useLayoutEffect(()=>{if(!_t||Ba){qc.current=!1;return}Ln.on&&da?(qc.current=!0,P.detail()):!Ln.on&&qc.current&&(qc.current=!1,Ui.current&&$(!0))},[Ln.on,_t,Ba]);const ud=m.useRef(null);m.useEffect(()=>{_t||TH(ud.current)},[_t]);const{leaveWorkspace:Tm,openInPane:ys}=it,Lo=m.useCallback((Ne,Lt,Na)=>{G3e(Lt,()=>{Ne==="workspace"?(ii.current||W3e(ud.current,Zn.current),Na&&(ys(Na,{focusPane:!0}),qs(Na))):(TH(ud.current),Tm()),Sc.set(Ne)})},[Tm,ys,qs,Sc.set]),_c=Pt(Lo),ii=Pt(_t),gh=m.useCallback(()=>_c.current(ii.current?"board":"workspace","key"),[_c,ii]),mh=Pt({available:it.workspaceOffered,toggle:gh});lWe(a,[...X,it.enabled&&it.shell.phase!=="closed"?ma(it.shell.target):null],a.current.revision);const hd=rWe(a.current,[...X,it.enabled&&it.shell.phase!=="closed"?ma(it.shell.target):null]),kw=_t&&it.enabled&&it.shell.phase!=="closed"?YHe(it.split,it.shell.target,(yd=it.arrangement)==null?void 0:yd.order):void 0;c_e({stateRef:a,removedNodes:td,hideSessions:ah,ready:No,keepSessionId:te?((xd=a.current.agents.get(te))==null?void 0:xd.sessionId)??te:null,stageSessionId:it.enabled&&it.shell.phase!=="closed"?ma(it.shell.target):null});const Lc=yH(it,I,_),pd=yH(it,D,L),vw=m.useMemo(()=>oj(Lc.set,U,H),[Lc.set,U,H]),fh=m.useMemo(()=>oj(pd.set,U,H),[pd.set,U,H]),Ua={shown:Lc.shown&&!j.right,set:vw},Po={shown:pd.shown&&!j.right,set:fh},Oo=(Ne,Lt)=>Ne?no(Lt):Lt==="leaving",_s=!ne&&!_t&&(da||Oo(Ua.shown,Se)||Oo(Po.shown,ve));O.settle({left:fn>0,right:!ne&&(Di||Lc.shown||pd.shown),board:!_t});const oi=b_e({clearSelection:V,selectAgent:K,detailOpen:R,setDetailOpen:$,detailShown:da,focusAgent:dh,revealAgent:vr,draggingRef:th,lodRef:ad,stage:{onNodeClick:(Ne,Lt)=>it.workspaceOffered?(Lo("workspace","pointer",gp(a.current.agents,Ne)),!0):it.onNodeClick(Ne,Lt)}}),bh=hqe({nodesRef:od,stateRef:a,canvasRef:Zn,railInsetRef:xc}),ww=Pt(nh),kh=m.useRef(null),{followSession:Wi}=it,ri=m.useCallback(Ne=>{if(ii.current&&it.enabled){ys(Ne),qs(Ne);return}as(Ne)},[ii,it.enabled,ys,qs,as]),ci=m.useCallback(Ne=>{if(ii.current&&it.enabled){la.has(Ne)&&vs([Ne]),ys(Ne),qs(Ne);return}if(Wi(Ne)){qs(Ne),la.has(Ne)&&vs([Ne]);return}la.has(Ne)&&vs([Ne]),as(Ne)},[la,vs,as,Wi,qs,ii,it.enabled,ys]),wr=m.useCallback(Ne=>{la.has(Ne)&&vs([Ne]),ys(Ne,{focusPane:!0})},[la,vs,ys]),vh=m.useCallback(Ne=>{la.has(Ne)&&vs([Ne]),it.openBeside(Ne)},[la,vs,it.openBeside]),yr=C_e(),[Hi,on]=m.useState(!1),rn=m.useCallback(()=>on(!0),[]),Gi=m.useCallback(()=>on(!1),[]),Xn=m.useCallback(Ne=>{on(!1),Ne.run()},[]),Ca=m.useCallback(()=>f8(a.current,kh,ri),[a,ri]),Mo=()=>{var Sd;if(!it.enabled)return;const Ne=it.shell.phase!=="closed"?ma(it.shell.target):null,Lt=te?((Sd=a.current.agents.get(te))==null?void 0:Sd.sessionId)??null:null,Na=Gfe(a.current.agents.values(),Ne??Lt);return Na?{folder:Na,launch:it.launch}:void 0},xr=sa(),ha=m.useRef(W),md=m.useCallback(()=>ha.current(),[]);j_e({pointerFocusRef:yr,nodesRef:od,stateRef:a,primarySelectedIdRef:Ui,providersRef:Vt,soundOnRef:Qe,keyHelpOpenRef:fe,modalOpenRef:re,waitingCursorRef:kh,removeSelectedRef:ww,activateSoundRef:Ge,viewRef:mh,stageRef:it.keysRef,lodRef:ad,inspectorSheetFoldRef:Sm,inspectorDoorRef:Rc,clearSelection:hn,selectAgent:K,focusAgent:dh,stepAgent:Eo,focusSession:ri,requestClear:Fa,handleRelayout:To,undoRearrange:eh.undo,handleFit:ch,togglePause:Ke,toggleSessionList:md,toggleAccountsPanel:G,setDetailOpen:$,setUsageHistoryOpen:ns,setUsagePanelOpen:Ua.set,setMachinePanelOpen:Po.set,setBrowserWatchOpen:ya,setKeyHelpOpen:ra,setTheme:Yu,openSettings:Ve,openIntegrationRef:ye,openQuickOpen:rn});const Nm=a.current.agents.size,fd=Vee(a.current),xs=m.useMemo(()=>ku(a.current.agents.values()),[a.current,a.current.revision]),Am=m.useMemo(()=>fOe(a.current.agents.values()),[a.current,a.current.revision]);e_e({stateRef:a,waitingSessions:xs,removedAgentIds:la,removedNodes:td,bringBack:vs}),p_e({stateRef:a,waitingSessions:xs,live:at});const Ls=wWe({waitingSessions:xs,watchUnseen:Ct,incidents:Ju}),Cr=jWe({waitingSessions:xs,liveSince:qe,focusSession:ri,stateRef:a}),{loadNotifyPrefs:wh}=Cr,yh=C3e(it,xs,Zn),[jm,Vi]=m.useState({on:!1,vetoed:!1});GWe({loadAutoRestartPrefs:Xl,loadNotifyPrefs:wh,loadReportsPrefs:je.loadReportsPrefs,loadTerminalPrefs:it.loadTerminalPrefs,loadAccountPrefs:Ne=>Vi({on:Ne.accountOn===!0,vetoed:Ne.accountVetoed===!0})});const Sr={theme:Ne=>Yu(Ne),textSize:Ne=>Oi.setTextSize(Ne),density:Ne=>Oi.setDensity(Ne),"panels.sessionList":Ne=>{Ne?c||h():b()},"panels.accounts":Ne=>{Ne?f():w()},"panels.detail":Ne=>z(Ne===!0),"panels.usage":Ne=>_(Ne===!0),"panels.machine":Ne=>L(Ne===!0),singleKeyShortcuts:Ne=>O5(Ne===!0),hideFinishedAfter:Ne=>c8(Number(Ne)),character:Ne=>Oi.setCharacterEnabled(Ne===!0),sound:Ne=>Ee.setSound(Ne===!0)},[Io,Pc]=m.useState(!1),[bd,Sa]=m.useState(null),ss=m.useCallback(()=>Sa(null),[]),Do=m.useCallback(Ne=>{const Lt=a.current.agents.get(Ne);return Lt?bu(Lt)??"session":null},[]),li=m.useCallback(Ne=>{Sa(null),ci(Ne)},[ci]),Ps=m.useCallback(()=>Pc(!1),[]),[Fo,xh]=m.useState(null),Ch=m.useCallback(()=>xh(null),[]),Sh=GLe(T8()),Wa=m.useCallback(()=>nn.openFeedback({initialTab:"conversations"}),[nn.openFeedback]),Qt=FLe({providers:Ye,sessionListOpen:Q,toggleSessionList:W,accountsPanelOpen:J,toggleAccountsPanel:G,accountsPanelId:q7(_n),codexPanelOpen:J&&_n==="codex",toggleCodexPanel:()=>Xa("codex"),usagePanelOpen:Ua.shown,setUsagePanelOpen:Ua.set,machinePanelOpen:Po.shown,setMachinePanelOpen:Po.set,setUsageHistoryOpen:ns,watchOn:st,watchUnseen:Ct,setBrowserWatchOpen:ya,setTrafficRadarOpen:nn.setTrafficRadarOpen,openSettings:Ve,onFeedback:nn.openFeedback,setRadioOpen:Pc,openToolActivity:Sa,openCapacity:xh,toggles:ua.toggles,integrations:ae.map(Ne=>({provider:Ne,onPress:()=>Bn(Ne.kind)})),openExploreIntegrations:()=>ks(!0),openQuickOpen:rn,feedbackUnread:Sh,openFeedbackConversations:Wa,inspectorOpen:Ac,toggleInspector:Ec}),en=m.useRef(!1),Ta=m.useCallback(Ne=>{if(ne&&it.enabled){la.has(Ne)&&vs([Ne]),ys(Ne),qs(Ne),en.current=!0,v();return}ci(Ne)},[ci,ne,v,it.enabled,ys,qs,la,vs]),Em=m.useCallback(Ne=>{Ta(Ne),en.current=!1},[Ta]),Tr=it.enabled&&it.shell.phase!=="closed",kd=m.useRef(!1);m.useEffect(()=>{if(kd.current&&!Tr){const Ne=ne&&en.current;en.current=!1,Ne&&!c&&h()}kd.current=Tr},[ne,Tr]);const{openFromButton:vd}=it,Rm=m.useCallback(Ne=>{vd(Ne),ne&&c&&(en.current=!0,v())},[vd,ne,c,v]),Oc=m.useRef(l),{giveRightBack:Th}=it;m.useLayoutEffect(()=>{const Ne=MMe({phone:ne,accountsOpen:l,accountsWasOpen:Oc.current,paneOpen:Tr});Oc.current=l,Ne&&Th()},[ne,l,Tr,Th]);const Ki=()=>{(Ye.claude?ua.accounts:ua.codex)(),w()},Nh=it.enabled&&it.supported!==!1&&!it.chunkFailed,{newSessionFromBoard:zm}=it,Mc=m.useCallback(Ne=>{zm(Ne),ne&&c&&(en.current=!0,v())},[zm,ne,c,v]),Ic=Ne=>fd?!at&&ut?i.jsx(__e,{reservedRight:Ne}):i.jsx(L_e,{live:at,everConnected:vt,providers:Ye,workspace:rt,onTour:Gt,onNewSession:Nh?Mc:void 0,reservedRight:Ne}):null,Ah=ne&&be&&!(vt&&!at),di=VMe({phone:ne,open:{accounts:Cn&&l,usage:Ua.shown,machine:Po.shown,inspector:da},close:{accounts:Ki,usage:()=>{ua.usage(),Ua.set(!1)},machine:()=>{ua.machine(),Po.set(!1)},inspector:()=>{ua.detail(),$(!1)}},openers:{accounts:()=>{var Ne;return((Ne=Ye.claude?ua.toggles.accounts:ua.toggles.codex)==null?void 0:Ne.current)??null},usage:()=>ua.toggles.usage.current,machine:()=>ua.toggles.machine.current,inspector:()=>te?document.querySelector(`.session-list .sl-row[data-session="${CSS.escape(te)}"], .phone-board .pb-card[data-session="${CSS.escape(te)}"]`):null},modalOpenRef:re,onLeavePhone:T,hold:{accounts:y,usage:P.usage,machine:P.machine},home:()=>ua.toggles.sessionList.current}),$i=Ne=>Ne.id==="session-list"&&di.sheet!=null?{...Ne,open:!1,onPress:()=>mW({sheet:di.sheet,listOpen:c,closeSheet:di.closeSheet,toggleList:Ne.onPress})}:Ne;ha.current=()=>mW({sheet:di.sheet,listOpen:c,closeSheet:di.closeSheet,toggleList:W});const qm={...Qt,left:Qt.left.map($i),right:Qt.right.map(Ne=>Ne.map($i))},Ji=(Ne,Lt)=>ne?()=>di.closeSheet(Ne):Lt,Dc=Rt.both?i.jsx(ANe,{shown:_n,notices:Rt.notices,onPick:Rt.pick}):void 0,Bo=Ne=>Rt.bothMounted?Ne===_n?"shown":"hidden":void 0,wd=i.jsxs(i.Fragment,{children:[Cn&&(_n==="claude"||Rt.bothMounted)&&i.jsx(TNe,{leaving:wf(J,he),onReport:nn.openFeedback,onRoster:pr.observe,onClose:Ji("accounts",Ki),lanWanted:qa,onLanShown:Dn,onLanAccounts:Xt,codexLanAccounts:es,switcher:Dc,side:Bo("claude"),onNotice:Rt.noteClaude,planLabel:((Cd=nm.reading)==null?void 0:Cd.planLabel)??null}),Cn&&(_n==="codex"||Rt.bothMounted)&&i.jsx(iAe,{leaving:wf(J,he),onClose:Ji("accounts",Ki),switcher:Dc,side:Bo("codex"),onNotice:Rt.noteCodex,lanAccounts:Oa,lanReady:!Ye.claude||oa!=null,lanWanted:qa,onLanShown:Dn,onLanAccounts:In})]});return i.jsxs("div",{ref:ud,className:"app","data-view":_t?"workspace":void 0,"data-zoom":Ro,"data-side":Ln.on?"":void 0,"data-right-col":_s?"":void 0,style:Ln.on?{"--workspace-side-w":`${Ln.width}px`}:void 0,children:[i.jsxs(X3.Provider,{value:fd,children:[_t?i.jsx("a",{className:"skip-link",href:`#${X7}`,onClick:Ne=>{I3e()&&Ne.preventDefault()},children:e(M3e)}):i.jsx("a",{className:"skip-link",href:"#canvas",children:e("shell.skipToCanvas")}),i.jsxs("header",{className:"topbar",children:[i.jsx(Zpe,{}),i.jsxs(VOe,{versionCheck:et,welcome:mn,desktopUpdate:Ht,pause:ot,announcements:Ls,notify:Cr,waitingSessions:xs,waitingCursorRef:kh,focusSession:ri,live:at,now:Yn,incidents:Ju,counts:Am,asksSaid:it.enabled?yh.said:void 0,children:[!ne&&it.workspaceOffered&&i.jsx(P3e,{view:_t?"workspace":"board",onChange:Lo}),!ne&&i.jsx("div",{className:"actions",children:i.jsx(VP,{items:[Qt.search]})})]}),i.jsx("div",{className:"tb-corner",children:i.jsx(VP,{items:[Qt.corner]})})]}),ne?i.jsx(Sme,{items:[...Qt.left,...Qt.right[0]].map($i),more:[Qt.search,...BLe(it.enabled?Rm:void 0),...Qt.capacity,...Qt.right.slice(1).flat(),...Qt.integrations,...Qt.explore,...Qt.utilities.filter(Ne=>Ne!==Qt.corner)],offline:vt&&!at}):i.jsx(HP,{side:"left",label:e("board.rail.tools"),groups:Qt.leftStripe,foot:Qt.leftFoot}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:cm?e("shell.board.removed",{label:cm.label}):""}),it.enabled&&i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:it.said}),i.jsx(AMe,{restart:Pi,versionCheck:et,upgrade:va,oldNameNotice:Ma,rating:ts,onFeedback:nn.openFeedback,everConnected:vt,live:at,paused:Ce,phone:ne,lastNewsAt:dt,cardInList:be}),ne&&wd,(be||Cn)&&i.jsxs(oAe,{width:cn,listWidth:ne?void 0:E,edge:ne?void 0:i.jsx(bAe,{width:E,cap:A,onWidth:C.choose,onReset:C.reset}),children:[!ne&&wd,be&&i.jsx(Jge,{historyReady:No,leaving:wf(Q,me),state:a.current,now:Yn,selectedIds:X,onSelect:Ta,onClose:()=>{ua.sessionList(),b()},removedIds:la,onBringBackAll:lw,landed:wm,watching:hd,openPanes:kw,onOpenKeys:_t?wr:void 0,onOpenBeside:_t&&it.enabled?vh:void 0,onNewSession:_t&&it.enabled?it.newSessionFrom:void 0,offline:ne&&vt&&!at&&!Pi.restarting?i.jsx($8,{lastNewsAt:dt}):void 0,emptyNotice:Ah?Ic(0):void 0})]}),_t&&i.jsx("div",{className:"ws-cell","aria-hidden":"true"}),i.jsxs(eMe,{canvasRef:Zn,bubbling:uw,dragging:ih,trash:kr,zoom:Ao,viewport:mm,stateRef:a,peek:bh,stagePhase:it.enabled&&it.shell.phase!=="closed"?it.shell.phase:void 0,joins:No&&sh,closing:fw,children:[!Ah&&Ic(ne?0:xc.current),ne?i.jsxs(i.Fragment,{children:[i.jsx(JOe,{state:a.current,now:Yn,watching:hd,removedIds:la,selectedIds:X,onOpen:Em}),i.jsx(eG,{fm:vc,character:Oi.character,characterEnabled:!1,open:Io,onClose:Ps})]}):i.jsx(Ype,{graph:Bi,layout:ai,viewport:mm,clicks:oi,drag:Cc,appearance:Oi,fm:vc,radioOpen:Io,onRadioClose:Ps,autoFit:om,pause:ot,stateRef:a,measuredRef:br,hiddenCats:Bt,now:Yn,openTool:un,focusAgent:dh,requestClear:Fa,setKeyHelpOpen:ra,zoomBy:ca.zoomBy,zoomReset:ca.zoomReset,onTerminal:it.enabled?it.openFromButton:void 0,notesDrawn:Ao.lod==="detail",presentCats:sn,toggleCat:Sn}),i.jsx(j3e,{stage:it})]}),i.jsx(E3e,{stage:it,stateRef:a,canvasRef:Zn,now:Yn,palette:Zu,asks:yh,waitingSessions:xs,onBoard:()=>Lo("board",AH()?"key":"pointer")}),i.jsx(Ft,{when:bd,children:Ne=>i.jsx(uke,{view:Ne,onClose:ss,sessionLabel:Do,onOpenSession:li})}),i.jsx(Ft,{when:Fo,children:Ne=>i.jsx(FNe,{view:Ne,onClose:Ch})}),i.jsx(Ft,{when:xa,children:Ne=>i.jsx(JPe,{kind:Ne,connections:Qo(Et,Ne)?Ak(Et,Ne):[],onClose:fc,onReconnect:Ue})}),i.jsx(Ft,{when:zt,children:()=>i.jsx(pOe,{integrations:Et,onClose:Li,onOpen:Bn,onConnect:ni,onManage:Yl})}),Hi&&i.jsx(hme,{onClose:Gi,onRun:Xn,items:Vfe({rails:qm,sessions:uv(a.current,Yn),openSession:Ta,settings:$G(Ye.claude,Ez(Et),Qg(Et)),openSettings:Ve,singleKeys:xr,fit:ch,rearrange:To,phone:ne,paused:Ce,togglePause:Ke,clear:fd?void 0:()=>Fa("button"),nextWaiting:ku(a.current.agents.values()).length>0?Ca:void 0,start:Mo(),keyHelp:()=>ra(!0),tour:Gt,theme:Oi.theme,setTheme:Yu})}),!ne&&i.jsx(HP,{side:"right",label:e("shell.rail.right"),groups:Qt.rightStripe}),i.jsxs("div",{className:"right-col",children:[i.jsxs(twe,{on:Ln.on,split:Ln.split,width:Ln.width,share:Ln.share,onWidth:Ln.setWidth,onShare:Ln.setShare,children:[no(Se)&&i.jsx(awe,{state:a.current,now:Yn,providers:Ye,incidents:Ju,liveSince:qe,leaving:Se==="leaving",dock:_o.usage,onClose:Ji("usage",()=>{ua.usage(),_(!1)})}),no(ve)&&i.jsx(Uwe,{usageOpen:I,leaving:ve==="leaving",dock:_o.machine,onClose:Ji("machine",()=>{ua.machine(),L(!1)})})]}),_t&&Ba&&!si&&!(R&&ws)?ws?i.jsx($U,{selected:ws,now:Yn,openTool:un,setSummaryFor:Ia,stateRef:a,removeSelectedNode:nh,onSelectAgent:de,onOpenSession:it.enabled?wr:void 0,stageSession:it.enabled&&ac(it.shell.phase)?ma(it.shell.target):null,workspace:!0,onClose:Nc}):i.jsx(KU,{}):null,hh?i.jsx($U,{workspace:_t,leaving:Tc,sheet:Un,selected:hh,now:Yn,openTool:un,setSummaryFor:Ia,stateRef:a,removeSelectedNode:nh,onSelectAgent:de,onOpenSession:it.enabled?wr:void 0,stageSession:it.enabled&&ac(it.shell.phase)?ma(it.shell.target):null,onClose:_t&&(Ba||Un)?Nc:Ji("inspector",()=>{ua.detail(),$(!1)})}):xm?i.jsx(KU,{leaving:Tc,sheet:Un}):null]}),ne&&i.jsx("div",{className:"phone-scrim","data-open":di.sheet?"":void 0,"aria-hidden":"true",onClick:()=>di.closeSheet()}),jm.on&&i.jsx(m.Suspense,{fallback:null,children:i.jsx(Z3e,{appliers:Sr})}),!ne&&i.jsx(ABe,{stageOpen:it.enabled&&ac(it.shell.phase),zoomedOut:Ao.lod!=="detail",viewChord:it.workspaceOffered?_t?"board":"workspace":null,waiting:xs.length>0,version:(Ie==null?void 0:Ie.running)??null,onVersion:mn.openReleaseNotes,setKeyHelpOpen:ra})]}),i.jsx(kBe,{dialogs:nn,welcome:mn,desktopUpdate:Ht,versionCheck:et,restart:Pi,upgrade:va,lanPairs:nt,attention:pr,clearFlow:km,watchBadge:We,announcements:Ls,appearance:Oi,providers:Ye,stateRef:a,agentCount:Nm,menus:Fe,sound:Ee,tones:Je,customTones:Re,notify:Cr,terminal:{on:it.enabled,supported:it.supported,windows:it.windows,phone:ne,failed:it.chunkFailed,toggle:it.toggleTerminal},panelDoors:{accounts:Qa,localNetwork:Pa},account:jm})]})}function jH(){try{fetch("/api/ui-language",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:Me()})}).catch(()=>null)}catch{}}function e4e(){jH();try{return b4(jH)}catch{return()=>{}}}try{rne(window.localStorage)}catch{}Ore();try{ine(window.localStorage)}catch{}try{lne(window.localStorage)}catch{}m4();e4e();const t4e=UJ.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);V3e();t4e.render(i.jsx(X3e,{}));export{p4e as $,Rs as A,Ze as B,A4e as C,Fu as D,dR as E,i5 as F,Zt as G,hR as H,Ks as I,tn as J,Ys as K,na as L,q4e as M,z4e as N,N4e as O,T4e as P,dn as Q,v6 as R,Ep as S,Gb as T,_4e as U,ope as V,Fg as W,M4e as X,M1 as Y,Au as Z,Oue as _,gt as a,Rce as a$,u4e as a0,h4e as a1,lv as a2,ule as a3,WFe as a4,TUe as a5,d4e as a6,rpe as a7,C1 as a8,Ut as a9,yi as aA,Jk as aB,ic as aC,$k as aD,f5 as aE,xo as aF,Cu as aG,iv as aH,D4 as aI,Ape as aJ,aG as aK,Gs as aL,dc as aM,zs as aN,js as aO,B4e as aP,Pt as aQ,I0e as aR,j0e as aS,x4e as aT,D0e as aU,Xs as aV,v4e as aW,k4e as aX,Tce as aY,wk as aZ,y4e as a_,f0 as aa,hO as ab,b0 as ac,f4e as ad,sc as ae,Yt as af,so as ag,b4e as ah,l4e as ai,hg as aj,fa as ak,tfe as al,us as am,mDe as an,ck as ao,$n as ap,Za as aq,rv as ar,j6 as as,ze as at,zl as au,oc as av,ibe as aw,Wt as ax,bs as ay,Wl as az,Ja as b,gn as b$,Py as b0,zce as b1,Oge as b2,kG as b3,qge as b4,zle as b5,G4 as b6,X2e as b7,P4e as b8,O4e as b9,zn as bA,aa as bB,kg as bC,fg as bD,m4e as bE,J7 as bF,U4e as bG,W4e as bH,g4e as bI,_ge as bJ,s0 as bK,Sz as bL,Hj as bM,a4e as bN,a4 as bO,c4e as bP,g5 as bQ,gp as bR,E1 as bS,fG as bT,h5 as bU,S1 as bV,El as bW,m5 as bX,du as bY,sv as bZ,r4e as b_,L4e as ba,H2e as bb,ab as bc,Xke as bd,hle as be,THe as bf,sa as bg,lu as bh,lr as bi,_0e as bj,F4e as bk,pHe as bl,D4e as bm,ole as bn,A5 as bo,q0e as bp,C4e as bq,w4e as br,bG as bs,I4e as bt,X7 as bu,Ft as bv,zUe as bw,Sg as bx,qn as by,ma as bz,Ya as c,Ot as c0,xPe as c1,A8 as c2,CPe as c3,i4e as c4,o4e as c5,s4e as c6,ene as c7,PAe as c8,OAe as c9,sne as ca,io as cb,O1 as cc,Vp as cd,Ws as d,E4e as e,P8 as f,Me as g,U4 as h,XPe as i,i as j,gs as k,$t as l,Rn as m,R4e as n,rr as o,S4e as p,j4e as q,m as r,$a as s,S as t,se as u,ZPe as v,yt as w,Yc as x,Qs as y,Es as z};
|