ccdeck 4.0.3 → 4.0.4
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-Cx7no9kK.js +1 -0
- package/dist/web/assets/{AccountSection-C0_ISsSw.js → AccountSection-HmlI65gN.js} +1 -1
- package/dist/web/assets/{BrowserWatchModal-C4G5G12x.js → BrowserWatchModal-DwY9hX-u.js} +1 -1
- package/dist/web/assets/{FeedbackConversations-Bqqn0VaM.js → FeedbackConversations-6S1QZR6S.js} +1 -1
- package/dist/web/assets/{IntegrationModal-CKgtTF3f.js → IntegrationModal-a8CAd22m.js} +1 -1
- package/dist/web/assets/{IntegrationSkeleton-WE6DOfez.js → IntegrationSkeleton-C2RiqqMA.js} +1 -1
- package/dist/web/assets/{RadioPanel-j_p9qx4L.js → RadioPanel-CyJsFSkf.js} +1 -1
- package/dist/web/assets/StageShell-DXcdcjPI.js +4 -0
- package/dist/web/assets/{TrafficRadar-CTGz345C.js → TrafficRadar-CEbp0Yi7.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-C2IDurbk.js → UsageHistoryModal-i16x6suY.js} +1 -1
- package/dist/web/assets/{app-82JtqhPe.css → app-BW8ALk8H.css} +1 -1
- package/dist/web/assets/{app-CdRq5GPP.js → app-C0usT8Zy.js} +95 -93
- package/dist/web/assets/{index-pIus964m.js → index-BQWffZlx.js} +1 -1
- package/dist/web/assets/{inspector-status-pane-BY6DHEeo.js → inspector-status-pane-DD3QOXE6.js} +1 -1
- package/dist/web/assets/{screens-BMLZR8WS.js → screens-DAn5OlXe.js} +1 -1
- package/dist/web/assets/stage-board-kUkV8N-4.js +2 -0
- package/dist/web/assets/{use-account-t_qL6ab-.js → use-account-x7fuCA6S.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/release-notes.json +23 -0
- package/src/server/claude-dir.mjs +93 -6
- package/src/server/claude-install.mjs +315 -0
- package/src/server/claude-reset-credits.mjs +77 -11
- package/src/server/cswap-admin.mjs +73 -4
- package/src/server/index.mjs +10 -0
- package/src/server/pro-engine-client.mjs +7 -3
- package/src/server/request-gates.mjs +3 -0
- package/dist/web/assets/AccountBridge-CmB2ClCh.js +0 -1
- package/dist/web/assets/StageShell-Bl0ddeiL.js +0 -4
- package/dist/web/assets/stage-board-6RJd7VXM.js +0 -2
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xterm-sheet-6GBZ9nXN.css","assets/screens-BMLZR8WS.js","assets/app-CdRq5GPP.js","assets/app-82JtqhPe.css","assets/IntegrationSkeleton-WE6DOfez.js","assets/stage-board-6RJd7VXM.js","assets/screens-DUniTTbC.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{aw as Bs,c as Kt,r as f,ax as an,j as s,u as de,ay as zs,az as Hs,aA as at,aB as Qn,aC as es,aD as $s,aE as Ks,aF as Us,aG as Gs,aH as ts,aI as Ws,aJ as qs,aK as ns,t as I,aL as Vs,B as Ce,A as Ut,aM as on,aN as kt,aO as Ge,aP as Et,aQ as Je,aR as ss,aS as Ys,aT as rs,aU as Xs,aV as Ze,y as Gt,aW as as,aX as os,aY as Ft,aZ as ln,a_ as Js,a$ as Zs,b0 as Qs,b1 as er,b2 as tr,b3 as nr,b4 as sr,b5 as rr,b6 as ar,b7 as or,b8 as ir,b9 as lr,ba as cr,bb as dr,bc as _e,K as Tt,a as ur,bd as fr,be as cn,bf as bt,bg as hr,bh as Ie,an as dn,bi as mr,bj as gr,l as is,bk as pr,bl as br,bm as wr,G as yr,bn as xr,J as kr,Q as vr,aq as Sr,bo as jr,bp as Nr,bq as Er,br as Tr,bs as Cr,bt as Ar,bu as Rr,bv as _r,bw as Lr,bx as Mr,by as Or,bz as ls,bA as Ir,bB as un,bC as Fr,D as Pr,bD as Dr,bE as fn,bF as Br,bG as zr,bH as Hr,bI as hn,bJ as $r,bK as Kr}from"./app-CdRq5GPP.js";import{n as Ur,a as Gr,s as Wr,b as qr,T as Vr,F as Yr,R as Xr,r as Jr,c as Zr,d as Qr,e as ea,f as Wt,g as vt,i as St,h as rt,j as ta,k as na,l as qt,m as sa,o as mn,p as ra,q as aa,t as oa,L as ia,P as la,u as gn,v as ca,w as da,x as ua,y as fa,z as ha,A as ma,B as ga,C as pn,D as pa,E as ba,G as wa,H as ya,I as xa}from"./stage-board-6RJd7VXM.js";const ka=[.32,.72,0,1],cs=280,ds=200,va=60,us=16,Sa=34,ja=250,Na=.45,fs=.5,Vt=Bs(...ka);function Ea(e){if(!(e>0))return 0;if(e>=1)return 1;let t=0,n=1;for(let r=0;r<24;r++){const a=(t+n)/2;Vt(a)<e?t=a:n=a}return(t+n)/2}function ke(e,t,n){return n<=t?e>=n?1:0:Math.min(1,Math.max(0,(e-t)/(n-t)))}const lt=(e,t,n)=>e+(t-e)*n,ot=e=>Math.round(e*100)/100,bn=e=>Math.round(e*1e4)/1e4;function Ta({board:e,nav:t,direction:n,reduced:r=Kt(),limit:a=va}){const o=[...t].map(([l,d])=>({id:l,board:e.get(l)??null,nav:d}));return r?{mode:"instant",direction:n,duration:0,tiles:o}:{mode:o.length>a?"fade":"flip",direction:n,duration:n==="open"?cs:ds,tiles:o}}function Ca(e,t){const n=e.duration>0?Math.min(1,Math.max(0,t/e.duration)):1,r=Vt(n),a=e.direction==="open"?r:1-r,o=n>=1,l=new Map;if(e.mode==="fade")return{t,eased:r,fold:a,done:o,board:1-a,nav:a,tiles:l};const d=ke(a,Na,1);for(const{id:c,board:i,nav:u}of e.tiles){if(!i||a>=1){l.set(c,{rim:"none",body:"none",rimOpacity:i?1:d,bodyOpacity:d});continue}const m=lt(i.x,u.x,a),k=lt(i.y,u.y,a),b=lt(i.w,u.w,a),j=lt(i.h,u.h,a),R=ot(m-u.x),h=ot(k-u.y),x=u.w>0?bn(b/u.w):1,_=u.h>0?bn(j/u.h):1;l.set(c,{rim:`translate(${R}px, ${h}px) scale(${x}, ${_})`,body:`translate(${R}px, ${h}px)`,rimOpacity:1,bodyOpacity:d})}return{t,eased:r,fold:a,done:o,board:1-ke(a,0,fs),nav:1,tiles:l}}const hs={now:()=>performance.now(),schedule:e=>{const t={};return typeof requestAnimationFrame!="function"?(t.timer=setTimeout(()=>e(!1),us),t):(t.raf=requestAnimationFrame(()=>{clearTimeout(t.timer),e(!0)}),t.timer=setTimeout(()=>{cancelAnimationFrame(t.raf),e(!1)},ja),t)},cancel:e=>{const t=e;t.raf!=null&&cancelAnimationFrame(t.raf),clearTimeout(t.timer)}};function ms(e,t,n=hs,r=0){let a=null,o=()=>{},l=!1;const d=new Promise(j=>{o=j}),c=n.now();let i=c;const u=e>0?Math.min(1,Math.max(0,r))*e:0;let m=u,k=!0;const b=j=>{if(a=null,l)return;const R=n.now(),h=Math.max(0,R-i);i=R;const x=k?us:Sa;j&&(k=!1),m=Math.max(m+(j?Math.min(h,x):h),u+(R-c)-e);const _=e>0?Math.min(1,m/e):1;if(t(_,Vt(_)),_>=1){l=!0,o(!0);return}a=n.schedule(b)};return b(!1),{cancel(){l||(l=!0,a!=null&&n.cancel(a),o(!1))},finished:d}}function Aa(e,t,n=hs,r=0){return ms(e.duration,a=>t(Ca(e,a*e.duration)),n,r)}function Ra(e){const t=/translate\(\s*(-?[\d.e+-]+)px\s*,\s*(-?[\d.e+-]+)px\s*\)\s*scale\(\s*([\d.e+-]+)\s*\)/.exec(e??"");if(!t)return null;const[n,r,a]=[Number(t[1]),Number(t[2]),Number(t[3])];return[n,r,a].every(Number.isFinite)&&a>0?{x:n,y:r,zoom:a}:null}function _a(e,t,n){const r=new Map;for(const a of e){const o={x:n.left+t.x+a.x*t.zoom,y:n.top+t.y+a.y*t.zoom,w:a.w*t.zoom,h:a.h*t.zoom};o.x<n.left+n.width&&o.x+o.w>n.left&&o.y<n.top+n.height&&o.y+o.h>n.top&&r.set(a.sessionId,o)}return r}function La(e,t,n){var a;if(!e)return new Map;const r=n??Ra((a=e.querySelector(".react-flow__viewport"))==null?void 0:a.style.transform);return r?_a(t,r,e.getBoundingClientRect()):new Map}function wn(e){const t=new Map;if(!e)return t;for(const n of e.querySelectorAll("[data-nav-session]")){const r=n.getBoundingClientRect();t.set(n.dataset.navSession,{x:r.left,y:r.top,w:r.width,h:r.height})}return t}function Ma(e,t,n){t.style.opacity=e.nav>=1?"":String(ot(e.nav));for(const[r,{rim:a,body:o}]of n){const l=e.tiles.get(r);a&&(a.style.transform=l&&l.rim!=="none"?l.rim:"",a.style.opacity=l&&l.rimOpacity<1?String(ot(l.rimOpacity)):""),o&&(o.style.transform=l&&l.body!=="none"?l.body:"",o.style.opacity=l&&l.bodyOpacity<1?String(ot(l.bodyOpacity)):"")}}function yn(e,t){e.style.opacity="";for(const{rim:n,body:r}of t.values())for(const a of[n,r])a&&(a.style.transform="",a.style.opacity="")}const Oa=.97,xn=8,kn=24,$e=(e,t,n)=>e+(t-e)*n,He=e=>Math.round(e*100)/100;function nt(e,t){return{x:e.x-t.x,y:e.y-t.y,w:e.w,h:e.h}}function Ia(e){const t=Math.min(kn,e.w/4),n=Math.min(kn,e.h/4);return{x:e.x+t,y:e.y+n,w:e.w-2*t,h:e.h-2*n}}function vn(e,t,n){return{x:$e(e.x,t.x,n),y:$e(e.y,t.y,n),w:$e(e.w,t.w,n),h:$e(e.h,t.h,n)}}function gs(e,t,n,r){const a=He(e.y),o=He(t-e.x-e.w),l=He(n-e.y-e.h),d=He(e.x);return`inset(${a}px ${o}px ${l}px ${d}px round ${He(r)}px)`}function Fa(e,t){const n=e.direction==="open",r=n?e.to:e.from;return{clip:gs(r,e.w,e.h,0),edge:{rect:r,radius:0,opacity:0},content:1,late:1,chip:1,stage:n?t:1-t,board:n?1-t:t,rider:null}}function Pa(e,t){const n=e.direction==="open",r=vn(e.from,e.to,t),a=n?$e(xn,0,t):$e(0,xn,t),o=n?t:1-t;let l=null;if(e.rider){const{card:d,header:c}=e.rider,i=c.h>0&&d.h>0?d.h/c.h:1,u=n?d:c,m=n?c:d,k=n?i:1,b=n?1:i,j=vn(u,m,t);l={transform:`translate(${He(j.x)}px, ${He(j.y)}px) scale(${Math.round($e(k,b,t)*1e4)/1e4})`,opacity:n?1:1-ke(t,.75,1)}}return{clip:gs(r,e.w,e.h,a),edge:{rect:r,radius:a,opacity:n?1-ke(t,.55,.95):ke(t,.1,.4)*(1-ke(t,.85,1))},content:n?ke(t,.4,.85):1-ke(t,.3,.62),late:n?ke(t,Oa,1):1-ke(t,0,.04),chip:n?ke(t,.98,1):1-ke(t,0,.04),stage:n?1:1-ke(t,.7,1),board:1-ke(o,0,fs),rider:l}}const Da=e=>ns(e.nodeInternals.values()),Ba=e=>ea(e.nodeInternals.values()),Sn=14,za=9,Ha=300,$a=typeof window>"u"?f.useEffect:f.useLayoutEffect,Ka="nav-new-session",Ua={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"},Ga=f.memo(f.forwardRef(function({clusters:t,sessions:n,width:r,density:a,attachedId:o,onOpen:l,onNewSession:d},c){var Q;const i=de(),u=f.useMemo(()=>Ur(Gr(t,n),r,a),[t,n,r,a]),m=f.useMemo(()=>new Map(t.map(H=>[H.sessionId,H])),[t]),k=f.useRef(null),b=f.useRef(new Map),j=f.useRef(null);f.useEffect(()=>()=>{var H;return(H=j.current)==null?void 0:H.cancel()},[]);const[R,h]=f.useState(null),x=H=>H!=null&&u.tiles.some(Z=>Z.sessionId===H),_=x(R)?R:x(o)?o:((Q=u.tiles[0])==null?void 0:Q.sessionId)??null,T=f.useCallback(H=>{var Z,F;(F=(Z=b.current.get(H))==null?void 0:Z.querySelector(".nav-open"))==null||F.focus(),h(H)},[]),[C,y]=f.useState(null),S=f.useRef(void 0);$a(()=>{var F,E;const H=S.current;if(S.current=o,!o){y(null);return}if(H===o||(h(o),(E=(F=b.current.get(o))==null?void 0:F.scrollIntoView)==null||E.call(F,{block:"nearest"}),H==null))return;y(o);const Z=window.setTimeout(()=>y(null),Ha);return()=>window.clearTimeout(Z)},[o]),f.useImperativeHandle(c,()=>({tileRects:()=>wn(k.current),fold(H,Z,F={}){var te;const E=k.current;if(!E)return Promise.resolve(!1);(te=j.current)==null||te.cancel();const ee=new Map;for(const[Y,K]of b.current)ee.set(Y,{rim:K.querySelector(".nav-rim"),body:K.querySelector(".nav-body")});yn(E,ee);const $=Ta({board:Z,nav:wn(E),direction:H,reduced:F.reduced});E.setAttribute("data-folding","");const le=Aa($,Y=>{var K;Ma(Y,E,ee),(K=F.onFrame)==null||K.call(F,Y)},void 0,F.from);return j.current=le,le.finished.then(Y=>(j.current!==le||(j.current=null,(H==="open"||!Y)&&(yn(E,ee),E.removeAttribute("data-folding"))),Y))},focusTile:T}),[T]);const z=H=>{var ee,$,le;const Z=Ua[H.key];if(!Z||H.altKey||H.ctrlKey||H.metaKey||H.shiftKey)return;const F=(le=($=(ee=H.target).closest)==null?void 0:$.call(ee,"[data-nav-session]"))==null?void 0:le.getAttribute("data-nav-session");if(!F)return;H.preventDefault(),H.stopPropagation();const E=qr(u,F,Z);E&&T(E)};return s.jsxs("div",{ref:k,className:"board-nav",role:"group","aria-label":i("board.nav.sessions"),"data-density":a,onKeyDown:z,children:[s.jsxs("div",{className:"nav-head",children:[d&&s.jsxs("button",{type:"button",id:Ka,className:"btn nav-new","aria-haspopup":"dialog","aria-label":i("board.newSession.title"),title:i("board.newSession.hint"),onClick:H=>d(H.currentTarget),children:[s.jsx("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",focusable:"false",children:s.jsx("path",{d:"M7 2.5v9M2.5 7h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),s.jsx("span",{className:"nav-new-word",children:i("board.newSession.title")})]}),s.jsx("span",{className:"nav-count",children:Wr(u.tiles.length)})]}),s.jsx("div",{className:"nav-scroll",children:s.jsx("div",{className:"nav-tiles",style:{height:u.height},children:u.tiles.map(H=>{const Z=m.get(H.sessionId);if(!Z)return null;const F=H.sessionId;return s.jsx(Va,{tile:H,cluster:Z,session:n.get(F)??null,density:u.density,attached:F===o,flash:F===C,tabbable:F===_,onFocus:h,onOpen:l,tileRef:E=>{E?b.current.set(F,E):b.current.delete(F)}},F)})})})]})})),Wa=f.forwardRef(function(t,n){const r=an(Da,qs),a=an(Ba,Qr);return s.jsx(Ga,{ref:n,clusters:r,sessions:a,...t})}),qa=f.memo(Wa);function Va({tile:e,cluster:t,session:n,density:r,attached:a,flash:o,tabbable:l,onFocus:d,onOpen:c,tileRef:i}){const u=e.sessionId,m=(n==null?void 0:n.root)??null,k=(n==null?void 0:n.subs)??[],b=m!=null&&zs(m.waiting),j=de(),R=m?Hs(m):{title:t.label},h=ts(R),x=_=>{_.shiftKey||c(u,{keyboard:_.detail===0})};return s.jsxs("div",{ref:i,className:"nav-tile","data-nav-session":u,"data-attached":a?"":void 0,"data-flash":o?"":void 0,style:{left:e.x,top:e.y,width:e.w,height:e.h},onClick:x,children:[s.jsx("span",{className:"nav-rim","aria-hidden":"true"}),s.jsxs("div",{className:"nav-body",children:[s.jsx("button",{type:"button",className:"nav-open","aria-current":a?"true":void 0,"aria-label":Xa(R,m,a,j),title:[R.title,h,t.startedAt!=null?Ks(t.startedAt,t.idTail):""].filter(Boolean).join(`
|
|
3
|
-
`),tabIndex:l?0:-1,onFocus:()=>d(u),children:s.jsxs("span",{className:"nav-face","data-state":m?$s(m):void 0,"data-alarm":b?"":void 0,children:[s.jsxs("span",{className:"nav-id",children:[m?s.jsx(at,{kind:Qn(m)}):null,s.jsx("span",{className:"nav-name",children:R.title}),s.jsx("span",{className:"nav-right",children:b?s.jsx(es,{}):m?s.jsxs("span",{className:"nav-el",children:[m.synthetic?"≥ ":"",s.jsx(Ja,{start:m.startedAt,end:m.endedAt,coarse:r==="rail"})]}):null})]}),h?s.jsx("span",{className:"nav-line",children:h}):null,a&&s.jsx("span",{className:"nav-socket","aria-hidden":"true",children:s.jsx("svg",{viewBox:"0 0 12 12",width:"12",height:"12",focusable:"false",children:s.jsx("path",{d:"M4.5 2.5 8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})]})}),r==="tiles"&&e.rows.length>0&&s.jsx("svg",{className:"nav-trunk",width:e.w,height:e.h,"aria-hidden":"true",focusable:"false",children:e.rows.map((_,T)=>k[T]&&s.jsx("path",{className:k[T].state==="active"?"sess-edge sess-live":"sess-edge sess-idle",d:`M${Sn},${Vr+Yr} V${_+Xr/2} H${Sn+za}`},k[T].id))}),r==="tiles"&&e.rows.map((_,T)=>k[T]&&s.jsx(Ya,{sub:k[T],top:_},k[T].id))]})]})}function Ya({sub:e,top:t}){const n=Zr(e);return s.jsxs("div",{className:"nav-row","data-state":e.state,style:{top:t},children:[s.jsx(at,{kind:Qn(e)}),s.jsx("span",{className:"nav-row-name",children:e.label}),n?s.jsx("span",{className:"nav-row-said","data-tone":n.tone,children:n.long}):null]})}function Xa(e,t,n,r){return[t?Ws({...t,label:e.title},Date.now(),!1,r):e.title,ts(e),n?r("board.nav.openHere"):null].filter(Boolean).join(", ")}function Ja({start:e,end:t,coarse:n=!1}){const r=Us(1e3),a=Gs(e,t,r);return s.jsx(s.Fragment,{children:n?Jr(a):a})}const De={status:"/api/terminal/status",target:"/api/terminal/target",open:"/api/terminal/open",adopt:"/api/terminal/adopt",launch:"/api/terminal/launch",claim:"/api/terminal/claim",hosts:"/api/terminal/hosts",endHosts:"/api/terminal/hosts/end"},Za="/api/terminal/folder",Qa="/api/terminal/projects";function eo(e={}){return Fe(Qa,{},e,t=>{if(!ue(t)||t.ok!==!0||!Array.isArray(t.projects)||t.projects.length>150)return null;const n=[];for(const r of t.projects){if(!ue(r)||typeof r.cwd!="string"||!r.cwd||typeof r.name!="string"||!r.name)return null;const a=r.worktree;ue(a)&&typeof a.projectCwd=="string"&&a.projectCwd&&typeof a.projectName=="string"&&a.projectName&&a.projectCwd!==r.cwd?n.push({cwd:r.cwd,name:r.name,worktree:{projectCwd:a.projectCwd,projectName:a.projectName,...typeof a.branch=="string"&&a.branch?{branch:a.branch}:{}}}):n.push({cwd:r.cwd,name:r.name})}return{ok:!0,projects:n,truncated:t.truncated===!0}})}function to(e){if(!ue(e))return null;if(e.stage==="checking")return{stage:"checking"};const t=n=>typeof n=="number"&&Number.isFinite(n)&&n>=0;return e.stage!=="downloading"||!t(e.received)?null:{stage:"downloading",received:e.received,total:t(e.total)&&e.total>0?e.total:null}}const ps=["unsupported","not-installed","not-verified","unsafe-folder","no-terminal","failed"],bs=["restarting","busy","no-answer"],no=["agent-missing","exists","full","stopping","host-generations"],so=["consent-outdated","host-gone","end-failed"],ro=new Set([...ps,...bs,...no,...so]),ao=e=>ps.includes(e??""),oo="still-running",io="board.api.unreachable",lo="board.api.cancelled",co="board.api.switchedOff",uo="board.api.refused",fo="board.api.unreadable",ue=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function jt(e){if(!ue(e)||typeof e.kind!="string"||typeof e.label!="string")return null;const t={kind:e.kind,label:e.label};return typeof e.adoptable=="boolean"&&(t.adoptable=e.adoptable),typeof e.reason=="string"&&(t.reason=e.reason),(e.provenance==="panel"||e.provenance==="external"||e.provenance==="unknown")&&(t.provenance=e.provenance),t}const Yt=e=>typeof e=="string"&&e?e:null,ho="not found";function mo(e,t){const n=ue(t)&&typeof t.error=="string"?t.error:"";if(e===404&&(!n||n===ho))return{ok:!1,status:e,error:I(co)};if(e===401||e===403)return{ok:!1,status:e,error:I(uo)};const r=ue(t)&&typeof t.hint=="string"?t.hint:"",a=ue(t)&&typeof t.code=="string"&&ro.has(t.code)?t.code:null;return n?{ok:!1,status:e,error:r?`${n} ${r}`:n,...a?{code:a}:{}}:{ok:!1,status:e,error:I(fo)}}async function Fe(e,t,n,r){var d;const a=n.fetchFn??((c,i)=>fetch(c,i));let o;try{o=await a(e,n.signal?{...t,signal:n.signal}:t)}catch{return{ok:!1,status:null,error:I((d=n.signal)!=null&&d.aborted?lo:io)}}const l=await o.json().catch(()=>null);if(o.ok){const c=r(l);if(c)return c}return mo(o.status,l)}const Qe=e=>({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),go=new Set(["stranded","security","draining"]),po=/^[0-9a-f]{32}$/;function bo(e){return!ue(e)||typeof e.id!="string"||!po.test(e.id)||typeof e.name!="string"||!e.name||e.agent!=="claude"&&e.agent!=="codex"||typeof e.cwd!="string"||typeof e.conversation!="string"||typeof e.started!="number"||!Number.isFinite(e.started)?null:{id:e.id,name:e.name,agent:e.agent,cwd:e.cwd,conversation:e.conversation,started:e.started}}function wo(e){if(!ue(e)||!Number.isInteger(e.generation)||typeof e.state!="string"||!go.has(e.state)||!Array.isArray(e.sessions))return null;const t=e.sessions.map(bo);return t.some(n=>n===null)?null:{generation:e.generation,state:e.state,sessions:t}}function yo(e={}){return Fe(De.status,{method:"GET"},e,t=>{if(!ue(t)||t.ok!==!0||!ue(t.tmux)||typeof t.tmux.ok!="boolean")return null;const{progress:n,...r}=t.tmux,a=to(n),o={...r,...a?{progress:a}:{}};return{ok:!0,platform:typeof t.platform=="string"?t.platform:"",tmux:o}})}function xo(e,t={}){const n=new URLSearchParams({session:e.sessionId,provider:e.provider,cwd:e.cwd});return Fe(`${De.target}?${n}`,{method:"GET"},t,r=>{const a=ue(r)&&r.ok===!0?jt(r.target):null;return a?{ok:!0,target:a}:null})}function ko(e,t,n={}){const{sessionId:r,provider:a,cwd:o}=e;return Fe(De.claim,Qe({key:t,sessionId:r,provider:a,cwd:o}),n,l=>{if(!ue(l)||l.ok!==!0||typeof l.claimed!="boolean")return null;const d=jt(l.target);return d?{ok:!0,claimed:l.claimed,target:d}:null})}function vo(e,t={},n,r){const{sessionId:a,provider:o,cwd:l}=e,d={...n?{cols:n.cols,rows:n.rows}:{},...r?{colours:r}:{}};return Fe(De.open,Qe({sessionId:a,provider:o,cwd:l,...d}),t,c=>{if(!ue(c))return null;const i=jt(c.target);if(!i)return null;if(c.ok===!1)return{ok:!1,target:i};const u=Yt(c.ticket);return c.ok===!0&&u?{ok:!0,ticket:u,target:i}:null})}function So(e={}){return Fe(De.hosts,{method:"GET"},e,t=>{if(!ue(t)||t.ok!==!0||!Array.isArray(t.hosts))return null;const n=t.hosts.map(wo);if(n.some(o=>o===null))return null;const r=t.launchesRefused,a=r===null?null:typeof r=="string"&&r?r:void 0;return a===void 0?null:{ok:!0,hosts:n,launchesRefused:a}})}function jo({generation:e,sessions:t},n={}){return Fe(De.endHosts,Qe({generation:e,sessions:[...t]}),n,r=>ue(r)&&r.ok===!0&&Number.isInteger(r.ended)?{ok:!0,ended:r.ended}:null)}function No(e,t={},n,r){const{sessionId:a,provider:o,cwd:l}=e,d={...n?{cols:n.cols,rows:n.rows}:{},...r?{colours:r}:{}};return Fe(De.adopt,Qe({sessionId:a,provider:o,cwd:l,...d}),t,c=>{if(!ue(c)||c.ok!==!0)return null;const i=Yt(c.ticket),u=jt(c.target);return i&&u?{ok:!0,ticket:i,target:u}:null})}const Eo=new Set(["relative","missing","denied","not-folder"]);async function To(e,t={}){const n=t.fetchFn??((o,l)=>fetch(o,l));let r;try{r=await n(Za,Qe({cwd:e}))}catch{return{ok:!1,code:"offline"}}const a=await r.json().catch(()=>null);if(r.ok&&ue(a)){if(a.ok===!0&&typeof a.cwd=="string"&&a.cwd)return{ok:!0,cwd:a.cwd};if(a.ok===!1&&typeof a.code=="string"&&Eo.has(a.code))return{ok:!1,code:a.code}}return{ok:!1,code:"unavailable"}}function Co({agent:e,cwd:t,size:n,launch:r,colours:a,key:o},l={}){const d={...o?{key:o}:{},...n?{cols:n.cols,rows:n.rows}:{},...r&&Object.keys(r).length?{options:r}:{},...a?{colours:a}:{}};return Fe(De.launch,Qe({agent:e,cwd:t,...d}),l,c=>{if(!ue(c)||c.ok!==!0)return null;const i=Yt(c.ticket);return!i||typeof c.name!="string"||!c.name?null:{ok:!0,sessionId:typeof c.sessionId=="string"?c.sessionId:"",name:c.name,ticket:i}})}function ws(){var e;try{return typeof window<"u"&&typeof((e=window.ccdeckFolder)==null?void 0:e.choose)=="function"}catch{return!1}}async function Ao(){if(ws())try{const e=await window.ccdeckFolder.choose();return typeof e=="string"&&e?e:null}catch{return}}const ys="agent-dag.newSession.recent",xs="agent-dag.newSession.forgotten",ks=12,vs=50;function it(){return Vs()}function Ss(e,t){if(!e)return null;try{const n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}function jn(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch{}}function We(e){const t=e.replace(/[\\/]+$/,"");return t===""?e.startsWith("/")?"/":e:/^[A-Za-z]:$/.test(t)?`${t}${e.slice(2,3)||"\\"}`:t}function Ae(e){const t=We(e);return/^[A-Za-z]:[\\/]|^\\\\/.test(t)?t.replace(/\\/g,"/").replace(/^[a-z]:/,n=>n.toUpperCase()):t}function Ro(e=it()){const t=Ss(e,ys);if(!Array.isArray(t))return[];const n=new Set,r=[];for(const a of t){if(!a||typeof a!="object")continue;const{cwd:o,at:l}=a;if(typeof o!="string"||!St(o)||typeof l!="number"||!Number.isFinite(l))continue;const d=We(o);n.has(d)||(n.add(d),r.push({cwd:d,at:l}))}return r.sort((a,o)=>o.at-a.at).slice(0,ks)}function _o(e=it()){const t=Ss(e,xs);return Array.isArray(t)?t.filter(n=>typeof n=="string"&&St(n)).slice(0,vs):[]}function Lo(e=it()){return{recents:Ro(e),forgotten:_o(e)}}function Nn(e,t=it()){jn(t,ys,e.recents),jn(t,xs,e.forgotten)}function En(e,t,n){const r=We(t);return St(r)?{recents:[{cwd:r,at:n},...e.recents.filter(a=>a.cwd!==r)].slice(0,ks),forgotten:e.forgotten.filter(a=>a!==r)}:e}function Mo(e,t){const n=We(t);return{recents:e.recents.filter(r=>r.cwd!==n),forgotten:[n,...e.forgotten.filter(r=>r!==n)].slice(0,vs)}}function Tn(e,t,n=[],r=[]){const a=new Set(n.map(Ae)),o=new Map;for(const i of e){const u=Ae(i.cwd);!a.has(u)&&!o.has(u)&&o.set(u,{...i,cwd:We(i.cwd)})}for(const i of t){const u=Ae(i.cwd);if(a.has(u))continue;const m=o.get(u);m?o.set(u,{...m,at:Math.max(m.at??0,i.at)}):o.set(u,{cwd:i.cwd,name:vt(i.cwd),hue:Wt(i.cwd),at:i.at})}for(const i of r){const u=Ae(i.cwd);if(a.has(u))continue;const m=o.get(u);m?i.worktree&&o.set(u,{...m,name:i.name,worktree:i.worktree}):o.set(u,i)}const l=[...o.values()];if(l.length<2)return l;const d=e.length>0&&Ae(e[0].cwd)===Ae(l[0].cwd),c=(d?l.slice(1):l).sort((i,u)=>(u.at??0)-(i.at??0));return d?[l[0],...c]:c}function Oo(e){var n;const t=new Map;for(const r of e){const a=Ae(((n=r.worktree)==null?void 0:n.projectCwd)??r.cwd),o=t.get(a)??{key:a,worktrees:[]};r.worktree?o.worktrees.push(r):o.main=r,t.set(a,o)}return[...t.values()]}function Io(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}function Fo(e,t){const n=Io(t);if(!n.length)return e;const r=[];return e.forEach((a,o)=>{const l=a.name.toLowerCase(),d=a.cwd.toLowerCase(),c=a.worktree,i=c?`${c.projectName} ${c.projectCwd} ${c.branch??""}`.toLowerCase():"";if(!n.every(m=>l.includes(m)||d.includes(m)||i.includes(m)))return;const u=l.startsWith(n[0])?0:n.every(m=>l.includes(m))?1:2;r.push({p:a,rank:u,i:o})}),r.sort((a,o)=>a.rank-o.rank||a.i-o.i).map(a=>a.p)}function Po(e,t){const n=t.trim();if(!St(n))return null;const r=We(n);return e.some(a=>Ae(a.cwd)===Ae(r))?null:{cwd:r,name:vt(r),hue:Wt(r)}}function Do(e){return/^(~|\.{1,2})([\\/]|$)/.test(e.trim())}function Bo(e,t=40){const n=new Map,r=new Map;for(const a of e){const o=a.name.toLowerCase();r.set(o,[...r.get(o)??[],a])}for(const a of r.values()){if(a.length<2){n.set(a[0].cwd,rt(a[0].cwd,t));continue}const o=a.map(c=>c.cwd.split(/[\\/]+/).filter(Boolean));let l=2;const d=Math.max(...o.map(c=>c.length));for(;l<d&&new Set(o.map(c=>c.slice(-l).join("/"))).size<a.length;)l+=1;a.forEach((c,i)=>{const u=o[i].slice(-l).join("/");n.set(c.cwd,l>=o[i].length?c.cwd:u.length+2<=Math.max(t,24)?`…/${u}`:`…/${u.slice(-(t-2))}`)})}return n}function wt({size:e=16,box:t=16,children:n}){return s.jsx("svg",{className:"ts-icon",width:e,height:e,viewBox:`0 0 ${t} ${t}`,"aria-hidden":"true",focusable:"false",children:n})}function zo({provider:e,size:t=10}){return e==="codex"?s.jsx(wt,{size:t,box:12,children:s.jsx("path",{d:"M2 3.5 4.5 6 2 8.5M6 9h4"})}):s.jsx(wt,{size:t,box:12,children:s.jsx("path",{d:"M6 1.5v9M1.5 6h9M2.8 2.8l6.4 6.4M9.2 2.8 2.8 9.2"})})}function Ho(e){switch(e){case"working":case"attaching":case"starting":return"working";case"waiting":return"waiting";case"ended":return"done";case"none":return null;default:return"idle"}}function Ue({kind:e}){return s.jsxs("span",{className:"ts-glyph","data-glyph":e,"aria-hidden":"true",children:[e==="waiting"&&s.jsx(es,{size:14}),e==="working"&&s.jsx(at,{kind:"live",size:14}),e==="done"&&s.jsx(at,{kind:"done",size:14}),e==="idle"&&s.jsx(at,{kind:"idle",size:14})]})}const $o=()=>s.jsx(Ce,{name:"keyboard",className:"ts-icon"}),Ko=()=>s.jsx(wt,{children:s.jsx("path",{d:"M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9"})}),Uo=()=>s.jsx(wt,{children:s.jsx("path",{d:"M13.5 6.5h-4v-4M9.5 6.5 14 2M2.5 9.5h4v4M6.5 9.5 2 14"})}),Go=()=>s.jsx(Ce,{name:"close",className:"ts-icon"}),Wo=()=>s.jsx(Ce,{name:"chevron-left",className:"ts-icon"}),qo=()=>s.jsx(Ce,{name:"copy",className:"ts-icon"}),Vo={outline:"",primary:"ui-button-primary",ghost:"ui-button-ghost"},Yo={default:"",icon:"ui-button-icon"},ze=f.forwardRef(({className:e="",variant:t="outline",size:n="default",type:r="button",...a},o)=>s.jsx("button",{ref:o,type:r,className:["ui-button",Vo[t],Yo[n],e].filter(Boolean).join(" "),...a}));ze.displayName="Button";const js=f.forwardRef(({className:e="",type:t="text",...n},r)=>s.jsx("input",{ref:r,type:t,className:`ui-input ${e}`,...n}));js.displayName="Input";const Xo="ns-pop",Ns="ns-title",Cn="ns-search",Ct="ns-projects",An="ns-keys",Rn="ns-worktree-label",_n=e=>`ns-opt-${e}`,Jo={loading:"board.newSession.discovery.loading",partial:"board.newSession.discovery.partial",unavailable:"board.newSession.discovery.unavailable"},Zo="board.newSession.note",Qo="board.newSession.noteWindows";function ei(){return{checkFolder:e=>To(e),loadProjects:async e=>{const t=await eo({signal:e});if(!t.ok)throw new Error("Project discovery unavailable");return t},...ws()?{chooseFolder:Ao}:{},store:it(),now:()=>Date.now(),apple:kt(Ge())}}const At=[{value:null,label:"board.newSession.default"},{value:"opus",label:"Opus",named:!0},{value:"sonnet",label:"Sonnet",named:!0},{value:"haiku",label:"Haiku",named:!0}],ct=[{value:null,label:"board.newSession.default",title:"board.newSession.modeDefaultTip"},{value:"auto",label:"board.newSession.modeAuto",title:"board.newSession.modeAutoTip"},{value:"acceptEdits",label:"board.newSession.modeEdits",title:"board.newSession.modeEditsTip"},{value:"plan",label:"board.newSession.modePlan",title:"board.newSession.modePlanTip"}];function ti(e,t,n){const r={};return e&&(r.model=e),t&&(r.permissionMode=t),n&&(r.worktree=!0),Object.keys(r).length?r:void 0}const ni=[{agent:"claude",label:"Claude"},{agent:"codex",label:"Codex"}];function si(e,t){const n=e==="codex"?"Codex":"Claude";return t?I("board.newSession.startIn",{agent:n,project:t.name}):I("board.newSession.start",{agent:n})}const ri={relative:"board.newSession.problemRelative",missing:"board.newSession.problemMissing",denied:"board.newSession.problemDenied","not-folder":"board.newSession.problemNotFolder",offline:"board.newSession.problemOffline"},ai=e=>e?"C:\\path\\to\\project":"/path/to/project";function oi({projects:e,initialAgent:t="claude",windows:n=!1,onStart:r,onCancel:a,deps:o,searchRef:l}){var se,he;const d=de(),[c]=f.useState(()=>({...ei(),...o})),[i,u]=f.useState(()=>Lo(c.store)),[m,k]=f.useState([]),[b,j]=f.useState(c.loadProjects?"loading":"ready"),R=Tn(e,i.recents,i.forgotten,m);f.useEffect(()=>{var L;const p=new AbortController;return(L=c.loadProjects)==null||L.call(c,p.signal).then(W=>{p.signal.aborted||(k(W.projects.map(ne=>({...ne,hue:Wt(ne.cwd)}))),j(W.truncated?"partial":"ready"))}).catch(()=>{p.signal.aborted||j("unavailable")}),()=>p.abort()},[c]);const[h,x]=f.useState(()=>R[0]?{cwd:R[0].cwd,name:R[0].name}:null),[_,T]=f.useState(""),[C,y]=f.useState(()=>{var p;return((p=R[0])==null?void 0:p.cwd)??null}),[S,z]=f.useState(!1),[Q,H]=f.useState(t),[Z,F]=f.useState(null),[E,ee]=f.useState(null),[$,le]=f.useState(!1),[te,Y]=f.useState(null),[K,G]=f.useState(null),[we,me]=f.useState(null),je=f.useRef(null),Le=f.useRef(null),ye=l??je,Ne=f.useRef(!1),xe=f.useRef(!1),ve=_.trim()!=="",fe=ve?Po(R,_):null,be=R.filter(p=>p.worktree).length,v=ve?[...fe?[fe]:[],...Fo(R,_)]:R.filter(p=>S||!p.worktree||p.cwd===(h==null?void 0:h.cwd)),M=Oo(v),A=M.flatMap(({main:p,worktrees:L})=>p?[p,...L]:L),D=new Map(A.map((p,L)=>[p.cwd,L])),B=A.length?D.get(C??"")??0:-1;f.useEffect(()=>{const p=Le.current,L=p==null?void 0:p.querySelector('[data-highlighted="true"]');if(!p||!L)return;const W=p.getBoundingClientRect(),ne=L.getBoundingClientRect();ne.top<W.top?p.scrollTop-=W.top-ne.top:ne.bottom>W.bottom&&(p.scrollTop+=ne.bottom-W.bottom)},[B,_,(se=A[B])==null?void 0:se.cwd,A.length]);const ie=Bo(R),ae=p=>{u(L=>{const W=p(L);return Nn(W,c.store),W})},g=()=>{G(null),me(null)},w=p=>{x({cwd:p.cwd,name:p.name}),T(""),y(p.cwd),g()},N=async p=>{if(xe.current)return;xe.current=!0,g(),Y("checking");const L=await c.checkFolder(p);if(xe.current=!1,Y(null),!L.ok&&L.code!=="unavailable"){G({code:L.code,cwd:p});return}const W=L.ok?L.cwd:We(p);ae(ne=>En(ne,W,c.now())),x({cwd:W,name:vt(W)}),T(""),y(W)},P=p=>{fe&&p.cwd===fe.cwd?N(p.cwd):w(p)},U=p=>{var W;const L=Mo(i,p.cwd);if(Nn(L,c.store),u(L),h&&Ae(h.cwd)===Ae(p.cwd)){const ne=Tn(e,L.recents,L.forgotten,m);x(ne[0]?{cwd:ne[0].cwd,name:ne[0].name}:null)}G(null),me(d("board.newSession.forgotten",{name:p.name})),(W=ye.current)==null||W.focus()},J=()=>{var p;G(null),me(d("board.newSession.typePath",{example:ai(n)})),(p=ye.current)==null||p.focus()},re=async()=>{var L,W;if(te)return;if(!c.chooseFolder)return J();g(),Y("picking");let p;try{p=await c.chooseFolder()}catch{p=void 0}if(Y(null),p===void 0)return J();if(p===null){me(d("board.newSession.pickCancelled")),(L=ye.current)==null||L.focus();return}await N(p),(W=ye.current)==null||W.focus()},oe=async()=>{if(!h||Ne.current||xe.current)return;xe.current=!0,g(),Y("checking");const p=await c.checkFolder(h.cwd);if(xe.current=!1,Y(null),!p.ok&&p.code!=="unavailable"){G({code:p.code,cwd:h.cwd});return}const L=p.ok?p.cwd:h.cwd;Ne.current=!0,ae(ne=>En(ne,L,c.now()));const W=Q==="claude"?ti(Z,E,$):void 0;W?r(Q,L,W):r(Q,L)},ce=p=>{if(p.key==="ArrowDown"||p.key==="ArrowUp"){if(!A.length)return;p.preventDefault();const L=p.key==="ArrowDown"?1:A.length-1;y(A[(B<0?0:B+L)%A.length].cwd)}else if(p.key==="Enter"){if(p.preventDefault(),p.ctrlKey||p.metaKey){oe();return}const L=B>=0?A[B]:void 0;L&&P(L)}else if(p.key==="Delete"&&p.shiftKey){const L=B>=0?A[B]:void 0;if(!L||fe&&L.cwd===fe.cwd)return;p.preventDefault(),U(L)}else p.key==="Escape"&&_&&(p.preventDefault(),p.stopPropagation(),T(""),y((h==null?void 0:h.cwd)??null))},Re=ve?Do(_)?d(n?"board.newSession.pathHintWindows":"board.newSession.pathHint"):d("board.newSession.noMatches",{query:_.trim()}):d("board.newSession.noProjects"),Se=K&&K.code!=="unavailable"?d(ri[K.code]):null,Ee=d("board.newSession.keysHint",{mod:c.apple?"⌘":"Ctrl"}),q=p=>{var Pe;const L=D.get(p.cwd),W=!!fe&&p.cwd===fe.cwd,ne=!!h&&h.cwd===p.cwd&&!W;return s.jsxs("div",{id:_n(L),className:"ns-option",role:"option","aria-selected":ne,"data-highlighted":L===B||void 0,"data-chosen":ne||void 0,"data-worktree":!!p.worktree||void 0,title:p.cwd,onMouseDown:pe=>pe.preventDefault(),onClick:()=>P(p),children:[s.jsx("span",{className:"ns-folder","aria-hidden":"true",children:s.jsx(Ce,{name:"folder"})}),s.jsxs("span",{className:"ns-project-copy",children:[s.jsx("span",{className:"ns-name",children:W?d("board.newSession.usePath",{name:p.name}):p.name}),s.jsxs("span",{className:"ns-path",children:[(Pe=p.worktree)!=null&&Pe.branch&&p.worktree.branch!==p.name?`${p.worktree.branch} · `:"",W?rt(p.cwd,56):ie.get(p.cwd)??rt(p.cwd,56)]})]}),ne&&s.jsx("svg",{className:"ns-check",width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:s.jsx("path",{d:"M2.5 6.5l2.25 2.25L9.5 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),!W&&s.jsx("span",{className:"ns-forget","aria-hidden":"true",title:d("board.newSession.forget",{name:p.name}),onClick:pe=>{pe.stopPropagation(),U(p)},children:"×"})]},`${W?"typed:":""}${p.cwd}`)};return s.jsxs("div",{className:"ns-form","data-searching":ve||void 0,"aria-busy":te?!0:void 0,children:[s.jsxs("div",{className:"ns-head",children:[s.jsx("h3",{id:Ns,className:"ns-title",children:d("board.newSession.title")}),s.jsx(ze,{variant:"ghost",size:"icon",className:"ns-close","aria-label":d("common.close"),onClick:a,children:s.jsx(Ce,{name:"close"})})]}),s.jsxs("div",{className:"ns-project-heading",children:[s.jsx("label",{className:"ns-label",id:"ns-project-label",htmlFor:Cn,children:d("board.newSession.project")}),be>0&&!ve&&s.jsxs(ze,{variant:"ghost",className:"ns-worktree-toggle","aria-pressed":S,"aria-controls":Ct,onClick:()=>z(p=>!p),children:[d("board.newSession.worktrees")," ",s.jsx("span",{className:"ns-worktree-count",children:be})]})]}),s.jsxs("div",{className:"ns-search",children:[s.jsx(Ce,{name:"search"}),s.jsx(js,{ref:ye,id:Cn,className:"ns-field",type:"text",name:"project-search",role:"combobox","aria-expanded":A.length>0,"aria-controls":Ct,"aria-activedescendant":B>=0?_n(B):void 0,"aria-autocomplete":"list","aria-label":d("board.newSession.searchLabel"),"aria-describedby":An,spellCheck:!1,autoComplete:"off",placeholder:d("board.newSession.searchLabel"),value:_,onChange:p=>{T(p.target.value),y(null),g()},onKeyDown:ce})]}),s.jsx("span",{id:An,className:"ns-keys",children:Ee}),s.jsx("div",{ref:Le,className:"ns-list",id:Ct,role:"listbox","aria-labelledby":"ns-project-label",hidden:A.length===0,children:M.map(p=>{var ne;const L=(ne=p.worktrees[0])==null?void 0:ne.worktree;if(!L)return p.main&&q(p.main);const W=d("board.newSession.worktreeGroup",{project:L.projectName});return s.jsxs("div",{className:"ns-project-group",role:"group","aria-label":W,children:[p.main&&q(p.main),s.jsx("div",{className:"ns-worktree-heading","aria-hidden":"true",title:L.projectCwd,children:W}),p.worktrees.map(q)]},p.key)})}),A.length===0&&b!=="loading"&&s.jsx("p",{className:"ns-empty",role:"status",children:Re}),b!=="ready"&&s.jsx("p",{className:"ns-discovery",role:"status",children:d(Jo[b])}),s.jsxs(ze,{variant:"ghost",className:"ns-choose",onClick:()=>void re(),"aria-disabled":te==="picking"||void 0,children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M1.75 4.25c0-.69.56-1.25 1.25-1.25h3.1l1.5 1.5H13c.69 0 1.25.56 1.25 1.25v6.5c0 .69-.56 1.25-1.25 1.25H3c-.69 0-1.25-.56-1.25-1.25z",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})}),d("board.newSession.chooseFolder")]}),Se?s.jsxs("p",{className:"ns-problem",role:"alert",children:[Se," ",s.jsx("span",{className:"ns-problem-path",title:K.cwd,children:rt(K.cwd,48)})]}):h?s.jsxs("p",{className:"ns-where",children:[s.jsx("span",{className:"ns-where-k",children:d("board.newSession.folder")}),s.jsx("span",{className:"ns-where-v",title:h.cwd,children:rt(h.cwd,56)})]}):null,s.jsx("p",{className:"ns-said",role:"status",children:te==="checking"?d("board.newSession.checking"):we??""}),s.jsx("span",{className:"ns-label ns-label-gap",id:"ns-agent-label",children:d("board.newSession.agent")}),s.jsx("div",{className:"uh-range ns-agents",role:"group","aria-labelledby":"ns-agent-label",children:ni.map(p=>s.jsxs(ze,{type:"button",className:"uh-range-btn","aria-pressed":Q===p.agent,onClick:()=>H(p.agent),children:[s.jsx(zo,{provider:p.agent,size:16})," ",p.label]},p.agent))}),Q==="claude"&&s.jsxs("details",{className:"ns-options",children:[s.jsxs("summary",{className:"ns-options-summary",children:[s.jsx("span",{children:d("board.newSession.options")}),s.jsx("span",{className:"ns-options-value",children:!Z&&!E&&!$?d("board.newSession.usesSettings"):s.jsxs(s.Fragment,{children:[Z?(he=At.find(p=>p.value===Z))==null?void 0:he.label:d("board.newSession.default")," · ",d(ct.find(p=>p.value===E).label),$?` · ${d("board.newSession.worktreeShort")}`:""]})}),s.jsx("svg",{className:"ns-options-chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:s.jsx("path",{d:"m3 4.5 3 3 3-3"})})]}),s.jsxs("div",{className:"ns-options-fields",children:[s.jsxs("label",{className:"ns-setting",htmlFor:"ns-model",children:[s.jsx("span",{className:"ns-label",id:"ns-model-label",children:d("board.newSession.model")}),s.jsx(on,{children:s.jsx("select",{id:"ns-model","aria-labelledby":"ns-model-label",className:"sm-select",value:Z??"",onChange:p=>{var L;return F(((L=At.find(W=>W.value===p.currentTarget.value))==null?void 0:L.value)??null)},children:At.map(p=>s.jsx("option",{value:p.value??"",children:p.named?p.label:d(p.label)},p.label))})})]}),s.jsxs("label",{className:"ns-setting",htmlFor:"ns-mode",children:[s.jsx("span",{className:"ns-label",id:"ns-mode-label",children:d("board.newSession.permissions")}),s.jsx(on,{children:s.jsx("select",{id:"ns-mode","aria-labelledby":"ns-mode-label",className:"sm-select",value:E??"",title:d(ct.find(p=>p.value===E).title),onChange:p=>{var L;return ee(((L=ct.find(W=>W.value===p.currentTarget.value))==null?void 0:L.value)??null)},children:ct.map(p=>s.jsx("option",{value:p.value??"",children:d(p.label)},p.label))})})]})]}),s.jsxs("label",{className:"ns-worktree",children:[s.jsx("span",{className:"ns-worktree-label",id:Rn,children:d("board.newSession.worktree")}),s.jsx("button",{type:"button",role:"switch","aria-checked":$,"aria-labelledby":Rn,className:"switch",title:d("board.newSession.worktreeTip"),onClick:()=>le(p=>!p),children:s.jsx("span",{className:"switch-knob"})})]})]}),s.jsx("p",{className:"ns-note",children:d(n?Qo:Zo)}),s.jsxs("div",{className:"ns-acts",children:[s.jsx(ze,{onClick:a,children:d("common.cancel")}),s.jsx(ze,{variant:"primary",className:"primary",disabled:!h,"aria-disabled":te!==null||void 0,title:h==null?void 0:h.cwd,onClick:()=>void oe(),children:si(Q,h)})]})]})}function ii(e){const t=f.useRef(null);return s.jsx(Ut,{anchorId:e.anchorId,id:Xo,className:"ns-pop",role:"dialog",labelledBy:Ns,onClose:e.onClose,focusRef:t,align:"start",overAnchor:!0,children:s.jsx(oi,{searchRef:t,projects:e.projects,initialAgent:e.initialAgent,windows:e.windows,onStart:(n,r,a)=>{e.onStart(n,r,a),e.onClose()},onCancel:e.onClose})})}function li({d:e,label:t,inRef:n,onRatio:r}){const a=f.useRef(0),o=m=>{var b;const k=(b=n.current)==null?void 0:b.getBoundingClientRect();return k?e.dir==="row"?m.clientX-k.left:m.clientY-k.top:null},l=m=>{var k,b;m.button===0&&(m.preventDefault(),(b=(k=m.currentTarget).setPointerCapture)==null||b.call(k,m.pointerId),m.currentTarget.setAttribute("data-moving",""))},d=m=>{var b,j;if(!((j=(b=m.currentTarget).hasPointerCapture)!=null&&j.call(b,m.pointerId)))return;const k=o(m);k!=null&&(cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>r(e.path,Et(e,k))))},c=m=>{var k,b;(b=(k=m.currentTarget).releasePointerCapture)==null||b.call(k,m.pointerId),m.currentTarget.removeAttribute("data-moving")},i=m=>{const k=e.dir==="row"?"ArrowLeft":"ArrowUp",b=e.dir==="row"?"ArrowRight":"ArrowDown";let j=null;m.key===k||m.key===b?j=e.ratio+(m.key===b?.05:-.05):m.key==="Home"?j=0:m.key==="End"?j=1:m.key==="Enter"&&(j=.5),j!=null&&(m.preventDefault(),m.stopPropagation(),r(e.path,Et(e,e.start+j*e.length)))};f.useEffect(()=>()=>cancelAnimationFrame(a.current),[]);const u=e.rect;return s.jsx("div",{role:"separator",tabIndex:0,className:"wsp-divider","data-dir":e.dir,"aria-orientation":e.dir==="row"?"vertical":"horizontal","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(e.ratio*100),style:{left:u.x,top:u.y,width:u.w,height:u.h},onPointerDown:l,onPointerMove:d,onPointerUp:c,onPointerCancel:c,onDoubleClick:()=>r(e.path,Et(e,e.start+e.length/2)),onKeyDown:i})}const ci=3,di=1500;function ui(e,t,n,r){const a=[];for(const o of e){if(o.kind!=="root"||o.provider!=="codex"||t.has(o.id))continue;const l=n.get(o.id);l&&(l.busy||l.done||l.tries>=ci||r-l.at<di)||a.push(o)}return a}function fi(e,t,n){const r=f.useRef(null),a=Je(n),o=(e==null?void 0:e.kind)==="launch"&&e.agent==="codex"?e.key:null;f.useEffect(()=>()=>{r.current=null},[]),f.useEffect(()=>{var c,i;if(!o){r.current=null;return}((c=r.current)==null?void 0:c.key)!==o&&(r.current={key:o,before:new Set(t.keys()),asked:new Map,found:!1});const l=r.current;if(l.found)return;const d=Date.now();for(const u of ui(t.values(),l.before,l.asked,d)){const m={tries:(((i=l.asked.get(u.id))==null?void 0:i.tries)??0)+1,at:d,busy:!0,done:!1};l.asked.set(u.id,m),ko({sessionId:u.sessionId,provider:"codex",cwd:u.cwd??""},o).then(k=>{if(m.busy=!1,!!k.ok){if(k.claimed){if(m.done=!0,r.current!==l||l.found)return;l.found=!0,a.current(u.sessionId,o);return}k.target.kind!=="unsupported"&&(m.done=!0)}})}})}const hi=4.5,mi=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],gi={black:{dark:"--muted",light:"--text"},red:{dark:"--err",light:"--err"},green:{dark:"--ok",light:"--ok"},yellow:{dark:"--cat-shell",light:"--cat-shell"},blue:{dark:"--accent",light:"--accent"},magenta:{dark:"--cat-agent",light:"--cat-agent"},cyan:{dark:"--cat-web",light:"--cat-web"},white:{dark:"--text-secondary",light:"--text-dim"},brightBlack:{dark:"--muted",light:"--muted"},brightRed:{dark:"--err",light:"--err"},brightGreen:{dark:"--ok",light:"--ok"},brightYellow:{dark:"--cat-shell",light:"--cat-shell"},brightBlue:{dark:"--accent",light:"--accent"},brightMagenta:{dark:"--cat-agent",light:"--cat-agent"},brightCyan:{dark:"--cat-web",light:"--cat-web"},brightWhite:{dark:"--text",light:"--text-dim"}},V=(e,t=e)=>({kind:"ink",token:{dark:e,light:t}}),Te=(e,t)=>({kind:"band",token:e,wash:t}),Es=new Map([[231,V("--text")],[255,V("--text")],[254,V("--text")],[253,V("--text-secondary")],[252,V("--text-secondary")],[251,V("--text-secondary")],[250,V("--text-secondary","--muted")],[249,V("--text-secondary","--muted")],[248,V("--text-secondary","--muted")],[247,V("--text-secondary","--muted")],[246,V("--text-secondary","--muted")],[245,V("--muted","--text-dim")],[244,V("--muted","--text-dim")],[243,V("--muted","--text-dim")],[242,V("--muted","--text-dim")],[241,V("--muted","--text-dim")],[240,V("--muted","--text-dim")],[239,Te("--text",.13)],[238,Te("--text",.1)],[237,Te("--text",.075)],[236,Te("--text",.05)],[235,Te("--text",.035)],[234,Te("--text",.025)],[233,Te("--text",.02)],[232,Te("--text",.015)],[114,V("--ok")],[120,V("--ok")],[77,V("--ok")],[71,V("--ok")],[153,V("--accent")],[117,V("--accent")],[111,V("--accent")],[147,V("--usage-indigo")],[105,V("--usage-indigo")],[211,V("--usage-pink")],[220,V("--cat-shell")],[214,V("--cat-shell")],[174,V("--usage-orange")],[180,V("--cat-shell")],[216,V("--cat-shell")],[197,V("--usage-pink")],[81,V("--usage-cyan")],[148,V("--usage-lime")],[186,V("--usage-orange")],[141,V("--usage-purple")],[208,V("--usage-indigo")],[22,Te("--ok",.16)],[52,Te("--err",.16)],[28,Te("--ok",.32)],[88,Te("--err",.32)]]);[...Es.keys()].sort((e,t)=>e-t);const Ts=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");function pi(e,t,n){const r=yt(e),a=yt(t);return!r||!a?null:"#"+[0,1,2].map(o=>Ts(r[o]*n+a[o]*(1-n))).join("")}function yt(e){const t=e.trim(),n=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t);if(n){const a=n[1].length<=4?n[1].replace(/./g,o=>o+o):n[1];return[parseInt(a.slice(0,2),16),parseInt(a.slice(2,4),16),parseInt(a.slice(4,6),16)]}const r=/^rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)/i.exec(t);return r?[+r[1],+r[2],+r[3]]:Cs(t)}function Cs(e){var k;const t=(k=/^color-mix\(\s*in\s+srgb\s*,([\s\S]*)\)$/i.exec(e))==null?void 0:k[1];if(t==null)return null;const n=[];let r=0,a=0;for(let b=0;b<t.length;b++)t[b]==="("?r++:t[b]===")"?r--:t[b]===","&&r===0&&(n.push(t.slice(a,b)),a=b+1);if(n.push(t.slice(a)),n.length!==2)return null;const o=n.map(b=>{const j=/^\s*(?:([\d.]+)%\s+)?(.+?)(?:\s+([\d.]+)%)?\s*$/.exec(b);if(!j||j[1]&&j[3])return null;const R=yt(j[2]),h=j[1]??j[3];return R?{rgb:R,share:h==null?null:Number(h)}:null}),[l,d]=o;if(!l||!d)return null;let c=l.share,i=d.share;c==null&&i==null?(c=50,i=50):c==null?c=100-i:i==null&&(i=100-c);const u=c+i;if(!(u>0))return null;const m=c/u;return[0,1,2].map(b=>l.rgb[b]*m+d.rgb[b]*(1-m))}function bi(e){if(!/^color-mix\(/i.test(e))return e;const t=Cs(e);return t?"#"+t.map(Ts).join(""):e}function wi(e){const t=yt(e);if(!t)return"dark";const[n,r,a]=t.map(l=>{const d=l/255;return d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4)}),o=.2126*n+.7152*r+.0722*a;return 1.05/(o+.05)>(o+.05)/.05?"dark":"light"}function yi(e,t="--panel"){const n={},r=(c,i)=>{const u=e(i).trim();u&&(n[c]=u)},a=bi(e(t).trim()),o=wi(a);a&&(n.background=a),r("foreground","--text"),r("cursor","--accent"),a&&(n.cursorAccent=a),r("selectionBackground","--accent-dim");for(const c of mi)r(c,gi[c][o]);const l=Array.from({length:240},()=>{});let d=!1;for(const[c,i]of Es){const u=i.kind==="ink"?e(i.token[o]).trim():a?pi(e(i.token),a,i.wash)??"":"";u&&(l[c-16]=u,d=!0)}return d&&(n.extendedAnsi=l),n}const xi="/api/terminal/attach",ki=1<<20,Ln=64*1024,vi=["ended","detached","server-shutdown","error"],Mn=(e,t)=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=t,Si=["da","dsr","decdsr","decrqm-ansi","decrqm-dec","decrqss","osc4","osc10","osc11","osc12"];function ji(e,t,n){const r=new URL(e,n);return r.protocol==="http:"?r.protocol="ws:":r.protocol==="https:"&&(r.protocol="wss:"),r.searchParams.set("ticket",t),r.toString()}const On=e=>typeof e=="number"&&Number.isInteger(e)&&e>0?e:null;function Ni(e){let t;try{const n=JSON.parse(e);if(!n||typeof n!="object"||Array.isArray(n))return null;t=n}catch{return null}switch(t.t){case"hello":return{t:"hello",kind:typeof t.kind=="string"?t.kind:"",sizeOwner:t.sizeOwner==="pane"?"pane":"dock",readOnly:t.readOnly===!0};case"reset":case"size":{const n=On(t.cols),r=On(t.rows);return n&&r?{t:t.t,cols:n,rows:r}:null}case"tmux":{const n=typeof t.version=="string"?/^(\d{1,3})\.(\d{1,3})$/.exec(t.version):null;return n?{t:"tmux",version:[Number(n[1]),Number(n[2])]}:null}case"replies":{if(t.v!==1||!Array.isArray(t.view)||!t.view.every(r=>typeof r=="string"))return null;const n=new Set(t.view);return{t:"replies",view:Si.filter(r=>n.has(r))}}case"exit":{const n=vi.includes(t.reason)?t.reason:"error";return{t:"exit",reason:n,...typeof t.message=="string"&&t.message?{message:t.message}:{},...t.atOpen===!0?{atOpen:!0}:{},...n==="ended"&&Mn(t.exitStatus,0)?{exitStatus:t.exitStatus}:{},...n==="ended"&&Mn(t.exitSignal,1)?{exitSignal:t.exitSignal}:{}}}default:return null}}function Ei(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null}const As=new TextEncoder;function xt(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase(),n=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(t);if(n)return`#${n[1].length<=4?n[1].slice(0,3).replace(/./g,l=>l+l):n[1].slice(0,6)}`;const r=/^rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*(?:[,/]\s*[\d.]+%?\s*)?\)$/.exec(t);if(!r)return null;const a=[r[1],r[2],r[3]].map(Number);return a.some(o=>!Number.isFinite(o)||o>255)?null:`#${a.map(o=>Math.round(o).toString(16).padStart(2,"0")).join("")}`}const Pt=e=>As.encode(JSON.stringify({t:"paste",text:e})).byteLength>ki,Ti="board.api.connectionRefused",Ci="board.api.connectionLost";function Ai(e){const{ticket:t,onHello:n,onReset:r,onData:a,onSize:o,onTmux:l,onReplies:d,onExit:c,onError:i}=e,u=e.base??(typeof location>"u"?void 0:location.href),k=(e.createSocket??(C=>new WebSocket(C)))(ji(e.url??xi,t,u));k.binaryType="arraybuffer";let b=!1,j=!1,R=!1,h=null,x="";const _=[],T=C=>j?!1:(b?k.send(C):_.push(C),!0);return k.onopen=()=>{if(!j){b=!0;for(const C of _.splice(0))k.send(C)}},k.onmessage=C=>{if(j)return;if(typeof C.data=="string"){const S=Ni(C.data);if(!S)return;switch(S.t){case"hello":R=S.readOnly,n==null||n({kind:S.kind,sizeOwner:S.sizeOwner,readOnly:S.readOnly});return;case"reset":h={cols:S.cols,rows:S.rows};return;case"size":o==null||o({cols:S.cols,rows:S.rows});return;case"tmux":l==null||l(S.version);return;case"replies":d==null||d(S.view);return;case"exit":j=!0,h=null,c==null||c({reason:S.reason,...S.message===void 0?{}:{message:S.message},...S.atOpen?{atOpen:!0}:{},...S.exitStatus===void 0?{}:{exitStatus:S.exitStatus},...S.exitSignal===void 0?{}:{exitSignal:S.exitSignal}}),k.close(1e3);return}return}const y=Ei(C.data);if(y){if(h){const S=h;h=null,r==null||r({cols:S.cols,rows:S.rows,seed:y});return}a==null||a(y)}},k.onerror=()=>{},k.onclose=C=>{if(j)return;j=!0,h=null;const y=typeof(C==null?void 0:C.code)=="number"?C.code:1006;i==null||i(b?{kind:"lost",code:y,message:I(Ci)}:{kind:"refused",code:y,message:I(Ti)})},{sendInput(C){if(R||j)return!1;const y=typeof C=="string"?As.encode(C):C;if(y.byteLength===0)return!0;for(let S=0;S<y.byteLength;S+=Ln)T(y.subarray(S,Math.min(S+Ln,y.byteLength)));return!0},sendSize(C,y){if(!Number.isFinite(C)||!Number.isFinite(y))return!1;const S=Math.floor(C),z=Math.floor(y);return S<1||z<1?!1:T(JSON.stringify({t:"size",cols:S,rows:z}))},sendPaste(C){return R||j||Pt(C)?!1:T(JSON.stringify({t:"paste",text:C}))},sendColours(C,y){if(R||j)return!1;const S=xt(C),z=xt(y);return!S||!z?!1:`${S} ${z}`===x?!0:(x=`${S} ${z}`,T(JSON.stringify({t:"colours",fg:S,bg:z})))},sendAck(C){return j||!Number.isSafeInteger(C)||C<0?!1:T(JSON.stringify({t:"ack",bytes:C}))},close(){j||(j=!0,h=null,_.length=0,k.close(1e3))}}}const Ri=e=>typeof e=="string"&&e.length>0&&e.length<=8192&&!/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/.test(e)&&(/^\//.test(e)||/^[a-z]:[\\/]/i.test(e)||/^\\\\/.test(e));function _i(e,t=Ge()){if(!e.length||e.length>64||!e.every(Ri))return null;const r=e.map(a=>`'${/^win/i.test(t)?a.replaceAll("'","''"):a.replaceAll("'","'\\''")}'`).join(" ")+" ";return r.length<=65536?r:null}function In(e){return!!e&&Array.from(e.types).includes("Files")}function Li(e,t=Ge(),n=r=>{var a;return(a=window.ccdeckFiles)==null?void 0:a.paths(r)}){try{const r=Array.from(e.files);if(!r.length||r.length>64)return null;const a=n(r);return Array.isArray(a)&&a.length===r.length?_i(a,t):null}catch{return null}}const Mi=new TextEncoder;function Oi(){const e=Ii();let t="text",n=[],r=!1;return{reset:()=>{t="text",n=[],r=!1,e.reset()},write(o){if(t==="text"&&!o.includes(27))return o;const l=[];for(const d of o)if(t==="string"||t==="string-escape")l.push(d),r&&d===7||t==="string-escape"&&d===92?t="text":t=d===27?"string-escape":"string";else if(t==="text")d===27?(n=[d],t="escape"):l.push(d);else if(t==="escape")n.push(d),d===91?t="csi":(l.push(...n),n=[],r=d===93,t=[80,88,93,94,95].includes(d)?"string":"text");else if(t==="csi-pass")l.push(d),(d>=64&&d<=126||d===24||d===26)&&(t="text");else if(n.push(d),d>=64&&d<=126){const c=String.fromCharCode(...n.slice(2,-1)),i=d===109&&/^[\d;:]*$/.test(c)?e.map(c):null;i===null?l.push(...n):l.push(...Mi.encode(`\x1B[${i}m`)),n=[],t="text"}else(n.length>=128||d===24||d===26)&&(l.push(...n),n=[],t=d===24||d===26?"text":"csi-pass");return Uint8Array.from(l)}}}function Fn(e){if(!e.every(a=>/^\d{1,3}$/.test(a)&&Number(a)<=255))return!1;const t=e.map(Number),n=Math.min(...t),r=Math.max(...t);return r-n<=20&&(r<=128||n>=192)}function Ii(){let e=!1,t=!1,n=!1;return{reset(){e=t=n=!1},map(r){const a=r.split(";"),o=[],l=()=>n?["22",...e?["1"]:[]]:["2"],d=i=>{n!==i&&t?(n=i,o.push(...l())):n=i};for(let i=0;i<a.length;i++){const u=a[i],m=/^48:2:(?::|0:)?(\d+):(\d+):(\d+)$/.exec(u);if(m){const k=Fn(m.slice(1));o.push(k?"48;5;237":u),d(k)}else if(["38","48","58"].includes(u)&&a[i+1]==="2"&&i+4<a.length){const k=u==="48"&&Fn(a.slice(i+2,i+5));o.push(...k?["48;5;237"]:a.slice(i,i+5)),u==="48"&&d(k),i+=4}else["38","48","58"].includes(u)&&a[i+1]==="5"&&i+2<a.length?(o.push(...a.slice(i,i+3)),u==="48"&&d(Number(a[i+2])>=232&&Number(a[i+2])<=239),i+=2):u==="2"?(t=!0,o.push(...n?l():[u])):(o.push(u),u==="0"||u===""?e=t=n=!1:u==="1"?e=!0:u==="22"?e=t=!1:(u==="49"||/^4\d$|^10\d$/.test(u))&&d(!1))}const c=o.join(";");return c===r?null:c}}}function Fi(e,t,{apple:n,programHasMouse:r}){if(r||!(n?e.metaKey:e.ctrlKey))return null;let a;try{a=new URL(t)}catch{return null}return a.protocol!=="http:"&&a.protocol!=="https:"?null:a.href}function Pi(e,t,n){const r=Fi(e,t,n);r&&window.open(r,"_blank","noopener,noreferrer")}const qe=[{final:"c"},{prefix:">",final:"c"},{final:"n"},{prefix:"?",final:"n"},{intermediates:"$",final:"p"},{prefix:"?",intermediates:"$",final:"p"}],Di=[{intermediates:"$",final:"q"}],Bi=new Set([12,2004,1004,1006,2031]);function zi(e){return e.split(";").includes("?")}const Ve=(e,t,n)=>e===null||e[0]>t||e[0]===t&&e[1]>=n,Rt=e=>{const t=e[0];return typeof t=="number"?t:Array.isArray(t)&&typeof t[0]=="number"?t[0]:0};function Oe(e,t){switch(e.kind){case"da":case"dsr":return!0;case"decdsr":return e.mode===996;case"decrqm-dec":return Ve(t,3,7)?!0:Ve(t,3,6)&&Bi.has(e.mode);case"decrqm-ansi":return Ve(t,3,7);case"decrqss":return Ve(t,3,6);case"osc":return e.data!=="?"?!1:e.ident===12?e.set:e.set||Ve(t,3,4);case"osc4":return Ve(t,3,3)&&e.asked.length>0&&e.asked.every(n=>e.set.has(n))}}function Hi(e){const t=e.split(";"),n=[],r=[];for(let a=0;a+1<t.length;a+=2){const o=Number(t[a]);!Number.isInteger(o)||o<0||o>255||(t[a+1]==="?"?n:r).push(o)}return{asked:n,set:r}}function $i(e){let t=null,n=null;const r=new Set,a={10:!1,11:!1,12:!1},o=(c,i)=>n?!n.has(c):i(),l=(c,i)=>e.registerCsiHandler(c,i),d=[l(qe[0],()=>o("da",()=>Oe({kind:"da"},t))),l(qe[1],()=>o("da",()=>Oe({kind:"da"},t))),l(qe[2],()=>o("dsr",()=>Oe({kind:"dsr"},t))),l(qe[3],c=>o("decdsr",()=>Oe({kind:"decdsr",mode:Rt(c)},t))),l(qe[4],c=>o("decrqm-ansi",()=>Oe({kind:"decrqm-ansi",mode:Rt(c)},t))),l(qe[5],c=>o("decrqm-dec",()=>Oe({kind:"decrqm-dec",mode:Rt(c)},t))),e.registerDcsHandler(Di[0],()=>o("decrqss",()=>Oe({kind:"decrqss"},t))),e.registerOscHandler(4,c=>{const{asked:i,set:u}=Hi(c);for(const m of u)r.add(m);return i.length>0&&o("osc4",()=>Oe({kind:"osc4",asked:i,set:r},t))}),...[10,11,12].map(c=>e.registerOscHandler(c,i=>zi(i)?o(`osc${c}`,()=>Oe({kind:"osc",ident:c,data:i,set:a[c]},t)):(a[c]=!0,!1))),e.registerOscHandler(104,c=>{if(c==="")r.clear();else for(const i of c.split(";"))r.delete(Number(i));return!1}),...[110,111,112].map(c=>e.registerOscHandler(c,()=>(a[c-100]=!1,!1)))];return{setTmux:c=>{t=c,n=null},setViewAnswers:c=>{n=c&&c.length>0?new Set(c):null},dispose:()=>{for(const c of d)c.dispose()}}}const Rs=13.3,Ki=1.2,Ui="--font-mono",Gi=120,Wi=1200,qi=250,Vi=64*1024,Pn=[400,800,1600,3200,5e3],Yi=12e4,Xi=250,Ji=15e3,Zi=400,Qi=18e4,el=4e3;function Ke(e){switch(e.kind){case"empty":return"empty";case"session":return`session:${e.ref.sessionId}`;case"launch":return`launch:${e.key}`}}function tl(){return typeof matchMedia=="function"&&matchMedia("(forced-colors: active)").matches}function nl(e){const t=e==null?void 0:e._core,n=t==null?void 0:t.coreService;n&&typeof n.isCursorInitialized=="boolean"&&(n.isCursorInitialized=!0)}function sl(e){const t=e==null?void 0:e._core;t&&(typeof t._keyDownSeen=="boolean"&&(t._keyDownSeen=!1),typeof t._keyPressHandled=="boolean"&&(t._keyPressHandled=!1))}const rl="";function al(e){return e==="\x1B[A"||e==="\x1B[B"?`\x1BO${e[2]}`:e}const ol=1e3;function il(e){const t=e==null?void 0:e.items;if(!t)return!1;for(let n=0;n<t.length;n++){const r=t[n];if(r&&r.kind==="file"&&r.type.startsWith("image/"))return!0}return!1}function ll(e){if(!e.hasSelection())return;const t=!!e.textarea&&document.activeElement===e.textarea;Gt(e.getSelection()).then(()=>{t&&document.activeElement!==e.textarea&&e.focus()})}const cl=async(e,t,n)=>{var C;const[{Terminal:r},{UnicodeGraphemesAddon:a},{WebLinksAddon:o}]=await Promise.all([Ze(()=>import("./xterm-4jYizCpg.js"),[]),Ze(()=>import("./addon-unicode-graphemes-DW3WJwyh.js"),[]),Ze(()=>import("./addon-web-links-BWjmmSgS.js"),[]),Ze(()=>Promise.resolve({}),__vite__mapDeps([0]))]),l=kt(Ge());let d=()=>!1;const c=(y,S)=>Pi(y,S,{apple:l,programHasMouse:d()}),i=new r({cols:t.cols,rows:t.rows,fontFamily:t.fontFamily,fontSize:t.fontSize??Rs,lineHeight:Ki,theme:t.theme,allowProposedApi:!0,customGlyphs:!0,cursorBlink:!Kt(),cursorStyle:"block",cursorInactiveStyle:"outline",minimumContrastRatio:hi,scrollback:1e4,smoothScrollDuration:0,screenReaderMode:!1,linkHandler:{activate:c,allowNonHttpProtocols:!1},macOptionClickForcesSelection:!0});i.loadAddon(new a),i.loadAddon(new o(c)),d=()=>i.modes.mouseTrackingMode!=="none",i.attachCustomWheelEventHandler(y=>d()||i.buffer.active.type!=="alternate"?!0:(y.preventDefault(),y.stopPropagation(),!1));const u=$i(i.parser);if(i.open(e),(C=i.textarea)==null||C.setAttribute("name","terminal-input"),nl(i),!tl())try{const{WebglAddon:y}=await Ze(async()=>{const{WebglAddon:z}=await import("./addon-webgl-CLK4R-_u.js");return{WebglAddon:z}},[]),S=new y;S.onContextLoss(()=>S.dispose()),i.loadAddon(S)}catch{}i.attachCustomKeyEventHandler(y=>{const S=n.onKey(y);return!S&&y.type==="keydown"&&(y.preventDefault(),ss(y,l)==="copy"&&ll(i)),S});const m=[i.onData(y=>n.onInput(y)),i.onBinary(y=>n.onBinary(y)),i.onRender(()=>n.onRender())];let k=-1/0;const b=y=>{y.button===1&&!y.shiftKey&&(k=performance.now())};e.addEventListener("mousedown",b,!0);const j=y=>{var Q;const S=((Q=y.clipboardData)==null?void 0:Q.getData("text/plain"))??"";y.preventDefault(),y.stopPropagation();const z=performance.now()-k<ol;if(k=-1/0,!(z&&d())){if(!S){il(y.clipboardData)&&(i.scrollToBottom(),n.onInput(rl));return}i.scrollToBottom(),n.onPaste(S)}};e.addEventListener("paste",j,!0);const R=y=>{In(y.dataTransfer)&&(y.preventDefault(),y.stopPropagation(),y.dataTransfer&&(y.dataTransfer.dropEffect="copy"))},h=y=>{var z;if(!In(y.dataTransfer))return;y.preventDefault(),y.stopPropagation();const S=y.dataTransfer&&Li(y.dataTransfer);if(!S){(z=n.onFileDropUnavailable)==null||z.call(n);return}i.focus(),i.scrollToBottom(),n.onPaste(S)};e.addEventListener("dragover",R,!0),e.addEventListener("drop",h,!0);const x=i.textarea,_=()=>n.onFocusChange(!0),T=()=>{sl(i),n.onFocusChange(!1)};return x==null||x.addEventListener("focus",_),x==null||x.addEventListener("blur",T),{get cols(){return i.cols},get rows(){return i.rows},write:(y,S)=>i.write(y,S),reset:()=>i.reset(),resize:(y,S)=>i.resize(y,S),setTheme:y=>{i.options.theme=y},tmuxVersion:y=>u.setTmux(y),viewAnswers:y=>u.setViewAnswers(y),focus:()=>i.focus(),blur:()=>i.blur(),hasFocus:()=>i.textarea!=null&&document.activeElement===i.textarea,applicationCursorKeys:()=>i.modes.applicationCursorKeysMode,scrollForInput:()=>{i.options.scrollOnUserInput!==!1&&i.scrollToBottom()},setFontSize:y=>{i.options.fontSize!==y&&(i.options.fontSize=y)},cell:()=>{var z;const y=(z=i.element)==null?void 0:z.querySelector(".xterm-screen");if(!y||!i.cols||!i.rows)return null;const S=y.getBoundingClientRect();return!S.width||!S.height?null:{w:S.width/i.cols,h:S.height/i.rows}},dispose:()=>{e.removeEventListener("paste",j,!0),e.removeEventListener("dragover",R,!0),e.removeEventListener("drop",h,!0),e.removeEventListener("mousedown",b,!0),x==null||x.removeEventListener("focus",_),x==null||x.removeEventListener("blur",T);for(const y of m)y.dispose();u.dispose(),i.dispose()}}},dl={api:{status:yo,open:vo,adopt:No,launch:Co},connect:Ai,mount:cl,now:()=>Date.now()},ul="board.session.pasteTooLarge",Dn=e=>e.ok===!1&&!("target"in e),Dt=e=>e.status===null||e.status===502||e.status===503||e.status===504,fl=e=>Dt(e)&&bs.includes(e.code??""),dt=e=>ao(e.code)?{kind:"error",message:e.error,code:e.code,busy:!1}:{kind:"error",message:e.error},hl=(e,t)=>(e==null?void 0:e.stage)===(t==null?void 0:t.stage)&&((e==null?void 0:e.stage)!=="downloading"||(t==null?void 0:t.stage)!=="downloading"||e.received===t.received&&e.total===t.total),ml="board.stage.panelStopped",gl="board.session.noReturn",pl="board.session.engineNoReturn",bl="board.session.noReturnWindows",wl="board.session.engineNoReturnWindows",Bn="board.session.notReopenable",yl="board.session.tmuxSetupSlow";function xl(e,t,n={}){const r=n.windows===!0;let a=0,o=!1,l={kind:"empty"},d=null,c=!1,i=null,u=!1,m=null,k=!1,b=null;const j=()=>{const g=xt(b==null?void 0:b.foreground),w=xt(b==null?void 0:b.background);return g&&w?{fg:g,bg:w}:void 0};let R=[],h=null,x="dock",_=!1,T={cols:80,rows:24},C=!1,y=null,S=null,z=null,Q=null,H=!1,Z=null,F=0,E={subject:"empty",phase:{kind:"empty"},keysOwner:"board",streaming:!1,cell:null};const ee=g=>{o||(E={...E,...g,subject:Ke(l)},t.onChange(E))},$=g=>ee({phase:g}),le=g=>{i?g(i):R.push(g)},te=()=>{var w;const g=i==null?void 0:i.cell();!g||E.cell&&E.cell.w===g.w&&E.cell.h===g.h||(ee({cell:g}),(w=t.onCell)==null||w.call(t,g))},Y=g=>{g!==null&&clearTimeout(g)},K=()=>{h==null||h.close(),h=null,Y(z),z=null,E.streaming&&ee({streaming:!1}),Y(S),S=null},G=()=>l.kind==="session"?l.ref:l.kind==="launch"?d:null,we=()=>l.kind==="launch"&&!d&&!c;let me=-1/0;const je=()=>{me=e.now()},Le=()=>{E.streaming||ee({streaming:!0}),Y(S),S=setTimeout(()=>{S=null,ee({streaming:!1})},Wi)},ye=(g,w)=>{var Ee;x="dock",_=!1,E.paneSize&&ee({paneSize:null}),le(q=>q.write("",()=>q.tmuxVersion(null)));let N=!0,P=0,U=0,J=null;const re=(q,se=!1)=>{w!==a||!N||(P+=q,(se||P-U>=Vi)&&(U=P,Se.sendAck(P)))},oe=Oi(),ce=l.kind==="launch"?l.agent==="codex":((Ee=G())==null?void 0:Ee.provider)==="codex",Re=q=>ce?oe.write(q):q,Se=e.connect({ticket:g,onHello:q=>{w===a&&(x=q.sizeOwner,_=q.readOnly)},onReset:({cols:q,rows:se,seed:he})=>{if(w!==a)return;oe.reset();const p=Re(he);le(L=>{L.write("",()=>{w===a&&(L.reset(),(L.cols!==q||L.rows!==se)&&L.resize(q,se))}),L.write(p,()=>{w!==a||!N||(re(he.byteLength,!0),F=0,Q=null,H=!1,Z=null,J===null&&(J=e.now()),ee({phase:{kind:"live",sizeOwner:x,readOnly:_},paneSize:x==="pane"?{cols:L.cols,rows:L.rows}:null}),te(),x==="dock"&&(L.cols!==T.cols||L.rows!==T.rows)&&ie())})})},onData:q=>{if(w!==a)return;e.now()-me>=qi&&Le();const se=Re(q);le(he=>he.write(se,()=>re(q.byteLength)))},onTmux:q=>{w===a&&le(se=>se.write("",()=>{w===a&&se.tmuxVersion(q)}))},onReplies:q=>{w===a&&le(se=>se.write("",()=>{w===a&&se.viewAnswers(q)}))},onSize:({cols:q,rows:se})=>{w===a&&le(he=>he.write("",()=>{w===a&&(he.resize(q,se),x==="pane"&&ee({paneSize:{cols:q,rows:se}}))}))},onExit:({reason:q,message:se,atOpen:he,exitStatus:p,exitSignal:L})=>{w===a&&(N=!1,h=null,E.streaming&&ee({streaming:!1}),q==="server-shutdown"?(Z=e.now(),B(w)):$(q==="ended"?he||E.phase.kind!=="live"?{kind:"ended",atOpen:!0}:ta({exitStatus:p,exitSignal:L},e.now()-(J??e.now()))?{kind:"ended",clean:!0}:{kind:"ended"}:q==="detached"?{kind:"detached"}:{kind:"error",message:se||I(ml)}))},onError:q=>{w===a&&(N=!1,h=null,q.kind==="lost"||E.phase.kind==="attaching"&&E.phase.reconnect?B(w):$({kind:"error",message:q.message}))}});h=Se,h.sendSize(T.cols,T.rows),b&&h.sendColours(b.foreground,b.background)},Ne=async(g,w)=>{if(r){$(w);return}const N=await e.api.status();g===a&&(N.ok&&!N.tmux.ok?xe(g,N.tmux,e.now()):$(w))},xe=(g,w,N)=>{if(w.reason!=="installing"){$({kind:"tmux-missing",reason:w.reason??"missing",...w.install?{install:w.install}:{},...w.download?{download:w.download}:{},busy:!1});return}if(e.now()-N>Qi){$({kind:"error",message:I(yl)});return}(E.phase.kind!=="tmux-installing"||!hl(E.phase.progress,w.progress))&&$({kind:"tmux-installing",...w.progress?{progress:w.progress}:{}}),Y(z),z=setTimeout(()=>{z=null,!(g!==a||o)&&e.api.status().then(P=>{if(g===a)if(P.ok&&P.tmux.ok)$(we()&&l.kind==="launch"?{kind:"starting",agent:l.agent,cwd:l.cwd}:{kind:"attaching",reconnect:!1}),ve(g);else if(P.ok)xe(g,P.tmux,N);else if(Dt(P)){const U=E.phase.kind==="tmux-installing"?E.phase.progress:void 0;xe(g,{reason:"installing",...U?{progress:U}:{}},N)}else $(dt(P))})},Zi)},ve=g=>{const w=G();we()&&l.kind==="launch"?A(l.agent,l.cwd,l.key,g,l.options):w?fe(w,g,!1):$({kind:"empty"})},fe=async(g,w,N)=>{const P=await e.api.open(g,{},{...T},j());w===a&&await M(P,w,N)},be=(g,w)=>{$(g),v(w)},v=g=>{Y(z),z=setTimeout(()=>{if(z=null,g!==a||o)return;const w=E.phase;if(w.kind!=="not-attachable"||!w.stillRunning)return;const N=G(),P=typeof document<"u"&&document.visibilityState==="hidden";if(!N||P||w.busy){v(g);return}e.api.open(N,{},{...T},j()).then(U=>{if(g!==a||o)return;const J=E.phase;if(!(J.kind!=="not-attachable"||!J.stillRunning||J.busy)){if(Dn(U)||!U.ok&&U.target.kind==="C"){v(g);return}M(U,g,!1)}})},el)},M=async(g,w,N)=>{if(g.ok){ye(g.ticket,w);return}if(Dn(g)){if(N&&Dt(g)||fl(g)){B(w,g);return}$(dt(g));return}if(g.target.kind==="unsupported"){await Ne(w,{kind:"error",message:g.target.reason==="uncertain"?I("board.stage.identityUncertain"):g.target.label});return}const P={kind:"not-attachable",target:g.target,stillRunning:g.target.kind==="C",busy:!1};P.stillRunning?be(P,w):$(P)},A=async(g,w,N,P,U)=>{var oe;const J=j(),re=await e.api.launch({agent:g,cwd:w,key:N,size:{...T},...U?{launch:U}:{},...J?{colours:J}:{}});if(P===a){if(!re.ok){re.status===409&&!re.code?await Ne(P,{kind:"error",message:re.error}):$(dt(re));return}c=!0,re.sessionId&&(d={sessionId:re.sessionId,provider:g,cwd:w}),(oe=t.onLaunched)==null||oe.call(t,{agent:g,cwd:w,sessionId:re.sessionId,name:re.name}),ye(re.ticket,P)}},D=(g=!1)=>{a+=1;const w=a;if(K(),l.kind==="empty"){$({kind:"empty"});return}if(we()&&l.kind==="launch"){$({kind:"starting",agent:l.agent,cwd:l.cwd}),A(l.agent,l.cwd,l.key,w,l.options);return}const N=G();if(!N){$({kind:"error",message:I(Bn)});return}$({kind:"attaching",reconnect:g}),fe(N,w,g)},B=(g,w)=>{if(g!==a||o)return;const N=e.now();if(w&&(H=!!w.code),Q??=N,N-Q>Yi){Q=null,F=0;const re=I(H?r?wl:pl:r?bl:gl);$({kind:"error",message:re}),H=!1;return}const P=na(E.phase)?{kind:"attaching",reconnect:!0}:{kind:"attaching",reconnect:!1};(E.phase.kind!=="attaching"||E.phase.reconnect!==P.reconnect)&&$(P);const J=Z!==null&&N-Z<Ji?Xi:Pn[Math.min(F,Pn.length-1)];F+=1,Y(z),z=setTimeout(()=>{if(z=null,g!==a||o)return;a+=1;const re=a,oe=G();if(!oe){$({kind:"error",message:I(Bn)});return}fe(oe,re,!0)},J)};function ie(){Y(y),y=null,!(!h||x==="pane")&&(i&&E.phase.kind==="live"&&(i.cols!==T.cols||i.rows!==T.rows)&&i.resize(T.cols,T.rows),h.sendSize(T.cols,T.rows))}const ae={onInput:g=>{E.phase.kind==="live"&&(je(),h==null||h.sendInput(g))},onBinary:g=>{if(E.phase.kind!=="live")return;je();const w=new Uint8Array(g.length);for(let N=0;N<g.length;N++)w[N]=g.charCodeAt(N)&255;h==null||h.sendInput(w)},onPaste:g=>{var w;E.phase.kind!=="live"||!h||(je(),!h.sendPaste(g)&&Pt(g)&&((w=t.onNotice)==null||w.call(t,I(ul))))},onFileDropUnavailable:()=>{var g;return(g=t.onNotice)==null?void 0:g.call(t,I("board.drop.pathsUnavailable"))},onKey:g=>{const w=ss(g);if(w==="pass")return!0;if(w==="zoom"){const P=g.type==="keydown"?Ys(g):null;return P&&rs(P),!1}const N=g.type==="keydown"&&E.phase.kind==="live"?Xs(g,w):null;return N&&(je(),h==null||h.sendInput(N)),!1},onFocusChange:g=>{const w=g?"pane":"board";w!==E.keysOwner&&ee({keysOwner:w})},onRender:()=>{E.cell&&!k||(k=!1,te())}};return{mount(g,w){if(i||u||o)return;u=!0;const N=m??w.theme;b||(b=N),e.mount(g,{...w,theme:N,cols:T.cols,rows:T.rows},ae).then(P=>{if(u=!1,o){P.dispose();return}i=P,m&&P.setTheme(m),m=null;const U=R;R=[];for(const J of U)J(P);te()},()=>{u=!1,o||$({kind:"error",message:I("board.session.loadFailed")})})},show(g){if(!o){if(g.kind==="session"&&l.kind==="launch"&&(d&&g.ref.sessionId===d.sessionId||c&&g.launch===l.key)){l=g,d=null,c=!1,ee({});return}Ke(g)!==Ke(l)&&(l=g,d=null,c=!1,R=[],F=0,Q=null,H=!1,D())}},resize(g,w,N){g>0&&w>0&&(T={cols:Math.floor(g),rows:Math.floor(w)},C=N,Y(y),y=null,!C&&(y=setTimeout(ie,Gi)))},setFontSize(g){o||le(w=>{w.setFontSize(g),k=!0,te()})},setTheme(g){i?i.setTheme(g):m=g,b=g,h==null||h.sendColours(g.foreground,g.background)},adopt(){const g=G(),w=E.phase;if(!g||o||w.kind!=="not-attachable"&&w.kind!=="ended"&&w.kind!=="detached"||w.kind==="not-attachable"&&w.busy)return;a+=1;const N=a;if(K(),w.kind==="not-attachable"?$({...w,busy:!0}):$({kind:"attaching",reconnect:!0}),w.kind==="not-attachable"&&w.stillRunning){fe(g,N,!1);return}e.api.adopt(g,{},{...T},j()).then(P=>{if(N===a){if(P.ok){ye(P.ticket,N);return}if(P.error===oo&&w.kind==="not-attachable"){be({...w,stillRunning:!0,busy:!1},N);return}$(dt(P))}})},retry(){if(o)return;const g=E.phase,w=g.kind==="tmux-missing"||g.kind==="error"&&!!g.code;if(w&&g.busy)return;if(F=0,Q=null,H=!1,!w){D(!1);return}a+=1;const N=a;K(),$({...g,busy:!0}),ve(N)},focus(){i==null||i.focus()},type(g){const w=[...g];for(let N=0;N<w.length;N++)w[N]==="\x1B"&&N+1<w.length?ae.onInput(w[N]+w[++N]):ae.onInput(w[N])},sendPrompt(g,w){const N=h,P=a,U=()=>!o&&a===P&&h===N&&Ke(l)===w&&E.subject===w&&E.phase.kind==="live"&&!E.phase.readOnly&&!_;if(!N||!U())return"unavailable";if(!g.trim())return"empty";if(Pt(g))return"too-large";let J=!1;try{return je(),!U()||!N.sendPaste(g)?"unavailable":(J=!0,U()&&N.sendInput("\r")?"sent":"partial")}catch{return J?"partial":"unavailable"}},press(g,w){const N=w??(i==null?void 0:i.hasFocus())===!0;ae.onInput(i!=null&&i.applicationCursorKeys()?al(g):g),i==null||i.scrollForInput(),N&&(i==null||i.focus())},holdsFocus(){return(i==null?void 0:i.hasFocus())===!0},release(){i==null||i.blur()},dispose(){o||(a+=1,K(),Y(y),o=!0,R=[],i==null||i.dispose(),i=null)},snapshot:()=>E}}const kl={subject:"empty",phase:{kind:"empty"},keysOwner:"board",streaming:!1,cell:null};function vl(e){const t=f.useRef(null),n=f.useRef(e);n.current=e;const r=f.useRef(null),[a,o]=f.useState(kl);f.useEffect(()=>{const h=n.current,x=xl({...dl,...h.deps},{onChange:o,onCell:_=>{var T,C;return(C=(T=n.current).onCell)==null?void 0:C.call(T,_)},onLaunched:_=>{var T,C;return(C=(T=n.current).onLaunched)==null?void 0:C.call(T,_)},onNotice:_=>{var T,C;return(C=(T=n.current).onNotice)==null?void 0:C.call(T,_)}},{windows:h.windows===!0});return r.current=x,x.resize(h.cols,h.rows,!!h.holdResize),x.setTheme(h.theme),t.current&&x.mount(t.current,{theme:h.theme,fontFamily:h.fontFamily,fontSize:h.fontSize}),x.show(h.subject),()=>{x.dispose(),r.current=null}},[]);const l=Ke(e.subject);f.useEffect(()=>{var h;(h=r.current)==null||h.show(n.current.subject)},[l]),f.useEffect(()=>{var h;(h=r.current)==null||h.resize(e.cols,e.rows,!!e.holdResize)},[e.cols,e.rows,e.holdResize]),f.useEffect(()=>{var h;(h=r.current)==null||h.setTheme(e.theme)},[e.theme]);const d=f.useRef(e.fontSize);f.useEffect(()=>{var h;e.fontSize!==d.current&&(d.current=e.fontSize,(h=r.current)==null||h.setFontSize(e.fontSize??Rs))},[e.fontSize]);const c=f.useCallback(()=>{var h;return(h=r.current)==null?void 0:h.adopt()},[]),i=f.useCallback(()=>{var h;return(h=r.current)==null?void 0:h.retry()},[]),u=f.useCallback(()=>{var h;return(h=r.current)==null?void 0:h.focus()},[]),m=f.useCallback(h=>{var x;return(x=r.current)==null?void 0:x.type(h)},[]),k=f.useCallback((h,x)=>{const _=r.current;return!_||x!==Ke(n.current.subject)?"unavailable":_.sendPrompt(h,x)},[]),b=f.useCallback((h,x)=>{var _;return(_=r.current)==null?void 0:_.press(h,x)},[]),j=f.useCallback(()=>{var h;return((h=r.current)==null?void 0:h.holdsFocus())===!0},[]),R=f.useCallback(()=>{var h;return(h=r.current)==null?void 0:h.release()},[]);return{...a,hostRef:t,adopt:c,retry:i,focus:u,type:m,sendPrompt:k,press:b,holdsFocus:j,release:R}}const zn="ts-text-size",Hn="ts-text-size-pop",_t="ts-text-size-title",Sl=e=>e.replace(/ /g," ").replace(/\+/g,"+");function jl({size:e}){const t=de(),[n,r]=f.useState(!1),a=f.useRef(null),o=f.useRef(null),l=as(e.step),d=os(e.step),c=(b,j)=>{j&&e.onStep(b)},i=t("board.stage.textSize"),u=Ft(e.step),m=e.step!==ln,k=t("board.stage.textSizeTip",{percent:u});return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",id:zn,className:"glyph-btn","aria-label":i,title:k,"aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?Hn:void 0,"data-changed":m||void 0,onClick:()=>r(b=>!b),children:s.jsx(Ce,{name:"text-size",className:"ts-icon"})}),n&&s.jsxs(Ut,{anchorId:zn,id:Hn,className:"ap-pop ts-text-pop",role:"dialog",labelledBy:_t,focusRef:l?a:o,onClose:()=>r(!1),children:[s.jsx("p",{className:"ts-text-title",id:_t,children:i}),s.jsxs("div",{className:"ts-text-step",role:"group","aria-labelledby":_t,children:[s.jsx("button",{ref:a,type:"button",className:"glyph-btn","aria-label":t("board.stage.textSmaller"),title:t("board.stage.textSmaller"),"aria-disabled":!l||void 0,onClick:()=>c("smaller",l),children:s.jsx(Ce,{name:"minus",className:"ts-icon"})}),s.jsx("output",{className:"ts-text-pct","aria-live":"polite",children:u}),s.jsx("button",{ref:o,type:"button",className:"glyph-btn","aria-label":t("board.stage.textLarger"),title:t("board.stage.textLarger"),"aria-disabled":!d||void 0,onClick:()=>c("larger",d),children:s.jsx(Ce,{name:"plus",className:"ts-icon"})})]}),s.jsx("button",{type:"button",className:"btn ts-text-reset","aria-disabled":!m||void 0,onClick:()=>c("reset",m),children:t("board.stage.textReset",{percent:Ft(ln)})}),s.jsx("p",{className:"ts-text-keys",children:t("board.stage.textKeys",{keys:Sl(Js(t("board.stage.textKeyCtrl")))})})]})]})}function Nl({pane:e}){const n=de()(e.active?"board.stage.split.activePane":"board.stage.split.paneNumber",{number:e.number});return s.jsxs("span",{className:"pane-badge","data-active":e.active||void 0,title:n,children:[s.jsx("span",{className:"vis-hidden",children:n}),s.jsx("span",{"aria-hidden":"true",children:e.number})]})}function El(e){if(e.id==="close")return e.label;if(e.label===I(Xt))return I("board.stage.fullScreenShort");const t=e.label.indexOf(" — ");return t>0?e.label.slice(0,t):e.label}function Tl({items:e,compact:t=!1}){const n=de(),a=`ts-more-${f.useId()}`,o=`${a}-menu`,[l,d]=f.useState(null),c=l!==null,i=n("board.rail.more");return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",id:a,className:t?"glyph-btn ts-more ts-compact-more":"glyph-btn ts-more","aria-label":i,title:i,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?o:void 0,onKeyDown:u=>{u.key!=="ArrowDown"&&u.key!=="ArrowUp"||(u.preventDefault(),d(u.key==="ArrowUp"?"last":"first"))},onClick:()=>d(c?null:"first"),children:s.jsxs("svg",{className:"ts-icon",width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":"true",children:[s.jsx("circle",{cx:"2.8",cy:"7",r:"0.7"}),s.jsx("circle",{cx:"7",cy:"7",r:"0.7"}),s.jsx("circle",{cx:"11.2",cy:"7",r:"0.7"})]})}),c&&s.jsx(Ut,{anchorId:a,id:o,className:"ap-pop dock-more-pop",role:"menu",labelledBy:a,start:l,onClose:()=>d(null),children:e.map(u=>s.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>{var m;(m=document.getElementById(a))==null||m.focus(),d(null),window.requestAnimationFrame(u.run)},children:El(u)},u.id))})]})}const $n="board.stage.closeLabel",Cl="board.stage.closeEmptyLabel",Kn="board.stage.backEmptyLabel",Al="board.stage.backLabel",Rl="board.stage.zoomLabel",_l="board.stage.zoomOffLabel",Ll="board.stage.paneCloseLabel";function _s(e){const t=[e.tool,e.arg,e.seconds].filter(n=>!!n);return t.length?t.join(" · "):null}const Ml=new Set(["working","idle","ready","none"]);function Ol(e){return Ml.has(e.state)||!e.phrase?null:e.emphasis?`${e.phrase} ${e.emphasis}`:e.phrase}function Un(e){const t=e.emphasis?`${e.phrase} ${e.emphasis}`:e.phrase,n=_s(e);return n?`${t} · ${n}`:t}function Il(e,t,n){return e?n?I(Ls):I("board.stage.giveRoomBack"):t?I(Xt):I("board.stage.giveWidth")}function Fl(e,t,n){return e?n?I(Ls):I(_l):t?I(Xt):I(Rl)}const Xt="board.stage.fullLabel",Pl="board.stage.split.maximize",Dl="board.stage.split.restore",Ls="board.stage.fullLeaveLabel";function Bl(e){const t=de(),{status:n}=e,r=e.context&&e.context.used>0?e.context:null,a=r!=null&&r.window>0,o=r?a?Ft(Zs(r.used,r.window)):Qs(r.used):"",l=r?t("board.stage.contextShort",{pct:er(r.used,r.window)}):"",d=Ho(n.state),c=Ol(n),i=_s(n),u=e.keysOwner==="pane",m=t("board.stage.typeInto"),k=u?t("board.stage.keysBack",{chord:e.chordLabel}):t("board.stage.typeIntoTip",{label:m}),b=e.workspace==="pane",j=e.split?t(e.expanded?Dl:Pl):b?Fl(e.expanded,e.canFull===!0,e.full===!0):Il(e.expanded,e.canFull===!0,e.full===!0),R=t(e.workspace==="empty"?Kn:e.workspace==="pane"?e.nothingRunning?Ll:$n:e.nothingRunning?Cl:$n),h=t(e.nothingRunning?Kn:Al),x=e.rename??null,_=t("board.rename.action");return s.jsxs("header",{className:"ts-head",draggable:e.onDragHead&&!(x!=null&&x.on)?!0:void 0,onDragStart:e.onDragHead&&!(x!=null&&x.on)?T=>{var C,y,S;if((y=(C=T.target)==null?void 0:C.closest)!=null&&y.call(C,"button, input, [role=menu]")){T.preventDefault();return}(S=e.onDragHead)==null||S.call(e,T)}:void 0,children:[e.takeover&&s.jsx("button",{type:"button",className:"glyph-btn","aria-label":h,title:h,onClick:e.onClose,children:s.jsx(Wo,{})}),s.jsxs("div",{className:"ts-id",children:[e.paneLink&&s.jsx(Nl,{pane:e.paneLink}),e.workspace&&e.provider?s.jsx(tr,{provider:e.provider}):d&&s.jsx(Ue,{kind:d}),x!=null&&x.on?s.jsx(nr,{facts:x.facts,place:"header",onDone:x.done}):s.jsx("h2",{className:"ts-name","data-renamable":x?"":void 0,onDoubleClick:x==null?void 0:x.start,children:e.name}),x&&!x.on&&s.jsx("button",{ref:x.back,type:"button",className:"glyph-btn ts-rename","aria-label":_,title:t("board.rename.tip"),onClick:x.start,children:s.jsx(sr,{})}),e.provider&&!e.workspace&&s.jsx("span",{className:"vis-hidden",children:qt(e.provider)}),c?s.jsxs("div",{className:"ts-meta","data-state":n.state,title:i?Un(n):void 0,children:[s.jsx("span",{className:"ts-meta-state",children:c}),i&&s.jsxs("span",{className:"vis-hidden",children:[" · ",i]})]}):n.phrase?s.jsx("span",{className:"vis-hidden",children:Un(n)}):null]},e.identity),r&&s.jsxs("span",{className:"ts-ctxchip",role:"img","aria-label":l,title:l,children:[a&&s.jsx(rr,{fill:ar(r.used,r.window)/100}),s.jsx("span",{className:"ts-ctxpct",children:o}),s.jsx("span",{className:"ts-ctxshort",children:t("board.stage.contextShort",{pct:o})})]}),e.view&&s.jsx("div",{className:"view-switch",role:"group","aria-label":t("board.stage.view"),children:["chat","term"].map(T=>s.jsx("button",{type:"button",className:"view-opt","aria-pressed":e.view.current===T,onClick:()=>e.view.onChange(T),children:t(T==="chat"?"board.stage.viewChat":"board.stage.viewTerm")},T))}),(e.takeover||e.workspace==="pane")&&s.jsx(Tl,{compact:!e.takeover,items:[...x?[{id:"rename",label:_,run:x.start}]:[],...e.canType?[{id:"keys",label:m,run:e.onKeys}]:[],...(e.canFull||e.split)&&e.workspace!=="empty"?[{id:"expand",label:j,run:e.onExpand}]:[],...e.textSize&&os(e.textSize.step)?[{id:"text-larger",label:t("board.stage.textLarger"),run:()=>{var T;return(T=e.textSize)==null?void 0:T.onStep("larger")}}]:[],...e.textSize&&as(e.textSize.step)?[{id:"text-smaller",label:t("board.stage.textSmaller"),run:()=>{var T;return(T=e.textSize)==null?void 0:T.onStep("smaller")}}]:[],{id:"close",label:R,run:e.onClose}]}),s.jsx("div",{className:"ts-ctl",children:s.jsxs("div",{className:"ts-tools",children:[e.textSize&&s.jsx(jl,{size:e.textSize}),e.canType&&s.jsx("button",{type:"button",className:"glyph-btn","aria-pressed":u,"aria-label":m,"aria-keyshortcuts":u?"Control+Shift+X":void 0,title:k,onMouseDown:T=>T.preventDefault(),onClick:e.onKeys,children:s.jsx($o,{})}),(!e.takeover||e.canFull)&&e.workspace!=="empty"&&s.jsx("button",{type:"button",className:"glyph-btn","aria-label":j,title:j,"aria-pressed":b?e.expanded:void 0,"data-zoom":b||void 0,onMouseDown:T=>T.preventDefault(),onClick:e.onExpand,children:e.expanded&&!b?s.jsx(Uo,{}):s.jsx(Ko,{})}),s.jsx("button",{type:"button",className:"glyph-btn","data-stage-close":!0,"aria-label":R,title:R,onClick:e.onClose,children:s.jsx(Go,{})})]})}),s.jsx("div",{className:"ts-scan","aria-hidden":"true"})]})}const zl=900,Hl=["not-installed","not-verified","unsafe-folder","unsupported","failed"],$l=e=>Hl.includes(e??"");function Ye({items:e}){return s.jsx("ol",{className:"ts-eng-steps",children:e.map(t=>s.jsxs("li",{className:"ts-eng-step","data-state":t.state,children:[s.jsxs("span",{className:"ts-eng-mark","aria-hidden":"true",children:[t.state==="done"&&s.jsx(Tt,{name:"done",size:14}),t.state==="now"&&s.jsx(Tt,{name:"working",size:14}),t.state==="fail"&&s.jsx(Tt,{name:"error",size:14}),t.state==="todo"&&s.jsx("i",{className:"ts-eng-ring"})]}),s.jsx("span",{children:t.label}),t.aside&&s.jsx("span",{className:"ts-eng-aside",children:t.aside})]},t.label))})}function ge({glyph:e,title:t,tone:n}){return s.jsxs("div",{className:"ts-eng-head",children:[s.jsx("span",{className:"ts-eng-chip","data-tone":n,"aria-hidden":"true",children:e==="alert"?s.jsx(Ce,{name:"info",className:"ts-eng-alert"}):s.jsx(Ce,{name:e})}),s.jsx("h3",{className:"ts-eng-title",children:t})]})}function Kl(e,t){return t<60?e("board.engine.leftSeconds",{n:String(Math.max(1,Math.round(t)))}):e("board.engine.leftMinutes",{n:String(Math.round(t/60))})}function Gn(e,t,n,r){const a=[n?e("board.stage.setupProgress",{received:_e(t),total:_e(n)}):e("board.stage.setupReceived",{received:_e(t)})];return r&&r>0&&(a.push(e("board.engine.speed",{speed:_e(r)})),n&&n>t&&a.push(Kl(e,(n-t)/r))),a.join(" · ")}function Ul(e,t,n){var a,o;const r=[`platform: ${(e==null?void 0:e.platform)??"unknown"}`,`ccdeck: ${(e==null?void 0:e.app)??"unknown"}`];return r.push(`engine pinned: ${(e==null?void 0:e.pinned)??"none"}`,`engine installed: ${((a=e==null?void 0:e.installed)==null?void 0:a.version)??"none"}`),(t.state==="check"||t.state==="failed")&&r.push(`step: ${t.step}`),t.state==="check"&&r.push(`code: ${t.code}`),n&&r.push(`refusal: ${n}`),((o=e==null?void 0:e.last)==null?void 0:o.outcome)==="failed"&&r.push(`last: ${e.last.code} at ${e.last.step}`),r.join(`
|
|
4
|
-
`)}function Lt({share:e,label:t,line:n,tone:r}){return s.jsxs("div",{className:"ts-eng-progress",children:[s.jsx("div",{className:"ts-setup-bar ts-eng-bar","data-tone":r,role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e==null?void 0:Math.round(e*100),"aria-valuetext":n,"data-unknown":e==null||void 0,children:s.jsx("i",{className:"ts-setup-fill",style:e==null?void 0:{transform:`scaleX(${e})`}})}),s.jsx("span",{className:"ts-eng-line",children:n})]})}function Gl(e){const t=de(),n=or(!0),[r,a]=f.useState(!1),[o,l]=f.useState(null),d=f.useRef(null),c=ir({status:n.status,code:e.code,mine:n.mine,watched:n.watched,retried:r}),{onRetry:i}=e,u=c.state==="ready"||c.state==="recovered";lr(u&&!r,zl,()=>{a(!0),i()});const m=c.state==="offline",{install:k}=n;f.useEffect(()=>{if(!m)return;const y=()=>{k()},S=setInterval(y,cr);return window.addEventListener("online",y),()=>{clearInterval(S),window.removeEventListener("online",y)}},[m,k]);const b=n.status??null,j=dr((b==null?void 0:b.platform)??""),R=async(y,S)=>{await Gt(S)&&(l(y),setTimeout(()=>l(null),1500))},h=s.jsx("button",{type:"button",className:"btn ts-eng-back",onClick:e.onNotNow,children:t("board.engine.back")}),x=(y=!1)=>s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:y?"btn primary":"btn","aria-busy":n.pending||void 0,onClick:()=>{var S;return(S=d.current)==null?void 0:S.click()},children:t("board.engine.installFile")}),s.jsx("input",{ref:d,type:"file",hidden:!0,accept:".tgz,application/gzip,application/x-gzip,application/octet-stream",onChange:S=>{var Q;const z=(Q=S.currentTarget.files)==null?void 0:Q[0];S.currentTarget.value="",z&&n.installFile(z)}})]}),_=(y,S=!0)=>s.jsx("button",{type:"button",className:S?"btn primary":"btn","data-stage-land":!0,"aria-busy":n.pending||e.busy||void 0,onClick:y,children:t("board.stage.tryAgain")}),T=s.jsx("button",{type:"button",className:"btn",onClick:()=>{R("details",Ul(n.status,c,e.code))},children:t(o==="details"?"board.stage.copied":"board.engine.copyDetails")});let C;switch(c.state){case"plain":return s.jsx(s.Fragment,{children:e.plain});case"checking":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.checkingTitle")}),s.jsx(Ye,{items:[{label:t("board.engine.checkingLine"),state:"now"}]})]});break;case"ask":{const y=(b==null?void 0:b.pinned)??"";C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.askTitle")}),s.jsx("p",{className:"ts-eng-text",children:c.download?t("board.engine.askBody",{app:(b==null?void 0:b.app)??"",platform:j,version:y}):t("board.engine.askBodyFile",{app:(b==null?void 0:b.app)??"",platform:j})}),n.refused&&s.jsx("p",{className:"ts-eng-said",role:"status",children:t("board.engine.refused")}),s.jsxs("div",{className:"ts-eng-acts",children:[c.download&&s.jsx("button",{type:"button",className:"btn primary","data-stage-land":!0,"aria-busy":n.pending||void 0,onClick:()=>{n.install()},children:t("board.engine.install")}),c.file&&x(!c.download),h]}),s.jsx("p",{className:"ts-eng-note",children:c.downloadOff?t("board.engine.downloadOff"):c.download?t("board.engine.askNote"):t("board.engine.fileNote")})]});break}case"downloading":{const{job:y}=c,S=y.total?Math.min(1,y.received/y.total):null;C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.downloadingTitle")}),s.jsx(Lt,{share:S,label:t("board.engine.downloadingTitle"),line:Gn(t,y.received,y.total,n.speed)}),s.jsx(Ye,{items:[{label:t("board.engine.stepDownload"),state:"now",...S==null?{}:{aside:`${Math.round(S*100)}%`}},{label:t("board.engine.stepVerify"),state:"todo"},{label:t("board.engine.stepInstall"),state:"todo"},{label:t("board.engine.stepStart"),state:"todo"}]}),s.jsx("div",{className:"ts-eng-acts",children:s.jsx("button",{type:"button",className:"btn","data-stage-land":!0,"aria-busy":n.pending||void 0,onClick:()=>{n.cancel()},children:t("common.cancel")})})]});break}case"verifying":{const{job:y}=c,S=y.phase==="installing";C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t(S?"board.engine.installingTitle":"board.engine.verifyingTitle")}),s.jsx("p",{className:"ts-eng-line",children:y.source==="file"?t("board.engine.fromFile"):t("board.engine.downloaded",{size:_e(y.received)})}),s.jsx(Ye,{items:[{label:t("board.engine.stepDownload"),state:"done",...y.received?{aside:`${_e(y.received)} MB`}:{}},{label:t("board.engine.stepSignature"),state:S?"done":"now"},{label:t("board.engine.stepPlatform"),state:S?"done":"todo"},{label:t("board.engine.stepInstall"),state:S?"now":"todo"}]})]});break}case"ready":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.readyTitle")}),s.jsx("p",{className:"ts-eng-text",role:"status",children:t("board.engine.readyBody",{version:c.version??""})}),s.jsx(Ye,{items:[{label:t("board.engine.stepDownload"),state:"done"},{label:t("board.engine.stepSignature"),state:"done"},{label:t("board.engine.stepPlatform"),state:"done"},{label:t("board.engine.stepInstall"),state:"done",aside:t("board.engine.inDataFolder")}]})]});break;case"offline":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"alert",tone:"danger",title:t("board.engine.offlineTitle")}),s.jsx("p",{className:"ts-eng-text",children:c.received>0&&c.total?t("board.engine.offlineBody",{received:_e(c.received),total:_e(c.total)}):t("board.engine.offlineBodyNone")}),c.received>0&&c.total?s.jsx(Lt,{tone:"danger",share:Math.min(1,c.received/c.total),label:t("board.engine.offlineTitle"),line:t("board.engine.stoppedAt",{received:_e(c.received),total:_e(c.total)})}):null,s.jsxs("div",{className:"ts-eng-acts",children:[_(()=>{n.install()}),(b==null?void 0:b.canInstallFile)&&x(),h]}),s.jsx("p",{className:"ts-eng-note",children:t("board.engine.offlineNote")})]});break;case"permission":{const y=c.fixPath?`sudo chown -R "$(id -un)" ${c.fixPath}`:null;C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"lock",tone:"danger",title:t("board.engine.permissionTitle")}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.permissionBody")}),s.jsxs("div",{className:"ts-eng-acts",children:[_(()=>{n.install()}),y&&s.jsx("button",{type:"button",className:"btn",onClick:()=>{R("fix",y)},children:t(o==="fix"?"board.stage.copied":"board.engine.copyFix")}),h]}),y&&s.jsx("p",{className:"ts-eng-note",children:t("board.engine.permissionNote")})]});break}case"unsupported":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.unsupportedTitle",{platform:j})}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.unsupportedBody")}),s.jsx("div",{className:"ts-eng-acts",children:h}),s.jsx("p",{className:"ts-eng-note",children:t("board.engine.unsupportedNote")})]});break;case"unavailable":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.unavailableTitle")}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.unavailableBody",{platform:j})}),s.jsxs("div",{className:"ts-eng-acts",children:[c.file&&x(),h]})]});break;case"check":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"warning",tone:"danger",title:t("board.engine.checkTitle")}),s.jsx("p",{className:"ts-eng-text",children:t(c.code==="wrong-machine"?"board.engine.wrongMachineBody":c.code==="downgrade"?"board.engine.downgradeBody":"board.engine.checkBody")}),s.jsx(Ye,{items:[{label:t("board.engine.stepDownload"),state:"done"},{label:t("board.engine.stepSignature"),state:"fail",aside:t("board.engine.noMatch")},{label:t("board.engine.stepInstall"),state:"todo"},{label:t("board.engine.stepStart"),state:"todo"}]}),s.jsxs("div",{className:"ts-eng-acts",children:[_(()=>{n.install()}),T,h]}),s.jsx("p",{className:"ts-eng-note",children:t("board.engine.checkNote")})]});break;case"folder":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"lock",tone:"danger",title:t("board.engine.folderTitle")}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.folderBody")}),s.jsxs("div",{className:"ts-eng-acts",children:[_(c.install?()=>{n.install()}:i),h]})]});break;case"update":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"update",title:t("board.engine.updateTitle")}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.updateBody",{installed:c.installed,app:(b==null?void 0:b.app)??"",pinned:c.pinned})}),s.jsxs("div",{className:"ts-eng-acts",children:[c.download&&s.jsx("button",{type:"button",className:"btn primary","data-stage-land":!0,"aria-busy":n.pending||void 0,onClick:()=>{n.install()},children:t("board.engine.installUpdate")}),c.file&&x(!c.download),h]}),s.jsx("p",{className:"ts-eng-note",children:t("board.engine.updateNote",{pinned:c.pinned})})]});break;case"elsewhere":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.elsewhereTitle")}),s.jsx("p",{className:"ts-eng-text",role:"status",children:t("board.engine.elsewhereBody")}),c.job&&c.job.phase==="downloading"&&s.jsx(Lt,{share:c.job.total?Math.min(1,c.job.received/c.job.total):null,label:t("board.engine.elsewhereTitle"),line:Gn(t,c.job.received,c.job.total,null)}),s.jsx("div",{className:"ts-eng-acts",children:h})]});break;case"recovered":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"terminal",title:t("board.engine.recoveredTitle")}),s.jsx("p",{className:"ts-eng-text",role:"status",children:t("board.engine.recoveredBody")}),s.jsx(Ye,{items:[{label:t("board.engine.stepPartial"),state:"done"},{label:t("board.engine.stepInPlace"),state:"now",aside:c.version},{label:t("board.engine.stepStart"),state:"todo"}]})]});break;case"start-failed":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"warning",tone:"danger",title:t("board.engine.startFailedTitle")}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.startFailedBody")}),s.jsxs("div",{className:"ts-eng-acts",children:[_(i),T,h]}),s.jsx("p",{className:"ts-eng-note",children:t("board.engine.startFailedNote")})]});break;case"no-space":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"warning",tone:"danger",title:t("board.engine.spaceTitle")}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.spaceBody")}),s.jsxs("div",{className:"ts-eng-acts",children:[_(()=>{n.install()}),h]})]});break;case"failed":C=s.jsxs(s.Fragment,{children:[s.jsx(ge,{glyph:"warning",tone:"danger",title:t("board.engine.failedTitle")}),s.jsx("p",{className:"ts-eng-text",children:t("board.engine.failedBody")}),s.jsxs("div",{className:"ts-eng-acts",children:[_(()=>{n.install()}),T,h]})]});break}return s.jsx("div",{className:"ts-card ts-engine","data-engine":c.state,children:s.jsx("div",{className:"ts-eng",children:C})})}const Wl="agent-dag.chat",ql="agent-dag.decision",Vl={chat:!1,decision:!1};function Yl(e=ur){return{chat:e(Wl)!=="0",decision:e(ql)==="1"}}function Xl(e,t){return!t.workspace||t.phone?Vl:e}const Jt=()=>Ze(()=>import("./screens-BMLZR8WS.js"),__vite__mapDeps([1,2,3,4,5,6])),Zt=()=>null,Jl=f.lazy(()=>Jt().then(e=>({default:e.ChatView}),()=>({default:Zt}))),Zl=f.lazy(()=>Jt().then(e=>({default:e.DecisionCard}),()=>({default:Zt}))),Ql=f.lazy(()=>Jt().then(e=>({default:e.ChatComposer}),()=>({default:Zt})));function ec(e){return f.createElement(f.Suspense,{fallback:null},f.createElement(Ql,e))}function Ms(e){const[t]=f.useState(Yl);return f.useMemo(()=>Xl(t,{workspace:e,phone:!1}),[t,e])}function Os(e,t){return e.chat&&!!t&&t.view==="chat"&&!!t.source}function tc({screens:e,flags:t}){if(!e)return null;const n=t.decision?e.decision:void 0;return Os(t,e)?f.createElement(f.Suspense,{fallback:null},f.createElement(Jl,{source:e.source,provider:e.provider,decision:n})):n?f.createElement(f.Suspense,{fallback:null},f.createElement(Zl,n)):null}const nc="board.stage.wsEmptyTitle",sc="board.stage.wsEmptyLine",rc="board.stage.wsEmptyBeside",ac="board.stage.wsEmptyPanes";function oc(e){return e==="too-old"?I("board.stage.tmuxTooOld"):e==="missing"?I("board.stage.tmuxMissing"):I("board.stage.tmuxUnavailable")}function ic(e){return e?e.stage==="checking"?1:e.total?Math.min(1,e.received/e.total):null:null}function lc(e){if(!e)return I("board.stage.setupStarting");if(e.stage==="checking")return I("board.stage.setupChecking");const t=n=>(n/1e6).toFixed(1);return e.total?I("board.stage.setupProgress",{received:t(e.received),total:t(e.total)}):I("board.stage.setupReceived",{received:t(e.received)})}function cc(e){return e==="download_failed"?I("board.stage.downloadFailed"):e==="checksum_mismatch"||e==="too_large"?I("board.stage.downloadUntrusted"):e==="extract_failed"||e==="does_not_run"?I("board.stage.downloadWontRun"):I("board.stage.downloadOther")}function dc({line:e}){const t=de(),[n,r]=f.useState(!1);return s.jsxs("div",{className:"ts-cmd",children:[s.jsx("code",{title:e,children:e}),s.jsx("button",{type:"button",className:"glyph-btn","aria-label":t(n?"board.stage.copied":"board.stage.copyCommand"),title:t(n?"board.stage.copied":"board.stage.copy"),onClick:()=>{Gt(e).then(a=>r(a))},children:s.jsx(qo,{})})]})}function uc({waiting:e,onOpen:t,onNewSession:n}){const r=de(),a=hr();if(e)return s.jsxs("div",{className:"ts-card ts-ws-empty","data-waiting":"",children:[s.jsxs("div",{className:"ts-ws-head",children:[s.jsx(Ue,{kind:"waiting"}),s.jsx("span",{className:"ts-ws-title",children:r("board.stage.waitingOnYou",{name:e.name})}),s.jsx("span",{className:"ts-ws-wait",children:e.waited})]}),s.jsxs("p",{className:"ts-ws-ask",children:[e.ask,e.command&&s.jsxs(s.Fragment,{children:[" ",s.jsx("code",{children:e.command})]})]}),s.jsxs("button",{type:"button",className:"btn ts-ws-open","data-stage-land":!0,onClick:t,children:[s.jsx("span",{children:r("board.stage.open",{name:e.name})}),a&&s.jsx(Ie,{children:"n"})]})]});const o=s.jsx(Ie,{label:r("board.stage.besideSpoken"),children:"⇧↵"}),l=s.jsx(Ie,{label:r("board.stage.panesSpoken"),children:"1–4"});return s.jsx("div",{className:"ts-card",children:s.jsxs("div",{className:"ts-empty-block",children:[s.jsx("p",{className:"ts-ws-title",children:r(nc)}),s.jsx("p",{className:"ts-text",children:r(sc)}),s.jsx("div",{className:"ts-acts",children:s.jsx("button",{type:"button",id:bt,className:"btn primary","aria-haspopup":"dialog","data-stage-land":!0,onClick:()=>n(bt),children:r("board.newSession.title")})}),s.jsxs("p",{className:"ts-ws-more",children:[dn(r(rc,{keys:"{keys}"}),{keys:o}),a&&s.jsxs(s.Fragment,{children:[" ",dn(r(ac,{keys:"{keys}"}),{keys:l})]})]})]})})}function Mt(e){var r;const t=de(),{phase:n}=e;switch(n.kind){case"empty":return e.workspace?s.jsx(uc,{waiting:e.waiting,onOpen:e.onOpenWaiting,onNewSession:e.onNewSession}):s.jsxs("div",{className:"ts-card",children:[s.jsx("p",{className:"ts-text",children:t("board.stage.emptyBoard")}),s.jsx("div",{className:"ts-acts",children:s.jsx("button",{type:"button",id:bt,className:"btn primary","aria-haspopup":"dialog","data-stage-land":!0,onClick:()=>e.onNewSession(bt),children:t("board.newSession.title")})})]});case"attaching":return n.reconnect||e.held?null:s.jsx("div",{className:"ts-card","data-timed":e.timed,children:s.jsxs("div",{className:"ts-text ts-wait",children:[s.jsx(Ue,{kind:"working"}),s.jsx("span",{children:t("board.stage.attaching")})]})});case"starting":return s.jsx("div",{className:"ts-card",children:s.jsxs("div",{className:"ts-text ts-wait",children:[s.jsx(Ue,{kind:"working"}),s.jsx("span",{children:t("board.stage.starting",{agent:qt(n.agent),cwd:n.cwd})})]})});case"not-attachable":{const{target:a}=n,o=ra(a,e),l=aa(a,e),d=a.adoptable&&!o&&!l,c=n.stillRunning&&!o&&!l,i=d?e.handoff:void 0,u=d&&!n.stillRunning&&!(i!=null&&i.moving);return s.jsxs("div",{className:"ts-card",children:[((r=e.context)==null?void 0:r.prompt)&&s.jsxs("div",{className:"ts-ctx",children:[s.jsx("span",{className:"ts-prompt",children:"❯ "}),e.context.prompt]}),i!=null&&i.moving?s.jsx("p",{className:"ts-text",role:"status",children:t("board.stage.handoff.waiting")}):i!=null&&i.failed?s.jsx("p",{className:"ts-text",role:"status",children:t("board.stage.handoff.failed")}):c?s.jsx("p",{className:"ts-text",role:"status",children:t(i?"board.stage.handoff.offer":oa(e.boardState))}):s.jsx("p",{className:"ts-text",children:o?t(ia):l?t(la):a.label}),s.jsxs("div",{className:"ts-acts",children:[i&&(c||i.moving)&&s.jsx("button",{type:"button",className:"btn primary","data-stage-land":!0,onClick:i.toggle,children:t(i.moving?"common.cancel":"board.stage.handoff.move")}),u&&s.jsx("button",{type:"button",className:"btn primary","aria-busy":n.busy||void 0,"data-stage-land":!0,onClick:e.onAdopt,children:t("board.stage.reopenHere")}),s.jsx("button",{type:"button",className:"btn","data-stage-land":u?void 0:!0,onClick:e.onNotNow,children:t("common.notNow")})]})]})}case"tmux-installing":{const a=ic(n.progress),o=lc(n.progress);return s.jsxs("div",{className:"ts-card",children:[s.jsx("div",{className:"ts-title",children:t("board.stage.tmuxSettingUp")}),s.jsx("p",{className:"ts-text",children:t("board.stage.tmuxFetching")}),s.jsxs("div",{className:"ts-setup",children:[s.jsx("div",{className:"ts-setup-bar",role:"progressbar","aria-label":t("board.stage.tmuxFetchingLabel"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a==null?void 0:Math.round(a*100),"aria-valuetext":o,"data-unknown":a==null||void 0,children:s.jsx("i",{className:"ts-setup-fill",style:a==null?void 0:{transform:`scaleX(${a})`}})}),s.jsx("span",{className:"ts-setup-line",children:o})]}),s.jsx("div",{className:"ts-acts",children:s.jsx("button",{type:"button",className:"btn",onClick:e.onNotNow,children:t("common.notNow")})})]})}case"tmux-missing":return s.jsxs("div",{className:"ts-card",children:[s.jsx("div",{className:"ts-title",children:oc(n.reason)}),n.download&&s.jsx("p",{className:"ts-note",children:cc(n.download)}),s.jsx("p",{className:"ts-text",children:t("board.stage.twoSentences",{first:t("board.stage.tmuxWhy"),second:n.reason==="too-old"?t("board.stage.updateIt"):t("board.stage.installIt")})}),n.install&&s.jsx(dc,{line:n.install}),s.jsx("div",{className:"ts-acts",children:s.jsx("button",{type:"button",className:"btn","aria-busy":n.busy||void 0,"data-stage-land":!0,onClick:e.onRetry,children:n.busy?t("board.stage.checking"):t("board.stage.checkAgain")})})]});case"error":{const a=n.code!=="unsupported",o=!!n.code,l=s.jsxs("div",{className:"ts-card",children:[s.jsx("p",{className:"ts-text",children:mn(n.message)}),s.jsxs("div",{className:"ts-acts",children:[a&&s.jsx("button",{type:"button",className:"btn","aria-busy":n.busy||void 0,"data-stage-land":!0,onClick:e.onRetry,children:o?n.busy?t("board.stage.checking"):t("board.stage.checkAgain"):t("board.stage.tryAgain")}),s.jsx("button",{type:"button",className:"btn","data-stage-land":a?void 0:!0,onClick:e.onNotNow,children:t("common.notNow")})]})]});return $l(n.code)?s.jsx(Gl,{code:n.code??"",message:mn(n.message),busy:n.busy,onRetry:e.onRetry,onNotNow:e.onNotNow,plain:l}):l}default:return null}}const Wn=1500,fc=600,ut=new WeakMap;function pt(e,{typing:t=!0}={}){var l;if((l=ut.get(e))==null||l(),e.focus(),document.activeElement!==e)return!1;let n=null;const r=d=>{n&&clearTimeout(n),n=setTimeout(o,d)},a=d=>{const c=d.key===" "||d.key==="Enter";d.type==="keydown"&&!c&&r(Wn),(d.key===" "||d.key==="Enter"&&d.type==="keydown")&&d.preventDefault()};function o(){n&&clearTimeout(n),ut.get(e)===o&&ut.delete(e),e.removeAttribute(cn),e.removeEventListener("keydown",a),e.removeEventListener("keyup",a),e.removeEventListener("blur",o)}return ut.set(e,o),e.setAttribute(cn,""),e.addEventListener("keydown",a),e.addEventListener("keyup",a),e.addEventListener("blur",o),r(t?Wn:fc),!0}const hc={state:"hidden",afterHold:!1};function mc(e){const t=f.useRef(hc),n=sa(t.current,e.phase),{state:r,afterHold:a}=n;f.useEffect(()=>{t.current=n});const{hostRef:o,paneName:l,screens:d,...c}=e,i=Ms(e.workspace===!0||d!==void 0),u=Os(i,d),m=!u&&e.phase.kind==="attaching"&&!e.phase.reconnect&&r!=="held",k=fr(m),b=!m&&!u&&k.draw&&e.phase.kind==="live",j=f.useRef(!1);f.useLayoutEffect(()=>{const h=o.current;if(!h)return;if(r==="shown"){j.current=!1,h.removeAttribute("aria-hidden");return}const x=typeof document>"u"?null:document.activeElement;x&&typeof x.blur=="function"&&h.contains(x)&&(x.blur(),j.current=!0),h.setAttribute("aria-hidden","true")},[r,o]);const R=e.phase.kind;return f.useLayoutEffect(()=>{var x,_;if(!j.current||R==="attaching"||R==="starting"||R==="tmux-installing"||(j.current=!1,R!=="error"||typeof document>"u")||document.activeElement&&document.activeElement!==document.body)return;const h=(_=(x=o.current)==null?void 0:x.parentElement)==null?void 0:_.querySelector("[data-stage-land]");h&&pt(h)},[R,o]),s.jsxs("div",{className:"ts-body","data-view":u?"chat":void 0,"data-frame":r!=="hidden"||void 0,children:[s.jsx("div",{ref:o,className:"ts-host","data-terminal-panel":"","data-terminal-name":e.paneName,"data-shown":r==="shown"||void 0,"data-held":r==="held"||void 0,"data-after-hold":a||void 0}),u?null:m?k.draw?s.jsx(Mt,{...c,held:!1,timed:k.leaving?"out":"in"}):null:s.jsx(Mt,{...c,held:r==="held"}),b&&s.jsx(Mt,{...c,phase:{kind:"attaching",reconnect:!1},held:!1,timed:k.leaving?"out":"in"}),s.jsx(tc,{screens:d,flags:i})]})}function gc({key:e,request:t,launch:n,typing:r,focus:a,settled:o=!1,land:l,unmet:d,from:c=null}){const i=f.useRef(null);f.useEffect(()=>{const u=i.current;if(u&&c!=null&&u.key===c){i.current={key:e,request:u.request};return}i.current=n?{key:e,request:t}:null,u&&(d==null||d(u.request))},[e]),f.useEffect(()=>{const u=i.current;if(t==null){(u==null?void 0:u.request)!=null&&(i.current=null,d==null||d(u.request));return}i.current={key:e,request:t},u&&u.request!==t&&(d==null||d(u.request))},[t]),f.useEffect(()=>{const u=i.current;(u==null?void 0:u.key)===e&&(r?(i.current=null,a(u.request)):o&&(l!=null&&l(u.request))&&(i.current=null,d==null||d(u.request)))})}function pc(e){var t;try{const n=typeof window>"u"||(t=window.ccdeckTerminal)==null?void 0:t.keys(e===!0);Promise.resolve(n).catch(()=>{})}catch{}}const ft=new Set;function bc(e,t=typeof document>"u"?void 0:document){var r,a,o;if(!e){for(const l of ft)try{l.play()}catch{}ft.clear();return}if(typeof(t==null?void 0:t.getAnimations)!="function")return;let n;try{n=t.getAnimations()}catch{return}for(const l of n){if(l.playState!=="running"||ft.has(l))continue;const d=l.effect;if(((r=d==null?void 0:d.getTiming)==null?void 0:r.call(d).iterations)===1/0&&!((o=(a=d.target)==null?void 0:a.closest)!=null&&o.call(a,".stage-dock")))try{l.pause(),ft.add(l)}catch{}}}const wc=2e3,yc={tell:pc,quiet:e=>bc(e),every:(e,t)=>{const n=setInterval(e,t);return()=>clearInterval(n)}},ht=new Set;let st=null;function qn(e,t,n=yc){const r=ht.size>0;t?ht.add(e):ht.delete(e);const a=ht.size>0;n.tell(a),a&&!r?(n.quiet(!0),st=n.every(()=>n.quiet(!0),wc)):!a&&r&&(st==null||st(),st=null,n.quiet(!1))}const Qt=()=>typeof navigator>"u"?void 0:navigator.keyboard,Is="board.keys.keptFull",Fs="board.keys.keptApp";function xc(e=Ge(),t){var r;if(typeof document>"u"||mr(t)||kt(e))return!1;const n=typeof navigator>"u"?"":navigator.userAgent;return/android/i.test(e)||/\bAndroid\b/.test(n)?!1:document.fullscreenEnabled===!0&&typeof((r=Qt())==null?void 0:r.lock)=="function"}function kc(e,t=Ge()){return kt(t)||typeof document<"u"&&document.fullscreenElement?null:I(e?Is:Fs)}function vc(e){return e===I(Is)||e===I(Fs)}async function Sc(){var e,t,n;try{await document.documentElement.requestFullscreen({navigationUI:"hide"})}catch{return!1}try{(n=(t=(e=Qt())==null?void 0:e.lock)==null?void 0:t.call(e,["Escape"]))==null||n.catch(()=>{})}catch{}return!0}function Xe(){var e,t;try{(t=(e=Qt())==null?void 0:e.unlock)==null||t.call(e)}catch{}typeof document>"u"||!document.fullscreenElement||document.exitFullscreen().catch(()=>{})}function jc(e,t,n){const[r]=f.useState(()=>xc()),[a,o]=f.useState(!1),l=f.useRef(!1),d=f.useRef(!0),c=f.useRef(e);c.current=e;const i=f.useRef(t);i.current=t,f.useEffect(()=>{if(d.current=!0,!r)return()=>{d.current=!1};const m=()=>{document.fullscreenElement||!l.current||(l.current=!1,o(!1),Xe(),c.current&&i.current())};return document.addEventListener("fullscreenchange",m),()=>{d.current=!1,document.removeEventListener("fullscreenchange",m),l.current&&(l.current=!1,Xe(),c.current&&i.current())}},[r]),f.useEffect(()=>{e||!l.current||(l.current=!1,o(!1),Xe())},[e]);const u=f.useCallback(()=>{if(c.current){l.current&&(l.current=!1,o(!1),Xe()),i.current();return}i.current(),r&&Sc().then(m=>{if(m){if(!c.current){Xe();return}if(!d.current){Xe(),i.current();return}l.current=!0,o(!0)}})},[r]);return{can:r,full:a,toggle:u}}function Nc(e,t,n){return!e||t.takeover||n||e<=t.cols||e>t.range.max?null:e}function Ec(e,t,n,r,a){const o=f.useRef(a);o.current=a;const l=f.useRef(n.cols);l.current=n.cols;const d=f.useRef(null),c=f.useRef(!1),i=Nc(t,n,r);f.useEffect(()=>{d.current&&n.cols!==d.current.made&&(c.current=!0)},[n.cols]),f.useEffect(()=>{var u;i==null||c.current||(d.current={before:((u=d.current)==null?void 0:u.before)??l.current,made:i},o.current(i,!1))},[i]),f.useEffect(()=>()=>{const u=d.current;d.current=null,c.current=!1,u&&l.current===u.made&&o.current(u.before,!1)},[e])}function Tc(e){return e?I("board.keys.firstWorkspace"):I("board.keys.firstBoard")}function Cc(e){return!!e&&(!!e.position||!!e.next||!!e.clear)}function Ac({asks:e,onNextAsk:t}){const n=de();if(e.position)return s.jsxs("div",{className:"ts-asks",children:[s.jsx("span",{className:"ts-asks-label",children:n("board.keys.asks")}),s.jsx("span",{className:"ts-count",children:n("board.keys.position",{index:e.position.index+1,total:e.position.total})})]});if(e.next){const{next:r}=e;return s.jsxs("div",{className:"ts-asks",children:[e.resumed&&s.jsxs("span",{className:"ts-resumed",children:[s.jsx(Ue,{kind:"done"}),n("board.keys.resumed",{name:e.resumed})]}),s.jsxs("button",{type:"button",className:"btn ts-next ts-plain","aria-label":r.tool?n("board.keys.nextAskLabelTool",{name:r.name,waited:r.waited,tool:r.tool}):n("board.keys.nextAskLabel",{name:r.name,waited:r.waited}),onClick:t,children:[n("board.keys.nextAsk")," ",s.jsx("span",{className:"ts-next-name",children:r.name})," ",r.waited]})]})}return e.clear?s.jsx("div",{className:"ts-asks","data-clear":!0,children:s.jsxs("span",{className:"ts-resumed",children:[s.jsx(Ue,{kind:"done"}),n("board.keys.noMoreAsks")]})}):null}function Rc({hosts:e}){const t=de();return s.jsxs("div",{className:"ts-asks ts-hosts",children:[s.jsx("span",{className:"ts-hosts-said",title:e.said,children:e.said}),e.onReview&&s.jsx("button",{type:"button",className:"btn",onClick:e.onReview,children:t("board.keys.review")})]})}function _c({arrival:e,onAnswer:t}){const n=de();return s.jsxs("div",{className:"ts-asks",children:[s.jsxs("span",{className:"ts-arrival",children:[s.jsx(Ue,{kind:"waiting"}),e.tool?n("board.keys.arrivalTool",{name:e.name,tool:e.tool}):n("board.keys.arrival",{name:e.name})]}),s.jsxs("button",{type:"button",className:"btn ts-next ts-plain","aria-label":n("board.keys.answerLabel",{name:e.name}),onClick:t,children:[s.jsx(Ie,{children:"n"})," ",n("board.keys.answer")]})]})}function Lc({children:e,visible:t}){const[n,r]=f.useState(null);return f.useLayoutEffect(()=>{const a=()=>r(document.getElementById("ccdeck-stage-status"));a();const o=new MutationObserver(a);return o.observe(document.querySelector(".app")??document.body,{childList:!0}),()=>o.disconnect()},[]),n?t?is.createPortal(s.jsx("div",{...e.props}),n):null:e}function Mc(e){const t=de();let n=null,r=!1;!e.end&&e.asks?(n=s.jsx(Ac,{asks:e.asks,onNextAsk:e.onNextAsk}),r=Cc(e.asks)):!e.end&&e.arrival?(n=s.jsx(_c,{arrival:e.arrival,onAnswer:e.onAnswerArrival}),r=!0):e.hosts&&(n=s.jsx(Rc,{hosts:e.hosts}),r=!0);const a=e.workspace===!0;let o;e.end?o=s.jsxs("div",{className:"ts-keys","data-owner":"none","data-split":!0,children:[s.jsx("span",{className:"ts-end",children:e.end.sentence}),s.jsx("button",{type:"button",className:"btn","aria-busy":e.end.busy||void 0,"data-stage-land":!0,onClick:e.end.onAction,children:e.end.action})]}):e.notice?o=s.jsx("div",{className:"ts-keys","data-owner":"none",children:s.jsx("span",{className:"ts-end",children:e.notice})}):e.chatCannotType?o=s.jsxs("div",{className:"ts-keys ts-chat-handoff","data-owner":"none","data-split":!0,children:[s.jsx("span",{className:"ts-chat-reply-note",children:t("board.chat.replyInTerm")}),s.jsx("button",{type:"button",className:"btn",onClick:e.onShowTerm,children:t("board.chat.showTerm")})]}):e.chat&&e.canType&&!r?o=s.jsxs("div",{className:"ts-keys ts-chat-handoff","data-owner":"board","data-split":!0,children:[s.jsx("span",{className:"ts-chat-reply-note",children:t("board.chat.replyInTerm")}),s.jsx("button",{type:"button",className:"btn primary",onClick:e.onTypeHere,children:t("board.chat.continueInTerm")})]}):e.firstRun&&e.canType&&!e.chat?o=s.jsxs("div",{className:"ts-keys","data-owner":e.owner,"data-split":!0,children:[s.jsxs("span",{className:"ts-first",children:[t("board.keys.typingGoes"),s.jsx("span",{className:"ts-first-keys",children:t("board.keys.escIncluded",{chord:e.chordLabel})}),". ",Tc(e.workspace===!0)]}),s.jsx("button",{type:"button",className:"btn",onClick:e.onFirstRunDone,children:t("board.keys.gotIt")})]}):e.owner==="pane"&&e.reconnecting?o=s.jsx("div",{className:"ts-keys","data-owner":"none",children:s.jsx("span",{className:"ts-reconnecting",title:t("board.keys.reconnecting",{name:e.name,note:t(gn)}),children:t("board.keys.reconnecting",{name:e.name,note:t(gn)})})}):e.owner==="pane"?o=s.jsxs("div",{className:"ts-keys","data-owner":"pane",children:[s.jsx("span",{className:"ts-label","data-strong":!0,children:t("board.keys.typingInto",{name:e.name})}),!r&&s.jsxs("span",{className:"ts-hint","data-optional":!0,children:[s.jsx(Ie,{children:"Esc"})," ",t("board.keys.escGoes")]}),!r&&s.jsxs("span",{className:"ts-hint",children:[s.jsx(Ie,{label:t(gr),children:e.chordLabel})," ",t(a?"board.status.keysBack":"board.keys.backToBoard")]})]}):o=s.jsxs("div",{className:"ts-keys","data-owner":"board",children:[s.jsx("span",{className:"ts-label",children:t(a?"board.status.deckLabel":"board.keys.onBoard")}),!r&&!e.takeover&&s.jsxs("span",{className:"ts-hint",children:[s.jsx(Ie,{children:"j k"})," ",t("board.keys.sessions")]}),!r&&e.canType&&s.jsxs("span",{className:"ts-hint",children:[s.jsx(Ie,{label:t("board.keys.enterSpoken"),children:"↵"}),s.jsx("button",{type:"button",className:"btn ts-plain",onClick:e.onTypeHere,children:t(e.chat?"board.keys.typeInTerm":"board.keys.typeHere")})]}),!r&&e.asksWaiting&&s.jsxs("span",{className:"ts-hint",children:[s.jsx(Ie,{children:"n"})," ",t("board.keys.nextAskHint")]})]});const l=s.jsx("footer",{className:e.composer?"ts-bar ts-bar-compose":"ts-bar","aria-label":t(e.composer?"board.chat.conversation":"board.keys.bar"),hidden:e.paneless&&!e.hosts&&!e.chatCannotType&&!e.composer||void 0,children:e.composer?s.jsxs(s.Fragment,{children:[e.composer,(e.end||e.notice||n)&&s.jsxs("div",{className:"ts-chat-status",children:[(e.end||e.notice)&&o,n]})]}):s.jsxs(s.Fragment,{children:[o,n]})});return e.composer?l:e.primary===!1?null:s.jsx(Lc,{visible:!(e.paneless&&!e.hosts&&!e.chatCannotType),children:l})}const Oc=[{id:"esc",cap:"Esc",nameKey:"board.keys.nameEscape",bytes:"\x1B"},{id:"tab",cap:"Tab",nameKey:"board.keys.nameTab",bytes:" "},{id:"up",cap:"↑",nameKey:"board.keys.nameUp",bytes:"\x1B[A"},{id:"down",cap:"↓",nameKey:"board.keys.nameDown",bytes:"\x1B[B"},{id:"ctrl-c",cap:"Ctrl+C",nameKey:"board.keys.nameCtrlC",bytes:""},{id:"enter",cap:"⏎",nameKey:"board.keys.nameEnter",bytes:"\r"}],Ic=e=>e.preventDefault();let Bt=null;function Vn(e){Bt=e?e():null}function Fc(e,t){const n=Bt??void 0;Bt=null,e(t,n)}function Pc({canType:e,paneless:t=!1,onKey:n,holdsFocus:r}){const a=de();return s.jsx("div",{className:"ts-keyrow",role:"group","aria-label":a("board.keys.rowLabel"),hidden:t||void 0,children:Oc.map(o=>s.jsx("button",{type:"button",className:"ts-key","data-key":o.id,"aria-label":a(o.nameKey),disabled:!e,onPointerDown:l=>{Vn(r),Ic(l)},onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&Vn(r)},onClick:()=>Fc(n,o.bytes),children:o.cap},o.id))})}function Dc(e){switch(e){case"ArrowLeft":return"wider";case"ArrowRight":return"narrower";case"Home":return"widest";case"End":return"narrowest";case"Enter":return"reset";default:return null}}const Bc=260;function zc(e){const t=e.closest(".app");t&&(t.setAttribute("data-snap",""),window.setTimeout(()=>t.removeAttribute("data-snap"),Bc))}function Hc(e){const t=de(),[n,r]=f.useState(!1),a=f.useRef(!1),o=f.useRef(0),l=f.useRef(e.cols),d=k=>{const b=br(wr(k-o.current,e.appW,e.cellW),e.range);b!==l.current&&(l.current=b,e.onCols(b,!1))},c=k=>{var j,R,h;if(k.button!==0)return;k.preventDefault(),(R=(j=k.currentTarget).setPointerCapture)==null||R.call(j,k.pointerId);const b=(h=k.currentTarget.parentElement)==null?void 0:h.getBoundingClientRect();o.current=((b==null?void 0:b.left)??0)-e.navW,l.current=e.cols,a.current=!0,r(!0),e.onHold(!0)},i=k=>{a.current&&d(k.clientX)},u=()=>{a.current&&(a.current=!1,r(!1),e.onHold(!1),e.onCols(l.current,!0))},m=k=>{const b=Dc(k.key);if(!b)return;if(k.preventDefault(),k.stopPropagation(),b==="reset"){e.onReset();return}const j=pr(e.cols,b,e.range);j!==e.cols&&e.onCols(j,!0)};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ts-divider",role:"separator","aria-orientation":"vertical","aria-label":t("board.stage.width"),"aria-valuemin":e.range.min,"aria-valuemax":e.range.max,"aria-valuenow":e.cols,"aria-valuetext":t("board.stage.widthColumns",{cols:e.cols}),tabIndex:0,"data-held":n||void 0,onPointerDown:c,onPointerMove:i,onPointerUp:u,onPointerCancel:u,onLostPointerCapture:u,onDoubleClick:k=>{zc(k.currentTarget),e.onReset()},onKeyDown:m,children:s.jsx("span",{className:"ts-grip"})}),n&&s.jsx("div",{className:"ts-detents","aria-hidden":"true",children:s.jsxs("span",{className:"ts-readout",children:[e.cols," × ",e.rows]})})]})}const $c={read:()=>So(),end:e=>jo(e)};async function zt(e){const t=await e.read();if(!t.ok)return null;const n=t.hosts.filter(r=>r.sessions.length>0);return n.length||t.launchesRefused?{hosts:n,launchesRefused:t.launchesRefused}:null}function Yn(e){return e?e.hosts.map(t=>`${t.generation}:${t.sessions.map(n=>n.id).join(",")}`).join(";"):""}const Xn=e=>I("board.hosts.sessions",{count:e}),Kc="board.hosts.refused";function Uc(e,t){if(!e)return null;const n=e.hosts.filter(d=>d.state!=="draining"),r=n.reduce((d,c)=>d+c.sessions.length,0);if(r===0)return e.launchesRefused;const a=n.length===1,o=!!e.launchesRefused,l=t?I("board.hosts.kept",{count:r}):n.some(d=>d.state==="security")?I(a?"board.hosts.securityOne":"board.hosts.securityMany",{sessions:Xn(r)}):I(a?o?"board.hosts.plainOneStop":"board.hosts.plainOne":o?"board.hosts.plainManyStop":"board.hosts.plainMany",{sessions:Xn(r)});return o?I("board.stage.twoSentences",{first:l,second:I(Kc)}):l}function Gc(e){switch(e.state){case"stranded":return I("board.hosts.reasonStranded");case"security":return I("board.hosts.reasonSecurity");case"draining":return I("board.hosts.reasonDraining")}}function Wc(e){const t=e.has("claude"),n=e.has("codex");return t&&n?I("board.hosts.ownerBoth"):t?I("board.hosts.ownerClaude"):n?I("board.hosts.ownerCodex"):I("board.hosts.ownerAgent")}function qc(e){const t=new Set(e.hosts.flatMap(n=>n.sessions.map(r=>r.agent)));return{ends:I("board.hosts.ends"),stays:I("board.hosts.stays",{owners:Wc(t)})}}const Vc=e=>I("board.hosts.endAll",{count:e});async function Yc(e,t){const n=await e.end({generation:t.generation,sessions:t.sessions.map(r=>r.id)});return n.ok?{ended:n.ended,view:await zt(e),said:null}:n.code==="consent-outdated"||n.code==="host-gone"?{ended:0,view:await zt(e),said:n.error}:{ended:0,said:n.error}}const mt=e=>!!e&&e.hosts.length>0,Jn=e=>e.charAt(0).toLowerCase()+e.slice(1);function Xc(e){const{ends:t,stays:n}=qc(e.view),r=[...new Set(e.view.hosts.map(Gc))],a=e.view.hosts.flatMap(o=>o.sessions);return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"modal-body",children:[r.map(o=>s.jsx("p",{className:"oh-intro",children:o},o)),s.jsx("ul",{className:"oh-sessions",children:a.map(o=>s.jsxs("li",{children:[s.jsx("b",{children:o.name}),s.jsx("span",{children:I("board.hosts.row",{agent:ca(o.agent),folder:vt(o.cwd),ago:jr(e.now-o.started)})})]},o.id))}),s.jsxs("div",{className:"oh-facts",children:[s.jsx("p",{className:"oh-ends",children:I("board.hosts.endsLine",{text:Jn(t)})}),s.jsx("p",{className:"oh-stays",children:I("board.hosts.staysLine",{text:Jn(n)})})]}),e.view.launchesRefused&&s.jsx("p",{className:"oh-last",children:e.view.launchesRefused}),e.said&&s.jsx("p",{className:"oh-last",role:"status",children:e.said})]}),s.jsxs("footer",{className:"modal-foot",children:[s.jsx("button",{type:"button",ref:e.keepRef,className:"btn",onClick:e.onKeep,children:I("board.hosts.keep")}),s.jsx("button",{type:"button",className:"btn danger","aria-busy":e.busy!==null||void 0,onClick:e.onEndAll,children:Vc(a.length)})]})]})}function Jc(e){const t=de(),n=f.useRef(null),r=yr(e.onCancel,{focusRef:n,layer:xr}),a=kr(e.onCancel),o=e.view.hosts.length>1;return is.createPortal(s.jsxs(vr,{scrim:a,dialogRef:r,className:"clear-confirm older-hosts",labelledBy:"older-hosts-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"older-hosts-title",className:"modal-tool-name",children:t(o?"board.hosts.titleMany":"board.hosts.titleOne")})}),s.jsx("div",{className:"modal-actions",children:s.jsx(Sr,{onClick:e.onCancel,label:t("board.hosts.cancelEsc")})})]}),s.jsx(Xc,{...e,keepRef:n})]}),document.body)}const Zc=5e3,Qc="/api/session/transcript",ed=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;function td(e,t){return!e||!t||t.provider!=="claude"&&t.provider!=="codex"?null:ed.test(t.sessionId)?t.sessionId:null}async function nd(e,t=(a,o)=>fetch(a,o),n,r="claude"){try{const a=new URLSearchParams({session:e});r==="codex"&&a.set("provider",r);const o=await t(`${Qc}?${a}`,{cache:"no-store",signal:n});if(o.status===404)return{kind:"unknown"};if(!o.ok)return{kind:"failed"};const l=await o.json();return l.ok!==!0||!Array.isArray(l.turns)?{kind:"failed"}:{kind:"ready",complete:l.complete!==!1,turns:l.turns}}catch{return{kind:"failed"}}}function sd(e,t={}){const n=de(),{session:r,provider:a="claude",shown:o,working:l,change:d,ended:c}=e,[i,u]=f.useState(null),[m,k]=f.useState(0),b=f.useRef(t);b.current=t;const j=f.useRef(0),R=f.useCallback((x,_)=>{const T=++j.current;nd(x,b.current.fetchFn,_,a).then(C=>{!_.aborted&&T===j.current&&u({session:x,provider:a,read:C})})},[a]);f.useEffect(()=>{if(!o||!r)return;const x=new AbortController;return R(r,x.signal),()=>x.abort()},[o,r,d,m,R]),f.useEffect(()=>{if(!o||!r||!l)return;const x=new AbortController,_=()=>(b.current.visible??(()=>typeof document>"u"||document.visibilityState==="visible"))(),T=setInterval(()=>{_()&&R(r,x.signal)},b.current.pollMs??Zc);return()=>{clearInterval(T),x.abort()}},[o,r,l,R]);const h=f.useCallback(()=>{u(null),k(x=>x+1)},[]);return f.useMemo(()=>{if(!i||i.session!==r||i.provider!==a)return{state:"loading"};const x=i.read;return x.kind==="unknown"?{state:"error",message:n(c?"board.chat.unavailable":"board.chat.notYet")}:x.kind==="failed"?{state:"error",message:n("board.chat.failed"),onRetry:h}:{state:"ready",turns:x.complete?x.turns:[{kind:"record",text:n("board.chat.earlier")},...x.turns]}},[i,r,a,c,n,h])}function rd(e,t,n,r=$c){const[a,o]=f.useState(null),[l,d]=f.useState(null),[c,i]=f.useState(!1),[u,m]=f.useState(null),[k,b]=f.useState(null),j=f.useRef(n);j.current=n;const R=f.useRef(!1);f.useEffect(()=>()=>{R.current=!0},[]),f.useEffect(()=>{if(!e){o(null);return}let _=!1;return zt(r).then(T=>{_||o(T)}),()=>{_=!0}},[e,t,r]);const h=()=>{i(!1),b(null)},x=l!==null&&l===Yn(a);return{line:Uc(a,x),canReview:mt(a),open:c&&mt(a),view:a,busy:u,said:k,review:()=>{b(null),i(!0)},keep:()=>{d(Yn(a)),h()},cancel:h,endAll:()=>{u!==null||!a||!mt(a)||(b(null),(async()=>{var y;let _=a,T=0,C=null;for(const S of a.hosts){if(R.current)return;if(!_||!_.hosts.some(Q=>Q.generation===S.generation))continue;m(S.generation);const z=await Yc(r,S);if(T+=z.ended,z.view!==void 0&&(_=z.view),z.said){C=z.said;break}}R.current||(m(null),o(_),T&&((y=j.current)==null||y.call(j,I("board.hosts.endedAnnounce",{count:T}))),mt(_)?b(C):h())})())}}}const gt=new Set(["empty","not-attachable","error","tmux-missing","tmux-installing"]),ad=6e3;function od(e){return e.kind!=="attaching"&&e.kind!=="starting"&&e.kind!=="tmux-installing"&&!((e.kind==="tmux-missing"||e.kind==="error"||e.kind==="not-attachable")&&e.busy)&&!(e.kind==="live"&&!e.readOnly)}function id(e,t=null){var i,u,m,k,b,j,R,h,x,_;if(!e)return!1;const n=document.activeElement,r=t==="typed",a=((i=e.dataset)==null?void 0:i.fill)!==void 0&&!!((u=n==null?void 0:n.closest)!=null&&u.call(n,".session-list")),o=((m=e.dataset)==null?void 0:m.fill)!==void 0&&((k=e.dataset)==null?void 0:k.empty)!==void 0?e.querySelector("[data-stage-land]"):null;if(o&&n&&n!==o&&e.contains(n)&&((b=n.closest)!=null&&b.call(n,"[data-stage-close]")))return t?pt(o,{typing:r}):o.focus(),!0;if(n&&n!==document.body&&!a&&(e.contains(n)||!((j=n.closest)!=null&&j.call(n,".react-flow"))))return t&&e.contains(n)&&n.tagName==="BUTTON"&&pt(n,{typing:r}),!0;const l=e.querySelector(".ts-head button[aria-pressed]"),d=((R=e.dataset)==null?void 0:R.secondary)===void 0?((x=(h=document.getElementById)==null?void 0:h.call(document,"ccdeck-stage-status"))==null?void 0:x.querySelector("[data-stage-land]"))??null:null,c=e.querySelector("[data-stage-land]")??d??(l&&((_=l.dataset)==null?void 0:_.zoom)===void 0?l:null)??e.querySelector(".ts-head button[data-stage-close]");return c?(t?pt(c,{typing:r}):c.focus(),!0):!1}function ld(e,t){if(!(!e||!t))return()=>t(e.id)}function cd(e){switch(e.kind){case"empty":return{kind:"empty"};case"session":return{kind:"session",ref:e.session.ref,...e.launch?{launch:e.launch}:{}};case"launch":return{kind:"launch",agent:e.agent,cwd:e.cwd,key:e.key,...e.options?{options:e.options}:{}}}}function Ht(e,t=!1){return e.kind==="session"?e.session.name:e.kind==="launch"?e.name:I(t?dd:"board.stage.noSessionOpen")}const dd="board.stage.emptyPane";function ud(e,t,n){if(e.kind==="ended"){if(t.kind==="launch"&&n.launchAgain){const a=qt(t.agent);return{sentence:I("board.stage.launchExited",{name:a}),action:I("board.stage.launchAgain",{name:a}),onAction:n.launchAgain}}const r=t.kind==="session"?t.session.endedAgo:null;return{sentence:r?I("board.stage.sessionEndedAgo",{ago:r}):I("board.stage.sessionEnded"),action:I("board.stage.reopenHere"),onAction:n.reopen}}return e.kind==="detached"?{sentence:I("board.stage.tookOver"),action:I("board.stage.attachAgain"),onAction:n.attachAgain}:null}function Zn(e,t,n,r){const a=f.useRef(n);a.current=n,f.useEffect(()=>{const o=[t,r].map(c=>{var i;return c?((i=e.current)==null?void 0:i.querySelector(c))??null:null}).filter(c=>c!==null);if(o.length===0||typeof ResizeObserver>"u")return;const l=()=>{var u;const c=o.reduce((m,k)=>m+k.getBoundingClientRect().height,0),i=Math.ceil(Math.round(c*100)/100);i>0&&((u=a.current)==null||u.call(a,i))};l();const d=new ResizeObserver(l);for(const c of o)d.observe(c);return()=>d.disconnect()},[e,t,r])}function fd(e){var Pe,pe,Be,et,en,tn;const t=de(),[n,r]=f.useState(!1),[a,o]=f.useState(null),l=cd(e.show),d=Ke(l),c=e.geometry.fill===!0,i=Ht(e.show,c),u=Ms(c),m=e.show.kind==="session"?e.show.session.ref:null,k=td(u.chat,m),b=(m==null?void 0:m.provider)??"claude",j=`${b}:${k}`,[R,h]=f.useState("term"),x=k!==null&&R==="chat",[_,T]=f.useState({}),[C,y]=f.useState(0),S=sd({session:k,provider:b,shown:x,working:e.show.kind==="session"&&e.show.session.status.state==="working",ended:e.show.kind==="session"&&e.show.session.status.state==="ended",change:e.show.kind==="session"?`${e.show.session.promptCount??0}:${e.show.session.status.state}:${C}`:""});f.useEffect(()=>{k===null&&h("term")},[k]);const z=f.useMemo(()=>yi(e.readToken,c?"--sunken":"--panel"),[e.readToken,c]),Q=f.useMemo(()=>e.readToken(Ui).trim()||"monospace",[e.readToken]),H=f.useMemo(()=>Nr(Ge()),[]),Z=Er(),F=vl({subject:l,cols:e.geometry.cols,rows:e.geometry.rows,holdResize:n,theme:z,fontFamily:Q,fontSize:Tr(Z),onCell:e.onCell,onLaunched:e.onLaunched,onNotice:o,deps:e.sessionDeps,windows:e.windows}),{phase:E}=F,[ee,$]=f.useState(null),[le,te]=f.useState(!1),Y=f.useRef(null),K=f.useRef(e.onContinuation);K.current=e.onContinuation;const G=(m==null?void 0:m.provider)==="claude"&&!e.windows?m.sessionId:null,we=(m==null?void 0:m.cwd)??"",me=!!e.onContinuation&&!!G&&!!we&&E.kind==="not-attachable",[je,Le]=f.useState(null);f.useEffect(()=>{if(!me||!G)return;const O=new AbortController;return(async()=>{try{const X=await fetch("/api/terminal/background",{method:"POST",signal:O.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:G,provider:"claude",cwd:we,check:!0})});if(!X.ok)return;const{movable:Me}=await X.json();!O.signal.aborted&&Me===!0&&Le(G)}catch{}})(),()=>O.abort()},[me,G,we]);const ye=me&&je===G,Ne=ye&&ee===G;f.useEffect(()=>($(null),te(!1),()=>{var O;return(O=Y.current)==null?void 0:O.abort()}),[G]);const xe=async()=>{var X;if(Ne){(X=Y.current)==null||X.abort(),$(null);return}if(!G||Y.current)return;const O=new AbortController;Y.current=O,te(!1),$(G);try{if((await fetch("/api/terminal/background",{method:"POST",signal:O.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:G,provider:"claude",cwd:we})})).ok)return}catch{}finally{Y.current=null}O.signal.aborted||($(null),te(!0))};f.useEffect(()=>{if(!Ne||!G)return;const O=new AbortController;let X;const Me=setTimeout(()=>{var tt;(tt=Y.current)==null||tt.abort(),O.abort(),$(null),te(!0)},4e4),nn=async()=>{var tt;try{const Ds=new URLSearchParams({session:G,continuation:"1"}),sn=await fetch(`/api/session/transcript?${Ds}`,{cache:"no-store",signal:O.signal});if(sn.ok){const{sessionId:Nt}=await sn.json();if(!O.signal.aborted&&typeof Nt=="string"){const rn=await xo({sessionId:Nt,provider:"claude",cwd:we},{signal:O.signal});if(!O.signal.aborted&&rn.ok&&rn.target.kind==="D"&&((tt=K.current)!=null&&tt.call(K,Nt,we))){h("term"),$(null);return}}}}catch{}O.signal.aborted||(X=setTimeout(nn,2e3))};return nn(),()=>{O.abort(),clearTimeout(X),clearTimeout(Me)}},[Ne,G,we]);const ve=f.useRef("hidden"),fe=da(ve.current,E);f.useEffect(()=>{ve.current=fe});const be=e.show.kind==="session"?e.show.session.status:null,v=ua(be,E),M=fa(v,E,F.streaming),A=ha(E),D=f.useRef(null),B=O=>{var Me;if(F.focus(),O===void 0)return;const X=(Me=e.takeTypeAhead)==null?void 0:Me.call(e,O);X&&F.type(X)},ie=O=>{if(x){D.current={key:d,request:O},h("term");return}B(O)};f.useLayoutEffect(()=>{var X;const O=D.current;x||!O||(D.current=null,O.key===d?B(O.request):O.request!==void 0&&((X=e.takeTypeAhead)==null||X.call(e,O.request)))});const ae=O=>{O==="chat"&&F.keysOwner==="pane"&&F.release(),h(O)},g=x&&e.show.kind==="session"&>.has(E.kind),w=F.subject!==d?t("board.chat.connecting"):E.kind==="live"?E.readOnly?t("board.chat.readOnly"):(be==null?void 0:be.state)==="waiting"?t("board.chat.waiting"):void 0:t(E.kind==="attaching"||E.kind==="starting"?"board.chat.connecting":"board.chat.offline"),N=e.show.kind==="session"?e.show.session.rename??null:null,P=f.useRef(null),U=Cr(N==null?void 0:N.sessionId,P),J=f.useRef(e.onKeysOwner);J.current=e.onKeysOwner,f.useEffect(()=>{var O;(O=J.current)==null||O.call(J,F.keysOwner)},[F.keysOwner]);const re=f.useRef({});f.useEffect(()=>{qn(re.current,F.keysOwner==="pane")},[F.keysOwner]),f.useEffect(()=>{const O=re.current;return()=>qn(O,!1)},[]);const oe=jc(e.expanded,e.onToggleExpand);f.useEffect(()=>{if(F.keysOwner==="pane")return Ar(()=>{const O=kc(oe.can);O&&o(O)})},[F.keysOwner,oe.can]),Ec(d,E.kind==="live"&&E.sizeOwner==="pane"?((Pe=F.paneSize)==null?void 0:Pe.cols)??0:0,e.geometry,e.expanded,e.onCols);const ce=f.useRef(e.onAnnounce);ce.current=e.onAnnounce,f.useEffect(()=>{var X;const O=ma(i,E);O&&((X=ce.current)==null||X.call(ce,O))},[E.kind,d]);const Re=f.useRef(e.onClose);Re.current=e.onClose;const Se=E.kind==="ended"&&E.clean===!0&&e.show.kind==="session";f.useEffect(()=>{Se&&Re.current()},[Se,d]),f.useEffect(()=>{var X;if(!a)return;(X=ce.current)==null||X.call(ce,a);const O=setTimeout(()=>o(null),ad);return()=>clearTimeout(O)},[a]),f.useEffect(()=>{o(null)},[d]),f.useEffect(()=>{oe.full&&o(O=>vc(O)?null:O)},[oe.full]);const Ee=f.useRef(null);Zn(Ee,".ts-bar",e.onBarH,".ts-keyrow"),Zn(Ee,".ts-head",e.onHeadH);const q=F.subject===d;gc({key:d,request:e.focusRequest,launch:l.kind==="launch",typing:q&&A,from:l.kind==="session"&&l.launch?`launch:${l.launch}`:null,focus:O=>{ie(O)},settled:q&&od(E),land:O=>{var X;return id(Ee.current,((X=e.holdsTypeAhead)==null?void 0:X.call(e,O))??null)},unmet:O=>{var X;(X=e.takeTypeAhead)==null||X.call(e,O)}});const se=()=>{var O;E.kind==="tmux-missing"&&E.busy||(F.retry(),(O=e.onWantKeys)==null||O.call(e))},he=()=>{var O;E.kind==="not-attachable"&&E.busy||(F.adopt(),(O=e.onWantKeys)==null||O.call(e))},p=ud(E,e.show,{reopen:he,launchAgain:e.onLaunchAgain,attachAgain:se}),L=rd(e.windows===!0,d,O=>{var X;return(X=ce.current)==null?void 0:X.call(ce,O)},e.hostsApi),W=x&&k!==null?s.jsx(ec,{value:_[j]??"",onChange:O=>T(X=>({...X,[j]:O})),unavailable:w,onShowTerm:()=>ae("term"),onSend:O=>{if(w)return"unavailable";const X=F.sendPrompt(O,d);return X==="sent"&&y(Me=>Me+1),X}},j):void 0,ne={"--ts-term-top":`${e.geometry.termTop}px`};return s.jsxs("section",{ref:Ee,className:"ts-stage",role:"region","aria-label":t("board.stage.region",{name:i}),"data-kind":E.kind,"data-empty":e.show.kind==="empty"||void 0,"data-live":M||void 0,"data-takeover":e.geometry.takeover||void 0,id:c&&(((pe=e.split)==null?void 0:pe.primary)??!0)?Rr:void 0,tabIndex:c?-1:void 0,"data-fill":c||void 0,"data-secondary":((Be=e.split)==null?void 0:Be.primary)===!1||void 0,"data-held":n||void 0,"data-pane-size":E.kind==="live"&&E.sizeOwner==="pane"||void 0,style:ne,children:[!e.geometry.takeover&&!e.expanded&&!c&&s.jsx(Hc,{cols:e.geometry.cols,rows:e.geometry.rows,range:e.geometry.range,appW:e.geometry.stageW+e.geometry.navW,navW:e.geometry.navW,cellW:e.cell.w,onCols:e.onCols,onReset:e.onColsReset,onHold:r}),s.jsx(Bl,{identity:d,name:i,rename:N?{facts:N,on:U.on,start:U.start,done:U.done,back:P}:null,provider:e.show.kind==="session"?e.show.session.ref.provider:e.show.kind==="launch"?e.show.agent:null,status:v,keysOwner:F.keysOwner,chordLabel:H,canType:A,expanded:e.split?e.split.max:e.expanded,canFull:e.split?!1:oe.can,full:e.split?!1:oe.full,split:e.split!=null,paneLink:((et=e.split)==null?void 0:et.number)!=null?{number:e.split.number,active:e.split.primary}:void 0,onDragHead:(en=e.split)==null?void 0:en.onDragHead,takeover:e.geometry.takeover,workspace:c?e.show.kind==="empty"?"empty":"pane":void 0,context:e.show.kind==="session"?e.show.session.contextUse:null,view:k!==null?{current:R,onChange:ae}:void 0,textSize:e.show.kind==="empty"||gt.has(E.kind)||x?void 0:{step:Z,onStep:rs},nothingRunning:e.show.kind==="empty"||E.kind==="ended"||l.kind==="launch"&&(E.kind==="error"||E.kind==="tmux-missing"||E.kind==="tmux-installing"),onKeys:()=>{var O;F.keysOwner==="pane"?(F.release(),(O=e.onRelease)==null||O.call(e)):ie()},onExpand:e.split?e.split.onMax:oe.toggle,onClose:e.onClose}),s.jsx(mc,{hostRef:F.hostRef,paneName:i,phase:E,context:e.show.kind==="session"?e.show.session.context:null,windows:e.windows,launched:e.show.kind==="session"&&(e.show.session.launched===!0||!!e.show.launch),boardState:(be==null?void 0:be.state)??null,onAdopt:he,handoff:ye?{moving:Ne,failed:le,toggle:xe}:void 0,onNotNow:e.onClose,onRetry:se,onNewSession:e.onNewSession,workspace:c&&e.show.kind==="empty",waiting:c?e.waiting??null:null,onOpenWaiting:ld(e.waiting,e.onOpenWaiting),screens:k!==null?{view:R,source:S,provider:b}:void 0}),s.jsx(Mc,{primary:((tn=e.split)==null?void 0:tn.primary)??!0,owner:F.keysOwner,name:i,chordLabel:H,canType:A,asksWaiting:e.asksWaiting,reconnecting:E.kind==="attaching"&&E.reconnect,takeover:e.geometry.takeover,notice:a,firstRun:e.firstRun,workspace:c,paneless:e.show.kind==="empty"||gt.has(E.kind)||ga(E,fe),onFirstRunDone:e.onFirstRunDone,chat:x,composer:W,chatCannotType:g,onShowTerm:()=>ae("term"),onTypeHere:()=>ie(),end:p,asks:e.asks,arrival:e.arrival,onNextAsk:e.onNextAsk,onAnswerArrival:e.onAnswerArrival,hosts:L.line?{said:L.line,onReview:L.canReview?L.review:null}:null}),s.jsx(Pc,{canType:A,paneless:e.show.kind==="empty"||gt.has(E.kind),onKey:F.press,holdsFocus:F.holdsFocus}),s.jsx(_r,{when:L.open&&L.view,children:O=>s.jsx(Jc,{view:O,now:Date.now(),busy:L.busy,said:L.said,onEndAll:L.endAll,onKeep:L.keep,onCancel:L.cancel})})]})}function hd({stage:e}){const t=e.geometry;return!t||t.takeover?null:s.jsx("div",{className:"stage-nav","data-phase":e.shell.phase,"data-grace":e.shell.grace||void 0,style:{"--nav-w":`${t.navW}px`},children:s.jsx(qa,{ref:e.navRef,width:t.navW,density:t.density,attachedId:ls(e.shell.target),onOpen:e.openTile,onNewSession:e.newSessionFrom})})}function Ot(e){return(e==null?void 0:e.querySelector(":scope > .react-flow"))??null}function md(e,t){if(!e||!t)return{card:null,name:null};let n=null;try{n=e.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`)}catch{}if(!n)return{card:null,name:null};const r=Dr(e),a=n.getBoundingClientRect();if(!(a.width>0&&a.right>r.left&&a.left<r.right&&a.bottom>r.top&&a.top<r.bottom))return{card:null,name:null};const l=n.querySelector(".lod-name"),d=l&&l.getBoundingClientRect().width>0?l:n.querySelector(".title .label");return{card:a,name:d?d.getBoundingClientRect():null}}function gd(e,t){return(Number(e.slice(1))||0)-(Number(t.slice(1))||0)}const It=e=>"width"in e?{x:e.left,y:e.top,w:e.width,h:e.height}:e;function pd(e){fi(e.target,e.agents,e.onFound);const t=e.rect,n=t?{left:t.x,top:t.y,width:t.w,height:t.h,right:"auto",bottom:"auto"}:void 0,r=e.multi&&!e.focused&&!e.hidden,a=e.hidden?{inert:""}:{},o={style:n,"data-pane":e.id,"data-focused":e.multi&&e.focused||void 0,"data-hidden":e.hidden||void 0,"aria-hidden":e.hidden||void 0,...a,onPointerDownCapture:r?e.onFocusIn:void 0,onFocusCapture:r?e.onFocusIn:void 0},l=e.id;return e.strip?s.jsx("div",{className:"wsp-pane",role:"tabpanel",id:Ps(l),"aria-labelledby":$t(l),...o,children:e.children}):s.jsx("div",{className:"wsp-pane",...o,children:e.children})}const $t=e=>`wsp-tab-${e}`,Ps=e=>`wsp-pane-${e}`;function bd(e){const{stage:t,stateRef:n,canvasRef:r}=e,{shell:a,geometry:o}=t,l=f.useMemo(()=>Lr(e.palette),[e.palette]),d=Mr(),c=Or(),i=f.useRef(null),u=f.useRef(null),m=f.useRef(null),k=f.useRef(null),b=f.useRef(null),j=f.useRef(1),R=de(),h=n.current.agents,x=pn(a.target,h,e.now),_=f.useCallback((v,M)=>t.onLaunched({sessionId:v,key:M}),[t]),T=(o==null?void 0:o.fill)===!0,[C,y]=f.useState(null);f.useEffect(()=>{if(!C)return;const v=()=>y(null);return window.addEventListener("dragend",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragend",v),window.removeEventListener("drop",v)}},[C]);const S=Ht(x,T),z=Je(x.kind==="empty"?null:S),Q=x.kind==="session"&&x.session.status.state==="waiting",H=Je(Q),Z=Je(a),F=Je(o);f.useLayoutEffect(()=>{a.phase==="waiting"&&t.reveal()},[a.phase,t.reveal]),f.useLayoutEffect(()=>{const v=i.current;if(!v)return;const M=a.grace?a.origin:null;for(const A of v.querySelectorAll(".ts-head button")){const D=A.getBoundingClientRect();A.toggleAttribute("data-over-origin",!!M&&D.left<M.x+M.w&&D.right>M.x&&D.top<M.y+M.h&&D.bottom>M.y)}},[a.grace,a.origin,a.phase,o]);const E=f.useCallback((v,M)=>{const A=i.current,D=u.current,B=m.current,ie=k.current;A&&(A.style.clipPath=v.clip,A.style.opacity=v.stage<1?String(v.stage):"",D&&(D.style.opacity=v.content<1?String(v.content):""),A.style.setProperty("--stage-late",String(v.late)),A.style.setProperty("--stage-chip",String(v.chip)),B&&(B.style.transform=`translate(${v.edge.rect.x}px, ${v.edge.rect.y}px)`,B.style.width=`${v.edge.rect.w}px`,B.style.height=`${v.edge.rect.h}px`,B.style.borderRadius=`${v.edge.radius}px`,B.style.opacity=String(v.edge.opacity)),ie&&(ie.style.transform=v.rider?v.rider.transform:"",ie.style.opacity=v.rider?String(v.rider.opacity):""),M&&(M.style.opacity=String(v.board)))},[]),ee=f.useCallback(()=>{var D;const v=i.current;v&&(v.style.clipPath="",v.style.opacity="",v.style.removeProperty("--stage-late"),v.style.removeProperty("--stage-chip"),v.removeAttribute("data-rider")),u.current&&(u.current.style.opacity="");const M=(D=r.current)==null?void 0:D.querySelector(".stage-nav .board-nav");M&&(M.style.opacity="");for(const B of[m.current,k.current])B&&(B.style.transform="",B.style.opacity="");const A=Ot(r.current);A&&(A.style.opacity="")},[r]),$=f.useCallback(v=>{var W,ne,Pe;const M=v==="close"&&b.current!=null?j.current:1;(W=b.current)==null||W.cancel(),b.current=null,j.current=v==="open"?0:1;const A=i.current,D=F.current,B=()=>{j.current=1,v==="open"?t.revealed():t.closed(ba(z.current))};if(!A||!D){B();return}if(D.fill){ee(),B();return}if(document.documentElement.dataset.motion==="instant"){ee(),B();return}const ie=A.getBoundingClientRect(),ae={x:ie.left,y:ie.top},g=ie.width,w=ie.height,N=D.takeover?{x:0,y:0,w:g,h:w}:{x:g-D.stageW,y:0,w:D.stageW,h:w},P=Z.current;let U=null,J=null;if(v==="open")U=P.origin?nt(P.origin,ae):null,J=P.originName?nt(P.originName,ae):null;else{const pe=md(r.current,ls(P.target));U=pe.card?nt(It(pe.card),ae):null,J=pe.name?nt(It(pe.name),ae):null}const re=U??Ia(N),oe=(ne=A.querySelector(".ts-name"))==null?void 0:ne.getBoundingClientRect(),ce=Kt(),Re={direction:v,w:g,h:w,from:v==="open"?re:N,to:v==="open"?N:re,rider:!ce&&U&&J&&oe&&oe.height>0?{card:J,header:nt(It(oe),ae)}:null};A.toggleAttribute("data-rider",Re.rider!=null),m.current&&(m.current.style.borderColor=v==="close"?"var(--line)":H.current?"var(--warn)":"var(--inflight)");const Se=Ot(r.current),Ee=t.navRef.current,q=M<1?Ea(1-M):0;let se=!1;const he=((Pe=r.current)==null?void 0:Pe.querySelector(".stage-nav .board-nav"))??null;if(Ee&&Se&&!D.takeover&&!ce){const pe=La(Se,ns(c.getState().nodeInternals.values()),d.getViewport());se=!0,Ee.fold(v,pe,{reduced:ce,from:q,onFrame:Be=>{Se.style.opacity=String(Be.board)}})}const p=ce?Ir("--dur-xfade"):v==="open"?cs:ds,L=ms(p,(pe,Be)=>{v==="open"&&(j.current=Be);const et=(ce?Fa:Pa)(Re,Be);ce&&he&&!D.takeover&&(he.style.opacity=String(et.stage)),E(et,se?null:Se)},void 0,q);b.current=L,L.finished.then(pe=>{!pe||b.current!==L||(b.current=null,B())})},[t,z,H,Z,F,r,c,d,E,ee]),le=Je($);f.useLayoutEffect(()=>{var v,M;if(a.phase==="opening")le.current("open");else if(a.phase==="closing")le.current("close");else if(a.phase==="open"){const A=b.current!=null;(v=b.current)==null||v.cancel(),b.current=null,j.current=1,ee(),A&&((M=t.navRef.current)==null||M.fold("open",new Map,{reduced:!0}))}},[a.phase]),f.useEffect(()=>()=>{var M;(M=b.current)==null||M.cancel();const v=Ot(r.current);v&&(v.style.opacity="")},[r]);const te=t.split??null,Y=(te==null?void 0:te.focused)??"p0",K=T?t.arrangement??null:null,G=K!=null&&K.mode!=="one",me=(G&&te?[...un(te.root)].sort(gd):[Y]).map(v=>{const M=v===Y,A=M?a.target:Fr(te,v,null),D=M?x:pn(A,h,e.now);return{id:v,focused:M,target:A,show:D,name:Ht(D,!0)}}),je=(v,M)=>{var B,ie,ae,g;const A=hn();if(!A||!te)return null;if(A.kind==="session"){const w=me.find(N=>{var P;return((P=N.target)==null?void 0:P.kind)==="session"&&N.target.id===A.id});if(w){const P=(G?K.rects.get(w.id):null)??{x:0,y:0,w:((B=u.current)==null?void 0:B.clientWidth)??0,h:((ie=u.current)==null?void 0:ie.clientHeight)??0};return{pane:w.id,zone:"here",rect:P,label:R("board.stage.split.already"),already:!0}}}const D=me.filter(w=>!(G&&K.mode==="strip"&&!w.focused));for(const w of D){const N=G?K.rects.get(w.id):{x:0,y:0,w:((ae=u.current)==null?void 0:ae.clientWidth)??0,h:((g=u.current)==null?void 0:g.clientHeight)??0};if(!N||v<N.x||M<N.y||v>N.x+N.w||M>N.y+N.h)continue;if(A.kind==="pane"&&A.id===w.id)return null;const P=A.kind==="pane"||un(te.root).length<Br&&w.show.kind!=="empty",U=zr(N,v,M,P),J=A.kind==="pane"?U==="here"?"board.stage.split.moveSwap":U==="top"?"board.stage.split.moveAbove":U==="bottom"?"board.stage.split.moveBelow":"board.stage.split.moveBeside":U==="here"?"board.stage.split.showHere":U==="top"?"board.stage.split.openAbove":U==="bottom"?"board.stage.split.openBelow":"board.stage.split.openBeside";return{pane:w.id,zone:U,rect:Hr(N,U),label:R(J,{name:A.name}),already:!1}}return null},Le=v=>{var A;const M=(A=u.current)==null?void 0:A.getBoundingClientRect();return M?{x:v.clientX-M.left,y:v.clientY-M.top}:null};function ye(v){var D;if(!fn((D=v.dataTransfer)==null?void 0:D.types))return;v.preventDefault(),v.stopPropagation();const M=Le(v),A=M?je(M.x,M.y):null;v.dataTransfer&&(v.dataTransfer.dropEffect=A?"move":"none"),y(B=>B&&A&&B.pane===A.pane&&B.zone===A.zone&&B.label===A.label?B:A)}function Ne(v){var A;const M=v.relatedTarget;M&&((A=u.current)!=null&&A.contains(M))||y(null)}function xe(v){var B;if(!fn((B=v.dataTransfer)==null?void 0:B.types))return;v.preventDefault(),v.stopPropagation();const M=Le(v),A=M?je(M.x,M.y):null,D=hn();y(null),Kr(),!(!A||!D)&&(D.kind==="pane"?t.movePaneTo(D.id,A.pane,A.zone):A.already?t.focusPaneId(A.pane,{keys:!0}):A.zone==="here"?t.dropHere(A.pane,D.id):t.openBeside(D.id,{at:A.pane,zone:A.zone}))}const ve=v=>{const M=v.focused,A=v.id,D=v.show,B=G?K.rects.get(A):null,ie=G&&B?t.geometryFor(B.w,B.h):o,ae=()=>{M||t.focusPaneId(A)},g=G?{number:K.order.indexOf(A)+1,primary:M,max:K.why==="max",onMax:()=>K.why==="max"?t.showAll():t.toggleMax(A),onDragHead:N=>$r(N,{kind:"pane",id:A,name:v.name})}:null,w=G?()=>t.closePane(A):T?D.kind==="empty"?e.onBoard??t.close:t.emptyPane:t.close;return s.jsx(fd,{show:D,geometry:ie,cell:t.cell,readToken:l,expanded:t.expanded,firstRun:M?t.firstRun:!1,asksWaiting:M&&e.waitingSessions.length>0,asks:M?xa(e.asks.view,e.waitingSessions,e.now):null,arrival:M?ya(e.asks.view,e.waitingSessions):null,focusRequest:G?t.requestFor(A):a.phase==="waiting"?null:a.focusRequest,takeTypeAhead:t.takeTypeAhead,holdsTypeAhead:t.holdsTypeAhead,onWantKeys:M?t.focusPane:()=>t.focusPaneId(A,{keys:!0}),onNextAsk:e.asks.nextAsk,onOpenWaiting:N=>t.switchTo(N,{focusPane:!0}),onAnswerArrival:e.asks.nextAsk,onClose:w,waiting:M&&T&&D.kind==="empty"?wa(e.waitingSessions,e.now):null,onToggleExpand:t.toggleExpand,onFirstRunDone:t.firstRunDone,onNewSession:N=>{ae(),t.openPopover(N)},onCols:t.onCols,onColsReset:t.onColsReset,onRelease:t.release,onCell:M?t.onCell:void 0,onBarH:M?t.onBarH:void 0,onHeadH:M?t.onHeadH:void 0,onLaunched:t.onLaunched,onContinuation:(N,P)=>{const U=e.stateRef.current.agents.get(N);return!U||U.provider!=="claude"||U.cwd!==P?!1:(G?t.dropHere(A,N):t.switchTo(N,{focusPane:!0}),!0)},onLaunchAgain:D.kind==="launch"?()=>{ae(),t.launch(D.agent,D.cwd,D.options)}:void 0,onAnnounce:t.announce,windows:t.windows,split:g})};if(!o)return null;const fe=a.phase==="waiting"||a.phase==="opening"||a.phase==="closing",be=x.kind==="session"?x.session.ref.cwd:x.kind==="launch"?x.cwd:null;return s.jsxs("div",{ref:i,className:"stage-dock","data-phase":a.phase,"data-morph":fe||void 0,"data-grace":a.grace||void 0,"data-takeover":o.takeover||void 0,"data-fill":T||void 0,style:{"--stage-w":`${o.stageW}px`},children:[s.jsx("div",{className:"stage-ground","aria-hidden":"true"}),s.jsxs("div",{ref:u,className:"stage-in","data-split":G?K.mode:void 0,onDragOverCapture:T?ye:void 0,onDragLeave:T?Ne:void 0,onDropCapture:T?xe:void 0,children:[(K==null?void 0:K.mode)==="strip"&&s.jsxs("div",{className:"wsp-strip",role:"tablist","aria-label":R("board.stage.split.strip"),style:{height:K.strip},onKeyDown:v=>{var B;if(v.target.getAttribute("role")!=="tab")return;const M=K.order,A=Pr(v,M.indexOf(Y),M.length);if(A.kind!=="select")return;v.preventDefault(),v.stopPropagation();const D=M[A.index];t.focusPaneId(D),(B=document.getElementById($t(D)))==null||B.focus()},children:[K.order.map((v,M)=>{const A=me.find(B=>B.id===v);if(!A)return null;const D=v===Y;return s.jsxs("button",{type:"button",role:"tab",id:$t(v),"aria-controls":Ps(v),tabIndex:D?0:-1,className:"wsp-tab","aria-selected":D,"data-on":D||void 0,title:A.name,onClick:()=>t.focusPaneId(v,{keys:!0}),children:[s.jsx("span",{className:"wsp-tab-n","aria-hidden":"true",children:M+1}),s.jsx("span",{className:"wsp-tab-name",children:A.name})]},v)}),K.why==="max"&&s.jsx("button",{type:"button",className:"wsp-all",onClick:t.showAll,children:R("board.stage.split.showAll",{count:me.length})}),K.why==="narrow"&&s.jsx("span",{className:"wsp-why",title:R("board.stage.split.narrowHint"),children:R("board.stage.split.narrow")})]}),me.map(v=>s.jsx(pd,{id:v.id,rect:G?K.rects.get(v.id)??null:null,multi:G,focused:v.focused,hidden:G&&K.mode==="strip"&&!v.focused,strip:G&&K.mode==="strip",target:v.target,agents:h,onFound:_,onFocusIn:()=>t.focusPaneId(v.id),children:ve(v)},v.id)),T&&s.jsx("p",{className:"wsp-note",role:"status","aria-atomic":"true","data-on":t.splitNote?!0:void 0,children:t.splitNote}),G&&K.mode==="split"&&K.dividers.map(v=>s.jsx(li,{d:v,label:R("board.stage.split.divider"),inRef:u,onRatio:t.setSplitRatio},v.path||"root")),C&&s.jsx("div",{className:"wsp-zone","data-zone":C.zone,"data-already":C.already||void 0,style:{left:C.rect.x,top:C.rect.y,width:C.rect.w,height:C.rect.h},"aria-hidden":"true",children:s.jsx("span",{className:"wsp-zone-label",children:C.label})})]}),s.jsx("span",{ref:m,className:"stage-edge","aria-hidden":"true"}),s.jsx("span",{ref:k,className:"stage-rider","aria-hidden":"true",children:S}),a.popover&&s.jsx(ii,{anchorId:a.popover,projects:pa(h.values(),be),onStart:t.launch,onClose:t.closePopover,windows:t.windows})]})}const xd=Object.freeze(Object.defineProperty({__proto__:null,StageDock:bd,StageNavigator:hd},Symbol.toStringTag,{value:"Module"}));export{qo as C,Ue as S,xd as a};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{bM as U,bN as W,bO as j,t as i,bP as O,bo as p,aG as G,bQ as H,bR as V,bS as B,bT as z,bU as X,ay as J,bV as K,az as E,bW as M,bX as S,bY as I,bZ as q}from"./app-CdRq5GPP.js";const m=14,Z=18,Q=24,A=12,Y=26,ee=24,x=7,T=50,te=22,R=25,$=5,ne=8,se=168,oe=360;function ae(e,n){return n==="rail"||e<=0?x*2+T:x+T+$+(e-1)*R+te+ne}function Pe(e){return e.replace(/^(\d+m) \d+s$/,"$1")}function re(e,n){if(n==="rail")return[];const t=[];for(let s=0;s<e;s++)t.push(x+T+$+s*R);return t}function ie(e){return Math.max(1,Math.floor((e-m*2+A)/(se+A)))}function Ne(e,n,t){const s=new Map([...new Set(e.map(u=>u.col))].sort((u,c)=>u-c).map((u,c)=>[u,c])),a=e.map((u,c)=>({c:u,boardCol:s.get(u.col),order:u.order??c,i:c})).sort((u,c)=>u.boardCol-c.boardCol||u.order-c.order||u.i-c.i),o=s.size;let r=0,l=Math.max(1,o);if(t==="rail")for(;l>1;)l=Math.ceil(l/2),r+=1;else{const u=ie(n);for(;l>u;)l=Math.ceil(l/2),r+=1}const d=t==="rail"?Math.max(0,Math.floor(n-m*2)):Math.max(0,Math.min(oe,Math.floor((n-m*2-A*(l-1))/l))),g=t==="rail"?ee:Y,h=Array.from({length:l},()=>Z),b=Array.from({length:l},()=>[]);for(const{c:u,boardCol:c}of a){const f=t==="rail"?0:c>>r,C=ae(u.rows,t);b[f].push({sessionId:u.sessionId,col:f,boardCol:c,x:m+f*(d+A),y:h[f],w:d,h:C,rows:re(u.rows,t)}),h[f]+=C+g}const k=b.flat(),D=Math.max(0,...k.map(u=>u.y+u.h));return{density:t,columns:l,merges:r,width:n,height:k.length?D+Q:0,tileW:d,tiles:k}}function le(e){const n=[...e].sort((a,o)=>a.x-o.x||a.y-o.y),t=[];let s=-1/0;for(const a of n)t.length===0||a.x>=s?(t.push([a]),s=a.x+a.w):(t[t.length-1].push(a),s=Math.max(s,a.x+a.w));return t.flatMap((a,o)=>[...a].sort((r,l)=>r.y-l.y||r.x-l.x).map((r,l)=>({sessionId:r.sessionId,col:o,order:l})))}function ve(e,n,t){var l;const s=e.tiles.find(d=>d.sessionId===n);if(!s)return null;if(t==="up"||t==="down"){const d=e.tiles.filter(h=>h.col===s.col),g=d.indexOf(s)+(t==="down"?1:-1);return((l=d[g])==null?void 0:l.sessionId)??null}const a=s.col+(t==="right"?1:-1),o=s.y+s.h/2;let r=null;for(const d of e.tiles)d.col===a&&(!r||Math.abs(d.y+d.h/2-o)<Math.abs(r.y+r.h/2-o))&&(r=d);return(r==null?void 0:r.sessionId)??null}function Le(e){const n=new Map,t=new Map;for(const a of e){if(a.type!=="agent")continue;const o=a.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null)continue;if(o.kind==="root"){n.set(o.sessionId,o);continue}const r=t.get(o.sessionId)??[];r.push({d:o,x:a.position.x,y:a.position.y}),t.set(o.sessionId,r)}const s=new Map;for(const a of new Set([...n.keys(),...t.keys()])){const o=(t.get(a)??[]).sort((r,l)=>r.y-l.y||r.x-l.x);s.set(a,{sessionId:a,root:n.get(a)??null,subs:o.map(r=>r.d)})}return s}function Oe(e,n){if(e.size!==n.size)return!1;for(const[t,s]of e){const a=n.get(t);if(!a||s.root!==a.root||s.subs.length!==a.subs.length)return!1;for(let o=0;o<s.subs.length;o++)if(s.subs[o]!==a.subs[o])return!1}return!0}function Re(e,n){return le(e).map(({sessionId:t,col:s,order:a})=>{var o;return{sessionId:t,col:s,order:a,rows:((o=n.get(t))==null?void 0:o.subs.length)??0}})}const y={sayWaiting:U,describeCall:e=>({name:j(e.name).label,subject:W(e.name,e.input)})};function $e(e){return O(e,e.kind==="root"?e.branch:void 0,y)}function Fe(e){return e===0?i("board.nav.none"):i("board.hosts.sessions",{count:e})}function w(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return Math.abs(n)%360}const ue=3e3;function De(e,n){return e.exitStatus===0&&e.exitSignal===void 0&&n>=ue}function de(e){return e.kind==="live"||e.kind==="ended"||e.kind==="detached"||e.kind==="attaching"&&e.reconnect}function ce(e,n){return de(n)?"shown":n.kind==="attaching"&&e!=="hidden"?"held":"hidden"}function Ue(e,n){const t=ce(e.state,n),s=t==="shown"&&(e.state==="held"||e.state==="shown"&&e.afterHold);return{state:t,afterHold:s}}function We(e,n){return e.kind==="starting"||e.kind==="attaching"&&n==="hidden"}function je(e){return e.kind==="live"&&!e.readOnly}function _(e){return H(Math.max(0,Math.floor(e/1e3)))}function he(e,n){if(e.closedAt!=null){const t=p(n-e.closedAt);return{state:"ended",phrase:t===i("common.ago.now")?i("board.stage.phrase.endedJustNow"):i("board.stage.phrase.endedAgo",{ago:t})}}if(e.waiting)return{state:"waiting",phrase:i("board.queue.waiting"),emphasis:_(n-e.waiting.since),...e.waiting.tool?{tool:e.waiting.tool}:{},...e.waiting.detail?{arg:e.waiting.detail}:{}};if(e.yourTurn&&!e.tool){if(e.fresh)return{state:"ready",phrase:i("board.stage.phrase.ready"),arg:i("board.stage.phrase.firstPrompt")};const t=e.lastTurnEndAt!=null?p(n-e.lastTurnEndAt):null;return{state:"idle",phrase:i("board.list.yourTurn"),...t?{arg:P(t)}:{}}}if(e.fresh&&!e.tool&&!e.subagentsLive)return{state:"ready",phrase:i("board.stage.phrase.ready"),arg:i("board.stage.phrase.firstPrompt")};if(e.active){const t={state:"working",phrase:i("board.stage.phrase.working")};return e.tool?(t.tool=e.tool.name,e.tool.subject&&(t.arg=e.tool.subject),e.tool.startedAt!=null&&(t.seconds=G(e.tool.startedAt,void 0,n))):e.subagentsLive&&(t.arg=i("board.stage.subagentsRunning",{count:e.subagentsLive})),t}return e.fresh?{state:"ready",phrase:i("board.stage.phrase.ready"),arg:i("board.stage.phrase.firstPrompt")}:e.lastTurnEndAt!=null?{state:"idle",phrase:i("board.stage.phrase.idle"),arg:P(p(n-e.lastTurnEndAt))}:{state:"idle",phrase:i("board.stage.phrase.idle")}}function P(e){return e===i("common.ago.now")?i("board.stage.phrase.lastTurnNow"):i("board.stage.phrase.lastTurn",{ago:e})}const ge="board.stage.reconnectNote";function Ge(e,n){switch(n.kind){case"empty":return{state:"none",phrase:""};case"attaching":return n.reconnect?{state:"attaching",phrase:i("board.stage.phrase.reconnecting"),arg:i(ge)}:{state:"attaching",phrase:i("board.stage.attaching")};case"starting":return{state:"starting",phrase:i("board.stage.phrase.starting"),arg:n.cwd};case"tmux-installing":return{state:"starting",phrase:i("board.stage.settingUpTmux")};case"tmux-missing":return{state:"detached",phrase:i("board.stage.phrase.notAttached")};case"error":return n.code?{state:"detached",phrase:i("board.stage.phrase.notAttached")}:e??{state:"none",phrase:""};case"not-attachable":if(n.target.kind==="C"&&e&&e.state!=="ended"){const{tool:t,arg:s}=e;return{state:"elsewhere",phrase:i(pe(e.state)),...t?{tool:t}:{},...s?{arg:s}:{}}}return e??{state:"ended",phrase:i("board.stage.phrase.ended")};case"ended":return(e==null?void 0:e.state)==="ended"?e:{state:"ended",phrase:n.atOpen?i("board.stage.phrase.ended"):i("board.stage.phrase.endedJustNow")};default:return e??{state:"none",phrase:""}}}function He(e,n,t){return n.kind==="live"&&t&&e.state!=="waiting"}const Ve="board.stage.launchedUnreachable",Be="board.stage.provenanceUnknown";function fe(e,n){return e.kind==="C"&&n.windows===!0&&(n.launched===!0||e.provenance==="panel")}function ze(e,n){return e.kind==="C"&&n.windows===!0&&!fe(e,n)&&e.provenance==="unknown"}function Xe(e){switch(e){case"idle":case"ready":return"board.stage.elsewhere.idle";case"waiting":return"board.stage.elsewhere.waiting";case"working":return"board.stage.elsewhere.working";default:return"board.stage.elsewhere.running"}}function pe(e){return e==="working"?"board.stage.phrase.workingElsewhere":e==="idle"||e==="ready"||e==="waiting"?"board.stage.phrase.waitingElsewhere":"board.stage.phrase.elsewhere"}function Je(e,n){switch(n.kind){case"live":return i("board.stage.announceLive",{name:e});case"ended":return i("board.stage.announceEnded",{name:e});case"detached":return i("board.stage.announceDetached",{name:e});case"not-attachable":return n.stillRunning?i("board.stage.announceStillRunning",{name:e}):i("board.stage.announceNoPane",{name:e});case"tmux-installing":return i("board.stage.announceTmuxSetup");case"tmux-missing":return i("board.stage.announceTmuxMissing");case"error":return we(n.message);default:return null}}const be="board.stage.panelStopped",me=new Set(["That is not a session id.","The provider must be claude or codex."]);function we(e){return me.has(e.trim())?i(be):e}function Ke(e){return e?i("board.stage.closedNamed",{name:e}):i("board.stage.closed")}function Ae(e){return/^\//.test(e)||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(e)}function F(e){const n=e.split(/[\\/]+/).filter(Boolean);return n.length?n[n.length-1]:e}function ke(e,n){const t=new Map;for(const o of e){if(!o.cwd||!Ae(o.cwd))continue;const r=t.get(o.cwd);(!r||o.at>r.at)&&t.set(o.cwd,o)}const s=[...t.values()].sort((o,r)=>r.at-o.at),a=n?s.findIndex(o=>o.cwd===n):-1;return a>0&&s.unshift(...s.splice(a,1)),s.map(o=>({cwd:o.cwd,name:o.name||F(o.cwd),hue:o.hue,at:o.at}))}function qe(e,n=24){if(e.length<=n)return e;const t=e.split(/[\\/]+/).filter(Boolean),s=t.slice(-2).join("/");if(s.length+2<=n)return`…/${s}`;const a=t[t.length-1]??e;return a.length+2<=n?`…/${a}`:`…/${a.slice(0,Math.max(1,n-3))}…`}function xe(e){return e==="codex"?"Codex":"Claude Code"}function Ze(e){return e==="codex"?"Codex":"Claude"}const Te=160,ye=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e;function N(e){var t;const n=((t=(e??"").split(`
|
|
2
|
-
`).find(s=>s.trim()!==""))==null?void 0:t.trim())??"";return n?ye(n,Te):null}function _e(e,n){const t=[];for(const s of e)s.sessionId===n&&s.kind==="subagent"&&t.push(s);return t}function Ce(e,n){var a,o;const t=e.waiting;let s=null;if(e.state==="active")for(let r=e.tools.length-1;r>=0;r--){const l=e.tools[r];if(l.endedAt!=null)continue;const d=y.describeCall(l);s={name:d.name,subject:d.subject??null,startedAt:l.startedAt};break}return{closedAt:e.closedAt??null,waiting:t&&J(t)?{since:t.since,...(a=t.tool)!=null&&a.name?{tool:t.tool.name}:{},...(o=t.tool)!=null&&o.preview?{detail:t.tool.preview}:{}}:null,active:e.state==="active",tool:s,subagentsLive:n.filter(r=>r.state==="active").length,lastTurnEndAt:e.lastTurnEndAt??null,fresh:e.prompts.length===0&&!e.firstPrompt&&e.lastTurnEndAt==null,yourTurn:(t==null?void 0:t.kind)==="idle"}}function Ee(e){const{used:n,limit:t}=K(e);return{used:n,window:t}}const v=32,L=e=>e.length>v?`${e.slice(0,v-1).trimEnd()}…`:e;function Me(e,n){const{title:t}=E(e),s=[...n.values()].filter(r=>r.kind!=="subagent"&&r.sessionId!==e.sessionId&&M(E(r).title,t));if(!s.length)return t;const a=L(S(e)),o=s.filter(r=>M(L(S(r)),a));return a&&!o.length?`${t}${I}${a}`:`${t}${I}${q(e.sessionId,o.map(r=>r.sessionId))}`}function Qe(e,n,t){if(!e||e.kind==="empty")return{kind:"empty"};if(e.kind==="launch")return{kind:"launch",agent:e.agent,cwd:e.cwd,name:F(e.cwd),hue:w(e.key),key:e.key,...e.options?{options:e.options}:{}};const s=V(n,e.id),a=e.launch?{launch:e.launch}:{},o=n.get(s);if(!o)return{kind:"session",session:{ref:{sessionId:s,provider:"claude",cwd:""},name:s.slice(0,8),hue:w(s),status:{state:"none",phrase:""},...e.launch?{launched:!0}:{}},...a};const r=_e(n.values(),s),l=Ce(o,r),d=o.provider==="codex"?"codex":"claude",g=B(o),h=O(o,void 0,y),b=[l.subagentsLive?i("board.stage.subagentsWorking",{count:l.subagentsLive}):null,o.closedAt!=null?i("board.stage.phrase.endedAgo",{ago:p(t-o.closedAt)}):null,`${xe(d)}${o.cwd?` · ${o.cwd}`:""}`].filter(Boolean).join(" · ");return{kind:"session",session:{ref:{sessionId:s,provider:d,cwd:o.cwd??""},name:Me(o,n),hue:w(s),model:o.model??null,effort:o.effort??null,status:he(l,t),contextUse:Ee(o),promptCount:X(o.prompts).length,ghostLine:(h==null?void 0:h.long)??N(g),context:{prompt:N(g),fact:b},endedAgo:o.closedAt!=null?p(t-o.closedAt):null,...o.panelLaunch!=null||e.launch?{launched:!0}:{},rename:z(o)},...a}}function Ye(e,n,t){var a,o;if(e.track.length===0)return null;let s=null;if(e.next){const r=n.find(l=>l.id===e.next.id);s={name:e.next.label,waited:r?_(t-r.waiting.since):"",tool:((a=r==null?void 0:r.waiting.tool)==null?void 0:a.name)??null}}return{position:e.position?{index:e.position.index-1,total:e.position.total}:null,resumed:((o=e.resumed)==null?void 0:o.label)??null,next:s,clear:e.clear}}function Se(e){return e.kind==="asked"?i("board.stage.askAsked"):e.kind==="idle"?i("board.stage.askIdle"):e.tool?e.tool.name==="Bash"?i("board.stage.askCommand"):i("board.stage.askTool",{tool:e.tool.name}):i("board.stage.askPermission")}function et(e,n){var s;const t=e[0];return t?{id:t.id,name:t.label,waited:_(n-t.waiting.since),ask:Se(t.waiting),command:((s=t.waiting.tool)==null?void 0:s.preview)||null}:null}function tt(e,n){var a;const t=e.arrival;if(!t)return null;const s=n.find(o=>o.id===t.id);return{name:t.label,tool:((a=s==null?void 0:s.waiting.tool)==null?void 0:a.name)??null}}function nt(e,n){const t=[];for(const s of e)s.kind!=="root"||!s.cwd||t.push({cwd:s.cwd,hue:w(s.sessionId),at:s.lastEventAt??s.startedAt});return ke(t,n)}export{Je as A,We as B,Qe as C,nt as D,Ke as E,T as F,et as G,tt as H,Ye as I,he as J,Ce as K,Ve as L,Be as P,te as R,x as T,Re as a,ve as b,$e as c,Oe as d,Le as e,w as f,F as g,qe as h,Ae as i,De as j,de as k,xe as l,Ue as m,Ne as n,we as o,fe as p,ze as q,Pe as r,Fe as s,Xe as t,ge as u,Ze as v,ce as w,Ge as x,He as y,je as z};
|