@spexcode/spec-dashboard 0.7.0-next.0 → 0.7.0-next.2
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/assets/{App-CDnq7CoJ.js → App-DYT3vIqP.js} +2 -2
- package/{dist-public/assets/EmptyView-Dil8vYWz.js → dist/assets/EmptyView-DXv-3Vi6.js} +1 -1
- package/{dist-public/assets/EvalsPage-DnIhSuCK.js → dist/assets/EvalsPage-DnqAjyfu.js} +1 -1
- package/dist/assets/{FileView-CiopSqO_.js → FileView-Ky36PD82.js} +2 -2
- package/dist/assets/{GraphView-CpSd8In8.js → GraphView-BvMh1fxd.js} +3 -3
- package/dist/assets/{IssuesPage-B0Lgqyjr.js → IssuesPage-o2vddaI6.js} +1 -1
- package/dist/assets/{MobileApp-BWgx12mU.js → MobileApp-BpxEZ2v5.js} +2 -2
- package/dist/assets/{Modal-DbaOKtG9.js → Modal-B5_IjGMa.js} +1 -1
- package/dist/assets/{NodeView-CVaIUdMO.js → NodeView-CmbCDI2Y.js} +1 -1
- package/{dist-public/assets/ProjectsPage-Z0t0yxxh.js → dist/assets/ProjectsPage-CgdGHve4.js} +1 -1
- package/dist/assets/{ProseActions-CFA-z4t3.js → ProseActions-Dkx3P_qH.js} +1 -1
- package/dist/assets/{Settings-DCI7WK4U.js → Settings-DMBJWtL1.js} +1 -1
- package/dist/assets/{SpecView-Cz828zhT.js → SpecView-p-_SoBZr.js} +1 -1
- package/{dist-public/assets/Thread-DIfN4RS4.js → dist/assets/Thread-C1g83eTx.js} +1 -1
- package/dist/assets/{WorkspaceSurface-CTZ5UUgv.js → WorkspaceSurface-BDOIUi8k.js} +1 -1
- package/dist/assets/{index-C6l-jpX4.js → index-46VMgJJ4.js} +1 -1
- package/dist/assets/index-B948v2sT.css +1 -0
- package/dist/assets/{index-DqfNBCzh.js → index-CgZDxhet.js} +1 -1
- package/dist/assets/{tabs-B7_g8HG7.js → tabs-Bvj-BhvS.js} +52 -51
- package/dist/index.html +2 -2
- package/dist-public/assets/{App-5COraOZF.js → App-CDdmrKFq.js} +2 -2
- package/{dist/assets/EmptyView-9otc0raU.js → dist-public/assets/EmptyView-DRdZkhRg.js} +1 -1
- package/{dist/assets/EvalsPage-CvJFW7Xx.js → dist-public/assets/EvalsPage-CBY68cBl.js} +1 -1
- package/dist-public/assets/{FileView-BubZCad5.js → FileView-DqnTViYx.js} +2 -2
- package/dist-public/assets/{GraphView-gPGwYpUk.js → GraphView-BJZFYfsi.js} +3 -3
- package/dist-public/assets/{IssuesPage-gbqBOftY.js → IssuesPage-DKmph_qG.js} +1 -1
- package/dist-public/assets/{MobileApp-CAqNJ_Bh.js → MobileApp-BFjt38EF.js} +2 -2
- package/dist-public/assets/{Modal-B_Q59vv6.js → Modal-BBcXFZSm.js} +1 -1
- package/dist-public/assets/{NodeView-B3WRY-q0.js → NodeView-B1bLcqBp.js} +1 -1
- package/{dist/assets/ProjectsPage-B8i6SOxZ.js → dist-public/assets/ProjectsPage-CFdwq3E1.js} +1 -1
- package/dist-public/assets/{ProseActions-DPypFjCH.js → ProseActions-DjJjWzCZ.js} +1 -1
- package/dist-public/assets/{Settings-d9DTofmL.js → Settings-gD1FYaqA.js} +1 -1
- package/dist-public/assets/{SpecView-CNGt9F1G.js → SpecView-DMl6Tici.js} +1 -1
- package/{dist/assets/Thread-BD6H7vPk.js → dist-public/assets/Thread-BNw463gn.js} +1 -1
- package/dist-public/assets/{WorkspaceSurface-BEDKMlRs.js → WorkspaceSurface-D698lLJt.js} +1 -1
- package/dist-public/assets/index-B948v2sT.css +1 -0
- package/dist-public/assets/{index-BJDLZCaX.js → index-BtwC9HM0.js} +1 -1
- package/dist-public/assets/{index-r6NCWBwM.js → index-CTgHFYup.js} +1 -1
- package/dist-public/assets/{tabs-BSpGhf1t.js → tabs-Di_VWVhW.js} +52 -51
- package/dist-public/index.html +2 -2
- package/package.json +5 -4
- package/dist/assets/index-BuOQYAQK.css +0 -1
- package/dist-public/assets/index-BuOQYAQK.css +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Ds=Object.defineProperty;var Ts=(s,t,n)=>t in s?Ds(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var Ee=(s,t,n)=>Ts(s,typeof t!="symbol"?t+"":t,n);import{u as D,j as e,I as R,r as h,f as $s,g as Ms,C as Ze,h as Os,b as be,a as Ce,i as es,k as Ps,m as Ls,n as Rs,o as V,S as De,e as Te,q as As,t as $e,V as Ks}from"./index-C6l-jpX4.js";import{i as zs,M as Ws}from"./Modal-DbaOKtG9.js";import{u as H,R as Bs,a as ae,n as M,r as Z,b as ke,c as Fs,d as ss,e as Ne,f as _s,g as Is,h as qs,I as ce,P as ts}from"./App-CDnq7CoJ.js";import{f as Me,w as ee,i as Oe,s as Hs,C as Gs,a as Q,b as z,c as Pe,o as W,n as ge,g as Ys,d as Le,e as je,h as ie,j as Vs,k as ns,u as oe,D as U,l as L,S as J,m as X,p as Us,q as Re,r as Ae,t as se,v as Ke,x as Js,y as Qs,z as le,A as Xs,B as Zs,E as et,F as de,G as st,H as tt,I as rs,J as nt,K as ze,L as rt,M as as,N as os,O as at,P as cs,Q as ot,R as ct,T as it,U as lt,V as dt,W as ut,X as pt,Y as ht,Z as ft,_ as te,$ as ne,a0 as mt,a1 as xt,a2 as gt,a3 as jt,a4 as yt,a5 as bt,a6 as is,a7 as kt,a8 as Nt}from"./tabs-B7_g8HG7.js";import{n as wt}from"./GraphStats-CxHsXNy-.js";const We=Bs,vt=s=>Z(s),St={evals:["shell.evals"]};function Et(){const s=D(),{dock:t}=ae(),{setDock:n}=H();if(!n)return null;const r=s(t?"dockModes.collapse":"dockModes.expand");return e.jsx("button",{type:"button",className:"rail-btn rail-panel-toggle","data-tip":r,"aria-label":r,"aria-pressed":t,onClick:()=>n(o=>!o),children:e.jsx(R,{name:t?"panel-left":"panel-right",size:18})})}function Ct({page:s,active:t,label:n,disabled:r=!1,onNavigate:o,badge:a=0}){return r?e.jsxs("span",{className:"rail-btn disabled","data-tip":n,"aria-label":n,"aria-disabled":"true",children:[e.jsx(R,{name:Oe(s)||s,size:18}),a>0&&e.jsx("span",{className:"rail-badge","aria-label":`${a} needs you`,children:a>99?"99+":a})]}):e.jsxs("a",{className:t?"rail-btn on":"rail-btn","data-tip":n,"aria-label":n,"aria-current":t?"page":void 0,href:vt(s),onClick:i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;i.preventDefault(),(o==null?void 0:o())===!0||M(s)},children:[e.jsx(R,{name:Oe(s)||s,size:18}),a>0&&e.jsx("span",{className:"rail-badge","aria-label":`${a} needs you`,children:a>99?"99+":a})]})}function Be({page:s,graphOnly:t=!1,needsYou:n=0,hideDockToggle:r=!1}){const o=D(),{setDock:a,setDockMode:i}=H(),d=t?["graph",...We]:We;return e.jsxs("nav",{className:"side-rail","aria-label":o("nav.railLabel"),onMouseDownCapture:zs,children:[!r&&e.jsx(Et,{}),d.map(c=>e.jsx(Ct,{page:c,active:s===c||c==="spec"&&s==="file",label:ee(o(`nav.${c}`),...St[c]||[]),badge:c==="sessions"?n:0,disabled:t&&c!=="graph",onNavigate:()=>c==="sessions"?(a==null||a(!0),i==null||i("sessions"),Me(l=>l.page==="sessions"&&l.param)):c==="spec"?(a==null||a(!0),i==null||i("explorer"),Me(l=>l.page==="spec")):(c==="graph"&&(a==null||a(!0),i==null||i("explorer")),!1)},c)),e.jsx("div",{className:"rail-spacer"})]})}const Dt=400,Tt=80,ue=7,pe=6;function Fe(){const[s,t]=h.useState(null),n=h.useRef(null),r=h.useRef(0),o=h.useRef(null),a=h.useRef(null),i=h.useRef(!1),d=h.useRef(()=>{});return ke(!!s,()=>d.current()),h.useEffect(()=>{const c=()=>{r.current&&(clearTimeout(r.current),r.current=0)},l=()=>{c(),o.current=null,a.current&&(a.current.getAttribute("aria-describedby")==="ui-tip"&&a.current.removeAttribute("aria-describedby"),a.current=null),t(k=>(k&&(i.current=!0,setTimeout(()=>{o.current||(i.current=!1)},300)),null))};d.current=l;const f=k=>{const w=k.getAttribute("data-tip");!w||!k.isConnected||(o.current=k,k.getAttribute("aria-describedby")||(k.setAttribute("aria-describedby","ui-tip"),a.current=k),t({text:w,anchor:k}))},g=(k,w)=>{o.current!==k&&(c(),o.current=k,r.current=setTimeout(()=>{r.current=0,f(k)},w))},j=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");w&&g(w,i.current?Tt:Dt)},p=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");!w||w!==o.current||w.contains(k.relatedTarget)||l()},u=k=>{var C,N;const w=(N=(C=k.target).closest)==null?void 0:N.call(C,"[data-tip]");if(!w)return;let E=!0;try{E=w.matches(":focus-visible")}catch{}E&&(c(),f(w))},S=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");w&&w===o.current&&l()};return document.addEventListener("pointerover",j,!0),document.addEventListener("pointerout",p,!0),document.addEventListener("focusin",u,!0),document.addEventListener("focusout",S,!0),document.addEventListener("pointerdown",l,!0),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{c(),document.removeEventListener("pointerover",j,!0),document.removeEventListener("pointerout",p,!0),document.removeEventListener("focusin",u,!0),document.removeEventListener("focusout",S,!0),document.removeEventListener("pointerdown",l,!0),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),d.current=()=>{}}},[]),h.useEffect(()=>{const c=n.current;if(!s||!c)return;if(!s.anchor.isConnected){t(null);return}const l=s.anchor.getBoundingClientRect(),f=c.offsetWidth,g=c.offsetHeight,j=l.top-g-ue>=pe?"top":"bottom",p=j==="top"?l.top-g-ue:l.bottom+ue,u=Math.min(Math.max(l.left+l.width/2-f/2,pe),window.innerWidth-f-pe);c.dataset.place=j,c.style.top=`${Math.round(p)}px`,c.style.left=`${Math.round(u)}px`;const S=c.querySelector(".ui-tip-arrow");S&&(S.style.left=`${Math.round(Math.min(Math.max(l.left+l.width/2-u,10),f-10))-4}px`);const k=requestAnimationFrame(()=>c.classList.add("show"));return()=>cancelAnimationFrame(k)},[s]),s?$s.createPortal(e.jsxs("div",{id:"ui-tip",role:"tooltip",ref:n,className:"ui-tip",children:[s.text,e.jsx("span",{className:"ui-tip-arrow","aria-hidden":"true"})]}),document.body):null}function $t({menu:s,onClose:t,owningNodeOf:n}){const r=D(),[o,a]=h.useState(null);if(h.useEffect(()=>{if(s)return window.addEventListener("click",t),window.addEventListener("contextmenu",t,!0),()=>{window.removeEventListener("click",t),window.removeEventListener("contextmenu",t,!0)}},[s,t]),ke(!!s,t),h.useEffect(()=>{a(null)},[s]),h.useEffect(()=>{if(!o)return;const g=setTimeout(t,900);return()=>clearTimeout(g)},[o,t]),!s)return null;const i=g=>j=>{j.stopPropagation(),t(),g()},d=g=>async j=>{j.stopPropagation(),a(await g()?"copied":"failed")},c=g=>r(o?`explorerMenu.${o}`:g),l=Hs("explorer.openInNewTab"),f=s.kind==="file"?n==null?void 0:n(s.path):null;return e.jsxs(Gs,{x:s.x,y:s.y,anchorKey:s.key,keyboard:s.keyboard,label:r(s.kind==="node"?"explorerMenu.nodeLabel":"explorerMenu.fileLabel"),children:[s.kind==="node"&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(z,{icon:"plus",hint:l,onClick:i(()=>W("spec",s.id)),children:r("tabs.openInNewTab")}),e.jsx(z,{icon:"graph",onClick:i(()=>ge(Ys(s.id))),children:r("explorerMenu.revealOnGraph")})]}),e.jsx(Pe,{}),e.jsxs(Q,{children:[e.jsx(z,{icon:"copy",onClick:d(()=>Le(je(s.id))),children:c("explorerMenu.copyLink")}),e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.id)),children:c("explorerMenu.copyNodeId")})]})]}),s.kind==="file"&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(z,{icon:"plus",hint:l,onClick:i(()=>W("file",s.path)),children:r("tabs.openInNewTab")}),f&&e.jsx(z,{icon:"node",onClick:i(()=>ge(je(f))),children:r("explorerMenu.revealOwner")})]}),e.jsx(Pe,{}),e.jsxs(Q,{children:[e.jsx(z,{icon:"copy",onClick:d(()=>Le(Vs(Z("file",s.path)))),children:c("explorerMenu.copyLink")}),e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.path)),children:c("explorerMenu.copyPath")})]})]}),s.kind==="dir"&&e.jsx(Q,{children:e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.path)),children:c("explorerMenu.copyPath")})})]})}const ls=s=>{let n={open:(()=>{try{const i=JSON.parse(localStorage.getItem(s)||"[]");return new Set(Array.isArray(i)?i.filter(d=>typeof d=="string"):[])}catch{return new Set}})()};const r=new Set,o=i=>{n={open:i};try{localStorage.setItem(s,JSON.stringify([...i]))}catch{}r.forEach(d=>d())};return{subscribe:i=>(r.add(i),()=>r.delete(i)),get:()=>n,toggle:i=>{if(!i)return;const d=new Set(n.open);d.has(i)?d.delete(i):d.add(i),o(d)},reveal:i=>{const d=i.filter(Boolean);if(!d.length||d.every(l=>n.open.has(l)))return;const c=new Set(n.open);d.forEach(l=>c.add(l)),o(c)},clear:()=>{n.open.size&&o(new Set)}}},_=ls("spex.specTreeOpen"),q=ls("spex.diskTreeOpen"),Mt=()=>h.useSyncExternalStore(_.subscribe,_.get,_.get),Ot=s=>_.toggle(s),Pt=(s=[])=>_.reveal(s),Lt=()=>h.useSyncExternalStore(q.subscribe,q.get,q.get),Rt=s=>q.toggle(s),At=s=>{const t=[_.subscribe(s),q.subscribe(s)];return()=>t.forEach(n=>n())},_e=()=>_.get().open.size===0&&q.get().open.size===0,Kt=()=>h.useSyncExternalStore(At,_e,_e),zt=()=>{_.clear(),q.clear()};function ds(s,t){const[n,r]=h.useState(null);return h.useEffect(()=>{if(!t||n)return;let o=!0;return Ms(s).then(a=>o&&r(a)).catch(a=>o&&r({error:a instanceof Error?a.message:String(a)})),()=>{o=!1}},[t,n,s]),n}function Wt({entry:s,depth:t}){const n=D(),{open:r}=Lt(),o=r.has(s.path),a=ds(s.path,o);return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"ft-row ft-dir",style:{paddingLeft:6+t*11,"--depth":t},"aria-expanded":o,"data-tip":s.path,"data-menu-kind":"dir","data-menu-path":s.path,onClick:()=>Rt(s.path),children:[e.jsx("span",{className:"ft-caret",children:e.jsx(Ze,{open:o})}),e.jsx("span",{className:"ft-label",children:s.name})]}),o&&e.jsx(us,{state:a,depth:t+1,loading:n("diskTree.loading")})]})}function Bt({entry:s,depth:t}){const n=Z("file",s.path);return e.jsxs("a",{className:"ft-row ft-code",style:{paddingLeft:6+t*11,"--depth":t},href:n,"data-tip":s.path,"data-menu-kind":"file","data-menu-path":s.path,onClick:r=>ns(r,n),onDoubleClick:r=>{r.preventDefault(),M("file",s.path)},children:[e.jsx("span",{className:"ft-caret"}),e.jsx("span",{className:"ft-label",children:s.name})]})}function us({state:s,depth:t,loading:n}){return s?s.error?e.jsx("div",{className:"ft-note ft-note-error",style:{paddingLeft:6+t*11},children:s.error}):e.jsxs(e.Fragment,{children:[s.entries.map(r=>r.kind==="dir"?e.jsx(Wt,{entry:r,depth:t},r.path):e.jsx(Bt,{entry:r,depth:t},r.path)),s.truncated&&e.jsx("div",{className:"ft-note",style:{paddingLeft:6+t*11},children:"…"})]}):e.jsx("div",{className:"ft-note",style:{paddingLeft:6+t*11},children:n})}function Ft({onCount:s}){const t=D(),n=ds("",!0);return h.useEffect(()=>{n&&!n.error&&(s==null||s(n.entries.length))},[n,s]),e.jsx("div",{className:"ft-files",children:e.jsx(us,{state:n,depth:0,loading:t("diskTree.loading")})})}const _t=s=>{const t=new Map;for(const n of s){const r=n.parent||"";t.has(r)||t.set(r,[]),t.get(r).push(n)}return t};function he({depth:s,onClick:t,open:n,hasKids:r,dot:o,label:a,kind:i,active:d,subject:c=null}){return e.jsxs("button",{type:"button",className:`ft-row ft-${i}${d?" on":""}`,style:{paddingLeft:6+s*11,"--depth":s},onClick:t,"data-tip":a,"data-menu-kind":c==null?void 0:c.kind,"data-menu-id":c==null?void 0:c.id,"data-menu-path":c==null?void 0:c.path,children:[e.jsx("span",{className:"ft-caret",children:r&&e.jsx(Ze,{open:n})}),o?e.jsx("i",{className:"ft-dot",style:{background:o}}):e.jsx("span",{className:"ft-dot ft-none"}),e.jsx("span",{className:"ft-label",children:a})]})}function ps({node:s,depth:t,kids:n,focusId:r,onOpenFile:o}){var p;const{open:a}=Mt(),i=a.has(s.id),d=u=>{(typeof u=="function"?u(i):u)!==i&&Ot(s.id)},[c,l]=h.useState(null);h.useEffect(()=>{if(!i||c)return;let u=!0;return Os(s.id).then(S=>u&&l(S)).catch(()=>u&&l([])),()=>{u=!1}},[i,c,s.id]);const f=n.get(s.id)||[],g=(s.code||[]).map(u=>u.split("#")[0]).filter((u,S,k)=>k.indexOf(u)===S),j=f.length>0||g.length>0;return e.jsxs(e.Fragment,{children:[e.jsx(he,{depth:t,kind:"node",label:s.title||s.id,active:r===s.id,subject:{kind:"node",id:s.id},dot:(p=J[s.status])==null?void 0:p.color,hasKids:j,open:i,onClick:u=>{d(S=>!S),X(u)?W("spec",s.id):M("spec",s.id)}}),i&&e.jsxs(e.Fragment,{children:[g.map(u=>e.jsx(he,{depth:t+1,kind:"code",label:u.split("/").pop(),subject:{kind:"file",path:u},onClick:S=>(X(S)?W:M)("file",u)},`c:${u}`)),(c||[]).map(u=>e.jsx(he,{depth:t+1,kind:"att",label:u.name,subject:{kind:"file",path:`.spec/${s.id}/${u.name}`},onClick:S=>(X(S)?W:M)("file",`.spec/${s.id}/${u.name}`)},`a:${u.name}`)),f.map(u=>e.jsx(ps,{node:u,depth:t+1,kids:n,focusId:r,onOpenFile:o},u.id))]})]})}function Ie({name:s,count:t,tone:n,children:r}){return e.jsxs("section",{className:"ft-section",children:[e.jsxs("div",{className:`ft-section-head si-zone si-zone-${n}`,role:"heading","aria-level":"2",children:[e.jsx("span",{className:"si-zone-count","aria-hidden":"true",children:t}),e.jsx("span",{className:"si-zone-label ft-section-name",children:s})]}),e.jsx("div",{className:"ft-section-body",children:r})]})}function It({specs:s,focusId:t,onOpenFile:n,embedded:r=!1}){const o=D(),[a,i,d]=oe(U.key,U.initial,U),[c,l]=h.useState(0),f=h.useMemo(()=>_t(s||[]),[s]),g=f.get("")||[],j=h.useMemo(()=>{const m=new Map;for(const y of s||[])m.set(y.id,y.parent||null);return m},[s]);h.useEffect(()=>{if(!t||!j.has(t))return;const m=[];for(let y=j.get(t),v=0;y&&v<64;y=j.get(y),v++)m.push(y);Pt(m)},[t,j]);const p=h.useCallback(m=>n==null?void 0:n(m),[n]),[u,S]=h.useState(null),k=h.useMemo(()=>{const m=new Map;for(const y of s||[])for(const v of y.code||[]){const T=v.split("#")[0];m.has(T)||m.set(T,y.id)}return m},[s]),w=h.useCallback(m=>k.get(m)||null,[k]),E=m=>{var $;const y=($=m==null?void 0:m.closest)==null?void 0:$.call(m,"[data-menu-kind]");if(!y)return null;const{menuKind:v,menuId:T,menuPath:K}=y.dataset;return{kind:v,id:T||null,path:K||null,key:`${v}:${T||K}`,row:y}},C=h.useCallback(()=>{var m,y;u!=null&&u.keyboard&&((y=(m=u.row)==null?void 0:m.focus)==null||y.call(m)),S(null)},[u]),N=m=>{const y=E(m.target);y&&(m.preventDefault(),S({...y,x:m.clientX,y:m.clientY,keyboard:!1}))},O=m=>{const y=L("explorer.menu",m);if(!y&&!L("explorer.openInNewTab",m))return;const v=E(m.target);if(v){if(m.preventDefault(),y){const T=v.row.getBoundingClientRect();S({...v,x:T.left+12,y:T.bottom,keyboard:!0});return}v.kind==="node"?W("spec",v.id):v.kind==="file"&&W("file",v.path)}},A=h.useCallback(m=>l(m),[]),b=()=>{M("spec")};return s!=null&&s.length?e.jsxs("div",{className:"filetree",style:r?{width:"100%"}:{width:a},children:[e.jsxs("div",{className:"ft-body",onContextMenu:N,onKeyDown:O,children:[e.jsx(Ie,{name:o("fileTree.specs"),count:s.length,tone:"specs",children:g.map(m=>e.jsx(ps,{node:m,depth:0,kids:f,focusId:t,onOpenFile:p},m.id))}),e.jsx(Ie,{name:o("fileTree.files"),count:c,tone:"files",children:e.jsx(Ft,{onCount:A})})]}),e.jsx($t,{menu:u,onClose:C,owningNodeOf:w}),e.jsxs("button",{type:"button",className:"ft-graph-entry","data-tip":o("fileTree.graph"),"aria-label":o("fileTree.graph"),onClick:b,children:[e.jsx(R,{name:"graph",size:14}),e.jsx("span",{children:o("fileTree.graph")})]}),!r&&e.jsx("div",{className:"ft-resize",onMouseDown:i,onDoubleClick:d,role:"separator","aria-orientation":"vertical"})]}):null}function qt({sessions:s,activeId:t,suppressRows:n=!1}){const r=D(),{offline:o}=be(),{expanded:a,offlineOpen:i}=Us(),{lockedSource:d}=ae(),{lockGraphTo:c}=H(),{reload:l}=Fs(),{notify:f}=es(),[g,j]=h.useState(null),[p,u]=h.useState(null),[S,k]=h.useState(null),w=h.useRef(null);h.useEffect(()=>()=>{var b;return(b=w.current)==null?void 0:b.call(w)},[]),h.useEffect(()=>{if(!t)return;const b=(s||[]).find(m=>m.id===t);Re(Ae(s||[],t)),b&&se(b)==="offline"&&Ke(!0)},[t,s]);const E=h.useMemo(()=>Js(s||[],b=>a.has(b),{zoneFolded:b=>b==="offline"&&!i,keepVisible:b=>b.id===t}),[s,a,i,t]);ss(b=>{if(n)return!1;const m=Qs(E,t,b);if(!m)return!1;if(b.preventDefault(),m.type==="move")M("sessions",m.id);else if(m.type==="expand"){const y=E.find(v=>v.type==="row"&&v.s.id===m.id);y&&!y.expanded&&le(m.id)}else if(m.type==="collapse"){const y=E.find(v=>v.type==="row"&&v.s.id===m.id);y!=null&&y.expanded&&le(m.id)}return!0},20);const C=h.useCallback(async(b,m)=>{const y=(s||[]).find(v=>v.id===b);if(!(!y||(y.parent||null)===m))try{const v=await Ps("/api/sessions/reparent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({children:[b],parent:m})}),T=await v.json().catch(()=>null);if(!v.ok||(T==null?void 0:T.ok)===!1)throw new Error((T==null?void 0:T.error)||`session parent update refused (HTTP ${v.status})`);m&&Re([m]),l==null||l()}catch(v){f(v instanceof Error?v.message:String(v),{kind:"error"})}},[s,l,f]),N=(b,m)=>{if(de(b.x,b.y,"[data-session-archive-drop]"))return"archive";const y=de(b.x,b.y,"[data-session-drop-id]");if(y){const v=y.dataset.sessionDropId;return v===m.id||v===m.parent||Ae(s||[],v).includes(m.id)?void 0:v}return m.parent&&de(b.x,b.y,"[data-session-root-drop]")?null:void 0},O=(b,m)=>{const y={id:m.id,parent:m.parent||null},v=$=>document.body.classList.toggle("is-session-dragging",$),T=$=>{const B=N($,y);u(G=>G&&G.id===y.id&&G.target===B?G:{...y,target:B})},K=()=>{v(!1),u(null),w.current=null};w.current=et(b,{onStart:$=>{v(!0),T($)},onMove:T,onDrop:$=>{const B=N($,y);K(),B==="archive"?k(m):B!==void 0&&C(y.id,B)},onCancel:K})},A=!!(p!=null&&p.parent);return n?null:e.jsxs("div",{className:"dock-session-body",children:[e.jsx("div",{className:`dock-session-list${A?" root-armed":""}${(p==null?void 0:p.target)===null?" root-on":""}`,...A?{"data-session-root-drop":""}:{},children:E.length?E.map(b=>{if(b.type==="zone"){const y=b.zone==="offline",v=r(`sessionZone.${b.zone}`);return e.jsxs("button",{type:"button",className:`dock-session-zone dock-session-zone-${b.zone}`,"aria-expanded":y?!b.folded:void 0,onClick:y?()=>Ke(b.folded):void 0,children:[e.jsx("span",{children:v}),e.jsxs("span",{className:"dock-session-count",children:[b.count,o&&e.jsx("em",{className:"dock-stale",children:r("backend.stale")})]})]},`zone-${b.zone}`)}const m=!!b.s.source&&b.s.source===d;return e.jsx(Xs,{item:b,activeId:t,dragging:(p==null?void 0:p.id)===b.s.id,dropTarget:(p==null?void 0:p.target)===b.s.id,onToggleFold:()=>le(b.s.id),rowProps:{"data-sid":b.s.id,"data-locked":m?"":void 0,"data-tip":r("dockSessions.rowTip"),"aria-grabbed":(p==null?void 0:p.id)===b.s.id||void 0,onMouseDown:y=>{y.preventDefault(),O(y,b.s)},onClick:y=>{if(y.altKey){y.preventDefault(),c(b.s.source);return}X(y)?W("sessions",b.s.id):M("sessions",b.s.id)},onContextMenu:y=>{y.preventDefault(),j({x:y.clientX,y:y.clientY,session:b.s})}}},b.s.id)}):e.jsx("div",{className:"dock-empty",children:"—"})}),A&&e.jsx("div",{className:"dock-root-hint","aria-hidden":"true",children:r("session.rootDrop")}),e.jsx(Zs,{menu:g,closeRequest:S,onCloseRequestDone:()=>k(null),onClose:()=>j(null),onChanged:l,onError:b=>f(b,{kind:"error"}),onLock:b=>c(b.source,{toggle:!1})})]})}function Ht({mode:s,specs:t,sessions:n}){const r=D(),{offline:o}=be(),{openPalette:a}=H(),i=s==="sessions",d=i?(n==null?void 0:n.length)||0:(t==null?void 0:t.length)||0,c=r(i?"dockModes.searchSessions":"dockModes.searchNodes"),l=Kt();return e.jsxs("div",{className:"dock-head",children:[e.jsx("span",{className:"dock-head-name",children:r(i?"dockModes.sessions":"dockModes.explorer")}),e.jsxs("span",{className:"dock-head-count",children:[d,o&&e.jsx("em",{className:"dock-stale",children:r("backend.stale")})]}),e.jsxs("span",{className:"dock-head-acts",children:[!i&&e.jsx(Ce,{icon:"collapse-all",size:13,className:"dock-head-act",label:r("dockModes.collapseFolders"),disabled:l,onClick:zt}),e.jsx("button",{type:"button",className:"dock-head-act","data-tip":ee(c,"graph.search"),"aria-label":c,onClick:()=>a(i?"sessions":"nodes"),children:e.jsx(R,{name:"search",size:13})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"dock-head-act dock-archive-door","data-session-archive-drop":!0,"data-tip":r("dockSessions.archive"),"aria-label":r("dockSessions.archive"),onClick:()=>M("sessions",null,{query:{archive:"1"}}),children:e.jsx(R,{name:"archive",size:13})}),e.jsx(Ce,{icon:"plus",size:15,className:"dock-head-act dock-head-act-new",label:r("dockSessions.new"),onClick:()=>M("sessions","new")})]})]})]})}function Gt({mode:s,specs:t,sessions:n,focusId:r,activeSessionId:o,suppressSessionRows:a=!1,closing:i=!1,opening:d=!1}){const[c,l,f]=oe(U.key,U.initial,U);return e.jsxs("aside",{className:i?"dock dock-closing":"dock","data-fold":d?"in":void 0,style:{width:c},"aria-hidden":i?"true":void 0,children:[e.jsx(Ht,{mode:s,specs:t,sessions:n}),s==="sessions"?e.jsx(qt,{sessions:n,activeId:o,suppressRows:a}):e.jsx(It,{specs:t,focusId:r,embedded:!0}),e.jsx("div",{className:"ft-resize",onMouseDown:l,onDoubleClick:f,role:"separator","aria-orientation":"vertical"})]})}const hs=8,Yt=5,Vt=2.2,Ut=1,Jt=new Set(["the","a","an","and","or","of","to","in","on","is","it","its","as","at","by","for","how","does","do","what","which","that","this","these","those","with","from","into","are","be","can","just","them","they","their","so","if","not","no","but","vs","us","we","you"]),fs="\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\u3040-\\u30ff",Qt=new RegExp(`[a-z0-9]+|[${fs}]`,"g"),Xt=new RegExp(`[${fs}]`);function ms(s){return Xt.test(s)}function xs(s){return s.toLowerCase().match(Qt)??[]}function Zt(s){const t=new Set;for(const n of xs(s))(ms(n)||n.length>1&&!Jt.has(n))&&t.add(n);return[...t]}function fe(s){return xs(s)}function we(s){let t=s;return t.length>=4&&t.endsWith("s")&&!t.endsWith("ss")&&(t=t.slice(0,-1)),t.length>=5&&t.endsWith("e")&&(t=t.slice(0,-1)),t}function en(s,t){return t.startsWith(we(s))}function re(s,t){return t.startsWith(we(s))||t.length>=3&&s.startsWith(t)}const sn=.5;function tn(s,t){const n=we(s);let r=0;for(const o of t.nameWords)if(o.startsWith(n)){const a=n.length/o.length;a>r&&(r=a)}return r>0?Math.max(sn,r):0}const qe=1.2,He=.4;function Ge(s,t,n){return s<=0?0:s*(qe+1)/(s+qe*(1-He+He*t/(n||1)))}function nn(s,t,n,r){const o=tn(s,t);if(o>0)return hs*o;if(t.name.includes(s))return Yt;if(t.descWords.some(i=>re(s,i)))return Vt*Ge(1,t.descWords.length,r);const a=t.bodyWords.reduce((i,d)=>i+(re(s,d)?1:0),0);return Ut*Ge(a,t.bodyWords.length,n)}function rn(s,t,n,r=140){const o=s.replace(/\s+/g," ").trim(),a=o.toLowerCase();let i=-1;for(const l of n){const f=ms(l)?a.indexOf(l):a.search(new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")));f>=0&&(i<0||f<i)&&(i=f)}if(i<0){const l=(t||o).replace(/\s+/g," ").trim();return l.length>r?l.slice(0,r).trimEnd()+"…":l}const d=Math.max(0,i-Math.floor(r/3));let c=o.slice(d,d+r).trim();return d>0&&(c="…"+c),d+r<o.length&&(c=c+"…"),c}function an(s,t,n={}){const r=n.limit??10,o=Zt(s);if(!o.length)return[];const a=t.map(g=>{const j=g.name.toLowerCase();return{ref:g.ref,name:j,nameWords:fe(j),desc:g.desc.toLowerCase(),descWords:fe(g.desc),bodyWords:fe(g.body),snippetText:`${g.desc}
|
|
1
|
+
var Ds=Object.defineProperty;var Ts=(s,t,n)=>t in s?Ds(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var Ee=(s,t,n)=>Ts(s,typeof t!="symbol"?t+"":t,n);import{u as D,j as e,I as R,r as h,f as $s,g as Ms,C as Ze,h as Os,b as be,a as Ce,i as es,k as Ps,m as Ls,n as Rs,o as V,S as De,e as Te,q as As,t as $e,V as Ks}from"./index-46VMgJJ4.js";import{i as zs,M as Ws}from"./Modal-B5_IjGMa.js";import{u as H,R as Bs,a as ae,n as M,r as Z,b as ke,c as Fs,d as ss,e as Ne,f as _s,g as Is,h as qs,I as ce,P as ts}from"./App-DYT3vIqP.js";import{f as Me,w as ee,i as Oe,s as Hs,C as Gs,a as Q,b as z,c as Pe,o as W,n as ge,g as Ys,d as Le,e as je,h as ie,j as Vs,k as ns,u as oe,D as U,l as L,S as J,m as X,p as Us,q as Re,r as Ae,t as se,v as Ke,x as Js,y as Qs,z as le,A as Xs,B as Zs,E as et,F as de,G as st,H as tt,I as rs,J as nt,K as ze,L as rt,M as as,N as os,O as at,P as cs,Q as ot,R as ct,T as it,U as lt,V as dt,W as ut,X as pt,Y as ht,Z as ft,_ as te,$ as ne,a0 as mt,a1 as xt,a2 as gt,a3 as jt,a4 as yt,a5 as bt,a6 as is,a7 as kt,a8 as Nt}from"./tabs-Bvj-BhvS.js";import{n as wt}from"./GraphStats-CxHsXNy-.js";const We=Bs,vt=s=>Z(s),St={evals:["shell.evals"]};function Et(){const s=D(),{dock:t}=ae(),{setDock:n}=H();if(!n)return null;const r=s(t?"dockModes.collapse":"dockModes.expand");return e.jsx("button",{type:"button",className:"rail-btn rail-panel-toggle","data-tip":r,"aria-label":r,"aria-pressed":t,onClick:()=>n(o=>!o),children:e.jsx(R,{name:t?"panel-left":"panel-right",size:18})})}function Ct({page:s,active:t,label:n,disabled:r=!1,onNavigate:o,badge:a=0}){return r?e.jsxs("span",{className:"rail-btn disabled","data-tip":n,"aria-label":n,"aria-disabled":"true",children:[e.jsx(R,{name:Oe(s)||s,size:18}),a>0&&e.jsx("span",{className:"rail-badge","aria-label":`${a} needs you`,children:a>99?"99+":a})]}):e.jsxs("a",{className:t?"rail-btn on":"rail-btn","data-tip":n,"aria-label":n,"aria-current":t?"page":void 0,href:vt(s),onClick:i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;i.preventDefault(),(o==null?void 0:o())===!0||M(s)},children:[e.jsx(R,{name:Oe(s)||s,size:18}),a>0&&e.jsx("span",{className:"rail-badge","aria-label":`${a} needs you`,children:a>99?"99+":a})]})}function Be({page:s,graphOnly:t=!1,needsYou:n=0,hideDockToggle:r=!1}){const o=D(),{setDock:a,setDockMode:i}=H(),d=t?["graph",...We]:We;return e.jsxs("nav",{className:"side-rail","aria-label":o("nav.railLabel"),onMouseDownCapture:zs,children:[!r&&e.jsx(Et,{}),d.map(c=>e.jsx(Ct,{page:c,active:s===c||c==="spec"&&s==="file",label:ee(o(`nav.${c}`),...St[c]||[]),badge:c==="sessions"?n:0,disabled:t&&c!=="graph",onNavigate:()=>c==="sessions"?(a==null||a(!0),i==null||i("sessions"),Me(l=>l.page==="sessions"&&l.param)):c==="spec"?(a==null||a(!0),i==null||i("explorer"),Me(l=>l.page==="spec")):(c==="graph"&&(a==null||a(!0),i==null||i("explorer")),!1)},c)),e.jsx("div",{className:"rail-spacer"})]})}const Dt=400,Tt=80,ue=7,pe=6;function Fe(){const[s,t]=h.useState(null),n=h.useRef(null),r=h.useRef(0),o=h.useRef(null),a=h.useRef(null),i=h.useRef(!1),d=h.useRef(()=>{});return ke(!!s,()=>d.current()),h.useEffect(()=>{const c=()=>{r.current&&(clearTimeout(r.current),r.current=0)},l=()=>{c(),o.current=null,a.current&&(a.current.getAttribute("aria-describedby")==="ui-tip"&&a.current.removeAttribute("aria-describedby"),a.current=null),t(k=>(k&&(i.current=!0,setTimeout(()=>{o.current||(i.current=!1)},300)),null))};d.current=l;const f=k=>{const w=k.getAttribute("data-tip");!w||!k.isConnected||(o.current=k,k.getAttribute("aria-describedby")||(k.setAttribute("aria-describedby","ui-tip"),a.current=k),t({text:w,anchor:k}))},g=(k,w)=>{o.current!==k&&(c(),o.current=k,r.current=setTimeout(()=>{r.current=0,f(k)},w))},j=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");w&&g(w,i.current?Tt:Dt)},p=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");!w||w!==o.current||w.contains(k.relatedTarget)||l()},u=k=>{var C,N;const w=(N=(C=k.target).closest)==null?void 0:N.call(C,"[data-tip]");if(!w)return;let E=!0;try{E=w.matches(":focus-visible")}catch{}E&&(c(),f(w))},S=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");w&&w===o.current&&l()};return document.addEventListener("pointerover",j,!0),document.addEventListener("pointerout",p,!0),document.addEventListener("focusin",u,!0),document.addEventListener("focusout",S,!0),document.addEventListener("pointerdown",l,!0),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{c(),document.removeEventListener("pointerover",j,!0),document.removeEventListener("pointerout",p,!0),document.removeEventListener("focusin",u,!0),document.removeEventListener("focusout",S,!0),document.removeEventListener("pointerdown",l,!0),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),d.current=()=>{}}},[]),h.useEffect(()=>{const c=n.current;if(!s||!c)return;if(!s.anchor.isConnected){t(null);return}const l=s.anchor.getBoundingClientRect(),f=c.offsetWidth,g=c.offsetHeight,j=l.top-g-ue>=pe?"top":"bottom",p=j==="top"?l.top-g-ue:l.bottom+ue,u=Math.min(Math.max(l.left+l.width/2-f/2,pe),window.innerWidth-f-pe);c.dataset.place=j,c.style.top=`${Math.round(p)}px`,c.style.left=`${Math.round(u)}px`;const S=c.querySelector(".ui-tip-arrow");S&&(S.style.left=`${Math.round(Math.min(Math.max(l.left+l.width/2-u,10),f-10))-4}px`);const k=requestAnimationFrame(()=>c.classList.add("show"));return()=>cancelAnimationFrame(k)},[s]),s?$s.createPortal(e.jsxs("div",{id:"ui-tip",role:"tooltip",ref:n,className:"ui-tip",children:[s.text,e.jsx("span",{className:"ui-tip-arrow","aria-hidden":"true"})]}),document.body):null}function $t({menu:s,onClose:t,owningNodeOf:n}){const r=D(),[o,a]=h.useState(null);if(h.useEffect(()=>{if(s)return window.addEventListener("click",t),window.addEventListener("contextmenu",t,!0),()=>{window.removeEventListener("click",t),window.removeEventListener("contextmenu",t,!0)}},[s,t]),ke(!!s,t),h.useEffect(()=>{a(null)},[s]),h.useEffect(()=>{if(!o)return;const g=setTimeout(t,900);return()=>clearTimeout(g)},[o,t]),!s)return null;const i=g=>j=>{j.stopPropagation(),t(),g()},d=g=>async j=>{j.stopPropagation(),a(await g()?"copied":"failed")},c=g=>r(o?`explorerMenu.${o}`:g),l=Hs("explorer.openInNewTab"),f=s.kind==="file"?n==null?void 0:n(s.path):null;return e.jsxs(Gs,{x:s.x,y:s.y,anchorKey:s.key,keyboard:s.keyboard,label:r(s.kind==="node"?"explorerMenu.nodeLabel":"explorerMenu.fileLabel"),children:[s.kind==="node"&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(z,{icon:"plus",hint:l,onClick:i(()=>W("spec",s.id)),children:r("tabs.openInNewTab")}),e.jsx(z,{icon:"graph",onClick:i(()=>ge(Ys(s.id))),children:r("explorerMenu.revealOnGraph")})]}),e.jsx(Pe,{}),e.jsxs(Q,{children:[e.jsx(z,{icon:"copy",onClick:d(()=>Le(je(s.id))),children:c("explorerMenu.copyLink")}),e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.id)),children:c("explorerMenu.copyNodeId")})]})]}),s.kind==="file"&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(z,{icon:"plus",hint:l,onClick:i(()=>W("file",s.path)),children:r("tabs.openInNewTab")}),f&&e.jsx(z,{icon:"node",onClick:i(()=>ge(je(f))),children:r("explorerMenu.revealOwner")})]}),e.jsx(Pe,{}),e.jsxs(Q,{children:[e.jsx(z,{icon:"copy",onClick:d(()=>Le(Vs(Z("file",s.path)))),children:c("explorerMenu.copyLink")}),e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.path)),children:c("explorerMenu.copyPath")})]})]}),s.kind==="dir"&&e.jsx(Q,{children:e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.path)),children:c("explorerMenu.copyPath")})})]})}const ls=s=>{let n={open:(()=>{try{const i=JSON.parse(localStorage.getItem(s)||"[]");return new Set(Array.isArray(i)?i.filter(d=>typeof d=="string"):[])}catch{return new Set}})()};const r=new Set,o=i=>{n={open:i};try{localStorage.setItem(s,JSON.stringify([...i]))}catch{}r.forEach(d=>d())};return{subscribe:i=>(r.add(i),()=>r.delete(i)),get:()=>n,toggle:i=>{if(!i)return;const d=new Set(n.open);d.has(i)?d.delete(i):d.add(i),o(d)},reveal:i=>{const d=i.filter(Boolean);if(!d.length||d.every(l=>n.open.has(l)))return;const c=new Set(n.open);d.forEach(l=>c.add(l)),o(c)},clear:()=>{n.open.size&&o(new Set)}}},_=ls("spex.specTreeOpen"),q=ls("spex.diskTreeOpen"),Mt=()=>h.useSyncExternalStore(_.subscribe,_.get,_.get),Ot=s=>_.toggle(s),Pt=(s=[])=>_.reveal(s),Lt=()=>h.useSyncExternalStore(q.subscribe,q.get,q.get),Rt=s=>q.toggle(s),At=s=>{const t=[_.subscribe(s),q.subscribe(s)];return()=>t.forEach(n=>n())},_e=()=>_.get().open.size===0&&q.get().open.size===0,Kt=()=>h.useSyncExternalStore(At,_e,_e),zt=()=>{_.clear(),q.clear()};function ds(s,t){const[n,r]=h.useState(null);return h.useEffect(()=>{if(!t||n)return;let o=!0;return Ms(s).then(a=>o&&r(a)).catch(a=>o&&r({error:a instanceof Error?a.message:String(a)})),()=>{o=!1}},[t,n,s]),n}function Wt({entry:s,depth:t}){const n=D(),{open:r}=Lt(),o=r.has(s.path),a=ds(s.path,o);return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"ft-row ft-dir",style:{paddingLeft:6+t*11,"--depth":t},"aria-expanded":o,"data-tip":s.path,"data-menu-kind":"dir","data-menu-path":s.path,onClick:()=>Rt(s.path),children:[e.jsx("span",{className:"ft-caret",children:e.jsx(Ze,{open:o})}),e.jsx("span",{className:"ft-label",children:s.name})]}),o&&e.jsx(us,{state:a,depth:t+1,loading:n("diskTree.loading")})]})}function Bt({entry:s,depth:t}){const n=Z("file",s.path);return e.jsxs("a",{className:"ft-row ft-code",style:{paddingLeft:6+t*11,"--depth":t},href:n,"data-tip":s.path,"data-menu-kind":"file","data-menu-path":s.path,onClick:r=>ns(r,n),onDoubleClick:r=>{r.preventDefault(),M("file",s.path)},children:[e.jsx("span",{className:"ft-caret"}),e.jsx("span",{className:"ft-label",children:s.name})]})}function us({state:s,depth:t,loading:n}){return s?s.error?e.jsx("div",{className:"ft-note ft-note-error",style:{paddingLeft:6+t*11},children:s.error}):e.jsxs(e.Fragment,{children:[s.entries.map(r=>r.kind==="dir"?e.jsx(Wt,{entry:r,depth:t},r.path):e.jsx(Bt,{entry:r,depth:t},r.path)),s.truncated&&e.jsx("div",{className:"ft-note",style:{paddingLeft:6+t*11},children:"…"})]}):e.jsx("div",{className:"ft-note",style:{paddingLeft:6+t*11},children:n})}function Ft({onCount:s}){const t=D(),n=ds("",!0);return h.useEffect(()=>{n&&!n.error&&(s==null||s(n.entries.length))},[n,s]),e.jsx("div",{className:"ft-files",children:e.jsx(us,{state:n,depth:0,loading:t("diskTree.loading")})})}const _t=s=>{const t=new Map;for(const n of s){const r=n.parent||"";t.has(r)||t.set(r,[]),t.get(r).push(n)}return t};function he({depth:s,onClick:t,open:n,hasKids:r,dot:o,label:a,kind:i,active:d,subject:c=null}){return e.jsxs("button",{type:"button",className:`ft-row ft-${i}${d?" on":""}`,style:{paddingLeft:6+s*11,"--depth":s},onClick:t,"data-tip":a,"data-menu-kind":c==null?void 0:c.kind,"data-menu-id":c==null?void 0:c.id,"data-menu-path":c==null?void 0:c.path,children:[e.jsx("span",{className:"ft-caret",children:r&&e.jsx(Ze,{open:n})}),o?e.jsx("i",{className:"ft-dot",style:{background:o}}):e.jsx("span",{className:"ft-dot ft-none"}),e.jsx("span",{className:"ft-label",children:a})]})}function ps({node:s,depth:t,kids:n,focusId:r,onOpenFile:o}){var p;const{open:a}=Mt(),i=a.has(s.id),d=u=>{(typeof u=="function"?u(i):u)!==i&&Ot(s.id)},[c,l]=h.useState(null);h.useEffect(()=>{if(!i||c)return;let u=!0;return Os(s.id).then(S=>u&&l(S)).catch(()=>u&&l([])),()=>{u=!1}},[i,c,s.id]);const f=n.get(s.id)||[],g=(s.code||[]).map(u=>u.split("#")[0]).filter((u,S,k)=>k.indexOf(u)===S),j=f.length>0||g.length>0;return e.jsxs(e.Fragment,{children:[e.jsx(he,{depth:t,kind:"node",label:s.title||s.id,active:r===s.id,subject:{kind:"node",id:s.id},dot:(p=J[s.status])==null?void 0:p.color,hasKids:j,open:i,onClick:u=>{d(S=>!S),X(u)?W("spec",s.id):M("spec",s.id)}}),i&&e.jsxs(e.Fragment,{children:[g.map(u=>e.jsx(he,{depth:t+1,kind:"code",label:u.split("/").pop(),subject:{kind:"file",path:u},onClick:S=>(X(S)?W:M)("file",u)},`c:${u}`)),(c||[]).map(u=>e.jsx(he,{depth:t+1,kind:"att",label:u.name,subject:{kind:"file",path:`.spec/${s.id}/${u.name}`},onClick:S=>(X(S)?W:M)("file",`.spec/${s.id}/${u.name}`)},`a:${u.name}`)),f.map(u=>e.jsx(ps,{node:u,depth:t+1,kids:n,focusId:r,onOpenFile:o},u.id))]})]})}function Ie({name:s,count:t,tone:n,children:r}){return e.jsxs("section",{className:"ft-section",children:[e.jsxs("div",{className:`ft-section-head si-zone si-zone-${n}`,role:"heading","aria-level":"2",children:[e.jsx("span",{className:"si-zone-count","aria-hidden":"true",children:t}),e.jsx("span",{className:"si-zone-label ft-section-name",children:s})]}),e.jsx("div",{className:"ft-section-body",children:r})]})}function It({specs:s,focusId:t,onOpenFile:n,embedded:r=!1}){const o=D(),[a,i,d]=oe(U.key,U.initial,U),[c,l]=h.useState(0),f=h.useMemo(()=>_t(s||[]),[s]),g=f.get("")||[],j=h.useMemo(()=>{const m=new Map;for(const y of s||[])m.set(y.id,y.parent||null);return m},[s]);h.useEffect(()=>{if(!t||!j.has(t))return;const m=[];for(let y=j.get(t),v=0;y&&v<64;y=j.get(y),v++)m.push(y);Pt(m)},[t,j]);const p=h.useCallback(m=>n==null?void 0:n(m),[n]),[u,S]=h.useState(null),k=h.useMemo(()=>{const m=new Map;for(const y of s||[])for(const v of y.code||[]){const T=v.split("#")[0];m.has(T)||m.set(T,y.id)}return m},[s]),w=h.useCallback(m=>k.get(m)||null,[k]),E=m=>{var $;const y=($=m==null?void 0:m.closest)==null?void 0:$.call(m,"[data-menu-kind]");if(!y)return null;const{menuKind:v,menuId:T,menuPath:K}=y.dataset;return{kind:v,id:T||null,path:K||null,key:`${v}:${T||K}`,row:y}},C=h.useCallback(()=>{var m,y;u!=null&&u.keyboard&&((y=(m=u.row)==null?void 0:m.focus)==null||y.call(m)),S(null)},[u]),N=m=>{const y=E(m.target);y&&(m.preventDefault(),S({...y,x:m.clientX,y:m.clientY,keyboard:!1}))},O=m=>{const y=L("explorer.menu",m);if(!y&&!L("explorer.openInNewTab",m))return;const v=E(m.target);if(v){if(m.preventDefault(),y){const T=v.row.getBoundingClientRect();S({...v,x:T.left+12,y:T.bottom,keyboard:!0});return}v.kind==="node"?W("spec",v.id):v.kind==="file"&&W("file",v.path)}},A=h.useCallback(m=>l(m),[]),b=()=>{M("spec")};return s!=null&&s.length?e.jsxs("div",{className:"filetree",style:r?{width:"100%"}:{width:a},children:[e.jsxs("div",{className:"ft-body",onContextMenu:N,onKeyDown:O,children:[e.jsx(Ie,{name:o("fileTree.specs"),count:s.length,tone:"specs",children:g.map(m=>e.jsx(ps,{node:m,depth:0,kids:f,focusId:t,onOpenFile:p},m.id))}),e.jsx(Ie,{name:o("fileTree.files"),count:c,tone:"files",children:e.jsx(Ft,{onCount:A})})]}),e.jsx($t,{menu:u,onClose:C,owningNodeOf:w}),e.jsxs("button",{type:"button",className:"ft-graph-entry","data-tip":o("fileTree.graph"),"aria-label":o("fileTree.graph"),onClick:b,children:[e.jsx(R,{name:"graph",size:14}),e.jsx("span",{children:o("fileTree.graph")})]}),!r&&e.jsx("div",{className:"ft-resize",onMouseDown:i,onDoubleClick:d,role:"separator","aria-orientation":"vertical"})]}):null}function qt({sessions:s,activeId:t,suppressRows:n=!1}){const r=D(),{offline:o}=be(),{expanded:a,offlineOpen:i}=Us(),{lockedSource:d}=ae(),{lockGraphTo:c}=H(),{reload:l}=Fs(),{notify:f}=es(),[g,j]=h.useState(null),[p,u]=h.useState(null),[S,k]=h.useState(null),w=h.useRef(null);h.useEffect(()=>()=>{var b;return(b=w.current)==null?void 0:b.call(w)},[]),h.useEffect(()=>{if(!t)return;const b=(s||[]).find(m=>m.id===t);Re(Ae(s||[],t)),b&&se(b)==="offline"&&Ke(!0)},[t,s]);const E=h.useMemo(()=>Js(s||[],b=>a.has(b),{zoneFolded:b=>b==="offline"&&!i,keepVisible:b=>b.id===t}),[s,a,i,t]);ss(b=>{if(n)return!1;const m=Qs(E,t,b);if(!m)return!1;if(b.preventDefault(),m.type==="move")M("sessions",m.id);else if(m.type==="expand"){const y=E.find(v=>v.type==="row"&&v.s.id===m.id);y&&!y.expanded&&le(m.id)}else if(m.type==="collapse"){const y=E.find(v=>v.type==="row"&&v.s.id===m.id);y!=null&&y.expanded&&le(m.id)}return!0},20);const C=h.useCallback(async(b,m)=>{const y=(s||[]).find(v=>v.id===b);if(!(!y||(y.parent||null)===m))try{const v=await Ps("/api/sessions/reparent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({children:[b],parent:m})}),T=await v.json().catch(()=>null);if(!v.ok||(T==null?void 0:T.ok)===!1)throw new Error((T==null?void 0:T.error)||`session parent update refused (HTTP ${v.status})`);m&&Re([m]),l==null||l()}catch(v){f(v instanceof Error?v.message:String(v),{kind:"error"})}},[s,l,f]),N=(b,m)=>{if(de(b.x,b.y,"[data-session-archive-drop]"))return"archive";const y=de(b.x,b.y,"[data-session-drop-id]");if(y){const v=y.dataset.sessionDropId;return v===m.id||v===m.parent||Ae(s||[],v).includes(m.id)?void 0:v}return m.parent&&de(b.x,b.y,"[data-session-root-drop]")?null:void 0},O=(b,m)=>{const y={id:m.id,parent:m.parent||null},v=$=>document.body.classList.toggle("is-session-dragging",$),T=$=>{const B=N($,y);u(G=>G&&G.id===y.id&&G.target===B?G:{...y,target:B})},K=()=>{v(!1),u(null),w.current=null};w.current=et(b,{onStart:$=>{v(!0),T($)},onMove:T,onDrop:$=>{const B=N($,y);K(),B==="archive"?k(m):B!==void 0&&C(y.id,B)},onCancel:K})},A=!!(p!=null&&p.parent);return n?null:e.jsxs("div",{className:"dock-session-body",children:[e.jsx("div",{className:`dock-session-list${A?" root-armed":""}${(p==null?void 0:p.target)===null?" root-on":""}`,...A?{"data-session-root-drop":""}:{},children:E.length?E.map(b=>{if(b.type==="zone"){const y=b.zone==="offline",v=r(`sessionZone.${b.zone}`);return e.jsxs("button",{type:"button",className:`dock-session-zone dock-session-zone-${b.zone}`,"aria-expanded":y?!b.folded:void 0,onClick:y?()=>Ke(b.folded):void 0,children:[e.jsx("span",{children:v}),e.jsxs("span",{className:"dock-session-count",children:[b.count,o&&e.jsx("em",{className:"dock-stale",children:r("backend.stale")})]})]},`zone-${b.zone}`)}const m=!!b.s.source&&b.s.source===d;return e.jsx(Xs,{item:b,activeId:t,dragging:(p==null?void 0:p.id)===b.s.id,dropTarget:(p==null?void 0:p.target)===b.s.id,onToggleFold:()=>le(b.s.id),rowProps:{"data-sid":b.s.id,"data-locked":m?"":void 0,"data-tip":r("dockSessions.rowTip"),"aria-grabbed":(p==null?void 0:p.id)===b.s.id||void 0,onMouseDown:y=>{y.preventDefault(),O(y,b.s)},onClick:y=>{if(y.altKey){y.preventDefault(),c(b.s.source);return}X(y)?W("sessions",b.s.id):M("sessions",b.s.id)},onContextMenu:y=>{y.preventDefault(),j({x:y.clientX,y:y.clientY,session:b.s})}}},b.s.id)}):e.jsx("div",{className:"dock-empty",children:"—"})}),A&&e.jsx("div",{className:"dock-root-hint","aria-hidden":"true",children:r("session.rootDrop")}),e.jsx(Zs,{menu:g,closeRequest:S,onCloseRequestDone:()=>k(null),onClose:()=>j(null),onChanged:l,onError:b=>f(b,{kind:"error"}),onLock:b=>c(b.source,{toggle:!1})})]})}function Ht({mode:s,specs:t,sessions:n}){const r=D(),{offline:o}=be(),{openPalette:a}=H(),i=s==="sessions",d=i?(n==null?void 0:n.length)||0:(t==null?void 0:t.length)||0,c=r(i?"dockModes.searchSessions":"dockModes.searchNodes"),l=Kt();return e.jsxs("div",{className:"dock-head",children:[e.jsx("span",{className:"dock-head-name",children:r(i?"dockModes.sessions":"dockModes.explorer")}),e.jsxs("span",{className:"dock-head-count",children:[d,o&&e.jsx("em",{className:"dock-stale",children:r("backend.stale")})]}),e.jsxs("span",{className:"dock-head-acts",children:[!i&&e.jsx(Ce,{icon:"collapse-all",size:13,className:"dock-head-act",label:r("dockModes.collapseFolders"),disabled:l,onClick:zt}),e.jsx("button",{type:"button",className:"dock-head-act","data-tip":ee(c,"graph.search"),"aria-label":c,onClick:()=>a(i?"sessions":"nodes"),children:e.jsx(R,{name:"search",size:13})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"dock-head-act dock-archive-door","data-session-archive-drop":!0,"data-tip":r("dockSessions.archive"),"aria-label":r("dockSessions.archive"),onClick:()=>M("sessions",null,{query:{archive:"1"}}),children:e.jsx(R,{name:"archive",size:13})}),e.jsx(Ce,{icon:"plus",size:15,className:"dock-head-act dock-head-act-new",label:r("dockSessions.new"),onClick:()=>M("sessions","new")})]})]})]})}function Gt({mode:s,specs:t,sessions:n,focusId:r,activeSessionId:o,suppressSessionRows:a=!1,closing:i=!1,opening:d=!1}){const[c,l,f]=oe(U.key,U.initial,U);return e.jsxs("aside",{className:i?"dock dock-closing":"dock","data-fold":d?"in":void 0,style:{width:c},"aria-hidden":i?"true":void 0,children:[e.jsx(Ht,{mode:s,specs:t,sessions:n}),s==="sessions"?e.jsx(qt,{sessions:n,activeId:o,suppressRows:a}):e.jsx(It,{specs:t,focusId:r,embedded:!0}),e.jsx("div",{className:"ft-resize",onMouseDown:l,onDoubleClick:f,role:"separator","aria-orientation":"vertical"})]})}const hs=8,Yt=5,Vt=2.2,Ut=1,Jt=new Set(["the","a","an","and","or","of","to","in","on","is","it","its","as","at","by","for","how","does","do","what","which","that","this","these","those","with","from","into","are","be","can","just","them","they","their","so","if","not","no","but","vs","us","we","you"]),fs="\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\u3040-\\u30ff",Qt=new RegExp(`[a-z0-9]+|[${fs}]`,"g"),Xt=new RegExp(`[${fs}]`);function ms(s){return Xt.test(s)}function xs(s){return s.toLowerCase().match(Qt)??[]}function Zt(s){const t=new Set;for(const n of xs(s))(ms(n)||n.length>1&&!Jt.has(n))&&t.add(n);return[...t]}function fe(s){return xs(s)}function we(s){let t=s;return t.length>=4&&t.endsWith("s")&&!t.endsWith("ss")&&(t=t.slice(0,-1)),t.length>=5&&t.endsWith("e")&&(t=t.slice(0,-1)),t}function en(s,t){return t.startsWith(we(s))}function re(s,t){return t.startsWith(we(s))||t.length>=3&&s.startsWith(t)}const sn=.5;function tn(s,t){const n=we(s);let r=0;for(const o of t.nameWords)if(o.startsWith(n)){const a=n.length/o.length;a>r&&(r=a)}return r>0?Math.max(sn,r):0}const qe=1.2,He=.4;function Ge(s,t,n){return s<=0?0:s*(qe+1)/(s+qe*(1-He+He*t/(n||1)))}function nn(s,t,n,r){const o=tn(s,t);if(o>0)return hs*o;if(t.name.includes(s))return Yt;if(t.descWords.some(i=>re(s,i)))return Vt*Ge(1,t.descWords.length,r);const a=t.bodyWords.reduce((i,d)=>i+(re(s,d)?1:0),0);return Ut*Ge(a,t.bodyWords.length,n)}function rn(s,t,n,r=140){const o=s.replace(/\s+/g," ").trim(),a=o.toLowerCase();let i=-1;for(const l of n){const f=ms(l)?a.indexOf(l):a.search(new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")));f>=0&&(i<0||f<i)&&(i=f)}if(i<0){const l=(t||o).replace(/\s+/g," ").trim();return l.length>r?l.slice(0,r).trimEnd()+"…":l}const d=Math.max(0,i-Math.floor(r/3));let c=o.slice(d,d+r).trim();return d>0&&(c="…"+c),d+r<o.length&&(c=c+"…"),c}function an(s,t,n={}){const r=n.limit??10,o=Zt(s);if(!o.length)return[];const a=t.map(g=>{const j=g.name.toLowerCase();return{ref:g.ref,name:j,nameWords:fe(j),desc:g.desc.toLowerCase(),descWords:fe(g.desc),bodyWords:fe(g.body),snippetText:`${g.desc}
|
|
2
2
|
${g.body}`}}),i=a.length,d=a.reduce((g,j)=>g+j.bodyWords.length,0)/(i||1),c=a.reduce((g,j)=>g+j.descWords.length,0)/(i||1),l={};for(const g of o){let j=0;for(const p of a)(p.nameWords.some(u=>en(g,u))||p.descWords.some(u=>re(g,u))||p.bodyWords.some(u=>re(g,u)))&&j++;l[g]=j>0?Math.log(i/j):0}const f=[];for(const g of a){let j=0;for(const p of o)j+=Math.min(nn(p,g,d,c)*l[p],hs);j<=0||f.push({ref:g.ref,score:Math.round(j*100)/100,snippet:rn(g.snippetText,g.desc,o)})}return f.sort((g,j)=>j.score-g.score),f.slice(0,r)}let me=null;function on(s=!0){const[t,n]=h.useState(me),r=h.useRef(!1);return h.useEffect(()=>{!s||r.current||(r.current=!0,fetch(Ls("/api/specs/lite")).then(o=>o.ok?o.json():[]).then(o=>{me={bodies:Object.fromEntries((o||[]).map(a=>[a.id,a.body||""]))},n(me)}).catch(()=>{}))},[s]),t}const Ye=["spec","session"],cn=s=>s?[s,...Ye.filter(t=>t!==s)]:Ye;function ln(s,t,n){const r=n==null?void 0:n.bodies,o=[];for(const a of s){const i=st(a.path);o.push({kind:"spec",key:`spec:${a.id}`,target:a.id,address:je(a.id),color:(J[a.status]||J.pending).color,title:a.title||a.id,sub:i,name:`${a.title||a.id} ${a.id}`,desc:a.desc||"",body:(r==null?void 0:r[a.id])??a.body??""})}for(const a of tt(t)){const i=rs(a),d=nt(a),c=a.status||a.promptPreview||a.note||"";o.push({kind:"session",key:`session:${a.id}`,target:a.id,address:rt(a.id),color:ze[a.status]||ze.offline,title:i,sub:c,name:i||"",desc:a.status||"",body:`${a.promptPreview||a.note||""} ${d}`.trim()})}return o}function dn(s,t,n){const r=Object.fromEntries(n.map((d,c)=>[d,c])),o=(d,c)=>r[d.kind]-r[c.kind];if(!t.trim())return s.slice().sort(o).slice(0,15);const a={};for(const d of n){const c=s.filter(l=>l.kind===d);a[d]=an(t,c.sort((l,f)=>l.name.length-f.name.length||l.key.localeCompare(f.key)).map(l=>({ref:l,name:l.name,desc:l.desc,body:l.body})),{limit:15}).map(l=>l.ref)}const i=[];for(let d=0;i.length<15;d++){let c=!1;for(const l of n)a[l][d]&&i.length<15&&(i.push(a[l][d]),c=!0);if(!c)break}return i}function un({specs:s,sessions:t,onPick:n,onClose:r,boost:o=null}){const a=D(),i=on(),[d,c]=h.useState(""),[l,f]=h.useState("");h.useEffect(()=>{if(!d.trim()){f(d);return}const N=setTimeout(()=>f(d),120);return()=>clearTimeout(N)},[d]);const[g,j]=h.useState(0),p=h.useRef(null),u=h.useRef(null),S=h.useMemo(()=>cn(o),[o]),k=h.useMemo(()=>ln(s,t,i),[s,t,i]),w=h.useMemo(()=>dn(k,l,S),[k,l,S]);h.useEffect(()=>{var N;(N=p.current)==null||N.focus()},[]),h.useEffect(()=>{j(0)},[d]),h.useEffect(()=>{var N,O;(O=(N=u.current)==null?void 0:N.querySelector(".search-item.on"))==null||O.scrollIntoView({block:"nearest"})},[g,w]);const E=(N,O=!1)=>{N&&(n(N,{newTab:O}),r())},C=N=>{N.key==="ArrowDown"?(N.preventDefault(),j(O=>Math.min(w.length-1,O+1))):N.key==="ArrowUp"?(N.preventDefault(),j(O=>Math.max(0,O-1))):N.key==="Enter"?(N.preventDefault(),E(w[g],N.ctrlKey||N.metaKey)):N.key==="Escape"&&(N.preventDefault(),r())};return e.jsx("div",{className:"search-backdrop","data-focus-overlay":!0,onClick:r,children:e.jsxs("div",{className:"search-panel",role:"dialog","aria-modal":"true","aria-label":a("search.title"),onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"search-bar",children:[e.jsx("span",{className:"search-icon",children:"⌕"}),e.jsx("input",{ref:p,className:"search-input",value:d,placeholder:a("search.placeholder"),onChange:N=>c(N.target.value),onKeyDown:C})]}),e.jsxs("ul",{className:"search-results",ref:u,children:[w.length===0&&e.jsx("li",{className:"search-empty",children:a("search.empty")}),w.map((N,O)=>e.jsxs("li",{className:`search-item${O===g?" on":""}`,"data-kind":N.kind,"data-target":N.target,onMouseEnter:()=>j(O),onClick:A=>E(N,X(A)),children:[e.jsx("span",{className:"node-dot",style:{background:N.color}}),e.jsx("span",{className:`search-kind k-${N.kind}`,children:a(`search.kind.${N.kind}`)}),e.jsx("span",{className:"search-title",children:N.title||N.target}),e.jsx("span",{className:"search-path",children:N.sub})]},N.key))]}),e.jsx("div",{className:"search-foot",children:a("search.hint")})]})})}class pn extends h.Component{constructor(){super(...arguments);Ee(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error(`view crashed (${this.props.resetKey}):`,n,r==null?void 0:r.componentStack)}componentDidUpdate(n){this.state.error&&n.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:n}=this.state;return n?e.jsx("div",{className:"view-error",children:e.jsxs("div",{className:"view-error-box",children:[e.jsx("p",{className:"view-error-title",children:this.props.t("viewError.title")}),e.jsx("p",{className:"view-error-detail",children:String((n==null?void 0:n.message)||n)}),e.jsx("button",{type:"button",className:"view-error-retry",onClick:()=>this.setState({error:null}),children:this.props.t("viewError.retry")})]})}):this.props.children}}function ve({resetKey:s,children:t}){const n=D();return e.jsx(pn,{resetKey:s,t:n,children:t})}const gs="spexcode.ctxPanels";function hn(){try{const s=JSON.parse(localStorage.getItem(gs)||"null");return{scenarios:(s==null?void 0:s.scenarios)!==!1,issues:(s==null?void 0:s.issues)!==!1}}catch{return{scenarios:!0,issues:!0}}}function js({href:s,children:t}){return e.jsx("a",{className:"ctx-row",href:s,onClick:n=>ns(n,s),children:t})}function fn({id:s}){var d;const t=D(),n=os("evals",_s(s),1,{pollMs:0,view:"timeline"});if(n.loading)return e.jsx("div",{className:"ctx-empty",children:t("contextDock.loading")});if(n.error)return e.jsx("div",{className:"ctx-empty ctx-error",children:n.error});const r=((d=n.data)==null?void 0:d.items)||[],o=[...new Map(r.filter(c=>c==null?void 0:c.scenario).map(c=>[c.scenario,{name:c.scenario}])).values()],a=r.filter(c=>c.filterKind==="result"),i=at(o,a);return i.length?e.jsx("div",{className:"ctx-list",children:i.map(c=>e.jsxs(js,{href:cs(ot(s,c.name)),children:[e.jsx("span",{className:`ctx-score ${c.state}`,"aria-label":t(`contextDock.states.${c.state}`),children:c.state==="pass"||c.state==="stalePass"?"✓":c.state==="fail"||c.state==="staleFail"?"×":"○"}),e.jsx("span",{className:"ctx-row-label",children:c.name}),e.jsx("span",{className:"ctx-state",children:t(`contextDock.states.${c.state}`)})]},c.name))}):e.jsx("div",{className:"ctx-empty",children:t("contextDock.noScenarios")})}function mn({id:s}){var o;const t=D(),n=os("issues",Is(s),1,{pollMs:0});if(n.loading)return e.jsx("div",{className:"ctx-empty",children:t("contextDock.loadingIssues")});if(n.error)return e.jsx("div",{className:"ctx-empty ctx-error",children:n.error});const r=((o=n.data)==null?void 0:o.items)||[];return r.length?e.jsx("div",{className:"ctx-list",children:r.map(a=>e.jsxs(js,{href:cs(it(a.id)),children:[e.jsx(ct,{kind:"issue",state:a.status||"open",size:12,className:"ctx-issue-state"}),e.jsx("span",{className:"ctx-row-label",children:a.concern})]},a.id))}):e.jsx("div",{className:"ctx-empty",children:t("contextDock.noIssues")})}function Ve({title:s,open:t,onToggle:n,children:r}){return e.jsxs("section",{className:"ctx-panel",children:[e.jsxs("button",{type:"button",className:"ctx-panel-head","aria-expanded":t,onClick:n,children:[e.jsx("span",{children:s}),e.jsx(R,{name:t?"chevron-down":"chevron-right",size:12})]}),t&&r]})}function xn({page:s,param:t,open:n=!0,onToggle:r}){const o=D(),{specs:a}=Ne(),[i,d,c]=oe("spex.ctxWidth",276,{min:220,max:460,dir:-1}),[l,f]=h.useState(hn),[g,j]=as(n);if(s!=="spec"||!t||!g)return null;const p=a==null?void 0:a.find(S=>S.id===t);if(!p)return null;const u=S=>f(k=>{const w={...k,[S]:!k[S]};try{localStorage.setItem(gs,JSON.stringify(w))}catch{}return w});return e.jsxs("aside",{className:j?"context-dock dock-closing":"context-dock",style:{width:i},"aria-hidden":j?"true":void 0,"aria-label":o("contextDock.title"),children:[e.jsx("div",{className:"ctx-resize",onMouseDown:d,onDoubleClick:c,role:"separator","aria-orientation":"vertical"}),e.jsxs("div",{className:"ctx-head",children:[e.jsx("span",{children:o("contextDock.title")}),e.jsx("span",{className:"ctx-node-id",children:p.id})]}),e.jsxs("div",{className:"ctx-body",children:[e.jsx(Ve,{title:o("contextDock.scenarios"),open:l.scenarios,onToggle:()=>u("scenarios"),children:e.jsx(fn,{id:t})}),e.jsx(Ve,{title:o("contextDock.issues"),open:l.issues,onToggle:()=>u("issues"),children:e.jsx(mn,{id:t})})]})]})}const gn=new Set(["=","_","I","H","J","K","L"]),jn=(()=>{const s=[];for(const t of dt){const n=ut(t,pt(t.id)).filter(o=>!gn.has(o)).map(ht),r=s[s.length-1];r&&r.desc===t.desc?r.keys.push(...n):s.push({desc:t.desc,keys:n})}return s})(),yn=[[["←","→","h","l","⇥","1","2"],"legend.popup.switch"],[["j","k","↑","↓"],"legend.popup.scroll"],[["⇧h","⇧j","⇧k","⇧l","⇧←↑↓→"],"legend.popup.lens"],[["⏎"],"legend.popup.enter"],[["esc"],"legend.popup.esc"]],bn=["merged","active","drift","pending"],kn=["added","edited","deleted","moved"];function Nn({t:s}){return e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("legend.secBoard")}),jn.map(t=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"keymap-keys",children:t.keys.map((n,r)=>e.jsx("kbd",{children:n},r))}),e.jsx("span",{className:"legend-desc",children:s(t.desc)})]},t.desc))]})}function wn({title:s,rows:t,t:n}){return e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s}),t.map(([r,o])=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"keymap-keys",children:r.map((a,i)=>e.jsx("kbd",{children:a},i))}),e.jsx("span",{className:"legend-desc",children:n(o)})]},o))]})}function vn({onClose:s}){const t=D();return e.jsxs(Ws,{title:t("legend.title"),closeLabel:ee(t("legend.close"),"graph.help"),onClose:s,children:[e.jsx(Nn,{t}),e.jsx(wn,{title:t("legend.secPopup"),rows:yn,t}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:t("legend.secStatus")}),bn.map(n=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"node-dot",style:{background:J[n].color},children:n==="active"&&e.jsx("span",{className:"pulse",style:{background:J[n].color}})}),e.jsx("span",{className:"legend-name",children:t(`status.${n}`)}),e.jsx("span",{className:"legend-desc",children:t(`legend.statusRows.${n}`)})]},n))]}),e.jsxs("section",{className:"legend-sec",children:[e.jsxs("div",{className:"legend-h",children:[t("legend.secOp")," ",e.jsx("span",{className:"legend-sub",children:t("legend.secOpSub")})]}),kn.map(n=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:`ov-mark ov-${n}`,children:lt[n]}),e.jsx("span",{className:"legend-desc",children:t(`legend.opRows.${n}`)})]},n))]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:t("legend.secBadges")}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"drift-badge",children:"⚠N"}),e.jsx("span",{className:"legend-desc",children:t("legend.badgeDrift")})]}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-glyph legend-ver",children:"vN"}),e.jsx("span",{className:"legend-desc",children:t("legend.badgeVer")})]})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:t("legend.secRing")}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-ring ring-dashed"}),e.jsx("span",{className:"legend-desc",children:t("legend.ringDashed")})]}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-ring ring-solid"}),e.jsx("span",{className:"legend-desc",children:t("legend.ringSolid")})]}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-ring ring-ghost"}),e.jsx("span",{className:"legend-desc",children:t("legend.ringGhost")})]})]})]})}const Sn=/^[a-z][a-z0-9-]*$/,En=/^[A-Za-z0-9_-]+$/,ys=Object.freeze(["open","hold","own-query"]),Cn=Object.freeze({intents:ys,samePage:(s,t)=>I(s,"from").page===I(t,"to").page,assertAddress:s=>I(s)}),bs=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return!1;const t=Object.getPrototypeOf(s);return t===Object.prototype||t===null};function ks(s,t="query"){if(s==null)return null;if(!bs(s))throw new TypeError(`${t} must be a plain object or null`);const n={};for(const[r,o]of Object.entries(s)){if(!En.test(r))throw new TypeError(`${t} key must be URL-safe: ${r}`);if(o!=null&&!["string","number","boolean"].includes(typeof o))throw new TypeError(`${t}.${r} must be a primitive value`);n[r]=o}return Object.freeze(n)}function I(s,t="address"){if(!bs(s))throw new TypeError(`${t} must be an address object`);const{page:n,param:r=null,query:o=null}=s;if(typeof n!="string"||!Sn.test(n))throw new TypeError(`${t}.page must be lowercase kebab-case`);if(r!=null&&typeof r!="string")throw new TypeError(`${t}.param must be a string or null`);return Object.freeze({page:n,param:r,query:ks(o,`${t}.query`)})}function Ue(s,t){return t===void 0?{accepted:!0,intent:s}:t}function Dn({route:s,dispatch:t,active:n=!0,contract:r=Cn,owner:o=null}={}){if(typeof t!="function")throw new TypeError("view scope requires a dispatch function");if(!r||typeof r.assertAddress!="function")throw new TypeError("view scope requires a route contract");if(o!=null&&(typeof o!="object"||o.kind!=="view"||typeof o.page!="string"))throw new TypeError("view scope owner must identify a view");let a=I(s,"route"),i=n!==!1;const d=(f,g,j=null)=>{if(!i)return{accepted:!1,reason:"inactive",type:f};const p=r.assertAddress(g,`${f}.address`),u=Object.freeze({type:f,address:I(p,`${f}.address`),...f==="open"&&(j==null?void 0:j.replace)===!0?{replace:!0}:{}});return Ue(u,t(u))},c={};Object.defineProperties(c,{route:{enumerable:!0,get:()=>a},active:{enumerable:!0,get:()=>i},owner:{enumerable:!0,value:o?Object.freeze({...o}):null}}),c.open=(f,g=null)=>d("open",f,g),c.hold=f=>d("hold",f),c.ownQuery=f=>{if(!i)return{accepted:!1,reason:"inactive",type:"own-query"};const g={page:a.page,param:a.param,query:ks(f,"own-query.query")},j=Object.freeze({type:"own-query",address:I(r.assertAddress(g,"own-query.address"),"own-query.address")});return Ue(j,t(j))};const l=({route:f=a,active:g=i}={})=>{a=I(f,"route"),i=g!==!1};return{scope:Object.freeze(c),update:l,intents:ys}}const Tn=(s,t)=>s==="issues"||s==="evals"||s==="settings"||s==="sessions"?"none":s==="spec"||s==="file"?"explorer":"keep",$n=new Set(["graph","sessions"]),Ns=(s,t)=>$n.has(s)?s:`${s}/${t??""}`,Mn=6;function ws({page:s,param:t,query:n,active:r,children:o}){const{splitTo:a}=H(),i=h.useCallback(c=>{const{page:l,param:f,query:g}=c.address;return c.type==="hold"?(a(c.address),{accepted:!0,intent:c}):(M(l,f,{query:g,replace:c.replace===!0}),{accepted:!0,intent:c})},[a]),d=h.useMemo(()=>Dn({route:{page:s,param:t,query:n},dispatch:i,active:r,contract:Nt,owner:{kind:"view",page:s,param:t??null}}),[]);return h.useEffect(()=>{d.update({route:{page:s,param:t,query:n},active:r})},[d,s,t,n,r]),e.jsx(Ks,{scope:d.scope,children:o})}function On({page:s,param:t,query:n,inactive:r=!1}){const o=Ns(s,t),a=Z(s,t,n),i=h.useRef(0),[d,c]=h.useState(()=>[{key:o,address:a,page:s,param:t,query:n,seq:0}]);return h.useEffect(()=>{c(l=>{const f=++i.current;let j=l.find(p=>p.key===o)?l.map(p=>p.key===o?{...p,address:a,page:s,param:t,query:n,seq:f}:p):[...l,{key:o,address:a,page:s,param:t,query:n,seq:f}];if(j.length>Mn){const p=j.reduce((u,S)=>S.seq<u.seq?S:u);j=j.filter(u=>u!==p)}return j})},[o,a]),d.map(l=>e.jsx(Pn,{entry:l,showing:!r&&l.key===o},l.key))}const Pn=h.memo(function({entry:t,showing:n}){const r=D(),{component:o,className:a}=is(t.page),i=h.useMemo(()=>({address:t.address,active:n}),[t.address,n]);return e.jsx("div",{className:`viewhost ${a}`,"aria-hidden":n?void 0:"true",style:n?void 0:{display:"none"},children:e.jsx(ve,{resetKey:t.address,children:e.jsx(ts,{value:i,children:e.jsx(ws,{page:t.page,param:t.param,query:t.query,active:n,children:e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"loading",children:r("hud.loading")}),children:e.jsx(o,{param:t.param,query:t.query})})})})})})});function ye({page:s,param:t,query:n,inactive:r=!1}){const o=D(),{component:a,className:i}=is(s),d=Z(s,t,n);return e.jsx("div",{className:`viewhost ${i}`,"aria-hidden":r?"true":void 0,style:r?{display:"none"}:void 0,children:e.jsx(ve,{resetKey:d,children:e.jsx(ts,{value:{address:d,active:!r},children:e.jsx(ws,{page:s,param:t,query:n,active:!r,children:e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"loading",children:o("hud.loading")}),children:e.jsx(a,{param:t,query:n},Ns(s,t))})})})})})}function Je(){var p;const s=D(),{identity:t,catalog:n}=Ne(),[r,o]=h.useState(!1);ke(r,()=>o(!1));const a=(n==null?void 0:n.state)==="ok",i=(n==null?void 0:n.state)==="denied",d=a?n.projects:null,c=(t==null?void 0:t.title)||Te||"spexcode",l=i?s("nav.projectChipLogin",{name:c}):s("nav.projectChip",{name:c});h.useEffect(()=>{if(!r)return;const u=S=>{var k,w;(w=(k=S.target).closest)!=null&&w.call(k,"[data-status-project], .status-project-menu")||o(!1)};return document.addEventListener("mousedown",u,!0),()=>{document.removeEventListener("mousedown",u,!0)}},[r]);const f=e.jsxs(e.Fragment,{children:[e.jsx(ce,{icon:t==null?void 0:t.icon,size:14,className:"sb-project-mark"}),e.jsx("span",{className:"sb-project-name",children:c})]}),g=d?e.jsx("button",{type:"button",className:r?"sb-project-trigger open":"sb-project-trigger","data-status-project":"","data-tip":l,"aria-label":l,"aria-haspopup":"menu","aria-expanded":r,"aria-controls":r?"status-project-menu":void 0,onClick:()=>o(u=>!u),children:f}):e.jsx("a",{className:"sb-project-trigger","data-status-project":"","data-tip":l,"aria-label":l,href:$e(),children:f}),j=r&&d?e.jsxs("div",{id:"status-project-menu",className:"proj-menu status-project-menu",role:"menu",onContextMenu:u=>u.stopPropagation(),children:[d.map(u=>{const S=u.online===!1,k=u.id===Te,w=S?s("nav.projectOffline"):u.online===!0?s("nav.projectOnline"):null,E=`proj-menu-item${k?" current":""}${S?" offline":""}`,C=e.jsxs(e.Fragment,{children:[e.jsx(ce,{icon:u.identity.icon,size:16,className:"proj-menu-mark"}),u.gated&&e.jsx(R,{name:"lock",size:11}),e.jsx("span",{className:"proj-menu-name",children:u.identity.title}),w&&e.jsx("span",{className:`proj-menu-status ${S?"offline":"online"}`,"aria-hidden":"true",children:w}),k&&e.jsx(R,{name:"check",size:12})]});return S?e.jsx("div",{role:"menuitem","aria-disabled":"true",className:E,children:C},u.id):e.jsx("a",{role:"menuitem",className:E,href:As(u.id),children:C},u.id)}),e.jsxs("a",{role:"menuitem",className:"proj-menu-item all",href:$e(),children:[e.jsx(ce,{icon:(p=n.gateway.identity)==null?void 0:p.icon,fallback:"gateway",size:16,className:"proj-menu-mark"}),e.jsx("span",{className:"proj-menu-name",children:s("nav.allProjects")})]})]}):null;return V({id:"project",side:"left",priority:1e3,kind:"prominent",overflow:r,node:e.jsxs("span",{className:"sb-project-slot",children:[g,j]})}),null}const Ln=[{state:"pass",always:!0,titleKey:"scorePass"},{state:"fail",always:!0,titleKey:"scoreFail"},{state:"stalePass",titleKey:"scoreStalePass"},{state:"staleFail",titleKey:"scoreStaleFail"},{state:"empty",titleKey:"scoreEmpty"}];function xe({name:s,count:t,title:n,onClick:r,children:o}){return e.jsxs("button",{type:"button",className:"sb-tally-button","data-board-stat":s,"data-tip":n,"aria-label":n,disabled:!r,onClick:r,children:[o,t]})}const Rn=()=>{try{return sessionStorage.getItem("spex.focus")}catch{return null}};function An({launcher:s,sessions:t,onOpen:n,tooltip:r}){const a=kt(s.harness).Glyph,i=t.reduce((d,c)=>{const l=se(c);return l==="run"?d.running+=1:l==="need"?d.needsYou+=1:d.other+=1,d},{running:0,needsYou:0,other:0});return e.jsxs("button",{type:"button",className:"sb-launcher-group","data-launcher":s.name,"data-tip":r,"aria-label":r,onClick:n,children:[e.jsx("span",{className:"sb-launcher-glyph","aria-hidden":"true",children:e.jsx(a,{})}),e.jsx("span",{className:"sb-launcher-name",children:s.name}),e.jsxs("span",{className:"sb-launcher-counts","aria-hidden":"true",children:[e.jsx("span",{className:"sb-launcher-running",children:i.running}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-needs",children:i.needsYou}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-other",children:i.other})]})]})}function Kn({launchers:s,sessions:t,onOpen:n,tooltip:r}){if(!t.length)return null;const o=t.reduce((a,i)=>{const d=se(i);return d==="run"?a.running+=1:d==="need"?a.needsYou+=1:a.other+=1,a},{running:0,needsYou:0,other:0});return e.jsxs("button",{type:"button",className:"sb-launcher-summary","data-launcher-summary":s.map(a=>a.name).join(","),"data-tip":r,"aria-label":r,onClick:n,children:[e.jsx("span",{className:"sb-launcher-summary-mark","aria-hidden":"true",children:s.length}),e.jsxs("span",{className:"sb-launcher-counts","aria-hidden":"true",children:[e.jsx("span",{className:"sb-launcher-running",children:o.running}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-needs",children:o.needsYou}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-other",children:o.other})]})]})}function zn(s,t){const n=(s||[]).filter(a=>(t||[]).some(i=>i.launcher===a.name)).map(a=>({...a,sessions:t.filter(i=>i.launcher===a.name)})),r=new Set((s||[]).map(a=>a.name)),o=(t||[]).filter(a=>!r.has(a.launcher));return o.length?[...n,{name:"other",harness:"claude",sessions:o}]:n}function Qe({specs:s,sessions:t,page:n}){const r=D(),{offline:o}=be(),{launchers:a}=gt(),i=h.useMemo(()=>zn(a,t||[]),[a,t]),d=h.useMemo(()=>(t||[]).filter(p=>se(p)==="need").length,[t]),c=o?e.jsx("span",{className:"sb-stale","aria-label":r("backend.stale"),"data-tip":r("backend.stale")}):null,l=h.useMemo(()=>jt(s||[]),[s]),{fail:f}=l.scoreCount,g=p=>{const u=wt(p,Rn());u&&M("graph",u,{replace:n==="graph"})},j=(p,u)=>p.length?n==="graph"?()=>g(p):()=>M(u):null;return V({id:"ledger-nodes",side:"right",priority:41,tooltip:r("statusBar.nodes",{n:l.total}),node:e.jsxs("span",{className:"sb-tally",children:[yt.map(p=>e.jsx(xe,{name:`status-${p}`,count:l.status[p].length,onClick:l.status[p].length?()=>g(l.status[p]):null,title:r("stats.statusTitle",{n:l.status[p].length,status:r(`status.${p}`)}),children:e.jsx("i",{className:"sb-status-dot",style:{background:J[p].color}})},p)),c]})}),V({id:"ledger-evals",side:"right",priority:42,kind:f>0?"error":void 0,tooltip:r("statusBar.evals",l.scoreCount),node:e.jsxs("span",{className:"sb-tally",children:[Ln.map(({state:p,always:u,titleKey:S})=>{const k=l.scoreCount[p];return!k&&!u?null:e.jsx(xe,{name:`eval-${p}`,count:k,onClick:j(l.scoreNodes[p],"evals"),title:n==="graph"?r(`stats.${S}`,{n:k}):`${r(`score.${p}`)} · ${r("statusBar.openEvals")}`,children:e.jsx(bt,{state:p})},p)}),c]})}),V({id:"ledger-issues",side:"right",priority:43,tooltip:r("statusBar.issues",{n:l.issueCount}),node:e.jsxs("span",{className:"sb-tally",children:[e.jsx(xe,{name:"issues",count:l.issueCount,onClick:j(l.issueIds,"issues"),title:n==="graph"?r("stats.issueTitle",{n:l.issueCount}):r("statusBar.issues",{n:l.issueCount}),children:e.jsx(R,{name:"issue-opened",size:13})}),c]})}),V({id:"ledger-sessions",side:"right",priority:44,kind:d>0?"warning":void 0,tooltip:r("statusBar.sessions"),node:e.jsxs("span",{className:"sb-launcher-groups",children:[e.jsx("span",{className:"sb-launcher-list",children:i.map(p=>e.jsx(An,{launcher:p,sessions:p.sessions,tooltip:r("statusBar.launcher",{name:p.name}),onOpen:()=>M("sessions")},p.name))}),e.jsx(Kn,{launchers:i,sessions:t||[],onOpen:()=>M("sessions"),tooltip:r("statusBar.launcherSummary",{n:i.length})}),c]})}),null}function Xe({page:s,param:t,query:n,inactive:r=!1}){const o=D(),{split:a}=ae(),{closeSplit:i}=H(),[d,c,l]=oe("spex.splitWidth",620,{min:320,max:1400,dir:-1});return a?e.jsxs("div",{className:"content-split",children:[e.jsx(ye,{page:s,param:t,query:n,inactive:r}),e.jsx("div",{className:"content-divider",onMouseDown:c,onDoubleClick:l,role:"separator","aria-orientation":"vertical"}),e.jsxs("div",{className:"content-second",style:{width:d},children:[e.jsx("button",{type:"button",className:"content-close",onClick:i,"aria-label":o("tabs.close"),children:e.jsx(R,{name:"x",size:12})}),e.jsx(ye,{page:a.page,param:a.param,query:a.query,inactive:r})]})]}):e.jsx(On,{page:s,param:t,query:n,inactive:r})}function Wn({visible:s,onToggle:t}){const n=D(),r=ee(n(s?"contextDock.close":"contextDock.open"),"shell.contextToggle");return e.jsx("button",{type:"button",className:`context-toggle${s?" on":""}`,onClick:t,"aria-pressed":s,"aria-label":r,"data-tip":r,children:e.jsx(R,{name:"panel-right",size:14})})}function Bn({routeOverride:s=null,inactive:t=!1}){const n=D(),r=qs(),{page:o,param:a,query:i}=s||r,{specs:d,sessions:c,identity:l,graphOnly:f}=Ne(),{notify:g}=es(),j=h.useRef(null),p=h.useMemo(()=>(c||[]).filter(x=>se(x)==="need").length,[c]);h.useEffect(()=>{const x=j.current;if(j.current=new Map((c||[]).map(P=>[P.id,P.status])),!!x)for(const P of c||[])P.status!=="asking"||x.get(P.id)==="asking"||g(`${rs(P)} · ${n("status.asking")}`,{kind:"info",onClick:()=>M("sessions",P.id)})},[c,g,n]);const u=Rs(),{dock:S,dockMode:k,palette:w,helpOpen:E}=ae(),{closePalette:C,openPalette:N,toggleHelp:O,closeHelp:A,setDock:b,setDockMode:m,splitTo:y}=H();V({id:"help",side:"left",priority:-1/0,text:"?",tooltip:ee(n("hud.helpTitle"),"graph.help"),onClick:O});const[v,T]=h.useState(()=>{try{return localStorage.getItem("spexcode.ctxOpen")==="1"}catch{return!1}}),K=()=>T(x=>{const P=!x;try{localStorage.setItem("spexcode.ctxOpen",P?"1":"0")}catch{}return P}),$=Tn(o),B=$!=="none"||o==="sessions",G=`${o}/${a??""}`,[vs,Ss,Es]=as(S);h.useEffect(()=>{($==="sessions"||$==="explorer")&&m($)},[G]);const Se=ft({page:o,param:a,query:i},{specs:d,sessions:c,names:u,t:n});h.useEffect(()=>{document.title=`${p>0?`(${p}) `:""}${Se} · ${(l==null?void 0:l.title)||"spexcode"}`},[Se,l==null?void 0:l.title,p]);const Cs=h.useCallback(x=>{var P,Y;if(t)return!1;if(w)return x.key==="Escape"?(x.preventDefault(),C(),!0):!1;if(E){if(x.key==="Escape"||!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.help",x.key))return x.preventDefault(),A(),!0;if(x.key==="j"||x.key==="k"||x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const F=document.querySelector(".legend-body");return F&&(F.scrollTop+=x.key==="j"||x.key==="ArrowDown"?120:-120),!0}return!0}if((x.key==="Enter"||x.key===" ")&&((Y=(P=x.target)==null?void 0:P.closest)!=null&&Y.call(P,"button, a[href], input, select, textarea, summary")))return!1;if(!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.help",x.key))return x.preventDefault(),C(),O(),!0;if(x.altKey&&!x.metaKey&&!x.ctrlKey){if(!f&&L("shell.newSession",x))return x.preventDefault(),M("sessions","new"),!0;if(!f&&L("shell.evals",x))return x.preventDefault(),C(),M("evals"),!0;if(!f&&L("shell.search",x))return x.preventDefault(),N("sessions"),!0}if(L("shell.dockToggle",x))return x.preventDefault(),b(F=>!F),!0;if(L("shell.dockMode",x))return x.preventDefault(),m(k==="explorer"?"sessions":"explorer"),!0;if(!f&&L("shell.contextToggle",x))return x.preventDefault(),K(),!0;if(!f&&L("shell.tabClose",x))return x.preventDefault(),ne("closeActive"),!0;if(!f&&L("shell.tabNext",x))return x.preventDefault(),ne("move",1),!0;if(!f&&L("shell.tabPrevious",x))return x.preventDefault(),ne("move",-1),!0;if(!f&&L("shell.tabSplit",x)){x.preventDefault();const F=ne("active");return F&&y(F),!0}return!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.settings",x.key)?(x.preventDefault(),o==="settings"?M("sessions"):M("settings"),!0):!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.search",x.key)?(x.preventDefault(),N(($==="sessions"||$==="explorer"?$:k)==="sessions"?"sessions":"nodes"),!0):!1},[A,C,$,k,f,E,t,N,o,w,b,m,y,O,v]);return ss(Cs,t?-1e3:-100),t?e.jsxs("div",{style:{display:"none"},"aria-hidden":"true",children:[e.jsx(Xe,{page:o,param:a,query:i,inactive:!0}),e.jsx(Je,{}),e.jsx(Qe,{specs:d,sessions:c,page:o})]}):f?e.jsxs("div",{className:"app-shell",children:[e.jsxs("div",{className:"app",children:[e.jsx(Fe,{}),e.jsx(Be,{page:"graph",graphOnly:!0}),e.jsx("div",{className:"app-main",children:e.jsx(ye,{page:"graph",param:a,query:i})})]}),e.jsx(De,{})]}):e.jsxs("div",{className:"app-shell",children:[e.jsxs("div",{className:"app",children:[e.jsx(Fe,{}),E&&e.jsx(vn,{onClose:A}),e.jsx(Be,{page:o,needsYou:p,hideDockToggle:!B}),vs&&$!=="none"&&e.jsx(ve,{resetKey:"dock",children:e.jsx(Gt,{closing:Ss,opening:Es,mode:k,specs:d,sessions:c,focusId:o==="spec"?a:null,activeSessionId:o==="sessions"?a:null,suppressSessionRows:o==="sessions"})}),e.jsxs("div",{className:"app-content-column",children:[e.jsxs("div",{className:"app-content-row",children:[e.jsxs("div",{className:"app-main",children:[o!=="sessions"&&e.jsx(mt,{specs:d,sessions:c,route:{page:o,param:a,query:i},trailing:o==="spec"?e.jsx(Wn,{visible:v,onToggle:K}):null}),e.jsx(Xe,{page:o,param:a,query:i,inactive:t})]}),e.jsx(xn,{page:o,param:a,open:v,onToggle:K})]}),e.jsx(Je,{}),e.jsx(Qe,{specs:d,sessions:c,page:o})]})]}),e.jsx(De,{}),w&&e.jsx(un,{specs:d,sessions:c,boost:w==="sessions"?"session":null,onClose:C,onPick:(x,P)=>{if(C(),!(P!=null&&P.newTab))return ge(x==null?void 0:x.address);const Y=xt(x==null?void 0:x.address);W(Y.page,Y.param,Y.query)}}),e.jsx("span",{className:"sr-only",children:n("nav.railLabel")})]})}function Yn({route:s=null,inactive:t=!1}){return e.jsx(Bn,{routeOverride:s,inactive:t})}export{Yn as default};
|