spexcode 0.5.1 → 0.5.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.
Files changed (28) hide show
  1. package/package.json +1 -1
  2. package/spec-cli/src/claude-headless.ts +105 -16
  3. package/spec-cli/src/cli.ts +13 -2
  4. package/spec-cli/src/harness.ts +21 -1
  5. package/spec-cli/src/host.ts +1 -0
  6. package/spec-cli/src/opencode-headless.ts +119 -5
  7. package/spec-cli/src/opencode.ts +8 -4
  8. package/spec-cli/src/pi-headless.ts +1 -0
  9. package/spec-cli/src/pty-bridge.ts +31 -4
  10. package/spec-cli/src/pty-helper.mjs +16 -6
  11. package/spec-cli/src/pty-native-helper.mjs +22 -0
  12. package/spec-cli/src/session-timeline.ts +23 -17
  13. package/spec-cli/src/sessions.ts +25 -4
  14. package/spec-dashboard/dist/assets/{Dashboard-C_w_wdk5.js → Dashboard-CTAuTyZ3.js} +3 -3
  15. package/spec-dashboard/dist/assets/{EvalsPage-5_nfIYll.js → EvalsPage-KbMMownG.js} +2 -2
  16. package/spec-dashboard/dist/assets/{IssuesPage-By-u--95.js → IssuesPage-DmyLb9Rj.js} +1 -1
  17. package/spec-dashboard/dist/assets/{MobileApp-CVEwjHr9.js → MobileApp-D2RZGt4Z.js} +2 -2
  18. package/spec-dashboard/dist/assets/{Modal-BqgvzMJD.js → Modal-3brXUhM0.js} +1 -1
  19. package/spec-dashboard/dist/assets/{PageScroll-B_dKCuXx.js → PageScroll-CadAKuSy.js} +1 -1
  20. package/spec-dashboard/dist/assets/ProjectsPage-DU3x4Y8l.js +1 -0
  21. package/spec-dashboard/dist/assets/{SessionInterface-Bh3vq8SU.js → SessionInterface-BtrzlOPs.js} +1 -1
  22. package/spec-dashboard/dist/assets/{SessionWindow-BuJ5mzjC.js → SessionWindow-BWH5O0jh.js} +1 -1
  23. package/spec-dashboard/dist/assets/{Settings-B8KFocsz.js → Settings-COgdKTJB.js} +1 -1
  24. package/spec-dashboard/dist/assets/{TimelineChat-K0wdlweB.js → TimelineChat-DQ21GSJK.js} +1 -1
  25. package/spec-dashboard/dist/assets/{index-BKaTHjmU.js → index-D6HBvKkJ.js} +2 -2
  26. package/spec-dashboard/dist/assets/{index-DcnCaBAC.css → index-DFdlYy4H.css} +1 -1
  27. package/spec-dashboard/dist/index.html +2 -2
  28. package/spec-dashboard/dist/assets/ProjectsPage-RVP8AqK4.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as t,r as p,d as js,I as V,u as C,e as me,a as ve,f as ys,i as bs,k as Ns,s as xe}from"./index-BKaTHjmU.js";import{P as ee}from"./PageScroll-B_dKCuXx.js";function ze(e){let s=2166136261;for(let a=0;a<(e||"").length;a++)s^=e.charCodeAt(a),s=Math.imul(s,16777619);return s>>>0}function Ue(e){return ze(e)%360}function ks(e){const s=Ue(e);return{bg:`hsl(${s} 55% 42%)`,fg:`hsl(${s} 70% 92%)`}}function Ss(e){return`hsl(${Ue(e)} 65% 50%)`}const be=["◆","▲","●","■","★","✦","⬟","⬢","❖","◈","✸","⟡","✚","❂","◐","◑","⬣","▰","✶","⬤","✹","◇","⊛","✺"],Ne=["circle","rounded","square","hex"];function $s(e){const s=ze(e);return{seed:e,glyph:be[(s>>>9)%be.length],shape:Ne[(s>>>17)%Ne.length],...ks(e)}}function Es({seed:e,status:s,title:a,size:n=16}){const r=$s(e),i={width:n,height:n};return t.jsx("span",{className:`avatar av-st-${s||"none"}`,"data-tip":a,"aria-label":a,style:i,children:t.jsx("span",{className:`av-face av-gen av-${r.shape}`,style:{...i,background:r.bg,color:r.fg,fontSize:n*.62},children:r.glyph})})}const re=typeof window<"u"?window.__escStack||(window.__escStack=[]):[];typeof window<"u"&&!window.__escStackBound&&(window.__escStackBound=!0,window.addEventListener("keydown",e=>{const s=window.__escStack;e.key!=="Escape"||!s||s.length===0||(e.preventDefault(),e.stopImmediatePropagation(),s[s.length-1].close())},!0));function Be(e,s){const a=p.useRef(s);a.current=s,p.useEffect(()=>{if(!e)return;const n={close:()=>{var r;return(r=a.current)==null?void 0:r.call(a)}};return re.push(n),()=>{const r=re.indexOf(n);r>=0&&re.splice(r,1)}},[e])}const Ls="is:issue state:open",ae="is:eval",He=e=>W(ae,"scope",e),Cs=e=>W(ae,"node",e),We=/^([A-Za-z][A-Za-z0-9-]*):(.*)$/s,ke=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,Ge=e=>/\s/.test(String(e))?`"${e}"`:String(e);function ge(e){const s=String(e??""),a=[];let n=0;for(;n<s.length;){let r=n;if(/\s/.test(s[n])){for(;r<s.length&&/\s/.test(s[r]);)r++;a.push({ws:!0,raw:s.slice(n,r),start:n,end:r})}else{for(;r<s.length&&!/\s/.test(s[r]);)if(s[r]==='"'){for(r++;r<s.length&&s[r]!=='"';)r++;r<s.length&&r++}else r++;const i=s.slice(n,r),l=We.exec(i);a.push(l?{ws:!1,raw:i,start:n,end:r,key:l[1].toLowerCase(),value:ke(l[2])}:{ws:!1,raw:i,start:n,end:r,key:null,value:ke(i)})}n=r}return a}const we=e=>ge(e).filter(s=>!s.ws),Qe=e=>e.map(s=>s.raw).join(" "),Se=e=>Qe(we(e)),Ye=(e,s)=>Se(e)===Se(s),ft=(e,s)=>{const a=we(e);for(let n=a.length-1;n>=0;n--)if(a[n].key===s)return a[n].value;return""};function W(e,s,a){const n=a==null||String(a)===""?null:{ws:!1,raw:`${s}:${Ge(a)}`,key:s,value:String(a)},r=[];let i=!1;for(const l of we(e)){if(l.key===s){n&&!i&&(r.push(n),i=!0);continue}r.push(l)}return n&&!i&&r.push(n),Qe(r)}const As=(e,s)=>{const a=String(e??"").trim();return!a||Ye(a,s)?null:{q:a}},pt=(e,s,a=null)=>{const n=As(e,s)||{};return a!=null&&(n.page=String(a)),Object.keys(n).length?n:null},Ze={state:e=>["state",e],concluded:e=>e==="1"?["state","closed"]:null,ok:e=>e==="1"?["state","reviewed"]:null,verdict:e=>["verdict",e],freshness:e=>["freshness",e],kind:e=>e==="all"?null:["evidence",e],store:e=>["store",e],author:e=>["author",e],node:e=>["node",e],filer:e=>["filer",e],live:e=>e==="1"?["session","present"]:null,session:e=>["scope",e]},Je=e=>Object.keys(Ze).some(s=>(e==null?void 0:e[s])!=null&&e[s]!==""),Ds=e=>/[\s:"]/.test(e)?`"${e.replace(/"/g,"")}"`:e;function Rs(e,s){if(!Je(s))return null;let a=e;for(const[r,i]of Object.entries(Ze)){const l=s[r];if(l==null||l==="")continue;const o=i(String(l));o&&(a=W(a,o[0],o[1]))}const n=String(s.q??"").trim();return n&&(a=`${a} ${Ds(n)}`.trim()),a}function Is(e,s,a=[],n={}){const r=String(e??""),i=Math.max(0,Math.min(s??r.length,r.length)),l=ge(r).find(m=>!m.ws&&m.start<i&&i<=m.end);if(!l)return{start:i,end:i,items:[]};const o=r.slice(l.start,i),c=We.exec(o);if(!c){const m=o.toLowerCase();if(!m||m.includes('"'))return{start:l.start,end:l.end,items:[]};const w=a.filter(x=>x.startsWith(m)).slice(0,8).map(x=>({type:"key",key:x,insert:`${x}:`}));return{start:l.start,end:l.end,items:w}}const u=c[1].toLowerCase(),d=c[2].replace(/^"/,"").replace(/"$/,"").toLowerCase(),h=(n[u]||[]).filter(m=>String(m.value).toLowerCase().startsWith(d)&&String(m.value).toLowerCase()!==d).slice(0,8).map(m=>({type:"value",key:u,value:String(m.value),label:m.label||null,insert:`${u}:${Ge(m.value)} `}));return{start:l.start,end:l.end,items:h}}const Q=new Map;async function Ts(e){if(Q.has(e))return Q.get(e);const s=js(e).then(async a=>{const n=await a.json().catch(()=>null);if(!a.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${a.status}`);return n}).finally(()=>Q.delete(e));return Q.set(e,s),s}const mt=e=>{const s=typeof e=="string"&&/^\d+$/.test(e)?Number(e):Number.NaN;return Number.isSafeInteger(s)&&s>0?s:1};function Ps(e,s){return s<=0?[]:s<=10?Array.from({length:s},(a,n)=>n+1):e<=7?[...Array.from({length:8},(a,n)=>n+1),"gap",s-1,s]:e>=s-6||e>s?[1,2,"gap",...Array.from({length:8},(a,n)=>s-7+n)]:[1,2,"gap",e-2,e-1,e,e+1,e+2,"gap",s-1,s]}function Xe(e,s,a,{enabled:n=!0,refreshKey:r=null,pollMs:i=15e3,view:l=null}={}){const[o,c]=p.useState(null),[u,d]=p.useState(null),[v,h]=p.useState(n),m=p.useRef(0),w=p.useCallback(async({quiet:f=!1}={})=>{if(!n)return null;const b=++m.current;f||h(!0),d(null);const k=new URLSearchParams({q:String(s||""),page:String(a)});l&&k.set("view",l);try{const S=await Ts(`/api/${e}?${k}`);return b===m.current&&c(D=>D&&S&&D.revision===S.revision?D:S),S}catch(S){return b===m.current&&d(S instanceof Error?S.message:String(S)),null}finally{b===m.current&&h(!1)}},[e,n,a,s,l]),x=p.useRef(null);return p.useEffect(()=>{if(!n){h(!1);return}const f=`${e}\0${s}\0${a}\0${l||""}`,b=f!==x.current;x.current=f,b&&c(null),w({quiet:!b});const k=i>0?setInterval(()=>w({quiet:!0}),i):null;return()=>{k&&clearInterval(k)}},[e,s,a,l,n,w,i,r]),{data:o,error:u,loading:v,reload:w}}const $e={issue:{open:{icon:"issue-opened",tone:"open",label:"reviewState.issueOpen"},closed:{icon:"issue-closed",tone:"closed",label:"reviewState.issueClosed"}},eval:{pass:{icon:"circle-check",tone:"pass",label:"score.pass"},fail:{icon:"circle-x",tone:"fail",label:"score.fail"},stalePass:{icon:"circle-check",tone:"stale",label:"score.stalePass"},staleFail:{icon:"circle-x",tone:"stale",label:"score.staleFail"},review:{icon:"clock",tone:"review",label:"reviewList.needsReview"},empty:{icon:"circle-minus",tone:"empty",label:"score.empty"},missing:{icon:"circle-dashed",tone:"empty",label:"score.missing"},legacy:{icon:"circle-minus",tone:"empty",label:"score.empty"}}},Vs=(e,s)=>{var n;const a=e==="issue"?s==="open"?"open":"closed":s||"empty";return((n=$e[e])==null?void 0:n[a])||$e.eval.empty};function je({kind:e,state:s,showLabel:a=!1,size:n=16,className:r="",title:i}){const l=C(),o=Vs(e,s),c=i||l(o.label);return t.jsxs("span",{className:`review-state ${e} ${o.tone} ${r}`,"data-tip":c,"aria-label":c,children:[t.jsx("span",{className:"review-state-icon",style:{width:n,height:n},children:t.jsx(V,{name:o.icon,size:n})}),a&&t.jsx("span",{className:"review-state-label",children:c})]})}function Fs(e,s){const a={...e,...s};for(const[n,r]of Object.entries(a))(r==null||r==="")&&delete a[n];return a}const qs=e=>e&&typeof e=="object"?e.hasData?e.filtered:e.dataset:e,es=(e,s,a)=>{const n=Array.isArray(e)?e:[];return!(s!=null&&String(s)!=="")||a==null||n.some(i=>String(i.value)==="")?n:[{value:"",label:a},...n]},Ms=(e=[])=>e.reduce((s,a)=>((a.active??(a.value!=null&&String(a.value)!==""))&&(s.mobile+=1,a.mobileOnly||(s.desktop+=1)),s),{desktop:0,mobile:0}),ye=(e,s,a)=>s?a==="Home"?0:a==="End"?s-1:a==="ArrowDown"||a==="ArrowRight"?e<0?0:(e+1)%s:a==="ArrowUp"||a==="ArrowLeft"?e<0?s-1:(e-1+s)%s:e:-1,Ks=(e,s)=>{var n;const a=e==null?void 0:e.tagName;return a==="INPUT"||a==="TEXTAREA"||a==="SELECT"||a==="BUTTON"&&(s==="Enter"||s===" ")||s==="Enter"&&((n=e==null?void 0:e.closest)!=null&&n.call(e,"a[href]"))?!1:s==="j"||s==="k"||s==="Enter"},le=e=>[...(e==null?void 0:e.querySelectorAll('[role="menuitemradio"]'))||[]].filter(s=>s.getClientRects().length>0),ie=(e,s)=>{const a=e[s];if(a){for(const n of e)n.tabIndex=n===a?0:-1;a.focus()}};function ss(){const[e,s]=p.useState(!1),a=p.useRef(null),n=p.useRef(null),r=p.useRef(null),i=p.useRef("checked"),l=(h=!1)=>{var m;h&&((m=r.current)==null||m.focus()),s(!1)},o=(h,m="checked")=>{r.current=h,i.current=m,s(!0)},c=h=>{e?l(!1):o(h)};return Be(e,()=>l(!0)),p.useEffect(()=>{if(!e)return;const h=m=>{var w;(w=a.current)!=null&&w.contains(m.target)||l(!1)};return window.addEventListener("pointerdown",h,!0),()=>window.removeEventListener("pointerdown",h,!0)},[e]),p.useEffect(()=>{if(!e)return;const h=requestAnimationFrame(()=>{const m=le(n.current),w=m.findIndex(f=>f.getAttribute("aria-checked")==="true"),x=i.current==="last"?m.length-1:i.current==="first"?0:w>=0?w:0;ie(m,x)});return()=>cancelAnimationFrame(h)},[e]),{open:e,ref:a,menuRef:n,close:l,toggle:c,onTriggerKeyDown:h=>{h.key!=="ArrowDown"&&h.key!=="ArrowUp"||(h.preventDefault(),h.stopPropagation(),o(h.currentTarget,h.key==="ArrowUp"?"last":"first"))},onMenuKeyDown:h=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(h.key))return;const m=le(n.current),w=m.indexOf(document.activeElement);h.preventDefault(),h.stopPropagation(),ie(m,ye(w,m.length,h.key))},onItemFocus:h=>{const m=le(n.current);ie(m,m.indexOf(h.currentTarget))}}}function vt({label:e,value:s="",options:a=[],onChange:n,mobile:r=!1,clearLabel:i}){const l=ss(),o=es(a,s,i);if(!o.length)return null;const c=o.find(v=>String(v.value)===String(s)),u=s?(c==null?void 0:c.label)||String(s):"",d=u?`${e}: ${u}`:e;return t.jsxs("div",{className:`rl-facet-wrap ${r?"mobile-stay":""}`,ref:l.ref,children:[t.jsxs("button",{type:"button",className:`rl-facet ${s?"active":""}`,"aria-label":d,"aria-haspopup":"menu","aria-expanded":l.open,onClick:v=>l.toggle(v.currentTarget),onKeyDown:l.onTriggerKeyDown,children:[t.jsx("span",{className:"rl-facet-label",children:d}),r&&t.jsx("span",{className:"rl-facet-label-mobile","aria-hidden":"true",children:u||e}),t.jsx(V,{name:"chevron-down",size:12})]}),l.open&&t.jsx("div",{className:"rl-menu",role:"menu","aria-label":e,ref:l.menuRef,onKeyDown:l.onMenuKeyDown,children:o.map(v=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(v.value)===String(s),tabIndex:-1,className:"rl-menu-item",onFocus:l.onItemFocus,onClick:()=>{l.close(!0),n(v.value)},children:[t.jsx(V,{name:String(v.value)===String(s)?"check":"blank",size:13}),t.jsx("span",{children:v.label}),v.count!=null&&t.jsx("span",{className:"rl-menu-count",children:v.count})]},String(v.value)))})]})}function Os({label:e,groups:s=[],clearLabel:a,compact:n=!1,className:r=""}){const i=C(),l=p.useId(),o=s.map(h=>({...h,options:es(h.options,h.value,h.clearLabel===null?null:h.clearLabel||a)})).filter(h=>h.options.length),c=o.some(h=>!h.mobileOnly),u=Ms(o),d=ss();if(!o.length)return null;const v=(h,m)=>h>0&&t.jsxs("span",{className:`rl-secondary-filter-count ${m}`,children:[t.jsx("span",{"aria-hidden":"true",children:h}),t.jsx("span",{className:"sr-only",children:i("reviewList.activeFilters",{n:h})})]});return t.jsxs("div",{className:`rl-secondary-filters ${c?"":"mobile-only"} ${u.desktop?"active-desktop":""} ${u.mobile?"active-mobile":""} ${r}`,ref:d.ref,children:[n?t.jsx(me,{icon:"filter",size:16,className:"rl-secondary-filters-trigger compact",label:e,"aria-haspopup":"menu","aria-expanded":d.open,onClick:h=>d.toggle(h.currentTarget),onKeyDown:d.onTriggerKeyDown}):t.jsxs("button",{type:"button",className:"rl-secondary-filters-trigger","aria-haspopup":"menu","aria-expanded":d.open,onClick:h=>d.toggle(h.currentTarget),onKeyDown:d.onTriggerKeyDown,children:[t.jsx(V,{name:"filter",size:14}),t.jsx("span",{children:e}),v(u.desktop,"for-desktop"),v(u.mobile,"for-mobile"),t.jsx(V,{name:"chevron-down",size:12})]}),d.open&&t.jsx("div",{className:"rl-menu rl-secondary-filters-menu",role:"menu","aria-label":e,ref:d.menuRef,onKeyDown:d.onMenuKeyDown,children:o.map((h,m)=>t.jsxs("div",{role:"group","aria-labelledby":`${l}-group-${m}`,className:`rl-menu-group ${h.mobileOnly?"mobile-only":""}`,children:[t.jsx("div",{className:"rl-menu-label",id:`${l}-group-${m}`,children:h.label}),h.options.map(w=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(w.value)===String(h.value||""),tabIndex:-1,className:"rl-menu-item",onFocus:d.onItemFocus,onClick:()=>{d.close(!0),h.onChange(w.value)},children:[t.jsx(V,{name:String(w.value)===String(h.value||"")?"check":"blank",size:13}),t.jsx("span",{children:w.label}),w.count!=null&&t.jsx("span",{className:"rl-menu-count",children:w.count})]},String(w.value)))]},`${h.label}-${h.mobileOnly?"mobile":"all"}`))})]})}function xt({state:e,title:s,meta:a,aside:n}){return t.jsxs("div",{className:"rl-row-grid",children:[t.jsx("div",{className:"rl-row-state",children:e}),t.jsxs("div",{className:"rl-row-body",children:[t.jsx("div",{className:"rl-row-title",children:s}),a&&t.jsx("div",{className:"rl-row-meta",children:a})]}),n&&t.jsx("div",{className:"rl-row-aside",children:n})]})}const Y=e=>{const s=String(e??"").trim();return s?`${s} `:""};function _s({value:e="",onSubmit:s,placeholder:a,label:n,keys:r=[],suggest:i={}}){const[l,o]=p.useState(()=>Y(e)),[c,u]=p.useState(-1),[d,v]=p.useState(-1),h=p.useRef(null),m=p.useRef(null),w=p.useId(),x=p.useRef(null),f=g=>requestAnimationFrame(()=>{const E=h.current;E&&(g&&E.focus(),E.setSelectionRange(E.value.length,E.value.length))});p.useEffect(()=>{o(Y(e)),u(-1),v(-1),f(x.current!==null&&x.current!==e),x.current=e},[e]);const b=c>=0?Is(l,c,r,i):{start:0,end:0,items:[]},k=b.items.length>0;Be(k,()=>u(-1));const S=()=>{m.current&&h.current&&(m.current.scrollLeft=h.current.scrollLeft)};p.useEffect(S);const D=g=>{u(-1),v(-1);const E=g.trim();o(Y(E)||Y(e)),f(!0),s(E)},N=g=>{const E=`${l.slice(0,b.start)}${g.insert}${l.slice(b.end)}`;if(o(E),g.type==="value"){D(E);return}const R=b.start+g.insert.length;u(R),v(-1),requestAnimationFrame(()=>{var y,$;(y=h.current)==null||y.focus(),($=h.current)==null||$.setSelectionRange(R,R)})};return t.jsxs("form",{className:"rl-query rq",role:"search",onSubmit:g=>{g.preventDefault(),D(l)},children:[t.jsxs("div",{className:"rq-wrap",children:[t.jsx("div",{className:"rq-hl","aria-hidden":"true",ref:m,children:ge(l).map((g,E)=>g.ws||g.key==null||!r.includes(g.key)?t.jsx("span",{children:g.raw},E):t.jsxs("span",{className:"rq-tok",children:[t.jsx("span",{className:"rq-tok-key",children:g.raw.slice(0,g.key.length+1)}),t.jsx("span",{className:"rq-tok-val",children:g.raw.slice(g.key.length+1)})]},E))}),t.jsx("input",{ref:h,role:"combobox","aria-expanded":k,"aria-controls":w,"aria-autocomplete":"list","aria-activedescendant":k&&d>=0?`${w}-o${d}`:void 0,value:l,spellCheck:!1,autoComplete:"off",placeholder:a,"aria-label":n,onChange:g=>{o(g.target.value),u(g.target.selectionStart??g.target.value.length),v(-1)},onScroll:S,onKeyDown:g=>{k&&(g.key==="ArrowDown"||g.key==="ArrowUp"?(g.preventDefault(),v(ye(d,b.items.length,g.key))):g.key==="Enter"&&d>=0&&(g.preventDefault(),N(b.items[d])))},onBlur:()=>u(-1)})]}),k&&t.jsx("div",{className:"rl-menu rq-list",role:"listbox",id:w,"aria-label":n,children:b.items.map((g,E)=>t.jsxs("div",{id:`${w}-o${E}`,role:"option","aria-selected":E===d,className:`rq-opt ${E===d?"active":""}`,onPointerDown:R=>{R.preventDefault(),N(g)},children:[t.jsx("span",{className:"rq-opt-token",children:g.insert.trim()}),g.label&&g.label!==g.value&&t.jsx("span",{className:"rq-opt-label",children:g.label})]},g.insert))}),t.jsx("button",{type:"submit",className:"rl-query-submit","data-tip":n,"aria-label":n,children:t.jsx(V,{name:"search",size:16})})]})}function ns({value:e="",onChange:s,placeholder:a,searchLabel:n,filterLabel:r,groups:i,clearLabel:l,clearSearchLabel:o,summary:c}){const u=C(),d=t.jsxs("div",{className:"rf-compact",role:"search",children:[t.jsx("span",{className:"rf-search-icon",children:t.jsx(V,{name:"search",size:13})}),t.jsx("input",{value:e,onChange:h=>s(h.target.value),placeholder:a,"aria-label":n}),e&&t.jsx(me,{icon:"x",size:12,className:"rf-clear",label:o,onClick:()=>s("")}),t.jsx(Os,{label:r,clearLabel:l,groups:i,compact:!0,className:"rf-secondary-filters"})]});if(!c)return d;const v=u("reviewList.showing",{shown:c.shown,total:c.total});return t.jsxs("div",{className:"rf-row",children:[t.jsxs("span",{className:"rf-summary","data-tip":v,children:[t.jsx("span",{className:"sr-only",children:v}),t.jsx("span",{className:"rf-summary-full","aria-hidden":"true",children:v}),t.jsxs("span",{className:"rf-summary-compact","aria-hidden":"true",children:[c.shown,"/",c.total]})]}),d]})}function zs({page:e,pageCount:s,prev:a,next:n,hrefFor:r}){const i=C();if(s<=1&&e<=1)return null;const l=(o,c,u,d="")=>o==null?t.jsx("span",{className:`rl-page-link disabled ${d}`,"aria-disabled":"true",children:c}):t.jsx("a",{className:`rl-page-link ${d}`,href:r(o),rel:u,"aria-label":u?i(`reviewList.${u}Page`):i("reviewList.page",{n:o}),children:c});return t.jsxs("nav",{className:"rl-pagination","aria-label":i("reviewList.pagination"),children:[l(a,i("reviewList.previous"),"prev","direction"),Ps(e,s).map((o,c)=>o==="gap"?t.jsx("span",{className:"rl-page-gap","aria-hidden":"true",children:"…"},`gap-${c}`):t.jsx("a",{className:"rl-page-link number",href:r(o),"aria-label":i("reviewList.page",{n:o}),"aria-current":o===e?"page":void 0,children:o},o)),l(n,i("reviewList.next"),"next","direction")]})}function gt({notice:e,leading:s,error:a,loading:n=!1,title:r,action:i,search:l,sections:o=[],sectionMode:c="tabs",facets:u,secondaryFilters:d,rows:v,empty:h,pagination:m,children:w}){const x=C(),[f,b]=p.useState(null),k=p.useId(),S=p.useRef({});S.current={rows:v,cur:f},p.useEffect(()=>{const y=$=>{if($.metaKey||$.ctrlKey||$.altKey||!Ks($.target,$.key))return;const A=S.current.rows.filter(F=>F.href);if(!A.length)return;if($.key==="Enter"){const F=A.find(j=>j.key===S.current.cur);F&&($.preventDefault(),$.stopPropagation(),window.location.hash=F.href);return}$.preventDefault(),$.stopPropagation();const I=A.findIndex(F=>F.key===S.current.cur),U=I<0?$.key==="j"?0:A.length-1:Math.max(0,Math.min(A.length-1,I+($.key==="j"?1:-1)));b(A[U].key)};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[]),p.useEffect(()=>{var y;(y=document.querySelector(".lp-row.cur"))==null||y.scrollIntoView({block:"nearest"})},[f]);const D=qs(h),N=Math.max(0,o.findIndex(y=>y.active)),g=c==="tabs",E=`${k}-panel`,R=y=>`${k}-tab-${y}`;return t.jsxs(ee,{className:"lp-page",children:[e&&t.jsx("div",{className:"fv-notice",children:e}),s,t.jsxs("div",{className:"rl-content",children:[t.jsxs("div",{className:"rl-titlebar",children:[t.jsx("h1",{children:r}),i]}),l&&t.jsx(_s,{...l}),a&&t.jsx("div",{className:"fv-error lp-error",role:"alert",children:a}),t.jsxs("section",{className:"rl-list",children:[t.jsxs("header",{className:"lp-head",children:[t.jsx("div",{className:"rl-sections",role:g?"tablist":"group","aria-label":r,...g?{"aria-orientation":"horizontal"}:{},children:o.map((y,$)=>t.jsxs("button",{type:"button",role:g?"tab":void 0,"aria-selected":g?y.active:void 0,"aria-pressed":g?void 0:y.active,"aria-controls":g?E:void 0,id:g?R($):void 0,tabIndex:g?$===N?0:-1:void 0,className:`rl-section ${y.active?"active":""}`,onClick:y.onSelect,onKeyDown:A=>{var F,j;if(!g||!["ArrowLeft","ArrowRight","Home","End"].includes(A.key))return;const I=[...A.currentTarget.closest('[role="tablist"]').querySelectorAll('[role="tab"]')],U=ye(I.indexOf(A.currentTarget),I.length,A.key);A.preventDefault(),A.stopPropagation(),(F=I[U])==null||F.focus(),(j=I[U])==null||j.click()},children:[t.jsx("span",{children:y.label}),t.jsx("span",{className:"rl-section-count",children:y.count})]},y.key))}),t.jsxs("div",{className:"rl-facets",children:[u,d]})]}),t.jsxs("div",{className:"lp-rows",role:g?"tabpanel":"region",id:E,"aria-busy":n||void 0,"aria-labelledby":g?R(N):void 0,"aria-label":g?void 0:r,children:[v.length===0&&t.jsx("div",{className:"lp-empty",children:n?x("common.loading"):D}),v.map(y=>y.href?t.jsx("a",{className:`lp-row ${y.cls||""} ${f===y.key?"cur":""}`,href:y.href,children:y.content},y.key):t.jsx("div",{className:`lp-row inert ${y.cls||""}`,children:y.content},y.key))]})]}),m&&t.jsx(zs,{...m})]}),w]})}function wt({title:e,titleMeta:s,status:a,side:n,composer:r,missing:i,failure:l,listHref:o,listLabel:c,backHref:u,backLabel:d,children:v}){return l?t.jsxs(ee,{className:"ds-page ds-missing ds-failed",role:"alert",children:[t.jsx("div",{className:"ds-missing-note",children:l}),o&&t.jsx("a",{className:"ds-backlink",href:o,children:c})]}):i?t.jsxs(ee,{className:"ds-page ds-missing",children:[t.jsx("div",{className:"ds-missing-note",children:i}),o&&t.jsx("a",{className:"ds-backlink",href:o,children:c})]}):t.jsxs(ee,{className:"ds-page",children:[t.jsxs("header",{className:"ds-head",children:[u&&t.jsx("a",{className:"ds-back",href:u,"data-tip":d,"aria-label":d,children:t.jsx(V,{name:"arrow-left",size:16})}),t.jsxs("h1",{className:"ds-title",children:[e,s&&t.jsx("span",{className:"ds-title-meta",children:s})]})]}),a&&t.jsx("div",{className:"ds-status",children:a}),t.jsxs("div",{className:"ds-cols",children:[t.jsxs("div",{className:"ds-main",children:[v,r&&t.jsx("div",{className:"ds-compose",children:r})]}),t.jsx("aside",{className:"ds-side",children:n})]})]})}function jt({label:e,children:s}){return t.jsxs("div",{className:"ds-side-sec",children:[t.jsx("span",{className:"ds-side-label",children:e}),t.jsx("div",{className:"ds-side-body",children:s})]})}function Us({text:e,tip:s,dim:a=!1,mono:n=!1,href:r=null,external:i=!1,onClick:l=null,className:o="",lead:c=null,trail:u=null,label:d=null}){const v=`ds-val${a?" dim":""}${n?" mono":""}${r||l?" link":""}${o?` ${o}`:""}`,h=s??(typeof e=="string"?e:void 0),m=d?{"aria-label":d}:{},w=t.jsxs(t.Fragment,{children:[c,t.jsx("span",{className:"ds-val-text",children:e}),u]});return r?t.jsx("a",{className:v,href:r,"data-tip":h,...m,...i?{target:"_blank",rel:"noreferrer"}:{},children:w}):l?t.jsx("button",{type:"button",className:v,onClick:l,"data-tip":h,...m,children:w}):t.jsx("span",{className:v,"data-tip":h,children:w})}function Bs(e){var s,a;return((s=e==null?void 0:e.verdict)==null?void 0:s.status)==="pass"?"check":((a=e==null?void 0:e.verdict)==null?void 0:a.status)==="fail"?"cross":null}function ts(e){const s=Bs(e);return s?e.fresh?s==="cross"?"fail":"pass":s==="cross"?"staleFail":"stalePass":"empty"}function Hs(e,s){if(!e)return[];const a=new Map;for(const n of s||[])a.has(n.scenario)||a.set(n.scenario,n);return e.map(n=>{const r=a.get(n.name)||null;return{...n,reading:r,state:r?ts(r):"missing"}})}function Ws(e){return e.length?e.some(s=>s.state==="fail")?"fail":e.some(s=>s.state==="staleFail")?"staleFail":e.some(s=>s.state==="stalePass")?"stalePass":e.some(s=>s.state==="empty"||s.state==="missing")?"empty":"pass":null}const Gs=e=>e.fail>0?"fail":e.staleFail>0?"staleFail":e.stalePass>0?"stalePass":e.empty>0?"empty":"pass";function Qs({scenarios:e,evals:s,summary:a=null,href:n}){const r=C(),i=a?null:Hs(e,s),l=(a==null?void 0:a.total)??i.length;if(!l)return null;const o=a?Gs(a):Ws(i),c=(a==null?void 0:a.pass)??i.filter(h=>h.state==="pass").length,u=r("score.count",{satisfied:c,total:l,outstanding:l-c}),d=t.jsxs(t.Fragment,{children:[t.jsx(V,{name:"check",size:11}),c,"/",l]});if(!n)return t.jsx("span",{className:`scenario-count ${o}`,"data-tip":u,"aria-label":u,children:d});const v=`${u} — ${r("score.openList")}`;return t.jsx("a",{className:`scenario-count ${o}`,href:n,"data-tip":v,"aria-label":v,children:d})}function Z({kind:e,state:s,cls:a,n,label:r}){return t.jsxs("span",{className:`ovc ${a}`,"data-tip":r,children:[t.jsx(je,{kind:e,state:s,title:r,size:11}),n]})}function Ys({tags:e}){return e!=null&&e.length?t.jsx("span",{className:"tag-chips",children:e.map(s=>t.jsx("span",{className:"tag-chip",children:s},s))}):null}function as({state:e,title:s}){return e?t.jsx(je,{kind:"eval",state:e,title:s,className:`score-badge ${e}`,size:14}):null}const yt={merged:{color:"#859900"},active:{color:"#cb4b16"},drift:{color:"#b58900"},pending:{color:"#93a1a1"}},Zs={added:"+",edited:"~",deleted:"✕",moved:"→"},q={working:"var(--green)",parked:"var(--green)",asking:"var(--yellow)",review:"var(--yellow)",done:"var(--yellow)",error:"var(--red)",idle:"var(--muted)",starting:"var(--muted)",queued:"var(--muted)","close-pending":"var(--muted)",offline:"var(--muted)",unknown:"var(--yellow)"},Js={working:"●",parked:"‖",asking:"?",review:"◑",done:"✓",error:"✕",idle:"·",starting:"◌",queued:"⋯","close-pending":"⊘",offline:"○",unknown:"⁇"},rs=new Set(["asking","review","done","close-pending","error"]),ne=e=>(e==null?void 0:e.liveness)==="offline"||(e==null?void 0:e.status)==="offline"?"offline":rs.has(e==null?void 0:e.status)?"need":"run",Xs=(e,s)=>{const a=s?(e||[]).find(n=>n.id===s):null;return a&&ne(a)!=="offline"?a:null},Ee=e=>(e==null?void 0:e.sortKey)!=null?e.sortKey:(e==null?void 0:e.created)??0,Le=e=>{const s={need:0,run:1,offline:2};return[...e].sort((a,n)=>s[ne(a)]-s[ne(n)]||Ee(n)-Ee(a))},en=e=>(e==null?void 0:e.label)||(e==null?void 0:e.name)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id),ls=e=>(e==null?void 0:e.headline)||(e==null?void 0:e.name)||(e==null?void 0:e.activity)||(e==null?void 0:e.promptPreview)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id);function sn(e){const s=new Set(e.map(r=>r==null?void 0:r.id)),a=new Map,n=[];for(const r of e){const i=r!=null&&r.parent&&r.parent!==r.id&&s.has(r.parent)?r.parent:null;if(i){const l=a.get(i)||[];l.push(r),a.set(i,l)}else n.push(r)}return{roots:n,childrenOf:a}}function bt(e,s){const a=new Map(e.map(l=>[l==null?void 0:l.id,l])),n=[],r=new Set([s]);let i=a.get(s);for(;i!=null&&i.parent&&!r.has(i.parent);){const l=a.get(i.parent);if(!l)break;n.push(l.id),r.add(l.id),i=l}return n}function nn(e,s){let a=!1,n=!1,r=0;const i=(l,o)=>{for(const c of s.get(l)||[])o.has(c.id)||(o.add(c.id),r++,rs.has(c.status)?a=!0:q[c.status]===q.working&&(n=!0),i(c.id,o))};return i(e,new Set([e])),{color:a?q.asking:n?q.working:q.idle,count:r}}function tn(e,s){const{roots:a,childrenOf:n}=sn(e),r=[],i=(c,u,d,v)=>{const h=n.get(c.id)||[],m=h.length>0,w=m&&!!s(c.id),x=m?nn(c.id,n):null;if(r.push({type:"row",s:c,depth:u,expandable:m,expanded:w,rollup:(x==null?void 0:x.color)??null,kin:(x==null?void 0:x.count)??0,guides:v}),w){const f=Le(h).filter(b=>!d.has(b.id));f.forEach((b,k)=>{d.add(b.id),i(b,u+1,d,[...v,k<f.length-1])})}},l=new Set;let o=null;for(const c of Le(a)){if(l.has(c.id))continue;l.add(c.id);const u=ne(c);u!==o&&(r.push({type:"zone",zone:u}),o=u),i(c,0,l,[])}return r}const oe=Object.freeze({RESULT:"result",BLIND:"blind",UNMEASURED:"unmeasured",DANGLING:"dangling"}),is=e=>{var s;return(s=e==null?void 0:e.evidence)!=null&&s.length?e.evidence:(e==null?void 0:e.blob)!=null?[{hash:e.blob,kind:e.blobKind||"image",state:e.blobState||"present"}]:[]},Nt=e=>{const s=is(e);return s.length?["video","image","transcript","data"].filter(a=>s.some(n=>n.kind===a)):["note"]},kt=e=>String(e||"").length>22?`${String(e).slice(0,8)}…`:e;function os(e,s,a){return a.map(n=>n==="section"?e.section:e.facets[n]).filter(n=>{var r;return(n==null?void 0:n.meaningful)!==!1&&(((r=n==null?void 0:n.options)==null?void 0:r.length)>1||(n==null?void 0:n.value)!=null&&n.value!==""&&n.value!=="all")}).map(n=>({key:n.key,label:n.label,value:n.value,active:n.value!=null&&n.value!==""&&n.value!=="all",options:n.options,clearLabel:n.value==="all"?null:void 0,onChange:r=>s({[n.key]:r||null})}))}const B=e=>ve(`/api/evidence/${e}`);function an({src:e,alt:s,onClose:a}){return p.useEffect(()=>{const n=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation(),a())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[a]),t.jsx("div",{className:"lightbox",onClick:a,children:t.jsx("img",{src:e,alt:s})})}function rn({hash:e}){const s=C(),[a,n]=p.useState(null);return p.useEffect(()=>{let r=!0;return fetch(B(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{r&&n(i)}).catch(()=>{r&&n("")}),()=>{r=!1}},[e]),a===null?t.jsx("pre",{className:"eval-transcript loading",children:s("nodeView.eval.loadingTranscript")}):t.jsx("pre",{className:"eval-transcript",children:a})}function ln({hash:e,collapsed:s=!1}){const a=C(),[n,r]=p.useState(null);if(p.useEffect(()=>{let l=!0;return fetch(B(e)).then(o=>o.ok?o.text():Promise.reject(new Error("miss"))).then(o=>{let c=o,u=!0;try{c=JSON.stringify(JSON.parse(o),null,2)}catch{u=!1}l&&r({text:c,valid:u})}).catch(()=>{l&&r({text:"",valid:!1})}),()=>{l=!1}},[e]),n===null)return t.jsx("pre",{className:"eval-data loading",children:a("nodeView.eval.loadingData")});const i=n.valid?a("nodeView.eval.data"):a("nodeView.eval.dataInvalid");return s?t.jsxs("details",{className:"eval-datawrap eval-datafold",children:[t.jsx("summary",{className:"eval-datahead",children:i}),t.jsx("pre",{className:"eval-data",children:n.text})]}):t.jsxs("div",{className:"eval-datawrap",children:[t.jsx("div",{className:"eval-datahead",children:i}),t.jsx("pre",{className:"eval-data",children:n.text})]})}function on({hash:e,alt:s}){const[a,n]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("img",{className:"an-image",src:B(e),alt:s,loading:"lazy",onClick:()=>n(!0)}),a&&t.jsx(an,{src:B(e),alt:s,onClose:()=>n(!1)})]})}function cn({exit:e}){return t.jsx(V,{name:e?"minimize":"maximize",size:15})}function St({target:e,className:s=""}){const a=C(),[n,r]=p.useState(!1);p.useEffect(()=>{const l=()=>{const o=document.fullscreenElement,c=e==null?void 0:e.current;r(!!o&&!!c&&(o===c||c.contains(o)))};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[e]);const i=()=>{var o,c;const l=e==null?void 0:e.current;l&&(document.fullscreenElement?(o=document.exitFullscreen||document.webkitExitFullscreen)==null||o.call(document):(c=l.requestFullscreen||l.webkitRequestFullscreen)==null||c.call(l))};return t.jsx("button",{type:"button",className:`an-fs ${s}`,onClick:i,"data-tip":a(n?"annotator.exitFullscreen":"annotator.fullscreen"),"aria-label":a(n?"annotator.exitFullscreen":"annotator.fullscreen"),children:t.jsx(cn,{exit:n})})}function cs({e,alt:s="",collapsed:a=!1}){const n=C();return e.state==="miss"?t.jsx("div",{className:"eval-noimg",children:n("nodeView.eval.miss")}):e.kind==="transcript"?t.jsx(rn,{hash:e.hash}):e.kind==="data"?t.jsx(ln,{hash:e.hash,collapsed:a}):e.kind==="video"?t.jsx("video",{className:"eval-video",src:B(e.hash),controls:!0,preload:"metadata",playsInline:!0}):t.jsx(on,{hash:e.hash,alt:s})}const J=new Map;function un(e){const[s,a]=p.useState(()=>J.get(e)??null);return p.useEffect(()=>{if(J.has(e)){a(J.get(e));return}let n=!0;return fetch(B(e),{headers:{Range:"bytes=0-0"}}).then(r=>{const i=r.headers.get("content-type")||"",l=r.ok?{kind:i.startsWith("video/")?"video":i.startsWith("image/")?"image":i.startsWith("application/json")?"data":"transcript",state:"present"}:{kind:"image",state:"miss"};J.set(e,l),n&&a(l)}).catch(()=>{n&&a({kind:"image",state:"miss"})}),()=>{n=!1}},[e]),s}function us({hash:e,alt:s=""}){const a=un(e);return a?t.jsx(cs,{e:{hash:e,...a},alt:s}):null}const $t=/\[\[(\.?[\p{L}\p{N}_-]+)\]\]/gu,ds=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,"");function dn(e,s,a){const n=s.toLowerCase(),r=[];for(const i of e){const l=i.id.toLowerCase(),o=ds(i.path).toLowerCase();let c;if(!n)c=3;else if(l.startsWith(n))c=0;else if(l.includes(n))c=1;else if(o.includes(n))c=2;else continue;i.id===a&&(c=-1),r.push({s:i,score:c})}return r.sort((i,l)=>i.score-l.score||i.s.id.length-l.s.id.length||i.s.id.localeCompare(l.s.id)),r.slice(0,8).map(i=>i.s)}function hn(e,s){const a=s.toLowerCase(),n=o=>ls(o)||(o.id||"").slice(0,8),r=[];for(const o of e||[]){if(o.liveness!=="online")continue;const c=(o.id||"").toLowerCase(),u=n(o).toLowerCase();let d;if(!a)d=3;else if(c===a||u===a)d=0;else if(c.startsWith(a)||u.startsWith(a))d=1;else if(c.includes(a)||u.includes(a))d=2;else continue;r.push({s:o,score:d})}r.sort((o,c)=>o.score-c.score||(c.s.created||0)-(o.s.created||0));const i=r.map(o=>({id:o.s.id,label:n(o.s),sub:o.s.node||o.s.status})),l=r.filter(o=>o.score===0).length;return i.splice(l,0,{id:"new",label:"new",sub:"choose a launcher"}),i.slice(0,8)}function fn(e,s){const a=s.toLowerCase();return(e||[]).map(n=>{const r=(n.name||"").toLowerCase(),i=a?r.startsWith(a)?0:r.includes(a)?1:-1:1;return{l:n,score:i}}).filter(n=>n.score>=0).sort((n,r)=>n.score-r.score||n.l.name.localeCompare(r.l.name)).slice(0,8).map(({l:n})=>({id:n.name,label:n.name,sub:n.cmd||n.harness||""}))}function se(e,s){if(!s)return e;const a=e.toLowerCase().indexOf(s.toLowerCase());return a<0?e:t.jsxs(t.Fragment,{children:[e.slice(0,a),t.jsx("b",{className:"mention-hit",children:e.slice(a,a+s.length)}),e.slice(a+s.length)]})}function hs(e,s){const a=s.toLowerCase(),n=[];for(const r of e){const i=r.name.toLowerCase();let l;if(!a)l=1;else if(i.startsWith(a))l=0;else if(i.includes(a))l=1;else continue;n.push({c:r,score:l})}return n.sort((r,i)=>r.score-i.score),n.slice(0,10).map(r=>r.c)}function Et(e,s,a){let n=s;for(;n>0&&!/\s/.test(e[n-1]);)n--;if(e[n]!=="/")return null;const r=e.slice(n+1,s),i=hs(a,r);return i.length?{items:i,index:0,start:n,end:s,query:r}:null}const pn=e=>e&&e[0].toUpperCase()+e.slice(1),mn={user:"(user)",project:"(project)",skill:"[skill]","built-in":"built-in",ui:"[ui]",preset:"[preset]",review:"[review]"};function vn({menu:e,up:s,head:a,onPick:n,onHover:r}){const i=C();return t.jsxs("ul",{className:s?"mention-menu up":"mention-menu",role:"listbox",children:[t.jsxs("li",{className:"mention-head",children:["// ",a," — ",i("session.menuHint")]}),e.items.map((l,o)=>{const c=l.ui?"ui":l.source??l.kind,u=l.ui?` sc-${l.color}`:"";return t.jsxs("li",{role:"option","aria-selected":o===e.index,className:`${o===e.index?"mention-item on":"mention-item"}${u}`,onMouseDown:d=>{d.preventDefault(),n(l)},onMouseEnter:()=>r(o),children:[t.jsxs("span",{className:l.ui?"slash-name ui":"slash-name",children:["/",se(l.name,e.query)]}),t.jsx("span",{className:"slash-desc",children:pn(l.description??l.desc)}),t.jsx("span",{className:`slash-src src-${c}`,children:mn[c]||c})]},`${c}:${l.name}`)})]})}function xn(e,s,a,n){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.\-]/u.test(e[r]);)r--;if(r>=1&&e[r-1]==="["&&e[r]==="["){const i=e.slice(r+1,s),l=dn(a,i,n);return l.length?{kind:"mention",items:l,index:0,start:r-1,end:s,query:i}:null}return null}function Ce(e,s,a,n=[]){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.:\-]/u.test(e[r]);)r--;if(r>=0&&e[r]==="@"&&(r===0||/\s/.test(e[r-1]))){const i=e.slice(r+1,s);if(i.startsWith("new:")){const o=i.slice(4),c=fn(n,o);return c.length?{kind:"launcher",items:c,index:0,start:r,end:s,query:o}:null}const l=hn(a,i);return l.length?{kind:"actor",items:l,index:0,start:r,end:s,query:i}:null}return null}function gn({menu:e,up:s,fixedStyle:a,onPick:n,onHover:r}){const i=C(),l=e.kind==="launcher",o=e.kind==="actor"||l,c=l?`@new:${e.query}`:e.query?o?`@${e.query}`:`[[${e.query}]]`:i(o?"session.menuSessions":"session.menuSpecNodes");return t.jsxs("ul",{className:`${s?"mention-menu up":"mention-menu"}${a?" fixed":""}`,style:a||void 0,role:"listbox",children:[t.jsxs("li",{className:"mention-head",children:["// ",c," — ",i("session.menuHint")]}),e.items.map((u,d)=>t.jsxs("li",{role:"option","aria-selected":d===e.index,className:`${d===e.index?"mention-item on":"mention-item"}${l||o&&u.id==="new"?" new":""}`,onMouseDown:v=>{v.preventDefault(),n(u)},onMouseEnter:()=>r(d),children:[!o&&t.jsx("span",{className:"mention-dot",style:{background:q[u.status]||q.offline}}),t.jsx("span",{className:"mention-id",children:l?t.jsxs(t.Fragment,{children:["@new:",se(u.label,e.query)]}):o?t.jsxs(t.Fragment,{children:["@",se(u.label,e.query)]}):se(u.id,e.query)}),t.jsx("span",{className:"mention-path",children:o?u.sub:ds(u.path)})]},u.id))]})}function wn({inputRef:e,value:s,setValue:a,specs:n=[],sessions:r=[],launchers:i=[],focusId:l=null,up:o=!1,fixedAbove:c=null}){const[u,d]=p.useState(null),[v,h]=p.useState(null),m=p.useRef(null),w=N=>`${N.value}\0${N.selectionStart}`,x=N=>{var I;if(!N){d(null),h(null);return}const g=w(N);if(m.current===g){d(null),h(null);return}m.current=null;const E=N.selectionStart,R=xn(N.value,E,n,l)||Ce(N.value,E,r,i);if(d(R),!R||!c){h(null);return}const y=N.getBoundingClientRect(),$=(I=N.closest(c))==null?void 0:I.getBoundingClientRect(),A=($==null?void 0:$.top)??y.top;h({left:`${y.left}px`,width:`${y.width}px`,right:"auto",bottom:`${Math.max(8,window.innerHeight-A+8)}px`})};p.useEffect(()=>{const N=e.current;i.length&&N&&document.activeElement===N&&x(N)},[i]);const f=N=>d(g=>g&&{...g,index:(g.index+N+g.items.length)%g.items.length}),b=N=>{if(!N||!u)return;m.current=null;const g=s.slice(0,u.start);if(u.kind==="actor"&&N.id==="new"){const y="@new:",$=g+y+s.slice(u.end),A=g.length+y.length;a($),d(Ce($,A,r,i)),requestAnimationFrame(()=>{const I=e.current;I&&(I.focus(),I.setSelectionRange(A,A))});return}const E=u.kind==="actor"?`@${N.id} `:u.kind==="launcher"?`@new:${N.id} `:`[[${N.id}]] `;a(g+E+s.slice(u.end)),d(null),h(null);const R=g.length+E.length;requestAnimationFrame(()=>{const y=e.current;y&&(y.focus(),y.setSelectionRange(R,R))})};return{menu:u,sync:x,onKeyDown:N=>u?N.key==="ArrowDown"?(N.preventDefault(),N.stopPropagation(),f(1),!0):N.key==="ArrowUp"?(N.preventDefault(),N.stopPropagation(),f(-1),!0):N.key==="Enter"||N.key==="Tab"?(N.preventDefault(),N.stopPropagation(),b(u.items[u.index]),!0):N.key==="Escape"?(N.preventDefault(),N.stopPropagation(),e.current&&(m.current=w(e.current)),d(null),h(null),!0):!1:!1,close:()=>{m.current=null,d(null),h(null)},menuEl:u?t.jsx(gn,{menu:u,up:o,fixedStyle:v,onPick:b,onHover:N=>d(g=>g&&{...g,index:N})}):null}}async function Lt(e,s){try{const a=await fetch(ve("/api/sessions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,...s?{launcher:s}:{}})}),n=await a.json().catch(()=>null);return{ok:a.ok,error:n==null?void 0:n.error}}catch{return{ok:!1}}}let _=null,X=null;const jn=()=>_?Promise.resolve(_):(X||(X=bs().then(e=>(_=e,e)).catch(e=>{throw X=null,e})),X),Ae=e=>Array.isArray(e==null?void 0:e.launchers)?e.launchers:[],yn=()=>{try{return localStorage.getItem("si.launcher")||""}catch{return""}},De=(e,s,a=yn())=>{var n;return e.some(r=>r.name===a)?a:s&&e.some(r=>r.name===s)?s:((n=e[0])==null?void 0:n.name)||a};function bn(){const e=Ae(_),[s,a]=p.useState(e),[n,r]=p.useState(()=>De(e,_==null?void 0:_.default)),i=l=>{r(l);try{localStorage.setItem("si.launcher",l)}catch{}};return p.useEffect(()=>{jn().then(l=>{const o=Ae(l);o.length&&(a(o),r(c=>De(o,l.default,c)))}).catch(()=>{})},[]),{launchers:s,launcher:n,pickLauncher:i}}function Ct(){const[e,s]=p.useState([]);return p.useEffect(()=>{ys().then(a=>{Array.isArray(a)&&s(a)}).catch(()=>{})},[]),e}function Nn(e,s,a=0){if(!e)return;const n=e.placeholder;!e.value&&n&&(e.placeholder=""),e.style.height="auto",e.style.overflowY=e.scrollHeight>s?"auto":"hidden",e.style.height=`${Math.min(Math.max(e.scrollHeight,a),s)}px`,e.placeholder!==n&&(e.placeholder=n)}function kn(e){var s,a;return e.isComposing||((s=e.nativeEvent)==null?void 0:s.isComposing)||e.keyCode===229||((a=e.nativeEvent)==null?void 0:a.keyCode)===229}const Sn=p.forwardRef(function({value:s,className:a="",...n},r){const i=p.useRef(null);return p.useImperativeHandle(r,()=>i.current),p.useLayoutEffect(()=>{const l=i.current;if(!l)return;const o=getComputedStyle(l);Nn(l,parseFloat(o.maxHeight)||1/0,parseFloat(o.minHeight)||0)},[s]),t.jsx("textarea",{ref:i,value:s,className:`composer-textarea ${a}`.trim(),...n})});function $n({className:e="",preview:s=null,editor:a,footer:n,...r}){return t.jsxs("div",{className:`composer-surface ${e}`.trim(),...r,children:[s,t.jsx("div",{className:"composer-editor",children:a}),t.jsx("div",{className:"composer-footer",children:n})]})}const En=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,Re=/^!\[frame\]\(\/api\/(?:evidence|yatsu\/blob)\/[0-9a-f]{64}\)\n?/,Ln=/\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})/g,Ie=/!\[[^\]]*\]\(\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})\)/g,Cn=e=>{const s=Math.floor(e/1e3);return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`};function pe(e){var i;const s=e||"",a=s.split(`
1
+ import{j as t,r as p,d as js,I as V,u as C,e as me,a as ve,f as ys,i as bs,k as Ns,s as xe}from"./index-D6HBvKkJ.js";import{P as ee}from"./PageScroll-CadAKuSy.js";function ze(e){let s=2166136261;for(let a=0;a<(e||"").length;a++)s^=e.charCodeAt(a),s=Math.imul(s,16777619);return s>>>0}function Ue(e){return ze(e)%360}function ks(e){const s=Ue(e);return{bg:`hsl(${s} 55% 42%)`,fg:`hsl(${s} 70% 92%)`}}function Ss(e){return`hsl(${Ue(e)} 65% 50%)`}const be=["◆","▲","●","■","★","✦","⬟","⬢","❖","◈","✸","⟡","✚","❂","◐","◑","⬣","▰","✶","⬤","✹","◇","⊛","✺"],Ne=["circle","rounded","square","hex"];function $s(e){const s=ze(e);return{seed:e,glyph:be[(s>>>9)%be.length],shape:Ne[(s>>>17)%Ne.length],...ks(e)}}function Es({seed:e,status:s,title:a,size:n=16}){const r=$s(e),i={width:n,height:n};return t.jsx("span",{className:`avatar av-st-${s||"none"}`,"data-tip":a,"aria-label":a,style:i,children:t.jsx("span",{className:`av-face av-gen av-${r.shape}`,style:{...i,background:r.bg,color:r.fg,fontSize:n*.62},children:r.glyph})})}const re=typeof window<"u"?window.__escStack||(window.__escStack=[]):[];typeof window<"u"&&!window.__escStackBound&&(window.__escStackBound=!0,window.addEventListener("keydown",e=>{const s=window.__escStack;e.key!=="Escape"||!s||s.length===0||(e.preventDefault(),e.stopImmediatePropagation(),s[s.length-1].close())},!0));function Be(e,s){const a=p.useRef(s);a.current=s,p.useEffect(()=>{if(!e)return;const n={close:()=>{var r;return(r=a.current)==null?void 0:r.call(a)}};return re.push(n),()=>{const r=re.indexOf(n);r>=0&&re.splice(r,1)}},[e])}const Ls="is:issue state:open",ae="is:eval",He=e=>W(ae,"scope",e),Cs=e=>W(ae,"node",e),We=/^([A-Za-z][A-Za-z0-9-]*):(.*)$/s,ke=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,Ge=e=>/\s/.test(String(e))?`"${e}"`:String(e);function ge(e){const s=String(e??""),a=[];let n=0;for(;n<s.length;){let r=n;if(/\s/.test(s[n])){for(;r<s.length&&/\s/.test(s[r]);)r++;a.push({ws:!0,raw:s.slice(n,r),start:n,end:r})}else{for(;r<s.length&&!/\s/.test(s[r]);)if(s[r]==='"'){for(r++;r<s.length&&s[r]!=='"';)r++;r<s.length&&r++}else r++;const i=s.slice(n,r),l=We.exec(i);a.push(l?{ws:!1,raw:i,start:n,end:r,key:l[1].toLowerCase(),value:ke(l[2])}:{ws:!1,raw:i,start:n,end:r,key:null,value:ke(i)})}n=r}return a}const we=e=>ge(e).filter(s=>!s.ws),Qe=e=>e.map(s=>s.raw).join(" "),Se=e=>Qe(we(e)),Ye=(e,s)=>Se(e)===Se(s),ft=(e,s)=>{const a=we(e);for(let n=a.length-1;n>=0;n--)if(a[n].key===s)return a[n].value;return""};function W(e,s,a){const n=a==null||String(a)===""?null:{ws:!1,raw:`${s}:${Ge(a)}`,key:s,value:String(a)},r=[];let i=!1;for(const l of we(e)){if(l.key===s){n&&!i&&(r.push(n),i=!0);continue}r.push(l)}return n&&!i&&r.push(n),Qe(r)}const As=(e,s)=>{const a=String(e??"").trim();return!a||Ye(a,s)?null:{q:a}},pt=(e,s,a=null)=>{const n=As(e,s)||{};return a!=null&&(n.page=String(a)),Object.keys(n).length?n:null},Ze={state:e=>["state",e],concluded:e=>e==="1"?["state","closed"]:null,ok:e=>e==="1"?["state","reviewed"]:null,verdict:e=>["verdict",e],freshness:e=>["freshness",e],kind:e=>e==="all"?null:["evidence",e],store:e=>["store",e],author:e=>["author",e],node:e=>["node",e],filer:e=>["filer",e],live:e=>e==="1"?["session","present"]:null,session:e=>["scope",e]},Je=e=>Object.keys(Ze).some(s=>(e==null?void 0:e[s])!=null&&e[s]!==""),Ds=e=>/[\s:"]/.test(e)?`"${e.replace(/"/g,"")}"`:e;function Rs(e,s){if(!Je(s))return null;let a=e;for(const[r,i]of Object.entries(Ze)){const l=s[r];if(l==null||l==="")continue;const o=i(String(l));o&&(a=W(a,o[0],o[1]))}const n=String(s.q??"").trim();return n&&(a=`${a} ${Ds(n)}`.trim()),a}function Is(e,s,a=[],n={}){const r=String(e??""),i=Math.max(0,Math.min(s??r.length,r.length)),l=ge(r).find(m=>!m.ws&&m.start<i&&i<=m.end);if(!l)return{start:i,end:i,items:[]};const o=r.slice(l.start,i),c=We.exec(o);if(!c){const m=o.toLowerCase();if(!m||m.includes('"'))return{start:l.start,end:l.end,items:[]};const w=a.filter(x=>x.startsWith(m)).slice(0,8).map(x=>({type:"key",key:x,insert:`${x}:`}));return{start:l.start,end:l.end,items:w}}const u=c[1].toLowerCase(),d=c[2].replace(/^"/,"").replace(/"$/,"").toLowerCase(),h=(n[u]||[]).filter(m=>String(m.value).toLowerCase().startsWith(d)&&String(m.value).toLowerCase()!==d).slice(0,8).map(m=>({type:"value",key:u,value:String(m.value),label:m.label||null,insert:`${u}:${Ge(m.value)} `}));return{start:l.start,end:l.end,items:h}}const Q=new Map;async function Ts(e){if(Q.has(e))return Q.get(e);const s=js(e).then(async a=>{const n=await a.json().catch(()=>null);if(!a.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${a.status}`);return n}).finally(()=>Q.delete(e));return Q.set(e,s),s}const mt=e=>{const s=typeof e=="string"&&/^\d+$/.test(e)?Number(e):Number.NaN;return Number.isSafeInteger(s)&&s>0?s:1};function Ps(e,s){return s<=0?[]:s<=10?Array.from({length:s},(a,n)=>n+1):e<=7?[...Array.from({length:8},(a,n)=>n+1),"gap",s-1,s]:e>=s-6||e>s?[1,2,"gap",...Array.from({length:8},(a,n)=>s-7+n)]:[1,2,"gap",e-2,e-1,e,e+1,e+2,"gap",s-1,s]}function Xe(e,s,a,{enabled:n=!0,refreshKey:r=null,pollMs:i=15e3,view:l=null}={}){const[o,c]=p.useState(null),[u,d]=p.useState(null),[v,h]=p.useState(n),m=p.useRef(0),w=p.useCallback(async({quiet:f=!1}={})=>{if(!n)return null;const b=++m.current;f||h(!0),d(null);const k=new URLSearchParams({q:String(s||""),page:String(a)});l&&k.set("view",l);try{const S=await Ts(`/api/${e}?${k}`);return b===m.current&&c(D=>D&&S&&D.revision===S.revision?D:S),S}catch(S){return b===m.current&&d(S instanceof Error?S.message:String(S)),null}finally{b===m.current&&h(!1)}},[e,n,a,s,l]),x=p.useRef(null);return p.useEffect(()=>{if(!n){h(!1);return}const f=`${e}\0${s}\0${a}\0${l||""}`,b=f!==x.current;x.current=f,b&&c(null),w({quiet:!b});const k=i>0?setInterval(()=>w({quiet:!0}),i):null;return()=>{k&&clearInterval(k)}},[e,s,a,l,n,w,i,r]),{data:o,error:u,loading:v,reload:w}}const $e={issue:{open:{icon:"issue-opened",tone:"open",label:"reviewState.issueOpen"},closed:{icon:"issue-closed",tone:"closed",label:"reviewState.issueClosed"}},eval:{pass:{icon:"circle-check",tone:"pass",label:"score.pass"},fail:{icon:"circle-x",tone:"fail",label:"score.fail"},stalePass:{icon:"circle-check",tone:"stale",label:"score.stalePass"},staleFail:{icon:"circle-x",tone:"stale",label:"score.staleFail"},review:{icon:"clock",tone:"review",label:"reviewList.needsReview"},empty:{icon:"circle-minus",tone:"empty",label:"score.empty"},missing:{icon:"circle-dashed",tone:"empty",label:"score.missing"},legacy:{icon:"circle-minus",tone:"empty",label:"score.empty"}}},Vs=(e,s)=>{var n;const a=e==="issue"?s==="open"?"open":"closed":s||"empty";return((n=$e[e])==null?void 0:n[a])||$e.eval.empty};function je({kind:e,state:s,showLabel:a=!1,size:n=16,className:r="",title:i}){const l=C(),o=Vs(e,s),c=i||l(o.label);return t.jsxs("span",{className:`review-state ${e} ${o.tone} ${r}`,"data-tip":c,"aria-label":c,children:[t.jsx("span",{className:"review-state-icon",style:{width:n,height:n},children:t.jsx(V,{name:o.icon,size:n})}),a&&t.jsx("span",{className:"review-state-label",children:c})]})}function Fs(e,s){const a={...e,...s};for(const[n,r]of Object.entries(a))(r==null||r==="")&&delete a[n];return a}const qs=e=>e&&typeof e=="object"?e.hasData?e.filtered:e.dataset:e,es=(e,s,a)=>{const n=Array.isArray(e)?e:[];return!(s!=null&&String(s)!=="")||a==null||n.some(i=>String(i.value)==="")?n:[{value:"",label:a},...n]},Ms=(e=[])=>e.reduce((s,a)=>((a.active??(a.value!=null&&String(a.value)!==""))&&(s.mobile+=1,a.mobileOnly||(s.desktop+=1)),s),{desktop:0,mobile:0}),ye=(e,s,a)=>s?a==="Home"?0:a==="End"?s-1:a==="ArrowDown"||a==="ArrowRight"?e<0?0:(e+1)%s:a==="ArrowUp"||a==="ArrowLeft"?e<0?s-1:(e-1+s)%s:e:-1,Ks=(e,s)=>{var n;const a=e==null?void 0:e.tagName;return a==="INPUT"||a==="TEXTAREA"||a==="SELECT"||a==="BUTTON"&&(s==="Enter"||s===" ")||s==="Enter"&&((n=e==null?void 0:e.closest)!=null&&n.call(e,"a[href]"))?!1:s==="j"||s==="k"||s==="Enter"},le=e=>[...(e==null?void 0:e.querySelectorAll('[role="menuitemradio"]'))||[]].filter(s=>s.getClientRects().length>0),ie=(e,s)=>{const a=e[s];if(a){for(const n of e)n.tabIndex=n===a?0:-1;a.focus()}};function ss(){const[e,s]=p.useState(!1),a=p.useRef(null),n=p.useRef(null),r=p.useRef(null),i=p.useRef("checked"),l=(h=!1)=>{var m;h&&((m=r.current)==null||m.focus()),s(!1)},o=(h,m="checked")=>{r.current=h,i.current=m,s(!0)},c=h=>{e?l(!1):o(h)};return Be(e,()=>l(!0)),p.useEffect(()=>{if(!e)return;const h=m=>{var w;(w=a.current)!=null&&w.contains(m.target)||l(!1)};return window.addEventListener("pointerdown",h,!0),()=>window.removeEventListener("pointerdown",h,!0)},[e]),p.useEffect(()=>{if(!e)return;const h=requestAnimationFrame(()=>{const m=le(n.current),w=m.findIndex(f=>f.getAttribute("aria-checked")==="true"),x=i.current==="last"?m.length-1:i.current==="first"?0:w>=0?w:0;ie(m,x)});return()=>cancelAnimationFrame(h)},[e]),{open:e,ref:a,menuRef:n,close:l,toggle:c,onTriggerKeyDown:h=>{h.key!=="ArrowDown"&&h.key!=="ArrowUp"||(h.preventDefault(),h.stopPropagation(),o(h.currentTarget,h.key==="ArrowUp"?"last":"first"))},onMenuKeyDown:h=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(h.key))return;const m=le(n.current),w=m.indexOf(document.activeElement);h.preventDefault(),h.stopPropagation(),ie(m,ye(w,m.length,h.key))},onItemFocus:h=>{const m=le(n.current);ie(m,m.indexOf(h.currentTarget))}}}function vt({label:e,value:s="",options:a=[],onChange:n,mobile:r=!1,clearLabel:i}){const l=ss(),o=es(a,s,i);if(!o.length)return null;const c=o.find(v=>String(v.value)===String(s)),u=s?(c==null?void 0:c.label)||String(s):"",d=u?`${e}: ${u}`:e;return t.jsxs("div",{className:`rl-facet-wrap ${r?"mobile-stay":""}`,ref:l.ref,children:[t.jsxs("button",{type:"button",className:`rl-facet ${s?"active":""}`,"aria-label":d,"aria-haspopup":"menu","aria-expanded":l.open,onClick:v=>l.toggle(v.currentTarget),onKeyDown:l.onTriggerKeyDown,children:[t.jsx("span",{className:"rl-facet-label",children:d}),r&&t.jsx("span",{className:"rl-facet-label-mobile","aria-hidden":"true",children:u||e}),t.jsx(V,{name:"chevron-down",size:12})]}),l.open&&t.jsx("div",{className:"rl-menu",role:"menu","aria-label":e,ref:l.menuRef,onKeyDown:l.onMenuKeyDown,children:o.map(v=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(v.value)===String(s),tabIndex:-1,className:"rl-menu-item",onFocus:l.onItemFocus,onClick:()=>{l.close(!0),n(v.value)},children:[t.jsx(V,{name:String(v.value)===String(s)?"check":"blank",size:13}),t.jsx("span",{children:v.label}),v.count!=null&&t.jsx("span",{className:"rl-menu-count",children:v.count})]},String(v.value)))})]})}function Os({label:e,groups:s=[],clearLabel:a,compact:n=!1,className:r=""}){const i=C(),l=p.useId(),o=s.map(h=>({...h,options:es(h.options,h.value,h.clearLabel===null?null:h.clearLabel||a)})).filter(h=>h.options.length),c=o.some(h=>!h.mobileOnly),u=Ms(o),d=ss();if(!o.length)return null;const v=(h,m)=>h>0&&t.jsxs("span",{className:`rl-secondary-filter-count ${m}`,children:[t.jsx("span",{"aria-hidden":"true",children:h}),t.jsx("span",{className:"sr-only",children:i("reviewList.activeFilters",{n:h})})]});return t.jsxs("div",{className:`rl-secondary-filters ${c?"":"mobile-only"} ${u.desktop?"active-desktop":""} ${u.mobile?"active-mobile":""} ${r}`,ref:d.ref,children:[n?t.jsx(me,{icon:"filter",size:16,className:"rl-secondary-filters-trigger compact",label:e,"aria-haspopup":"menu","aria-expanded":d.open,onClick:h=>d.toggle(h.currentTarget),onKeyDown:d.onTriggerKeyDown}):t.jsxs("button",{type:"button",className:"rl-secondary-filters-trigger","aria-haspopup":"menu","aria-expanded":d.open,onClick:h=>d.toggle(h.currentTarget),onKeyDown:d.onTriggerKeyDown,children:[t.jsx(V,{name:"filter",size:14}),t.jsx("span",{children:e}),v(u.desktop,"for-desktop"),v(u.mobile,"for-mobile"),t.jsx(V,{name:"chevron-down",size:12})]}),d.open&&t.jsx("div",{className:"rl-menu rl-secondary-filters-menu",role:"menu","aria-label":e,ref:d.menuRef,onKeyDown:d.onMenuKeyDown,children:o.map((h,m)=>t.jsxs("div",{role:"group","aria-labelledby":`${l}-group-${m}`,className:`rl-menu-group ${h.mobileOnly?"mobile-only":""}`,children:[t.jsx("div",{className:"rl-menu-label",id:`${l}-group-${m}`,children:h.label}),h.options.map(w=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(w.value)===String(h.value||""),tabIndex:-1,className:"rl-menu-item",onFocus:d.onItemFocus,onClick:()=>{d.close(!0),h.onChange(w.value)},children:[t.jsx(V,{name:String(w.value)===String(h.value||"")?"check":"blank",size:13}),t.jsx("span",{children:w.label}),w.count!=null&&t.jsx("span",{className:"rl-menu-count",children:w.count})]},String(w.value)))]},`${h.label}-${h.mobileOnly?"mobile":"all"}`))})]})}function xt({state:e,title:s,meta:a,aside:n}){return t.jsxs("div",{className:"rl-row-grid",children:[t.jsx("div",{className:"rl-row-state",children:e}),t.jsxs("div",{className:"rl-row-body",children:[t.jsx("div",{className:"rl-row-title",children:s}),a&&t.jsx("div",{className:"rl-row-meta",children:a})]}),n&&t.jsx("div",{className:"rl-row-aside",children:n})]})}const Y=e=>{const s=String(e??"").trim();return s?`${s} `:""};function _s({value:e="",onSubmit:s,placeholder:a,label:n,keys:r=[],suggest:i={}}){const[l,o]=p.useState(()=>Y(e)),[c,u]=p.useState(-1),[d,v]=p.useState(-1),h=p.useRef(null),m=p.useRef(null),w=p.useId(),x=p.useRef(null),f=g=>requestAnimationFrame(()=>{const E=h.current;E&&(g&&E.focus(),E.setSelectionRange(E.value.length,E.value.length))});p.useEffect(()=>{o(Y(e)),u(-1),v(-1),f(x.current!==null&&x.current!==e),x.current=e},[e]);const b=c>=0?Is(l,c,r,i):{start:0,end:0,items:[]},k=b.items.length>0;Be(k,()=>u(-1));const S=()=>{m.current&&h.current&&(m.current.scrollLeft=h.current.scrollLeft)};p.useEffect(S);const D=g=>{u(-1),v(-1);const E=g.trim();o(Y(E)||Y(e)),f(!0),s(E)},N=g=>{const E=`${l.slice(0,b.start)}${g.insert}${l.slice(b.end)}`;if(o(E),g.type==="value"){D(E);return}const R=b.start+g.insert.length;u(R),v(-1),requestAnimationFrame(()=>{var y,$;(y=h.current)==null||y.focus(),($=h.current)==null||$.setSelectionRange(R,R)})};return t.jsxs("form",{className:"rl-query rq",role:"search",onSubmit:g=>{g.preventDefault(),D(l)},children:[t.jsxs("div",{className:"rq-wrap",children:[t.jsx("div",{className:"rq-hl","aria-hidden":"true",ref:m,children:ge(l).map((g,E)=>g.ws||g.key==null||!r.includes(g.key)?t.jsx("span",{children:g.raw},E):t.jsxs("span",{className:"rq-tok",children:[t.jsx("span",{className:"rq-tok-key",children:g.raw.slice(0,g.key.length+1)}),t.jsx("span",{className:"rq-tok-val",children:g.raw.slice(g.key.length+1)})]},E))}),t.jsx("input",{ref:h,role:"combobox","aria-expanded":k,"aria-controls":w,"aria-autocomplete":"list","aria-activedescendant":k&&d>=0?`${w}-o${d}`:void 0,value:l,spellCheck:!1,autoComplete:"off",placeholder:a,"aria-label":n,onChange:g=>{o(g.target.value),u(g.target.selectionStart??g.target.value.length),v(-1)},onScroll:S,onKeyDown:g=>{k&&(g.key==="ArrowDown"||g.key==="ArrowUp"?(g.preventDefault(),v(ye(d,b.items.length,g.key))):g.key==="Enter"&&d>=0&&(g.preventDefault(),N(b.items[d])))},onBlur:()=>u(-1)})]}),k&&t.jsx("div",{className:"rl-menu rq-list",role:"listbox",id:w,"aria-label":n,children:b.items.map((g,E)=>t.jsxs("div",{id:`${w}-o${E}`,role:"option","aria-selected":E===d,className:`rq-opt ${E===d?"active":""}`,onPointerDown:R=>{R.preventDefault(),N(g)},children:[t.jsx("span",{className:"rq-opt-token",children:g.insert.trim()}),g.label&&g.label!==g.value&&t.jsx("span",{className:"rq-opt-label",children:g.label})]},g.insert))}),t.jsx("button",{type:"submit",className:"rl-query-submit","data-tip":n,"aria-label":n,children:t.jsx(V,{name:"search",size:16})})]})}function ns({value:e="",onChange:s,placeholder:a,searchLabel:n,filterLabel:r,groups:i,clearLabel:l,clearSearchLabel:o,summary:c}){const u=C(),d=t.jsxs("div",{className:"rf-compact",role:"search",children:[t.jsx("span",{className:"rf-search-icon",children:t.jsx(V,{name:"search",size:13})}),t.jsx("input",{value:e,onChange:h=>s(h.target.value),placeholder:a,"aria-label":n}),e&&t.jsx(me,{icon:"x",size:12,className:"rf-clear",label:o,onClick:()=>s("")}),t.jsx(Os,{label:r,clearLabel:l,groups:i,compact:!0,className:"rf-secondary-filters"})]});if(!c)return d;const v=u("reviewList.showing",{shown:c.shown,total:c.total});return t.jsxs("div",{className:"rf-row",children:[t.jsxs("span",{className:"rf-summary","data-tip":v,children:[t.jsx("span",{className:"sr-only",children:v}),t.jsx("span",{className:"rf-summary-full","aria-hidden":"true",children:v}),t.jsxs("span",{className:"rf-summary-compact","aria-hidden":"true",children:[c.shown,"/",c.total]})]}),d]})}function zs({page:e,pageCount:s,prev:a,next:n,hrefFor:r}){const i=C();if(s<=1&&e<=1)return null;const l=(o,c,u,d="")=>o==null?t.jsx("span",{className:`rl-page-link disabled ${d}`,"aria-disabled":"true",children:c}):t.jsx("a",{className:`rl-page-link ${d}`,href:r(o),rel:u,"aria-label":u?i(`reviewList.${u}Page`):i("reviewList.page",{n:o}),children:c});return t.jsxs("nav",{className:"rl-pagination","aria-label":i("reviewList.pagination"),children:[l(a,i("reviewList.previous"),"prev","direction"),Ps(e,s).map((o,c)=>o==="gap"?t.jsx("span",{className:"rl-page-gap","aria-hidden":"true",children:"…"},`gap-${c}`):t.jsx("a",{className:"rl-page-link number",href:r(o),"aria-label":i("reviewList.page",{n:o}),"aria-current":o===e?"page":void 0,children:o},o)),l(n,i("reviewList.next"),"next","direction")]})}function gt({notice:e,leading:s,error:a,loading:n=!1,title:r,action:i,search:l,sections:o=[],sectionMode:c="tabs",facets:u,secondaryFilters:d,rows:v,empty:h,pagination:m,children:w}){const x=C(),[f,b]=p.useState(null),k=p.useId(),S=p.useRef({});S.current={rows:v,cur:f},p.useEffect(()=>{const y=$=>{if($.metaKey||$.ctrlKey||$.altKey||!Ks($.target,$.key))return;const A=S.current.rows.filter(F=>F.href);if(!A.length)return;if($.key==="Enter"){const F=A.find(j=>j.key===S.current.cur);F&&($.preventDefault(),$.stopPropagation(),window.location.hash=F.href);return}$.preventDefault(),$.stopPropagation();const I=A.findIndex(F=>F.key===S.current.cur),U=I<0?$.key==="j"?0:A.length-1:Math.max(0,Math.min(A.length-1,I+($.key==="j"?1:-1)));b(A[U].key)};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[]),p.useEffect(()=>{var y;(y=document.querySelector(".lp-row.cur"))==null||y.scrollIntoView({block:"nearest"})},[f]);const D=qs(h),N=Math.max(0,o.findIndex(y=>y.active)),g=c==="tabs",E=`${k}-panel`,R=y=>`${k}-tab-${y}`;return t.jsxs(ee,{className:"lp-page",children:[e&&t.jsx("div",{className:"fv-notice",children:e}),s,t.jsxs("div",{className:"rl-content",children:[t.jsxs("div",{className:"rl-titlebar",children:[t.jsx("h1",{children:r}),i]}),l&&t.jsx(_s,{...l}),a&&t.jsx("div",{className:"fv-error lp-error",role:"alert",children:a}),t.jsxs("section",{className:"rl-list",children:[t.jsxs("header",{className:"lp-head",children:[t.jsx("div",{className:"rl-sections",role:g?"tablist":"group","aria-label":r,...g?{"aria-orientation":"horizontal"}:{},children:o.map((y,$)=>t.jsxs("button",{type:"button",role:g?"tab":void 0,"aria-selected":g?y.active:void 0,"aria-pressed":g?void 0:y.active,"aria-controls":g?E:void 0,id:g?R($):void 0,tabIndex:g?$===N?0:-1:void 0,className:`rl-section ${y.active?"active":""}`,onClick:y.onSelect,onKeyDown:A=>{var F,j;if(!g||!["ArrowLeft","ArrowRight","Home","End"].includes(A.key))return;const I=[...A.currentTarget.closest('[role="tablist"]').querySelectorAll('[role="tab"]')],U=ye(I.indexOf(A.currentTarget),I.length,A.key);A.preventDefault(),A.stopPropagation(),(F=I[U])==null||F.focus(),(j=I[U])==null||j.click()},children:[t.jsx("span",{children:y.label}),t.jsx("span",{className:"rl-section-count",children:y.count})]},y.key))}),t.jsxs("div",{className:"rl-facets",children:[u,d]})]}),t.jsxs("div",{className:"lp-rows",role:g?"tabpanel":"region",id:E,"aria-busy":n||void 0,"aria-labelledby":g?R(N):void 0,"aria-label":g?void 0:r,children:[v.length===0&&t.jsx("div",{className:"lp-empty",children:n?x("common.loading"):D}),v.map(y=>y.href?t.jsx("a",{className:`lp-row ${y.cls||""} ${f===y.key?"cur":""}`,href:y.href,children:y.content},y.key):t.jsx("div",{className:`lp-row inert ${y.cls||""}`,children:y.content},y.key))]})]}),m&&t.jsx(zs,{...m})]}),w]})}function wt({title:e,titleMeta:s,status:a,side:n,composer:r,missing:i,failure:l,listHref:o,listLabel:c,backHref:u,backLabel:d,children:v}){return l?t.jsxs(ee,{className:"ds-page ds-missing ds-failed",role:"alert",children:[t.jsx("div",{className:"ds-missing-note",children:l}),o&&t.jsx("a",{className:"ds-backlink",href:o,children:c})]}):i?t.jsxs(ee,{className:"ds-page ds-missing",children:[t.jsx("div",{className:"ds-missing-note",children:i}),o&&t.jsx("a",{className:"ds-backlink",href:o,children:c})]}):t.jsxs(ee,{className:"ds-page",children:[t.jsxs("header",{className:"ds-head",children:[u&&t.jsx("a",{className:"ds-back",href:u,"data-tip":d,"aria-label":d,children:t.jsx(V,{name:"arrow-left",size:16})}),t.jsxs("h1",{className:"ds-title",children:[e,s&&t.jsx("span",{className:"ds-title-meta",children:s})]})]}),a&&t.jsx("div",{className:"ds-status",children:a}),t.jsxs("div",{className:"ds-cols",children:[t.jsxs("div",{className:"ds-main",children:[v,r&&t.jsx("div",{className:"ds-compose",children:r})]}),t.jsx("aside",{className:"ds-side",children:n})]})]})}function jt({label:e,children:s}){return t.jsxs("div",{className:"ds-side-sec",children:[t.jsx("span",{className:"ds-side-label",children:e}),t.jsx("div",{className:"ds-side-body",children:s})]})}function Us({text:e,tip:s,dim:a=!1,mono:n=!1,href:r=null,external:i=!1,onClick:l=null,className:o="",lead:c=null,trail:u=null,label:d=null}){const v=`ds-val${a?" dim":""}${n?" mono":""}${r||l?" link":""}${o?` ${o}`:""}`,h=s??(typeof e=="string"?e:void 0),m=d?{"aria-label":d}:{},w=t.jsxs(t.Fragment,{children:[c,t.jsx("span",{className:"ds-val-text",children:e}),u]});return r?t.jsx("a",{className:v,href:r,"data-tip":h,...m,...i?{target:"_blank",rel:"noreferrer"}:{},children:w}):l?t.jsx("button",{type:"button",className:v,onClick:l,"data-tip":h,...m,children:w}):t.jsx("span",{className:v,"data-tip":h,children:w})}function Bs(e){var s,a;return((s=e==null?void 0:e.verdict)==null?void 0:s.status)==="pass"?"check":((a=e==null?void 0:e.verdict)==null?void 0:a.status)==="fail"?"cross":null}function ts(e){const s=Bs(e);return s?e.fresh?s==="cross"?"fail":"pass":s==="cross"?"staleFail":"stalePass":"empty"}function Hs(e,s){if(!e)return[];const a=new Map;for(const n of s||[])a.has(n.scenario)||a.set(n.scenario,n);return e.map(n=>{const r=a.get(n.name)||null;return{...n,reading:r,state:r?ts(r):"missing"}})}function Ws(e){return e.length?e.some(s=>s.state==="fail")?"fail":e.some(s=>s.state==="staleFail")?"staleFail":e.some(s=>s.state==="stalePass")?"stalePass":e.some(s=>s.state==="empty"||s.state==="missing")?"empty":"pass":null}const Gs=e=>e.fail>0?"fail":e.staleFail>0?"staleFail":e.stalePass>0?"stalePass":e.empty>0?"empty":"pass";function Qs({scenarios:e,evals:s,summary:a=null,href:n}){const r=C(),i=a?null:Hs(e,s),l=(a==null?void 0:a.total)??i.length;if(!l)return null;const o=a?Gs(a):Ws(i),c=(a==null?void 0:a.pass)??i.filter(h=>h.state==="pass").length,u=r("score.count",{satisfied:c,total:l,outstanding:l-c}),d=t.jsxs(t.Fragment,{children:[t.jsx(V,{name:"check",size:11}),c,"/",l]});if(!n)return t.jsx("span",{className:`scenario-count ${o}`,"data-tip":u,"aria-label":u,children:d});const v=`${u} — ${r("score.openList")}`;return t.jsx("a",{className:`scenario-count ${o}`,href:n,"data-tip":v,"aria-label":v,children:d})}function Z({kind:e,state:s,cls:a,n,label:r}){return t.jsxs("span",{className:`ovc ${a}`,"data-tip":r,children:[t.jsx(je,{kind:e,state:s,title:r,size:11}),n]})}function Ys({tags:e}){return e!=null&&e.length?t.jsx("span",{className:"tag-chips",children:e.map(s=>t.jsx("span",{className:"tag-chip",children:s},s))}):null}function as({state:e,title:s}){return e?t.jsx(je,{kind:"eval",state:e,title:s,className:`score-badge ${e}`,size:14}):null}const yt={merged:{color:"#859900"},active:{color:"#cb4b16"},drift:{color:"#b58900"},pending:{color:"#93a1a1"}},Zs={added:"+",edited:"~",deleted:"✕",moved:"→"},q={working:"var(--green)",parked:"var(--green)",asking:"var(--yellow)",review:"var(--yellow)",done:"var(--yellow)",error:"var(--red)",idle:"var(--muted)",starting:"var(--muted)",queued:"var(--muted)","close-pending":"var(--muted)",offline:"var(--muted)",unknown:"var(--yellow)"},Js={working:"●",parked:"‖",asking:"?",review:"◑",done:"✓",error:"✕",idle:"·",starting:"◌",queued:"⋯","close-pending":"⊘",offline:"○",unknown:"⁇"},rs=new Set(["asking","review","done","close-pending","error"]),ne=e=>(e==null?void 0:e.liveness)==="offline"||(e==null?void 0:e.status)==="offline"?"offline":rs.has(e==null?void 0:e.status)?"need":"run",Xs=(e,s)=>{const a=s?(e||[]).find(n=>n.id===s):null;return a&&ne(a)!=="offline"?a:null},Ee=e=>(e==null?void 0:e.sortKey)!=null?e.sortKey:(e==null?void 0:e.created)??0,Le=e=>{const s={need:0,run:1,offline:2};return[...e].sort((a,n)=>s[ne(a)]-s[ne(n)]||Ee(n)-Ee(a))},en=e=>(e==null?void 0:e.label)||(e==null?void 0:e.name)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id),ls=e=>(e==null?void 0:e.headline)||(e==null?void 0:e.name)||(e==null?void 0:e.activity)||(e==null?void 0:e.promptPreview)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id);function sn(e){const s=new Set(e.map(r=>r==null?void 0:r.id)),a=new Map,n=[];for(const r of e){const i=r!=null&&r.parent&&r.parent!==r.id&&s.has(r.parent)?r.parent:null;if(i){const l=a.get(i)||[];l.push(r),a.set(i,l)}else n.push(r)}return{roots:n,childrenOf:a}}function bt(e,s){const a=new Map(e.map(l=>[l==null?void 0:l.id,l])),n=[],r=new Set([s]);let i=a.get(s);for(;i!=null&&i.parent&&!r.has(i.parent);){const l=a.get(i.parent);if(!l)break;n.push(l.id),r.add(l.id),i=l}return n}function nn(e,s){let a=!1,n=!1,r=0;const i=(l,o)=>{for(const c of s.get(l)||[])o.has(c.id)||(o.add(c.id),r++,rs.has(c.status)?a=!0:q[c.status]===q.working&&(n=!0),i(c.id,o))};return i(e,new Set([e])),{color:a?q.asking:n?q.working:q.idle,count:r}}function tn(e,s){const{roots:a,childrenOf:n}=sn(e),r=[],i=(c,u,d,v)=>{const h=n.get(c.id)||[],m=h.length>0,w=m&&!!s(c.id),x=m?nn(c.id,n):null;if(r.push({type:"row",s:c,depth:u,expandable:m,expanded:w,rollup:(x==null?void 0:x.color)??null,kin:(x==null?void 0:x.count)??0,guides:v}),w){const f=Le(h).filter(b=>!d.has(b.id));f.forEach((b,k)=>{d.add(b.id),i(b,u+1,d,[...v,k<f.length-1])})}},l=new Set;let o=null;for(const c of Le(a)){if(l.has(c.id))continue;l.add(c.id);const u=ne(c);u!==o&&(r.push({type:"zone",zone:u}),o=u),i(c,0,l,[])}return r}const oe=Object.freeze({RESULT:"result",BLIND:"blind",UNMEASURED:"unmeasured",DANGLING:"dangling"}),is=e=>{var s;return(s=e==null?void 0:e.evidence)!=null&&s.length?e.evidence:(e==null?void 0:e.blob)!=null?[{hash:e.blob,kind:e.blobKind||"image",state:e.blobState||"present"}]:[]},Nt=e=>{const s=is(e);return s.length?["video","image","transcript","data"].filter(a=>s.some(n=>n.kind===a)):["note"]},kt=e=>String(e||"").length>22?`${String(e).slice(0,8)}…`:e;function os(e,s,a){return a.map(n=>n==="section"?e.section:e.facets[n]).filter(n=>{var r;return(n==null?void 0:n.meaningful)!==!1&&(((r=n==null?void 0:n.options)==null?void 0:r.length)>1||(n==null?void 0:n.value)!=null&&n.value!==""&&n.value!=="all")}).map(n=>({key:n.key,label:n.label,value:n.value,active:n.value!=null&&n.value!==""&&n.value!=="all",options:n.options,clearLabel:n.value==="all"?null:void 0,onChange:r=>s({[n.key]:r||null})}))}const B=e=>ve(`/api/evidence/${e}`);function an({src:e,alt:s,onClose:a}){return p.useEffect(()=>{const n=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation(),a())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[a]),t.jsx("div",{className:"lightbox",onClick:a,children:t.jsx("img",{src:e,alt:s})})}function rn({hash:e}){const s=C(),[a,n]=p.useState(null);return p.useEffect(()=>{let r=!0;return fetch(B(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{r&&n(i)}).catch(()=>{r&&n("")}),()=>{r=!1}},[e]),a===null?t.jsx("pre",{className:"eval-transcript loading",children:s("nodeView.eval.loadingTranscript")}):t.jsx("pre",{className:"eval-transcript",children:a})}function ln({hash:e,collapsed:s=!1}){const a=C(),[n,r]=p.useState(null);if(p.useEffect(()=>{let l=!0;return fetch(B(e)).then(o=>o.ok?o.text():Promise.reject(new Error("miss"))).then(o=>{let c=o,u=!0;try{c=JSON.stringify(JSON.parse(o),null,2)}catch{u=!1}l&&r({text:c,valid:u})}).catch(()=>{l&&r({text:"",valid:!1})}),()=>{l=!1}},[e]),n===null)return t.jsx("pre",{className:"eval-data loading",children:a("nodeView.eval.loadingData")});const i=n.valid?a("nodeView.eval.data"):a("nodeView.eval.dataInvalid");return s?t.jsxs("details",{className:"eval-datawrap eval-datafold",children:[t.jsx("summary",{className:"eval-datahead",children:i}),t.jsx("pre",{className:"eval-data",children:n.text})]}):t.jsxs("div",{className:"eval-datawrap",children:[t.jsx("div",{className:"eval-datahead",children:i}),t.jsx("pre",{className:"eval-data",children:n.text})]})}function on({hash:e,alt:s}){const[a,n]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("img",{className:"an-image",src:B(e),alt:s,loading:"lazy",onClick:()=>n(!0)}),a&&t.jsx(an,{src:B(e),alt:s,onClose:()=>n(!1)})]})}function cn({exit:e}){return t.jsx(V,{name:e?"minimize":"maximize",size:15})}function St({target:e,className:s=""}){const a=C(),[n,r]=p.useState(!1);p.useEffect(()=>{const l=()=>{const o=document.fullscreenElement,c=e==null?void 0:e.current;r(!!o&&!!c&&(o===c||c.contains(o)))};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[e]);const i=()=>{var o,c;const l=e==null?void 0:e.current;l&&(document.fullscreenElement?(o=document.exitFullscreen||document.webkitExitFullscreen)==null||o.call(document):(c=l.requestFullscreen||l.webkitRequestFullscreen)==null||c.call(l))};return t.jsx("button",{type:"button",className:`an-fs ${s}`,onClick:i,"data-tip":a(n?"annotator.exitFullscreen":"annotator.fullscreen"),"aria-label":a(n?"annotator.exitFullscreen":"annotator.fullscreen"),children:t.jsx(cn,{exit:n})})}function cs({e,alt:s="",collapsed:a=!1}){const n=C();return e.state==="miss"?t.jsx("div",{className:"eval-noimg",children:n("nodeView.eval.miss")}):e.kind==="transcript"?t.jsx(rn,{hash:e.hash}):e.kind==="data"?t.jsx(ln,{hash:e.hash,collapsed:a}):e.kind==="video"?t.jsx("video",{className:"eval-video",src:B(e.hash),controls:!0,preload:"metadata",playsInline:!0}):t.jsx(on,{hash:e.hash,alt:s})}const J=new Map;function un(e){const[s,a]=p.useState(()=>J.get(e)??null);return p.useEffect(()=>{if(J.has(e)){a(J.get(e));return}let n=!0;return fetch(B(e),{headers:{Range:"bytes=0-0"}}).then(r=>{const i=r.headers.get("content-type")||"",l=r.ok?{kind:i.startsWith("video/")?"video":i.startsWith("image/")?"image":i.startsWith("application/json")?"data":"transcript",state:"present"}:{kind:"image",state:"miss"};J.set(e,l),n&&a(l)}).catch(()=>{n&&a({kind:"image",state:"miss"})}),()=>{n=!1}},[e]),s}function us({hash:e,alt:s=""}){const a=un(e);return a?t.jsx(cs,{e:{hash:e,...a},alt:s}):null}const $t=/\[\[(\.?[\p{L}\p{N}_-]+)\]\]/gu,ds=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,"");function dn(e,s,a){const n=s.toLowerCase(),r=[];for(const i of e){const l=i.id.toLowerCase(),o=ds(i.path).toLowerCase();let c;if(!n)c=3;else if(l.startsWith(n))c=0;else if(l.includes(n))c=1;else if(o.includes(n))c=2;else continue;i.id===a&&(c=-1),r.push({s:i,score:c})}return r.sort((i,l)=>i.score-l.score||i.s.id.length-l.s.id.length||i.s.id.localeCompare(l.s.id)),r.slice(0,8).map(i=>i.s)}function hn(e,s){const a=s.toLowerCase(),n=o=>ls(o)||(o.id||"").slice(0,8),r=[];for(const o of e||[]){if(o.liveness!=="online")continue;const c=(o.id||"").toLowerCase(),u=n(o).toLowerCase();let d;if(!a)d=3;else if(c===a||u===a)d=0;else if(c.startsWith(a)||u.startsWith(a))d=1;else if(c.includes(a)||u.includes(a))d=2;else continue;r.push({s:o,score:d})}r.sort((o,c)=>o.score-c.score||(c.s.created||0)-(o.s.created||0));const i=r.map(o=>({id:o.s.id,label:n(o.s),sub:o.s.node||o.s.status})),l=r.filter(o=>o.score===0).length;return i.splice(l,0,{id:"new",label:"new",sub:"choose a launcher"}),i.slice(0,8)}function fn(e,s){const a=s.toLowerCase();return(e||[]).map(n=>{const r=(n.name||"").toLowerCase(),i=a?r.startsWith(a)?0:r.includes(a)?1:-1:1;return{l:n,score:i}}).filter(n=>n.score>=0).sort((n,r)=>n.score-r.score||n.l.name.localeCompare(r.l.name)).slice(0,8).map(({l:n})=>({id:n.name,label:n.name,sub:n.cmd||n.harness||""}))}function se(e,s){if(!s)return e;const a=e.toLowerCase().indexOf(s.toLowerCase());return a<0?e:t.jsxs(t.Fragment,{children:[e.slice(0,a),t.jsx("b",{className:"mention-hit",children:e.slice(a,a+s.length)}),e.slice(a+s.length)]})}function hs(e,s){const a=s.toLowerCase(),n=[];for(const r of e){const i=r.name.toLowerCase();let l;if(!a)l=1;else if(i.startsWith(a))l=0;else if(i.includes(a))l=1;else continue;n.push({c:r,score:l})}return n.sort((r,i)=>r.score-i.score),n.slice(0,10).map(r=>r.c)}function Et(e,s,a){let n=s;for(;n>0&&!/\s/.test(e[n-1]);)n--;if(e[n]!=="/")return null;const r=e.slice(n+1,s),i=hs(a,r);return i.length?{items:i,index:0,start:n,end:s,query:r}:null}const pn=e=>e&&e[0].toUpperCase()+e.slice(1),mn={user:"(user)",project:"(project)",skill:"[skill]","built-in":"built-in",ui:"[ui]",preset:"[preset]",review:"[review]"};function vn({menu:e,up:s,head:a,onPick:n,onHover:r}){const i=C();return t.jsxs("ul",{className:s?"mention-menu up":"mention-menu",role:"listbox",children:[t.jsxs("li",{className:"mention-head",children:["// ",a," — ",i("session.menuHint")]}),e.items.map((l,o)=>{const c=l.ui?"ui":l.source??l.kind,u=l.ui?` sc-${l.color}`:"";return t.jsxs("li",{role:"option","aria-selected":o===e.index,className:`${o===e.index?"mention-item on":"mention-item"}${u}`,onMouseDown:d=>{d.preventDefault(),n(l)},onMouseEnter:()=>r(o),children:[t.jsxs("span",{className:l.ui?"slash-name ui":"slash-name",children:["/",se(l.name,e.query)]}),t.jsx("span",{className:"slash-desc",children:pn(l.description??l.desc)}),t.jsx("span",{className:`slash-src src-${c}`,children:mn[c]||c})]},`${c}:${l.name}`)})]})}function xn(e,s,a,n){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.\-]/u.test(e[r]);)r--;if(r>=1&&e[r-1]==="["&&e[r]==="["){const i=e.slice(r+1,s),l=dn(a,i,n);return l.length?{kind:"mention",items:l,index:0,start:r-1,end:s,query:i}:null}return null}function Ce(e,s,a,n=[]){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.:\-]/u.test(e[r]);)r--;if(r>=0&&e[r]==="@"&&(r===0||/\s/.test(e[r-1]))){const i=e.slice(r+1,s);if(i.startsWith("new:")){const o=i.slice(4),c=fn(n,o);return c.length?{kind:"launcher",items:c,index:0,start:r,end:s,query:o}:null}const l=hn(a,i);return l.length?{kind:"actor",items:l,index:0,start:r,end:s,query:i}:null}return null}function gn({menu:e,up:s,fixedStyle:a,onPick:n,onHover:r}){const i=C(),l=e.kind==="launcher",o=e.kind==="actor"||l,c=l?`@new:${e.query}`:e.query?o?`@${e.query}`:`[[${e.query}]]`:i(o?"session.menuSessions":"session.menuSpecNodes");return t.jsxs("ul",{className:`${s?"mention-menu up":"mention-menu"}${a?" fixed":""}`,style:a||void 0,role:"listbox",children:[t.jsxs("li",{className:"mention-head",children:["// ",c," — ",i("session.menuHint")]}),e.items.map((u,d)=>t.jsxs("li",{role:"option","aria-selected":d===e.index,className:`${d===e.index?"mention-item on":"mention-item"}${l||o&&u.id==="new"?" new":""}`,onMouseDown:v=>{v.preventDefault(),n(u)},onMouseEnter:()=>r(d),children:[!o&&t.jsx("span",{className:"mention-dot",style:{background:q[u.status]||q.offline}}),t.jsx("span",{className:"mention-id",children:l?t.jsxs(t.Fragment,{children:["@new:",se(u.label,e.query)]}):o?t.jsxs(t.Fragment,{children:["@",se(u.label,e.query)]}):se(u.id,e.query)}),t.jsx("span",{className:"mention-path",children:o?u.sub:ds(u.path)})]},u.id))]})}function wn({inputRef:e,value:s,setValue:a,specs:n=[],sessions:r=[],launchers:i=[],focusId:l=null,up:o=!1,fixedAbove:c=null}){const[u,d]=p.useState(null),[v,h]=p.useState(null),m=p.useRef(null),w=N=>`${N.value}\0${N.selectionStart}`,x=N=>{var I;if(!N){d(null),h(null);return}const g=w(N);if(m.current===g){d(null),h(null);return}m.current=null;const E=N.selectionStart,R=xn(N.value,E,n,l)||Ce(N.value,E,r,i);if(d(R),!R||!c){h(null);return}const y=N.getBoundingClientRect(),$=(I=N.closest(c))==null?void 0:I.getBoundingClientRect(),A=($==null?void 0:$.top)??y.top;h({left:`${y.left}px`,width:`${y.width}px`,right:"auto",bottom:`${Math.max(8,window.innerHeight-A+8)}px`})};p.useEffect(()=>{const N=e.current;i.length&&N&&document.activeElement===N&&x(N)},[i]);const f=N=>d(g=>g&&{...g,index:(g.index+N+g.items.length)%g.items.length}),b=N=>{if(!N||!u)return;m.current=null;const g=s.slice(0,u.start);if(u.kind==="actor"&&N.id==="new"){const y="@new:",$=g+y+s.slice(u.end),A=g.length+y.length;a($),d(Ce($,A,r,i)),requestAnimationFrame(()=>{const I=e.current;I&&(I.focus(),I.setSelectionRange(A,A))});return}const E=u.kind==="actor"?`@${N.id} `:u.kind==="launcher"?`@new:${N.id} `:`[[${N.id}]] `;a(g+E+s.slice(u.end)),d(null),h(null);const R=g.length+E.length;requestAnimationFrame(()=>{const y=e.current;y&&(y.focus(),y.setSelectionRange(R,R))})};return{menu:u,sync:x,onKeyDown:N=>u?N.key==="ArrowDown"?(N.preventDefault(),N.stopPropagation(),f(1),!0):N.key==="ArrowUp"?(N.preventDefault(),N.stopPropagation(),f(-1),!0):N.key==="Enter"||N.key==="Tab"?(N.preventDefault(),N.stopPropagation(),b(u.items[u.index]),!0):N.key==="Escape"?(N.preventDefault(),N.stopPropagation(),e.current&&(m.current=w(e.current)),d(null),h(null),!0):!1:!1,close:()=>{m.current=null,d(null),h(null)},menuEl:u?t.jsx(gn,{menu:u,up:o,fixedStyle:v,onPick:b,onHover:N=>d(g=>g&&{...g,index:N})}):null}}async function Lt(e,s){try{const a=await fetch(ve("/api/sessions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,...s?{launcher:s}:{}})}),n=await a.json().catch(()=>null);return{ok:a.ok,error:n==null?void 0:n.error}}catch{return{ok:!1}}}let _=null,X=null;const jn=()=>_?Promise.resolve(_):(X||(X=bs().then(e=>(_=e,e)).catch(e=>{throw X=null,e})),X),Ae=e=>Array.isArray(e==null?void 0:e.launchers)?e.launchers:[],yn=()=>{try{return localStorage.getItem("si.launcher")||""}catch{return""}},De=(e,s,a=yn())=>{var n;return e.some(r=>r.name===a)?a:s&&e.some(r=>r.name===s)?s:((n=e[0])==null?void 0:n.name)||a};function bn(){const e=Ae(_),[s,a]=p.useState(e),[n,r]=p.useState(()=>De(e,_==null?void 0:_.default)),i=l=>{r(l);try{localStorage.setItem("si.launcher",l)}catch{}};return p.useEffect(()=>{jn().then(l=>{const o=Ae(l);o.length&&(a(o),r(c=>De(o,l.default,c)))}).catch(()=>{})},[]),{launchers:s,launcher:n,pickLauncher:i}}function Ct(){const[e,s]=p.useState([]);return p.useEffect(()=>{ys().then(a=>{Array.isArray(a)&&s(a)}).catch(()=>{})},[]),e}function Nn(e,s,a=0){if(!e)return;const n=e.placeholder;!e.value&&n&&(e.placeholder=""),e.style.height="auto",e.style.overflowY=e.scrollHeight>s?"auto":"hidden",e.style.height=`${Math.min(Math.max(e.scrollHeight,a),s)}px`,e.placeholder!==n&&(e.placeholder=n)}function kn(e){var s,a;return e.isComposing||((s=e.nativeEvent)==null?void 0:s.isComposing)||e.keyCode===229||((a=e.nativeEvent)==null?void 0:a.keyCode)===229}const Sn=p.forwardRef(function({value:s,className:a="",...n},r){const i=p.useRef(null);return p.useImperativeHandle(r,()=>i.current),p.useLayoutEffect(()=>{const l=i.current;if(!l)return;const o=getComputedStyle(l);Nn(l,parseFloat(o.maxHeight)||1/0,parseFloat(o.minHeight)||0)},[s]),t.jsx("textarea",{ref:i,value:s,className:`composer-textarea ${a}`.trim(),...n})});function $n({className:e="",preview:s=null,editor:a,footer:n,...r}){return t.jsxs("div",{className:`composer-surface ${e}`.trim(),...r,children:[s,t.jsx("div",{className:"composer-editor",children:a}),t.jsx("div",{className:"composer-footer",children:n})]})}const En=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,Re=/^!\[frame\]\(\/api\/(?:evidence|yatsu\/blob)\/[0-9a-f]{64}\)\n?/,Ln=/\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})/g,Ie=/!\[[^\]]*\]\(\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})\)/g,Cn=e=>{const s=Math.floor(e/1e3);return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`};function pe(e){var i;const s=e||"",a=s.split(`
2
2
  `,1)[0],n=En.exec(a);return n?{tMs:(parseInt(n[1],10)*60+parseInt(n[2],10))*1e3,step:((i=n[3])==null?void 0:i.trim())||null,label:a.trim(),rest:s.slice(a.length).replace(/^\n/,"")}:null}const fs=(e,s)=>`▶${Cn(e)}${s?` · ${s}`:""}`,Te=e=>[...(e||"").matchAll(Ln)].map(s=>s[1]);function An(e,s){if(!e)return null;if(e.step&&(s!=null&&s.length)){const a=s.find(n=>n.step===e.step);return a?{tMs:a.at,step:e.step,label:fs(a.at,e.step),seekable:!0,degraded:!1}:{tMs:e.tMs,step:e.step,label:e.label,seekable:!1,degraded:!0}}return{tMs:e.tMs,step:e.step,label:e.label,seekable:!0,degraded:!1}}function At({originator:e,sessions:s=[],kind:a="issue",onOpenSession:n=null}){const r=C();if(!e)return null;const i=Xs(s,e),l=!!i,o=l?q[i.status]||q.working:q.offline,c=r(a==="eval"?"thread.originatorEval":"thread.originatorIssue",{by:e}),u=t.jsx("span",{className:"fv-originator-dot",style:{background:o},"aria-hidden":"true"});return t.jsx(Us,{text:e,tip:c,label:c,lead:u,className:`fv-originator ${l?"alive":"offline"}${l&&n?" openable":""}`,onClick:l&&n?()=>n(e):null})}function Dn({replies:e,onSeek:s,selIdx:a=null,activeIdx:n=null,onSelect:r=null,events:i=null,threadId:l=null,onRemarkChange:o=null}){const c=C(),[u,d]=p.useState(null),[v,h]=p.useState(null),m=async(w,x)=>{if(!u){d(x),h(null);try{const f=await Ns(w,x);f!=null&&f.ok?await(o==null?void 0:o()):h({ref:x,msg:(f==null?void 0:f.error)||`${w} failed`})}finally{d(null)}}};return e.map((w,x)=>{const f=pe(w.body),b=An(f,i),k=f?f.rest:w.body,S=[...k.matchAll(Ie)].map($=>$[1]),D=(S.length?k.replace(Ie,""):k).trim(),N=w.rid!==void 0,g=N?w.resolved?" remark resolved":" remark open":"",E=`fv-reply${a===x?" sel":""}${n===x?" active":""}${g}`,R=b&&b.seekable&&s?()=>r?r(x,b.tMs):s(b.tMs):null,y=N&&l?`${l}#${w.rid}`:null;return t.jsxs("div",{className:E,children:[t.jsxs("div",{className:"fv-reply-meta",children:[t.jsx("span",{className:"fv-reply-by",children:w.by}),w.at&&t.jsx("span",{className:"fv-reply-at",children:w.at}),b&&(R?t.jsx("button",{type:"button",className:"fv-anchor",onClick:R,"data-tip":"seek the clip to this moment",children:b.label}):t.jsxs("span",{className:`fv-anchor static${b.degraded?" degraded":""}`,"data-tip":b.degraded?c("thread.anchorDegraded"):void 0,children:[b.label,b.degraded?" ⚠":""]})),N&&(w.resolved?t.jsxs("span",{className:"fv-remark-state resolved","data-tip":w.resolvedBy?c("thread.resolvedBy",{by:w.resolvedBy}):c("thread.resolved"),children:["✓ ",c("thread.resolved")]}):t.jsxs("span",{className:"fv-remark-state open","data-tip":c("thread.openRemark"),children:["● ",c("thread.openRemark")]})),y&&o&&!w.resolved&&(w.by==="human"?t.jsx("button",{type:"button",className:"fv-remark-act retract",disabled:!!u,"data-tip":c("thread.retractTitle"),onClick:()=>m("retract",y),children:c("thread.retract")}):t.jsx("button",{type:"button",className:"fv-remark-act resolve",disabled:!!u,"data-tip":c("thread.resolveTitle"),onClick:()=>m("resolve",y),children:c("thread.resolve")}))]}),v&&v.ref===y&&t.jsx("div",{className:"fv-error",children:v.msg}),D&&t.jsx("div",{className:"fvd-body",children:t.jsx(te,{body:D})}),S.length>0&&t.jsx("div",{className:"fv-reply-media",children:S.map(($,A)=>t.jsx(us,{hash:$,alt:"evidence"},`${$}-${A}`))})]},x)})}function Rn(e,s,a){const n=e.lastIndexOf(`
3
3
  `,s-1)+1,r=/^\/(\S*)$/.exec(e.slice(n,s));if(!r)return null;const i=hs(a,r[1]);return i.length?{items:i,index:0,start:n,end:s,query:r[1]}:null}function Dt({onSend:e,specs:s=[],sessions:a=[],focusId:n=null,onDone:r,anchorNow:i=null,draft:l=null,actionsEnd:o=null,commands:c=null}){const u=C(),[d,v]=p.useState(""),[h,m]=p.useState(!1),[w,x]=p.useState(""),f=p.useRef(null),{launchers:b}=bn(),k=wn({inputRef:f,value:d,setValue:v,specs:s,sessions:a,launchers:b,focusId:n,up:!0}),[S,D]=p.useState(null),N=j=>D(j&&(c!=null&&c.length)?Rn(j.value,j.selectionStart,c):null),g=j=>{var O;if(!j||!S)return;const L=d.slice(0,S.start)+d.slice(S.end);if(D(null),j.run){v(L.trim()?L:""),j.run();return}const M=pe(L);let K="";if(M){const T=((O=Re.exec(M.rest))==null?void 0:O[0])??"";K=`${M.label}
4
4
  ${T}`,K.endsWith(`
@@ -1 +1 @@
1
- import{a5 as x,r as o,j as e,a6 as N}from"./index-BKaTHjmU.js";import{A as j,k as b,a as T,i as f,r as S,s as k}from"./bindings-BC9vqpYU.js";import{P as v}from"./PageScroll-B_dKCuXx.js";import{g as E,T as y,a as C,b as A,c as F}from"./terminalFont-DmTPNdbU.js";const h="spexcode.theme",g=[{code:"minimal",label:"Minimal"},{code:"things",label:"Things"},{code:"tokyonight",label:"Tokyo Night"},{code:"catppuccin",label:"Catppuccin"},{code:"everforest",label:"Everforest"},{code:"gruvbox",label:"Gruvbox"},{code:"rosepine",label:"Rosé Pine Dawn"},{code:"dracula",label:"Dracula"}],u=new Set(g.map(s=>s.code)),p="minimal";function w(){try{const s=localStorage.getItem(h);if(u.has(s))return s}catch{}return p}function L(s){const i=u.has(s)?s:p;try{document.documentElement.setAttribute("data-theme",i)}catch{}try{localStorage.setItem(h,i)}catch{}return i}function M({t:s}){const[i,d]=o.useState(0),[c,l]=o.useState(null),r=()=>d(n=>n+1);return o.useEffect(()=>{if(!c)return;const n=a=>{if(a.preventDefault(),a.stopPropagation(),a.key==="Escape"){l(null);return}["Shift","Control","Alt","Meta"].includes(a.key)||(k(c,{keys:[a.key]}),l(null),r())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c]),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secShortcuts")}),e.jsx("div",{className:"set-keys",children:j.map(n=>e.jsxs("div",{className:"set-key-row",children:[e.jsx("span",{className:"legend-desc",children:s(n.desc)}),e.jsx("button",{className:`bind-cell${c===n.id?" capturing":""}${n.rebind?"":" fixed"}${f(n.id)?" custom":""}`,disabled:!n.rebind,onClick:()=>n.rebind&&l(n.id),children:c===n.id?e.jsx("span",{className:"bind-hint",children:s("settings.bindPrompt")}):b(n.id).map((a,m)=>e.jsx("kbd",{children:T(a)},m))})]},n.id))}),e.jsxs("div",{className:"set-foot",children:[e.jsx("span",{className:"legend-desc set-hint",children:s("settings.shortcutsHint")}),e.jsx("button",{className:"set-reset",onClick:()=>{S(),l(null),r()},children:s("settings.reset")})]})]})}function D(){const{t:s,lang:i,setLang:d}=x(),[c,l]=o.useState(w),[r,n]=o.useState(E),a=t=>{L(t),l(t)},m=t=>n(F(t));return e.jsx(v,{className:"page-settings-scroll",children:e.jsxs("div",{className:"settings-body",children:[e.jsx("h1",{className:"page-title",children:s("settings.title")}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secLanguage")}),e.jsx("div",{className:"set-langs",children:N.map(t=>e.jsx("button",{className:t.code===i?"set-lang on":"set-lang",onClick:()=>d(t.code),"aria-pressed":t.code===i,children:t.label},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTheme")}),e.jsx("div",{className:"set-langs",children:g.map(t=>e.jsx("button",{className:t.code===c?"set-lang on":"set-lang",onClick:()=>a(t.code),"aria-pressed":t.code===c,children:s(t.label)},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTerminal")}),e.jsxs("label",{className:"set-terminal-font",children:[e.jsx("span",{children:s("settings.terminalFontSize")}),e.jsx("input",{type:"range",min:A,max:C,step:y,value:r,onChange:t=>m(t.target.value)}),e.jsxs("output",{children:[r,"px"]})]})]}),e.jsx(M,{t:s})]})})}export{D as default};
1
+ import{a6 as x,r as o,j as e,a7 as N}from"./index-D6HBvKkJ.js";import{A as j,k as b,a as T,i as f,r as S,s as k}from"./bindings-BC9vqpYU.js";import{P as v}from"./PageScroll-CadAKuSy.js";import{g as E,T as y,a as C,b as A,c as F}from"./terminalFont-DmTPNdbU.js";const h="spexcode.theme",g=[{code:"minimal",label:"Minimal"},{code:"things",label:"Things"},{code:"tokyonight",label:"Tokyo Night"},{code:"catppuccin",label:"Catppuccin"},{code:"everforest",label:"Everforest"},{code:"gruvbox",label:"Gruvbox"},{code:"rosepine",label:"Rosé Pine Dawn"},{code:"dracula",label:"Dracula"}],u=new Set(g.map(s=>s.code)),p="minimal";function w(){try{const s=localStorage.getItem(h);if(u.has(s))return s}catch{}return p}function L(s){const i=u.has(s)?s:p;try{document.documentElement.setAttribute("data-theme",i)}catch{}try{localStorage.setItem(h,i)}catch{}return i}function M({t:s}){const[i,d]=o.useState(0),[c,l]=o.useState(null),r=()=>d(n=>n+1);return o.useEffect(()=>{if(!c)return;const n=a=>{if(a.preventDefault(),a.stopPropagation(),a.key==="Escape"){l(null);return}["Shift","Control","Alt","Meta"].includes(a.key)||(k(c,{keys:[a.key]}),l(null),r())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c]),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secShortcuts")}),e.jsx("div",{className:"set-keys",children:j.map(n=>e.jsxs("div",{className:"set-key-row",children:[e.jsx("span",{className:"legend-desc",children:s(n.desc)}),e.jsx("button",{className:`bind-cell${c===n.id?" capturing":""}${n.rebind?"":" fixed"}${f(n.id)?" custom":""}`,disabled:!n.rebind,onClick:()=>n.rebind&&l(n.id),children:c===n.id?e.jsx("span",{className:"bind-hint",children:s("settings.bindPrompt")}):b(n.id).map((a,m)=>e.jsx("kbd",{children:T(a)},m))})]},n.id))}),e.jsxs("div",{className:"set-foot",children:[e.jsx("span",{className:"legend-desc set-hint",children:s("settings.shortcutsHint")}),e.jsx("button",{className:"set-reset",onClick:()=>{S(),l(null),r()},children:s("settings.reset")})]})]})}function D(){const{t:s,lang:i,setLang:d}=x(),[c,l]=o.useState(w),[r,n]=o.useState(E),a=t=>{L(t),l(t)},m=t=>n(F(t));return e.jsx(v,{className:"page-settings-scroll",children:e.jsxs("div",{className:"settings-body",children:[e.jsx("h1",{className:"page-title",children:s("settings.title")}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secLanguage")}),e.jsx("div",{className:"set-langs",children:N.map(t=>e.jsx("button",{className:t.code===i?"set-lang on":"set-lang",onClick:()=>d(t.code),"aria-pressed":t.code===i,children:t.label},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTheme")}),e.jsx("div",{className:"set-langs",children:g.map(t=>e.jsx("button",{className:t.code===c?"set-lang on":"set-lang",onClick:()=>a(t.code),"aria-pressed":t.code===c,children:s(t.label)},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTerminal")}),e.jsxs("label",{className:"set-terminal-font",children:[e.jsx("span",{children:s("settings.terminalFontSize")}),e.jsx("input",{type:"range",min:A,max:C,step:y,value:r,onChange:t=>m(t.target.value)}),e.jsxs("output",{children:[r,"px"]})]})]}),e.jsx(M,{t:s})]})})}export{D as default};
@@ -1 +1 @@
1
- import{u as L,r as i,N as F,Q as U,j as s,I as k,S as _,T as I,U as J}from"./index-BKaTHjmU.js";import{b as w,c as D,s as K}from"./SessionWindow-BuJ5mzjC.js";const ee=e=>{var n;return((n=e==null?void 0:e.capabilities)==null?void 0:n.headless)===!0},Y=e=>{var n;return((n=e==null?void 0:e.capabilities)==null?void 0:n.messageStream)===!0},q=["command","file_path","path","pattern","query","description","prompt","url"];function H(e,n=180){const o=typeof e=="string"?e:JSON.stringify(e);if(!o)return"";const r=o.replace(/\s+/g," ").trim();return r.length>n?`${r.slice(0,n-1)}…`:r}function G(e){if(!e||typeof e!="object")return"";for(const n of q)if(e[n]!=null)return H(e[n]);return H(e)}function Q(e){const n=e==null?void 0:e.event;if(!n||typeof n!="object")return[];const o=n.message&&typeof n.message=="object"?n.message:n,r=o.role||n.role||n.type;if(r!=="user"&&r!=="assistant")return[];const m=o.content,f=typeof m=="string"?[{type:"text",text:m}]:Array.isArray(m)?m:[],d=[];for(const[u,c]of f.entries())!c||typeof c!="object"||(c.type==="text"&&typeof c.text=="string"&&c.text.trim()?d.push({key:`${e.cursor}:${u}`,kind:r,text:c.text}):r==="assistant"&&c.type==="tool_use"&&d.push({key:`${e.cursor}:${u}`,kind:"tool",name:typeof c.name=="string"&&c.name?c.name:"tool",summary:G(c.input)}));return d}function V(e){return(e||[]).flatMap(Q)}function B({sessionId:e,active:n}){const o=L(),[r,m]=i.useState(null),[f,d]=i.useState("loading"),u=i.useRef(null),c=i.useRef(!0),g=i.useMemo(()=>V(r),[r]);i.useEffect(()=>{if(!n)return;let l=!1,v=()=>{};return d("loading"),F(e).then(N=>{l||(m(N.messages),d("connecting"),v=U(e,N.cursor,{onMessage:x=>m(j=>{const h=j||[];return h.length&&x.cursor<=h[h.length-1].cursor?h:[...h,x]}),onStatus:x=>d(j=>x?"live":j==="error"?j:"disconnected"),onError:()=>d("error")}))}).catch(()=>{l||(m([]),d("error"))}),()=>{l=!0,v()}},[n,e]);const b=()=>{const l=u.current;l&&(c.current=l.scrollHeight-l.scrollTop-l.clientHeight<48)};return i.useEffect(()=>{const l=u.current;l&&c.current&&(l.scrollTop=l.scrollHeight)},[r]),s.jsxs("div",{className:"ms-console",children:[s.jsx("div",{className:"ms-scroll",ref:u,onScroll:b,"aria-live":"polite",children:r===null?s.jsx("div",{className:"ms-empty",children:o("session.messagesLoading")}):g.length===0?s.jsx("div",{className:"ms-empty",children:o("session.messagesEmpty")}):g.map(l=>l.kind==="tool"?s.jsxs("div",{className:"ms-tool",title:l.summary||l.name,children:[s.jsx(k,{name:"terminal",size:13}),s.jsx("span",{className:"ms-tool-name",children:l.name}),l.summary&&s.jsx("code",{className:"ms-tool-summary",children:l.summary})]},l.key):s.jsxs("div",{className:`ms-turn ${l.kind}`,children:[s.jsx("span",{className:"ms-role",children:o(l.kind==="user"?"session.messagesYou":"session.messagesAssistant")}),s.jsx("div",{className:"ms-bubble",children:l.text})]},l.key))}),(f==="disconnected"||f==="error")&&s.jsx("div",{className:`ms-state ${f}`,role:"status",children:o(f==="error"?"session.messagesUnavailable":"session.messagesDisconnected")})]})}const R=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),M=e=>new Date(e).toLocaleDateString([],{month:"short",day:"numeric"}),C=e=>new Date(e).toDateString(),W=(e,n)=>e!=null&&e.length===n.length&&(e.length===0||JSON.stringify(e[e.length-1])===JSON.stringify(n[n.length-1]));function se({s:e,sessions:n=[],active:o=!0}){const r=L(),m=Y(e),[f,d]=i.useState(null),[u,c]=i.useState(null),[g,b]=i.useState(""),[l,v]=i.useState(!1),[N,x]=i.useState(null),[j,h]=i.useState(!1),E=i.useRef(null),T=i.useRef(!0),p=i.useCallback(()=>_(e.id).then(t=>{t&&d(a=>W(a,t.events)?a:t.events)}),[e.id]);i.useEffect(()=>{d(null),c(null),T.current=!0,p(),I(e.id).then(t=>{t&&c(t)})},[e.id,p]),i.useEffect(()=>{h(!1)},[e.id,m]),i.useEffect(()=>{const t=setInterval(p,8e3);return()=>clearInterval(t)},[p]),i.useEffect(()=>{p()},[e.status,e.note,p]);const O=()=>{const t=E.current;t&&(T.current=t.scrollHeight-t.scrollTop-t.clientHeight<48)};i.useEffect(()=>{const t=E.current;t&&T.current&&(t.scrollTop=t.scrollHeight)},[f]);const P=async()=>{const t=g.trim();if(!t||l)return;v(!0),x(null);const a=await J(e.id,t,{replyVia:"note"});v(!1),a.ok?(b(""),p()):x(a.error||r("mobile.sendFailed"))},A=t=>{if(!t)return r("mobile.you");const a=n.find(y=>y.id===t);return a?K(a):t.slice(0,8)},S=[];let $=null;for(const[t,a]of(f||[]).entries())if(C(a.ts)!==$&&($=C(a.ts),S.push(s.jsx("div",{className:"m-day",children:M(a.ts)},`d${t}`))),a.kind==="status"){const y=a.display||a.status;S.push(s.jsxs("div",{className:"m-ev",children:[s.jsxs("div",{className:"m-ev-head",children:[s.jsx("span",{className:"m-ev-glyph",style:{color:D[y]},children:w[y]||"·"}),s.jsx("span",{className:"m-ev-word",style:{color:D[y]},children:r(`status.${y}`)}),s.jsx("span",{className:"m-ev-time",children:R(a.ts)})]}),a.note&&s.jsx("div",{className:"m-ev-note",children:a.note})]},t))}else S.push(s.jsxs("div",{className:"m-ev m-ev-sent",children:[s.jsxs("div",{className:"m-ev-head",children:[s.jsx("span",{className:"m-ev-from",children:A(a.from)}),s.jsx("span",{className:"m-ev-time",children:R(a.ts)})]}),s.jsx("div",{className:"m-ev-text",children:a.text})]},t));const z=e.liveness==="offline"||e.status==="offline";return j&&m?s.jsxs("div",{className:"tl-process",children:[s.jsxs("header",{className:"tl-process-head",children:[s.jsxs("button",{type:"button",className:"tl-process-back",onClick:()=>h(!1),children:[s.jsx(k,{name:"arrow-left",size:14}),s.jsx("span",{children:r("session.backToConversation")})]}),s.jsx("span",{className:"tl-process-title",children:r("session.fullProcess")})]}),s.jsx(B,{sessionId:e.id,active:o})]}):s.jsxs("div",{className:"tl-chat",children:[m&&s.jsx("div",{className:"tl-chat-tools",children:s.jsxs("button",{type:"button",className:"tl-process-door",onClick:()=>h(!0),children:[s.jsx(k,{name:"list-checks",size:14}),s.jsx("span",{children:r("session.fullProcess")}),s.jsx(k,{name:"chevron-right",size:13})]})}),s.jsxs("div",{className:"m-timeline",ref:E,onScroll:O,children:[(u==null?void 0:u.prompt)&&s.jsxs("details",{className:"m-ev m-ev-prompt",children:[s.jsxs("summary",{children:[r("mobile.asked"),e.created?` · ${M(e.created)} ${R(e.created)}`:""]}),s.jsx("div",{className:"m-ev-text",children:u.prompt})]}),f===null?s.jsx("div",{className:"m-empty",children:r("common.loading")}):S.length===0?s.jsx("div",{className:"m-empty",children:r("mobile.noEvents")}):S]}),z&&s.jsx("div",{className:"m-offline",children:r("mobile.offlineHint")}),N&&s.jsx("div",{className:"m-senderr",children:N}),s.jsx("div",{className:"m-composer",children:s.jsxs("div",{className:"m-composer-line",children:[s.jsx("textarea",{className:"m-input",rows:1,placeholder:r("mobile.inputPlaceholder"),value:g,onChange:t=>b(t.target.value)}),s.jsx("button",{className:"m-send",disabled:!g.trim()||l,onClick:P,children:r("mobile.send")})]})})]})}export{se as T,ee as i};
1
+ import{u as L,r as i,Q as F,S as U,j as s,I as k,T as _,U as I,V as J}from"./index-D6HBvKkJ.js";import{b as w,c as D,s as K}from"./SessionWindow-BWH5O0jh.js";const ee=e=>{var n;return((n=e==null?void 0:e.capabilities)==null?void 0:n.headless)===!0},V=e=>{var n;return((n=e==null?void 0:e.capabilities)==null?void 0:n.messageStream)===!0},Y=["command","file_path","path","pattern","query","description","prompt","url"];function H(e,n=180){const o=typeof e=="string"?e:JSON.stringify(e);if(!o)return"";const r=o.replace(/\s+/g," ").trim();return r.length>n?`${r.slice(0,n-1)}…`:r}function q(e){if(!e||typeof e!="object")return"";for(const n of Y)if(e[n]!=null)return H(e[n]);return H(e)}function G(e){const n=e==null?void 0:e.event;if(!n||typeof n!="object")return[];const o=n.message&&typeof n.message=="object"?n.message:n,r=o.role||n.role||n.type;if(r!=="user"&&r!=="assistant")return[];const m=o.content,f=typeof m=="string"?[{type:"text",text:m}]:Array.isArray(m)?m:[],d=[];for(const[u,c]of f.entries())!c||typeof c!="object"||(c.type==="text"&&typeof c.text=="string"&&c.text.trim()?d.push({key:`${e.cursor}:${u}`,kind:r,text:c.text}):r==="assistant"&&c.type==="tool_use"&&d.push({key:`${e.cursor}:${u}`,kind:"tool",name:typeof c.name=="string"&&c.name?c.name:"tool",summary:q(c.input)}));return d}function Q(e){return(e||[]).flatMap(G)}function B({sessionId:e,active:n}){const o=L(),[r,m]=i.useState(null),[f,d]=i.useState("loading"),u=i.useRef(null),c=i.useRef(!0),g=i.useMemo(()=>Q(r),[r]);i.useEffect(()=>{if(!n)return;let l=!1,v=()=>{};return d("loading"),F(e).then(N=>{l||(m(N.messages),d("connecting"),v=U(e,N.cursor,{onMessage:x=>m(j=>{const h=j||[];return h.length&&x.cursor<=h[h.length-1].cursor?h:[...h,x]}),onStatus:x=>d(j=>x?"live":j==="error"?j:"disconnected"),onError:()=>d("error")}))}).catch(()=>{l||(m([]),d("error"))}),()=>{l=!0,v()}},[n,e]);const b=()=>{const l=u.current;l&&(c.current=l.scrollHeight-l.scrollTop-l.clientHeight<48)};return i.useEffect(()=>{const l=u.current;l&&c.current&&(l.scrollTop=l.scrollHeight)},[r]),s.jsxs("div",{className:"ms-console",children:[s.jsx("div",{className:"ms-scroll",ref:u,onScroll:b,"aria-live":"polite",children:r===null?s.jsx("div",{className:"ms-empty",children:o("session.messagesLoading")}):g.length===0?s.jsx("div",{className:"ms-empty",children:o("session.messagesEmpty")}):g.map(l=>l.kind==="tool"?s.jsxs("div",{className:"ms-tool",title:l.summary||l.name,children:[s.jsx(k,{name:"terminal",size:13}),s.jsx("span",{className:"ms-tool-name",children:l.name}),l.summary&&s.jsx("code",{className:"ms-tool-summary",children:l.summary})]},l.key):s.jsxs("div",{className:`ms-turn ${l.kind}`,children:[s.jsx("span",{className:"ms-role",children:o(l.kind==="user"?"session.messagesYou":"session.messagesAssistant")}),s.jsx("div",{className:"ms-bubble",children:l.text})]},l.key))}),(f==="disconnected"||f==="error")&&s.jsx("div",{className:`ms-state ${f}`,role:"status",children:o(f==="error"?"session.messagesUnavailable":"session.messagesDisconnected")})]})}const R=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),M=e=>new Date(e).toLocaleDateString([],{month:"short",day:"numeric"}),C=e=>new Date(e).toDateString(),W=(e,n)=>e!=null&&e.length===n.length&&(e.length===0||JSON.stringify(e[e.length-1])===JSON.stringify(n[n.length-1]));function se({s:e,sessions:n=[],active:o=!0}){const r=L(),m=V(e),[f,d]=i.useState(null),[u,c]=i.useState(null),[g,b]=i.useState(""),[l,v]=i.useState(!1),[N,x]=i.useState(null),[j,h]=i.useState(!1),E=i.useRef(null),T=i.useRef(!0),p=i.useCallback(()=>_(e.id).then(t=>{t&&d(a=>W(a,t.events)?a:t.events)}),[e.id]);i.useEffect(()=>{d(null),c(null),T.current=!0,p(),I(e.id).then(t=>{t&&c(t)})},[e.id,p]),i.useEffect(()=>{h(!1)},[e.id,m]),i.useEffect(()=>{const t=setInterval(p,8e3);return()=>clearInterval(t)},[p]),i.useEffect(()=>{p()},[e.status,e.note,p]);const O=()=>{const t=E.current;t&&(T.current=t.scrollHeight-t.scrollTop-t.clientHeight<48)};i.useEffect(()=>{const t=E.current;t&&T.current&&(t.scrollTop=t.scrollHeight)},[f]);const P=async()=>{const t=g.trim();if(!t||l)return;v(!0),x(null);const a=await J(e.id,t,{replyVia:"note"});v(!1),a.ok?(b(""),p()):x(a.error||r("mobile.sendFailed"))},A=t=>{if(!t)return r("mobile.you");const a=n.find(y=>y.id===t);return a?K(a):t.slice(0,8)},S=[];let $=null;for(const[t,a]of(f||[]).entries())if(C(a.ts)!==$&&($=C(a.ts),S.push(s.jsx("div",{className:"m-day",children:M(a.ts)},`d${t}`))),a.kind==="status"){const y=a.display||a.status;S.push(s.jsxs("div",{className:"m-ev",children:[s.jsxs("div",{className:"m-ev-head",children:[s.jsx("span",{className:"m-ev-glyph",style:{color:D[y]},children:w[y]||"·"}),s.jsx("span",{className:"m-ev-word",style:{color:D[y]},children:r(`status.${y}`)}),s.jsx("span",{className:"m-ev-time",children:R(a.ts)})]}),a.note&&s.jsx("div",{className:"m-ev-note",children:a.note})]},t))}else S.push(s.jsxs("div",{className:"m-ev m-ev-sent",children:[s.jsxs("div",{className:"m-ev-head",children:[s.jsx("span",{className:"m-ev-from",children:A(a.from)}),s.jsx("span",{className:"m-ev-time",children:R(a.ts)})]}),s.jsx("div",{className:"m-ev-text",children:a.text})]},t));const z=e.liveness==="offline"||e.status==="offline";return j&&m?s.jsxs("div",{className:"tl-process",children:[s.jsxs("header",{className:"tl-process-head",children:[s.jsxs("button",{type:"button",className:"tl-process-back",onClick:()=>h(!1),children:[s.jsx(k,{name:"arrow-left",size:14}),s.jsx("span",{children:r("session.backToConversation")})]}),s.jsx("span",{className:"tl-process-title",children:r("session.fullProcess")})]}),s.jsx(B,{sessionId:e.id,active:o})]}):s.jsxs("div",{className:"tl-chat",children:[m&&s.jsx("div",{className:"tl-chat-tools",children:s.jsxs("button",{type:"button",className:"tl-process-door",onClick:()=>h(!0),children:[s.jsx(k,{name:"list-checks",size:14}),s.jsx("span",{children:r("session.fullProcess")}),s.jsx(k,{name:"chevron-right",size:13})]})}),s.jsxs("div",{className:"m-timeline",ref:E,onScroll:O,children:[(u==null?void 0:u.prompt)&&s.jsxs("details",{className:"m-ev m-ev-prompt",children:[s.jsxs("summary",{children:[r("mobile.asked"),e.created?` · ${M(e.created)} ${R(e.created)}`:""]}),s.jsx("div",{className:"m-ev-text",children:u.prompt})]}),f===null?s.jsx("div",{className:"m-empty",children:r("common.loading")}):S.length===0?s.jsx("div",{className:"m-empty",children:r("mobile.noEvents")}):S]}),z&&s.jsx("div",{className:"m-offline",children:r("mobile.offlineHint")}),N&&s.jsx("div",{className:"m-senderr",children:N}),s.jsx("div",{className:"m-composer",children:s.jsxs("div",{className:"m-composer-line",children:[s.jsx("textarea",{className:"m-input",rows:1,placeholder:r("mobile.inputPlaceholder"),value:g,onChange:t=>b(t.target.value)}),s.jsx("button",{className:"m-send",disabled:!g.trim()||l,onClick:P,children:r("mobile.send")})]})})]})}export{se as T,ee as i};