ompchamber 0.8.0 → 1.0.0

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 (79) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/static/css/{index.5c0447cefe.css → index.e880517fcd.css} +1 -1
  3. package/dist/client/static/js/async/g.a06ca3b3e9.js +2 -0
  4. package/dist/client/static/js/async/{m.0896dab823.js → m.c038c71b9f.js} +2 -2
  5. package/dist/client/static/js/async/ms.98960af4eb.js +67 -0
  6. package/dist/client/static/js/async/ms.98960af4eb.js.LICENSE.txt +12 -0
  7. package/dist/client/static/js/async/ot.84c71b308f.js +2 -0
  8. package/dist/client/static/js/async/{x4.69ec69c61b.js.LICENSE.txt → ot.84c71b308f.js.LICENSE.txt} +5 -0
  9. package/dist/client/static/js/{index.dc5f5fabe8.js → index.0de15c5e17.js} +10 -10
  10. package/package.json +2 -1
  11. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -1
  12. package/src/client/components/layout/session-sidebar/SessionItem.tsx +1 -1
  13. package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
  14. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -1
  15. package/src/client/components/mobile/mobile-session-sidebar/List.tsx +1 -1
  16. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +2 -2
  17. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +11 -4
  18. package/src/client/components/workspace/chat-timeline/QueueList.tsx +18 -14
  19. package/src/client/components/workspace/chat-timeline/index.tsx +4 -2
  20. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
  21. package/src/client/components/workspace/git-panel/index.tsx +5 -1
  22. package/src/client/components/workspace/terminal-panel/Header.tsx +51 -19
  23. package/src/client/components/workspace/terminal-panel/RealtimeXtermView.tsx +86 -282
  24. package/src/client/components/workspace/terminal-panel/index.tsx +76 -50
  25. package/src/client/components/workspace/terminal-panel/mount.ts +275 -0
  26. package/src/client/data/theme/terminal.ts +27 -29
  27. package/src/client/hooks/chat/omp/session-list.tsx +19 -2
  28. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +1 -1
  29. package/src/client/hooks/chat/timeline/actions.ts +23 -25
  30. package/src/client/hooks/chat/timeline/index.ts +12 -20
  31. package/src/client/hooks/chat/timeline/queue.ts +110 -46
  32. package/src/client/hooks/workspace/terminal/index.ts +217 -0
  33. package/src/client/hooks/workspace/terminal/socket.ts +227 -0
  34. package/src/server/db.server.ts +19 -0
  35. package/src/server/lib/fs/git-sync.ts +191 -0
  36. package/src/server/lib/omp/rpc/manager.ts +58 -3
  37. package/src/server/lib/omp/rpc/session-commands.ts +6 -0
  38. package/src/server/lib/omp/session/sidebar-data.server.ts +3 -3
  39. package/src/server/lib/queue/delivery.server.ts +114 -0
  40. package/src/server/lib/queue/schema-migration.server.ts +50 -0
  41. package/src/server/lib/queue/store.server.ts +185 -0
  42. package/src/server/lib/terminal/foreground.ts +73 -0
  43. package/src/server/lib/terminal/history.test.ts +118 -0
  44. package/src/server/lib/terminal/history.ts +205 -0
  45. package/src/server/lib/terminal/runtime.server.ts +338 -0
  46. package/src/server/lib/terminal/session.server.ts +215 -0
  47. package/src/server/lib/terminal/shell.test.ts +97 -0
  48. package/src/server/lib/terminal/shell.ts +103 -0
  49. package/src/server/routes/fs/git.ts +22 -12
  50. package/src/server/routes/index.ts +2 -1
  51. package/src/server/routes/sessions/index.ts +11 -3
  52. package/src/server/routes/sessions/queue.ts +121 -0
  53. package/src/server/routes/sessions/session.ts +1 -132
  54. package/src/server/routes/settings/commands.ts +1 -1
  55. package/src/server/routes/terminal/index.ts +2 -2
  56. package/src/server/routes/terminal/run.ts +8 -100
  57. package/src/server/routes/terminal/sessions.ts +24 -0
  58. package/src/server/routes/terminal/ws.ts +149 -0
  59. package/src/shared/lib/chat/omp/agent-events.test.ts +37 -1
  60. package/src/shared/lib/chat/omp/agent-events.ts +30 -0
  61. package/src/shared/lib/chat/timeline/omp-callbacks.test.ts +9 -1
  62. package/src/shared/lib/chat/timeline/omp-callbacks.ts +45 -8
  63. package/src/shared/lib/omp/session/stream-state.server.ts +2 -3
  64. package/src/shared/lib/workspace/session-state/store.ts +1 -4
  65. package/src/shared/lib/workspace/terminal/protocol.ts +222 -0
  66. package/src/shared/types/omp/agent.ts +12 -0
  67. package/src/shared/types/terminal.ts +17 -15
  68. package/src/shared/types/workspace.ts +2 -2
  69. package/dist/client/static/js/async/g.d1c2fe09aa.js +0 -2
  70. package/dist/client/static/js/async/x4.69ec69c61b.js +0 -6
  71. package/src/client/components/workspace/terminal-panel/InputBar.tsx +0 -82
  72. package/src/client/components/workspace/terminal-panel/LogEntry.tsx +0 -70
  73. package/src/client/hooks/workspace/terminal-output.ts +0 -66
  74. package/src/client/hooks/workspace/terminal.ts +0 -283
  75. package/src/server/lib/fs/terminal-cwd.ts +0 -49
  76. package/src/server/routes/terminal/stream.ts +0 -100
  77. /package/dist/client/static/js/async/{g.d1c2fe09aa.js.LICENSE.txt → g.a06ca3b3e9.js.LICENSE.txt} +0 -0
  78. /package/dist/client/static/js/async/{m.0896dab823.js.LICENSE.txt → m.c038c71b9f.js.LICENSE.txt} +0 -0
  79. /package/dist/client/static/js/{index.dc5f5fabe8.js.LICENSE.txt → index.0de15c5e17.js.LICENSE.txt} +0 -0
@@ -1,13 +1,13 @@
1
- /*! LICENSE: index.dc5f5fabe8.js.LICENSE.txt */
1
+ /*! LICENSE: index.0de15c5e17.js.LICENSE.txt */
2
2
  (()=>{"use strict";var e,t,n,r,i,s={vp(e,t,n){n.d(t,{T:()=>H});var r=n("j"),i=n("H"),s=n("XT7"),a=n("HA"),l=n("rt"),o=n("DU"),c=n("L");let d=["math","annotation","annotation-xml","semantics","mrow","mi","mn","mo","mspace","ms","mtext","mroot","mfrac","msqrt","mstyle","merror","mpadded","mphantom","mtable","mtr","mtd","mlabeledtr","munder","mover","munderover","msup","msub","msubsup","mtext","mtd","menclose"],u=["svg","path","polyline","rect","circle","line"],p=["viewBox","d","points","x","y","x1","y1","x2","y2","width","height","rx","ry","cx","cy","r","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","xmlns","aria-hidden","aria-label"],m=["svg","g","line","path","rect","circle","ellipse","polygon","polyline","text","tspan","title","desc","marker","defs","style","use","symbol","foreignObject","html","head","body","div","span","p","br","img"],h=["id","class","style","transform","viewBox","width","height","xmlns","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","d","points","fill","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","fill-opacity","opacity","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","text-decoration","direction","marker-end","marker-start","marker-mid","markerWidth","markerHeight","refX","refY","orient","markerUnits","preserveAspectRatio","version","dx","dy","dy1","dy2","rowspan","colspan","start","aria-roledescription","aria-describedby","role","aria-hidden","aria-label","data-mermaid-theme","overflow","visibility","rel","src","alt"],f=["href","xlink:href"],x=null,g="math-pending";function b(){return x||(x=n.e(121).then(n.bind(n,"Bi")).then(e=>e.default).catch(e=>(console.error("[katex] load failed",e),null))),x}async function v(e){let t=[...e.querySelectorAll(`.${g}`)];if(0===t.length)return{rendered:0,failed:0};let n=await b();if(!n)return{rendered:0,failed:t.length};let r=0;for(let e of t)e.isConnected&&(!function(e,t){let n=e.dataset.math??"",r="1"===e.dataset.mathDisplay;try{e.innerHTML=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=`<div data-katex-wrap>${e}</div>`;try{let e=c.A.sanitize(t,{USE_PROFILES:{html:!0,mathMl:!0},ADD_ATTR:["class","aria-hidden","encoding","style","data-katex-wrap"]}),n=document.createElement("div");return n.innerHTML=e,n.querySelector("[data-katex-wrap]")?.innerHTML??e}catch{return e}}(t.renderToString(n,{throwOnError:!1,displayMode:r})),e.classList.remove(g),e.removeAttribute("data-math"),e.removeAttribute("data-math-display")}catch{e.textContent=n,e.classList.remove(g)}}(e,n),r+=1);return{rendered:r,failed:0}}function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function y(e,t){let n=k(e),r=`<span class="${g}" data-math="${n}"${t?' data-math-display="1"':""}></span>`;return t?`<p>${r}</p>`:r}let w=new s.Dz({gfm:!0,breaks:!0});function N(e,t){let n=e.replace(/"/g,"&quot;");return`<div class="code-block">
3
3
  <button type="button" class="code-copy-float" data-copy="${n}" aria-label="Copy code">
4
4
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
5
5
  </button>
6
6
  ${t}
7
7
  </div>
8
- `}w.use((0,a.A)()),w.use({renderer:{code:e=>e.raw&&/^```/.test(e.raw)||(e.text??"").includes("\n")?function(e){let t=e.lang?.trim()||"text",n=e.text??"";if("mermaid"===t){let e,t;return e=`<pre><code class="language-mermaid">${k(n)}</code></pre>`,t=N(n,e),`<div class="mermaid-block" data-mermaid="${encodeURIComponent(n)}" data-mermaid-state="pending">${t}</div>`}let r="text"===t?k(n):(0,o.wY)(n,t);return N(n,`<pre><code class="language-${t}">${r}</code></pre>`)}(e):`<code class="inline-code">${k(e.text??"")}</code>`,codespan:e=>`<code class="inline-code">${k(e.text??"")}</code>`}}),w.use({extensions:[{name:"inlineMath",level:"inline",start:e=>e.match(/\\\(/)?.index,tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);return t?{type:"inlineMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)},{name:"blockMath",level:"block",start:e=>e.match(/^\\\[/)?.index,tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);return t?{type:"blockMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"blockMathDisplay",level:"block",start:e=>e.match(/^\$\$/)?.index,tokenizer(e){let t=/^\$\$([\s\S]+?)\$\$(?:\n|$)/.exec(e);return t?{type:"blockMathDisplay",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"inlineMathDollar",level:"inline",start(e){let t=/(^|[^\w$])\$(?!\$)(?!\s)/.exec(e);return t?t.index+(t[1]?.length??0):void 0},tokenizer(e){let t=/^\$(?!\$)(?!\s)((?:\\\$|[^$])*?)(?<!\s)\$(?!\$)(?!\d)/.exec(e);return t?{type:"inlineMathDollar",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)}]});let Y=/\[([^\]]*)\]\(streamdown:incomplete-link\)/g,D=new Map,F=null,A=null;function C(){let e=document.documentElement.dataset.theme||document.documentElement.getAttribute("data-theme");return"one-dark-pro-soft"===e||"noir"===e||"dark"===e?"dark":"default"}function S(e,t){return`${e}\0${t}`}async function T(e){return F&&A===e||(A=e,F=Promise.all([n.e("a3"),n.e("3y")]).then(n.bind(n,"Fl")).then(t=>(t.default.initialize({startOnLoad:!1,securityLevel:"strict",theme:e,layout:"dagre",suppressErrorRendering:!0,flowchart:{useMaxWidth:!1,wrappingWidth:1e5},sequence:{useMaxWidth:!1}}),t.default)).catch(e=>{throw F=null,e})),F}function z(e,t,n){let r=(e.dataset.mermaid??"").replace(/"/g,"&quot;");e.innerHTML=`<button type="button" class="code-copy-float" data-copy="${r}" aria-label="Copy diagram source" title="Copy diagram source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button>`+t,e.dataset.mermaidState="done",e.dataset.mermaidTheme=n;let i=e.querySelector(":scope > svg"),s=Number(i?.getAttribute("width"));i&&Number.isFinite(s)&&s>0&&e.style.setProperty("--mermaid-diagram-max",`${Math.round(.8*s)}px`)}let $=0;async function j(e,t){let n=e.dataset.mermaid;if(null==n)return!1;let r=C(),i=decodeURIComponent(n),s=D.get(S(r,i))??null;if(s)return z(e,s,r),!0;if(t)return!0;e.dataset.mermaidState="rendering";try{let t=await T(r),{svg:n}=await t.render(`mermaid-svg-${Date.now()}-${$++}`,i);if(!e.isConnected)return!1;let s=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=/href/.test(e);try{return c.A.sanitize(e,{USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},ADD_TAGS:m,ADD_ATTR:[...h,...t?f:[]],HTML_INTEGRATION_POINTS:{"annotation-xml":!0,foreignobject:!0}})}catch{return e}}(n);if(D.size>=60){let e=D.keys().next().value;void 0!==e&&D.delete(e)}return D.set(S(r,i),s),z(e,s,r),!0}catch{return e.isConnected&&(e.dataset.mermaidState="error"),!1}}async function L(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=C(),r=Array.from(e.querySelectorAll(".mermaid-block")),i=await Promise.all(r.map(async e=>{let r=e.dataset.mermaidState,i=e.dataset.mermaidTheme===n;return"done"===r&&!!i&&!t.force||"rendering"!==r&&j(e,!0===t.cachedOnly)}));return{rendered:i.filter(Boolean).length,failed:i.filter(e=>!e).length}}var M=n("pH"),P=n("Po"),E=n("G"),R=n("DV"),I=n("r"),O=n("C"),J=n("S");let _=e=>Math.min(8,Math.max(.1,e));function W(e){let{svg:t,width:n,height:s,onClose:a}=e,l=(0,i.li)(null),o=(0,i.li)(null),[c,d]=(0,i.J0)({scale:1,x:0,y:0}),[u,p]=(0,i.J0)(1),[m,h]=(0,i.J0)(!1),f=(0,i.hb)(()=>{let e=l.current?.getBoundingClientRect();return e?_(Math.min(1,(e.width-112)/n,(e.height-112)/s)):1},[n,s]),x=(0,i.hb)(()=>{let e=f();p(e),d({scale:e,x:0,y:0})},[f]);(0,i.Nf)(()=>{x()},[x]),(0,i.vJ)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus()},[]);let g=(0,i.hb)((e,t,n)=>{d(r=>{let i=l.current?.getBoundingClientRect(),s=t??(i?i.left+i.width/2:0),a=n??(i?i.top+i.height/2:0);return function(e,t,n,r,i){let s=_(t);if(s===e.scale)return e;let a=i?n-(i.left+i.width/2):0,l=i?r-(i.top+i.height/2):0,o=s/e.scale;return{scale:s,x:a-(a-e.x)*o,y:l-(l-e.y)*o}}(r,r.scale*e,s,a,i)})},[]),b=(0,i.hb)(e=>{e.preventDefault(),g(Math.exp(-(.0015*e.deltaY)),e.clientX,e.clientY)},[g]),v=(0,i.hb)(e=>{0===e.button&&(o.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture(e.pointerId),h(!0))},[]),k=(0,i.hb)(e=>{let t=o.current;if(!t||t.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;t.x=e.clientX,t.y=e.clientY,d(e=>({...e,x:e.x+n,y:e.y+r}))},[]),y=(0,i.hb)(e=>{o.current?.pointerId===e.pointerId&&(o.current=null,h(!1))},[]),w=(0,i.hb)(()=>{d(e=>.01>Math.abs(e.scale-1)?{scale:u,x:0,y:0}:{scale:1,x:0,y:0})},[u]);(0,i.vJ)(()=>{let e=e=>{if("Escape"===e.key){e.preventDefault(),a();return}if("+"===e.key||"="===e.key){e.preventDefault(),g(1.4);return}if("-"===e.key||"_"===e.key){e.preventDefault(),g(1/1.4);return}"0"===e.key&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,g,x]),(0,i.vJ)(()=>{let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[]);let N={width:`${n}px`,height:`${s}px`,transform:`translate3d(${c.x}px, ${c.y}px, 0) scale(${c.scale})`};return(0,E.d5)((0,r.FD)("div",{className:"fixed inset-0 z-[200] bg-ink/85 backdrop-blur-sm",role:"dialog","aria-modal":"true","aria-label":"Diagram viewer",onWheel:b,children:[(0,r.Y)("div",{ref:l,tabIndex:-1,className:`diagram-viewer-stage absolute inset-0 overflow-hidden outline-none ${m?"cursor-grabbing":"cursor-grab"}`,onPointerDown:v,onPointerMove:k,onPointerUp:y,onPointerCancel:y,onDblClick:w,children:(0,r.Y)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.Y)("div",{className:"diagram-viewer-canvas",style:N,dangerouslySetInnerHTML:{__html:t}})})}),(0,r.Y)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pb-4",children:(0,r.FD)("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-canvas/15 bg-paper/10 px-1.5 py-1 text-canvas backdrop-blur-sm",children:[(0,r.Y)(K,{label:"Zoom out (-)",onClick:()=>g(1/1.4),children:(0,r.Y)(R.A,{size:14})}),(0,r.FD)("span",{className:"w-12 text-center font-mono text-[11px] tabular-nums text-canvas/80",children:[Math.round(100*c.scale),"%"]}),(0,r.Y)(K,{label:"Zoom in (+)",onClick:()=>g(1.4),children:(0,r.Y)(I.A,{size:14})}),(0,r.Y)(K,{label:"Fit to view (0)",onClick:x,children:(0,r.Y)(O.A,{size:14})}),(0,r.Y)(K,{label:"Close (Esc)",onClick:a,children:(0,r.Y)(J.A,{size:14})})]})})]}),document.body)}function K(e){let{label:t,onClick:n,children:i}=e;return(0,r.Y)("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-canvas/80 transition-colors hover:bg-canvas/10 hover:text-canvas",children:i})}function U(e){var t;let n,r,i=e.querySelector(":scope > svg");return i?{svg:i.outerHTML,...(t=i,n=t.viewBox?.baseVal,r=t.getBoundingClientRect(),{width:q(t.getAttribute("width"),n?.width,r.width),height:q(t.getAttribute("height"),n?.height,r.height)})}:null}function q(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];for(let e of t){let t="number"==typeof e?e:Number.parseFloat(e??"");if(Number.isFinite(t)&&t>0)return t}return 1}let B="u"<typeof window?i.vJ:i.Nf;function H(e){let{content:t,className:n=""}=e,s=(0,i.li)(null),a=(0,i.li)(null),[o,m]=(0,i.J0)(null),h=(0,P.w)(),f=(0,i.Kr)(()=>{let e,n;if(!t)return"";let r=(e=t.split("`").map((e,t)=>t%2==1?e:e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")).join("`"),n=(0,l.Ay)(e,{katex:!0,inlineKatex:!0}).replace(Y,(e,t)=>`<span class="md-incomplete-link">${t}</span>`),w.parse(n).trim());if(r.includes(g)&&b(),!r||"u"<typeof window||!window.document)return r;let i=/<svg[^>]*>/.test(r),s=r.includes("math-pending"),a=/class="[^"]*katex/.test(r)||i||s?{USE_PROFILES:{html:!0,mathMl:!0},ADD_TAGS:[...d,...i?u:[]],ADD_ATTR:["aria-hidden","aria-label","encoding","nonce","data-math","data-math-display",...i?p:[]]}:{USE_PROFILES:{html:!0}};try{return c.A.sanitize(r,a)}catch{return r}},[t,h]),x=f.includes("mermaid-block"),k=f.includes(g);(0,i.vJ)(()=>{if(!k||"u"<typeof window)return;let e=s.current;if(!e)return;let t=!1;(async()=>{if(e.isConnected&&(await v(e),t))return})();let n=new MutationObserver(()=>{let e=s.current;e?.isConnected&&v(e)});return n.observe(e,{childList:!0}),()=>{t=!0,n.disconnect()}},[k,f]),B(()=>{let e;if(!x||"u"<typeof window)return;let t=s.current;if(!t)return;let n=async()=>{let e=s.current;e&&e.isConnected&&await L(e)};n();let r=new MutationObserver(()=>{let t=s.current;t?.isConnected&&L(t,{cachedOnly:!0}),window.clearTimeout(e),e=window.setTimeout(()=>void n(),120)});r.observe(t,{childList:!0});let i=async()=>{await n();let e=a.current;if(!e?.isConnected)return;let t=U(e);t&&m(t)},l=new MutationObserver(()=>void i());return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{window.clearTimeout(e),r.disconnect(),l.disconnect()}},[x,f]);let y=(0,i.hb)(e=>{let t=e.target.closest("button.code-copy-float");if(t){let n=t.dataset.copy??"";if(!n)return;e.preventDefault(),e.stopPropagation(),(0,M.l)(n).then(e=>{e&&(t.setAttribute("data-copied","true"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',setTimeout(()=>{t.removeAttribute("data-copied"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'},2e3))});return}let n=e.target.closest('.mermaid-block[data-mermaid-state="done"]');if(!n)return;let r=U(n);r&&(e.preventDefault(),a.current=n,m(r))},[]),N=(0,i.hb)(()=>{a.current=null,m(null)},[]);return t?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{ref:s,className:`prose-content text-[13px] text-ink leading-relaxed select-text ${n}`,onClick:y,dangerouslySetInnerHTML:{__html:f}}),o&&(0,r.Y)(W,{...o,onClose:N})]}):null}},R2(e,t,n){var r=n("j");function i(e){let{status:t}=e;if(t?.transport!=="websocket")return null;let n=!!t.connected,i=n?"WebSocket connected":"WebSocket disconnected";return(0,r.Y)("span",{role:"status","aria-label":i,title:i,className:"flex items-center flex-shrink-0 select-none",children:(0,r.Y)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${n?"bg-success":"bg-error"}`})})}n.d(t,{c:()=>i})},Uo(e,t,n){var r=n("j"),i=n("m"),s=n("p"),a=n("F"),l=n("V");function o(e){let{status:t,live:n,size:o=12}=e,c={size:o,strokeWidth:2,"aria-hidden":!0};if("completed"===t)return(0,r.Y)(i.A,{...c,className:"text-success"});if("failed"===t)return(0,r.Y)(s.A,{...c,className:"text-error"});if("aborted"===t)return(0,r.Y)(a.A,{...c,className:"text-ink/40"});if(!1===n)return(0,r.Y)(l.A,{...c,className:"text-ink/30"});let d=Math.max(5,Math.round(o/2));return(0,r.Y)("span",{"aria-hidden":!0,className:"inline-block shrink-0 animate-pulse rounded-full bg-success",style:{width:d,height:d}})}n.d(t,{l:()=>o})},wu(e,t,n){n.d(t,{y:()=>d});var r=n("j"),i=n("H"),s=n("G"),a=n("p"),l=n("m"),o=n("S");function c(e){let{toast:t,onDismiss:n,duration:c}=e,[d,u]=(0,i.J0)(!1),p=c??t.duration??4e3,m=(0,i.li)(null);return(0,i.vJ)(()=>{let e=requestAnimationFrame(()=>u(!0)),r=setTimeout(()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},p);return()=>{cancelAnimationFrame(e),clearTimeout(r),m.current&&clearTimeout(m.current)}},[t.id,p,n]),(0,s.d5)((0,r.FD)("div",{className:`fixed bottom-4 right-4 z-[200] flex items-center space-x-2 bg-paper border shadow-2xl rounded-lg px-4 py-3 text-xs font-sans transition-all duration-200 ${"error"===t.type?"border-error/40":"border-ink/15"} ${d?"opacity-100 translate-y-0":"opacity-0 translate-y-2"}`,role:"status",children:["error"===t.type?(0,r.Y)(a.A,{size:15,className:"text-error flex-shrink-0"}):(0,r.Y)(l.A,{size:15,className:"text-success flex-shrink-0"}),(0,r.Y)("span",{className:"text-ink max-w-[320px]",children:t.message}),t.action&&(0,r.Y)("button",{type:"button",onClick:()=>{t.action?.onClick(),u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"flex-shrink-0 px-2 py-0.5 rounded bg-ink text-paper font-semibold hover:opacity-80 transition-opacity",children:t.action.label}),(0,r.Y)("button",{type:"button",onClick:()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"text-ink/40 hover:text-ink transition-colors flex-shrink-0",title:"Dismiss",children:(0,r.Y)(o.A,{size:13})})]}),document.body)}function d(e){let{toasts:t,onDismiss:n}=e;return(0,r.Y)(r.FK,{children:t.map(e=>(0,r.Y)(c,{toast:e,onDismiss:n},e.id))})}},nG(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("dc")]).then(n.bind(n,"fy")).then(e=>({default:e.FileExplorer}))),a=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("1k")]).then(n.bind(n,"X8")).then(e=>({default:e.SearchPanel}))),l=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("m")]).then(n.bind(n,"ABt")).then(e=>({default:e.GitPanel}))),o=(0,i.RZ)(()=>n.e("x4").then(n.bind(n,"Xc")).then(e=>({default:e.TerminalPanel}))),c=(0,i.RZ)(()=>n.e(51).then(n.bind(n,"zO")).then(e=>({default:e.ContextPanel}))),d=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("s")]).then(n.bind(n,"a6")).then(e=>({default:e.BrowserPanel}))),u=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("rd")]).then(n.bind(n,"NU")).then(e=>({default:e.UserBrowserPanel}))),p=(0,i.RZ)(()=>Promise.all([n.e("ma"),n.e("bi")]).then(n.bind(n,"Rc")).then(e=>({default:e.UsagePanel}))),m=new WeakMap;function h(e,t){let n=m.get(e);if(n||(n={},m.set(e,n)),!n[t]){let e="files"===t?s:"search"===t?a:"git"===t?l:"terminal"===t?o:"context"===t?c:"user-browser"===t?u:"browser"===t?d:p,i=t=>{let{className:n,...i}=t;return(0,r.Y)("div",{className:`w-full h-full ${"string"==typeof n?n:""}`,children:(0,r.Y)(e,{...i,className:"w-full h-full"})})};i.displayName=`CachedView(${t})`,n[t]=i}return n[t]}n.d(t,{SU:()=>h},{Bz:o,M:u,N1:a,WE:p,XL:d,gI:s,nR:l,ov:c})},E(e,t,n){n.d(t,{i:()=>l});var r=n("j"),i=n("z");let s=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],a={"A-Z":"A-Z","Z-A":"Z-A",LATEST_SESSION:"Latest Session",LATEST_ADDED:"Latest Added"};function l(e){let{variant:t,sortOption:n,onSortChange:l}=e;return"mobile"===t?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>l(e),className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${n===e?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[(0,r.Y)("span",{children:e.replace("_"," ")}),n===e&&(0,r.Y)(i.A,{size:13,className:"text-ink"})]},e))]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase font-bold text-ink/40 tracking-wider",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("div",{className:`px-3 py-1.5 text-xs cursor-pointer flex items-center justify-between ${n===e?"bg-ink/5 text-ink font-medium":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,onClick:()=>l(e),children:[(0,r.Y)("span",{children:a[e]}),n===e&&(0,r.Y)("div",{className:"w-1.5 h-1.5 rounded-full bg-ink"})]},e))]})}},C4(e,t,n){var r=n("j"),i=n("mO"),s=n("Wi"),a=n("a");function l(e){let{variant:t,isPinned:n=!1,confirmDelete:l,onPin:o,onDelete:c,onRequestDelete:d,onCancelDelete:u}=e;return"mobile"===t?l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-2 text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("button",{type:"button",onClick:u,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/70",children:"Cancel"})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("button",{type:"button",onClick:o,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[n?(0,r.Y)(s.A,{size:13}):(0,r.Y)(a.A,{size:13}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("button",{type:"button",onClick:d,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Delete Workspace"})]})]}):l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-xs text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:c,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/70",onClick:u,children:(0,r.Y)("span",{children:"Cancel"})})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",onClick:o,children:[n?(0,r.Y)(s.A,{size:12}):(0,r.Y)(a.A,{size:12}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:d,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Delete Workspace"})]})]})}n.d(t,{t:()=>l})},g(e,t,n){n.d(t,{VT:()=>T,xV:()=>z,Lo:()=>$,bB:()=>f.b});var r=n("j"),i=n("H"),s=n("S"),a=n("w"),l=n("Y"),o=n("o"),c=n("r"),d=n("lP"),u=n("C"),p=n("W"),m=n("N"),h=n("YL"),f=n("u"),x=n("Nf"),g=n("t"),b=n("n"),v=n("g6");async function k(e){let t=e?`?path=${encodeURIComponent(e)}`:"",n=await fetch(`/api/fs/browse${t}`),r=await n.json();if(!n.ok||r.error)throw Error(r.error||`HTTP ${n.status}`);return r}function y(e){let{initialPath:t,onSelect:n,onClose:o}=e,[c,d]=(0,i.J0)(t??""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)([]),[f,y]=(0,i.J0)(null),[w,N]=(0,i.J0)(!0),[Y,D]=(0,i.J0)(null),[F,A]=(0,i.J0)(null),C=(0,i.li)(null),S=(0,i.hb)(async e=>{N(!0),D(null);try{let t=await k(e);d(t.path??e??""),y(t.parentPath??null),p(t.path??e??""),h(t.directories??[])}catch(e){D(e instanceof Error?e.message:String(e))}finally{N(!1)}},[]);(0,i.vJ)(()=>{S(t)},[t,S]);let T=e=>{S(e.path)};return(0,r.Y)("div",{className:"fixed inset-0 bg-ink/30 z-[60] flex items-center justify-center p-4",onClick:o,children:(0,r.FD)("div",{className:"bg-paper border border-ink/15 rounded-lg shadow-2xl w-full max-w-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[(0,r.FD)("h3",{className:"font-semibold text-sm flex items-center space-x-2",children:[(0,r.Y)(l.A,{size:15,className:"text-ink/70"}),(0,r.Y)("span",{children:"Choose Project Folder"})]}),(0,r.Y)("button",{type:"button",onClick:o,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors","aria-label":"Close picker",children:(0,r.Y)(s.A,{size:15})})]}),(0,r.FD)("div",{className:"px-4 py-2 border-b border-ink/10 bg-canvas/50",children:[(0,r.FD)("form",{onSubmit:e=>{e.preventDefault();let t=u.trim();t&&S(t)},className:"flex items-center space-x-2",children:[(0,r.Y)(a.A,{size:14,className:"text-ink/40 flex-shrink-0"}),(0,r.Y)("input",{ref:C,type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~ or /absolute/path",className:"flex-1 bg-transparent outline-none text-xs font-mono text-ink placeholder-ink/30 py-1",spellcheck:!1}),(0,r.Y)("button",{type:"submit",className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Go"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 mt-1 text-[11px] text-ink/40 truncate",children:[(0,r.FD)("button",{type:"button",onClick:()=>void S(),className:"hover:text-ink transition-colors flex items-center",children:[(0,r.Y)(a.A,{size:11,className:"mr-0.5"})," home"]}),c.split("/").filter(Boolean).map((e,t,n)=>{let i="/"+c.split("/").filter(Boolean).slice(0,t+1).join("/"),s=t===n.length-1;return(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0",children:[(0,r.Y)(x.A,{size:10,className:"text-ink/20 flex-shrink-0"}),s?(0,r.Y)("span",{className:"text-ink/70 truncate",children:e}):(0,r.Y)("button",{type:"button",onClick:()=>void S(i),className:"hover:text-ink transition-colors truncate max-w-[120px]",children:e})]},i)})]})]}),(0,r.Y)("div",{className:"flex-1 min-h-[240px] max-h-[360px] scrollbar-overlay-container scrollbar-overlay-static p-2",children:w?(0,r.Y)("div",{className:"flex items-center justify-center h-40 text-ink/40",children:(0,r.Y)(g.A,{size:18,className:"animate-spin"})}):Y?(0,r.FD)("div",{className:"flex flex-col items-center justify-center h-40 text-xs text-red-600 space-y-2 px-4",children:[(0,r.Y)("span",{children:Y}),(0,r.FD)("button",{type:"button",onClick:()=>void S(c||void 0),className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[(0,r.Y)(b.A,{size:11})," Retry"]})]}):0===m.length?(0,r.Y)("div",{className:"text-center py-16 text-xs text-ink/40",children:"No subfolders"}):m.map(e=>(0,r.FD)("div",{className:`group flex items-center justify-between px-2.5 py-2 rounded cursor-pointer transition-colors ${F===e.path?"bg-ink/10":"hover:bg-ink/5"}`,onDblClick:()=>T(e),children:[(0,r.FD)("button",{type:"button",onClick:()=>T(e),className:"flex items-center space-x-2 min-w-0 flex-1 text-left",children:[(0,r.Y)(v.A,{size:15,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"text-xs truncate text-ink/85",children:e.name})]}),(0,r.Y)("button",{type:"button",onClick:()=>{A(e.path),n(e.path)},className:"hidden group-hover:flex px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-semibold hover:bg-ink/80 transition-colors flex-shrink-0",children:"Choose"})]},e.path))}),(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-ink/10",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("button",{type:"button",onClick:()=>{f&&S(f)},disabled:!f,className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1",children:[(0,r.Y)("span",{children:"↑"}),(0,r.Y)("span",{children:"Up"})]}),(0,r.Y)("button",{type:"button",onClick:()=>void S(),className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Home"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.Y)("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),(0,r.Y)("button",{type:"button",onClick:()=>{c&&(A(c),n(c))},disabled:!c,className:"px-3.5 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 disabled:opacity-50 transition-colors",children:"Use This Folder"})]})]})]})})}var w=n("P");function N(){return(0,r.FD)("div",{className:"flex flex-col items-center gap-3 mt-6 pt-1",children:[(0,r.FD)("div",{className:"flex items-center justify-center gap-6",children:[(0,r.FD)("a",{href:"https://github.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),(0,r.Y)("span",{children:"GitHub"})]}),(0,r.FD)("a",{href:"https://discord.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994.021-.041.001-.09-.041-.106a13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.929 1.793 8.18 1.793 12.061 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.894.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.028zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})}),(0,r.Y)("span",{children:"Discord"})]})]}),(0,r.FD)("a",{href:"https://x.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),(0,r.Y)("span",{children:"@ompchamber"})]})]})}var Y=n("tC"),D=n("p"),F=n("z");let A="inline-flex items-center gap-1.5 rounded-md border border-ink/20 px-2.5 py-1.5 text-[11px] font-medium text-ink transition-colors hover:border-ink/40 disabled:cursor-not-allowed disabled:opacity-50";function C(e){let{target:t,info:n,applying:i,disabled:s,onApply:a}=e,l=`v${n.current??"…"} → v${n.latest??"…"}`;return(0,r.FD)("div",{className:"flex items-center justify-between gap-3 border-t border-ink/10 py-2.5 first:border-t-0",children:[(0,r.FD)("div",{className:"min-w-0",children:[(0,r.Y)("p",{className:"text-xs font-medium text-ink",children:"ompchamber"===t?"OMPChamber":"Oh-My-Pi"}),(0,r.Y)("p",{className:"font-mono text-[10px] text-ink/60",children:n.installed?l:"not detected"})]}),n.installed?(0,r.FD)("button",{type:"button",onClick:()=>a(t),disabled:s,className:A,children:[i?(0,r.Y)(g.A,{size:12,className:"animate-spin motion-reduce:animate-none"}):(0,r.Y)(Y.A,{size:12}),(0,r.Y)("span",{children:"Update"})]}):(0,r.Y)("span",{className:"shrink-0 text-[10px] text-ink/40",children:"not detected"})]})}function S(e){let{updates:t,onToast:n}=e,i=t.info?[{target:"ompchamber",info:t.info.ompchamber},{target:"omp",info:t.info.omp}].filter(e=>{let{info:t}=e;return t.updateAvailable&&null!==t.latest}):[],s=async e=>{let r=await t.apply(e);if(n){if(!r)return void n("The update request could not be completed.","error");if("ompchamber"===e)return void n(r.message,r.success?"success":"error");r.success?n(`${r.message} A restart may be needed.`,"success"):n(r.message,"error")}},a=!!(t.info&&!t.checking&&!t.error);return(0,r.FD)("section",{className:"mt-5 border-y border-ink/10 py-3 text-left","aria-labelledby":"updates-heading",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.Y)("h3",{id:"updates-heading",className:"text-xs font-semibold text-ink",children:"Updates"}),t.info&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:"checked"})]}),(0,r.FD)("div",{className:"mt-2.5",children:[t.checking&&(0,r.FD)("button",{type:"button",disabled:!0,className:`${A} w-full justify-center`,children:[(0,r.Y)(g.A,{size:13,className:"animate-spin motion-reduce:animate-none"}),(0,r.Y)("span",{children:"Checking…"})]}),t.error&&!t.checking&&(0,r.FD)("div",{className:"flex items-start gap-2",children:[(0,r.Y)(D.A,{size:14,className:"mt-0.5 shrink-0 text-error"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("p",{className:"text-[11px] leading-4 text-error",children:t.error}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} mt-2`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Retry"})]})]})]}),!t.info&&!t.checking&&!t.error&&(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} w-full justify-center`,children:[(0,r.Y)(b.A,{size:13}),(0,r.Y)("span",{children:"Check for updates"})]}),a&&0===i.length&&(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.FD)("p",{className:"flex items-center gap-1.5 text-[11px] text-success",children:[(0,r.Y)(F.A,{size:13}),(0,r.Y)("span",{children:"You're up to date"})]}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:A,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]}),a&&i.length>0&&(0,r.FD)("div",{children:[i.map(e=>{let{target:n,info:i}=e;return(0,r.Y)(C,{target:n,info:i,applying:t.applying===n,disabled:null!==t.applying,onApply:e=>void s(e)},n)}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),disabled:null!==t.applying,className:`${A} mt-2 w-full justify-center`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]})]})]})}function T(e){let{isOpen:t,onClose:n,updates:i,onToast:a}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/40 backdrop-blur-[2px] z-50 flex items-center justify-center p-4 animate-in fade-in duration-200",onClick:n,children:(0,r.FD)("div",{className:"relative bg-paper border border-ink/15 rounded-2xl shadow-2xl w-full max-w-[340px] p-6 text-center text-ink select-none",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{onClick:n,className:"absolute top-4 right-4 text-ink/40 hover:text-ink transition-colors p-1 rounded-md","aria-label":"Close",children:(0,r.Y)(s.A,{size:18,className:"stroke-[2.5]"})}),(0,r.Y)("div",{className:"flex justify-center pt-2 pb-1",children:(0,r.Y)("img",{src:"/icon.svg",alt:"OMPChamber",width:96,height:96,draggable:!1})}),(0,r.FD)("h2",{className:"text-xl font-bold tracking-tight mt-3 flex items-center justify-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-2xl tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"text-ink text-2xl font-bold ml-[1px]",children:"Chamber"})]}),(0,r.FD)("div",{className:"text-xs text-ink/60 space-y-1 mt-1.5 font-mono",children:[(0,r.FD)("p",{children:["OMPChamber v",w.rE]}),(0,r.FD)("p",{children:["Oh-My-Pi ",i.info?.omp.current??"…"]})]}),(0,r.Y)(S,{updates:i,onToast:a}),(0,r.Y)(N,{}),(0,r.Y)("p",{className:"text-[11px] text-ink/50 font-normal mt-8",children:"Made with love for the community"})]})}):null}function z(e){let{isOpen:t,onClose:n,onCreate:o}=e,[c,d]=(0,i.J0)(""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)(!1),[f,x]=(0,i.J0)(null),[g,b]=(0,i.J0)(!1);if((0,i.vJ)(()=>{t&&(d(""),p(""),h(!1),x(null),b(!1))},[t]),!t)return null;let v=async()=>{if(!o)return void n();if(!c.trim()&&!u.trim())return void x("Enter a name or a project path.");h(!0),x(null);try{await o({name:c.trim(),path:u.trim()||void 0}),n()}catch(e){x(e instanceof Error?e.message:String(e)),h(!1)}};return(0,r.FD)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center",children:[(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-96 p-4 flex flex-col",children:[(0,r.FD)("div",{className:"flex justify-between items-center mb-4 border-b border-ink/10 pb-2",children:[(0,r.Y)("h3",{className:"font-semibold text-sm",children:"New Workspace"}),(0,r.Y)(s.A,{size:14,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.FD)("div",{className:"text-sm text-ink/80 py-2 space-y-3",children:[(0,r.FD)("div",{children:[(0,r.Y)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:"Workspace Name"}),(0,r.Y)("input",{type:"text",value:c,onChange:e=>d(e.currentTarget.value),placeholder:"e.g. bofis-pro",className:"w-full bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm"})]}),(0,r.FD)("div",{children:[(0,r.FD)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Project Path ",(0,r.Y)("span",{className:"text-ink/40 font-normal",children:"(optional — binds omp sessions)"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.FD)("div",{className:"flex-1 flex items-center bg-paper border border-ink/20 rounded overflow-hidden focus-within:border-ink/50",children:[(0,r.Y)("div",{className:"px-2 text-ink/40 bg-ink/5 h-full flex items-center border-r border-ink/10",children:(0,r.Y)(a.A,{size:14})}),(0,r.Y)("input",{type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~/projects/my-project",className:"w-full px-3 py-2 outline-none text-sm bg-transparent"})]}),(0,r.FD)("button",{type:"button",onClick:()=>b(!0),className:"px-3 py-2 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 transition-colors flex items-center space-x-1.5 flex-shrink-0",children:[(0,r.Y)(l.A,{size:13}),(0,r.Y)("span",{children:"Browse"})]})]})]}),f&&(0,r.Y)("div",{className:"text-xs text-red-600",children:f})]}),(0,r.FD)("div",{className:"mt-4 flex justify-end space-x-2",children:[(0,r.Y)("button",{className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",onClick:n,disabled:m,children:"Cancel"}),(0,r.Y)("button",{className:"px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-50",onClick:v,disabled:m,children:m?"Creating…":"Create Workspace"})]})]}),g&&(0,r.Y)(y,{initialPath:u||void 0,onSelect:e=>{if(p(e),b(!1),!c.trim()){let t=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||"";t&&d(t)}},onClose:()=>b(!1)})]})}function $(e){let{isOpen:t,onClose:n}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center p-4",children:(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-full max-w-2xl flex flex-col overflow-hidden",children:[(0,r.FD)("div",{className:"flex justify-between items-center p-4 border-b border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 text-ink",children:[(0,r.Y)(o.A,{size:16}),(0,r.Y)("h3",{className:"font-semibold text-sm",children:"Schedule Chat / Task"})]}),(0,r.Y)(s.A,{size:16,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.Y)("div",{className:"p-4 bg-canvas",children:(0,r.FD)("div",{className:"w-full bg-paper border border-ink/20 rounded-md focus-within:border-ink transition-colors flex flex-col shadow-sm",children:[(0,r.FD)("div",{className:"flex items-center px-3 py-2 border-b border-ink/5 text-ink/60 space-x-2",children:[(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(c.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(d.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(u.A,{size:14})}),(0,r.Y)("div",{className:"flex-1"}),(0,r.FD)("div",{className:"flex items-center space-x-2 text-xs text-ink",children:[(0,r.Y)("span",{className:"font-medium",children:"Schedule:"}),(0,r.FD)("select",{className:"bg-transparent border border-ink/20 rounded px-1.5 py-0.5 outline-none focus:border-ink/50",children:[(0,r.Y)("option",{value:"once",children:"Once"}),(0,r.Y)("option",{value:"every",children:"Every"}),(0,r.Y)("option",{value:"cron",children:"Cron"})]}),(0,r.Y)("input",{type:"text",placeholder:"e.g. 5 mins, 0 0 * * *",className:"w-32 bg-transparent border border-ink/20 rounded px-2 py-0.5 outline-none focus:border-ink/50"})]})]}),(0,r.Y)("textarea",{placeholder:"Describe your scheduled task, ask a question, or paste commands...",className:"w-full bg-transparent border-none px-4 py-4 text-sm focus:outline-none resize-none text-ink placeholder-ink/40 min-h-[120px]"}),(0,r.FD)("div",{className:"flex items-center justify-between px-3 py-2 border-t border-ink/5",children:[(0,r.FD)("div",{className:"flex items-center space-x-3 text-ink/60 text-xs",children:[(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(p.A,{size:14}),(0,r.Y)("span",{children:"Default"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(m.A,{size:14}),(0,r.Y)("span",{children:"[CMD] DeepSeek V4 Flash"})]})]}),(0,r.FD)("button",{onClick:n,className:"flex items-center justify-center space-x-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/80 transition-colors text-xs font-medium",children:[(0,r.Y)("span",{children:"Schedule Task"}),(0,r.Y)(h.A,{size:12,className:"ml-px"})]})]})]})})]})}):null}},u(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("ma"),n.e("5b")]).then(n.bind(n,"bS")).then(e=>({default:e.SettingsModal})));function a(e){let{isOpen:t,...n}=e;return t?(0,r.Y)(i.tY,{fallback:null,children:(0,r.Y)(s,{isOpen:t,...n})}):null}n.d(t,{b:()=>a})},d(e,t,n){n.d(t,{E:()=>iO});var r=n("j"),i=n("H"),s=n("s"),a=n("G");let l=(0,a.RZ)(()=>n.e("xn").then(n.bind(n,"PB")).then(e=>({default:e.ExtensionDialog})));function o(e){return(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(l,{...e})})}let c=/^other\b/i,d=/\s+\(\d+\s*\/\s*\d+\)$/,u=/^\(\d+\s+selected\)\s*/;function p(e){return e.replace(u,"").replace(d,"").replace(/\s+/g," ").trim().toLowerCase()}function m(e){if("string"==typeof e){let t=e.trim();return t?{label:t}:null}if(!e||"object"!=typeof e)return null;let t="string"==typeof e.label?e.label.trim():"";return t?{label:t,description:"string"==typeof e.description?e.description:void 0,preview:"string"==typeof e.preview?e.preview:void 0}:null}function h(e){let t=e.input,n="object"==typeof t&&null!==t?t:null,r=n&&Array.isArray(n.questions)?n.questions:[],i=[];for(let e of r){if(!e||"object"!=typeof e)continue;let t="string"==typeof e.question?e.question.trim():"";t&&i.push({id:"string"==typeof e.id?e.id:void 0,header:"string"==typeof e.header&&e.header.trim()?e.header.trim():void 0,question:t,options:Array.isArray(e.options)?e.options.map(m).filter(e=>null!==e):[],multi:!0===e.multi,recommended:"number"==typeof e.recommended?e.recommended:void 0})}return i}function f(e){return{selectedOptions:Array.isArray(e.selectedOptions)?e.selectedOptions.filter(e=>"string"==typeof e):[],customInput:"string"==typeof e.customInput&&e.customInput?e.customInput:void 0,timedOut:!0===e.timedOut}}let x=/^([\w.-]+):\s*(.+)$/,g=/^User selected:\s*(.+)$/m,b=/^User provided custom input:\s*([\s\S]+)$/m;function v(e,t){let n=e.trim();return/^"[\s\S]*"$/.test(n)?{selectedOptions:[],customInput:n.slice(1,-1)}:{selectedOptions:(t&&n.includes(", ")?n.split(", "):[n]).map(e=>e.trim()).filter(Boolean)}}let k={framesByTool:new Map,respond:()=>{}},y=(0,a.q6)(k);var w=n("v"),N=n("g6"),Y=n("Go"),D=n("z"),F=n("oj"),A=n("s8"),C=n("YL"),S=n("tN"),T=n("W9"),z=n("r"),$=n("t3"),j=n("S");function L(e){let{search:t,onSearchChange:n,onAddProvider:i}=e;return(0,r.FD)("div",{className:"flex flex-col border-b border-ink/10 bg-canvas/40",children:[(0,r.FD)("button",{type:"button",onClick:i,className:"w-full flex items-center space-x-2 px-3 py-2 text-xs text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors text-left font-medium cursor-pointer border-b border-ink/5",children:[(0,r.Y)(z.A,{size:14,className:"text-ink/60"}),(0,r.Y)("span",{children:"Add new provider"})]}),(0,r.FD)("div",{className:"p-2 flex items-center bg-canvas/60",children:[(0,r.Y)($.A,{size:13,className:"text-ink/40 mr-2 flex-shrink-0"}),(0,r.Y)("input",{type:"text",value:t,onChange:e=>n(e.currentTarget.value),placeholder:"Search models",className:"bg-transparent border-none focus:outline-none w-full text-ink placeholder-ink/40 text-xs font-sans",autoFocus:!0}),t&&(0,r.Y)("button",{type:"button",onClick:()=>n(""),className:"p-0.5 text-ink/40 hover:text-ink transition-colors cursor-pointer",title:"Clear search",children:(0,r.Y)(j.A,{size:12})})]})]})}var M=n("HW"),P=n("hw"),E=n("j7"),R=n("Wb"),I=n("cV"),O=n("lW"),J=n("C7"),_=n("XT"),W=n("Oj"),K=n("K6"),U=n("pm");function q(e){let{model:t,isSelected:n,isFocused:i,onSelect:s,onToggleFavorite:a,onCycleThinking:l,onMouseEnter:o}=e;return(0,r.FD)("div",{role:"button",tabIndex:0,onClick:()=>s(t),onMouseEnter:o,className:`group relative w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-colors cursor-pointer select-none ${i?"bg-ink/10 text-ink":n?"bg-ink/5 text-ink":"text-ink/85 hover:bg-ink/5"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)(E.A,{size:12,className:"text-ink/20 group-hover:text-ink/50 transition-colors flex-shrink-0"}),(()=>{if(t.isCmdAgent)return(0,r.Y)("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded border border-ink/20 bg-ink/5 text-ink/80 flex-shrink-0",title:"Autonomous Agent Command Mode [CMD]",children:(0,r.Y)(I.A,{size:10})});switch(t.providerIcon||t.provider.toLowerCase()){case"deepseek":return(0,r.Y)("span",{className:"text-[12px] leading-none flex-shrink-0",title:"DeepSeek",children:"🐋"});case"anthropic":case"claude":return(0,r.Y)(O.A,{size:13,className:"text-orange-400 flex-shrink-0"});case"openai":return(0,r.Y)(J.A,{size:13,className:"text-emerald-500 flex-shrink-0"});case"google":case"gemini":return(0,r.Y)(S.A,{size:13,className:"text-blue-400 flex-shrink-0"});case"opencode":return(0,r.Y)(_.A,{size:13,className:"text-violet-400 flex-shrink-0"});case"mistral":return(0,r.Y)(W.A,{size:13,className:"text-rose-400 flex-shrink-0"});default:return(0,r.Y)(S.A,{size:13,className:"text-ink/60 flex-shrink-0"})}})(),(0,r.FD)("div",{className:"flex items-center space-x-1.5 truncate",children:[t.isCmdAgent&&(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink/75 flex-shrink-0",children:"[CMD]"}),(0,r.Y)("span",{className:`truncate ${n?"font-semibold text-ink":"font-normal text-ink/90"}`,children:t.name}),t.contextWindow&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/45 flex-shrink-0",children:(0,U.F)(t.contextWindow)})]})]}),(0,r.FD)("div",{className:"flex items-center space-x-2 flex-shrink-0",children:[t.thinkingLevel&&(0,r.FD)("button",{type:"button",onClick:e=>{e.stopPropagation(),l?.(t,e)},title:`Thinking preset: ${t.thinkingLevel} (Click or use ← / → to change)`,className:"inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono text-ink/70 bg-ink/5 hover:bg-ink/10 border border-ink/10 transition-colors cursor-pointer",children:[(0,r.Y)(K.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:t.thinkingLevel})]}),n&&(0,r.Y)(D.A,{size:13,className:"text-ink flex-shrink-0"}),(0,r.Y)("button",{type:"button",onClick:e=>a(t,e),title:t.isFavorite?"Remove from favorites":"Add to favorites",className:"p-1 rounded text-ink/30 hover:text-sky-400 hover:bg-ink/5 transition-colors cursor-pointer",children:(0,r.Y)(M.A,{size:13,className:t.isFavorite?"fill-sky-400 text-sky-400":"text-ink/30 hover:text-sky-400"})})]})]})}function B(e){return e?`${e.provider}:${e.id}`:""}function H(e){let{id:t,title:n,iconType:i="provider",models:s,isCollapsed:a,onToggleCollapse:l,selectedModelKey:o,modelIndex:c,focusedIndex:d,onSelect:u,onToggleFavorite:p,onCycleThinking:m,onHoverItem:h}=e;return 0===s.length?null:(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(t),className:"w-full flex items-center justify-between px-2 py-1 text-[11px] font-semibold text-ink/60 uppercase tracking-wider hover:text-ink cursor-pointer select-none",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:["star"===i&&(0,r.Y)(M.A,{size:12,className:"fill-sky-400 text-sky-400"}),"recent"===i&&(0,r.Y)(P.A,{size:12,className:"text-ink/60"}),"whale"===i&&(0,r.Y)("span",{children:"🐋"}),"provider"===i&&(0,r.Y)(E.A,{size:11,className:"text-ink/25"}),(0,r.Y)("span",{children:n})]}),a?(0,r.Y)(Y.A,{size:12,className:"text-ink/40"}):(0,r.Y)(R.A,{size:12,className:"text-ink/40"})]}),!a&&(0,r.Y)("div",{className:"space-y-0.5",children:s.map(e=>{let n=B(e),i=c[n]??-1;return(0,r.Y)(q,{model:e,isSelected:o===n,isFocused:d===i,onSelect:u,onToggleFavorite:p,onCycleThinking:m,onMouseEnter:()=>h(i,e)},`${t}-${n}`)})})]})}function G(){return(0,r.Y)("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-ink/10 bg-canvas/60 text-[10px] text-ink/50 font-mono select-none",children:(0,r.FD)("div",{className:"flex items-center space-x-3",children:[(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"↑ ↓"}),(0,r.Y)("span",{children:"navigate"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"Tab"}),(0,r.Y)("span",{children:"switch agent"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"← →"}),(0,r.Y)("span",{children:"thinking"})]})]})})}let V=[3,2];function Z(){return(0,r.Y)("div",{className:"space-y-2","aria-hidden":"true",children:V.map((e,t)=>(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 px-2 py-1",children:[(0,r.Y)("span",{className:"w-2.5 h-2.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-2.5 w-20 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,n)=>(0,r.FD)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)("span",{className:"w-3 h-3 rounded-sm animate-pulse bg-ink/10 flex-shrink-0"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${52-(n+t)%3*10}%`}})]}),(0,r.Y)("span",{className:"h-4 w-9 rounded animate-pulse bg-ink/10 flex-shrink-0"})]},n))]},t))})}function Q(e){let{model:t}=e;return t?(0,r.Y)("div",{className:"w-72 bg-paper/95 backdrop-blur-sm border border-ink/20 rounded-xl shadow-2xl p-3.5 text-xs text-ink select-none animate-in fade-in zoom-in-95 duration-100",children:(0,r.FD)("div",{className:"space-y-2.5 font-mono text-[11px]",children:[t.capabilities&&t.capabilities.length>0&&(0,r.FD)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Capabilities"}),(0,r.Y)("span",{className:"text-ink font-medium text-right text-xs font-sans",children:t.capabilities.join(", ")})]}),t.contextWindow&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Context"}),(0,r.Y)("span",{className:"text-ink/80",children:(0,U.F)(t.contextWindow)})]}),t.thinkingLevel&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Thinking"}),(0,r.Y)("span",{className:"text-ink/80",children:t.thinkingLevel})]}),t.input&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Input"}),(0,r.Y)("span",{className:"text-ink/80",children:t.input})]}),t.output&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Output"}),(0,r.Y)("span",{className:"text-ink/80",children:t.output})]}),t.cost&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/10",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cost ($/1M tokens)"}),(0,r.FD)("span",{className:"text-ink font-semibold tracking-tight",children:["In ",t.cost.input," · Out ",t.cost.output]})]}),(t.cost?.cacheRead!==void 0||t.cost?.cacheWrite!==void 0)&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/5",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cache"}),(0,r.Y)("span",{className:"text-ink/80",children:t.cost?.cacheRead!==void 0&&t.cost?.cacheWrite!==void 0?`Read ${t.cost.cacheRead} \xb7 Write ${t.cost.cacheWrite}`:t.cost?.cacheRead!==void 0?`Read ${t.cost.cacheRead}`:`Write ${t.cost.cacheWrite}`})]}),t.description&&(0,r.Y)("div",{className:"pt-1.5 text-[10px] text-ink/60 font-sans leading-relaxed border-t border-ink/5",children:t.description})]})}):null}function X(e){let{search:t,onSearchChange:n,onAddProvider:i,isLoading:s,filteredModels:a,favoriteModels:l,recentModels:o,providerGroups:c,collapsedSections:d,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,hoveredModel:f,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v,onMouseLeave:k}=e;return(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-2.5 z-50 flex items-start",children:[(0,r.FD)("div",{className:"w-84 sm:w-96 bg-paper border border-ink/20 rounded-xl shadow-2xl flex flex-col overflow-hidden text-xs max-h-[460px] animate-in fade-in zoom-in-95 duration-100",children:[(0,r.Y)(L,{search:t,onSearchChange:n,onAddProvider:i}),(0,r.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-2 max-h-80",onMouseLeave:k,children:s?(0,r.Y)(Z,{}):0===a.length?(0,r.Y)("div",{className:"px-3 py-6 text-center text-ink/40 italic",children:t?(0,r.FD)(r.FK,{children:['No models found matching "',t,'"']}):(0,r.Y)(r.FK,{children:"No models available. Enable a provider in Settings → Providers."})}):(0,r.FD)(r.FK,{children:[(0,r.Y)(H,{id:"favorites",title:"FAVORITES",iconType:"star",models:l,isCollapsed:!!d.favorites,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),(0,r.Y)(H,{id:"recent",title:"RECENT",iconType:"recent",models:o,isCollapsed:!!d.recent,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),Object.entries(c).map(e=>{let[t,n]=e;return(0,r.Y)(H,{id:t,title:t,iconType:"DEEPSEEK"===t?"whale":"provider",models:n,isCollapsed:!!d[t],onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v},t)})]})}),(0,r.Y)(G,{})]}),f&&(0,r.Y)("div",{className:"hidden lg:block ml-2 self-center",children:(0,r.Y)(Q,{model:f})})]})}function ee(e){let t=Array.isArray(e.thinkingLevels)?e.thinkingLevels:[],n=e.cost;return{id:e.id,name:e.name,provider:e.provider,contextWindow:e.contextWindow,thinkingLevel:t[0]??"off",thinkingLevels:t,capabilities:t.length>1?["Tool calling","Reasoning"]:["Tool calling"],cost:n?{input:void 0!==n.input?`$${n.input}`:"—",output:void 0!==n.output?`$${n.output}`:"—",cacheRead:void 0!==n.cacheRead?`$${n.cacheRead}`:void 0,cacheWrite:void 0!==n.cacheWrite?`$${n.cacheWrite}`:void 0}:void 0}}function et(e){let{selectedModel:t,onSelectModel:n,onOpenAddProvider:s,onThinkingLevelChange:a,className:l=""}=e,[o,c]=(0,i.J0)(!1),[d,u]=(0,i.J0)(""),[p,m]=(0,i.J0)(-1),[h,f]=(0,i.J0)(null),[x,g]=(0,i.J0)({}),{models:b,isLoading:v,setModels:k,selectedModel:y,setSelectedModel:w}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,i.J0)(!0),[a,l]=(0,i.J0)(e??null),o=(0,i.li)(e);o.current=e;let c=(0,i.hb)(e=>{n(e)},[]),d=(0,i.hb)(async()=>{try{let e=await (0,T.xo)();if(Array.isArray(e.modelList)&&e.modelList.length>0){let t=e.modelList.map(ee);n(e=>t.map(t=>{let n=e.find(e=>e.id===t.id&&e.provider===t.provider);return n?.thinkingLevel&&t.thinkingLevels?.includes(n.thinkingLevel)?{...t,thinkingLevel:n.thinkingLevel}:t}));let r=e.defaultModel;if(r&&!o.current){let e=t.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&l(e)}}else Array.isArray(e.models)&&e.models.length>0&&n(e.models);e.selectedModel&&!o.current&&l(e.selectedModel)}catch{}finally{s(!1)}},[]);return(0,i.vJ)(()=>(d(),(0,T.Sy)(d)),[d]),(0,i.vJ)(()=>{e&&(l(e),n(t=>t.map(t=>t.id===e.id&&t.provider===e.provider?{...t,thinkingLevel:e.thinkingLevel}:t)))},[e]),{models:t,isLoading:r,setModels:c,selectedModel:a,setSelectedModel:l}}(t),N=(0,i.li)(null);(0,F.W)(N,()=>{c(!1),f(null),m(-1)});let{filtered:D,favorites:A,recent:C,byProvider:z,visibleFlatList:$,index:j}=(0,i.Kr)(()=>(function(e,t,n){let r=t.trim().toLowerCase(),i=r?e.filter(e=>e.name.toLowerCase().includes(r)||e.provider.toLowerCase().includes(r)||String(e.contextWindow??"").toLowerCase().includes(r)||e.capabilities?.some(e=>e.toLowerCase().includes(r))):e,s=i.filter(e=>e.isFavorite),a=i.filter(e=>e.isRecent&&!e.isFavorite),l={};for(let e of i){let t=e.provider.toUpperCase();(l[t]??=[]).push(e)}let o=[];for(let[e,t]of(n.favorites||o.push(...s),n.recent||o.push(...a),Object.entries(l)))n[e]||o.push(...t);let c={};return o.forEach((e,t)=>{c[B(e)]=t}),{filtered:i,favorites:s,recent:a,byProvider:l,visibleFlatList:o,index:c}})(b,d,x),[b,d,x]),L=B(y),M=async(e,t)=>{t.stopPropagation();let n=B(e);k(e=>e.map(e=>B(e)===n?{...e,isFavorite:!e.isFavorite}:e));try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleFavorite",provider:e.provider,modelId:e.id})})}catch{}},P=e=>{let t=e.thinkingLevels??[];if(0===t.length)return;let r=e.thinkingLevel??t[0],i=t.indexOf(r),s=t[(i+1)%t.length],l=B(e);if(k(e=>e.map(e=>B(e)===l?{...e,thinkingLevel:s}:e)),L===l&&y){let e={...y,thinkingLevel:s};w(e),n?.(e),a?.(s)}},E=async e=>{let t=!e.isCmdAgent,n=B(e);k(e=>e.map(e=>B(e)===n?{...e,isCmdAgent:t}:e)),L===n&&y&&w({...y,isCmdAgent:t});try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleCmd",provider:e.provider,modelId:e.id})})}catch{}},R=async e=>{w(e),n?.(e),c(!1),f(null);try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"selectModel",model:e})}),(0,T.kn)()}catch{}};return(0,r.FD)("div",{className:`relative ${l}`,ref:N,onKeyDown:e=>{if(o){if("ArrowDown"===e.key)e.preventDefault(),m(e=>{let t=(e+1)%Math.max(1,$.length);return f($[t]||null),t});else if("ArrowUp"===e.key)e.preventDefault(),m(e=>{let t=(e-1+$.length)%Math.max(1,$.length);return f($[t]||null),t});else if("Enter"===e.key){e.preventDefault();let t=(p>=0?$[p]:null)||h;t&&R(t)}else if("Escape"===e.key)e.preventDefault(),c(!1),f(null);else if("Tab"===e.key){e.preventDefault();let t=(p>=0?$[p]:null)||h;t&&E(t)}else if("ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();let t=(p>=0?$[p]:null)||h;t&&P(t)}}},children:[(0,r.FD)("button",{type:"button",onClick:()=>{c(e=>!e),f(null),m(-1)},className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 font-medium cursor-pointer min-w-0 max-w-full",title:y?`${y.provider} • ${y.name}`:"Select a model",children:[y?(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:y.isCmdAgent?(0,r.Y)("span",{className:"font-mono text-[10px] font-bold text-ink/70",children:"⌘"}):"deepseek"===y.provider.toLowerCase()?(0,r.Y)("span",{children:"🐋"}):(0,r.Y)(S.A,{size:12,className:"text-ink/60"})}),(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0 max-w-[280px]",children:[(0,r.Y)("span",{className:"text-ink/50 font-normal truncate",children:y.provider}),(0,r.Y)("span",{className:"text-ink/30 flex-shrink-0",children:"•"}),(0,r.Y)("span",{className:"truncate",children:y.name})]})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:(0,r.Y)(S.A,{size:12,className:"text-ink/60"})}),(0,r.Y)("span",{className:"h-3 w-28 rounded animate-pulse bg-ink/10"})]}),(0,r.Y)(Y.A,{size:12,className:"text-ink/40 flex-shrink-0"})]}),o&&(0,r.Y)(X,{search:d,onSearchChange:u,onAddProvider:()=>{c(!1),f(null),s?s():window.dispatchEvent(new CustomEvent("omp:open-settings",{detail:{category:"providers",autoOpenAdd:!0}}))},isLoading:v,filteredModels:D,favoriteModels:A,recentModels:C,providerGroups:z,collapsedSections:x,onToggleCollapse:e=>{g(t=>({...t,[e]:!t[e]}))},selectedModelKey:L,modelIndex:j,focusedIndex:p,hoveredModel:h,onSelect:R,onToggleFavorite:M,onCycleThinking:P,onHoverItem:(e,t)=>{m(e),f(t)},onMouseLeave:()=>f(null)})]})}function en(e){let{thinkingLevels:t,currentThinking:n,onSelect:s}=e,[a,l]=(0,i.J0)(!1),o=(0,i.li)(null);return(0,F.W)(o,()=>l(!1)),(0,r.FD)("div",{className:"relative",ref:o,children:[(0,r.FD)("button",{onClick:()=>t.length>0&&l(!a),disabled:0===t.length,className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 disabled:opacity-40 disabled:cursor-not-allowed",title:0===t.length?"This model exposes no thinking levels":`Thinking Level: ${n}`,children:[(0,r.Y)(K.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:n})]}),a&&t.length>0&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Thinking Level"}),t.map(e=>(0,r.FD)("button",{onClick:()=>{l(!1),s(e)},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:e}),n===e&&(0,r.Y)(D.A,{size:12,className:"text-ink"})]},e))]})]})}var er=n("wf");let ei=["always-ask","write","yolo"],es={"always-ask":"Always ask",write:"Minimal",yolo:"Full bypass"},ea={"always-ask":"Read-only tools run automatically; writes and shell commands ask first.",write:"Reads and edits run automatically; shell commands ask first.",yolo:"Everything runs without asking."};function el(e){let{value:t,onSelect:n}=e,[s,a]=(0,i.J0)(!1),l=(0,i.li)(null);return(0,F.W)(l,()=>a(!1)),(0,r.FD)("div",{className:"relative",ref:l,children:[(0,r.FD)("button",{type:"button",onClick:()=>a(!s),className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80",children:[(0,r.Y)(er.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:es[t]})]}),s&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Access Control"}),ei.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{n(e),a(!1)},title:ea[e],className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:es[e]}),t===e&&(0,r.Y)(D.A,{size:12,className:"text-ink"})]},e))]})]})}function eo(e){let{isMobile:t,selectedModel:n,onSelectModel:i,thinkingLevels:s,currentThinking:a,onSelectThinking:l,onThinkingLevelChange:o,isGenerating:c,onStop:d,onSend:u,sendDisabled:p,accessMode:m,onSelectAccess:h}=e;return(0,r.FD)("div",{className:`flex items-center justify-between border-t border-ink/5 bg-canvas/50 rounded-b-md ${t?"px-2 py-2":"px-3 py-2"}`,children:[(0,r.FD)("div",{className:`flex items-center min-w-0 ${t?"space-x-1":"space-x-2"}`,children:[(0,r.Y)(et,{selectedModel:n??void 0,onSelectModel:i,onThinkingLevelChange:o,className:t?"min-w-0 max-w-[58%]":void 0}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(en,{thinkingLevels:s,currentThinking:a,onSelect:l}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(el,{value:m,onSelect:h})]}),(0,r.FD)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c&&(!t||!!d)&&(0,r.Y)("button",{type:"button",onClick:d,className:`flex items-center justify-center rounded transition-colors cursor-pointer shadow-xs animate-in zoom-in-90 duration-150 flex-shrink-0 ${t?"w-10 h-10 rounded-lg border border-ink/25 text-ink hover:bg-error hover:text-canvas hover:border-error":"w-7 h-7 bg-ink text-canvas hover:bg-error hover:text-canvas"}`,title:"Stop generation",children:(0,r.Y)(A.A,{size:t?14:10,className:"fill-current"})}),(!c||t)&&(0,r.Y)("button",{type:"button",onClick:u,disabled:p,className:`flex items-center justify-center rounded bg-ink text-canvas hover:bg-ink/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer flex-shrink-0 ${t?"w-10 h-10 rounded-lg":"w-7 h-7"}`,title:c?"Queue follow-up message":"Send message",children:(0,r.Y)(C.A,{size:t?16:12,className:"ml-px"})})]})]})}let ec=/[\s([{]/,ed=/^file:/i;var eu=n("ns");function ep(e){let{item:t}=e,n=t.match;return!n||n.start<0||n.start>=n.end||n.end>t.name.length?(0,r.Y)(r.FK,{children:t.name}):(0,r.FD)(r.FK,{children:[t.name.slice(0,n.start),(0,r.Y)("mark",{className:"bg-transparent font-semibold text-ink",children:t.name.slice(n.start,n.end)}),t.name.slice(n.end)]})}function em(e){let{open:t,kind:n,items:s,activeIndex:a,loading:l,error:o,listboxId:c,optionId:d,onSelect:u,onHover:p}=e,m=(0,i.li)(null);if((0,i.vJ)(()=>{t&&m.current?.scrollIntoView({block:"nearest"})},[a,t,s.length]),!t)return null;let h="mention"===n;return(0,r.FD)("div",{role:"listbox",id:c,"aria-label":h?"Files and agents":"Commands and skills",className:"absolute left-0 right-0 bottom-full mb-1 z-50 min-w-[260px] flex max-h-60 flex-col rounded-md border border-ink/20 bg-paper shadow-lg text-sm",children:[(0,r.Y)("div",{className:"shrink-0 text-[10px] uppercase tracking-wider text-ink/40 px-3 py-1.5 border-b border-ink/10",children:h?"Type to search files and agents":"Type to search commands and skills"}),(0,r.Y)("div",{className:"flex-1 overflow-y-auto",children:o?(0,r.Y)("div",{className:"px-3 py-2 text-error",children:o}):l&&0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:"Loading…"}):0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:h?"No matching files or agents":"No matching commands or skills"}):s.slice(0,100).map((e,t)=>(0,r.FD)("div",{id:d(t),role:"option","aria-selected":t===a,ref:t===a?m:void 0,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>p(t),onClick:()=>u(e),className:`px-3 py-2 cursor-pointer ${t===a?"bg-ink/10":""}`,children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"truncate",children:(0,r.Y)(ep,{item:e})}),"file"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"file"}),"skill"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"skill"})]}),(0,r.Y)("div",{className:"truncate text-ink/50 text-xs",children:e.description})]},e.id))}),(0,r.Y)("div",{className:"shrink-0 px-3 py-1.5 border-t border-ink/10 text-[10px] text-ink/40",children:"↑↓ navigate · Enter select · Esc close"})]})}function eh(e){let{value:t,onChange:n,onSend:s,disabled:a=!1,appSettings:l,placeholder:o,className:c,onPaste:d,rootPath:u,variant:p="desktop"}=e,m="mobile"===p,h=(0,i.li)(null),f=(0,i.li)(null),x=function(e){let{value:t,setValue:n,textareaRef:r,disabled:s=!1,rootPath:a}=e,[l,o]=(0,i.J0)(null),[c,d]=(0,i.J0)(0),u=(0,i.li)(!1),p=(0,i.li)(null),{items:m,loading:h,error:f}=function(e,t){let[n,r]=(0,i.J0)({items:[],loading:!1,error:null});return(0,i.vJ)(()=>{if(!e)return void r({items:[],loading:!1,error:null});let n=!1;return r({items:[],loading:!0,error:null}),(0,eu.bF)(e,t??null).then(e=>{n||r({items:e,loading:!1,error:null})}).catch(e=>{n||r({items:[],loading:!1,error:e instanceof Error?e.message:String(e)})}),()=>{n=!0}},[e,t]),n}(l?.kind??null,a??null),x=(0,i.Kr)(()=>(function(e,t){let n=t.trim(),r=ed.test(n),i=r?e.filter(e=>"file"===e.source):e,s=r?n.replace(ed,"").trim():n;if(""===s)return i.map(e=>({...e,match:null}));let a=[];return i.forEach((e,t)=>{let n=function(e,t,n){let r=n.trim().toLowerCase();if(""===r)return null;let i=e.toLowerCase(),s=t.toLowerCase();if(i===r)return{tier:0,match:{start:0,end:e.length}};if(i.startsWith(r))return{tier:1,match:{start:0,end:r.length}};let a=i.indexOf(r);return a>=0?{tier:2,match:{start:a,end:a+r.length}}:s.includes(r)?{tier:3,match:null}:null}(e.name,e.description,s);n&&a.push({...n,index:t})}),a.sort((e,t)=>e.tier-t.tier||e.index-t.index),a.map(e=>({...i[e.index],match:e.match}))})(m,l?.query??""),[m,l?.query]),g=x.length>0?Math.min(Math.max(c,0),x.length-1):-1,b=(0,i.Bi)(),v=(0,i.hb)(e=>`${b}-option-${e}`,[b]),k=(0,i.hb)(()=>{o(null),d(0)},[]),y=(0,i.hb)(e=>{d(e)},[]),w=(0,i.hb)(()=>{u.current=!0},[]),N=(0,i.hb)(()=>{u.current=!1},[]),Y=(0,i.hb)(e=>{var t;let r=e.currentTarget,i=r.value,a=r.selectionStart??i.length;if(u.current||!0===(t=e).isComposing||t.inputType?.startsWith("insertFromPaste")===!0||t.inputType?.startsWith("insertFromDrop")===!0){n(i),k();return}(n(i),s)?k():(o(function(e,t){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(/\s/.test(r))break;if("/"===r||"@"===r){if("/"===r){if(0!==t)return null;return{kind:"command",query:e.slice(t+1,n),start:t,end:n}}if(0===t||ec.test(e[t-1]))return{kind:"mention",query:e.slice(t+1,n),start:t,end:n};break}}return null}(i,a)),d(0))},[n,k,s]),D=(0,i.hb)(e=>{var r;if(!l)return;let i=(r=`${e.token} `,{value:t.slice(0,l.start)+r+t.slice(l.end),caret:l.start+r.length});p.current=i.caret,n(i.value),k()},[t,l,n,k]),F=(0,i.hb)(e=>!u.current&&229!==e.keyCode&&!!l&&("ArrowDown"===e.key||"ArrowUp"===e.key?(e.preventDefault(),x.length>0&&d((g+("ArrowDown"===e.key?1:-1)+x.length)%x.length),!0):("Enter"===e.key||"Tab"===e.key)&&x.length>0?(e.preventDefault(),e.stopPropagation(),D(x[g]),!0):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),k(),!0)),[l,x,g,D,k]);return(0,i.Nf)(()=>{if(null==p.current)return;let e=p.current;p.current=null;let t=r.current;t&&(t.focus(),t.setSelectionRange(e,e))},[t,r]),{trigger:l,isOpen:null!==l,matches:x,loading:h,error:f,activeIndex:g,setActiveIndex:y,handleChange:Y,handleCompositionStart:w,handleCompositionEnd:N,handleKeyDown:F,selectItem:D,close:k,listboxId:b,optionId:v}}({value:t,setValue:n,textareaRef:h,disabled:a,rootPath:u});return(0,F.W)(f,x.close),(0,r.FD)("div",{className:"relative",ref:f,children:[(0,r.Y)("textarea",{ref:h,value:t,onChange:x.handleChange,onCompositionStart:x.handleCompositionStart,onCompositionEnd:x.handleCompositionEnd,onKeyDown:e=>{if(x.handleKeyDown(e)||"Enter"!==e.key)return;let t=l?.keybindingSend||"Enter",n=l?.keybindingNewLine||"Shift + Enter",r=l?.keybindingSteering||"Ctrl / Cmd + Enter",i="u">typeof navigator&&navigator.platform.toUpperCase().indexOf("MAC")>=0?e.metaKey:e.ctrlKey,o=e.shiftKey,c=t=>"Enter"===t&&!o&&!i&&!e.altKey||"Shift + Enter"===t&&!!o&&!i&&!e.altKey||"Ctrl / Cmd + Enter"===t&&!o&&!!i&&!e.altKey,d=!o&&!i&&!e.altKey;(!m||!d)&&(c(r)?(e.preventDefault(),a||s({steering:!0})):c(t)?(e.preventDefault(),a||s()):c(n)||e.preventDefault())},onPaste:d,disabled:a,placeholder:o,enterkeyhint:m?"enter":void 0,className:c,"aria-autocomplete":"list","aria-expanded":x.isOpen,"aria-controls":x.listboxId,"aria-haspopup":"listbox","aria-activedescendant":x.isOpen&&x.matches.length>0?x.optionId(x.activeIndex):void 0}),(0,r.Y)(em,{open:x.isOpen,kind:x.trigger?.kind??"mention",items:x.matches,activeIndex:x.activeIndex,loading:x.loading,error:x.error,listboxId:x.listboxId,optionId:x.optionId,onSelect:x.selectItem,onHover:x.setActiveIndex})]})}var ef=n("Bt"),ex=n("HD");function eg(e){let{attachments:t,onFilesSelected:n,onRemove:s}=e,a=(0,i.li)(null);return(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"flex items-center flex-wrap gap-1.5 px-3 py-2 border-b border-ink/5 text-ink/60",children:[(0,r.Y)("button",{onClick:()=>a.current?.click(),className:"flex items-center justify-center hover:bg-ink/5 p-1 rounded transition-colors text-ink/60 hover:text-ink shrink-0",title:"Attach file or image",children:(0,r.Y)(ef.A,{size:14})}),t.map(e=>(0,r.FD)("div",{className:"relative flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-6 text-xs shadow-sm group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"preview",className:"w-6 h-6 object-cover rounded-sm mr-1.5 border border-ink/5"}):(0,r.Y)("div",{className:"w-6 h-6 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(ex.A,{size:12})}),(0,r.Y)("span",{className:"truncate max-w-[120px] font-mono text-[10px] text-ink/80",children:e.file.name}),(0,r.Y)("button",{onClick:()=>s(e.id),className:"absolute right-0.5 top-1/2 -translate-y-1/2 p-0.5 text-ink/40 hover:text-error hover:bg-error/10 rounded transition-colors",title:"Remove attachment",children:(0,r.Y)(j.A,{size:10})})]},e.id))]}),(0,r.Y)("input",{type:"file",multiple:!0,className:"hidden",ref:a,onChange:e=>{e.currentTarget.files&&e.currentTarget.files.length>0&&n(Array.from(e.currentTarget.files)),a.current&&(a.current.value="")}})]})}let eb=["auto","off","minimal","low","medium","high","xhigh","max"];function ev(e){if(!e||0===e.length)return[];let t=new Set(e.filter(e=>e&&"auto"!==e));return[...eb.filter(e=>t.delete(e)),...t]}function ek(e,t,n){let r=ev(e??[]);return t&&(0===r.length||r.includes(t))?t:n??"auto"}function ey(e,t,n){return{id:e.id,name:e.name,provider:e.provider,contextWindow:e.contextWindow,thinkingLevels:e.thinkingLevels,thinkingLevel:ek(e.thinkingLevels,t,n?.thinkingLevel)}}function ew(e){let{value:t,onChange:n,onSend:s,isGenerating:a,onStop:l,className:o="",disabled:c=!1,appSettings:d={},attachments:u,onAttachmentsChange:p,onThinkingLevelChange:m,onModelChange:h,sessionModel:f,sessionThinkingLevel:x,rootPath:g,variant:b="desktop",accessMode:v,onAccessModeChange:k,composerModelRef:y}=e,[w,N]=(0,i.J0)([]),Y=void 0!==u?u:w,D=e=>{p?p(e):N(e)},[F,A]=(0,i.J0)(null),[C,S]=(0,i.J0)("auto");(0,i.vJ)(()=>{F?.id&&(y.current={provider:F.provider,modelId:F.id,thinkingLevel:F.thinkingLevel??"auto"})},[F?.provider,F?.id,F?.thinkingLevel,y]);let z=(0,i.li)(null);z.current=x??null;let $=(0,i.li)(f??null);$.current=f??null,(0,i.vJ)(()=>{if(!f?.provider||!f.modelId)return;let e=!0;return(0,T.xo)().then(t=>{if(!e||!f)return;let n=(t.modelList||[]).find(e=>e.id===f.modelId&&e.provider===f.provider);n&&A(e=>ey(n,z.current,e))}).catch(()=>{}),()=>{e=!1}},[f?.provider,f?.modelId]),(0,i.vJ)(()=>{x&&A(e=>{if(!e)return e;let t=ek(e.thinkingLevels,x,e.thinkingLevel);return t===e.thinkingLevel?e:{...e,thinkingLevel:t}})},[x]),(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,T.xo)();if(!e)return;if(Array.isArray(t.modelList)&&t.modelList.length>0){let e=$.current;if(e?.provider&&e.modelId){let n=t.modelList.find(t=>t.id===e.modelId&&t.provider===e.provider);n&&A(e=>ey(n,z.current,e));return}let n=t.selectedModel;if(n?.provider&&n.id){let e=t.modelList.find(e=>e.id===n.id&&e.provider===n.provider);if(e)return void A(t=>ey(e,z.current,t))}let r=t.defaultModel;if(r){let e=t.modelList.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&A(t=>ey(e,z.current,t))}}else if(t.selectedModel){let e=t.selectedModel;A(t=>({...e,thinkingLevel:ek(e.thinkingLevels,z.current,t?.thinkingLevel??e.thinkingLevel)}))}}catch{}};t();let n=(0,T.Sy)(t);return()=>{e=!1,n()}},[]);let j=(0,i.Kr)(()=>ev(F?.thinkingLevels),[F]);(0,i.vJ)(()=>{F?.thinkingLevel&&S(F.thinkingLevel)},[F?.thinkingLevel]);let L=e=>{let t=e.map(e=>({id:Math.random().toString(36).substring(7),file:e,preview:e.type.startsWith("image/")?URL.createObjectURL(e):""}));for(let e of(D(e=>[...e,...t]),t)){if(!e.file.type.startsWith("image/"))continue;let t=new FileReader;t.onload=()=>{let n=t.result.split(",")[1];n&&D(t=>t.map(t=>t.id===e.id?{...t,dataBase64:n}:t))},t.readAsDataURL(e.file)}},M=e=>{(t.trim()||0!==Y.length)&&(s(Y,e),D([]))},P="mobile"===b;return(0,r.FD)("div",{className:`relative border border-ink/20 rounded-md bg-paper focus-within:border-ink transition-colors flex flex-col shadow-sm ${o}`,children:[(0,r.Y)(eg,{attachments:Y,onFilesSelected:L,onRemove:e=>{D(t=>{let n=t.find(t=>t.id===e);return n&&n.preview&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e)})}}),(0,r.Y)(eh,{value:t,onChange:n,onSend:M,disabled:c,appSettings:d,rootPath:g,placeholder:c?"Please select a workspace above to start prompting...":"@ for files/agents; / for commands and skills; ! for shell; # for snippets (Paste images/files here)",className:`w-full bg-transparent border-none focus:outline-none resize-none text-ink placeholder-ink/40 disabled:opacity-50 disabled:cursor-not-allowed ${P?"px-3 py-3 text-base min-h-[68px] max-h-40":"px-3 py-3 text-sm min-h-[80px]"}`,onPaste:e=>{let t=e.clipboardData;t&&t.files.length>0&&(e.preventDefault(),L(Array.from(t.files)))},variant:b}),(0,r.Y)(eo,{isMobile:P,selectedModel:F,onSelectModel:e=>{A(e),h?.(e.provider,e.id)},thinkingLevels:j,currentThinking:C,onSelectThinking:e=>{S(e),A(t=>t?{...t,thinkingLevel:e}:t),m?.(e)},onThinkingLevelChange:m,isGenerating:a,onStop:l,onSend:()=>M(),sendDisabled:c||!t.trim()&&0===Y.length,accessMode:v,onSelectAccess:k})]})}var eN=n("rD"),eY=n("I"),eD=n("J"),eF=n("p"),eA=n("wU"),eC=n("DT"),eS=n("vp"),eT=n("b0"),ez=n("pH");function e$(e){let{text:t,className:n="flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:s=10,iconClassName:a,copiedIconClassName:l="text-success",label:o,copiedLabel:c="Copied",wrapLabel:d=!1,copiedLabelClassName:u,title:p,onClick:m,resetMs:h=2e3}=e,{copied:f,flagCopied:x}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,[t,n]=(0,i.J0)(!1),r=(0,i.li)(null),s=(0,i.hb)(()=>{n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),e)},[e]);return(0,i.vJ)(()=>()=>{r.current&&clearTimeout(r.current)},[]),{copied:t,flagCopied:s}}(h),g=async e=>{m?.(e),!t||await (0,ez.l)(t)&&x()},b=f?c:o;return(0,r.FD)("button",{type:"button",onClick:g,className:n,title:p,children:[f?(0,r.Y)(D.A,{size:s,className:l}):(0,r.Y)(eT.A,{size:s,className:a}),void 0!==b&&(d?(0,r.Y)("span",{className:f?u:void 0,children:b}):b)]})}function ej(e){let{thinking:t,defaultExpanded:n=!1,showSeparator:s=!1}=e,a="object"==typeof t&&!!t.isGenerating,[l,o]=(0,i.J0)(n||a),c=(0,i.li)(null);(0,i.vJ)(()=>{a&&o(!0)},[a]);let d="string"==typeof t?t:t.thought||"",u=d.match(/<system-notice[^>]*>([\s\S]*?)<\/system-notice>/),p=u?.[1]?.trim()??"",m=d.replace(/<system-notice[^>]*>[\s\S]*?<\/system-notice>/g,"").trim(),h="object"==typeof t?t.duration:void 0,f="object"==typeof t&&t.summary?t.summary:m.slice(0,100)+(m.length>100?"...":"");return((0,i.vJ)(()=>{if(!l||!a)return;let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[l,m,a]),m)?(0,r.FD)("div",{className:`mx-3 ${s?"space-y-1.5":""}`,children:[s&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:"Thinking"}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),(0,r.FD)("div",{className:"overflow-hidden rounded-xl border border-ink/10 bg-paper transition-colors hover:border-ink/20",children:[(0,r.FD)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-ink/[0.03] cursor-pointer select-none","aria-expanded":l,children:[(0,r.Y)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink/70",children:(0,r.Y)(S.A,{size:13})}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[12px] font-semibold tracking-tight text-ink",children:"Thinking"}),a&&(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/60 animate-pulse"})]}),!l&&f&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:f})]}),h&&(0,r.Y)("span",{className:"shrink-0 rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/50",children:h}),(0,r.Y)(Y.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&(0,r.FD)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between pb-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Model Reasoning & Strategy"}),(0,r.Y)(e$,{text:m,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy thinking",wrapLabel:!0,label:"Copy"})]}),p&&(0,r.FD)("div",{className:"mb-2 flex items-start gap-2.5 rounded-lg border border-ink/15 bg-paper px-3 py-2.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-ink/10",children:(0,r.Y)(eC.A,{size:13,className:"text-ink/70"})}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("div",{className:"mb-0.5 text-[9.5px] font-semibold uppercase tracking-[0.12em] text-ink/50",children:"System Notice"}),(0,r.Y)("div",{className:"text-[12px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:p,className:"text-[12px] text-ink/85 leading-relaxed"})})]})]}),(0,r.Y)("div",{ref:c,className:"max-h-72 overflow-auto border-l-2 border-ink/15 py-1 pl-3 text-ink/80 scrollbar-overlay-container scrollbar-overlay-static select-text",children:(0,r.Y)(eS.T,{content:m,className:"text-[12px] leading-relaxed text-ink/85 [&_.code-block]:my-2 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5"})})]})]})]}):null}function eL(e){if(!0===e.synthetic||"skipped"===e.status||"aborted"===e.status)return!0;let t=e.details;return t?.__synthetic===!0||t?.source==="assistant_stop_skipped"||t?.executed===!1}var eM=n("N"),eP=n("Jr"),eE=n("SR"),eR=n("aP"),eI=n("AB"),eO=n("uV"),eJ=n("DK"),e_=n("WO"),eW=n("R"),eK=n("bt"),eU=n("k"),eq=n("wJ"),eB=n("s0");let eH=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][0-9A-B]|\x1b\[[0-9;?]*[A-Za-z]/g;function eG(e){return e?e.includes("\x1b")?e.replace(eH,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n"):e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"):""}let eV=/^[A-Za-z_][A-Za-z0-9_.:-]*/,eZ=/([A-Za-z_:][A-Za-z0-9_.:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;function eQ(e){return"system-reminder"===e||"reminder"===e}function eX(e,t){let n="";for(let r=t;r<e.length;r+=1){let t=e[r];if(n)t===n&&(n="");else if('"'===t||"'"===t)n=t;else if(">"===t)return r}return -1}function e0(e,t){let n=e.slice(t,t+9);if(n.startsWith("\x3c!--")){let n=e.indexOf("--\x3e",t+4);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("<![CDATA["===n){let n=e.indexOf("]]>",t+9);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("!"===e[t+1]||"?"===e[t+1]){let n=eX(e,t+2);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+1}}let r="/"===e[t+1],i=t+(r?2:1),s=eV.exec(e.slice(i,i+64))?.[0];if(!s)return;let a=eX(e,i+s.length);if(-1===a)return;let l=e.slice(i+s.length,a);return r?{kind:"end",name:s,attrs:l,end:a+1}:{kind:"/"===e[a-1]?"self":"start",name:s,attrs:l,end:a+1}}function e1(e){let t=e.search(/\S/);if(-1===t||"<"!==e[t])return;let n=e0(e,t);if(!n||"start"!==n.kind)return;let r=[n.name];for(let t=n.end;t<e.length;){if("<"!==e[t]){t+=1;continue}let i=e0(e,t);if(!i)break;if("start"===i.kind)r.push(i.name);else if("end"===i.kind){if(r.pop()!==i.name)return;if(0===r.length){let r=e.slice(i.end).trim();if(r.startsWith("<"))return;return{tag:n.name,attributes:function(e){let t={};for(let n of e.matchAll(eZ))t[n[1]]=n[2]??n[3]??n[4]??"";return t}(n.attrs),inner:function(e){let t=e.split("\n");for(t.length>1&&!t[0].trim()&&t.shift();t.length>1&&!t[t.length-1].trim();)t.pop();let n=1/0;for(let e of t)e.trim()&&(n=Math.min(n,e.length-e.trimStart().length));return Number.isFinite(n)?0===n?t.join("\n"):t.map(e=>e.slice(Math.min(n,e.length-e.trimStart().length))).join("\n"):""}(e.slice(n.end,t)),...r?{rest:r}:{}}}}t=i.end}}var e5=n("yy"),e2=n("t");function e4(e){let t,{tool:n,icon:s,title:a,subtitle:l,meta:o,isOpen:c,onToggle:d,defaultExpanded:u=!1,alwaysExpanded:p=!1,children:m}=e,[h,f]=(0,i.J0)(u),x=!p,g=p||(void 0!==c?c:h),b=n.status||(n.error?"error":"success"),v="running"===b,k=!!m,y=eL(n);return(0,r.FD)("div",{className:`group overflow-hidden rounded-xl border transition-all duration-200 ${"error"===b&&!y?"border-error/25 bg-error/[0.03]":v?"border-ink/15 bg-paper":y?"border-dashed border-ink/15 bg-paper/60 opacity-80":"border-ink/10 bg-paper hover:border-ink/20"} ${g?"shadow-sm":""}`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{k&&x&&(d?d():f(e=>!e))},disabled:!k||!x,"aria-expanded":g,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${k&&x?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg transition-colors ${"error"===b&&!y?"bg-error/10 text-error":v?"bg-ink/8 text-ink":"bg-ink/5 text-ink/70 group-hover:bg-ink/8"}`,children:s}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:a}),(t="h-1.5 w-1.5 rounded-full","running"===b?(0,r.Y)("span",{className:`${t} bg-ink/60 animate-pulse`}):y?(0,r.Y)("span",{className:`${t} bg-ink/30`}):"error"===b?(0,r.Y)("span",{className:`${t} bg-error`}):(0,r.Y)("span",{className:`${t} bg-success`}))]}),l&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:l})]}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-2",children:[o,function(e){if(eL(e))return(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/50",children:[(0,r.Y)(e5.A,{size:10})," Skipped"]});let t=e.status||(e.error?"error":"success");return"error"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(eF.A,{size:10})," Failed"]}):"running"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/60",children:[(0,r.Y)(e2.A,{size:10,className:"animate-spin"})," Running"]}):(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[10px] font-semibold text-success",children:[(0,r.Y)(D.A,{size:10})," Done"]})}(n),k&&x&&(0,r.Y)(Y.A,{size:14,className:`text-ink/35 transition-transform duration-200 ${g?"rotate-180":""}`})]})]}),g&&k&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3 code-surface",children:m})]})}var e3=n("DU"),e8=n("Po");function e6(e){let{text:t}=e,n=(0,i.Kr)(()=>(function(e){let t=[],n=null;for(let r of e.split(/\r?\n/)){if(r.startsWith("diff --git ")){n&&t.push(n),n=null;continue}if(r.startsWith("--- ")){n?n.oldPath=r.slice(4).replace(/^[ab]\//,""):n={oldPath:r.slice(4).replace(/^[ab]\//,""),newPath:"",lines:[]};continue}if(r.startsWith("+++ ")){n||(n={oldPath:"",newPath:"",lines:[]}),n.newPath=r.slice(4).replace(/^[ab]\//,"");continue}if(!n)if(!(r.startsWith("@@")||r.startsWith("+")||r.startsWith("-")))continue;else n={oldPath:"",newPath:"",lines:[]};r.startsWith("@@")?n.lines.push({kind:"meta",text:r}):r.startsWith("+")&&!r.startsWith("+++")?n.lines.push({kind:"add",text:r.slice(1)}):r.startsWith("-")&&!r.startsWith("---")?n.lines.push({kind:"del",text:r.slice(1)}):n.lines.push({kind:"context",text:r.startsWith(" ")?r.slice(1):r})}return n&&t.push(n),t})(t),[t]),s=(0,e8.w)(),a=(0,i.Kr)(()=>n.map(e=>{let t=(0,e3.sQ)(e.newPath||e.oldPath);return(0,e3.O9)(e.lines.map(e=>"meta"===e.kind?"":e.text).join("\n"),t)}),[n,s]);if(0===n.length)return(0,r.Y)("pre",{className:"max-h-48 overflow-auto whitespace-pre overflow-x-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed text-ink/80 select-text",children:t});let l=n.reduce((e,t)=>{for(let n of t.lines)"add"===n.kind?e.added++:"del"===n.kind&&e.removed++;return e},{added:0,removed:0});return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/60",children:n[0]?.newPath||n[0]?.oldPath||"diff"}),n.length>1&&(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:[n.length," files"]}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[10px]",children:[(0,r.FD)("span",{className:"text-success",children:["+",l.added]}),(0,r.FD)("span",{className:"text-error",children:["-",l.removed]})]})]}),(0,r.Y)("div",{className:"max-h-56 overflow-auto bg-paper font-mono text-[11px] leading-relaxed select-text",children:n.map((e,t)=>(0,r.Y)("div",{className:t>0?"border-t border-ink/6":"",children:e.lines.map((e,n)=>{let i="add"===e.kind?"bg-success/[0.07]":"del"===e.kind?"bg-error/[0.07]":"meta"===e.kind?"bg-ink/[0.04]":"",s="add"===e.kind?"text-success":"del"===e.kind?"text-error":"meta"===e.kind?"text-ink/45":"text-ink/70",l="add"===e.kind?"+":"del"===e.kind?"-":"meta"===e.kind?"@":" ",o=a[t]?.[n]||"";return(0,r.FD)("div",{className:`flex px-2.5 ${i}`,children:[(0,r.Y)("span",{className:`w-4 shrink-0 select-none font-bold ${s}`,children:l}),"meta"!==e.kind&&o?(0,r.Y)("span",{className:"shiki min-w-0 flex-1 whitespace-pre-wrap break-all",dangerouslySetInnerHTML:{__html:o}}):(0,r.Y)("span",{className:`min-w-0 flex-1 whitespace-pre-wrap break-all ${s}`,children:e.text||" "})]},n)})},t))})]})}var e9=n("m"),e7=n("rr"),te=n("F"),tt=n("k8"),tn=n("dg");function tr(e){let{jsonString:t,title:n,maxHeightClass:s,showHeader:a=!0,className:l="",compact:o=!1,icon:c}=e,d=(0,i.Kr)(()=>t.split("\n"),[t]),u=(0,e8.w)(),p=(0,i.Kr)(()=>(0,e3.PH)(t),[t,u]);return(0,r.FD)("div",{className:`overflow-hidden ${o?"rounded-md":"rounded-lg"} border border-ink/8 bg-paper ${l}`,children:[a&&(0,r.FD)("div",{className:`flex items-center justify-between border-b border-ink/6 bg-canvas/40 ${o?"px-2.5 py-1":"px-3 py-1.5"}`,children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0",children:[c||(0,r.Y)(tn.A,{size:o?10.5:11,className:"text-ink/60 shrink-0"}),(0,r.Y)("span",{className:`font-mono ${o?"text-[10px]":"text-[10.5px]"} font-semibold text-ink truncate`,children:n||"JSON"}),(0,r.Y)("span",{className:`rounded bg-ink/5 px-1.5 py-0.2 font-mono ${o?"text-[8.5px]":"text-[9px]"} uppercase tracking-wider text-ink/50 shrink-0`,children:"JSON"}),(0,r.FD)("span",{className:`font-mono ${o?"text-[9px]":"text-[9.5px]"} text-ink/40 shrink-0`,children:[d.length," ",1===d.length?"line":"lines"]})]}),(0,r.Y)(e$,{text:t,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink shrink-0",title:"Copy JSON",onClick:e=>e.stopPropagation(),label:"Copy"})]}),(0,r.FD)("div",{className:`flex ${s||(o?"max-h-40":"max-h-56")} items-start overflow-x-auto font-mono ${o?"text-[10.5px] leading-snug":"text-[11px] leading-relaxed"} select-text`,children:[(0,r.Y)("div",{className:`sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 ${o?"py-1.5 pl-2 pr-1.5 text-[9.5px]":"py-2 pl-2.5 pr-2 text-[10px]"} text-right text-ink/25`,children:d.map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:`flex-1 overflow-x-auto ${o?"p-1.5":"p-2"} whitespace-pre text-ink/85 font-mono`,dangerouslySetInnerHTML:{__html:p}})]})]})}var ti=n("U8");let ts={running:{icon:(0,r.Y)(e2.A,{size:11,className:"animate-spin text-ink/50"}),label:"running"},done:{icon:(0,r.Y)(e9.A,{size:11,className:"text-success"}),label:"done"},failed:{icon:(0,r.Y)(e7.A,{size:11,className:"text-error"}),label:"failed"},aborted:{icon:(0,r.Y)(te.A,{size:11,className:"text-ink/35"}),label:"aborted"}};function ta(e){return"number"==typeof e?(0,ti.Rk)(e)??"":""}function tl(e){return"number"==typeof e?(0,ti.BD)(e,3):""}function to(e){let{tool:t}=e,[n,s]=(0,i.J0)(!1),[a,l]=(0,i.J0)(!0),o=t.details??{},c=Array.isArray(o.results)?o.results:[],d=Array.isArray(o.progress)?o.progress:[],u=(0,i.Kr)(()=>t.output?(0,e3.Bl)(t.output):{isValid:!1},[t.output]),p="object"==typeof t.input&&null!==t.input?t.input:void 0,m="string"==typeof p?.context?p.context.trim():"",h=Array.isArray(p?.tasks)?p.tasks:[],f=(0,i.Kr)(()=>c.length>0?c:d.length>0?d:h.length>0?h.map((e,n)=>({id:`task-sub-${n}`,name:e.name,agent:e.agent||"scout",task:e.task,status:"success"===t.status?"done":"running"})):[],[c,d,h,t.status]);if(0===f.length&&!t.output&&!m)return null;let x=f.reduce((e,t)=>e+("number"==typeof t.tokens?t.tokens:0),0),g=f.reduce((e,t)=>e+("number"==typeof t.cost?t.cost:0),0);return(0,r.FD)("div",{className:"space-y-2.5",children:[f.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 px-2.5 py-1.5",children:[(0,r.FD)("span",{className:"flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(O.A,{size:11,className:"text-ink/60"}),"Subagents"]}),(0,r.FD)("span",{className:"ml-auto font-mono text-[10px] text-ink/45",children:[f.length," ",f.length>1?"agents":"agent",x?` \xb7 ${ta(x)} tok`:"",g?` \xb7 ${tl(g)}`:""]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 px-2.5 py-1",children:f.map((e,t)=>{var n;let i=!0===e.aborted?"aborted":"string"==typeof e.error&&e.error?"failed":"number"==typeof e.exitCode?0===e.exitCode?"done":"failed":"done"===e.status||"completed"===e.status||"success"===e.status?"done":"failed"===e.status?"failed":"aborted"===e.status?"aborted":"running",s=ts[i],a="string"==typeof e.name&&e.name?e.name:null,l="string"==typeof e.agent?e.agent:"scout",o=[ta(e.tokens),tl(e.cost),"running"!==i?"number"!=typeof(n=e.durationMs)||!Number.isFinite(n)||n<1e3?"":`${Math.floor(n/1e3)}s`:""].filter(Boolean).join(" · ");return(0,r.FD)("div",{className:"flex items-center gap-2 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-ink/[0.04]",children:s.icon}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10.5px] font-semibold text-ink",children:a||l}),a&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:l}),(0,r.Y)("span",{className:"ml-auto shrink-0 font-mono text-[9.5px] text-ink/40",children:o||("done"===i?"settled":"running")})]},"string"==typeof e.id?e.id:`row-${t}`)})})]}),m&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(tt.A,{size:11,className:"text-ink/60"}),"Goal & Constraints"]}),(0,r.Y)(Y.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${n?"rotate-180":""}`})]}),n&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/30 px-3 py-2 text-[11.5px] text-ink/80 select-text leading-relaxed",children:(0,r.Y)(eS.T,{content:m})})]}),h.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(eE.A,{size:11,className:"text-ink/60"}),"Task Brief & Specification"]}),(0,r.Y)(Y.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${a?"rotate-180":""}`})]}),a&&(0,r.Y)("div",{className:"divide-y divide-ink/8 border-t border-ink/8 bg-canvas/30",children:h.map((e,t)=>(0,r.FD)("div",{className:"p-3 space-y-1.5 text-[11.5px] text-ink/80 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:"font-semibold text-ink text-[12px]",children:e.name||`Task #${t+1}`}),e.agent&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/60",children:e.agent})]}),e.task&&(0,r.Y)("div",{className:"text-ink/85 leading-relaxed font-sans",children:(0,r.Y)(eS.T,{content:e.task})})]},t))})]}),t.output&&(u.isValid&&u.pretty?(0,r.Y)(tr,{jsonString:u.pretty,title:"Yield Output",maxHeightClass:"max-h-72",showHeader:!0}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 px-2.5 py-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(O.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Yield Output"})]}),(0,r.Y)("div",{className:"bg-canvas/30 px-3 py-2 text-[11px] font-sans leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eS.T,{content:t.output})})]}))]})}function tc(e){let t=e.replace(/:$/,"").trim();return(t=(t=(t=(t=t.replace(/^active\s+phase(?:\s+\d+\/\d+)?(?:\s*[:\-]\s*|\s+)?/i,"")).replace(/^["']|["']$/g,"")).replace(/\s*\(\d+(?:\/\d+)?\s*(?:done|remaining|tasks)?\)$/i,"")).replace(/^\((.+)\)$/,"$1")).trim()||"Tasks"}function td(e){let t,n=e.input,r="object"==typeof n&&null!==n?n:void 0,i=e.output||"";r?.op==="done"&&r.task?t=`Completed: ${r.task}`:r?.op==="init"&&(t="Initialized Todo List");let s=i.split(/\r?\n/),a=[],l={phase:"Tasks",tasks:[]},o=!1;for(let e of s){let t=e.trim();if(!t)continue;if(t.endsWith(":")&&!t.startsWith("Overall")&&!t.startsWith("Remaining")){let e=tc(t);l.tasks.length>0&&a.push(l),l={phase:e,tasks:[]},o=!0;continue}let n=t.match(/^(?:[-*]\s*)?\[([ xX])\]\s*(.+)$/);if(n){let e=n[1].toLowerCase(),t=n[2].trim(),r="x"===e?"done":"pending";(t.includes("(in progress)")||t.includes("[in_progress]"))&&(r="in_progress",t=t.replace(/\(in progress\)/gi,"").replace(/\[in_progress\]/gi,"").trim()),l.tasks.push({text:t,status:r,phase:l.phase});continue}let r=t.match(/^-\s*(.+?)\s*\[(in_progress|pending|done)\](?:\s*\((.+?)\))?$/);if(r&&!o){let e=r[1].trim(),t=r[2],n=tc(r[3]?.trim()||"Tasks"),i=a.find(e=>tc(e.phase).toLowerCase()===n.toLowerCase());i||(i={phase:n,tasks:[]},a.push(i)),i.tasks.push({text:e,status:t,phase:n})}}if(l.tasks.length>0&&!a.includes(l)&&a.push(l),0===a.length&&Array.isArray(r?.list))for(let e of r.list){let t=tc(e.phase||"Tasks"),n=(e.items||[]).map(e=>({text:e,status:"pending",phase:t}));a.push({phase:t,tasks:n})}let c=function(e){let t=new Map;for(let n of e){if(!n.tasks.length)continue;let e=tc(n.phase),r=e.toLowerCase(),i=t.get(r);if(i){let t=n.tasks.length>=i.tasks.length?n.tasks:i.tasks,r=t===n.tasks?i.tasks:n.tasks,s=new Map;for(let n of t)s.set(n.text.toLowerCase().trim(),{...n,phase:e});for(let t of r){let n=t.text.toLowerCase().trim(),r=s.get(n);r?"done"===t.status?r.status="done":"in_progress"===t.status&&"done"!==r.status&&(r.status="in_progress"):s.set(n,{...t,phase:e})}i.phase=e,i.tasks=Array.from(s.values())}else t.set(r,{phase:e,tasks:[...n.tasks]})}let n=Array.from(t.values()),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.tasks.map(e=>e.text.toLowerCase().trim()),s=!1;for(let r=0;r<n.length;r++){if(e===r)continue;let a=n[r],l=new Set(a.tasks.map(e=>e.text.toLowerCase().trim()));if(a.tasks.length>=t.tasks.length&&i.every(e=>l.has(e))){for(let e of t.tasks){let t=a.tasks.find(t=>t.text.toLowerCase().trim()===e.text.toLowerCase().trim());t&&("done"===e.status?t.status="done":"in_progress"===e.status&&"done"!==t.status&&(t.status="in_progress"))}s=!0;break}}s||r.push(t)}return r}(a);if(r?.op==="done"&&r.task){let e=String(r.task).toLowerCase().trim();for(let t of c){let n=t.tasks.find(t=>t.text.toLowerCase().trim()===e);n&&(n.status="done")}}let d=0,u=0,p=0;for(let e of c)for(let t of e.tasks)"done"===t.status?d++:"in_progress"===t.status?u++:p++;let m=d+u+p,h=i.match(/Overall:\s*(\d+)\/(\d+)\s*done/i)||i.match(/(\d+)\s+of\s+(\d+)\s+completed/i);if(h){let e=parseInt(h[1],10),t=parseInt(h[2],10);t>=m&&(d=e,p=Math.max(0,(m=t)-d-u))}let f=[];d>0&&f.push(`${d} complete`),u>0&&f.push(`${u} in progress`),p>0&&f.push(`${p} pending`);let x=f.length>0?f.join(" · "):m>0?`${m} items`:"";return{groups:c,totalDone:d,totalInProgress:u,totalPending:p,totalTasks:m,opBadge:t,summaryText:x}}var tu=n("uF");let tp={github:"GitHub",openai:"OpenAI",gitlab:"GitLab",sqlite:"SQLite",postgresql:"PostgreSQL",mysql:"MySQL",mongodb:"MongoDB",redis:"Redis",docker:"Docker",kubernetes:"Kubernetes",vercel:"Vercel",bun:"Bun",node:"Node",deno:"Deno",react:"React",vue:"Vue",svelte:"Svelte",angular:"Angular",next:"Next",nuxt:"Nuxt",remix:"Remix",tailwind:"Tailwind",prisma:"Prisma",zod:"Zod",axios:"Axios",express:"Express",fastify:"Fastify",koa:"Koa",hono:"Hono",elysia:"Elysia",drizzle:"Drizzle",kysely:"Kysely",biome:"Biome",oxc:"Oxc",rolldown:"Rolldown",turbopack:"Turbopack",vite:"Vite",webpack:"Webpack",rollup:"Rollup",esbuild:"Esbuild",babel:"Babel",swc:"SWC",typescript:"TypeScript",javascript:"JavaScript",coffeescript:"CoffeeScript",dart:"Dart",kotlin:"Kotlin",swift:"Swift",rust:"Rust",python:"Python",ruby:"Ruby",php:"PHP",perl:"Perl",lua:"Lua",scala:"Scala",haskell:"Haskell",elixir:"Elixir",erlang:"Erlang",clojure:"Clojure",ocaml:"OCaml",zig:"Zig",nim:"Nim",crystal:"Crystal",julia:"Julia",groovy:"Groovy",powershell:"PowerShell",bash:"Bash",zsh:"Zsh",fish:"Fish",grep:"Grep",find:"Find",glob:"Glob",ls:"Ls",cat:"Cat",echo:"Echo",mkdir:"Mkdir",rm:"Rm",cp:"Cp",mv:"Mv",touch:"Touch",chmod:"Chmod",chown:"Chown",sudo:"Sudo",apt:"Apt",brew:"Brew",npm:"Npm",pnpm:"Pnpm",yarn:"Yarn",playwright:"Playwright",cypress:"Cypress",puppeteer:"Puppeteer",selenium:"Selenium",jest:"Jest",vitest:"Vitest",mocha:"Mocha",chai:"Chai",sinon:"Sinon",karma:"Karma",jasmine:"Jasmine",qunit:"QUnit",ava:"Ava",tape:"Tape",lodash:"Lodash",underscore:"Underscore",ramda:"Ramda",rxjs:"RxJS",redux:"Redux",zustand:"Zustand",jotai:"Jotai",recoil:"Recoil",mobx:"MobX",xstate:"XState",framer:"Framer",motion:"Motion",gsap:"GSAP",anime:"Anime",three:"Three",babylon:"Babylon",pixi:"Pixi",phaser:"Phaser",matter:"Matter",planck:"Planck",rapier:"Rapier",cannon:"Cannon",ammo:"Ammo",bullet:"Bullet",box2d:"Box2D",chipmunk:"Chipmunk",verlet:"Verlet",ode:"ODE",physx:"PhysX",havok:"Havok",unity:"Unity",unreal:"Unreal",godot:"Godot",bevy:"Bevy",amethyst:"Amethyst",macroquad:"Macroquad",miniquad:"Miniquad",sdl:"SDL",sfml:"SFML",glfw:"GLFW",opengl:"OpenGL",vulkan:"Vulkan",directx:"DirectX",metal:"Metal",webgpu:"WebGPU",webgl:"WebGL",canvas:"Canvas",webaudio:"WebAudio",webmidi:"WebMIDI",webrtc:"WebRTC",websocket:"WebSocket",sse:"SSE",eventsource:"EventSource",fetch:"Fetch",xhr:"XHR",ky:"Ky",got:"Got",undici:"Undici",superagent:"Superagent",request:"Request",needle:"Needle",bent:"Bent",r2:"R2",s3:"S3",gcs:"GCS",azure:"Azure",blob:"Blob",storage:"Storage",firebase:"Firebase",supabase:"Supabase",pocketbase:"PocketBase",appwrite:"Appwrite",nhost:"Nhost",hasura:"Hasura",graphql:"GraphQL",rest:"REST",grpc:"gRPC",trpc:"tRPC",soap:"SOAP",mqtt:"MQTT",amqp:"AMQP",kafka:"Kafka",rabbitmq:"RabbitMQ",pubsub:"PubSub",nats:"NATS",zeromq:"ZeroMQ",dds:"DDS",coap:"CoAP",ble:"BLE",zigbee:"Zigbee",lora:"LoRa",nbiot:"NB-IoT",lte:"LTE",wifi:"Wi-Fi",ethernet:"Ethernet",usb:"USB",hdmi:"HDMI",displayport:"DisplayPort",thunderbolt:"Thunderbolt",pcie:"PCIe",nvme:"NVMe",sata:"SATA",ddr:"DDR",ecc:"ECC",xmp:"XMP",docsis:"DOCSIS",gpon:"GPON",epon:"EPON",pon:"PON",olt:"OLT",ont:"ONT",onu:"ONU",odn:"ODN",p2mp:"P2MP",p2p:"P2P",ftth:"FTTH",fttb:"FTTB",fttc:"FTTC",fttn:"FTTN",hfc:"HFC",dsl:"DSL",adsl:"ADSL",vdsl:"VDSL",sdsl:"SDSL",shdsl:"SHDSL",isdn:"ISDN",pstn:"PSTN",pots:"POTS",voip:"VoIP",sip:"SIP",rtp:"RTP",rtcp:"RTCP",rtsp:"RTSP",hls:"HLS",dash:"DASH",mpeg:"MPEG",av1:"AV1",vp9:"VP9",vp8:"VP8",hevc:"HEVC",avc:"AVC",mp4:"MP4",mkv:"MKV",avi:"AVI",mov:"MOV",wmv:"WMV",flv:"FLV",webm:"WebM",ogg:"OGG",mp3:"MP3",wav:"WAV",flac:"FLAC",aac:"AAC",midi:"MIDI",opus:"OPUS",alac:"ALAC",ape:"APE",wavpack:"WavPack"},tm=new Set(["MCP","AST","LSP","DAP","RPC","SSH","TTS","STT","URL","API","JSON","SQL","CSS","HTML","JS","TS","PDF","PR","UI","UX","DB","CLI","TUI","IDE","HTTP","HTTPS","OAUTH","YAML","XML","CSV","PNG","SVG","WASM","AI","ML","LLM","RAG","SDK","GUI","DOM","ESM","CJS","UMD","IIFE","XHR","TCP","UDP","DNS","IP","GPU","CPU","RAM","SSD","HDD","FIFO","PTY","TTY","WEB"]);function th(e){if(!e)return e;let t=e.split("__"),n=t.length>1?t[0]:null,r=t[t.length-1].split(/[_\-\s]+/).filter(Boolean).map(e=>{let t=tp[e.toLowerCase()];if(t)return t;let n=e.toUpperCase();return tm.has(n)?n:e.charAt(0).toUpperCase()+e.slice(1)}).join(" ");return n?`${n.toUpperCase()} ${r}`:r}function tf(e){var t;let{envelope:n}=e,i=eQ(t=n.tag)?{icon:(0,r.Y)(eB.A,{size:12}),badge:"bg-warning/10 text-warning"}:"error"===t||"failure"===t?{icon:(0,r.Y)(eF.A,{size:12}),badge:"bg-error/10 text-error"}:{icon:(0,r.Y)(J.A,{size:12}),badge:"bg-info/10 text-info"};return(0,r.FD)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.Y)("span",{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded ${i.badge}`,children:i.icon}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/60",children:th(n.tag)}),Object.entries(n.attributes).map(e=>{let[t,n]=e;return(0,r.Y)("span",{title:`${t}=${n}`,className:"max-w-[240px] truncate rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9.5px] text-ink/60",children:n?`${t}=${n}`:t},t)})]})}let tx=/(^|\n)\s*(#{1,6}\s|```|`[^`\n]+`|>|[-*+]\s|\d+\.\s|\[[^\]]+\]\([^)]+\)|\|.*\|)/;function tg(e){let t=e1(e),n=t?[t.inner,t.rest].filter(Boolean).join("\n\n"):e;return{content:n,format:function(e){if(!e)return"text";let t=e.trim();if(!t)return"text";if(t.includes("```"))return"markdown";if(t.length<1e5&&(t.startsWith("{")||t.startsWith("[")))try{let e=JSON.parse(t);if(null!==e&&"object"==typeof e)return"json"}catch{}return tx.test(t)?"markdown":/^<(?:!doctype|html|div|section|article|table|ul|ol|h[1-6]|p|pre|code|span|a|b|strong|em|i|blockquote|form|button|input|img|nav|header|footer|main|aside|figure|figcaption|details|summary|label|select|option|textarea|video|audio|iframe|script|style|link|meta|title|body|head)\b/i.test(t)||/<[a-z][a-z0-9-]*\s[^>]*>[\s\S]*<\/[a-z][a-z0-9-]*>/i.test(t)&&/<\/[a-z][a-z0-9-]*>/i.test(t)?"html":"text"}(n),...t?{envelope:t}:{}}}function tb(e,t){if(!e||"markdown"===t)return e;let n=0;for(let t of e.match(/`+/g)??[])n=Math.max(n,t.length);let r="`".repeat(Math.max(3,n+1));return`${r}${"text"===t?"":t}
8
+ `}w.use((0,a.A)()),w.use({renderer:{code:e=>e.raw&&/^```/.test(e.raw)||(e.text??"").includes("\n")?function(e){let t=e.lang?.trim()||"text",n=e.text??"";if("mermaid"===t){let e,t;return e=`<pre><code class="language-mermaid">${k(n)}</code></pre>`,t=N(n,e),`<div class="mermaid-block" data-mermaid="${encodeURIComponent(n)}" data-mermaid-state="pending">${t}</div>`}let r="text"===t?k(n):(0,o.wY)(n,t);return N(n,`<pre><code class="language-${t}">${r}</code></pre>`)}(e):`<code class="inline-code">${k(e.text??"")}</code>`,codespan:e=>`<code class="inline-code">${k(e.text??"")}</code>`}}),w.use({extensions:[{name:"inlineMath",level:"inline",start:e=>e.match(/\\\(/)?.index,tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);return t?{type:"inlineMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)},{name:"blockMath",level:"block",start:e=>e.match(/^\\\[/)?.index,tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);return t?{type:"blockMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"blockMathDisplay",level:"block",start:e=>e.match(/^\$\$/)?.index,tokenizer(e){let t=/^\$\$([\s\S]+?)\$\$(?:\n|$)/.exec(e);return t?{type:"blockMathDisplay",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"inlineMathDollar",level:"inline",start(e){let t=/(^|[^\w$])\$(?!\$)(?!\s)/.exec(e);return t?t.index+(t[1]?.length??0):void 0},tokenizer(e){let t=/^\$(?!\$)(?!\s)((?:\\\$|[^$])*?)(?<!\s)\$(?!\$)(?!\d)/.exec(e);return t?{type:"inlineMathDollar",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)}]});let Y=/\[([^\]]*)\]\(streamdown:incomplete-link\)/g,D=new Map,F=null,A=null;function C(){let e=document.documentElement.dataset.theme||document.documentElement.getAttribute("data-theme");return"one-dark-pro-soft"===e||"noir"===e||"dark"===e?"dark":"default"}function S(e,t){return`${e}\0${t}`}async function T(e){return F&&A===e||(A=e,F=Promise.all([n.e("a3"),n.e("3y")]).then(n.bind(n,"Fl")).then(t=>(t.default.initialize({startOnLoad:!1,securityLevel:"strict",theme:e,layout:"dagre",suppressErrorRendering:!0,flowchart:{useMaxWidth:!1,wrappingWidth:1e5},sequence:{useMaxWidth:!1}}),t.default)).catch(e=>{throw F=null,e})),F}function z(e,t,n){let r=(e.dataset.mermaid??"").replace(/"/g,"&quot;");e.innerHTML=`<button type="button" class="code-copy-float" data-copy="${r}" aria-label="Copy diagram source" title="Copy diagram source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button>`+t,e.dataset.mermaidState="done",e.dataset.mermaidTheme=n;let i=e.querySelector(":scope > svg"),s=Number(i?.getAttribute("width"));i&&Number.isFinite(s)&&s>0&&e.style.setProperty("--mermaid-diagram-max",`${Math.round(.8*s)}px`)}let $=0;async function j(e,t){let n=e.dataset.mermaid;if(null==n)return!1;let r=C(),i=decodeURIComponent(n),s=D.get(S(r,i))??null;if(s)return z(e,s,r),!0;if(t)return!0;e.dataset.mermaidState="rendering";try{let t=await T(r),{svg:n}=await t.render(`mermaid-svg-${Date.now()}-${$++}`,i);if(!e.isConnected)return!1;let s=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=/href/.test(e);try{return c.A.sanitize(e,{USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},ADD_TAGS:m,ADD_ATTR:[...h,...t?f:[]],HTML_INTEGRATION_POINTS:{"annotation-xml":!0,foreignobject:!0}})}catch{return e}}(n);if(D.size>=60){let e=D.keys().next().value;void 0!==e&&D.delete(e)}return D.set(S(r,i),s),z(e,s,r),!0}catch{return e.isConnected&&(e.dataset.mermaidState="error"),!1}}async function L(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=C(),r=Array.from(e.querySelectorAll(".mermaid-block")),i=await Promise.all(r.map(async e=>{let r=e.dataset.mermaidState,i=e.dataset.mermaidTheme===n;return"done"===r&&!!i&&!t.force||"rendering"!==r&&j(e,!0===t.cachedOnly)}));return{rendered:i.filter(Boolean).length,failed:i.filter(e=>!e).length}}var M=n("pH"),P=n("Po"),E=n("G"),R=n("DV"),I=n("r"),O=n("C"),J=n("S");let _=e=>Math.min(8,Math.max(.1,e));function W(e){let{svg:t,width:n,height:s,onClose:a}=e,l=(0,i.li)(null),o=(0,i.li)(null),[c,d]=(0,i.J0)({scale:1,x:0,y:0}),[u,p]=(0,i.J0)(1),[m,h]=(0,i.J0)(!1),f=(0,i.hb)(()=>{let e=l.current?.getBoundingClientRect();return e?_(Math.min(1,(e.width-112)/n,(e.height-112)/s)):1},[n,s]),x=(0,i.hb)(()=>{let e=f();p(e),d({scale:e,x:0,y:0})},[f]);(0,i.Nf)(()=>{x()},[x]),(0,i.vJ)(()=>{let e=document.activeElement;return l.current?.focus(),()=>e?.focus()},[]);let g=(0,i.hb)((e,t,n)=>{d(r=>{let i=l.current?.getBoundingClientRect(),s=t??(i?i.left+i.width/2:0),a=n??(i?i.top+i.height/2:0);return function(e,t,n,r,i){let s=_(t);if(s===e.scale)return e;let a=i?n-(i.left+i.width/2):0,l=i?r-(i.top+i.height/2):0,o=s/e.scale;return{scale:s,x:a-(a-e.x)*o,y:l-(l-e.y)*o}}(r,r.scale*e,s,a,i)})},[]),b=(0,i.hb)(e=>{e.preventDefault(),g(Math.exp(-(.0015*e.deltaY)),e.clientX,e.clientY)},[g]),v=(0,i.hb)(e=>{0===e.button&&(o.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture(e.pointerId),h(!0))},[]),k=(0,i.hb)(e=>{let t=o.current;if(!t||t.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;t.x=e.clientX,t.y=e.clientY,d(e=>({...e,x:e.x+n,y:e.y+r}))},[]),y=(0,i.hb)(e=>{o.current?.pointerId===e.pointerId&&(o.current=null,h(!1))},[]),w=(0,i.hb)(()=>{d(e=>.01>Math.abs(e.scale-1)?{scale:u,x:0,y:0}:{scale:1,x:0,y:0})},[u]);(0,i.vJ)(()=>{let e=e=>{if("Escape"===e.key){e.preventDefault(),a();return}if("+"===e.key||"="===e.key){e.preventDefault(),g(1.4);return}if("-"===e.key||"_"===e.key){e.preventDefault(),g(1/1.4);return}"0"===e.key&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,g,x]),(0,i.vJ)(()=>{let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[]);let N={width:`${n}px`,height:`${s}px`,transform:`translate3d(${c.x}px, ${c.y}px, 0) scale(${c.scale})`};return(0,E.d5)((0,r.FD)("div",{className:"fixed inset-0 z-[200] bg-ink/85 backdrop-blur-sm",role:"dialog","aria-modal":"true","aria-label":"Diagram viewer",onWheel:b,children:[(0,r.Y)("div",{ref:l,tabIndex:-1,className:`diagram-viewer-stage absolute inset-0 overflow-hidden outline-none ${m?"cursor-grabbing":"cursor-grab"}`,onPointerDown:v,onPointerMove:k,onPointerUp:y,onPointerCancel:y,onDblClick:w,children:(0,r.Y)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.Y)("div",{className:"diagram-viewer-canvas",style:N,dangerouslySetInnerHTML:{__html:t}})})}),(0,r.Y)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pb-4",children:(0,r.FD)("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-canvas/15 bg-paper/10 px-1.5 py-1 text-canvas backdrop-blur-sm",children:[(0,r.Y)(K,{label:"Zoom out (-)",onClick:()=>g(1/1.4),children:(0,r.Y)(R.A,{size:14})}),(0,r.FD)("span",{className:"w-12 text-center font-mono text-[11px] tabular-nums text-canvas/80",children:[Math.round(100*c.scale),"%"]}),(0,r.Y)(K,{label:"Zoom in (+)",onClick:()=>g(1.4),children:(0,r.Y)(I.A,{size:14})}),(0,r.Y)(K,{label:"Fit to view (0)",onClick:x,children:(0,r.Y)(O.A,{size:14})}),(0,r.Y)(K,{label:"Close (Esc)",onClick:a,children:(0,r.Y)(J.A,{size:14})})]})})]}),document.body)}function K(e){let{label:t,onClick:n,children:i}=e;return(0,r.Y)("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-canvas/80 transition-colors hover:bg-canvas/10 hover:text-canvas",children:i})}function U(e){var t;let n,r,i=e.querySelector(":scope > svg");return i?{svg:i.outerHTML,...(t=i,n=t.viewBox?.baseVal,r=t.getBoundingClientRect(),{width:B(t.getAttribute("width"),n?.width,r.width),height:B(t.getAttribute("height"),n?.height,r.height)})}:null}function B(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];for(let e of t){let t="number"==typeof e?e:Number.parseFloat(e??"");if(Number.isFinite(t)&&t>0)return t}return 1}let q="u"<typeof window?i.vJ:i.Nf;function H(e){let{content:t,className:n=""}=e,s=(0,i.li)(null),a=(0,i.li)(null),[o,m]=(0,i.J0)(null),h=(0,P.w)(),f=(0,i.Kr)(()=>{let e,n;if(!t)return"";let r=(e=t.split("`").map((e,t)=>t%2==1?e:e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")).join("`"),n=(0,l.Ay)(e,{katex:!0,inlineKatex:!0}).replace(Y,(e,t)=>`<span class="md-incomplete-link">${t}</span>`),w.parse(n).trim());if(r.includes(g)&&b(),!r||"u"<typeof window||!window.document)return r;let i=/<svg[^>]*>/.test(r),s=r.includes("math-pending"),a=/class="[^"]*katex/.test(r)||i||s?{USE_PROFILES:{html:!0,mathMl:!0},ADD_TAGS:[...d,...i?u:[]],ADD_ATTR:["aria-hidden","aria-label","encoding","nonce","data-math","data-math-display",...i?p:[]]}:{USE_PROFILES:{html:!0}};try{return c.A.sanitize(r,a)}catch{return r}},[t,h]),x=f.includes("mermaid-block"),k=f.includes(g);(0,i.vJ)(()=>{if(!k||"u"<typeof window)return;let e=s.current;if(!e)return;let t=!1;(async()=>{if(e.isConnected&&(await v(e),t))return})();let n=new MutationObserver(()=>{let e=s.current;e?.isConnected&&v(e)});return n.observe(e,{childList:!0}),()=>{t=!0,n.disconnect()}},[k,f]),q(()=>{let e;if(!x||"u"<typeof window)return;let t=s.current;if(!t)return;let n=async()=>{let e=s.current;e&&e.isConnected&&await L(e)};n();let r=new MutationObserver(()=>{let t=s.current;t?.isConnected&&L(t,{cachedOnly:!0}),window.clearTimeout(e),e=window.setTimeout(()=>void n(),120)});r.observe(t,{childList:!0});let i=async()=>{await n();let e=a.current;if(!e?.isConnected)return;let t=U(e);t&&m(t)},l=new MutationObserver(()=>void i());return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{window.clearTimeout(e),r.disconnect(),l.disconnect()}},[x,f]);let y=(0,i.hb)(e=>{let t=e.target.closest("button.code-copy-float");if(t){let n=t.dataset.copy??"";if(!n)return;e.preventDefault(),e.stopPropagation(),(0,M.l)(n).then(e=>{e&&(t.setAttribute("data-copied","true"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',setTimeout(()=>{t.removeAttribute("data-copied"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'},2e3))});return}let n=e.target.closest('.mermaid-block[data-mermaid-state="done"]');if(!n)return;let r=U(n);r&&(e.preventDefault(),a.current=n,m(r))},[]),N=(0,i.hb)(()=>{a.current=null,m(null)},[]);return t?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{ref:s,className:`prose-content text-[13px] text-ink leading-relaxed select-text ${n}`,onClick:y,dangerouslySetInnerHTML:{__html:f}}),o&&(0,r.Y)(W,{...o,onClose:N})]}):null}},R2(e,t,n){var r=n("j");function i(e){let{status:t}=e;if(t?.transport!=="websocket")return null;let n=!!t.connected,i=n?"WebSocket connected":"WebSocket disconnected";return(0,r.Y)("span",{role:"status","aria-label":i,title:i,className:"flex items-center flex-shrink-0 select-none",children:(0,r.Y)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${n?"bg-success":"bg-error"}`})})}n.d(t,{c:()=>i})},Uo(e,t,n){var r=n("j"),i=n("m"),s=n("p"),a=n("F"),l=n("V");function o(e){let{status:t,live:n,size:o=12}=e,c={size:o,strokeWidth:2,"aria-hidden":!0};if("completed"===t)return(0,r.Y)(i.A,{...c,className:"text-success"});if("failed"===t)return(0,r.Y)(s.A,{...c,className:"text-error"});if("aborted"===t)return(0,r.Y)(a.A,{...c,className:"text-ink/40"});if(!1===n)return(0,r.Y)(l.A,{...c,className:"text-ink/30"});let d=Math.max(5,Math.round(o/2));return(0,r.Y)("span",{"aria-hidden":!0,className:"inline-block shrink-0 animate-pulse rounded-full bg-success",style:{width:d,height:d}})}n.d(t,{l:()=>o})},wu(e,t,n){n.d(t,{y:()=>d});var r=n("j"),i=n("H"),s=n("G"),a=n("p"),l=n("m"),o=n("S");function c(e){let{toast:t,onDismiss:n,duration:c}=e,[d,u]=(0,i.J0)(!1),p=c??t.duration??4e3,m=(0,i.li)(null);return(0,i.vJ)(()=>{let e=requestAnimationFrame(()=>u(!0)),r=setTimeout(()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},p);return()=>{cancelAnimationFrame(e),clearTimeout(r),m.current&&clearTimeout(m.current)}},[t.id,p,n]),(0,s.d5)((0,r.FD)("div",{className:`fixed bottom-4 right-4 z-[200] flex items-center space-x-2 bg-paper border shadow-2xl rounded-lg px-4 py-3 text-xs font-sans transition-all duration-200 ${"error"===t.type?"border-error/40":"border-ink/15"} ${d?"opacity-100 translate-y-0":"opacity-0 translate-y-2"}`,role:"status",children:["error"===t.type?(0,r.Y)(a.A,{size:15,className:"text-error flex-shrink-0"}):(0,r.Y)(l.A,{size:15,className:"text-success flex-shrink-0"}),(0,r.Y)("span",{className:"text-ink max-w-[320px]",children:t.message}),t.action&&(0,r.Y)("button",{type:"button",onClick:()=>{t.action?.onClick(),u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"flex-shrink-0 px-2 py-0.5 rounded bg-ink text-paper font-semibold hover:opacity-80 transition-opacity",children:t.action.label}),(0,r.Y)("button",{type:"button",onClick:()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"text-ink/40 hover:text-ink transition-colors flex-shrink-0",title:"Dismiss",children:(0,r.Y)(o.A,{size:13})})]}),document.body)}function d(e){let{toasts:t,onDismiss:n}=e;return(0,r.Y)(r.FK,{children:t.map(e=>(0,r.Y)(c,{toast:e,onDismiss:n},e.id))})}},nG(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("dc")]).then(n.bind(n,"fy")).then(e=>({default:e.FileExplorer}))),a=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("1k")]).then(n.bind(n,"X8")).then(e=>({default:e.SearchPanel}))),l=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("m")]).then(n.bind(n,"ABt")).then(e=>({default:e.GitPanel}))),o=(0,i.RZ)(()=>n.e("ot").then(n.bind(n,"SA")).then(e=>({default:e.TerminalPanel}))),c=(0,i.RZ)(()=>n.e(51).then(n.bind(n,"zO")).then(e=>({default:e.ContextPanel}))),d=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("s")]).then(n.bind(n,"a6")).then(e=>({default:e.BrowserPanel}))),u=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("rd")]).then(n.bind(n,"NU")).then(e=>({default:e.UserBrowserPanel}))),p=(0,i.RZ)(()=>Promise.all([n.e("ma"),n.e("bi")]).then(n.bind(n,"Rc")).then(e=>({default:e.UsagePanel}))),m=new WeakMap;function h(e,t){let n=m.get(e);if(n||(n={},m.set(e,n)),!n[t]){let e="files"===t?s:"search"===t?a:"git"===t?l:"terminal"===t?o:"context"===t?c:"user-browser"===t?u:"browser"===t?d:p,i=t=>{let{className:n,...i}=t;return(0,r.Y)("div",{className:`w-full h-full ${"string"==typeof n?n:""}`,children:(0,r.Y)(e,{...i,className:"w-full h-full"})})};i.displayName=`CachedView(${t})`,n[t]=i}return n[t]}n.d(t,{SU:()=>h},{Bz:o,M:u,N1:a,WE:p,XL:d,gI:s,nR:l,ov:c})},E(e,t,n){n.d(t,{i:()=>l});var r=n("j"),i=n("z");let s=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],a={"A-Z":"A-Z","Z-A":"Z-A",LATEST_SESSION:"Latest Session",LATEST_ADDED:"Latest Added"};function l(e){let{variant:t,sortOption:n,onSortChange:l}=e;return"mobile"===t?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>l(e),className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${n===e?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[(0,r.Y)("span",{children:e.replace("_"," ")}),n===e&&(0,r.Y)(i.A,{size:13,className:"text-ink"})]},e))]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase font-bold text-ink/40 tracking-wider",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("div",{className:`px-3 py-1.5 text-xs cursor-pointer flex items-center justify-between ${n===e?"bg-ink/5 text-ink font-medium":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,onClick:()=>l(e),children:[(0,r.Y)("span",{children:a[e]}),n===e&&(0,r.Y)("div",{className:"w-1.5 h-1.5 rounded-full bg-ink"})]},e))]})}},C4(e,t,n){var r=n("j"),i=n("mO"),s=n("Wi"),a=n("a");function l(e){let{variant:t,isPinned:n=!1,confirmDelete:l,onPin:o,onDelete:c,onRequestDelete:d,onCancelDelete:u}=e;return"mobile"===t?l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-2 text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("button",{type:"button",onClick:u,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/70",children:"Cancel"})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("button",{type:"button",onClick:o,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[n?(0,r.Y)(s.A,{size:13}):(0,r.Y)(a.A,{size:13}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("button",{type:"button",onClick:d,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Delete Workspace"})]})]}):l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-xs text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:c,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/70",onClick:u,children:(0,r.Y)("span",{children:"Cancel"})})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",onClick:o,children:[n?(0,r.Y)(s.A,{size:12}):(0,r.Y)(a.A,{size:12}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:d,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Delete Workspace"})]})]})}n.d(t,{t:()=>l})},g(e,t,n){n.d(t,{VT:()=>T,xV:()=>z,Lo:()=>$,bB:()=>f.b});var r=n("j"),i=n("H"),s=n("S"),a=n("w"),l=n("Y"),o=n("o"),c=n("r"),d=n("lP"),u=n("C"),p=n("W"),m=n("N"),h=n("YL"),f=n("u"),x=n("Nf"),g=n("t"),b=n("n"),v=n("g6");async function k(e){let t=e?`?path=${encodeURIComponent(e)}`:"",n=await fetch(`/api/fs/browse${t}`),r=await n.json();if(!n.ok||r.error)throw Error(r.error||`HTTP ${n.status}`);return r}function y(e){let{initialPath:t,onSelect:n,onClose:o}=e,[c,d]=(0,i.J0)(t??""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)([]),[f,y]=(0,i.J0)(null),[w,N]=(0,i.J0)(!0),[Y,D]=(0,i.J0)(null),[F,A]=(0,i.J0)(null),C=(0,i.li)(null),S=(0,i.hb)(async e=>{N(!0),D(null);try{let t=await k(e);d(t.path??e??""),y(t.parentPath??null),p(t.path??e??""),h(t.directories??[])}catch(e){D(e instanceof Error?e.message:String(e))}finally{N(!1)}},[]);(0,i.vJ)(()=>{S(t)},[t,S]);let T=e=>{S(e.path)};return(0,r.Y)("div",{className:"fixed inset-0 bg-ink/30 z-[60] flex items-center justify-center p-4",onClick:o,children:(0,r.FD)("div",{className:"bg-paper border border-ink/15 rounded-lg shadow-2xl w-full max-w-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[(0,r.FD)("h3",{className:"font-semibold text-sm flex items-center space-x-2",children:[(0,r.Y)(l.A,{size:15,className:"text-ink/70"}),(0,r.Y)("span",{children:"Choose Project Folder"})]}),(0,r.Y)("button",{type:"button",onClick:o,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors","aria-label":"Close picker",children:(0,r.Y)(s.A,{size:15})})]}),(0,r.FD)("div",{className:"px-4 py-2 border-b border-ink/10 bg-canvas/50",children:[(0,r.FD)("form",{onSubmit:e=>{e.preventDefault();let t=u.trim();t&&S(t)},className:"flex items-center space-x-2",children:[(0,r.Y)(a.A,{size:14,className:"text-ink/40 flex-shrink-0"}),(0,r.Y)("input",{ref:C,type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~ or /absolute/path",className:"flex-1 bg-transparent outline-none text-xs font-mono text-ink placeholder-ink/30 py-1",spellcheck:!1}),(0,r.Y)("button",{type:"submit",className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Go"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 mt-1 text-[11px] text-ink/40 truncate",children:[(0,r.FD)("button",{type:"button",onClick:()=>void S(),className:"hover:text-ink transition-colors flex items-center",children:[(0,r.Y)(a.A,{size:11,className:"mr-0.5"})," home"]}),c.split("/").filter(Boolean).map((e,t,n)=>{let i="/"+c.split("/").filter(Boolean).slice(0,t+1).join("/"),s=t===n.length-1;return(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0",children:[(0,r.Y)(x.A,{size:10,className:"text-ink/20 flex-shrink-0"}),s?(0,r.Y)("span",{className:"text-ink/70 truncate",children:e}):(0,r.Y)("button",{type:"button",onClick:()=>void S(i),className:"hover:text-ink transition-colors truncate max-w-[120px]",children:e})]},i)})]})]}),(0,r.Y)("div",{className:"flex-1 min-h-[240px] max-h-[360px] scrollbar-overlay-container scrollbar-overlay-static p-2",children:w?(0,r.Y)("div",{className:"flex items-center justify-center h-40 text-ink/40",children:(0,r.Y)(g.A,{size:18,className:"animate-spin"})}):Y?(0,r.FD)("div",{className:"flex flex-col items-center justify-center h-40 text-xs text-red-600 space-y-2 px-4",children:[(0,r.Y)("span",{children:Y}),(0,r.FD)("button",{type:"button",onClick:()=>void S(c||void 0),className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[(0,r.Y)(b.A,{size:11})," Retry"]})]}):0===m.length?(0,r.Y)("div",{className:"text-center py-16 text-xs text-ink/40",children:"No subfolders"}):m.map(e=>(0,r.FD)("div",{className:`group flex items-center justify-between px-2.5 py-2 rounded cursor-pointer transition-colors ${F===e.path?"bg-ink/10":"hover:bg-ink/5"}`,onDblClick:()=>T(e),children:[(0,r.FD)("button",{type:"button",onClick:()=>T(e),className:"flex items-center space-x-2 min-w-0 flex-1 text-left",children:[(0,r.Y)(v.A,{size:15,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"text-xs truncate text-ink/85",children:e.name})]}),(0,r.Y)("button",{type:"button",onClick:()=>{A(e.path),n(e.path)},className:"hidden group-hover:flex px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-semibold hover:bg-ink/80 transition-colors flex-shrink-0",children:"Choose"})]},e.path))}),(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-ink/10",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("button",{type:"button",onClick:()=>{f&&S(f)},disabled:!f,className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1",children:[(0,r.Y)("span",{children:"↑"}),(0,r.Y)("span",{children:"Up"})]}),(0,r.Y)("button",{type:"button",onClick:()=>void S(),className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Home"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.Y)("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),(0,r.Y)("button",{type:"button",onClick:()=>{c&&(A(c),n(c))},disabled:!c,className:"px-3.5 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 disabled:opacity-50 transition-colors",children:"Use This Folder"})]})]})]})})}var w=n("P");function N(){return(0,r.FD)("div",{className:"flex flex-col items-center gap-3 mt-6 pt-1",children:[(0,r.FD)("div",{className:"flex items-center justify-center gap-6",children:[(0,r.FD)("a",{href:"https://github.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),(0,r.Y)("span",{children:"GitHub"})]}),(0,r.FD)("a",{href:"https://discord.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994.021-.041.001-.09-.041-.106a13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.929 1.793 8.18 1.793 12.061 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.894.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.028zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})}),(0,r.Y)("span",{children:"Discord"})]})]}),(0,r.FD)("a",{href:"https://x.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),(0,r.Y)("span",{children:"@ompchamber"})]})]})}var Y=n("tC"),D=n("p"),F=n("z");let A="inline-flex items-center gap-1.5 rounded-md border border-ink/20 px-2.5 py-1.5 text-[11px] font-medium text-ink transition-colors hover:border-ink/40 disabled:cursor-not-allowed disabled:opacity-50";function C(e){let{target:t,info:n,applying:i,disabled:s,onApply:a}=e,l=`v${n.current??"…"} → v${n.latest??"…"}`;return(0,r.FD)("div",{className:"flex items-center justify-between gap-3 border-t border-ink/10 py-2.5 first:border-t-0",children:[(0,r.FD)("div",{className:"min-w-0",children:[(0,r.Y)("p",{className:"text-xs font-medium text-ink",children:"ompchamber"===t?"OMPChamber":"Oh-My-Pi"}),(0,r.Y)("p",{className:"font-mono text-[10px] text-ink/60",children:n.installed?l:"not detected"})]}),n.installed?(0,r.FD)("button",{type:"button",onClick:()=>a(t),disabled:s,className:A,children:[i?(0,r.Y)(g.A,{size:12,className:"animate-spin motion-reduce:animate-none"}):(0,r.Y)(Y.A,{size:12}),(0,r.Y)("span",{children:"Update"})]}):(0,r.Y)("span",{className:"shrink-0 text-[10px] text-ink/40",children:"not detected"})]})}function S(e){let{updates:t,onToast:n}=e,i=t.info?[{target:"ompchamber",info:t.info.ompchamber},{target:"omp",info:t.info.omp}].filter(e=>{let{info:t}=e;return t.updateAvailable&&null!==t.latest}):[],s=async e=>{let r=await t.apply(e);if(n){if(!r)return void n("The update request could not be completed.","error");if("ompchamber"===e)return void n(r.message,r.success?"success":"error");r.success?n(`${r.message} A restart may be needed.`,"success"):n(r.message,"error")}},a=!!(t.info&&!t.checking&&!t.error);return(0,r.FD)("section",{className:"mt-5 border-y border-ink/10 py-3 text-left","aria-labelledby":"updates-heading",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.Y)("h3",{id:"updates-heading",className:"text-xs font-semibold text-ink",children:"Updates"}),t.info&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:"checked"})]}),(0,r.FD)("div",{className:"mt-2.5",children:[t.checking&&(0,r.FD)("button",{type:"button",disabled:!0,className:`${A} w-full justify-center`,children:[(0,r.Y)(g.A,{size:13,className:"animate-spin motion-reduce:animate-none"}),(0,r.Y)("span",{children:"Checking…"})]}),t.error&&!t.checking&&(0,r.FD)("div",{className:"flex items-start gap-2",children:[(0,r.Y)(D.A,{size:14,className:"mt-0.5 shrink-0 text-error"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("p",{className:"text-[11px] leading-4 text-error",children:t.error}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} mt-2`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Retry"})]})]})]}),!t.info&&!t.checking&&!t.error&&(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} w-full justify-center`,children:[(0,r.Y)(b.A,{size:13}),(0,r.Y)("span",{children:"Check for updates"})]}),a&&0===i.length&&(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.FD)("p",{className:"flex items-center gap-1.5 text-[11px] text-success",children:[(0,r.Y)(F.A,{size:13}),(0,r.Y)("span",{children:"You're up to date"})]}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:A,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]}),a&&i.length>0&&(0,r.FD)("div",{children:[i.map(e=>{let{target:n,info:i}=e;return(0,r.Y)(C,{target:n,info:i,applying:t.applying===n,disabled:null!==t.applying,onApply:e=>void s(e)},n)}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),disabled:null!==t.applying,className:`${A} mt-2 w-full justify-center`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]})]})]})}function T(e){let{isOpen:t,onClose:n,updates:i,onToast:a}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/40 backdrop-blur-[2px] z-50 flex items-center justify-center p-4 animate-in fade-in duration-200",onClick:n,children:(0,r.FD)("div",{className:"relative bg-paper border border-ink/15 rounded-2xl shadow-2xl w-full max-w-[340px] p-6 text-center text-ink select-none",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{onClick:n,className:"absolute top-4 right-4 text-ink/40 hover:text-ink transition-colors p-1 rounded-md","aria-label":"Close",children:(0,r.Y)(s.A,{size:18,className:"stroke-[2.5]"})}),(0,r.Y)("div",{className:"flex justify-center pt-2 pb-1",children:(0,r.Y)("img",{src:"/icon.svg",alt:"OMPChamber",width:96,height:96,draggable:!1})}),(0,r.FD)("h2",{className:"text-xl font-bold tracking-tight mt-3 flex items-center justify-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-2xl tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"text-ink text-2xl font-bold ml-[1px]",children:"Chamber"})]}),(0,r.FD)("div",{className:"text-xs text-ink/60 space-y-1 mt-1.5 font-mono",children:[(0,r.FD)("p",{children:["OMPChamber v",w.rE]}),(0,r.FD)("p",{children:["Oh-My-Pi ",i.info?.omp.current??"…"]})]}),(0,r.Y)(S,{updates:i,onToast:a}),(0,r.Y)(N,{}),(0,r.Y)("p",{className:"text-[11px] text-ink/50 font-normal mt-8",children:"Made with love for the community"})]})}):null}function z(e){let{isOpen:t,onClose:n,onCreate:o}=e,[c,d]=(0,i.J0)(""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)(!1),[f,x]=(0,i.J0)(null),[g,b]=(0,i.J0)(!1);if((0,i.vJ)(()=>{t&&(d(""),p(""),h(!1),x(null),b(!1))},[t]),!t)return null;let v=async()=>{if(!o)return void n();if(!c.trim()&&!u.trim())return void x("Enter a name or a project path.");h(!0),x(null);try{await o({name:c.trim(),path:u.trim()||void 0}),n()}catch(e){x(e instanceof Error?e.message:String(e)),h(!1)}};return(0,r.FD)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center",children:[(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-96 p-4 flex flex-col",children:[(0,r.FD)("div",{className:"flex justify-between items-center mb-4 border-b border-ink/10 pb-2",children:[(0,r.Y)("h3",{className:"font-semibold text-sm",children:"New Workspace"}),(0,r.Y)(s.A,{size:14,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.FD)("div",{className:"text-sm text-ink/80 py-2 space-y-3",children:[(0,r.FD)("div",{children:[(0,r.Y)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:"Workspace Name"}),(0,r.Y)("input",{type:"text",value:c,onChange:e=>d(e.currentTarget.value),placeholder:"e.g. bofis-pro",className:"w-full bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm"})]}),(0,r.FD)("div",{children:[(0,r.FD)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Project Path ",(0,r.Y)("span",{className:"text-ink/40 font-normal",children:"(optional — binds omp sessions)"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.FD)("div",{className:"flex-1 flex items-center bg-paper border border-ink/20 rounded overflow-hidden focus-within:border-ink/50",children:[(0,r.Y)("div",{className:"px-2 text-ink/40 bg-ink/5 h-full flex items-center border-r border-ink/10",children:(0,r.Y)(a.A,{size:14})}),(0,r.Y)("input",{type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~/projects/my-project",className:"w-full px-3 py-2 outline-none text-sm bg-transparent"})]}),(0,r.FD)("button",{type:"button",onClick:()=>b(!0),className:"px-3 py-2 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 transition-colors flex items-center space-x-1.5 flex-shrink-0",children:[(0,r.Y)(l.A,{size:13}),(0,r.Y)("span",{children:"Browse"})]})]})]}),f&&(0,r.Y)("div",{className:"text-xs text-red-600",children:f})]}),(0,r.FD)("div",{className:"mt-4 flex justify-end space-x-2",children:[(0,r.Y)("button",{className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",onClick:n,disabled:m,children:"Cancel"}),(0,r.Y)("button",{className:"px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-50",onClick:v,disabled:m,children:m?"Creating…":"Create Workspace"})]})]}),g&&(0,r.Y)(y,{initialPath:u||void 0,onSelect:e=>{if(p(e),b(!1),!c.trim()){let t=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||"";t&&d(t)}},onClose:()=>b(!1)})]})}function $(e){let{isOpen:t,onClose:n}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center p-4",children:(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-full max-w-2xl flex flex-col overflow-hidden",children:[(0,r.FD)("div",{className:"flex justify-between items-center p-4 border-b border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 text-ink",children:[(0,r.Y)(o.A,{size:16}),(0,r.Y)("h3",{className:"font-semibold text-sm",children:"Schedule Chat / Task"})]}),(0,r.Y)(s.A,{size:16,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.Y)("div",{className:"p-4 bg-canvas",children:(0,r.FD)("div",{className:"w-full bg-paper border border-ink/20 rounded-md focus-within:border-ink transition-colors flex flex-col shadow-sm",children:[(0,r.FD)("div",{className:"flex items-center px-3 py-2 border-b border-ink/5 text-ink/60 space-x-2",children:[(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(c.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(d.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(u.A,{size:14})}),(0,r.Y)("div",{className:"flex-1"}),(0,r.FD)("div",{className:"flex items-center space-x-2 text-xs text-ink",children:[(0,r.Y)("span",{className:"font-medium",children:"Schedule:"}),(0,r.FD)("select",{className:"bg-transparent border border-ink/20 rounded px-1.5 py-0.5 outline-none focus:border-ink/50",children:[(0,r.Y)("option",{value:"once",children:"Once"}),(0,r.Y)("option",{value:"every",children:"Every"}),(0,r.Y)("option",{value:"cron",children:"Cron"})]}),(0,r.Y)("input",{type:"text",placeholder:"e.g. 5 mins, 0 0 * * *",className:"w-32 bg-transparent border border-ink/20 rounded px-2 py-0.5 outline-none focus:border-ink/50"})]})]}),(0,r.Y)("textarea",{placeholder:"Describe your scheduled task, ask a question, or paste commands...",className:"w-full bg-transparent border-none px-4 py-4 text-sm focus:outline-none resize-none text-ink placeholder-ink/40 min-h-[120px]"}),(0,r.FD)("div",{className:"flex items-center justify-between px-3 py-2 border-t border-ink/5",children:[(0,r.FD)("div",{className:"flex items-center space-x-3 text-ink/60 text-xs",children:[(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(p.A,{size:14}),(0,r.Y)("span",{children:"Default"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(m.A,{size:14}),(0,r.Y)("span",{children:"[CMD] DeepSeek V4 Flash"})]})]}),(0,r.FD)("button",{onClick:n,className:"flex items-center justify-center space-x-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/80 transition-colors text-xs font-medium",children:[(0,r.Y)("span",{children:"Schedule Task"}),(0,r.Y)(h.A,{size:12,className:"ml-px"})]})]})]})})]})}):null}},u(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("ma"),n.e("5b")]).then(n.bind(n,"bS")).then(e=>({default:e.SettingsModal})));function a(e){let{isOpen:t,...n}=e;return t?(0,r.Y)(i.tY,{fallback:null,children:(0,r.Y)(s,{isOpen:t,...n})}):null}n.d(t,{b:()=>a})},d(e,t,n){n.d(t,{E:()=>iW});var r=n("j"),i=n("H"),s=n("s"),a=n("G");let l=(0,a.RZ)(()=>n.e("xn").then(n.bind(n,"PB")).then(e=>({default:e.ExtensionDialog})));function o(e){return(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(l,{...e})})}let c=/^other\b/i,d=/\s+\(\d+\s*\/\s*\d+\)$/,u=/^\(\d+\s+selected\)\s*/;function p(e){return e.replace(u,"").replace(d,"").replace(/\s+/g," ").trim().toLowerCase()}function m(e){if("string"==typeof e){let t=e.trim();return t?{label:t}:null}if(!e||"object"!=typeof e)return null;let t="string"==typeof e.label?e.label.trim():"";return t?{label:t,description:"string"==typeof e.description?e.description:void 0,preview:"string"==typeof e.preview?e.preview:void 0}:null}function h(e){let t=e.input,n="object"==typeof t&&null!==t?t:null,r=n&&Array.isArray(n.questions)?n.questions:[],i=[];for(let e of r){if(!e||"object"!=typeof e)continue;let t="string"==typeof e.question?e.question.trim():"";t&&i.push({id:"string"==typeof e.id?e.id:void 0,header:"string"==typeof e.header&&e.header.trim()?e.header.trim():void 0,question:t,options:Array.isArray(e.options)?e.options.map(m).filter(e=>null!==e):[],multi:!0===e.multi,recommended:"number"==typeof e.recommended?e.recommended:void 0})}return i}function f(e){return{selectedOptions:Array.isArray(e.selectedOptions)?e.selectedOptions.filter(e=>"string"==typeof e):[],customInput:"string"==typeof e.customInput&&e.customInput?e.customInput:void 0,timedOut:!0===e.timedOut}}let x=/^([\w.-]+):\s*(.+)$/,g=/^User selected:\s*(.+)$/m,b=/^User provided custom input:\s*([\s\S]+)$/m;function v(e,t){let n=e.trim();return/^"[\s\S]*"$/.test(n)?{selectedOptions:[],customInput:n.slice(1,-1)}:{selectedOptions:(t&&n.includes(", ")?n.split(", "):[n]).map(e=>e.trim()).filter(Boolean)}}let k={framesByTool:new Map,respond:()=>{}},y=(0,a.q6)(k);var w=n("v"),N=n("g6"),Y=n("Go"),D=n("z"),F=n("oj"),A=n("s8"),C=n("YL"),S=n("tN"),T=n("W9"),z=n("r"),$=n("t3"),j=n("S");function L(e){let{search:t,onSearchChange:n,onAddProvider:i}=e;return(0,r.FD)("div",{className:"flex flex-col border-b border-ink/10 bg-canvas/40",children:[(0,r.FD)("button",{type:"button",onClick:i,className:"w-full flex items-center space-x-2 px-3 py-2 text-xs text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors text-left font-medium cursor-pointer border-b border-ink/5",children:[(0,r.Y)(z.A,{size:14,className:"text-ink/60"}),(0,r.Y)("span",{children:"Add new provider"})]}),(0,r.FD)("div",{className:"p-2 flex items-center bg-canvas/60",children:[(0,r.Y)($.A,{size:13,className:"text-ink/40 mr-2 flex-shrink-0"}),(0,r.Y)("input",{type:"text",value:t,onChange:e=>n(e.currentTarget.value),placeholder:"Search models",className:"bg-transparent border-none focus:outline-none w-full text-ink placeholder-ink/40 text-xs font-sans",autoFocus:!0}),t&&(0,r.Y)("button",{type:"button",onClick:()=>n(""),className:"p-0.5 text-ink/40 hover:text-ink transition-colors cursor-pointer",title:"Clear search",children:(0,r.Y)(j.A,{size:12})})]})]})}var M=n("HW"),P=n("hw"),E=n("j7"),R=n("Wb"),I=n("cV"),O=n("lW"),J=n("C7"),_=n("XT"),W=n("Oj"),K=n("K6"),U=n("pm");function B(e){let{model:t,isSelected:n,isFocused:i,onSelect:s,onToggleFavorite:a,onCycleThinking:l,onMouseEnter:o}=e;return(0,r.FD)("div",{role:"button",tabIndex:0,onClick:()=>s(t),onMouseEnter:o,className:`group relative w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-colors cursor-pointer select-none ${i?"bg-ink/10 text-ink":n?"bg-ink/5 text-ink":"text-ink/85 hover:bg-ink/5"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)(E.A,{size:12,className:"text-ink/20 group-hover:text-ink/50 transition-colors flex-shrink-0"}),(()=>{if(t.isCmdAgent)return(0,r.Y)("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded border border-ink/20 bg-ink/5 text-ink/80 flex-shrink-0",title:"Autonomous Agent Command Mode [CMD]",children:(0,r.Y)(I.A,{size:10})});switch(t.providerIcon||t.provider.toLowerCase()){case"deepseek":return(0,r.Y)("span",{className:"text-[12px] leading-none flex-shrink-0",title:"DeepSeek",children:"🐋"});case"anthropic":case"claude":return(0,r.Y)(O.A,{size:13,className:"text-orange-400 flex-shrink-0"});case"openai":return(0,r.Y)(J.A,{size:13,className:"text-emerald-500 flex-shrink-0"});case"google":case"gemini":return(0,r.Y)(S.A,{size:13,className:"text-blue-400 flex-shrink-0"});case"opencode":return(0,r.Y)(_.A,{size:13,className:"text-violet-400 flex-shrink-0"});case"mistral":return(0,r.Y)(W.A,{size:13,className:"text-rose-400 flex-shrink-0"});default:return(0,r.Y)(S.A,{size:13,className:"text-ink/60 flex-shrink-0"})}})(),(0,r.FD)("div",{className:"flex items-center space-x-1.5 truncate",children:[t.isCmdAgent&&(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink/75 flex-shrink-0",children:"[CMD]"}),(0,r.Y)("span",{className:`truncate ${n?"font-semibold text-ink":"font-normal text-ink/90"}`,children:t.name}),t.contextWindow&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/45 flex-shrink-0",children:(0,U.F)(t.contextWindow)})]})]}),(0,r.FD)("div",{className:"flex items-center space-x-2 flex-shrink-0",children:[t.thinkingLevel&&(0,r.FD)("button",{type:"button",onClick:e=>{e.stopPropagation(),l?.(t,e)},title:`Thinking preset: ${t.thinkingLevel} (Click or use ← / → to change)`,className:"inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono text-ink/70 bg-ink/5 hover:bg-ink/10 border border-ink/10 transition-colors cursor-pointer",children:[(0,r.Y)(K.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:t.thinkingLevel})]}),n&&(0,r.Y)(D.A,{size:13,className:"text-ink flex-shrink-0"}),(0,r.Y)("button",{type:"button",onClick:e=>a(t,e),title:t.isFavorite?"Remove from favorites":"Add to favorites",className:"p-1 rounded text-ink/30 hover:text-sky-400 hover:bg-ink/5 transition-colors cursor-pointer",children:(0,r.Y)(M.A,{size:13,className:t.isFavorite?"fill-sky-400 text-sky-400":"text-ink/30 hover:text-sky-400"})})]})]})}function q(e){return e?`${e.provider}:${e.id}`:""}function H(e){let{id:t,title:n,iconType:i="provider",models:s,isCollapsed:a,onToggleCollapse:l,selectedModelKey:o,modelIndex:c,focusedIndex:d,onSelect:u,onToggleFavorite:p,onCycleThinking:m,onHoverItem:h}=e;return 0===s.length?null:(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(t),className:"w-full flex items-center justify-between px-2 py-1 text-[11px] font-semibold text-ink/60 uppercase tracking-wider hover:text-ink cursor-pointer select-none",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:["star"===i&&(0,r.Y)(M.A,{size:12,className:"fill-sky-400 text-sky-400"}),"recent"===i&&(0,r.Y)(P.A,{size:12,className:"text-ink/60"}),"whale"===i&&(0,r.Y)("span",{children:"🐋"}),"provider"===i&&(0,r.Y)(E.A,{size:11,className:"text-ink/25"}),(0,r.Y)("span",{children:n})]}),a?(0,r.Y)(Y.A,{size:12,className:"text-ink/40"}):(0,r.Y)(R.A,{size:12,className:"text-ink/40"})]}),!a&&(0,r.Y)("div",{className:"space-y-0.5",children:s.map(e=>{let n=q(e),i=c[n]??-1;return(0,r.Y)(B,{model:e,isSelected:o===n,isFocused:d===i,onSelect:u,onToggleFavorite:p,onCycleThinking:m,onMouseEnter:()=>h(i,e)},`${t}-${n}`)})})]})}function G(){return(0,r.Y)("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-ink/10 bg-canvas/60 text-[10px] text-ink/50 font-mono select-none",children:(0,r.FD)("div",{className:"flex items-center space-x-3",children:[(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"↑ ↓"}),(0,r.Y)("span",{children:"navigate"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"Tab"}),(0,r.Y)("span",{children:"switch agent"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"← →"}),(0,r.Y)("span",{children:"thinking"})]})]})})}let V=[3,2];function Z(){return(0,r.Y)("div",{className:"space-y-2","aria-hidden":"true",children:V.map((e,t)=>(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 px-2 py-1",children:[(0,r.Y)("span",{className:"w-2.5 h-2.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-2.5 w-20 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,n)=>(0,r.FD)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)("span",{className:"w-3 h-3 rounded-sm animate-pulse bg-ink/10 flex-shrink-0"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${52-(n+t)%3*10}%`}})]}),(0,r.Y)("span",{className:"h-4 w-9 rounded animate-pulse bg-ink/10 flex-shrink-0"})]},n))]},t))})}function Q(e){let{model:t}=e;return t?(0,r.Y)("div",{className:"w-72 bg-paper/95 backdrop-blur-sm border border-ink/20 rounded-xl shadow-2xl p-3.5 text-xs text-ink select-none animate-in fade-in zoom-in-95 duration-100",children:(0,r.FD)("div",{className:"space-y-2.5 font-mono text-[11px]",children:[t.capabilities&&t.capabilities.length>0&&(0,r.FD)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Capabilities"}),(0,r.Y)("span",{className:"text-ink font-medium text-right text-xs font-sans",children:t.capabilities.join(", ")})]}),t.contextWindow&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Context"}),(0,r.Y)("span",{className:"text-ink/80",children:(0,U.F)(t.contextWindow)})]}),t.thinkingLevel&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Thinking"}),(0,r.Y)("span",{className:"text-ink/80",children:t.thinkingLevel})]}),t.input&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Input"}),(0,r.Y)("span",{className:"text-ink/80",children:t.input})]}),t.output&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Output"}),(0,r.Y)("span",{className:"text-ink/80",children:t.output})]}),t.cost&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/10",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cost ($/1M tokens)"}),(0,r.FD)("span",{className:"text-ink font-semibold tracking-tight",children:["In ",t.cost.input," · Out ",t.cost.output]})]}),(t.cost?.cacheRead!==void 0||t.cost?.cacheWrite!==void 0)&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/5",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cache"}),(0,r.Y)("span",{className:"text-ink/80",children:t.cost?.cacheRead!==void 0&&t.cost?.cacheWrite!==void 0?`Read ${t.cost.cacheRead} \xb7 Write ${t.cost.cacheWrite}`:t.cost?.cacheRead!==void 0?`Read ${t.cost.cacheRead}`:`Write ${t.cost.cacheWrite}`})]}),t.description&&(0,r.Y)("div",{className:"pt-1.5 text-[10px] text-ink/60 font-sans leading-relaxed border-t border-ink/5",children:t.description})]})}):null}function X(e){let{search:t,onSearchChange:n,onAddProvider:i,isLoading:s,filteredModels:a,favoriteModels:l,recentModels:o,providerGroups:c,collapsedSections:d,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,hoveredModel:f,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v,onMouseLeave:k}=e;return(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-2.5 z-50 flex items-start",children:[(0,r.FD)("div",{className:"w-84 sm:w-96 bg-paper border border-ink/20 rounded-xl shadow-2xl flex flex-col overflow-hidden text-xs max-h-[460px] animate-in fade-in zoom-in-95 duration-100",children:[(0,r.Y)(L,{search:t,onSearchChange:n,onAddProvider:i}),(0,r.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-2 max-h-80",onMouseLeave:k,children:s?(0,r.Y)(Z,{}):0===a.length?(0,r.Y)("div",{className:"px-3 py-6 text-center text-ink/40 italic",children:t?(0,r.FD)(r.FK,{children:['No models found matching "',t,'"']}):(0,r.Y)(r.FK,{children:"No models available. Enable a provider in Settings → Providers."})}):(0,r.FD)(r.FK,{children:[(0,r.Y)(H,{id:"favorites",title:"FAVORITES",iconType:"star",models:l,isCollapsed:!!d.favorites,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),(0,r.Y)(H,{id:"recent",title:"RECENT",iconType:"recent",models:o,isCollapsed:!!d.recent,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),Object.entries(c).map(e=>{let[t,n]=e;return(0,r.Y)(H,{id:t,title:t,iconType:"DEEPSEEK"===t?"whale":"provider",models:n,isCollapsed:!!d[t],onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v},t)})]})}),(0,r.Y)(G,{})]}),f&&(0,r.Y)("div",{className:"hidden lg:block ml-2 self-center",children:(0,r.Y)(Q,{model:f})})]})}function ee(e){let t=Array.isArray(e.thinkingLevels)?e.thinkingLevels:[],n=e.cost;return{id:e.id,name:e.name,provider:e.provider,contextWindow:e.contextWindow,thinkingLevel:t[0]??"off",thinkingLevels:t,capabilities:t.length>1?["Tool calling","Reasoning"]:["Tool calling"],cost:n?{input:void 0!==n.input?`$${n.input}`:"—",output:void 0!==n.output?`$${n.output}`:"—",cacheRead:void 0!==n.cacheRead?`$${n.cacheRead}`:void 0,cacheWrite:void 0!==n.cacheWrite?`$${n.cacheWrite}`:void 0}:void 0}}function et(e){let{selectedModel:t,onSelectModel:n,onOpenAddProvider:s,onThinkingLevelChange:a,className:l=""}=e,[o,c]=(0,i.J0)(!1),[d,u]=(0,i.J0)(""),[p,m]=(0,i.J0)(-1),[h,f]=(0,i.J0)(null),[x,g]=(0,i.J0)({}),{models:b,isLoading:v,setModels:k,selectedModel:y,setSelectedModel:w}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,i.J0)(!0),[a,l]=(0,i.J0)(e??null),o=(0,i.li)(e);o.current=e;let c=(0,i.hb)(e=>{n(e)},[]),d=(0,i.hb)(async()=>{try{let e=await (0,T.xo)();if(Array.isArray(e.modelList)&&e.modelList.length>0){let t=e.modelList.map(ee);n(e=>t.map(t=>{let n=e.find(e=>e.id===t.id&&e.provider===t.provider);return n?.thinkingLevel&&t.thinkingLevels?.includes(n.thinkingLevel)?{...t,thinkingLevel:n.thinkingLevel}:t}));let r=e.defaultModel;if(r&&!o.current){let e=t.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&l(e)}}else Array.isArray(e.models)&&e.models.length>0&&n(e.models);e.selectedModel&&!o.current&&l(e.selectedModel)}catch{}finally{s(!1)}},[]);return(0,i.vJ)(()=>(d(),(0,T.Sy)(d)),[d]),(0,i.vJ)(()=>{e&&(l(e),n(t=>t.map(t=>t.id===e.id&&t.provider===e.provider?{...t,thinkingLevel:e.thinkingLevel}:t)))},[e]),{models:t,isLoading:r,setModels:c,selectedModel:a,setSelectedModel:l}}(t),N=(0,i.li)(null);(0,F.W)(N,()=>{c(!1),f(null),m(-1)});let{filtered:D,favorites:A,recent:C,byProvider:z,visibleFlatList:$,index:j}=(0,i.Kr)(()=>(function(e,t,n){let r=t.trim().toLowerCase(),i=r?e.filter(e=>e.name.toLowerCase().includes(r)||e.provider.toLowerCase().includes(r)||String(e.contextWindow??"").toLowerCase().includes(r)||e.capabilities?.some(e=>e.toLowerCase().includes(r))):e,s=i.filter(e=>e.isFavorite),a=i.filter(e=>e.isRecent&&!e.isFavorite),l={};for(let e of i){let t=e.provider.toUpperCase();(l[t]??=[]).push(e)}let o=[];for(let[e,t]of(n.favorites||o.push(...s),n.recent||o.push(...a),Object.entries(l)))n[e]||o.push(...t);let c={};return o.forEach((e,t)=>{c[q(e)]=t}),{filtered:i,favorites:s,recent:a,byProvider:l,visibleFlatList:o,index:c}})(b,d,x),[b,d,x]),L=q(y),M=async(e,t)=>{t.stopPropagation();let n=q(e);k(e=>e.map(e=>q(e)===n?{...e,isFavorite:!e.isFavorite}:e));try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleFavorite",provider:e.provider,modelId:e.id})})}catch{}},P=e=>{let t=e.thinkingLevels??[];if(0===t.length)return;let r=e.thinkingLevel??t[0],i=t.indexOf(r),s=t[(i+1)%t.length],l=q(e);if(k(e=>e.map(e=>q(e)===l?{...e,thinkingLevel:s}:e)),L===l&&y){let e={...y,thinkingLevel:s};w(e),n?.(e),a?.(s)}},E=async e=>{let t=!e.isCmdAgent,n=q(e);k(e=>e.map(e=>q(e)===n?{...e,isCmdAgent:t}:e)),L===n&&y&&w({...y,isCmdAgent:t});try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleCmd",provider:e.provider,modelId:e.id})})}catch{}},R=async e=>{w(e),n?.(e),c(!1),f(null);try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"selectModel",model:e})}),(0,T.kn)()}catch{}};return(0,r.FD)("div",{className:`relative ${l}`,ref:N,onKeyDown:e=>{if(o){if("ArrowDown"===e.key)e.preventDefault(),m(e=>{let t=(e+1)%Math.max(1,$.length);return f($[t]||null),t});else if("ArrowUp"===e.key)e.preventDefault(),m(e=>{let t=(e-1+$.length)%Math.max(1,$.length);return f($[t]||null),t});else if("Enter"===e.key){e.preventDefault();let t=(p>=0?$[p]:null)||h;t&&R(t)}else if("Escape"===e.key)e.preventDefault(),c(!1),f(null);else if("Tab"===e.key){e.preventDefault();let t=(p>=0?$[p]:null)||h;t&&E(t)}else if("ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();let t=(p>=0?$[p]:null)||h;t&&P(t)}}},children:[(0,r.FD)("button",{type:"button",onClick:()=>{c(e=>!e),f(null),m(-1)},className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 font-medium cursor-pointer min-w-0 max-w-full",title:y?`${y.provider} • ${y.name}`:"Select a model",children:[y?(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:y.isCmdAgent?(0,r.Y)("span",{className:"font-mono text-[10px] font-bold text-ink/70",children:"⌘"}):"deepseek"===y.provider.toLowerCase()?(0,r.Y)("span",{children:"🐋"}):(0,r.Y)(S.A,{size:12,className:"text-ink/60"})}),(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0 max-w-[280px]",children:[(0,r.Y)("span",{className:"text-ink/50 font-normal truncate",children:y.provider}),(0,r.Y)("span",{className:"text-ink/30 flex-shrink-0",children:"•"}),(0,r.Y)("span",{className:"truncate",children:y.name})]})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:(0,r.Y)(S.A,{size:12,className:"text-ink/60"})}),(0,r.Y)("span",{className:"h-3 w-28 rounded animate-pulse bg-ink/10"})]}),(0,r.Y)(Y.A,{size:12,className:"text-ink/40 flex-shrink-0"})]}),o&&(0,r.Y)(X,{search:d,onSearchChange:u,onAddProvider:()=>{c(!1),f(null),s?s():window.dispatchEvent(new CustomEvent("omp:open-settings",{detail:{category:"providers",autoOpenAdd:!0}}))},isLoading:v,filteredModels:D,favoriteModels:A,recentModels:C,providerGroups:z,collapsedSections:x,onToggleCollapse:e=>{g(t=>({...t,[e]:!t[e]}))},selectedModelKey:L,modelIndex:j,focusedIndex:p,hoveredModel:h,onSelect:R,onToggleFavorite:M,onCycleThinking:P,onHoverItem:(e,t)=>{m(e),f(t)},onMouseLeave:()=>f(null)})]})}function en(e){let{thinkingLevels:t,currentThinking:n,onSelect:s}=e,[a,l]=(0,i.J0)(!1),o=(0,i.li)(null);return(0,F.W)(o,()=>l(!1)),(0,r.FD)("div",{className:"relative",ref:o,children:[(0,r.FD)("button",{onClick:()=>t.length>0&&l(!a),disabled:0===t.length,className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 disabled:opacity-40 disabled:cursor-not-allowed",title:0===t.length?"This model exposes no thinking levels":`Thinking Level: ${n}`,children:[(0,r.Y)(K.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:n})]}),a&&t.length>0&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Thinking Level"}),t.map(e=>(0,r.FD)("button",{onClick:()=>{l(!1),s(e)},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:e}),n===e&&(0,r.Y)(D.A,{size:12,className:"text-ink"})]},e))]})]})}var er=n("wf");let ei=["always-ask","write","yolo"],es={"always-ask":"Always ask",write:"Minimal",yolo:"Full bypass"},ea={"always-ask":"Read-only tools run automatically; writes and shell commands ask first.",write:"Reads and edits run automatically; shell commands ask first.",yolo:"Everything runs without asking."};function el(e){let{value:t,onSelect:n}=e,[s,a]=(0,i.J0)(!1),l=(0,i.li)(null);return(0,F.W)(l,()=>a(!1)),(0,r.FD)("div",{className:"relative",ref:l,children:[(0,r.FD)("button",{type:"button",onClick:()=>a(!s),className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80",children:[(0,r.Y)(er.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:es[t]})]}),s&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Access Control"}),ei.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{n(e),a(!1)},title:ea[e],className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:es[e]}),t===e&&(0,r.Y)(D.A,{size:12,className:"text-ink"})]},e))]})]})}function eo(e){let{isMobile:t,selectedModel:n,onSelectModel:i,thinkingLevels:s,currentThinking:a,onSelectThinking:l,onThinkingLevelChange:o,isGenerating:c,onStop:d,onSend:u,sendDisabled:p,accessMode:m,onSelectAccess:h}=e;return(0,r.FD)("div",{className:`flex items-center justify-between border-t border-ink/5 bg-canvas/50 rounded-b-md ${t?"px-2 py-2":"px-3 py-2"}`,children:[(0,r.FD)("div",{className:`flex items-center min-w-0 ${t?"space-x-1":"space-x-2"}`,children:[(0,r.Y)(et,{selectedModel:n??void 0,onSelectModel:i,onThinkingLevelChange:o,className:t?"min-w-0 max-w-[58%]":void 0}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(en,{thinkingLevels:s,currentThinking:a,onSelect:l}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(el,{value:m,onSelect:h})]}),(0,r.FD)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c&&(!t||!!d)&&(0,r.Y)("button",{type:"button",onClick:d,className:`flex items-center justify-center rounded transition-colors cursor-pointer shadow-xs animate-in zoom-in-90 duration-150 flex-shrink-0 ${t?"w-10 h-10 rounded-lg border border-ink/25 text-ink hover:bg-error hover:text-canvas hover:border-error":"w-7 h-7 bg-ink text-canvas hover:bg-error hover:text-canvas"}`,title:"Stop generation",children:(0,r.Y)(A.A,{size:t?14:10,className:"fill-current"})}),(!c||t)&&(0,r.Y)("button",{type:"button",onClick:u,disabled:p,className:`flex items-center justify-center rounded bg-ink text-canvas hover:bg-ink/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer flex-shrink-0 ${t?"w-10 h-10 rounded-lg":"w-7 h-7"}`,title:c?"Queue follow-up message":"Send message",children:(0,r.Y)(C.A,{size:t?16:12,className:"ml-px"})})]})]})}let ec=/[\s([{]/,ed=/^file:/i;var eu=n("ns");function ep(e){let{item:t}=e,n=t.match;return!n||n.start<0||n.start>=n.end||n.end>t.name.length?(0,r.Y)(r.FK,{children:t.name}):(0,r.FD)(r.FK,{children:[t.name.slice(0,n.start),(0,r.Y)("mark",{className:"bg-transparent font-semibold text-ink",children:t.name.slice(n.start,n.end)}),t.name.slice(n.end)]})}function em(e){let{open:t,kind:n,items:s,activeIndex:a,loading:l,error:o,listboxId:c,optionId:d,onSelect:u,onHover:p}=e,m=(0,i.li)(null);if((0,i.vJ)(()=>{t&&m.current?.scrollIntoView({block:"nearest"})},[a,t,s.length]),!t)return null;let h="mention"===n;return(0,r.FD)("div",{role:"listbox",id:c,"aria-label":h?"Files and agents":"Commands and skills",className:"absolute left-0 right-0 bottom-full mb-1 z-50 min-w-[260px] flex max-h-60 flex-col rounded-md border border-ink/20 bg-paper shadow-lg text-sm",children:[(0,r.Y)("div",{className:"shrink-0 text-[10px] uppercase tracking-wider text-ink/40 px-3 py-1.5 border-b border-ink/10",children:h?"Type to search files and agents":"Type to search commands and skills"}),(0,r.Y)("div",{className:"flex-1 overflow-y-auto",children:o?(0,r.Y)("div",{className:"px-3 py-2 text-error",children:o}):l&&0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:"Loading…"}):0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:h?"No matching files or agents":"No matching commands or skills"}):s.slice(0,100).map((e,t)=>(0,r.FD)("div",{id:d(t),role:"option","aria-selected":t===a,ref:t===a?m:void 0,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>p(t),onClick:()=>u(e),className:`px-3 py-2 cursor-pointer ${t===a?"bg-ink/10":""}`,children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"truncate",children:(0,r.Y)(ep,{item:e})}),"file"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"file"}),"skill"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"skill"})]}),(0,r.Y)("div",{className:"truncate text-ink/50 text-xs",children:e.description})]},e.id))}),(0,r.Y)("div",{className:"shrink-0 px-3 py-1.5 border-t border-ink/10 text-[10px] text-ink/40",children:"↑↓ navigate · Enter select · Esc close"})]})}function eh(e){let{value:t,onChange:n,onSend:s,disabled:a=!1,appSettings:l,placeholder:o,className:c,onPaste:d,rootPath:u,variant:p="desktop"}=e,m="mobile"===p,h=(0,i.li)(null),f=(0,i.li)(null),x=function(e){let{value:t,setValue:n,textareaRef:r,disabled:s=!1,rootPath:a}=e,[l,o]=(0,i.J0)(null),[c,d]=(0,i.J0)(0),u=(0,i.li)(!1),p=(0,i.li)(null),{items:m,loading:h,error:f}=function(e,t){let[n,r]=(0,i.J0)({items:[],loading:!1,error:null});return(0,i.vJ)(()=>{if(!e)return void r({items:[],loading:!1,error:null});let n=!1;return r({items:[],loading:!0,error:null}),(0,eu.bF)(e,t??null).then(e=>{n||r({items:e,loading:!1,error:null})}).catch(e=>{n||r({items:[],loading:!1,error:e instanceof Error?e.message:String(e)})}),()=>{n=!0}},[e,t]),n}(l?.kind??null,a??null),x=(0,i.Kr)(()=>(function(e,t){let n=t.trim(),r=ed.test(n),i=r?e.filter(e=>"file"===e.source):e,s=r?n.replace(ed,"").trim():n;if(""===s)return i.map(e=>({...e,match:null}));let a=[];return i.forEach((e,t)=>{let n=function(e,t,n){let r=n.trim().toLowerCase();if(""===r)return null;let i=e.toLowerCase(),s=t.toLowerCase();if(i===r)return{tier:0,match:{start:0,end:e.length}};if(i.startsWith(r))return{tier:1,match:{start:0,end:r.length}};let a=i.indexOf(r);return a>=0?{tier:2,match:{start:a,end:a+r.length}}:s.includes(r)?{tier:3,match:null}:null}(e.name,e.description,s);n&&a.push({...n,index:t})}),a.sort((e,t)=>e.tier-t.tier||e.index-t.index),a.map(e=>({...i[e.index],match:e.match}))})(m,l?.query??""),[m,l?.query]),g=x.length>0?Math.min(Math.max(c,0),x.length-1):-1,b=(0,i.Bi)(),v=(0,i.hb)(e=>`${b}-option-${e}`,[b]),k=(0,i.hb)(()=>{o(null),d(0)},[]),y=(0,i.hb)(e=>{d(e)},[]),w=(0,i.hb)(()=>{u.current=!0},[]),N=(0,i.hb)(()=>{u.current=!1},[]),Y=(0,i.hb)(e=>{var t;let r=e.currentTarget,i=r.value,a=r.selectionStart??i.length;if(u.current||!0===(t=e).isComposing||t.inputType?.startsWith("insertFromPaste")===!0||t.inputType?.startsWith("insertFromDrop")===!0){n(i),k();return}(n(i),s)?k():(o(function(e,t){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(/\s/.test(r))break;if("/"===r||"@"===r){if("/"===r){if(0!==t)return null;return{kind:"command",query:e.slice(t+1,n),start:t,end:n}}if(0===t||ec.test(e[t-1]))return{kind:"mention",query:e.slice(t+1,n),start:t,end:n};break}}return null}(i,a)),d(0))},[n,k,s]),D=(0,i.hb)(e=>{var r;if(!l)return;let i=(r=`${e.token} `,{value:t.slice(0,l.start)+r+t.slice(l.end),caret:l.start+r.length});p.current=i.caret,n(i.value),k()},[t,l,n,k]),F=(0,i.hb)(e=>!u.current&&229!==e.keyCode&&!!l&&("ArrowDown"===e.key||"ArrowUp"===e.key?(e.preventDefault(),x.length>0&&d((g+("ArrowDown"===e.key?1:-1)+x.length)%x.length),!0):("Enter"===e.key||"Tab"===e.key)&&x.length>0?(e.preventDefault(),e.stopPropagation(),D(x[g]),!0):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),k(),!0)),[l,x,g,D,k]);return(0,i.Nf)(()=>{if(null==p.current)return;let e=p.current;p.current=null;let t=r.current;t&&(t.focus(),t.setSelectionRange(e,e))},[t,r]),{trigger:l,isOpen:null!==l,matches:x,loading:h,error:f,activeIndex:g,setActiveIndex:y,handleChange:Y,handleCompositionStart:w,handleCompositionEnd:N,handleKeyDown:F,selectItem:D,close:k,listboxId:b,optionId:v}}({value:t,setValue:n,textareaRef:h,disabled:a,rootPath:u});return(0,F.W)(f,x.close),(0,r.FD)("div",{className:"relative",ref:f,children:[(0,r.Y)("textarea",{ref:h,value:t,onChange:x.handleChange,onCompositionStart:x.handleCompositionStart,onCompositionEnd:x.handleCompositionEnd,onKeyDown:e=>{if(x.handleKeyDown(e)||"Enter"!==e.key)return;let t=l?.keybindingSend||"Enter",n=l?.keybindingNewLine||"Shift + Enter",r=l?.keybindingSteering||"Ctrl / Cmd + Enter",i="u">typeof navigator&&navigator.platform.toUpperCase().indexOf("MAC")>=0?e.metaKey:e.ctrlKey,o=e.shiftKey,c=t=>"Enter"===t&&!o&&!i&&!e.altKey||"Shift + Enter"===t&&!!o&&!i&&!e.altKey||"Ctrl / Cmd + Enter"===t&&!o&&!!i&&!e.altKey,d=!o&&!i&&!e.altKey;(!m||!d)&&(c(r)?(e.preventDefault(),a||s({steering:!0})):c(t)?(e.preventDefault(),a||s()):c(n)||e.preventDefault())},onPaste:d,disabled:a,placeholder:o,enterkeyhint:m?"enter":void 0,className:c,"aria-autocomplete":"list","aria-expanded":x.isOpen,"aria-controls":x.listboxId,"aria-haspopup":"listbox","aria-activedescendant":x.isOpen&&x.matches.length>0?x.optionId(x.activeIndex):void 0}),(0,r.Y)(em,{open:x.isOpen,kind:x.trigger?.kind??"mention",items:x.matches,activeIndex:x.activeIndex,loading:x.loading,error:x.error,listboxId:x.listboxId,optionId:x.optionId,onSelect:x.selectItem,onHover:x.setActiveIndex})]})}var ef=n("Bt"),ex=n("HD");function eg(e){let{attachments:t,onFilesSelected:n,onRemove:s}=e,a=(0,i.li)(null);return(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"flex items-center flex-wrap gap-1.5 px-3 py-2 border-b border-ink/5 text-ink/60",children:[(0,r.Y)("button",{onClick:()=>a.current?.click(),className:"flex items-center justify-center hover:bg-ink/5 p-1 rounded transition-colors text-ink/60 hover:text-ink shrink-0",title:"Attach file or image",children:(0,r.Y)(ef.A,{size:14})}),t.map(e=>(0,r.FD)("div",{className:"relative flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-6 text-xs shadow-sm group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"preview",className:"w-6 h-6 object-cover rounded-sm mr-1.5 border border-ink/5"}):(0,r.Y)("div",{className:"w-6 h-6 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(ex.A,{size:12})}),(0,r.Y)("span",{className:"truncate max-w-[120px] font-mono text-[10px] text-ink/80",children:e.file.name}),(0,r.Y)("button",{onClick:()=>s(e.id),className:"absolute right-0.5 top-1/2 -translate-y-1/2 p-0.5 text-ink/40 hover:text-error hover:bg-error/10 rounded transition-colors",title:"Remove attachment",children:(0,r.Y)(j.A,{size:10})})]},e.id))]}),(0,r.Y)("input",{type:"file",multiple:!0,className:"hidden",ref:a,onChange:e=>{e.currentTarget.files&&e.currentTarget.files.length>0&&n(Array.from(e.currentTarget.files)),a.current&&(a.current.value="")}})]})}let eb=["auto","off","minimal","low","medium","high","xhigh","max"];function ev(e){if(!e||0===e.length)return[];let t=new Set(e.filter(e=>e&&"auto"!==e));return[...eb.filter(e=>t.delete(e)),...t]}function ek(e,t,n){let r=ev(e??[]);return t&&(0===r.length||r.includes(t))?t:n??"auto"}function ey(e,t,n){return{id:e.id,name:e.name,provider:e.provider,contextWindow:e.contextWindow,thinkingLevels:e.thinkingLevels,thinkingLevel:ek(e.thinkingLevels,t,n?.thinkingLevel)}}function ew(e){let{value:t,onChange:n,onSend:s,isGenerating:a,onStop:l,className:o="",disabled:c=!1,appSettings:d={},attachments:u,onAttachmentsChange:p,onThinkingLevelChange:m,onModelChange:h,sessionModel:f,sessionThinkingLevel:x,rootPath:g,variant:b="desktop",accessMode:v,onAccessModeChange:k,composerModelRef:y}=e,[w,N]=(0,i.J0)([]),Y=void 0!==u?u:w,D=e=>{p?p(e):N(e)},[F,A]=(0,i.J0)(null),[C,S]=(0,i.J0)("auto");(0,i.vJ)(()=>{F?.id&&(y.current={provider:F.provider,modelId:F.id,thinkingLevel:F.thinkingLevel??"auto"})},[F?.provider,F?.id,F?.thinkingLevel,y]);let z=(0,i.li)(null);z.current=x??null;let $=(0,i.li)(f??null);$.current=f??null,(0,i.vJ)(()=>{if(!f?.provider||!f.modelId)return;let e=!0;return(0,T.xo)().then(t=>{if(!e||!f)return;let n=(t.modelList||[]).find(e=>e.id===f.modelId&&e.provider===f.provider);n&&A(e=>ey(n,z.current,e))}).catch(()=>{}),()=>{e=!1}},[f?.provider,f?.modelId]),(0,i.vJ)(()=>{x&&A(e=>{if(!e)return e;let t=ek(e.thinkingLevels,x,e.thinkingLevel);return t===e.thinkingLevel?e:{...e,thinkingLevel:t}})},[x]),(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,T.xo)();if(!e)return;if(Array.isArray(t.modelList)&&t.modelList.length>0){let e=$.current;if(e?.provider&&e.modelId){let n=t.modelList.find(t=>t.id===e.modelId&&t.provider===e.provider);n&&A(e=>ey(n,z.current,e));return}let n=t.selectedModel;if(n?.provider&&n.id){let e=t.modelList.find(e=>e.id===n.id&&e.provider===n.provider);if(e)return void A(t=>ey(e,z.current,t))}let r=t.defaultModel;if(r){let e=t.modelList.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&A(t=>ey(e,z.current,t))}}else if(t.selectedModel){let e=t.selectedModel;A(t=>({...e,thinkingLevel:ek(e.thinkingLevels,z.current,t?.thinkingLevel??e.thinkingLevel)}))}}catch{}};t();let n=(0,T.Sy)(t);return()=>{e=!1,n()}},[]);let j=(0,i.Kr)(()=>ev(F?.thinkingLevels),[F]);(0,i.vJ)(()=>{F?.thinkingLevel&&S(F.thinkingLevel)},[F?.thinkingLevel]);let L=e=>{let t=e.map(e=>({id:Math.random().toString(36).substring(7),file:e,preview:e.type.startsWith("image/")?URL.createObjectURL(e):""}));for(let e of(D(e=>[...e,...t]),t)){if(!e.file.type.startsWith("image/"))continue;let t=new FileReader;t.onload=()=>{let n=t.result.split(",")[1];n&&D(t=>t.map(t=>t.id===e.id?{...t,dataBase64:n}:t))},t.readAsDataURL(e.file)}},M=e=>{(t.trim()||0!==Y.length)&&(s(Y,e),D([]))},P="mobile"===b;return(0,r.FD)("div",{className:`relative border border-ink/20 rounded-md bg-paper focus-within:border-ink transition-colors flex flex-col shadow-sm ${o}`,children:[(0,r.Y)(eg,{attachments:Y,onFilesSelected:L,onRemove:e=>{D(t=>{let n=t.find(t=>t.id===e);return n&&n.preview&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e)})}}),(0,r.Y)(eh,{value:t,onChange:n,onSend:M,disabled:c,appSettings:d,rootPath:g,placeholder:c?"Please select a workspace above to start prompting...":"@ for files/agents; / for commands and skills; ! for shell; # for snippets (Paste images/files here)",className:`w-full bg-transparent border-none focus:outline-none resize-none text-ink placeholder-ink/40 disabled:opacity-50 disabled:cursor-not-allowed ${P?"px-3 py-3 text-base min-h-[68px] max-h-40":"px-3 py-3 text-sm min-h-[80px]"}`,onPaste:e=>{let t=e.clipboardData;t&&t.files.length>0&&(e.preventDefault(),L(Array.from(t.files)))},variant:b}),(0,r.Y)(eo,{isMobile:P,selectedModel:F,onSelectModel:e=>{A(e),h?.(e.provider,e.id)},thinkingLevels:j,currentThinking:C,onSelectThinking:e=>{S(e),A(t=>t?{...t,thinkingLevel:e}:t),m?.(e)},onThinkingLevelChange:m,isGenerating:a,onStop:l,onSend:()=>M(),sendDisabled:c||!t.trim()&&0===Y.length,accessMode:v,onSelectAccess:k})]})}var eN=n("rD"),eY=n("I"),eD=n("J"),eF=n("p"),eA=n("wU"),eC=n("DT"),eS=n("vp"),eT=n("b0"),ez=n("pH");function e$(e){let{text:t,className:n="flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:s=10,iconClassName:a,copiedIconClassName:l="text-success",label:o,copiedLabel:c="Copied",wrapLabel:d=!1,copiedLabelClassName:u,title:p,onClick:m,resetMs:h=2e3}=e,{copied:f,flagCopied:x}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,[t,n]=(0,i.J0)(!1),r=(0,i.li)(null),s=(0,i.hb)(()=>{n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),e)},[e]);return(0,i.vJ)(()=>()=>{r.current&&clearTimeout(r.current)},[]),{copied:t,flagCopied:s}}(h),g=async e=>{m?.(e),!t||await (0,ez.l)(t)&&x()},b=f?c:o;return(0,r.FD)("button",{type:"button",onClick:g,className:n,title:p,children:[f?(0,r.Y)(D.A,{size:s,className:l}):(0,r.Y)(eT.A,{size:s,className:a}),void 0!==b&&(d?(0,r.Y)("span",{className:f?u:void 0,children:b}):b)]})}function ej(e){let{thinking:t,defaultExpanded:n=!1,showSeparator:s=!1}=e,a="object"==typeof t&&!!t.isGenerating,[l,o]=(0,i.J0)(n||a),c=(0,i.li)(null);(0,i.vJ)(()=>{a&&o(!0)},[a]);let d="string"==typeof t?t:t.thought||"",u=d.match(/<system-notice[^>]*>([\s\S]*?)<\/system-notice>/),p=u?.[1]?.trim()??"",m=d.replace(/<system-notice[^>]*>[\s\S]*?<\/system-notice>/g,"").trim(),h="object"==typeof t?t.duration:void 0,f="object"==typeof t&&t.summary?t.summary:m.slice(0,100)+(m.length>100?"...":"");return((0,i.vJ)(()=>{if(!l||!a)return;let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[l,m,a]),m)?(0,r.FD)("div",{className:`mx-3 ${s?"space-y-1.5":""}`,children:[s&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:"Thinking"}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),(0,r.FD)("div",{className:"overflow-hidden rounded-xl border border-ink/10 bg-paper transition-colors hover:border-ink/20",children:[(0,r.FD)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-ink/[0.03] cursor-pointer select-none","aria-expanded":l,children:[(0,r.Y)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink/70",children:(0,r.Y)(S.A,{size:13})}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[12px] font-semibold tracking-tight text-ink",children:"Thinking"}),a&&(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/60 animate-pulse"})]}),!l&&f&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:f})]}),h&&(0,r.Y)("span",{className:"shrink-0 rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/50",children:h}),(0,r.Y)(Y.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&(0,r.FD)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between pb-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Model Reasoning & Strategy"}),(0,r.Y)(e$,{text:m,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy thinking",wrapLabel:!0,label:"Copy"})]}),p&&(0,r.FD)("div",{className:"mb-2 flex items-start gap-2.5 rounded-lg border border-ink/15 bg-paper px-3 py-2.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-ink/10",children:(0,r.Y)(eC.A,{size:13,className:"text-ink/70"})}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("div",{className:"mb-0.5 text-[9.5px] font-semibold uppercase tracking-[0.12em] text-ink/50",children:"System Notice"}),(0,r.Y)("div",{className:"text-[12px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:p,className:"text-[12px] text-ink/85 leading-relaxed"})})]})]}),(0,r.Y)("div",{ref:c,className:"max-h-72 overflow-auto border-l-2 border-ink/15 py-1 pl-3 text-ink/80 scrollbar-overlay-container scrollbar-overlay-static select-text",children:(0,r.Y)(eS.T,{content:m,className:"text-[12px] leading-relaxed text-ink/85 [&_.code-block]:my-2 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5"})})]})]})]}):null}function eL(e){if(!0===e.synthetic||"skipped"===e.status||"aborted"===e.status)return!0;let t=e.details;return t?.__synthetic===!0||t?.source==="assistant_stop_skipped"||t?.executed===!1}var eM=n("N"),eP=n("Jr"),eE=n("SR"),eR=n("aP"),eI=n("AB"),eO=n("uV"),eJ=n("DK"),e_=n("WO"),eW=n("R"),eK=n("bt"),eU=n("k"),eB=n("wJ"),eq=n("s0");let eH=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][0-9A-B]|\x1b\[[0-9;?]*[A-Za-z]/g;function eG(e){return e?e.includes("\x1b")?e.replace(eH,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n"):e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"):""}let eV=/^[A-Za-z_][A-Za-z0-9_.:-]*/,eZ=/([A-Za-z_:][A-Za-z0-9_.:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;function eQ(e){return"system-reminder"===e||"reminder"===e}function eX(e,t){let n="";for(let r=t;r<e.length;r+=1){let t=e[r];if(n)t===n&&(n="");else if('"'===t||"'"===t)n=t;else if(">"===t)return r}return -1}function e0(e,t){let n=e.slice(t,t+9);if(n.startsWith("\x3c!--")){let n=e.indexOf("--\x3e",t+4);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("<![CDATA["===n){let n=e.indexOf("]]>",t+9);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("!"===e[t+1]||"?"===e[t+1]){let n=eX(e,t+2);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+1}}let r="/"===e[t+1],i=t+(r?2:1),s=eV.exec(e.slice(i,i+64))?.[0];if(!s)return;let a=eX(e,i+s.length);if(-1===a)return;let l=e.slice(i+s.length,a);return r?{kind:"end",name:s,attrs:l,end:a+1}:{kind:"/"===e[a-1]?"self":"start",name:s,attrs:l,end:a+1}}function e1(e){let t=e.search(/\S/);if(-1===t||"<"!==e[t])return;let n=e0(e,t);if(!n||"start"!==n.kind)return;let r=[n.name];for(let t=n.end;t<e.length;){if("<"!==e[t]){t+=1;continue}let i=e0(e,t);if(!i)break;if("start"===i.kind)r.push(i.name);else if("end"===i.kind){if(r.pop()!==i.name)return;if(0===r.length){let r=e.slice(i.end).trim();if(r.startsWith("<"))return;return{tag:n.name,attributes:function(e){let t={};for(let n of e.matchAll(eZ))t[n[1]]=n[2]??n[3]??n[4]??"";return t}(n.attrs),inner:function(e){let t=e.split("\n");for(t.length>1&&!t[0].trim()&&t.shift();t.length>1&&!t[t.length-1].trim();)t.pop();let n=1/0;for(let e of t)e.trim()&&(n=Math.min(n,e.length-e.trimStart().length));return Number.isFinite(n)?0===n?t.join("\n"):t.map(e=>e.slice(Math.min(n,e.length-e.trimStart().length))).join("\n"):""}(e.slice(n.end,t)),...r?{rest:r}:{}}}}t=i.end}}var e5=n("yy"),e2=n("t");function e4(e){let t,{tool:n,icon:s,title:a,subtitle:l,meta:o,isOpen:c,onToggle:d,defaultExpanded:u=!1,alwaysExpanded:p=!1,children:m}=e,[h,f]=(0,i.J0)(u),x=!p,g=p||(void 0!==c?c:h),b=n.status||(n.error?"error":"success"),v="running"===b,k=!!m,y=eL(n);return(0,r.FD)("div",{className:`group overflow-hidden rounded-xl border transition-all duration-200 ${"error"===b&&!y?"border-error/25 bg-error/[0.03]":v?"border-ink/15 bg-paper":y?"border-dashed border-ink/15 bg-paper/60 opacity-80":"border-ink/10 bg-paper hover:border-ink/20"} ${g?"shadow-sm":""}`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{k&&x&&(d?d():f(e=>!e))},disabled:!k||!x,"aria-expanded":g,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${k&&x?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg transition-colors ${"error"===b&&!y?"bg-error/10 text-error":v?"bg-ink/8 text-ink":"bg-ink/5 text-ink/70 group-hover:bg-ink/8"}`,children:s}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:a}),(t="h-1.5 w-1.5 rounded-full","running"===b?(0,r.Y)("span",{className:`${t} bg-ink/60 animate-pulse`}):y?(0,r.Y)("span",{className:`${t} bg-ink/30`}):"error"===b?(0,r.Y)("span",{className:`${t} bg-error`}):(0,r.Y)("span",{className:`${t} bg-success`}))]}),l&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:l})]}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-2",children:[o,function(e){if(eL(e))return(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/50",children:[(0,r.Y)(e5.A,{size:10})," Skipped"]});let t=e.status||(e.error?"error":"success");return"error"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(eF.A,{size:10})," Failed"]}):"running"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/60",children:[(0,r.Y)(e2.A,{size:10,className:"animate-spin"})," Running"]}):(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[10px] font-semibold text-success",children:[(0,r.Y)(D.A,{size:10})," Done"]})}(n),k&&x&&(0,r.Y)(Y.A,{size:14,className:`text-ink/35 transition-transform duration-200 ${g?"rotate-180":""}`})]})]}),g&&k&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3 code-surface",children:m})]})}var e3=n("DU"),e8=n("Po");function e6(e){let{text:t}=e,n=(0,i.Kr)(()=>(function(e){let t=[],n=null;for(let r of e.split(/\r?\n/)){if(r.startsWith("diff --git ")){n&&t.push(n),n=null;continue}if(r.startsWith("--- ")){n?n.oldPath=r.slice(4).replace(/^[ab]\//,""):n={oldPath:r.slice(4).replace(/^[ab]\//,""),newPath:"",lines:[]};continue}if(r.startsWith("+++ ")){n||(n={oldPath:"",newPath:"",lines:[]}),n.newPath=r.slice(4).replace(/^[ab]\//,"");continue}if(!n)if(!(r.startsWith("@@")||r.startsWith("+")||r.startsWith("-")))continue;else n={oldPath:"",newPath:"",lines:[]};r.startsWith("@@")?n.lines.push({kind:"meta",text:r}):r.startsWith("+")&&!r.startsWith("+++")?n.lines.push({kind:"add",text:r.slice(1)}):r.startsWith("-")&&!r.startsWith("---")?n.lines.push({kind:"del",text:r.slice(1)}):n.lines.push({kind:"context",text:r.startsWith(" ")?r.slice(1):r})}return n&&t.push(n),t})(t),[t]),s=(0,e8.w)(),a=(0,i.Kr)(()=>n.map(e=>{let t=(0,e3.sQ)(e.newPath||e.oldPath);return(0,e3.O9)(e.lines.map(e=>"meta"===e.kind?"":e.text).join("\n"),t)}),[n,s]);if(0===n.length)return(0,r.Y)("pre",{className:"max-h-48 overflow-auto whitespace-pre overflow-x-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed text-ink/80 select-text",children:t});let l=n.reduce((e,t)=>{for(let n of t.lines)"add"===n.kind?e.added++:"del"===n.kind&&e.removed++;return e},{added:0,removed:0});return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/60",children:n[0]?.newPath||n[0]?.oldPath||"diff"}),n.length>1&&(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:[n.length," files"]}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[10px]",children:[(0,r.FD)("span",{className:"text-success",children:["+",l.added]}),(0,r.FD)("span",{className:"text-error",children:["-",l.removed]})]})]}),(0,r.Y)("div",{className:"max-h-56 overflow-auto bg-paper font-mono text-[11px] leading-relaxed select-text",children:n.map((e,t)=>(0,r.Y)("div",{className:t>0?"border-t border-ink/6":"",children:e.lines.map((e,n)=>{let i="add"===e.kind?"bg-success/[0.07]":"del"===e.kind?"bg-error/[0.07]":"meta"===e.kind?"bg-ink/[0.04]":"",s="add"===e.kind?"text-success":"del"===e.kind?"text-error":"meta"===e.kind?"text-ink/45":"text-ink/70",l="add"===e.kind?"+":"del"===e.kind?"-":"meta"===e.kind?"@":" ",o=a[t]?.[n]||"";return(0,r.FD)("div",{className:`flex px-2.5 ${i}`,children:[(0,r.Y)("span",{className:`w-4 shrink-0 select-none font-bold ${s}`,children:l}),"meta"!==e.kind&&o?(0,r.Y)("span",{className:"shiki min-w-0 flex-1 whitespace-pre-wrap break-all",dangerouslySetInnerHTML:{__html:o}}):(0,r.Y)("span",{className:`min-w-0 flex-1 whitespace-pre-wrap break-all ${s}`,children:e.text||" "})]},n)})},t))})]})}var e9=n("m"),e7=n("rr"),te=n("F"),tt=n("k8"),tn=n("dg");function tr(e){let{jsonString:t,title:n,maxHeightClass:s,showHeader:a=!0,className:l="",compact:o=!1,icon:c}=e,d=(0,i.Kr)(()=>t.split("\n"),[t]),u=(0,e8.w)(),p=(0,i.Kr)(()=>(0,e3.PH)(t),[t,u]);return(0,r.FD)("div",{className:`overflow-hidden ${o?"rounded-md":"rounded-lg"} border border-ink/8 bg-paper ${l}`,children:[a&&(0,r.FD)("div",{className:`flex items-center justify-between border-b border-ink/6 bg-canvas/40 ${o?"px-2.5 py-1":"px-3 py-1.5"}`,children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0",children:[c||(0,r.Y)(tn.A,{size:o?10.5:11,className:"text-ink/60 shrink-0"}),(0,r.Y)("span",{className:`font-mono ${o?"text-[10px]":"text-[10.5px]"} font-semibold text-ink truncate`,children:n||"JSON"}),(0,r.Y)("span",{className:`rounded bg-ink/5 px-1.5 py-0.2 font-mono ${o?"text-[8.5px]":"text-[9px]"} uppercase tracking-wider text-ink/50 shrink-0`,children:"JSON"}),(0,r.FD)("span",{className:`font-mono ${o?"text-[9px]":"text-[9.5px]"} text-ink/40 shrink-0`,children:[d.length," ",1===d.length?"line":"lines"]})]}),(0,r.Y)(e$,{text:t,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink shrink-0",title:"Copy JSON",onClick:e=>e.stopPropagation(),label:"Copy"})]}),(0,r.FD)("div",{className:`flex ${s||(o?"max-h-40":"max-h-56")} items-start overflow-x-auto font-mono ${o?"text-[10.5px] leading-snug":"text-[11px] leading-relaxed"} select-text`,children:[(0,r.Y)("div",{className:`sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 ${o?"py-1.5 pl-2 pr-1.5 text-[9.5px]":"py-2 pl-2.5 pr-2 text-[10px]"} text-right text-ink/25`,children:d.map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:`flex-1 overflow-x-auto ${o?"p-1.5":"p-2"} whitespace-pre text-ink/85 font-mono`,dangerouslySetInnerHTML:{__html:p}})]})]})}var ti=n("U8");let ts={running:{icon:(0,r.Y)(e2.A,{size:11,className:"animate-spin text-ink/50"}),label:"running"},done:{icon:(0,r.Y)(e9.A,{size:11,className:"text-success"}),label:"done"},failed:{icon:(0,r.Y)(e7.A,{size:11,className:"text-error"}),label:"failed"},aborted:{icon:(0,r.Y)(te.A,{size:11,className:"text-ink/35"}),label:"aborted"}};function ta(e){return"number"==typeof e?(0,ti.Rk)(e)??"":""}function tl(e){return"number"==typeof e?(0,ti.BD)(e,3):""}function to(e){let{tool:t}=e,[n,s]=(0,i.J0)(!1),[a,l]=(0,i.J0)(!0),o=t.details??{},c=Array.isArray(o.results)?o.results:[],d=Array.isArray(o.progress)?o.progress:[],u=(0,i.Kr)(()=>t.output?(0,e3.Bl)(t.output):{isValid:!1},[t.output]),p="object"==typeof t.input&&null!==t.input?t.input:void 0,m="string"==typeof p?.context?p.context.trim():"",h=Array.isArray(p?.tasks)?p.tasks:[],f=(0,i.Kr)(()=>c.length>0?c:d.length>0?d:h.length>0?h.map((e,n)=>({id:`task-sub-${n}`,name:e.name,agent:e.agent||"scout",task:e.task,status:"success"===t.status?"done":"running"})):[],[c,d,h,t.status]);if(0===f.length&&!t.output&&!m)return null;let x=f.reduce((e,t)=>e+("number"==typeof t.tokens?t.tokens:0),0),g=f.reduce((e,t)=>e+("number"==typeof t.cost?t.cost:0),0);return(0,r.FD)("div",{className:"space-y-2.5",children:[f.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 px-2.5 py-1.5",children:[(0,r.FD)("span",{className:"flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(O.A,{size:11,className:"text-ink/60"}),"Subagents"]}),(0,r.FD)("span",{className:"ml-auto font-mono text-[10px] text-ink/45",children:[f.length," ",f.length>1?"agents":"agent",x?` \xb7 ${ta(x)} tok`:"",g?` \xb7 ${tl(g)}`:""]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 px-2.5 py-1",children:f.map((e,t)=>{var n;let i=!0===e.aborted?"aborted":"string"==typeof e.error&&e.error?"failed":"number"==typeof e.exitCode?0===e.exitCode?"done":"failed":"done"===e.status||"completed"===e.status||"success"===e.status?"done":"failed"===e.status?"failed":"aborted"===e.status?"aborted":"running",s=ts[i],a="string"==typeof e.name&&e.name?e.name:null,l="string"==typeof e.agent?e.agent:"scout",o=[ta(e.tokens),tl(e.cost),"running"!==i?"number"!=typeof(n=e.durationMs)||!Number.isFinite(n)||n<1e3?"":`${Math.floor(n/1e3)}s`:""].filter(Boolean).join(" · ");return(0,r.FD)("div",{className:"flex items-center gap-2 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-ink/[0.04]",children:s.icon}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10.5px] font-semibold text-ink",children:a||l}),a&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:l}),(0,r.Y)("span",{className:"ml-auto shrink-0 font-mono text-[9.5px] text-ink/40",children:o||("done"===i?"settled":"running")})]},"string"==typeof e.id?e.id:`row-${t}`)})})]}),m&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(tt.A,{size:11,className:"text-ink/60"}),"Goal & Constraints"]}),(0,r.Y)(Y.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${n?"rotate-180":""}`})]}),n&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/30 px-3 py-2 text-[11.5px] text-ink/80 select-text leading-relaxed",children:(0,r.Y)(eS.T,{content:m})})]}),h.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(eE.A,{size:11,className:"text-ink/60"}),"Task Brief & Specification"]}),(0,r.Y)(Y.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${a?"rotate-180":""}`})]}),a&&(0,r.Y)("div",{className:"divide-y divide-ink/8 border-t border-ink/8 bg-canvas/30",children:h.map((e,t)=>(0,r.FD)("div",{className:"p-3 space-y-1.5 text-[11.5px] text-ink/80 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:"font-semibold text-ink text-[12px]",children:e.name||`Task #${t+1}`}),e.agent&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/60",children:e.agent})]}),e.task&&(0,r.Y)("div",{className:"text-ink/85 leading-relaxed font-sans",children:(0,r.Y)(eS.T,{content:e.task})})]},t))})]}),t.output&&(u.isValid&&u.pretty?(0,r.Y)(tr,{jsonString:u.pretty,title:"Yield Output",maxHeightClass:"max-h-72",showHeader:!0}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 px-2.5 py-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(O.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Yield Output"})]}),(0,r.Y)("div",{className:"bg-canvas/30 px-3 py-2 text-[11px] font-sans leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eS.T,{content:t.output})})]}))]})}function tc(e){let t=e.replace(/:$/,"").trim();return(t=(t=(t=(t=t.replace(/^active\s+phase(?:\s+\d+\/\d+)?(?:\s*[:\-]\s*|\s+)?/i,"")).replace(/^["']|["']$/g,"")).replace(/\s*\(\d+(?:\/\d+)?\s*(?:done|remaining|tasks)?\)$/i,"")).replace(/^\((.+)\)$/,"$1")).trim()||"Tasks"}function td(e){let t,n=e.input,r="object"==typeof n&&null!==n?n:void 0,i=e.output||"";r?.op==="done"&&r.task?t=`Completed: ${r.task}`:r?.op==="init"&&(t="Initialized Todo List");let s=i.split(/\r?\n/),a=[],l={phase:"Tasks",tasks:[]},o=!1;for(let e of s){let t=e.trim();if(!t)continue;if(t.endsWith(":")&&!t.startsWith("Overall")&&!t.startsWith("Remaining")){let e=tc(t);l.tasks.length>0&&a.push(l),l={phase:e,tasks:[]},o=!0;continue}let n=t.match(/^(?:[-*]\s*)?\[([ xX])\]\s*(.+)$/);if(n){let e=n[1].toLowerCase(),t=n[2].trim(),r="x"===e?"done":"pending";(t.includes("(in progress)")||t.includes("[in_progress]"))&&(r="in_progress",t=t.replace(/\(in progress\)/gi,"").replace(/\[in_progress\]/gi,"").trim()),l.tasks.push({text:t,status:r,phase:l.phase});continue}let r=t.match(/^-\s*(.+?)\s*\[(in_progress|pending|done)\](?:\s*\((.+?)\))?$/);if(r&&!o){let e=r[1].trim(),t=r[2],n=tc(r[3]?.trim()||"Tasks"),i=a.find(e=>tc(e.phase).toLowerCase()===n.toLowerCase());i||(i={phase:n,tasks:[]},a.push(i)),i.tasks.push({text:e,status:t,phase:n})}}if(l.tasks.length>0&&!a.includes(l)&&a.push(l),0===a.length&&Array.isArray(r?.list))for(let e of r.list){let t=tc(e.phase||"Tasks"),n=(e.items||[]).map(e=>({text:e,status:"pending",phase:t}));a.push({phase:t,tasks:n})}let c=function(e){let t=new Map;for(let n of e){if(!n.tasks.length)continue;let e=tc(n.phase),r=e.toLowerCase(),i=t.get(r);if(i){let t=n.tasks.length>=i.tasks.length?n.tasks:i.tasks,r=t===n.tasks?i.tasks:n.tasks,s=new Map;for(let n of t)s.set(n.text.toLowerCase().trim(),{...n,phase:e});for(let t of r){let n=t.text.toLowerCase().trim(),r=s.get(n);r?"done"===t.status?r.status="done":"in_progress"===t.status&&"done"!==r.status&&(r.status="in_progress"):s.set(n,{...t,phase:e})}i.phase=e,i.tasks=Array.from(s.values())}else t.set(r,{phase:e,tasks:[...n.tasks]})}let n=Array.from(t.values()),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.tasks.map(e=>e.text.toLowerCase().trim()),s=!1;for(let r=0;r<n.length;r++){if(e===r)continue;let a=n[r],l=new Set(a.tasks.map(e=>e.text.toLowerCase().trim()));if(a.tasks.length>=t.tasks.length&&i.every(e=>l.has(e))){for(let e of t.tasks){let t=a.tasks.find(t=>t.text.toLowerCase().trim()===e.text.toLowerCase().trim());t&&("done"===e.status?t.status="done":"in_progress"===e.status&&"done"!==t.status&&(t.status="in_progress"))}s=!0;break}}s||r.push(t)}return r}(a);if(r?.op==="done"&&r.task){let e=String(r.task).toLowerCase().trim();for(let t of c){let n=t.tasks.find(t=>t.text.toLowerCase().trim()===e);n&&(n.status="done")}}let d=0,u=0,p=0;for(let e of c)for(let t of e.tasks)"done"===t.status?d++:"in_progress"===t.status?u++:p++;let m=d+u+p,h=i.match(/Overall:\s*(\d+)\/(\d+)\s*done/i)||i.match(/(\d+)\s+of\s+(\d+)\s+completed/i);if(h){let e=parseInt(h[1],10),t=parseInt(h[2],10);t>=m&&(d=e,p=Math.max(0,(m=t)-d-u))}let f=[];d>0&&f.push(`${d} complete`),u>0&&f.push(`${u} in progress`),p>0&&f.push(`${p} pending`);let x=f.length>0?f.join(" · "):m>0?`${m} items`:"";return{groups:c,totalDone:d,totalInProgress:u,totalPending:p,totalTasks:m,opBadge:t,summaryText:x}}var tu=n("uF");let tp={github:"GitHub",openai:"OpenAI",gitlab:"GitLab",sqlite:"SQLite",postgresql:"PostgreSQL",mysql:"MySQL",mongodb:"MongoDB",redis:"Redis",docker:"Docker",kubernetes:"Kubernetes",vercel:"Vercel",bun:"Bun",node:"Node",deno:"Deno",react:"React",vue:"Vue",svelte:"Svelte",angular:"Angular",next:"Next",nuxt:"Nuxt",remix:"Remix",tailwind:"Tailwind",prisma:"Prisma",zod:"Zod",axios:"Axios",express:"Express",fastify:"Fastify",koa:"Koa",hono:"Hono",elysia:"Elysia",drizzle:"Drizzle",kysely:"Kysely",biome:"Biome",oxc:"Oxc",rolldown:"Rolldown",turbopack:"Turbopack",vite:"Vite",webpack:"Webpack",rollup:"Rollup",esbuild:"Esbuild",babel:"Babel",swc:"SWC",typescript:"TypeScript",javascript:"JavaScript",coffeescript:"CoffeeScript",dart:"Dart",kotlin:"Kotlin",swift:"Swift",rust:"Rust",python:"Python",ruby:"Ruby",php:"PHP",perl:"Perl",lua:"Lua",scala:"Scala",haskell:"Haskell",elixir:"Elixir",erlang:"Erlang",clojure:"Clojure",ocaml:"OCaml",zig:"Zig",nim:"Nim",crystal:"Crystal",julia:"Julia",groovy:"Groovy",powershell:"PowerShell",bash:"Bash",zsh:"Zsh",fish:"Fish",grep:"Grep",find:"Find",glob:"Glob",ls:"Ls",cat:"Cat",echo:"Echo",mkdir:"Mkdir",rm:"Rm",cp:"Cp",mv:"Mv",touch:"Touch",chmod:"Chmod",chown:"Chown",sudo:"Sudo",apt:"Apt",brew:"Brew",npm:"Npm",pnpm:"Pnpm",yarn:"Yarn",playwright:"Playwright",cypress:"Cypress",puppeteer:"Puppeteer",selenium:"Selenium",jest:"Jest",vitest:"Vitest",mocha:"Mocha",chai:"Chai",sinon:"Sinon",karma:"Karma",jasmine:"Jasmine",qunit:"QUnit",ava:"Ava",tape:"Tape",lodash:"Lodash",underscore:"Underscore",ramda:"Ramda",rxjs:"RxJS",redux:"Redux",zustand:"Zustand",jotai:"Jotai",recoil:"Recoil",mobx:"MobX",xstate:"XState",framer:"Framer",motion:"Motion",gsap:"GSAP",anime:"Anime",three:"Three",babylon:"Babylon",pixi:"Pixi",phaser:"Phaser",matter:"Matter",planck:"Planck",rapier:"Rapier",cannon:"Cannon",ammo:"Ammo",bullet:"Bullet",box2d:"Box2D",chipmunk:"Chipmunk",verlet:"Verlet",ode:"ODE",physx:"PhysX",havok:"Havok",unity:"Unity",unreal:"Unreal",godot:"Godot",bevy:"Bevy",amethyst:"Amethyst",macroquad:"Macroquad",miniquad:"Miniquad",sdl:"SDL",sfml:"SFML",glfw:"GLFW",opengl:"OpenGL",vulkan:"Vulkan",directx:"DirectX",metal:"Metal",webgpu:"WebGPU",webgl:"WebGL",canvas:"Canvas",webaudio:"WebAudio",webmidi:"WebMIDI",webrtc:"WebRTC",websocket:"WebSocket",sse:"SSE",eventsource:"EventSource",fetch:"Fetch",xhr:"XHR",ky:"Ky",got:"Got",undici:"Undici",superagent:"Superagent",request:"Request",needle:"Needle",bent:"Bent",r2:"R2",s3:"S3",gcs:"GCS",azure:"Azure",blob:"Blob",storage:"Storage",firebase:"Firebase",supabase:"Supabase",pocketbase:"PocketBase",appwrite:"Appwrite",nhost:"Nhost",hasura:"Hasura",graphql:"GraphQL",rest:"REST",grpc:"gRPC",trpc:"tRPC",soap:"SOAP",mqtt:"MQTT",amqp:"AMQP",kafka:"Kafka",rabbitmq:"RabbitMQ",pubsub:"PubSub",nats:"NATS",zeromq:"ZeroMQ",dds:"DDS",coap:"CoAP",ble:"BLE",zigbee:"Zigbee",lora:"LoRa",nbiot:"NB-IoT",lte:"LTE",wifi:"Wi-Fi",ethernet:"Ethernet",usb:"USB",hdmi:"HDMI",displayport:"DisplayPort",thunderbolt:"Thunderbolt",pcie:"PCIe",nvme:"NVMe",sata:"SATA",ddr:"DDR",ecc:"ECC",xmp:"XMP",docsis:"DOCSIS",gpon:"GPON",epon:"EPON",pon:"PON",olt:"OLT",ont:"ONT",onu:"ONU",odn:"ODN",p2mp:"P2MP",p2p:"P2P",ftth:"FTTH",fttb:"FTTB",fttc:"FTTC",fttn:"FTTN",hfc:"HFC",dsl:"DSL",adsl:"ADSL",vdsl:"VDSL",sdsl:"SDSL",shdsl:"SHDSL",isdn:"ISDN",pstn:"PSTN",pots:"POTS",voip:"VoIP",sip:"SIP",rtp:"RTP",rtcp:"RTCP",rtsp:"RTSP",hls:"HLS",dash:"DASH",mpeg:"MPEG",av1:"AV1",vp9:"VP9",vp8:"VP8",hevc:"HEVC",avc:"AVC",mp4:"MP4",mkv:"MKV",avi:"AVI",mov:"MOV",wmv:"WMV",flv:"FLV",webm:"WebM",ogg:"OGG",mp3:"MP3",wav:"WAV",flac:"FLAC",aac:"AAC",midi:"MIDI",opus:"OPUS",alac:"ALAC",ape:"APE",wavpack:"WavPack"},tm=new Set(["MCP","AST","LSP","DAP","RPC","SSH","TTS","STT","URL","API","JSON","SQL","CSS","HTML","JS","TS","PDF","PR","UI","UX","DB","CLI","TUI","IDE","HTTP","HTTPS","OAUTH","YAML","XML","CSV","PNG","SVG","WASM","AI","ML","LLM","RAG","SDK","GUI","DOM","ESM","CJS","UMD","IIFE","XHR","TCP","UDP","DNS","IP","GPU","CPU","RAM","SSD","HDD","FIFO","PTY","TTY","WEB"]);function th(e){if(!e)return e;let t=e.split("__"),n=t.length>1?t[0]:null,r=t[t.length-1].split(/[_\-\s]+/).filter(Boolean).map(e=>{let t=tp[e.toLowerCase()];if(t)return t;let n=e.toUpperCase();return tm.has(n)?n:e.charAt(0).toUpperCase()+e.slice(1)}).join(" ");return n?`${n.toUpperCase()} ${r}`:r}function tf(e){var t;let{envelope:n}=e,i=eQ(t=n.tag)?{icon:(0,r.Y)(eq.A,{size:12}),badge:"bg-warning/10 text-warning"}:"error"===t||"failure"===t?{icon:(0,r.Y)(eF.A,{size:12}),badge:"bg-error/10 text-error"}:{icon:(0,r.Y)(J.A,{size:12}),badge:"bg-info/10 text-info"};return(0,r.FD)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.Y)("span",{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded ${i.badge}`,children:i.icon}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/60",children:th(n.tag)}),Object.entries(n.attributes).map(e=>{let[t,n]=e;return(0,r.Y)("span",{title:`${t}=${n}`,className:"max-w-[240px] truncate rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9.5px] text-ink/60",children:n?`${t}=${n}`:t},t)})]})}let tx=/(^|\n)\s*(#{1,6}\s|```|`[^`\n]+`|>|[-*+]\s|\d+\.\s|\[[^\]]+\]\([^)]+\)|\|.*\|)/;function tg(e){let t=e1(e),n=t?[t.inner,t.rest].filter(Boolean).join("\n\n"):e;return{content:n,format:function(e){if(!e)return"text";let t=e.trim();if(!t)return"text";if(t.includes("```"))return"markdown";if(t.length<1e5&&(t.startsWith("{")||t.startsWith("[")))try{let e=JSON.parse(t);if(null!==e&&"object"==typeof e)return"json"}catch{}return tx.test(t)?"markdown":/^<(?:!doctype|html|div|section|article|table|ul|ol|h[1-6]|p|pre|code|span|a|b|strong|em|i|blockquote|form|button|input|img|nav|header|footer|main|aside|figure|figcaption|details|summary|label|select|option|textarea|video|audio|iframe|script|style|link|meta|title|body|head)\b/i.test(t)||/<[a-z][a-z0-9-]*\s[^>]*>[\s\S]*<\/[a-z][a-z0-9-]*>/i.test(t)&&/<\/[a-z][a-z0-9-]*>/i.test(t)?"html":"text"}(n),...t?{envelope:t}:{}}}function tb(e,t){if(!e||"markdown"===t)return e;let n=0;for(let t of e.match(/`+/g)??[])n=Math.max(n,t.length);let r="`".repeat(Math.max(3,n+1));return`${r}${"text"===t?"":t}
9
9
  ${e}
10
- ${r}`}function tv(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if(!e)return{text:"",skipped:0};let n=e.split(/\r?\n/);return n.length<=t?{text:e,skipped:0}:{text:n.slice(n.length-t).join("\n"),skipped:n.length-t}}function tk(e){let{text:t}=e,n=(0,i.Kr)(()=>eG(t),[t]),s=(0,i.Kr)(()=>tg(n),[n]),a=(0,i.Kr)(()=>tv(s.content,1e3),[s]),l=(0,i.Kr)(()=>tb(a.text,s.format),[a,s.format]),o=(0,i.Kr)(()=>s.content.split(/\r?\n/).length,[s.content]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)(tu.A,{size:11,className:"text-ink/40"}),(0,r.Y)("span",{children:"Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/45",children:s.format}),o>1&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:[o," lines"]})]}),(0,r.Y)(e$,{text:s.content,className:"flex cursor-pointer items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),s.envelope&&(0,r.Y)(tf,{envelope:s.envelope}),a.skipped>0&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",a.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 select-text",children:(0,r.Y)(eS.T,{content:l,className:"text-[12px] text-ink/85"})})]})}function ty(e){let{tool:t}=e,{groups:n,totalDone:s,totalInProgress:a,totalPending:l,totalTasks:o,opBadge:c}=(0,i.Kr)(()=>td(t),[t]);if(0===n.length&&!c){let e=t.output||"";return e.trim()?(0,r.Y)(tk,{text:e}):null}let d=o>0?Math.round(s/o*100):0;return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eR.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Todo"}),c&&(0,r.Y)("span",{className:"rounded bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-medium text-success",children:c})]}),o>0&&(0,r.FD)("div",{className:"flex items-center gap-2 font-mono text-[10.5px]",children:[(0,r.FD)("span",{className:"text-ink/50",children:[s," of ",o," completed"]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-semibold text-ink",children:[d,"%"]})]})]}),o>0&&(s>0||a>0||l>0)&&(0,r.FD)("div",{className:"mt-2.5 flex flex-wrap items-center gap-1.5 font-mono text-[10px]",children:[s>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-success/10 px-2 py-0.5 text-success",children:[(0,r.Y)(e9.A,{size:11}),(0,r.FD)("span",{children:[s," complete"]})]}),a>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/8 px-2 py-0.5 text-ink/70",children:[(0,r.Y)(e2.A,{size:11,className:"animate-spin"}),(0,r.FD)("span",{children:[a," in progress"]})]}),l>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/5 px-2 py-0.5 text-ink/50",children:[(0,r.Y)(A.A,{size:11}),(0,r.FD)("span",{children:[l," pending"]})]})]}),o>0&&(0,r.Y)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${d}%`}})})]}),(0,r.Y)("div",{className:"space-y-2",children:n.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:e.phase}),(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[e.tasks.filter(e=>"done"===e.status).length,"/",e.tasks.length]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/[0.04] p-1",children:e.tasks.map((e,t)=>{let n="done"===e.status,i="in_progress"===e.status;return(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1.5 text-[11.5px] transition-colors ${i?"bg-ink/[0.03]":""}`,children:[n?(0,r.Y)(e9.A,{size:13,className:"mt-0.5 shrink-0 text-success"}):i?(0,r.Y)(e2.A,{size:13,className:"mt-0.5 shrink-0 animate-spin text-ink"}):(0,r.Y)(A.A,{size:13,className:"mt-0.5 shrink-0 text-ink/25"}),(0,r.Y)("span",{className:`min-w-0 flex-1 leading-snug ${n?"text-ink/40 line-through":i?"font-medium text-ink":"text-ink/80"}`,children:e.text}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/8 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/70",children:"In Progress"})]},t)})})]},t))})]})}var tw=n("E6");function tN(e){if(e&&"object"==typeof e&&"string"==typeof e.path)return e.path}function tY(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"error"===t||"1"===t?"error":"warning"===t||"2"===t?"warning":"info"}let tD={error:{Icon:eF.A,color:"text-error",text:"text-error",badge:"bg-error/10 text-error"},warning:{Icon:tw.A,color:"text-warning",text:"text-warning",badge:"bg-warning/10 text-warning"},info:{Icon:eA.A,color:"text-ink/40",text:"text-ink/70",badge:"bg-ink/5 text-ink/50"}};function tF(e){let{tool:t}=e,n=t.details??{},s=t.output??"",a=n.xdev?.args?.action==="capabilities"||"capabilities"===function(e){if(e&&"object"==typeof e&&"string"==typeof e.action)return e.action}(t.input)||s.includes("capabilities:"),l=(0,i.Kr)(()=>a?function(e){if(!e||!e.includes("capabilities:"))return[];let t=[];for(let n of e.split(/^(?=[A-Za-z0-9_-]+:)/m)){let e=n.trim();if(!e)continue;let r=e.match(/^([A-Za-z0-9_-]+):\s*capabilities:\s*(\{[\s\S]*\})/m);if(r){let e=r[1];try{let n=JSON.parse(r[2]);t.push({name:e,capabilities:n})}catch{t.push({name:e,capabilities:{}})}}}return t}(s):[],[a,s]),o=(0,i.Kr)(()=>a?[]:Array.isArray(n.diagnostics)?n.diagnostics:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.diagnostics))return t.diagnostics;if(Array.isArray(t.errors))return t.errors}}catch{}let t=e.split(/\r?\n/).filter(Boolean),n=[],r=[],i="";for(let e of t){let t=e.trim();if(/^\d+\s+(?:error|warning|hint|info)\(s\):/i.test(t))continue;let s=t.match(/^(#{1,6})\s+(.+)$/);if(s){let e=s[1].length,t=s[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{let e=r.filter(Boolean).join("");i=e?`${e.replace(/\/+$/,"")}/${t}`:t}continue}let a=e.match(/^\s*(\d+):(\d+)\s+\[(error|warning|info|hint)\]\s*(?:\[([^\]]+)\])?\s*(.*?)(?:\s*\((\d+|TS\d+)\))?$/i);if(a){n.push({file:i||void 0,line:parseInt(a[1],10),column:parseInt(a[2],10),severity:"hint"===a[3].toLowerCase()?"info":a[3].toLowerCase(),source:a[4]||void 0,message:a[5].trim(),code:a[6]||void 0});continue}let l=e.match(/^([^:\n]+):(\d+)(?::(\d+))?\s*[-:]?\s*(error|warning|info|hint)?\s*(?:(TS\d+|[A-Za-z0-9_-]+):)?\s*(.*)$/i);l&&n.push({file:l[1].trim(),line:parseInt(l[2],10),column:l[3]?parseInt(l[3],10):void 0,severity:l[4]?"hint"===l[4].toLowerCase()?"info":l[4].toLowerCase():"error",code:l[5]||void 0,message:l[6]?.trim()||e})}return n}(s),[n.diagnostics,a,s]);if(a&&l.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eJ.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:"Language Servers"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"Capabilities"})]}),(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:[l.length," active"]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/30",children:l.map((e,t)=>{let n=Object.entries(e.capabilities).filter(e=>{let[,t]=e;return!!t}).map(e=>{let[t]=e;return t.replace(/Provider$/,"")});return(0,r.FD)("div",{className:"p-3 text-[11px]",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eO.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"font-mono font-medium text-ink",children:e.name}),(0,r.FD)("span",{className:"ml-auto inline-flex items-center gap-1 font-mono text-[9.5px] text-success",children:[(0,r.Y)(e9.A,{size:10}),"Connected"]})]}),n.length>0&&(0,r.Y)("div",{className:"mt-2 flex flex-wrap gap-1",children:n.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] text-ink/60",children:e},t))})]},t)})})]})});if(0===o.length)return s?(0,r.Y)(tk,{text:s}):null;let c=e=>o.filter(t=>tY(t)===e),d=c("error").length,u=c("warning").length,p=c("info").length;return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diagnostics"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-2 font-mono text-[10px]",children:[d>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-error",children:[(0,r.Y)(eF.A,{size:9}),d]}),u>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-warning",children:[(0,r.Y)(tw.A,{size:9}),u]}),p>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-ink/50",children:[(0,r.Y)(eA.A,{size:9}),p]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1 max-h-72 overflow-auto",children:o.map((e,t)=>{let n,i,s,a=tD[tY(e)],l=(n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="number"==typeof e.line?e.line:void 0,s="number"==typeof e.column?e.column:void 0,n?void 0===i?n:void 0===s?`${n}:${i}`:`${n}:${i}:${s}`:""),o="string"==typeof e.message?e.message:"",c="string"==typeof e.code?e.code:void 0,d="string"==typeof e.source?e.source:void 0,{Icon:u,color:p,text:m}=a;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-3.5 shrink-0 items-center justify-center",children:(0,r.Y)(u,{size:12,className:p})}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words leading-5",children:[l&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45 mr-1",children:[l,":"]}),(0,r.Y)("span",{className:m,children:o}),d&&(0,r.FD)("span",{className:"ml-1.5 font-mono text-[9px] text-ink/35",children:["[",d,"]"]}),c&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9px] text-ink/35",children:["(",c,")"]})]})]},t)})})]})}var tA=n("q");function tC(e){return"string"==typeof e.url?e.url:"string"==typeof e.link?e.link:""}function tS(e){return"string"==typeof e.snippet&&e.snippet?e.snippet:"string"==typeof e.description?e.description:""}function tT(e){let{tool:t}=e,n=t.details??{},i="string"==typeof n.response?.provider?n.response.provider:"string"==typeof n.provider?n.provider:void 0,s=Array.isArray(n.results)?n.results:Array.isArray(n.sources)?n.sources:Array.isArray(n.response?.sources)?n.response.sources:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.results))return t.results;if(Array.isArray(t.sources))return t.sources;if(Array.isArray(t.organic))return t.organic;if(Array.isArray(t.items))return t.items;if(t.response&&Array.isArray(t.response.sources))return t.response.sources}}catch{}return[]}(t.output??"");return 0===s.length?t.output?(0,r.Y)(tk,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:[i&&(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-paper px-2.5 py-1 text-[9.5px]",children:[(0,r.Y)("span",{className:"font-semibold uppercase tracking-wider text-ink/40",children:"Sources"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-ink/50 uppercase",children:i})]}),(0,r.Y)("ol",{className:"divide-y divide-ink/6",children:s.map((e,t)=>{let n=tC(e),i="string"==typeof e.publishedDate?e.publishedDate:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:"string"==typeof e.title&&e.title?e.title:tC(e)||"Result"}),n&&(0,r.Y)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex shrink-0 items-center rounded-md p-0.5 text-ink/40 transition-colors hover:bg-ink/5 hover:text-ink",title:n,children:(0,r.Y)(tA.A,{size:10})})]}),(0,r.FD)("div",{className:"flex items-center gap-2 pl-[22px] font-mono text-[9.5px] text-ink/40",children:[n&&(0,r.Y)("span",{className:"truncate",children:n}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 text-[8.5px] text-ink/50",children:i})]}),tS(e)&&(0,r.Y)("div",{className:"mt-0.5 pl-[22px] leading-snug text-ink/65",children:tS(e)})]},t)})})]})}var tz=n("o"),t$=n("sJ");function tj(e){let{tool:t}=e,n=t.input,s="object"==typeof n&&null!==n?n:void 0,a="string"==typeof s?.code?s.code:"string"==typeof n?n:"",l=("string"==typeof s?.language?s.language:"js").toUpperCase(),o="number"==typeof s?.timeout?`${s.timeout}s`:void 0,c="string"==typeof s?.title?s.title:void 0,d=t.output||(t.error?`Error: ${t.error}`:""),u="error"===t.status||d.includes("ToolError:")||d.includes("Command exited with code"),p=d.includes("Command aborted")||"aborted"===t.status,m=(0,e8.w)(),h=(0,i.Kr)(()=>u||p?{isValid:!1}:(0,e3.Bl)(d),[d,u,p]),f=(0,i.Kr)(()=>tv(a,1e3),[a]),x=(0,i.Kr)(()=>(0,e3.wY)(f.text,"javascript"),[f,m]),g=(0,i.Kr)(()=>tv(d,1e3),[d]),b=(0,i.Kr)(()=>h.isValid&&h.pretty?tv(h.pretty,1e3):null,[h]),v=(0,i.Kr)(()=>b?(0,e3.PH)(b.text):"",[b,m]);return(0,r.FD)("div",{className:"space-y-2",children:[a&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eI.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:c||"Script Evaluation"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:l}),o&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/40",children:[(0,r.Y)(tz.A,{size:10}),(0,r.Y)("span",{children:o})]})]}),(0,r.Y)(e$,{text:a,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),f.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",f.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2.5 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:f.text.split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:x}})]})]}),d&&(0,r.FD)("div",{className:`overflow-hidden rounded-lg border ${u?"border-error/25 bg-error/[0.03]":p?"border-warning/25 bg-warning/[0.03]":"border-ink/8 bg-paper"}`,children:[(0,r.FD)("div",{className:`flex items-center justify-between border-b px-3 py-1.5 ${u?"border-error/15 bg-error/[0.06]":p?"border-warning/15 bg-warning/[0.06]":"border-ink/6 bg-canvas/30"}`,children:[(0,r.Y)("div",{className:"flex items-center gap-1.5",children:u?(0,r.FD)(r.FK,{children:[(0,r.Y)(eF.A,{size:11,className:"text-error"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-error",children:"Execution Error"})]}):p?(0,r.FD)(r.FK,{children:[(0,r.Y)(te.A,{size:11,className:"text-warning"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-warning",children:"Evaluation Aborted"})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)(t$.A,{size:11,className:"text-success"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:"Evaluation Result"}),h.isValid&&(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),h.linesCount&&h.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[h.linesCount," lines"]})]})]})}),(0,r.Y)(e$,{text:h.isValid&&h.pretty?h.pretty:d,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),h.isValid&&h.pretty?(0,r.FD)(r.FK,{children:[b&&b.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:(b?b.text:h.pretty).split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:v}})]})]}):(0,r.FD)(r.FK,{children:[g.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:`max-h-48 overflow-y-auto p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words select-text ${u?"text-error":p?"text-warning":"text-ink/80"}`,children:g.text})]})]})]})}var tL=n("DB"),tM=n("vZ");let tP={open:"bg-success/10 text-success",merged:"bg-ink/10 text-ink/60",closed:"bg-error/10 text-error"};function tE(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.pullRequests))return t.pullRequests;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:i.map((e,t)=>{let n=!0===e.merged||"merged"===e.state?"merged":"closed"===e.state?"closed":"open",i="string"==typeof e.title?e.title:"",s="number"==typeof e.number?`#${e.number}`:"",a="string"==typeof e.author?e.author:"",l="number"==typeof e.additions?e.additions:void 0,o="number"==typeof e.deletions?e.deletions:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:["merged"===n?(0,r.Y)(tL.A,{size:12,className:"shrink-0 text-success"}):"closed"===n?(0,r.Y)(eU.A,{size:12,className:"shrink-0 text-error"}):(0,r.Y)(tM.A,{size:12,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:i}),s&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/45",children:s})]}),(0,r.FD)("div",{className:"mt-1 flex items-center gap-1.5 pl-[18px] text-[10px] text-ink/50",children:[(0,r.Y)("span",{className:`rounded-full px-1.5 py-px font-mono ${tP[n]}`,children:n}),a&&(0,r.Y)("span",{children:a}),(void 0!==l||void 0!==o)&&(0,r.FD)("span",{className:"ml-auto font-mono",children:[void 0!==l&&(0,r.FD)("span",{className:"text-success",children:["+",l]}),void 0!==o&&(0,r.FD)("span",{className:"ml-1 text-error",children:["-",o]})]})]})]},t)})})}var tR=n("Ir");function tI(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function tO(e){if(!e.startsWith("Today,"))return null;let t=e.slice(6).trim(),n=new Date(`${new Date().toDateString()} ${t}`);return Number.isNaN(n.getTime())?null:n.getTime()}function tJ(e){let t=e?.timestamp||e?.date;if(!t)return"";if(t.startsWith("Today,"))return`Today, ${t.slice(6).trim()}`;if(/^\d{1,2}:\d{2}\s*(AM|PM)$/i.test(t)){let e=tO(`Today, ${t}`);if(null!==e)return`Today, ${tI(e)}`}let n=new Date(t);if(Number.isNaN(n.getTime()))return"";let r=n.toLocaleDateString("en-US",{month:"short",day:"numeric"});return`${r}, ${tI(n)}`}function t_(e){let{tool:t}=e,n=t.details??{},i=n&&"object"==typeof n?n:{},s="rewind"===t.type,a="string"==typeof i.id?i.id:void 0,l=function(e){if("number"==typeof e){let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString()}return"string"==typeof e?e:""}(i.timestamp),o="number"==typeof i.fileCount?i.fileCount:void 0,c="string"==typeof i.branch?i.branch:void 0,d="string"==typeof i.message?i.message:"string"==typeof i.description?i.description:"";return a||l||o||c||d?(0,r.FD)("div",{className:"flex items-start gap-2.5 rounded-lg border border-ink/8 bg-canvas/40 px-3 py-2.5",children:[(0,r.Y)("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-ink/5 text-ink/60",children:s?(0,r.Y)(tR.A,{size:12}):(0,r.Y)(eK.A,{size:12})}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[d&&(0,r.Y)("div",{className:"text-[11.5px] text-ink/85",children:d}),(0,r.FD)("div",{className:"flex flex-wrap gap-x-2 gap-y-0.5 font-mono text-[9.5px] text-ink/45",children:[a&&(0,r.Y)("span",{children:a}),l&&(0,r.Y)("span",{children:l}),void 0!==o&&(0,r.FD)("span",{children:[o," files"]}),c&&(0,r.Y)("span",{children:c})]})]})]}):t.output?.trim()?(0,r.Y)(tk,{text:t.output}):null}function tW(e){var t;let n,{tool:s}=e,a=s.details??{},l="object"==typeof s.input&&null!==s.input?s.input:void 0,o=s.command||("string"==typeof l?.command?l.command:void 0)||("string"==typeof l?.cmd?l.cmd:void 0)||("string"==typeof l?.CommandLine?l.CommandLine:void 0)||("string"==typeof l?.commandLine?l.commandLine:void 0)||("string"==typeof s.input?s.input:""),{cleanText:c,wallTime:d}=(n=(t=s.output||(s.error?`Error: ${s.error}`:"")).match(/\n*Wall time:\s*([^\n\r]+)$/))?{cleanText:t.replace(/\n*Wall time:\s*[^\n\r]+$/,""),wallTime:n[1].trim()}:{cleanText:t},u="number"==typeof a.exitCode?a.exitCode:s.isError?1:void 0,p=("string"==typeof a.cwd?a.cwd:void 0)||("string"==typeof l?.cwd?l.cwd:void 0)||("string"==typeof l?.Cwd?l.Cwd:void 0),m="number"==typeof a.durationMs?a.durationMs:s.durationMs,h=s.duration||d||(m?`${m}ms`:void 0),f=!c||"(no output)"===c,x=(0,i.Kr)(()=>f||s.isError?{isValid:!1}:(0,e3.Bl)(c),[c,f,s.isError]),g=(0,i.Kr)(()=>eG(c),[c]),b=(0,i.Kr)(()=>tv(g,1e3),[g]),v=(0,i.Kr)(()=>x.isValid&&x.pretty?x.pretty:g,[x,g]),k=(0,i.Kr)(()=>(0,e3.rw)(g),[g]),y=(0,i.Kr)(()=>g.trim().startsWith("{")||g.trim().startsWith("[")?"json":"javascript",[g]),w=(0,i.Kr)(()=>x.isValid&&x.pretty?tv(x.pretty,1e3):null,[x]),N=(0,e8.w)(),Y=(0,i.Kr)(()=>o?(0,e3.wY)(o,"bash"):"",[o,N]),F=(0,i.Kr)(()=>k?(0,e3.wY)(b.text,y):"",[k,b,y,N]);return(0,r.FD)("div",{className:"space-y-2",children:[o&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/60 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1",children:[(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"})]}),(0,r.Y)("span",{className:"font-mono text-[10px] font-semibold text-ink/50",children:"bash"}),p&&(0,r.Y)("span",{className:"truncate font-mono text-[9.5px] text-ink/40",title:p,children:p})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[void 0!==u&&(0,r.FD)("span",{className:`rounded-full px-1.5 py-0.2 font-mono text-[9px] font-semibold ${0===u?"bg-success/10 text-success":"bg-error/10 text-error"}`,children:["exit ",u]}),h&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/45",children:[(0,r.Y)(tz.A,{size:10}),(0,r.Y)("span",{children:h})]}),(0,r.Y)(e$,{text:o,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy command",label:"Copy"})]})]}),(0,r.FD)("div",{className:"flex items-start gap-2.5 px-3 py-2 font-mono text-[11.5px] leading-relaxed",children:[(0,r.Y)("span",{className:"select-none font-bold text-ink/40",children:"$"}),(0,r.Y)("pre",{className:"min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all text-ink/90 select-text",dangerouslySetInnerHTML:{__html:Y}})]})]}),f?(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-dashed border-ink/15 bg-canvas/30 px-3 py-2 font-mono text-[11px] text-ink/50",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(D.A,{size:12,className:"text-success"}),(0,r.Y)("span",{children:"Command executed successfully with no output"})]}),h&&(0,r.FD)("span",{className:"text-[10px] text-ink/40",children:["Wall time: ",h]})]}):x.isValid&&x.pretty?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),x.linesCount&&x.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[x.linesCount," lines"]})]}),(0,r.Y)(e$,{text:x.isValid&&x.pretty?x.pretty:c,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),w&&w.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",w.skipped," earlier lines hidden"]}),(0,r.Y)(tr,{jsonString:w?w.text:x.pretty,maxHeightClass:"max-h-72",showHeader:!1})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)(e$,{text:v,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),b.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-y-auto overscroll-contain p-3 font-mono text-[11px] leading-relaxed select-text",children:k?(0,r.Y)("pre",{className:"overflow-x-auto whitespace-pre text-ink/85 leading-relaxed",dangerouslySetInnerHTML:{__html:F}}):b.text.split("\n").map((e,t)=>{let n=e.includes("✓")||e.includes("built in")||e.includes("ready: 0 errors"),i=e.includes("Error:")||e.includes("error:")||e.includes("FAILED"),s=e.includes("warning:")||e.includes("warn:");return(0,r.Y)("div",{className:`whitespace-pre-wrap break-words ${n?"text-success font-medium":i?"text-error font-medium":s?"text-warning font-medium":"text-ink/80"}`,children:e||" "},t)})})]})]})}var tK=n("W0"),tU=n("jx"),tq=n("Nf");function tB(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=t.output||("string"==typeof a.displayContent?a.displayContent:""),o=function(e){let t=e.input;if(t&&"object"==typeof t){if("string"==typeof t.pattern)return t.pattern;if("string"==typeof t.path)return t.path;if("string"==typeof t.glob)return t.glob;if("string"==typeof t.query)return t.query;if("string"==typeof t.regex)return t.regex;if("string"==typeof t.search)return t.search;if("string"==typeof t.text)return t.text}return"string"==typeof e.target&&"."!==e.target?e.target:""}(t),c="glob"===t.type||"glob"===t.name,d=(0,i.Kr)(()=>tv(l,1e3),[l]),{files:u,totalMatches:p,isGlobList:m}=(0,i.Kr)(()=>(function(e){let t=e.split(/\r?\n/),n=[],r=[],i=null,s=!0;for(let e of t){let t=e.trimEnd();if(!t||t.startsWith("[")&&t.endsWith("]")||/^Showing files \d+/i.test(t)||/^Found \d+ matches/i.test(t))continue;let a=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+)):(\d+)(?::\d+)?:(.*)$/);if(a){s=!1;let e=a[1].trim(),t=parseInt(a[2],10)||1,r=a[3],l=n.find(t=>t.path===e);l||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),l={path:e,lines:[],matchCount:0},n.push(l),i=l),l.lines.push({lineNum:t,text:r,isMatch:!0}),l.matchCount++;continue}let l=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+))-(\d+)-(.*)$/);if(l){s=!1;let e=l[1].trim(),t=parseInt(l[2],10)||1,r=l[3],a=n.find(t=>t.path===e);a||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),a={path:e,lines:[],matchCount:0},n.push(a),i=a),a.lines.push({lineNum:t,text:r,isMatch:!1});continue}let o=t.match(/^(#{1,6})\s+(.+)$/);if(o){let e=o[1].length,t=o[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let e=r.filter(Boolean).join("");i={path:e?`${e.replace(/\/+$/,"")}/${t}`:t,lines:[],matchCount:0}}continue}let c=t.match(/^(\*?)(\s*\d+)[|:\u2502](.*)$/);if(c){s=!1;let e="*"===c[1],t=parseInt(c[2].trim(),10)||1,r=c[3];i||(i={path:"Results",lines:[],matchCount:0},n.push(i)),i.lines.push({lineNum:t,text:r,isMatch:e}),e&&i.matchCount++;continue}if(!t.startsWith("#")&&!c){(t.includes("|")||t.includes(":")||t.includes("│"))&&(s=!1);let e=r.filter(Boolean).join(""),i=e?`${e.replace(/\/+$/,"")}/${t}`:t;n.push({path:i,lines:[],matchCount:1})}}i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let a=n.reduce((e,t)=>e+(t.matchCount||t.lines.length||1),0);return{files:n,totalMatches:a,isGlobList:s}})(d.text),[d.text]),h=(0,i.Kr)(()=>{if(!n)return u;let e=n.toLowerCase();return u.map(t=>{let n=t.path.toLowerCase().includes(e),r=t.lines.filter(t=>t.text.toLowerCase().includes(e));return n?t:r.length>0?{...t,lines:r}:null}).filter(e=>null!==e)},[u,n]),f=(0,e8.w)(),x=(0,i.Kr)(()=>h.map(e=>{let t=(0,e3.sQ)(e.path);return(0,e3.O9)(e.lines.map(e=>e.text).join("\n"),t)}),[h,f]);return l||0!==u.length?(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-ink/5 text-ink/60",children:c||m?(0,r.Y)(tK.A,{size:12}):(0,r.Y)(tU.A,{size:12})}),(0,r.Y)("span",{className:"font-semibold text-ink",children:c||m?"Files Found":"Search Matches"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/60",children:[p," ",1===p?"match":"matches"]}),u.length>1&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:["in ",u.length," ",1===u.length?"file":"files"]}),o&&(0,r.FD)("span",{className:"rounded border border-ink/10 bg-canvas px-1.5 py-0.5 font-mono text-[10px] text-ink/75",children:['"',o,'"']})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[u.length>4&&(0,r.Y)("input",{type:"text",placeholder:"Filter paths...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-28 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink placeholder:text-ink/30 focus:border-ink/30 focus:outline-none"}),(0,r.Y)(e$,{text:l,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),d.skipped>0&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:["… ",d.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"max-h-80 space-y-2 overflow-y-auto overscroll-contain pr-0.5",children:[h.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(eE.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink/85",children:e.path})]}),e.matchCount>0&&!m&&(0,r.FD)("span",{className:"ml-2 shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/50",children:[e.matchCount," ",1===e.matchCount?"hit":"hits"]})]}),e.lines.length>0&&(0,r.Y)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,r.Y)("div",{className:"w-max min-w-full divide-y divide-ink/[0.04] font-mono text-[11px] leading-relaxed select-text",children:e.lines.map((e,n)=>(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1 transition-colors ${e.isMatch?"bg-warning/[0.08] text-ink":"bg-paper text-ink/60 hover:bg-ink/[0.02]"}`,children:[(0,r.FD)("span",{className:`sticky left-0 z-10 flex w-9 shrink-0 select-none items-center justify-end bg-inherit font-mono text-[10px] ${e.isMatch?"font-semibold text-warning-dark dark:text-warning":"text-ink/30"}`,children:[e.isMatch&&(0,r.Y)(tq.A,{size:10,className:"mr-0.5 text-warning"}),e.lineNum]}),(0,r.Y)("pre",{className:"shiki whitespace-pre font-mono",dangerouslySetInnerHTML:{__html:x[t]?.[n]||"&nbsp;"}})]},n))})})]},t)),0===h.length&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 p-4 text-center font-mono text-[11px] text-ink/40",children:['No results match filter "',n,'"']})]})]}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[c?(0,r.Y)(tK.A,{size:13,className:"shrink-0"}):(0,r.Y)(tU.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",c?"files":"matches"," found",o?` for "${o}"`:""]})]})}var tH=n("B5"),tG=n("gk");function tV(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"high"===t||"critical"===t||"error"===t?"high":"medium"===t||"warning"===t?"medium":"low"===t?"low":"info"}let tZ={high:"bg-error/10 text-error",medium:"bg-warning/10 text-warning",low:"bg-ink/8 text-ink/60",info:"bg-ink/5 text-ink/50"};function tQ(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.findings)?n.findings:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.findings))return t.findings;if(Array.isArray(t.vulnerabilities))return t.vulnerabilities;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");if(0===i.length)return t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-success/20 bg-success/[0.04] px-3 py-2.5 text-[11.5px] text-success",children:[(0,r.Y)(tH.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No issues found"})]});let s=function(e){let t={high:0,medium:0,low:0,info:0};for(let n of e)t[tV(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Findings"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.high>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.high," high"]}),s.medium>0&&(0,r.FD)("span",{className:"rounded-full bg-warning/10 px-1.5 py-px text-warning",children:[s.medium," med"]}),s.low>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/55",children:[s.low," low"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=tV(e),i="string"==typeof e.message?e.message:"",s="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",a="number"==typeof e.line?e.line:void 0,l="string"==typeof e.rule?e.rule:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(tG.A,{size:11,className:`mt-0.5 shrink-0 ${"high"===n?"text-error":"medium"===n?"text-warning":"text-ink/40"}`}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[(0,r.Y)("span",{className:`mr-1.5 rounded-full px-1.5 py-px font-mono text-[9px] ${tZ[n]}`,children:n}),s&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[s,void 0!==a?`:${a}`:"",": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),l&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",l,")"]})]})]},t)})})]})}var tX=n("zH"),t0=n("cQ");let t1={running:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",failed:"bg-error/10 text-error",idle:"bg-ink/5 text-ink/45"};function t5(e){let{tool:t}=e,n=t.details??{},s=Array.isArray(n.jobs)?n.jobs:Array.isArray(n.items)?n.items:[],a=t.input,l="object"==typeof a&&null!==a?a:void 0,o=t.output||"";if(l?.op==="wait"){let e=Array.isArray(l.ids)?l.ids:[],t="string"==typeof l.name?l.name:void 0,n="string"==typeof l.for?l.for:void 0,i="number"==typeof l.timeout?`${l.timeout}s`:"number"==typeof l.timeoutMs?`${Math.round(l.timeoutMs/1e3)}s`:void 0;return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tX.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:t?`Hub Wait: ${t}`:"Hub Wait"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?`wait (${n})`:"job wait"})]}),i&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:["timeout: ",i]})]}),e.length>0&&(0,r.FD)("div",{className:"pt-1",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Waiting for Job IDs"}),(0,r.Y)("div",{className:"mt-1 flex flex-wrap gap-1.5 font-mono text-[10.5px]",children:e.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/80",children:e},t))})]}),o&&(0,r.Y)(tk,{text:o})]})}if(l?.op==="logs"){let e="string"==typeof l.name?l.name:"Process";return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.Y)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eJ.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:e}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"logs"})]})}),(0,r.Y)("div",{className:"rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/85 whitespace-pre-wrap",children:o||"// No log output"})]})}let c=(0,i.Kr)(()=>{let e="string"==typeof l?.op?l.op.toLowerCase():"",t=["start","stop","restart","status"].includes(e),n=o.includes("pid=");if(!t&&!n)return null;let r=l?.name||"Service",i=l?.application,s=Array.isArray(l?.args)?l.args.join(" "):"",a=i?`${i} ${s}`.trim():s,c=l?.ready?.port,d=o.match(/pid=(\d+)/i),u=o.match(/uptime=([^\s]+)/i),p=o.match(/restarts=(\d+)/i),m=o.toLowerCase().includes("ready")||o.toLowerCase().includes("started")||o.toLowerCase().includes("running");return{op:e||"process",name:r,cmd:a,port:c,pid:d?d[1]:void 0,uptime:u?u[1]:void 0,restarts:p?p[1]:void 0,isReady:m,outputLines:o.split(/\r?\n/).filter(Boolean)}},[l,o]);return c?(0,r.Y)("div",{className:"space-y-2",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eJ.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:c.name}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] uppercase tracking-wider text-ink/50",children:c.op})]}),c.isReady&&(0,r.FD)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-semibold text-success",children:[(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-success animate-pulse"}),"Active"]})]}),(0,r.FD)("div",{className:"divide-y divide-ink/[0.04] p-3 text-[11px]",children:[c.cmd&&(0,r.FD)("div",{className:"flex items-center justify-between py-1 font-mono",children:[(0,r.Y)("span",{className:"text-ink/45",children:"Command"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/85",children:c.cmd})]}),(0,r.FD)("div",{className:"flex flex-wrap items-center gap-4 py-1.5 font-mono text-[10.5px]",children:[c.port&&(0,r.FD)("span",{className:"text-ink/60",children:["Port: ",(0,r.Y)("strong",{className:"text-ink",children:c.port})]}),c.pid&&(0,r.FD)("span",{className:"text-ink/60",children:["PID: ",(0,r.Y)("strong",{className:"text-ink",children:c.pid})]}),c.uptime&&(0,r.FD)("span",{className:"text-ink/60",children:["Uptime: ",(0,r.Y)("strong",{className:"text-ink",children:c.uptime})]})]}),c.outputLines.length>0&&(0,r.FD)("div",{className:"pt-2",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Log Output"}),(0,r.Y)("div",{className:"mt-1 rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/75",children:c.outputLines.map((e,t)=>(0,r.Y)("div",{children:e},t))})]})]})]})}):0===s.length?o?(0,r.Y)(tk,{text:o}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(t0.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No hub activities"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Hub Jobs"}),(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:s.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:s.map((e,t)=>{let n,i="running"===(n="string"==typeof e.status?e.status.toLowerCase():"string"==typeof e.state?e.state.toLowerCase():"")||"started"===n||"pending"===n?"running":"done"===n||"completed"===n||"success"===n?"done":"failed"===n||"error"===n?"failed":"idle",s="string"==typeof e.id?e.id:"string"==typeof e.name?e.name:`job-${t}`,a="string"==typeof e.label?e.label:"string"==typeof e.task?e.task:"string"==typeof e.message?e.message:"",l="string"==typeof e.type?e.type:void 0,o="number"==typeof e.durationMs?`${(e.durationMs/1e3).toFixed(1)}s`:void 0,c="string"==typeof e.resolvedModel?e.resolvedModel:void 0;return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px]",children:["running"===i?(0,r.Y)(tX.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):"done"===i?(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-success"}):(0,r.Y)(t$.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/80",children:s}),l&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/45",children:l}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/85",children:a}),c&&(0,r.Y)("span",{className:"hidden sm:inline-block font-mono text-[9px] text-ink/40 truncate max-w-[120px]",children:c}),o&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:o}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${t1[i]}`,children:i})]},t)})})]}),o&&(0,r.Y)(tk,{text:o})]})}var t2=n("jI"),t4=n("rY"),t3=n("Os");function t8(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.notes)?n.notes:[],s="new_context"===t.type;return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[s?(0,r.Y)(t2.A,{size:13,className:"shrink-0"}):(0,r.Y)(t4.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",s?"notes created":"notes"]})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"New Context":"Notes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.title&&e.title?e.title:"string"==typeof e.text&&e.text?e.text:"string"==typeof e.content&&e.content?e.content:"string"==typeof e.note?e.note:"";return n?(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[s?(0,r.Y)(t3.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(t4.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n})]},"string"==typeof e.id?e.id:`note-${t}`):null})})]})}var t6=n("YO"),t9=n("Y0"),t7=n("z9");let ne={memory_edit:{label:"Memory Edit",icon:(0,r.Y)(eq.A,{size:11})},retain:{label:"Retained",icon:(0,r.Y)(t6.A,{size:11})},recall:{label:"Recalled",icon:(0,r.Y)(K.A,{size:11})},reflect:{label:"Reflections",icon:(0,r.Y)(K.A,{size:11})},learn:{label:"Learned",icon:(0,r.Y)(t9.A,{size:11})}};function nt(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.memories))return t.memories;if(Array.isArray(t.results))return t.results}}catch{}return[]}(t.output??""),s=ne[t.type]??{label:"Memory",icon:(0,r.Y)(K.A,{size:11})};return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(t7.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No memories"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s.label}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.text&&e.text?e.text:"string"==typeof e.content?e.content:"";if(!n)return null;let i="number"==typeof e.score&&Number.isFinite(e.score)?e.score:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"mt-0.5 shrink-0 text-ink/40",children:s.icon}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n}),void 0!==i&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[Math.round(100*i),"%"]})]},"string"==typeof e.id?e.id:`mem-${t}`)})})]})}var nn=n("ND"),nr=n("u8");function ni(e){let t="string"==typeof e.state?e.state.toLowerCase():"";return"attached"===t||"running"===t?t:"detached"===t?"detached":"stopped"}let ns={attached:"bg-success/10 text-success",running:"bg-ink/8 text-ink/60",stopped:"bg-ink/5 text-ink/45",detached:"bg-error/10 text-error"};function na(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[];if(0===i.length)return t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(nn.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No debug session"})]});let s=function(e){let t={attached:0,running:0,stopped:0,detached:0};for(let n of e)t[ni(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Debug Session"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.attached>0&&(0,r.FD)("span",{className:"rounded-full bg-success/10 px-1.5 py-px text-success",children:[s.attached," attached"]}),s.running>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/60",children:[s.running," run"]}),s.detached>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.detached," detach"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=ni(e),i="string"==typeof e.target&&e.target?e.target:"number"==typeof e.pid?`pid ${e.pid}`:"string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["attached"===n?(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-success"}):"running"===n?(0,r.Y)(nr.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):(0,r.Y)(tt.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/75",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${ns[n]}`,children:n})]},`${i}-${t}`)})})]})}var nl=n("vBE"),no=n("qd"),nc=n("Sy"),nd=n("oS");let nu={active:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",paused:"bg-warning/10 text-warning"};function np(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[],s="yield"===t.type||"yield"===t.name,a="error"===t.status;if(s){let e=function(e){let t=(0,nd.u)(e.details)?e.details:void 0,n=(0,nd.u)(e.input)?e.input:void 0,r=(t&&(0,nd.u)(t.data)?t.data:void 0)??(n&&(0,nd.u)(n.data)?n.data:void 0)??t??n;if(!r)return null;let i="string"==typeof r.summary?r.summary:void 0,s="string"==typeof r.report?r.report:void 0,a="string"==typeof r.architecture?r.architecture:void 0,l=Array.isArray(r.files)?r.files:void 0,o=[];if(l)for(let e of l)"string"==typeof e&&e?o.push(e):(0,nd.u)(e)&&"string"==typeof e.path&&o.push({path:e.path,description:"string"==typeof e.description?e.description:void 0});let c="string"==typeof t?.status?t.status:"string"==typeof r.status?r.status:void 0,d="string"==typeof r.error?r.error:null;return i||s||a||0!==o.length||d?{summary:i,report:s,architecture:a,files:o.length>0?o:void 0,status:c,error:d}:null}(t);if(e)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper text-[12px] text-ink select-text",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:`flex h-5 w-5 items-center justify-center rounded-md ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:a||e.error?(0,r.Y)(tw.A,{size:12}):(0,r.Y)(e9.A,{size:12})}),(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:a||e.error?"Yield Error":"Yield Result"})]}),(e.status||(a?"error":"success"))&&(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-medium uppercase ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.status||(a?"failed":"success")})]}),(0,r.FD)("div",{className:"space-y-2.5 p-3",children:[(e.error||a&&t.output)&&(0,r.FD)("div",{className:"flex items-start gap-2 rounded-md bg-error/10 p-2.5 text-error text-[11.5px]",children:[(0,r.Y)(tw.A,{size:13,className:"shrink-0 mt-0.5"}),(0,r.Y)("span",{className:"font-mono leading-relaxed",children:e.error||t.output})]}),e.summary&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Summary"}),(0,r.Y)("p",{className:"mt-0.5 font-sans text-[12px] text-ink font-medium leading-relaxed",children:e.summary})]}),e.report&&e.report!==e.summary&&(0,r.FD)("div",{className:"rounded-md border border-ink/8 bg-canvas/30 p-2.5",children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Report"}),(0,r.Y)("div",{className:"mt-1 text-[11.5px] text-ink/85 leading-relaxed",children:(0,r.Y)(eS.T,{content:e.report})})]}),e.architecture&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Evidence / Architecture"}),(0,r.Y)("div",{className:"mt-0.5 text-[11px] text-ink/75 leading-relaxed bg-ink/[0.03] p-2 rounded border border-ink/6",children:(0,r.Y)(eS.T,{content:e.architecture})})]}),e.files&&e.files.length>0&&(0,r.FD)("div",{children:[(0,r.FD)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:["Files Inspected (",e.files.length,")"]}),(0,r.Y)("div",{className:"mt-1 grid grid-cols-1 gap-1 sm:grid-cols-2",children:e.files.map((e,t)=>{let n="string"==typeof e?e:e.path,i="string"==typeof e?void 0:e.description;return(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5",children:[(0,r.FD)("span",{className:"inline-flex items-center gap-1 font-mono text-[10.5px] font-medium text-ink truncate",children:[(0,r.Y)(eE.A,{size:10,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:n})]}),i&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight mt-0.5 truncate",children:i})]},t)})})]})]})]})}return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tt.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:s?"No yield":"No goals"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"Yield":"Goals"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.title&&e.title?e.title:"string"==typeof e.description?e.description:"";if(!i)return null;let a="number"==typeof e.progress&&Number.isFinite(e.progress)?e.progress:void 0,l="done"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"completed"===n?"done":"paused"===n||"yielded"===n?"paused":"active";return(0,r.FD)("div",{className:"px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-start gap-2 text-[11.5px]",children:[s?(0,r.Y)(nl.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(no.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${nu[l]}`,children:l})]}),void 0!==a&&(0,r.FD)("div",{className:"mt-1.5 flex items-center gap-1.5 pl-[18px]",children:[(0,r.Y)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-ink/60 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,Math.round(100*a)))}%`}})}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-0.5 font-mono text-[9px] text-ink/45",children:[(0,r.Y)(nc.A,{size:8}),Math.round(100*a),"%"]})]})]},"string"==typeof e.id?e.id:`goal-${t}`)})})]})}var nm=n("fj"),nh=n("qw");function nf(e){let{tool:t}=e,n=t.details??{},s=n.xdev??{},a=s.inner??{},l=s.args??{},o=t.output??"",c=!1===a.applied||o.toLowerCase().includes("staged as a proposal")||o.toLowerCase().includes("files not modified yet"),d=Array.isArray(l.ops)?l.ops:[],u=Array.isArray(l.paths)?l.paths:a.scopePath?[a.scopePath]:[],p=a.displayContent||(o.includes("-")&&o.includes("+")?o:""),m=p?p.split(/\r?\n/).filter(e=>!e.startsWith("Staged as a proposal")&&!!e.trim()):[],h=Array.isArray(n.changes)?n.changes:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.changes))return t.changes;if(Array.isArray(t.edits))return t.edits}}catch{}return[]}(o),f=(0,e8.w)(),x=(0,e3.sQ)(u[0]),g=(0,i.Kr)(()=>{let e=m.map(e=>e.startsWith("+")||e.startsWith("-")||e.startsWith(" ")?e.slice(1):e);return(0,e3.O9)(e.join("\n"),x)},[m,x,f]);if(c||d.length>0||m.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(nm.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:"AST Edit"}),u.length>0&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/50 truncate max-w-[200px]",children:u[0]})]}),(0,r.FD)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-mono text-[9px] font-semibold ${c?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:[c?(0,r.Y)(tz.A,{size:10}):(0,r.Y)(e9.A,{size:10}),c?"STAGED PROPOSAL":"APPLIED"]})]}),d.length>0&&(0,r.FD)("div",{className:"border-b border-ink/6 p-2.5 bg-canvas/20",children:[(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40",children:"Pattern Transformation"}),(0,r.Y)("div",{className:"mt-1 space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded border border-ink/6 bg-paper px-2 py-1 font-mono text-[10.5px]",children:[(0,r.Y)("span",{className:"text-error/90 line-through truncate",children:e.pat}),(0,r.Y)(nh.A,{size:10,className:"shrink-0 text-ink/35"}),(0,r.Y)("span",{className:"text-success/90 font-medium truncate",children:e.out||"/* removed */"})]},t))})]}),m.length>0&&(0,r.Y)("div",{className:"p-2.5 font-mono text-[10.5px] leading-relaxed bg-canvas/30 space-y-0.5",children:m.map((e,t)=>{let n=e.startsWith("-"),i=e.startsWith("+"),s=g[t]||"";return(0,r.FD)("div",{className:`rounded px-1.5 py-0.5 ${n?"bg-error/10 text-error font-medium":i?"bg-success/10 text-success font-medium":"text-ink/70"}`,children:[(n||i)&&e[0],s?(0,r.Y)("span",{className:"shiki",dangerouslySetInnerHTML:{__html:s}}):n||i?e.slice(1):e]},t)})}),c&&(0,r.FD)("div",{className:"border-t border-ink/6 bg-paper px-3 py-1.5 text-[10px] text-ink/50",children:["Proposal staged in memory. Apply with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://resolve"})," or discard with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://reject"}),"."]})]})});if(h.length>0)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"AST Changes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:h.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:h.map((e,t)=>{let n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="string"==typeof e.message?e.message:"",s="string"==typeof e.nodeKind?e.nodeKind:"",a="number"==typeof e.changes?e.changes:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(nm.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[n&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[n,": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),s&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",s,")"]})]}),void 0!==a&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[a," changes"]})]},t)})})]});let b=o.split(/\r?\n/).filter(Boolean);return 0===b.length?null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40 select-text",children:b.map((e,t)=>(0,r.Y)("li",{className:"px-2.5 py-1.5 font-mono text-[11px] break-words text-ink/75",children:e},t))})}function nx(e){let{tool:t}=e,n=(t.details??{}).xdev??{},i=n.inner??{},s="object"==typeof t.input&&null!==t.input?t.input:void 0,a="reject"===t.name||t.target?.includes("reject")||"reject"===n.tool||"reject"===i.action||"discard"===i.action,l=i.reason||n.args?.reason||("string"==typeof s?.content?s.content:"")||("string"==typeof t.input?t.input:""),o=i.sourceToolName||"ast_edit",c=i.label||t.output||(a?"Proposal discarded":"Proposal applied"),d=Array.isArray(i.sourceResultDetails?.files)?i.sourceResultDetails.files:[],u=i.sourceResultDetails?.totalReplacements??i.totalReplacements;return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2 border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[a?(0,r.Y)(e7.A,{size:14,className:"text-warning shrink-0"}):(0,r.Y)(e9.A,{size:14,className:"text-success shrink-0"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:a?"Proposal Discarded":"Proposal Applied"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:o})]}),(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-semibold ${a?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:a?"REJECTED":"RESOLVED"})]}),l&&(0,r.FD)("div",{className:"pt-2.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Reason"}),(0,r.FD)("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink/85 italic",children:["“",l,"”"]})]}),c&&(0,r.Y)("div",{className:"mt-2 text-[11.5px] font-medium text-ink/80",children:c}),d.length>0&&(0,r.FD)("div",{className:"mt-2.5 space-y-1 border-t border-ink/6 pt-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.FD)("span",{children:["Touched Files (",d.length,")"]}),"number"==typeof u&&(0,r.FD)("span",{children:[u," replacement",1===u?"":"s"]})]}),(0,r.Y)("div",{className:"space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10.5px] text-ink/70",children:[(0,r.Y)(eE.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate",children:e})]},t))})]})]})})}var ng=n("xn"),nb=n("JH");let nv={enabled:"bg-success/10 text-success",installed:"bg-ink/8 text-ink/60",disabled:"bg-ink/5 text-ink/45",removed:"bg-error/10 text-error"};function nk(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.skills)?n.skills:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.skills))return t.skills;if(Array.isArray(t.items))return t.items}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Skills"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.name?e.name:"string"==typeof e.slug?e.slug:"";if(!i)return null;let s="enabled"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"installed"===n?n:"removed"===n||"uninstalled"===n||"deleted"===n?"removed":"disabled",a="string"==typeof e.scope?e.scope:void 0,l="string"==typeof e.version?e.version:void 0,o="string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["removed"===s?(0,r.Y)(ng.A,{size:11,className:"shrink-0 text-error"}):(0,r.Y)(nb.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/70",children:i}),a&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:a}),l&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:["v",l]}),o&&(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/65",children:o}),(0,r.Y)("span",{className:`ml-auto shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${nv[s]}`,children:s})]},t)})})]})}function ny(e){return"string"==typeof e.path?e.path:"string"==typeof e.name?e.name:""}function nw(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=Array.isArray(a.results)?a.results:[],o=(0,i.Kr)(()=>{if(l.length>0)return l;if(t.output)try{let e=JSON.parse(t.output);if(Array.isArray(e))return e;if(e&&"object"==typeof e){if(Array.isArray(e.results))return e.results;if(Array.isArray(e.items))return e.items;if(Array.isArray(e.files))return e.files}}catch{}return(t.output??"").split(/\r?\n/).filter(Boolean).map(e=>{let t=e.endsWith("/");return{path:e,type:t?"dir":"file"}})},[l,t.output]),c=(0,i.Kr)(()=>{if(!n)return o;let e=n.toLowerCase();return o.filter(t=>ny(t).toLowerCase().includes(e))},[o,n]);return 0===o.length?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tK.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No filesystem matches found"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tK.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Filesystem Search"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[9.5px] text-ink/50",children:[o.length," ",1===o.length?"entry":"entries"]})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[o.length>5&&(0,r.Y)("input",{type:"text",placeholder:"Filter...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-24 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink focus:outline-none"}),(0,r.Y)(e$,{text:o.map(e=>ny(e)).join("\n"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),(0,r.Y)("div",{className:"max-h-64 divide-y divide-ink/6 overflow-y-auto rounded-lg border border-ink/8 bg-paper",children:c.map((e,t)=>{let n,i=ny(e);if(!i)return null;let s="file"===(n="string"==typeof e.type?e.type.toLowerCase():"")||"directory"===n||"dir"===n?"directory"===n||"dir"===n?"dir":"file":"unknown",a="number"==typeof e.size&&e.size>0?(0,ti.z3)(e.size):"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px] transition-colors hover:bg-ink/[0.02]",children:["dir"===s?(0,r.Y)(N.A,{size:12,className:"shrink-0 text-ink/50"}):(0,r.Y)(ex.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-ink/80",children:i}),"unknown"!==s&&(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider ${"dir"===s?"bg-ink/8 text-ink/60":"bg-ink/5 text-ink/45"}`,children:s}),a&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:a})]},t)})})]})}function nN(e,t){let n=e[t];return n&&n.length>0?n[n.length-1]:null}function nY(e){return`ompchamber.ask-draft:${e}`}var nD=n("DTR");let nF=/ \(recommended\)$/i,nA=/\bdone\b/i;function nC(e){let{frame:t,multi:n,selected:s,onAnswer:a,onToggle:l,onRespond:o}=e,[d,u]=(0,i.J0)("");if((0,i.vJ)(()=>{u("editor"===t.method?t.prefill??"":"")},[t.id,t.method,t.prefill]),"confirm"===t.method)return(0,r.FD)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.FD)("button",{type:"button",onClick:()=>o({confirmed:!0}),className:"flex cursor-pointer items-center gap-1.5 rounded-md bg-ink px-3 py-1 text-[11.5px] font-semibold text-paper transition-opacity hover:opacity-90",children:[(0,r.Y)(D.A,{size:11}),(0,r.Y)("span",{children:"Confirm"})]}),(0,r.Y)("button",{type:"button",onClick:()=>o({confirmed:!1}),className:"cursor-pointer rounded-md border border-ink/15 px-3 py-1 text-[11.5px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:text-ink",children:"Decline"})]});if("input"===t.method||"editor"===t.method)return(0,r.FD)("div",{className:"mt-2 space-y-1.5",children:[t.title&&(0,r.Y)("div",{className:"text-[10.5px] text-ink/45",children:t.title}),"editor"===t.method?(0,r.Y)("textarea",{autoFocus:!0,value:d,onChange:e=>u(e.currentTarget.value),rows:4,placeholder:t.placeholder||"Type your answer…",className:"w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 font-mono text-[11.5px] leading-relaxed text-ink outline-none focus:border-ink"}):(0,r.Y)("input",{autoFocus:!0,value:d,placeholder:t.placeholder||"Type your answer…",onChange:e=>u(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),o({value:d}))},className:"w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 text-[11.5px] text-ink outline-none focus:border-ink"}),(0,r.FD)("button",{type:"button",onClick:()=>o({value:d}),className:"flex cursor-pointer items-center gap-1.5 rounded-md bg-ink px-3 py-1 text-[11.5px] font-semibold text-paper transition-opacity hover:opacity-90",children:[(0,r.Y)("span",{children:"Submit"}),(0,r.Y)(nD.A,{size:11,className:"opacity-70"})]})]});let p=t.options??[],m=t.optionDetails??[];return"select"!==t.method||0===p.length?null:(0,r.FD)("div",{className:"mt-2 space-y-1",role:n?"group":"radiogroup",children:[p.map((e,t)=>{if(!n&&c.test(e.trim()))return null;let i=m[t]?.description,d=n&&s.includes(e),u=n&&nA.test(e);return(0,r.FD)("button",{type:"button",onClick:()=>n?u?o({value:e}):l(e):a(e),className:`flex w-full cursor-pointer items-start gap-2 rounded-md border px-2.5 py-1.5 text-left text-[11.5px] transition-colors ${d?"border-ink/30 bg-ink/5 text-ink":u?"border-ink/20 bg-canvas/60 font-medium text-ink hover:border-ink/40":"border-ink/8 bg-canvas/30 text-ink/80 hover:border-ink/25 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)("span",{className:`mt-1 h-3 w-3 shrink-0 ${n?"rounded-[3px]":"rounded-full"} border ${d?"border-ink bg-ink":"border-ink/30"}`}),(0,r.FD)("span",{className:"min-w-0 flex-1",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 font-medium",children:[(0,r.Y)("span",{className:"truncate",children:e}),nF.test(e)&&!n&&(0,r.Y)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] uppercase tracking-wider text-ink/45",children:"Suggested"})]}),i&&(0,r.Y)("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-ink/50",children:i})]})]},e)}),!n&&(0,r.Y)("input",{value:d,placeholder:"Other — type your own answer…",onChange:e=>u(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&d.trim()&&(e.preventDefault(),a(d.trim()))},className:"w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 text-[11.5px] text-ink outline-none focus:border-ink"})]})}function nS(e){let t,{index:n,total:i,question:s,frames:a,recorded:l,draft:o,passed:c,multiSelected:d,onAnswer:u,onToggle:p,onRespond:m}=e,h=a.length>0?a[a.length-1]:null,f=l?(t=[...l.selectedOptions],l.customInput&&t.push(l.customInput),t):o?[o]:d,x=!!h&&!l&&(s.multi||!o);return(0,r.Y)("div",{className:"rounded-lg border border-ink/10 bg-paper p-2.5 shadow-xs",children:(0,r.FD)("div",{className:"flex items-start gap-2",children:[(0,r.Y)("span",{className:"mt-px flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] font-semibold text-ink/60",children:n+1}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40",children:s.header??`Question ${n+1}`}),s.multi&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[8.5px] text-ink/45",children:"multi"}),i>1&&(0,r.FD)("span",{className:"ml-auto font-mono text-[9px] text-ink/35",children:[n+1,"/",i]})]}),(0,r.Y)("div",{className:"mt-1 text-[12.5px] leading-relaxed text-ink/90 select-text",children:(0,r.Y)(eS.T,{content:s.question})}),x&&h&&(0,r.Y)(nC,{frame:h,multi:s.multi,selected:d,onAnswer:u,onToggle:p,onRespond:m}),f.length>0&&(0,r.FD)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-success"}),f.map(e=>(0,r.Y)("span",{className:"rounded-md border border-ink/12 bg-canvas/40 px-2 py-0.5 text-[11.5px] font-medium text-ink select-text",children:e},e)),l?.timedOut&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:"auto-selected on timeout"})]}),!x&&0===f.length&&c&&(0,r.FD)("div",{className:"mt-2 flex items-center gap-1.5 text-[10.5px] text-ink/45",children:[(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-ink/35"}),(0,r.Y)("span",{children:"Answered earlier in this run."})]}),!x&&0===f.length&&!c&&(0,r.FD)("div",{className:"mt-2 space-y-1 border-t border-ink/6 pt-2",children:[s.options.map((e,t)=>(0,r.FD)("div",{className:"flex items-start gap-2 px-0.5 text-[11.5px] text-ink/45",children:[(0,r.Y)("span",{className:"mt-1 h-3 w-3 shrink-0 rounded-full border border-ink/20"}),(0,r.FD)("span",{className:"min-w-0 flex-1",children:[(0,r.FD)("span",{className:"block truncate",children:[e.label,s.recommended===t&&(0,r.Y)("span",{className:"ml-1.5 font-mono text-[9px] uppercase tracking-wider text-ink/35",children:"suggested"})]}),e.description&&(0,r.Y)("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-ink/35",children:e.description})]})]},e.label)),(0,r.FD)("div",{className:"flex items-center gap-1.5 pt-0.5 text-[10.5px] text-ink/40",children:[(0,r.Y)(tz.A,{size:10,className:"shrink-0"}),(0,r.Y)("span",{children:"Waiting for the previous answer…"})]})]})]})]})})}let nT=[],nz=[],n$=[];function nj(e){let{tool:t}=e,n=h(t),s=function(e,t){let n=t.map(()=>null);if(0===t.length)return n;let r=e.details??{},i=Array.isArray(r.results)?r.results:null;if(i){for(let e=0;e<n.length;e+=1){let t=i[e];t&&"object"==typeof t&&(n[e]=f(t))}return n}return void 0!==r.selectedOptions||"string"==typeof r.customInput?(n[0]=f(r),n):"error"===e.status||"aborted"===e.status||e.isError?n:function(e,t){let n=t.map(()=>null),r=e.trim();if(!r)return n;let i=new Map;for(let e of r.split("\n")){let n=x.exec(e.trim());n&&i.set(n[1],v(n[2],t.some(e=>e.multi)))}if(i.size>0){let e=[...i.values()];for(let r=0;r<t.length;r+=1){let s=t[r].id;n[r]=(s?i.get(s):void 0)??e[r]??null}return n}let s=g.exec(r);if(s)return n[0]=v(s[1],t[0].multi),n;let a=b.exec(r);return a?n[0]={selectedOptions:[],customInput:a[1].trim()}:1!==t.length||r.includes("\n")||(n[0]={selectedOptions:[r]}),n}("string"==typeof e.output?e.output:"",t)}(t,n),{framesByTool:l,respond:o}=(0,a.NT)(y),c=l.get(t.id)??nz,{drafts:d,multiSelected:u,commit:p,toggleMulti:m}=function(e){let{toolId:t,questions:n,groups:r,recorded:s,respond:a}=e,[l,o]=(0,i.J0)(()=>(function(e){try{let t=sessionStorage.getItem(nY(e));return t?JSON.parse(t):{}}catch{return{}}})(t)),[c,d]=(0,i.J0)({}),u=(0,i.li)(new Set);return(0,i.vJ)(()=>{for(let e=0;e<n.length;e+=1){if(s[e]||n[e].multi)continue;let t=l[e];if(!t)continue;let i=nN(r,e);!i||"select"!==i.method||u.current.has(i.id)||(u.current.add(i.id),a(i,{value:t}))}},[n,r,l,s,a]),(0,i.vJ)(()=>{try{sessionStorage.setItem(nY(t),JSON.stringify(l))}catch{}},[t,l]),{drafts:l,multiSelected:c,commit:(0,i.hb)((e,t)=>{o(n=>n[e]===t?n:{...n,[e]:t})},[]),toggleMulti:(0,i.hb)((e,t)=>{let n=nN(r,e);!n||u.current.has(n.id)||(u.current.add(n.id),a(n,{value:t}),d(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}}))},[r,a])}}({toolId:t.id,questions:n,groups:c,recorded:s,respond:o});if(0===n.length)return t.output?(0,r.Y)(tk,{text:t.output}):null;let k=c.some((e,t)=>e.length>0&&!s[t]),w=c.findIndex(e=>e.length>0);return(0,r.FD)("div",{className:"space-y-2",children:[k&&(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[10.5px] text-ink/50",children:[(0,r.Y)(e_.A,{size:11,className:"shrink-0"}),(0,r.Y)("span",{children:"Input needed — the agent is blocked until you answer."})]}),n.map((e,t)=>(0,r.Y)(nS,{index:t,total:n.length,question:e,frames:c[t]??nT,recorded:s[t]??null,draft:d[t],passed:-1!==w&&t<w,multiSelected:u[t]??n$,onAnswer:e=>p(t,e),onToggle:e=>m(t,e),onRespond:e=>{let n=nN(c,t);n&&o(n,e)}},e.id??t)),("error"===t.status||"aborted"===t.status)&&t.output&&(0,r.FD)("div",{className:"flex items-start gap-2 rounded-md border border-ink/8 bg-ink/[0.02] px-2.5 py-1.5 text-[10.5px] text-ink/60",children:[(0,r.Y)(e7.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"font-mono select-text",children:t.output})]})]})}function nL(e){let{tool:t}=e,n=t.input,i="object"==typeof n&&null!==n?n:void 0,s="string"==typeof i?.thought?i.thought:"string"==typeof i?.reasoning?i.reasoning:"string"==typeof i?.notes?i.notes:"string"==typeof n?n:t.output||t.detail||"";return s?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(eC.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Internal Reasoning"})]}),(0,r.Y)(e$,{text:s,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),(0,r.Y)("div",{className:"max-h-64 overflow-y-auto p-3 text-[11.5px] leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eS.T,{content:s})})]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 p-3 font-mono text-[11px] text-ink/40",children:"No thought details recorded."})}var nM=n("Y");function nP(e){let{tool:t,targetFilePath:n,output:s}=e,[a,l]=(0,i.J0)(null),[o,c]=(0,i.J0)(!1),d=tN(t?.input),u=n||d||t?.target||"",p=u.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");(0,i.vJ)(()=>{!p||s||null!==a||o||(c(!0),fetch(`/api/fs/read?path=${encodeURIComponent(p)}`).then(e=>e.json()).then(e=>{l(e&&void 0!==e.content?e.content:`// Loaded file: ${p}`)}).catch(()=>{l(`// Loaded file: ${p}`)}).finally(()=>{c(!1)}))},[p,s,a,o]);let m=t?.details??{},h=s||("object"==typeof m?.displayContent&&"string"==typeof m.displayContent?.text?m.displayContent.text:"")||a||"",f=(0,i.Kr)(()=>(function(e){let t,n=e.split(/\r?\n/).filter(Boolean);if(0===n.length)return{isDirectory:!1,entries:[]};let r=n[0].trim(),i=n.some(e=>e.trimStart().startsWith("- ")||e.trimStart().startsWith("├──")||e.trimStart().startsWith("└──"));if("."!==r&&!i)return{isDirectory:!1,entries:[]};let s=[];for(let e of n){if(e.startsWith("[")&&e.endsWith("]")){t=e.slice(1,-1);continue}if("."===e.trim()){s.push({indent:0,isDir:!0,name:"."});continue}let n=e.match(/^(\s*)-\s+([^\s]+)\s*(.*)$/);if(n){let e,t,r=Math.floor(n[1].length/2),i=n[2],a=n[3].trim(),l=i.endsWith("/"),o=l?i.slice(0,-1):i,c=a.split(/\s{2,}|\t+/).filter(Boolean);2===c.length?(e=c[0],t=c[1]):1===c.length&&(c[0].endsWith("ago")?t=c[0]:e=c[0]),s.push({indent:r,isDir:l,name:o,size:e,time:t})}}return{isDirectory:s.length>0,entries:s,notice:t}})(h),[h]),x=(0,i.Kr)(()=>(function(e,t,n){let r=e?.details??{},i=e?.input&&"object"==typeof e.input?e.input:{},s=r.displayContent;if(s&&Array.isArray(s.lineNumbers)&&s.lineNumbers.length>0)return{startLine:"number"==typeof s.startLine?s.startLine:void 0,lineNumbers:s.lineNumbers};if(Array.isArray(r.lineNumbers)&&r.lineNumbers.length>0)return{startLine:"number"==typeof r.startLine?r.startLine:void 0,lineNumbers:r.lineNumbers};if("number"==typeof s?.startLine&&s.startLine>0)return{startLine:s.startLine};if("number"==typeof r.startLine&&r.startLine>0)return{startLine:r.startLine};if("number"==typeof r.start_line&&r.start_line>0)return{startLine:r.start_line};if("number"==typeof r.offset&&r.offset>0)return{startLine:r.offset};let a=r.meta?.truncation?.shownRange?.start??r.truncation?.shownRange?.start??r.meta?.shownRange?.start??r.shownRange?.start;if("number"==typeof a&&a>0)return{startLine:a};let l=i.start_line??i.startLine??i.offset??i.StartLine??i.from;if("number"==typeof l&&l>0)return{startLine:l};if("string"==typeof l&&/^\d+$/.test(l.trim())){let e=parseInt(l.trim(),10);if(e>0)return{startLine:e}}for(let n of["string"==typeof i.path?i.path:"",e?.target||"",e?.title||"",t||""]){let e=n.match(/:(\d+)(?:-\d+)?(?:\s|$)/);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}if(n){let e=n.match(/\[(?:Showing\s+)?lines?\s+(\d+)(?:-\d+)?/i);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}return{}})(t,u,h),[t,u,h]),{displayContent:g,elisionNotices:b}=(0,i.Kr)(()=>{if(f.isDirectory)return{displayContent:h,elisionNotices:[]};let e=h.split(/\r?\n/),t=[],n=[];for(let r of e){let e=r.trim();(e.startsWith("[…")||e.startsWith("[Showing lines ")||e.startsWith("[1 results limit"))&&e.endsWith("]")?t.push(e.slice(1,-1)):n.push(r)}return 0===t.length&&m.summary&&"number"==typeof m.summary.elidedLines&&m.summary.elidedLines>0&&t.push(`…${m.summary.elidedLines}ln elided (${m.summary.lines??n.length} lines shown)`),x.lineNumbers&&n.length>x.lineNumbers.length&&""===n[n.length-1].trim()&&n.pop(),{displayContent:n.join("\n"),elisionNotices:t}},[h,f.isDirectory,x.lineNumbers,m.summary]),v=(0,i.Kr)(()=>f.isDirectory||!g?{lines:[],cleanCode:"",hasLineNumbers:!1}:function(e,t){let n=e.replace(/\r?\n$/,"").split(/\r?\n/);if(0===n.length)return{lines:[],cleanCode:"",hasLineNumbers:!1};let r=[],i=0,s=0;for(let e of n){if(!e.trim()){r.push(null);continue}let t=e.match(/^(\s*(\d+):)/);if(t){let n=parseInt(t[2],10);r.push({lineNum:n,rawLine:e}),i++;continue}let n=e.match(/^(\s*(\d+)\s*[|│][ \t]?)/);if(n){let t=parseInt(n[2],10);r.push({lineNum:t,rawLine:e,pipePrefixLen:n[1].length}),s++;continue}r.push(null)}let a=n.filter(e=>e.trim().length>0),l=s>=2&&s>=.7*a.length,o=!l&&i>=2&&i>=.7*a.length&&(()=>{let e=r.filter(e=>null!==e).map(e=>e.lineNum);for(let t=1;t<e.length;t++)if(e[t]<e[t-1])return!1;return!0})();if(!l&&!o){let e=t?.lineNumbers,r="number"==typeof t?.startLine&&!isNaN(t.startLine)&&t.startLine>0?t.startLine:1;return{lines:n.map((t,n)=>{let i;if(e&&n<e.length){let t=e[n];i=null==t||""===t?"…":t}else i=r+n;return{lineNum:i,code:t}}),cleanCode:n.join("\n"),hasLineNumbers:!!(e&&e.length>0||r>1)}}if(l){let e=r.find(e=>null!==e)?.lineNum??1,t=[];for(let i=0;i<n.length;i++){let s=n[i],a=r[i];s.trim()?a&&void 0!==a.pipePrefixLen?(t.push({lineNum:a.lineNum,code:s.slice(a.pipePrefixLen)}),e=a.lineNum+1):(t.push({lineNum:e,code:s}),e++):(t.push({lineNum:e,code:""}),e++)}return{lines:t,cleanCode:t.map(e=>e.code).join("\n"),hasLineNumbers:!0}}let c=r.filter(e=>null!==e),d=String(Math.max(...c.map(e=>e.lineNum))).length+1,u=c.filter(e=>e.rawLine.length>d);u.length>0&&u.every(e=>" "===e.rawLine[d]||" "===e.rawLine[d])&&d++;let p=c[0]?.lineNum??1,m=[];for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(!t.trim()){m.push({lineNum:p,code:""}),p++;continue}if(i){p=i.lineNum;let e=t.length<=d?"":t.slice(d);m.push({lineNum:i.lineNum,code:e}),p=i.lineNum+1}else m.push({lineNum:p,code:t}),p++}return{lines:m,cleanCode:m.map(e=>e.code).join("\n"),hasLineNumbers:!0}}(g,x),[g,f.isDirectory,x]),k=f.isDirectory,y=(0,e3.sQ)(u),w=f.entries.slice(-1e3),Y=f.entries.length-w.length,D=(0,i.Kr)(()=>tv(v.cleanCode,1e3),[v.cleanCode]),F=D.skipped>0?v.lines.slice(D.skipped):v.lines,A=(0,e8.w)(),C=(0,i.Kr)(()=>D.text?(0,e3.wY)(D.text,y):"",[D,y,A]);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:k?(0,r.Y)(nM.A,{size:12}):(0,r.Y)(eP.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:u||(k?"Directory Listing":"File Content")}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:k?"Directory":y})]}),h&&(0,r.Y)(e$,{text:v.hasLineNumbers?v.cleanCode:h||"",className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),o?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-3 font-mono text-[11px] text-ink/50",children:[(0,r.Y)(e2.A,{size:12,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading file content..."})]}):k?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[Y>0&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(eA.A,{size:11,className:"shrink-0"}),(0,r.FD)("span",{children:["… ",Y," earlier entries hidden"]})]}),(0,r.Y)("div",{className:"max-h-72 divide-y divide-ink/[0.04] overflow-y-auto font-mono text-[11px]",children:w.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-ink/[0.02]",style:{paddingLeft:`${Math.max(12,(e.indent+1)*16)}px`},children:[e.isDir?(0,r.Y)(N.A,{size:12,className:"shrink-0 text-ink/60"}):(0,r.Y)(eE.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{className:`min-w-0 flex-1 truncate ${e.isDir?"font-semibold text-ink":"text-ink/80"}`,children:[e.name,e.isDir&&"/"]}),e.size&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[9.5px] text-ink/40",children:e.size}),e.time&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 font-mono text-[9px] text-ink/45",children:e.time})]},t))}),f.notice&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-t border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(eA.A,{size:11,className:"shrink-0"}),(0,r.Y)("span",{children:f.notice})]})]}):h?(0,r.FD)("div",{className:"space-y-1.5",children:[D.skipped>0&&(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(eA.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{children:["… ",D.skipped," earlier lines hidden"]})]}),(0,r.FD)("div",{className:"relative flex max-h-80 items-start overflow-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.Y)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/90 py-2.5 pl-3 pr-2.5 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/35 backdrop-blur-xs","aria-hidden":"true",children:F.map((e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:e.lineNum},t))}),(0,r.Y)("pre",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 font-mono text-[11px] leading-[20px] whitespace-pre text-ink/85 focus:outline-none",dangerouslySetInnerHTML:{__html:C}})]}),b.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(eA.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{children:e})]},t))]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 px-3 py-3 font-mono text-[11px] text-ink/45",children:"File is ready for inspection."})]})}var nE=n("fQ"),nR=n("BE");function nI(e){let{sections:t}=e,n=(0,e8.w)(),s=(0,i.Kr)(()=>t.map(e=>{let t=(0,e3.sQ)(e.path);return e.ops.map(e=>(0,e3.O9)(e.body.join("\n"),t))}),[t,n]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)("span",{children:"Hashline Patch"}),t[0].tag&&(0,r.FD)("span",{className:"font-mono text-[9px] font-normal tracking-normal text-ink/50",children:["snapshot ",t[0].tag]})]}),(0,r.Y)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:t.map((e,t)=>(0,r.FD)("div",{className:"border-b border-ink/6 last:border-b-0",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-medium text-ink",children:e.path}),e.moveTo&&(0,r.FD)("span",{className:"shrink-0 font-mono text-[10px] text-ink/50",children:["→ ",e.moveTo]}),e.removed&&(0,r.Y)("span",{className:"shrink-0 rounded bg-error/10 px-1.5 font-mono text-[9px] uppercase tracking-wider text-error",children:"Removes file"})]}),(0,r.Y)("div",{className:"overflow-x-auto",children:e.ops.map((e,n)=>(0,r.FD)("div",{children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1",children:[(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 font-mono text-[9px] font-semibold ${"CUT"===e.verb?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.verb}),e.spec&&(0,r.Y)("span",{className:"font-mono text-[10.5px] text-ink/70",children:e.spec})]}),e.body.map((e,i)=>{let a=s[t]?.[n]?.[i]||"";return a?(0,r.Y)("div",{className:"shiki whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed",dangerouslySetInnerHTML:{__html:a}},i):(0,r.Y)("div",{className:"whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed text-success/90",children:e},i)})]},`${e.verb}-${e.spec}-${n}`))})]},e.path))})]})}var nO=n("e");function nJ(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"diff",r=e?e.split(/\r?\n/):[],i=t?t.split(/\r?\n/):[],s=0;for(;s<r.length&&s<i.length&&r[s]===i[s];)s++;let a=0;for(;a<r.length-s&&a<i.length-s&&r[r.length-1-a]===i[i.length-1-a];)a++;let l=r.slice(Math.max(0,s-2),s),o=r.slice(s,r.length-a),c=i.slice(s,i.length-a),d=r.slice(r.length-a,r.length-a+2),u=n||"diff",p=[`--- a/${u}`,`+++ b/${u}`,`@@ -1,${r.length||1} +1,${i.length||1} @@`];for(let e of l)p.push(` ${e}`);for(let e of o)p.push(`-${e}`);for(let e of c)p.push(`+${e}`);for(let e of d)p.push(` ${e}`);return p.join("\n")}function n_(e){let{tool:t}=e,n="write"===t.type||"write"===t.name||"create_file"===t.type,s=t.input,a="object"==typeof s&&null!==s?s:void 0,l=(0,i.Kr)(()=>(0,nO.I)(a),[a]),o=t.target||l?.sections[0].path||a?.path||a?.TargetFile||a?.targetFile||a?.FilePath||a?.filePath||a?.AbsolutePath||a?.absolutePath||("string"==typeof t.details?.path?t.details.path:void 0)||("string"==typeof s&&(s.includes("/")||s.includes("."))?s:void 0)||"",c="string"==typeof a?.content?a.content:"string"==typeof a?.Content?a.Content:void 0,d="string"==typeof a?.old_string?a.old_string:"string"==typeof a?.oldString?a.oldString:"string"==typeof a?.TargetContent?a.TargetContent:"string"==typeof a?.targetContent?a.targetContent:void 0,u="string"==typeof a?.new_string?a.new_string:"string"==typeof a?.newString?a.newString:"string"==typeof a?.ReplacementContent?a.ReplacementContent:"string"==typeof a?.replacementContent?a.replacementContent:void 0,p=Array.isArray(a?.ReplacementChunks)?a.ReplacementChunks:void 0,m=t.diff?.diffText||("string"==typeof t.details?.diff?t.details.diff:void 0)||("string"==typeof t.details?.patch?t.details.patch:void 0),h=(0,i.Kr)(()=>m||(p&&p.length>0?p.map(e=>nJ(e.TargetContent||"",e.ReplacementContent||"",o)).join("\n"):d||u?nJ(d||"",u||"",o):void 0),[m,p,d,u,o]),f=t.output||"",x=(0,e3.sQ)(o),g=(0,i.Kr)(()=>d?tv(d,1e3):null,[d]),b=(0,i.Kr)(()=>u?tv(u,1e3):null,[u]),v=(0,e8.w)(),k=(0,i.Kr)(()=>g?(0,e3.wY)(g.text,x):"",[g,x,v]),y=(0,i.Kr)(()=>b?(0,e3.wY)(b.text,x):"",[b,x,v]),w=(0,i.Kr)(()=>c?c.split("\n").length:0,[c]),N=(0,i.Kr)(()=>c?(0,e3.wY)(c.split("\n").slice(0,80).join("\n"),x):"",[c,x,v]),Y=(0,i.Kr)(()=>tg(f),[f]),D=(0,i.Kr)(()=>tv(Y.content,1e3),[Y]),F=(0,i.Kr)(()=>tb(D.text,Y.format),[D,Y.format]);return(0,r.FD)("div",{className:"space-y-2.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:n?(0,r.Y)(nE.A,{size:12}):(0,r.Y)(nR.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:o||"File modification"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?"Write":"Edit"})]}),(c||u||l)&&(0,r.Y)(e$,{text:l?.text||c||u||f,className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),h&&(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diff Changes"}),(0,r.Y)(e6,{text:h})]}),!h&&l&&(0,r.Y)(nI,{sections:l.sections}),!h&&(d||u)&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Replacement Changes"}),(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[d&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-error/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-error",children:(0,r.Y)("span",{children:"- Original Content"})}),g&&g.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-40 overflow-x-auto font-mono text-[11px] leading-relaxed text-error/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:k}})]}),u&&(0,r.FD)("div",{className:"bg-success/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-success",children:(0,r.Y)("span",{children:"+ Replaced With"})}),b&&b.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-48 overflow-x-auto font-mono text-[11px] leading-relaxed text-success/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:y}})]})]})]}),!h&&!d&&!u&&c&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.FD)("span",{className:"flex items-center gap-1",children:[(0,r.Y)(eP.A,{size:11}),(0,r.Y)("span",{children:"Written File Preview"})]}),(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/50",children:[w," lines · ",(0,ti.z3)(c.length)]})]}),(0,r.FD)("div",{className:"flex max-h-64 items-start overflow-x-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.FD)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/60 py-2.5 pl-2.5 pr-2 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/25","aria-hidden":"true",children:[Array.from({length:Math.min(w,80)},(e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:t+1},t)),w>80&&(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:"…"})]}),(0,r.Y)("div",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 leading-[20px] whitespace-pre text-ink/85",dangerouslySetInnerHTML:{__html:N}})]})]}),f&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 mb-1.5 text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.Y)(nh.A,{size:11,className:"text-success"}),(0,r.Y)("span",{children:"Execution Output"})]}),Y.envelope&&(0,r.Y)(tf,{envelope:Y.envelope}),D.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",D.skipped," earlier lines hidden"]}),(0,r.Y)(eS.T,{content:F,className:"text-[11.5px] text-ink/85"})]})]})}function nW(e){let{value:t}=e;return Array.isArray(t)?(0,r.Y)(nK,{items:t}):(0,nd.u)(t)?(0,r.Y)(nU,{data:t}):"string"==typeof t?t.length>120||t.includes("\n")?(0,r.Y)("div",{className:"prose-content max-h-60 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eS.T,{content:t})}):(0,r.Y)("span",{className:"break-words text-[12px] leading-relaxed text-ink/85",children:t}):(0,r.Y)("span",{className:"font-mono text-[12px] text-ink/85",children:JSON.stringify(t)??""})}function nK(e){let{items:t}=e,n=t.slice(0,50);return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("ol",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map((e,t)=>(0,r.FD)("li",{className:"flex items-start gap-2 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("div",{className:"min-w-0 flex-1",children:(0,r.Y)(nW,{value:e})})]},t))}),t.length>n.length&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",t.length-n.length," more items"]})]})}function nU(e){let{data:t}=e,n=Object.entries(t);return 0===n.length?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-canvas/40 px-2.5 py-2 text-[11px] text-ink/45",children:"Empty object"}):(0,r.Y)("div",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map(e=>{let[t,n]=e,i=Array.isArray(n)?`list \xb7 ${n.length}`:(0,nd.u)(n)?"json":"string"==typeof n?"markdown":typeof n;return(0,r.FD)("div",{className:"px-2.5 py-2",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5",children:[(0,r.Y)(tn.A,{size:10.5,className:"shrink-0 text-ink/45"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",title:t,children:t}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:i})]}),(0,r.Y)(nW,{value:n})]},t)})})}function nq(e){let{tool:t}=e,n="object"==typeof t.input&&null!==t.input?t.input:void 0,s="string"==typeof n?.path?n.path:t.target||"",a="string"==typeof t.name?t.name:"",l=(s?s.replace(/^xd:\/\//,""):a).replace(/^mcp__/,""),o="string"==typeof n?.content?n.content:"",c=(0,i.Kr)(()=>o?(0,e3.Bl)(o):{isValid:!1},[o]),d=c.isValid?c.data:void 0,u=(0,nd.u)(d)||Array.isArray(d),p=(0,i.Kr)(()=>t.output?(0,e3.Bl)(t.output):{isValid:!1},[t.output]),m=p.isValid?p.data:void 0,h=(0,nd.u)(m)||Array.isArray(m);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 rounded-lg border border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)(J.A,{size:12,className:"shrink-0 text-ink/60"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",children:l||"MCP Tool"}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:"MCP"})]}),o&&u?(0,r.Y)(nW,{value:d}):o?(0,r.Y)("div",{className:"prose-content max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eS.T,{content:o})}):null,t.output&&h?(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Result"}),(0,r.Y)(nW,{value:m})]}):t.output?(0,r.Y)(tk,{text:t.output}):null]})}function nB(e){if(e.target)return e.target;if(e.diff?.file)return e.diff.file;if(e.input&&"object"==typeof e.input){let t=e.input;if("string"==typeof t.path)return t.path;if("string"==typeof t.TargetFile)return t.TargetFile;if("string"==typeof t.targetFile)return t.targetFile;if("string"==typeof t.FilePath)return t.FilePath;if("string"==typeof t.filePath)return t.filePath;if("string"==typeof t.AbsolutePath)return t.AbsolutePath;if("string"==typeof t.absolutePath)return t.absolutePath;if("string"==typeof t.file)return t.file;let n=(0,nO.f$)(t);if(n)return n}return"string"==typeof e.details?.path?e.details.path:"string"==typeof e.input&&(e.input.includes(".")||e.input.includes("/"))?e.input:e.detail&&(e.detail.includes(".")||e.detail.includes("/"))?e.detail:void 0}function nH(e){let t=e.details;if(t?.xdev?.tool&&"string"==typeof t.xdev.tool)return t.xdev.tool.toLowerCase();let n=(e.target||"").toLowerCase(),r=tN(e.input)?.toLowerCase()??"",i=n.startsWith("xd://")?n.slice(5):r.startsWith("xd://")?r.slice(5):"";if(i){let e=i.split(/[/?#]/)[0].trim();if(e)return e}let s=(e.name||"").toLowerCase(),a=(e.type||"").toLowerCase(),l=(e.title||"").toLowerCase();if(s&&"tool"!==s&&"custom"!==s)return s;let o=l.split(/[\s—\-:]+/)[0]?.trim();return["grep","glob","read","write","edit","bash","terminal","run_command","todo","eval","hub","lsp","github","task","resolve","reject"].includes(o)?o:a}function nG(e){let{tool:t}=e,n=nH(t);if("read"===n||"read_file"===n||"view_file"===n||"read_file_content"===n){let e=nB(t);return(0,r.Y)(nP,{tool:t,targetFilePath:e,output:t.output||""})}return"edit"===n||"write"===n||"edit_file"===n||"create_file"===n||"write_to_file"===n||"replace_file_content"===n||"multi_edit_file"===n?(0,r.Y)(n_,{tool:t}):"task"===n?(0,r.Y)(to,{tool:t}):"todo"===n?(0,r.Y)(ty,{tool:t}):"grep"===n||"glob"===n||"ast_grep"===n?(0,r.Y)(tB,{tool:t}):"search_fs"===n?(0,r.Y)(nw,{tool:t}):"web_search"===n?(0,r.Y)(tT,{tool:t}):"bash"===n||"terminal"===n||"run_command"===n?(0,r.Y)(tW,{tool:t}):"eval"===n?(0,r.Y)(tj,{tool:t}):"lsp"===n?(0,r.Y)(tF,{tool:t}):"ast_edit"===n?(0,r.Y)(nf,{tool:t}):"resolve"===n||"reject"===n?(0,r.Y)(nx,{tool:t}):"hub"===n?(0,r.Y)(t5,{tool:t}):"github"===n?(0,r.Y)(tE,{tool:t}):"checkpoint"===n||"rewind"===n?(0,r.Y)(t_,{tool:t}):"security_scan"===n?(0,r.Y)(tQ,{tool:t}):"debug"===n?(0,r.Y)(na,{tool:t}):"manage_skill"===n?(0,r.Y)(nk,{tool:t}):"context_notes"===n||"new_context"===n?(0,r.Y)(t8,{tool:t}):"memory_edit"===n||"retain"===n||"recall"===n||"reflect"===n||"learn"===n?(0,r.Y)(nt,{tool:t}):"goal"===n||"yield"===n?(0,r.Y)(np,{tool:t}):"ask"===n?(0,r.Y)(nj,{tool:t}):"think"===n?(0,r.Y)(nL,{tool:t}):n.startsWith("mcp__")||"string"==typeof t.name&&t.name.startsWith("mcp__")?(0,r.Y)(nq,{tool:t}):null}function nV(e){let t="object"==typeof e.input&&null!==e.input?e.input:void 0,n="string"==typeof t?.path?t.path:e.target||"",r=(n.startsWith("xd://")?n.slice(5):"string"==typeof e.name&&e.name.startsWith("mcp__")?e.name:"").split(/[/?#]/)[0].trim();return r.startsWith("mcp__")?r.slice(5):void 0}function nZ(e){let t=e.details?.xdev;return t&&"object"==typeof t?t:void 0}function nQ(e){let{children:t}=e;return(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:t})}let nX=(0,a.ph)(function(e){let t,{tool:n,isOpen:s,onToggle:a,defaultExpanded:l=!1}=e,o=nH(n),c=(0,i.Kr)(()=>null!==nG({tool:n}),[n]),d=n.command?n.command:"string"==typeof n.input?n.input:n.input&&"object"==typeof n.input?JSON.stringify(n.input,null,2):(n.target||n.detail)&&(n.target||n.detail)||"",u=n.output||(n.error?`Error: ${n.error}`:""),p=function(e){if(e.diff?.diffText)return e.diff.diffText;let t=e.details;if(t&&"object"==typeof t){if("string"==typeof t.patch)return t.patch;if("string"==typeof t.diff)return t.diff}}(n),m=(0,i.hb)(()=>{a?.(n.id)},[a,n.id]),f=(0,i.Kr)(()=>!c&&d?(0,e3.Bl)(d):null,[c,d]),x=(0,i.Kr)(()=>{let e=e1(eG(u));return!!(e&&eQ(e.tag))},[u]),g="";if("lsp"===o){g="LSP";let e=nZ(n);e?.args?.action&&(t=`${e.args.action}${e.args.file?` \xb7 ${e.args.file}`:""}`)}else if("ast_edit"===o){g="AST Edit";let e=nZ(n);e?.args?.paths?.[0]&&(t=e.args.paths[0])}else if("resolve"===o)g="Resolve Proposal";else if("reject"===o)g="Reject Proposal";else if("yield"===o)g="error"===n.status?"Yield":u?`Yield - ${u}`:"Yield";else if("todo"===o||"todo"===n.name||"todo"===n.type||n.title&&n.title.toLowerCase().startsWith("todo")){g="Todo";let e=function(e){let t=td(e);if(t.totalTasks>0||t.groups.length>0)return t.summaryText}(n);if(e)t=e;else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/).slice(1).join(" — ").trim();t=e.split(/\s*·\s*/).filter(e=>!/^0\s+(complete|in progress|pending)/i.test(e)).join(" · ")||e}}else if("ask"===o){g="Question";let e=h(n).length;e>0&&(t=`Asked ${e} question${1===e?"":"s"}`)}else if(nV(n)){let e="object"==typeof n.input&&null!==n.input?n.input:void 0;g=th(nV(n));let r=function(e,t){if(e.intent)return e.intent;let n="string"==typeof t?.content?t.content:"",r=n?(0,e3.Bl)(n):{isValid:!1,data:void 0},i=r.isValid?r.data:t;if(i&&"object"==typeof i){let e=["query","q","pattern","pat","name","sql","path","symbol","url","command"].find(e=>"string"==typeof i[e]&&i[e]);if(e)return i[e]}}(n,e);r&&(t=r.length>80?`${r.slice(0,79)}…`:r)}else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/);g=th(e[0].trim()),t=e.slice(1).join(" — ").trim()}else g=n.title?th(n.title):th(o||n.name||"Tool Call");if(("task"===o||"task"===n.name)&&!t){let e="object"==typeof n.input&&null!==n.input?n.input:void 0,r=Array.isArray(e?.tasks)?e.tasks[0]:void 0;r?.name&&(t=`${r.name}${r.agent?` \xb7 ${r.agent}`:""}`)}let b=nB(n),v=t&&!t.startsWith("xd://")?t:b&&!b.startsWith("xd://")?b:t||(n.detail&&!b?n.detail:void 0),k=n.duration||n.time,y=k||x?(0,r.FD)("span",{className:"flex items-center gap-2",children:[k?(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/40",children:k}):null,x&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(eB.A,{size:10})," Reminder"]})]}):null;return(0,r.FD)(e4,{tool:n,icon:n.icon||function(e){switch(e){case"bash":case"terminal":return(0,r.Y)(eM.A,{size:14});case"edit":case"write":case"edit_file":case"create_file":case"ast_edit":return(0,r.Y)(eP.A,{size:14});case"read":case"read_file":case"view_file":return(0,r.Y)(eE.A,{size:14});case"glob":case"grep":case"search_fs":case"ast_grep":return(0,r.Y)($.A,{size:14});case"web_search":return(0,r.Y)(W.A,{size:14});case"todo":case"task":return(0,r.Y)(eR.A,{size:14});case"eval":return(0,r.Y)(eI.A,{size:14});case"lsp":return(0,r.Y)(eO.A,{size:14});case"resolve":case"reject":return(0,r.Y)(D.A,{size:14});case"hub":return(0,r.Y)(eJ.A,{size:14});case"ask":return(0,r.Y)(e_.A,{size:14});case"think":return(0,r.Y)(eC.A,{size:14});case"security_scan":return(0,r.Y)(eW.A,{size:14});case"checkpoint":case"rewind":return(0,r.Y)(eK.A,{size:14});case"github":return(0,r.Y)(eU.A,{size:14});case"memory_edit":case"retain":case"recall":case"reflect":case"learn":return(0,r.Y)(K.A,{size:14});default:if(e.startsWith("mcp__"))return(0,r.Y)(J.A,{size:14});return(0,r.Y)(eq.A,{size:14})}}(o),title:g,subtitle:v,meta:y,isOpen:s,onToggle:a?m:void 0,defaultExpanded:l,alwaysExpanded:c&&("yield"===o||"ask"===o),children:[(0,r.Y)(nG,{tool:n}),!c&&d&&(0,r.FD)("div",{className:"space-y-1.5 code-surface",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(nQ,{children:"Input"}),f?.isValid&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/45",children:"JSON"})]}),(0,r.Y)(e$,{text:f?.isValid&&f.pretty?f.pretty:d,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),f?.isValid&&f.pretty?(0,r.Y)(tr,{jsonString:f.pretty,maxHeightClass:"max-h-60",showHeader:!1}):(0,r.Y)("pre",{className:"overflow-x-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-ink/80 select-text",children:d})]}),!c&&p&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)(nQ,{children:"Diff"}),(0,r.Y)(e6,{text:p})]}),!c&&u&&(0,r.Y)(tk,{text:u})]})});function n0(e){let{tools:t,title:n,defaultExpanded:s=!1}=e,a=(0,i.Kr)(()=>(t||[]).map((e,t)=>(function(e,t){if("id"in e&&e.id)return e;let n=e.title||"",r=n.toLowerCase(),i="terminal";r.includes("shell")||r.includes("command")||r.includes("bun")||r.includes("git")?i="bash":r.includes("edit")||r.includes("write")?i="edit_file":r.includes("read")||r.includes("view")||r.includes("cat")||r.includes("inspect")?i="read_file":(r.includes("search")||r.includes("find")||r.includes("grep"))&&(i="search_fs");let s=n.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()||"tool",a="type"in e&&e.type?e.type:i;return{id:`stable-tool-${t}-${s}`,type:a,title:e.title,duration:e.time,time:e.time,detail:e.detail,target:"target"in e&&e.target?e.target:"read_file"===a||"edit_file"===a||"create_file"===a?e.detail:void 0,command:e.command||("bash"===a?e.detail:void 0),output:e.output,status:e.status||"success",icon:e.icon,diff:"diff"in e?e.diff:void 0,input:"input"in e?e.input:void 0}})(e,t)),[t]),[l,o]=(0,i.J0)(()=>{let e={};return a.forEach((t,n)=>{let r=!eL(t)&&("error"===t.status||s&&0===n);e[t.id]=r}),e}),c=(0,i.hb)(e=>{o(t=>({...t,[e]:!t[e]}))},[]);return a&&0!==a.length?(0,r.FD)("div",{className:"mx-3 space-y-1.5",children:[n&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:n}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),a.map(e=>(0,r.Y)(nX,{tool:e,isOpen:!!l[e.id],onToggle:c},e.id))]}):null}var n1=n("oE"),n5=n("bH"),n2=n("Sb");function n4(e){let{task:t}=e;(0,e8.w)();let n=t.structuredOutput,s=!t.formattedJson&&(0,e3.rw)(t.rawOutput),[a,l]=(0,i.J0)(n||!s?"formatted":"raw");return(0,r.FD)("div",{className:"space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(n||!s)&&(0,r.FD)("button",{type:"button",onClick:()=>l("formatted"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"formatted"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(n5.A,{size:12}),(0,r.Y)("span",{children:n?"Overview":"Markdown"})]}),(0,r.FD)("button",{type:"button",onClick:()=>l("raw"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"raw"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(tu.A,{size:12}),(0,r.Y)("span",{children:t.formattedJson?"Raw JSON":s?"Code":"Raw Text"})]})]}),(0,r.Y)(e$,{text:t.formattedJson||t.rawOutput,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10.5px] font-medium text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:12,title:"Copy payload",resetMs:1800,wrapLabel:!0,copiedLabelClassName:"text-success",label:"Copy"})]}),"formatted"===a&&(n?(0,r.FD)("div",{className:"space-y-3 text-[11.5px]",children:[n.summary&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:[(0,r.Y)(n2.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Summary"})]}),(0,r.Y)("div",{className:"leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:n.summary,className:"text-[11.5px]"})})]}),n.architecture&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(n1.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Architecture"})]}),(0,r.Y)("p",{className:"leading-relaxed text-ink/80",children:n.architecture})]}),Array.isArray(n.files)&&n.files.length>0&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(eP.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Files Inspected"})]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:[n.files.length," items"]})]}),(0,r.Y)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:n.files.map((e,t)=>(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5 transition-colors hover:border-ink/15",children:[(0,r.Y)("span",{className:"font-mono text-[10.5px] font-medium text-ink truncate",children:e.path}),e.description&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight line-clamp-2 mt-0.5",children:e.description})]},t))})]}),n.report&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(eE.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Report"})]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded border border-ink/6 bg-canvas/30 p-2 text-ink/85 scrollbar-overlay-container",children:(0,r.Y)(eS.T,{content:n.report,className:"text-[11.5px] leading-relaxed"})})]})]}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85 max-h-72 overflow-auto scrollbar-overlay-container",children:(0,r.Y)(eS.T,{content:t.rawOutput})})),"raw"===a&&(0,r.Y)("pre",{className:"max-h-64 overflow-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/80 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,e3.wY)(t.formattedJson||t.rawOutput,t.formattedJson?"json":s?"javascript":"markdown")}}),t.outro&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5 text-[11px] text-ink/75",children:[(0,r.FD)("div",{className:"mb-1.5 flex items-center gap-1.5 font-mono text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:[(0,r.Y)(eM.A,{size:11}),(0,r.Y)("span",{children:"Follow-up & Transcript"})]}),(0,r.Y)("div",{className:"text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:t.outro})})]})]})}function n3(e){let{notice:t}=e,[n,s]=(0,i.J0)(!1);(0,e8.w)();let a=(0,i.Kr)(()=>(function(e){let t,n,r;if(!e)return null;let i=e.match(/([\s\S]*?)<task-result\b([^>]*)>([\s\S]*?)<\/task-result>([\s\S]*)/i);if(!i)return null;let s=i[1].trim(),a=i[2],l=i[3].trim(),o=i[4].trim(),c=a.match(/\bid=["']([^"']+)["']/i)?.[1],d=a.match(/\bagent=["']([^"']+)["']/i)?.[1],u=a.match(/\bstatus=["']([^"']+)["']/i)?.[1],p=a.match(/\bduration=["']([^"']+)["']/i)?.[1],m=l.match(/<meta\b([^>]*)\/?>/i);if(m){let e=m[1],n=e.match(/\blines=["']([^"']+)["']/i)?.[1],r=e.match(/\bsize=["']([^"']+)["']/i)?.[1];(n||r)&&(t={lines:n,size:r})}let h="",f=l.match(/<output\b[^>]*>([\s\S]*?)<\/output>/i);if(f)h=f[1].trim();else{let e=l.match(/<preview\b[^>]*>([\s\S]*?)<\/preview>/i),t=e?.[1].trim();h=t||l.replace(/<meta\b[^>]*\/?>(?:\s*<\/meta>)?|<\/?preview\b[^>]*>/gi,"").trim()}if(h.startsWith("{")||h.startsWith("["))try{let e=JSON.parse(h);e&&"object"==typeof e&&!Array.isArray(e)&&(n=e,r=JSON.stringify(e,null,2))}catch{let e=function(e){let t=e;for(let e=0;e<16;e+=1){let{stack:e,inString:n,escaped:r}=function(e){let t=[],n=!1,r=!1;for(let i of e){if(n){r?r=!1:"\\"===i?r=!0:'"'===i&&(n=!1);continue}'"'===i?n=!0:"{"===i||"["===i?t.push("{"===i?"}":"]"):("}"===i||"]"===i)&&t.pop()}return{stack:t,inString:n,escaped:r}}(t),i=t;n&&(r&&(i=i.slice(0,-1)),i+='"'),i=(i=i.replace(/,\s*"[^"]*"\s*:\s*$/,"").replace(/"[^"]*"\s*:\s*$/,"").replace(/,\s*$/,"")+[...e].reverse().join("")).replace(/,\s*(?=[}\]])/g,"");try{return JSON.parse(i),i}catch{let e=t.lastIndexOf(",");if(e<=0)return null;t=t.slice(0,e)}}return null}(h);if(e){let t=JSON.parse(e);t&&"object"==typeof t&&!Array.isArray(t)&&(n=t,r=JSON.stringify(t,null,2),h=e)}}return{intro:s||(c?`Background job ${c} completed`:"System notice"),id:c,agent:d,status:u,duration:p,meta:t,rawOutput:h,formattedJson:r,structuredOutput:n,outro:o||void 0}})(t),[t]),l=(0,i.Kr)(()=>{if(!(/<\/?system-reminder[^>]*>/i.test(t)||t.includes("xd://resolve")||t.includes("`ast_edit` result")))return null;let e=t.replace(/<\/?system-reminder[^>]*>/gi,"").trim();if(!e)return null;let n=(e.split(/\r?\n/).map(e=>e.trim()).find(Boolean)??e).replace(/`([^`]+)`/g,"$1");return{content:e,title:n}},[t]),o=(0,i.Kr)(()=>{let e=t.replace(/<\/?system-notice[^>]*>/gi,"").trim(),n=e.split(/\r?\n/),r=(n.find(e=>e.trim())??"").trim(),i=n.findIndex(e=>e.trim()===r),s=n.slice(i+1).join("\n").trim(),a=(0,e3.rw)(s);return{clean:e,firstLine:r,rest:s,isCode:a}},[t]),c=a?.intro||l?.title||o.firstLine||t,d=c.length>100,u=c.slice(0,100)+(d?"...":""),p=(0,i.Kr)(()=>{if(a)return!0;let e=t.replace(/<\/?(?:system-notice|system-reminder)[^>]*>/gi,"").trim();return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).length>1||e.length>100||c.length>100},[a,t,c]),m=(0,i.Kr)(()=>a?"failed"===a.status||"error"===a.status?{icon:(0,r.Y)(eF.A,{size:13}),badgeClass:"bg-error/10 text-error",label:"Task Result",isError:!0}:{icon:(0,r.Y)(e9.A,{size:13}),badgeClass:"bg-success/10 text-success",label:"Task Result",isError:!1}:l?{icon:(0,r.Y)(eB.A,{size:13}),badgeClass:"bg-warning/10 text-warning",label:"System Reminder",isError:!1}:{icon:(0,r.Y)(eA.A,{size:13}),badgeClass:"bg-info/10 text-info",label:"System Notice",isError:!1},[a,l]);return(0,r.FD)("div",{className:`mx-3 overflow-hidden rounded-xl border border-ink/10 bg-paper text-[12px] text-ink transition-colors ${p?"hover:border-ink/20":""} select-text`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{p&&s(e=>!e)},disabled:!p,"aria-expanded":p?n:void 0,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${p?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg ${m.badgeClass}`,children:m.icon}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:m.label}),a?.agent&&(0,r.FD)("span",{className:"flex items-center gap-1 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/60",children:[(0,r.Y)(O.A,{size:10}),a.agent]}),a?.status&&(0,r.FD)("span",{className:`flex items-center gap-1 rounded px-1.5 py-0.2 font-mono text-[9px] font-semibold uppercase ${m.isError?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:[m.isError?(0,r.Y)(eF.A,{size:10}):(0,r.Y)(e9.A,{size:10}),a.status]}),a?.duration&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(tz.A,{size:9}),a.duration]}),a?.meta?.size&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(n1.A,{size:9}),a.meta.size]})]}),!n&&u&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",title:c,children:u})]}),p&&(0,r.Y)(Y.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${n?"rotate-180":""}`})]}),n&&p&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3.5 py-2.5",children:a?(0,r.Y)(n4,{task:a}):l?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:l.content})}):o.isCode?(0,r.Y)("pre",{className:"max-h-56 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/75 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,e3.wY)(o.rest||o.clean,"javascript")}}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:o.clean||o.rest})})})]})}function n8(e){return!!(e.preview?.startsWith("data:image/")||e.preview?.startsWith("blob:"))||(e.type?.startsWith("image/")??!1)}function n6(e){let{src:t,name:n,onClose:s}=e,[l,o]=(0,i.J0)(!1);return(0,i.vJ)(()=>{let e=e=>{"Escape"===e.key&&s()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]),(0,a.d5)((0,r.Y)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-ink/80 backdrop-blur-sm",onClick:s,role:"dialog","aria-modal":"true","aria-label":`Preview ${n}`,children:(0,r.FD)("div",{className:"relative max-w-[90vw] max-h-[90vh] flex flex-col items-center",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{type:"button",onClick:s,className:"absolute -top-10 right-0 flex items-center justify-center w-8 h-8 rounded-full bg-paper/10 text-canvas hover:bg-paper/20 transition-colors",title:"Close (Esc)",children:(0,r.Y)(j.A,{size:18})}),(0,r.Y)("img",{src:t,alt:n,onClick:()=>o(e=>!e),title:l?"Zoom out":"Zoom in (click image)",className:`max-w-[90vw] max-h-[85vh] object-contain rounded-md shadow-2xl bg-canvas/5 cursor-zoom-in transition-transform ${l?"scale-150 cursor-zoom-out":"scale-100"}`}),(0,r.Y)("div",{className:"mt-3 max-w-[90vw] truncate text-[11px] font-mono text-canvas/80",children:n})]})}),document.body)}function n9(e){let{attachments:t,className:n="",onOpenFile:s}=e,[a,l]=(0,i.J0)(null);return(0,r.FD)(r.FK,{children:[t.length>0&&(0,r.Y)("div",{className:`flex flex-wrap gap-1.5 pt-2 border-t border-ink/10 ${n}`,children:t.map((e,t)=>(0,r.FD)("button",{type:"button",onClick:()=>{n8(e)&&e.preview?l(e):s?s(e):window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment"}}))},title:n8(e)?"Preview image":"Open in editor",className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-1.5 text-xs font-sans hover:border-ink/40 hover:bg-ink/5 hover:shadow-sm transition-all cursor-pointer group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"attachment preview",className:"w-5 h-5 rounded-sm object-cover mr-1.5 border border-ink/5 group-hover:scale-105 transition-transform"}):(0,r.Y)("div",{className:"w-5 h-5 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(ex.A,{size:11})}),(0,r.Y)("span",{className:"truncate max-w-[100px] font-mono text-[10px] text-ink/80",children:e.name})]},t))}),a&&a.preview&&(0,r.Y)(n6,{src:a.preview,name:a.name??"image",onClose:()=>l(null)})]})}function n7(e){let t=e.match(/^(\s*)([a-zA-Z\u00C0-\u024F])(.*)$/s);return t?t[1]+t[2].toUpperCase()+t[3]:e}let re=/<\/?(?:system-reminder|reminder|system-notice|task-result)\b/i,rt=["model","provider","usage","durationMs","startedAt","completedAt","thinking","toolCalls"];function rn(e){return!("string"!=typeof e?.notice||!e.notice.trim()||re.test(e.notice))&&rt.some(t=>void 0!==e[t]&&null!==e[t])}function rr(e){return"string"==typeof e?.notice&&!!e.notice.trim()&&!rn(e)}function ri(e){return rn(e)?e.notice:"string"==typeof e?.content?e.content:""}let rs=(0,a.ph)(function(e){let{msg:t,isStreaming:n=!1,onUndo:s,onNewChat:a,className:l="",isPrevAssistant:o=!1}=e,c="user"===t.role,d=rr(t),u=d?t.content:ri(t),p=(0,i.Kr)(()=>"string"==typeof u?u.trim():u,[u]),m=(0,i.Kr)(()=>"string"==typeof u?n7(u):u,[u]),h="string"==typeof u&&/[A-Za-z0-9]/.test(u);if(c){let e="agent"===t.attribution;return(0,r.FD)("div",{id:t.id,className:`flex flex-col items-end space-y-1.5 w-full max-w-full ${l}`,children:[(0,r.FD)("div",{className:"bg-paper p-3.5 sm:p-4 rounded-xl border border-ink/15 text-[13px] text-ink shadow-xs max-w-[92%] sm:max-w-[85%] break-words overflow-hidden flex flex-col space-y-2 font-sans select-text mx-3",style:{lineHeight:"var(--markdown-body-line-height)"},children:[e&&(0,r.FD)("div",{className:"flex items-center space-x-1.5 pb-1.5 mb-1 border-b border-ink/10 text-[11px] font-mono text-ink/70",children:[(0,r.Y)(O.A,{size:12,className:"text-ink shrink-0"}),(0,r.Y)("span",{className:"font-semibold text-ink",children:"Subagent Assignment"}),(0,r.Y)("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-ink/5 text-ink/60",children:"Delegated"})]}),(0,r.Y)(eS.T,{content:p}),(0,r.Y)(n9,{attachments:t.attachments||[],onOpenFile:e=>{window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment",content:e.content}}))}})]}),(0,r.FD)("div",{className:"flex items-center space-x-2.5 text-[11px] text-ink/60 px-1 font-mono",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5",children:[e?(0,r.FD)(r.FK,{children:[(0,r.Y)(O.A,{size:11,className:"text-ink/70 shrink-0"}),(0,r.Y)("span",{className:"text-[10px] uppercase font-semibold tracking-wider text-ink/60",children:"Agent"})]}):(0,r.Y)(eN.A,{size:11,className:"text-ink/70 shrink-0"}),tJ(t)&&(0,r.Y)("span",{children:tJ(t)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Undo / Edit message",onClick:()=>{s&&s(t.id,t.content)},children:(0,r.Y)(eY.A,{size:12})}),(0,r.Y)(e$,{text:t.content,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy prompt"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:e=>{e&&e.preventDefault(),a&&a(t.content)},children:(0,r.Y)(eD.A,{size:12})})]})]})]})}let f=t.thinking||(t.monologue?{thought:t.monologue}:void 0),x=t.toolCalls||t.actions,g=t.actions2,b=t.intent?n7(t.intent.replace(/^[.\s]+/,"")):null,v=!!(x&&x.length>0),k=x?.filter(e=>"yield"===e.name||"yield"===e.type).find(e=>"error"!==e.status)?.output,y=b||(k??(x?.length===1?"Tool Execution (1 step)":`Tool Executions (${x?.length} steps)`));return(0,r.Y)("div",{id:t.id,className:`flex flex-col items-start space-y-2 w-full max-w-full transition-all ${n?"pb-10 mb-2":""} ${l}`,children:(0,r.FD)("div",{className:"w-full space-y-2.5 font-sans leading-relaxed",children:[d&&(0,r.Y)(n3,{notice:t.notice}),f&&(0,r.Y)(ej,{thinking:f,defaultExpanded:!1,showSeparator:o}),t.error&&(0,r.FD)("div",{className:"flex items-start space-x-2.5 bg-error/10 border border-error/30 rounded-lg mx-3 px-3.5 py-2.5 text-[12px] text-ink select-text",children:[(0,r.Y)(eF.A,{size:15,className:"text-error flex-shrink-0 mt-0.5"}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 flex-wrap",children:[(0,r.Y)("span",{className:"font-semibold text-error text-[12px] tracking-tight",children:t.error.status?`Error ${t.error.status}`:"Request Failed"}),t.error.stopReason&&(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded",children:t.error.stopReason})]}),t.error.message&&(0,r.FD)("p",{className:"text-ink/80 leading-relaxed text-[12px] font-mono whitespace-pre-wrap break-words",children:[t.error.message.split("\n").map(e=>e.trim()).filter(Boolean)[0],t.error.message.split("\n").map(e=>e.trim()).filter(Boolean).length>1&&(0,r.FD)("span",{className:"relative inline-flex items-center ml-1.5 align-middle group",children:[(0,r.Y)(eA.A,{size:13,className:"text-error/70 hover:text-error cursor-pointer transition-colors"}),(0,r.Y)("span",{className:"pointer-events-none absolute z-50 left-1/2 bottom-full mb-1.5 w-72 -translate-x-1/2 rounded-md bg-ink text-canvas p-2.5 text-[11px] font-mono leading-relaxed whitespace-pre-wrap break-words opacity-0 group-hover:opacity-100 transition-opacity duration-150 shadow-lg",children:t.error.message})]})]})]})]}),h&&(0,r.Y)("div",{className:"text-[13px] text-ink leading-relaxed font-sans bg-transparent px-3 py-1 select-text",children:(0,r.Y)(eS.T,{content:m})}),b&&!v&&(!h||!t.content.toLowerCase().includes(t.intent.toLowerCase().trim()))&&(0,r.Y)("div",{className:`leading-relaxed font-sans px-3 select-text ${h?"text-[12px] text-ink/70 py-0.5":"text-[13px] text-ink py-1"}`,children:b}),v&&(0,r.Y)(n0,{tools:x,title:y,defaultExpanded:!1}),t.systemNote&&(0,r.FD)("div",{className:"text-[12px] text-ink leading-relaxed border-l-2 border-ink/30 bg-paper/60 px-3 py-2 rounded-r-md font-mono break-words whitespace-pre-wrap select-text",children:[(0,r.Y)("span",{className:"text-[10px] text-ink/50 uppercase tracking-wider block mb-0.5 font-sans font-semibold",children:"Diagnostic Note"}),t.systemNote]}),g&&g.length>0&&(0,r.Y)(n0,{tools:g,title:`Follow-up Tools (${g.length})`,defaultExpanded:!0}),!n&&t.summary&&(0,r.FD)("div",{className:"text-[12px] text-ink bg-paper border border-ink/15 rounded-lg p-3 space-y-1 select-text font-sans",children:[(0,r.FD)("div",{className:"font-semibold text-ink flex items-center space-x-1.5 text-[12px]",children:[(0,r.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),(0,r.Y)("span",{children:"Resolution Summary"})]}),(0,r.Y)("p",{className:"text-ink/80 leading-relaxed text-[12px]",children:t.summary})]})]})})});var ra=n("Sjr"),rl=n("Sj"),ro=n("sM"),rc=n("kk");function rd(e){if("number"==typeof e?.startedAt&&Number.isFinite(e.startedAt))return e.startedAt;let t=e?.date||e?.timestamp;if(!t)return null;let n=tO(t);if(null!==n)return n;let r=new Date(t).getTime();return Number.isNaN(r)?null:r}function ru(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.trim())return"";let n=t[e];return n?.trim()?n:e.trim()?e.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function rp(e){let{provider:t,providerNames:n,currentModel:s,dateStr:a,durationMs:l,usage:o,content:c,msgId:d,thinkingLevel:u,onRetry:p,onNewChat:m,isMobile:h=!1}=e,[f,x]=(0,i.J0)(!1),g=()=>{x(!1),p?.(d)},b=()=>{x(!1),m?.(c)};(0,i.vJ)(()=>{if(!f)return;let e=e=>{"Escape"===e.key&&x(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[f]);let v=function(e){if(!Number.isFinite(e)||e<1e3)return;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}(l??0),k=o?.totalTokens??(o?.input??0)+(o?.output??0),y=k>0?`${(0,ti.Rk)(k)??""} tok`:"",w=t?ru(t,n):"",N=o?.cost?.total&&o.cost.total>0?`$${o.cost.total<.01?o.cost.total.toFixed(4):o.cost.total.toFixed(3)}`:"",Y=[];w&&Y.push({key:"provider",content:w}),s&&Y.push({key:"model",content:s,className:"font-semibold text-ink min-w-0 truncate shrink"}),u&&Y.push({key:"thinking",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Thinking level: ${u}`,children:[(0,r.Y)(K.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:u})]})}),a&&Y.push({key:"date",content:a}),v&&Y.push({key:"duration",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Response time: ${v}`,children:[(0,r.Y)(ra.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:v})]})}),y&&Y.push({key:"tokens",content:y,className:"hidden sm:inline",title:o?.cost?.total?`${y} (${N})`:y});let D=[w,s||"Assistant",a||"Just now",y,N].filter(Boolean).join(" • ");return h?(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"w-full flex items-center gap-2 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0 truncate",title:D,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(O.A,{size:10})}),w&&(0,r.Y)("span",{className:"shrink-0 truncate",children:w}),w&&s&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),s&&(0,r.Y)("span",{className:"font-semibold text-ink min-w-0 truncate",children:s}),s&&u&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),u&&(0,r.FD)("span",{className:"shrink-0 inline-flex items-center gap-1 text-ink/60",title:`Thinking level: ${u}`,children:[(0,r.Y)(K.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:u})]})]}),(0,r.Y)("button",{type:"button","aria-label":"More actions","aria-haspopup":"dialog","aria-expanded":f,title:"More actions",onClick:()=>x(!0),className:`ml-auto shrink-0 rounded-md p-2 transition-colors cursor-pointer ${f?"text-ink bg-ink/10":"text-ink/50 hover:bg-ink/5 hover:text-ink"}`,children:(0,r.Y)(rl.A,{size:16})})]}),f&&(0,r.Y)("div",{className:"fixed inset-0 z-[70] flex items-end bg-ink/40 backdrop-blur-[1px] animate-in fade-in duration-150",role:"presentation",onClick:()=>x(!1),children:(0,r.FD)("div",{className:"w-full max-h-[80vh] overflow-y-auto rounded-t-2xl border border-ink/15 bg-paper pb-[max(0.75rem,env(safe-area-inset-bottom,0px))] shadow-2xl animate-in slide-in-from-bottom-4 duration-200",role:"dialog","aria-modal":"true","aria-labelledby":`message-actions-${d}`,onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/10 px-5 py-4",children:[(0,r.Y)("h2",{id:`message-actions-${d}`,className:"text-base font-semibold text-ink",children:"More actions"}),(0,r.Y)("button",{type:"button","aria-label":"Close more actions",title:"Close",onClick:()=>x(!1),className:"rounded-lg p-2 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink cursor-pointer",children:(0,r.Y)(j.A,{size:20})})]}),(a||v||y)&&(0,r.FD)("div",{className:"flex flex-nowrap items-center gap-3 overflow-hidden whitespace-nowrap border-b border-ink/10 px-5 py-3 text-[11px] text-ink/70",children:[a&&(0,r.FD)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(ro.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:a})]}),v&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:"Response time",children:[(0,r.Y)(ra.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:v})]}),y&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:N?`${y} (${N})`:y,children:[(0,r.Y)(rc.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:y})]})]}),(0,r.FD)("div",{className:"p-2",children:[(0,r.Y)(e$,{text:c,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",iconSize:20,iconClassName:"shrink-0 text-ink/55",copiedIconClassName:"shrink-0 text-success",label:"Copy answer",wrapLabel:!0,onClick:()=>x(!1)}),(0,r.FD)("button",{type:"button",onClick:g,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(tR.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Retry response"})]}),(0,r.FD)("button",{type:"button",onClick:b,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(eD.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Start new chat from this answer"})]})]})]})})]}):(0,r.FD)("div",{className:"w-full flex items-center flex-nowrap space-x-2.5 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5 min-w-0 shrink overflow-hidden",title:D,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(O.A,{size:10})}),Y.map((e,t)=>{let{key:n,content:i,className:s,title:a}=e;return(0,r.FD)("span",{className:`inline-flex items-center text-ink/60 ${"model"===n?"min-w-0 shrink":"shrink-0"} whitespace-nowrap ${s??""}`,title:a,children:[t>0&&(0,r.Y)("span",{className:"text-ink/40 mr-1.5",children:"•"}),i]},n)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 shrink-0",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Re-run / Retry generation",onClick:g,children:(0,r.Y)(tR.A,{size:12})}),(0,r.Y)(e$,{text:c,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy response"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:b,children:(0,r.Y)(eD.A,{size:12})})]})]})}function rm(e){let{msg:t,provider:n,providerNames:i,modelName:s,modelNames:a,thinkingLevel:l,durationMs:o,onRetry:c,onNewChat:d,isMobile:u=!1}=e;return(0,r.Y)("div",{className:"mt-2",children:(0,r.Y)(rp,{provider:t.provider||n,providerNames:i,currentModel:(t.model?a?.[t.model]??t.model:"")||s||"",thinkingLevel:t.thinkingLevel??l,dateStr:tJ(t),durationMs:o??t.durationMs,usage:t.usage,content:ri(t),msgId:t.id,onRetry:c,onNewChat:d,isMobile:u})})}let rh=["Synthesizing solution","Evaluating context","Reading workspace","Planning next step","Executing diagnostics","Compiling edge routes"];function rf(e){let{modelName:t,generatingVerb:n,provider:s,providerNames:a}=e,[l,o]=(0,i.J0)(0);(0,i.vJ)(()=>{if(n)return;let e=setInterval(()=>{o(e=>(e+1)%rh.length)},2800);return()=>clearInterval(e)},[n]);let c=n?n.charAt(0).toUpperCase()+n.slice(1):rh[l],d=s?ru(s,a):"";return(0,r.FD)("div",{id:"generating-docked-indicator",className:"w-full flex items-center px-1 py-1 bg-transparent border-0 border-none text-[11px] font-mono select-none animate-in fade-in duration-200",children:[(0,r.Y)("style",{children:`
10
+ ${r}`}function tv(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if(!e)return{text:"",skipped:0};let n=e.split(/\r?\n/);return n.length<=t?{text:e,skipped:0}:{text:n.slice(n.length-t).join("\n"),skipped:n.length-t}}function tk(e){let{text:t}=e,n=(0,i.Kr)(()=>eG(t),[t]),s=(0,i.Kr)(()=>tg(n),[n]),a=(0,i.Kr)(()=>tv(s.content,1e3),[s]),l=(0,i.Kr)(()=>tb(a.text,s.format),[a,s.format]),o=(0,i.Kr)(()=>s.content.split(/\r?\n/).length,[s.content]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)(tu.A,{size:11,className:"text-ink/40"}),(0,r.Y)("span",{children:"Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/45",children:s.format}),o>1&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:[o," lines"]})]}),(0,r.Y)(e$,{text:s.content,className:"flex cursor-pointer items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),s.envelope&&(0,r.Y)(tf,{envelope:s.envelope}),a.skipped>0&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",a.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 select-text",children:(0,r.Y)(eS.T,{content:l,className:"text-[12px] text-ink/85"})})]})}function ty(e){let{tool:t}=e,{groups:n,totalDone:s,totalInProgress:a,totalPending:l,totalTasks:o,opBadge:c}=(0,i.Kr)(()=>td(t),[t]);if(0===n.length&&!c){let e=t.output||"";return e.trim()?(0,r.Y)(tk,{text:e}):null}let d=o>0?Math.round(s/o*100):0;return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eR.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Todo"}),c&&(0,r.Y)("span",{className:"rounded bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-medium text-success",children:c})]}),o>0&&(0,r.FD)("div",{className:"flex items-center gap-2 font-mono text-[10.5px]",children:[(0,r.FD)("span",{className:"text-ink/50",children:[s," of ",o," completed"]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-semibold text-ink",children:[d,"%"]})]})]}),o>0&&(s>0||a>0||l>0)&&(0,r.FD)("div",{className:"mt-2.5 flex flex-wrap items-center gap-1.5 font-mono text-[10px]",children:[s>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-success/10 px-2 py-0.5 text-success",children:[(0,r.Y)(e9.A,{size:11}),(0,r.FD)("span",{children:[s," complete"]})]}),a>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/8 px-2 py-0.5 text-ink/70",children:[(0,r.Y)(e2.A,{size:11,className:"animate-spin"}),(0,r.FD)("span",{children:[a," in progress"]})]}),l>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/5 px-2 py-0.5 text-ink/50",children:[(0,r.Y)(A.A,{size:11}),(0,r.FD)("span",{children:[l," pending"]})]})]}),o>0&&(0,r.Y)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${d}%`}})})]}),(0,r.Y)("div",{className:"space-y-2",children:n.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:e.phase}),(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[e.tasks.filter(e=>"done"===e.status).length,"/",e.tasks.length]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/[0.04] p-1",children:e.tasks.map((e,t)=>{let n="done"===e.status,i="in_progress"===e.status;return(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1.5 text-[11.5px] transition-colors ${i?"bg-ink/[0.03]":""}`,children:[n?(0,r.Y)(e9.A,{size:13,className:"mt-0.5 shrink-0 text-success"}):i?(0,r.Y)(e2.A,{size:13,className:"mt-0.5 shrink-0 animate-spin text-ink"}):(0,r.Y)(A.A,{size:13,className:"mt-0.5 shrink-0 text-ink/25"}),(0,r.Y)("span",{className:`min-w-0 flex-1 leading-snug ${n?"text-ink/40 line-through":i?"font-medium text-ink":"text-ink/80"}`,children:e.text}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/8 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/70",children:"In Progress"})]},t)})})]},t))})]})}var tw=n("E6");function tN(e){if(e&&"object"==typeof e&&"string"==typeof e.path)return e.path}function tY(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"error"===t||"1"===t?"error":"warning"===t||"2"===t?"warning":"info"}let tD={error:{Icon:eF.A,color:"text-error",text:"text-error",badge:"bg-error/10 text-error"},warning:{Icon:tw.A,color:"text-warning",text:"text-warning",badge:"bg-warning/10 text-warning"},info:{Icon:eA.A,color:"text-ink/40",text:"text-ink/70",badge:"bg-ink/5 text-ink/50"}};function tF(e){let{tool:t}=e,n=t.details??{},s=t.output??"",a=n.xdev?.args?.action==="capabilities"||"capabilities"===function(e){if(e&&"object"==typeof e&&"string"==typeof e.action)return e.action}(t.input)||s.includes("capabilities:"),l=(0,i.Kr)(()=>a?function(e){if(!e||!e.includes("capabilities:"))return[];let t=[];for(let n of e.split(/^(?=[A-Za-z0-9_-]+:)/m)){let e=n.trim();if(!e)continue;let r=e.match(/^([A-Za-z0-9_-]+):\s*capabilities:\s*(\{[\s\S]*\})/m);if(r){let e=r[1];try{let n=JSON.parse(r[2]);t.push({name:e,capabilities:n})}catch{t.push({name:e,capabilities:{}})}}}return t}(s):[],[a,s]),o=(0,i.Kr)(()=>a?[]:Array.isArray(n.diagnostics)?n.diagnostics:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.diagnostics))return t.diagnostics;if(Array.isArray(t.errors))return t.errors}}catch{}let t=e.split(/\r?\n/).filter(Boolean),n=[],r=[],i="";for(let e of t){let t=e.trim();if(/^\d+\s+(?:error|warning|hint|info)\(s\):/i.test(t))continue;let s=t.match(/^(#{1,6})\s+(.+)$/);if(s){let e=s[1].length,t=s[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{let e=r.filter(Boolean).join("");i=e?`${e.replace(/\/+$/,"")}/${t}`:t}continue}let a=e.match(/^\s*(\d+):(\d+)\s+\[(error|warning|info|hint)\]\s*(?:\[([^\]]+)\])?\s*(.*?)(?:\s*\((\d+|TS\d+)\))?$/i);if(a){n.push({file:i||void 0,line:parseInt(a[1],10),column:parseInt(a[2],10),severity:"hint"===a[3].toLowerCase()?"info":a[3].toLowerCase(),source:a[4]||void 0,message:a[5].trim(),code:a[6]||void 0});continue}let l=e.match(/^([^:\n]+):(\d+)(?::(\d+))?\s*[-:]?\s*(error|warning|info|hint)?\s*(?:(TS\d+|[A-Za-z0-9_-]+):)?\s*(.*)$/i);l&&n.push({file:l[1].trim(),line:parseInt(l[2],10),column:l[3]?parseInt(l[3],10):void 0,severity:l[4]?"hint"===l[4].toLowerCase()?"info":l[4].toLowerCase():"error",code:l[5]||void 0,message:l[6]?.trim()||e})}return n}(s),[n.diagnostics,a,s]);if(a&&l.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eJ.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:"Language Servers"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"Capabilities"})]}),(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:[l.length," active"]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/30",children:l.map((e,t)=>{let n=Object.entries(e.capabilities).filter(e=>{let[,t]=e;return!!t}).map(e=>{let[t]=e;return t.replace(/Provider$/,"")});return(0,r.FD)("div",{className:"p-3 text-[11px]",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eO.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"font-mono font-medium text-ink",children:e.name}),(0,r.FD)("span",{className:"ml-auto inline-flex items-center gap-1 font-mono text-[9.5px] text-success",children:[(0,r.Y)(e9.A,{size:10}),"Connected"]})]}),n.length>0&&(0,r.Y)("div",{className:"mt-2 flex flex-wrap gap-1",children:n.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] text-ink/60",children:e},t))})]},t)})})]})});if(0===o.length)return s?(0,r.Y)(tk,{text:s}):null;let c=e=>o.filter(t=>tY(t)===e),d=c("error").length,u=c("warning").length,p=c("info").length;return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diagnostics"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-2 font-mono text-[10px]",children:[d>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-error",children:[(0,r.Y)(eF.A,{size:9}),d]}),u>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-warning",children:[(0,r.Y)(tw.A,{size:9}),u]}),p>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-ink/50",children:[(0,r.Y)(eA.A,{size:9}),p]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1 max-h-72 overflow-auto",children:o.map((e,t)=>{let n,i,s,a=tD[tY(e)],l=(n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="number"==typeof e.line?e.line:void 0,s="number"==typeof e.column?e.column:void 0,n?void 0===i?n:void 0===s?`${n}:${i}`:`${n}:${i}:${s}`:""),o="string"==typeof e.message?e.message:"",c="string"==typeof e.code?e.code:void 0,d="string"==typeof e.source?e.source:void 0,{Icon:u,color:p,text:m}=a;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-3.5 shrink-0 items-center justify-center",children:(0,r.Y)(u,{size:12,className:p})}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words leading-5",children:[l&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45 mr-1",children:[l,":"]}),(0,r.Y)("span",{className:m,children:o}),d&&(0,r.FD)("span",{className:"ml-1.5 font-mono text-[9px] text-ink/35",children:["[",d,"]"]}),c&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9px] text-ink/35",children:["(",c,")"]})]})]},t)})})]})}var tA=n("q");function tC(e){return"string"==typeof e.url?e.url:"string"==typeof e.link?e.link:""}function tS(e){return"string"==typeof e.snippet&&e.snippet?e.snippet:"string"==typeof e.description?e.description:""}function tT(e){let{tool:t}=e,n=t.details??{},i="string"==typeof n.response?.provider?n.response.provider:"string"==typeof n.provider?n.provider:void 0,s=Array.isArray(n.results)?n.results:Array.isArray(n.sources)?n.sources:Array.isArray(n.response?.sources)?n.response.sources:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.results))return t.results;if(Array.isArray(t.sources))return t.sources;if(Array.isArray(t.organic))return t.organic;if(Array.isArray(t.items))return t.items;if(t.response&&Array.isArray(t.response.sources))return t.response.sources}}catch{}return[]}(t.output??"");return 0===s.length?t.output?(0,r.Y)(tk,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:[i&&(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-paper px-2.5 py-1 text-[9.5px]",children:[(0,r.Y)("span",{className:"font-semibold uppercase tracking-wider text-ink/40",children:"Sources"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-ink/50 uppercase",children:i})]}),(0,r.Y)("ol",{className:"divide-y divide-ink/6",children:s.map((e,t)=>{let n=tC(e),i="string"==typeof e.publishedDate?e.publishedDate:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:"string"==typeof e.title&&e.title?e.title:tC(e)||"Result"}),n&&(0,r.Y)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex shrink-0 items-center rounded-md p-0.5 text-ink/40 transition-colors hover:bg-ink/5 hover:text-ink",title:n,children:(0,r.Y)(tA.A,{size:10})})]}),(0,r.FD)("div",{className:"flex items-center gap-2 pl-[22px] font-mono text-[9.5px] text-ink/40",children:[n&&(0,r.Y)("span",{className:"truncate",children:n}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 text-[8.5px] text-ink/50",children:i})]}),tS(e)&&(0,r.Y)("div",{className:"mt-0.5 pl-[22px] leading-snug text-ink/65",children:tS(e)})]},t)})})]})}var tz=n("o"),t$=n("sJ");function tj(e){let{tool:t}=e,n=t.input,s="object"==typeof n&&null!==n?n:void 0,a="string"==typeof s?.code?s.code:"string"==typeof n?n:"",l=("string"==typeof s?.language?s.language:"js").toUpperCase(),o="number"==typeof s?.timeout?`${s.timeout}s`:void 0,c="string"==typeof s?.title?s.title:void 0,d=t.output||(t.error?`Error: ${t.error}`:""),u="error"===t.status||d.includes("ToolError:")||d.includes("Command exited with code"),p=d.includes("Command aborted")||"aborted"===t.status,m=(0,e8.w)(),h=(0,i.Kr)(()=>u||p?{isValid:!1}:(0,e3.Bl)(d),[d,u,p]),f=(0,i.Kr)(()=>tv(a,1e3),[a]),x=(0,i.Kr)(()=>(0,e3.wY)(f.text,"javascript"),[f,m]),g=(0,i.Kr)(()=>tv(d,1e3),[d]),b=(0,i.Kr)(()=>h.isValid&&h.pretty?tv(h.pretty,1e3):null,[h]),v=(0,i.Kr)(()=>b?(0,e3.PH)(b.text):"",[b,m]);return(0,r.FD)("div",{className:"space-y-2",children:[a&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eI.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:c||"Script Evaluation"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:l}),o&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/40",children:[(0,r.Y)(tz.A,{size:10}),(0,r.Y)("span",{children:o})]})]}),(0,r.Y)(e$,{text:a,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),f.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",f.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2.5 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:f.text.split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:x}})]})]}),d&&(0,r.FD)("div",{className:`overflow-hidden rounded-lg border ${u?"border-error/25 bg-error/[0.03]":p?"border-warning/25 bg-warning/[0.03]":"border-ink/8 bg-paper"}`,children:[(0,r.FD)("div",{className:`flex items-center justify-between border-b px-3 py-1.5 ${u?"border-error/15 bg-error/[0.06]":p?"border-warning/15 bg-warning/[0.06]":"border-ink/6 bg-canvas/30"}`,children:[(0,r.Y)("div",{className:"flex items-center gap-1.5",children:u?(0,r.FD)(r.FK,{children:[(0,r.Y)(eF.A,{size:11,className:"text-error"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-error",children:"Execution Error"})]}):p?(0,r.FD)(r.FK,{children:[(0,r.Y)(te.A,{size:11,className:"text-warning"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-warning",children:"Evaluation Aborted"})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)(t$.A,{size:11,className:"text-success"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:"Evaluation Result"}),h.isValid&&(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),h.linesCount&&h.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[h.linesCount," lines"]})]})]})}),(0,r.Y)(e$,{text:h.isValid&&h.pretty?h.pretty:d,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),h.isValid&&h.pretty?(0,r.FD)(r.FK,{children:[b&&b.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:(b?b.text:h.pretty).split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:v}})]})]}):(0,r.FD)(r.FK,{children:[g.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:`max-h-48 overflow-y-auto p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words select-text ${u?"text-error":p?"text-warning":"text-ink/80"}`,children:g.text})]})]})]})}var tL=n("DB"),tM=n("vZ");let tP={open:"bg-success/10 text-success",merged:"bg-ink/10 text-ink/60",closed:"bg-error/10 text-error"};function tE(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.pullRequests))return t.pullRequests;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:i.map((e,t)=>{let n=!0===e.merged||"merged"===e.state?"merged":"closed"===e.state?"closed":"open",i="string"==typeof e.title?e.title:"",s="number"==typeof e.number?`#${e.number}`:"",a="string"==typeof e.author?e.author:"",l="number"==typeof e.additions?e.additions:void 0,o="number"==typeof e.deletions?e.deletions:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:["merged"===n?(0,r.Y)(tL.A,{size:12,className:"shrink-0 text-success"}):"closed"===n?(0,r.Y)(eU.A,{size:12,className:"shrink-0 text-error"}):(0,r.Y)(tM.A,{size:12,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:i}),s&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/45",children:s})]}),(0,r.FD)("div",{className:"mt-1 flex items-center gap-1.5 pl-[18px] text-[10px] text-ink/50",children:[(0,r.Y)("span",{className:`rounded-full px-1.5 py-px font-mono ${tP[n]}`,children:n}),a&&(0,r.Y)("span",{children:a}),(void 0!==l||void 0!==o)&&(0,r.FD)("span",{className:"ml-auto font-mono",children:[void 0!==l&&(0,r.FD)("span",{className:"text-success",children:["+",l]}),void 0!==o&&(0,r.FD)("span",{className:"ml-1 text-error",children:["-",o]})]})]})]},t)})})}var tR=n("Ir");function tI(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function tO(e){if(!e.startsWith("Today,"))return null;let t=e.slice(6).trim(),n=new Date(`${new Date().toDateString()} ${t}`);return Number.isNaN(n.getTime())?null:n.getTime()}function tJ(e){let t=e?.timestamp||e?.date;if(!t)return"";if(t.startsWith("Today,"))return`Today, ${t.slice(6).trim()}`;if(/^\d{1,2}:\d{2}\s*(AM|PM)$/i.test(t)){let e=tO(`Today, ${t}`);if(null!==e)return`Today, ${tI(e)}`}let n=new Date(t);if(Number.isNaN(n.getTime()))return"";let r=n.toLocaleDateString("en-US",{month:"short",day:"numeric"});return`${r}, ${tI(n)}`}function t_(e){let{tool:t}=e,n=t.details??{},i=n&&"object"==typeof n?n:{},s="rewind"===t.type,a="string"==typeof i.id?i.id:void 0,l=function(e){if("number"==typeof e){let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString()}return"string"==typeof e?e:""}(i.timestamp),o="number"==typeof i.fileCount?i.fileCount:void 0,c="string"==typeof i.branch?i.branch:void 0,d="string"==typeof i.message?i.message:"string"==typeof i.description?i.description:"";return a||l||o||c||d?(0,r.FD)("div",{className:"flex items-start gap-2.5 rounded-lg border border-ink/8 bg-canvas/40 px-3 py-2.5",children:[(0,r.Y)("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-ink/5 text-ink/60",children:s?(0,r.Y)(tR.A,{size:12}):(0,r.Y)(eK.A,{size:12})}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[d&&(0,r.Y)("div",{className:"text-[11.5px] text-ink/85",children:d}),(0,r.FD)("div",{className:"flex flex-wrap gap-x-2 gap-y-0.5 font-mono text-[9.5px] text-ink/45",children:[a&&(0,r.Y)("span",{children:a}),l&&(0,r.Y)("span",{children:l}),void 0!==o&&(0,r.FD)("span",{children:[o," files"]}),c&&(0,r.Y)("span",{children:c})]})]})]}):t.output?.trim()?(0,r.Y)(tk,{text:t.output}):null}function tW(e){var t;let n,{tool:s}=e,a=s.details??{},l="object"==typeof s.input&&null!==s.input?s.input:void 0,o=s.command||("string"==typeof l?.command?l.command:void 0)||("string"==typeof l?.cmd?l.cmd:void 0)||("string"==typeof l?.CommandLine?l.CommandLine:void 0)||("string"==typeof l?.commandLine?l.commandLine:void 0)||("string"==typeof s.input?s.input:""),{cleanText:c,wallTime:d}=(n=(t=s.output||(s.error?`Error: ${s.error}`:"")).match(/\n*Wall time:\s*([^\n\r]+)$/))?{cleanText:t.replace(/\n*Wall time:\s*[^\n\r]+$/,""),wallTime:n[1].trim()}:{cleanText:t},u="number"==typeof a.exitCode?a.exitCode:s.isError?1:void 0,p=("string"==typeof a.cwd?a.cwd:void 0)||("string"==typeof l?.cwd?l.cwd:void 0)||("string"==typeof l?.Cwd?l.Cwd:void 0),m="number"==typeof a.durationMs?a.durationMs:s.durationMs,h=s.duration||d||(m?`${m}ms`:void 0),f=!c||"(no output)"===c,x=(0,i.Kr)(()=>f||s.isError?{isValid:!1}:(0,e3.Bl)(c),[c,f,s.isError]),g=(0,i.Kr)(()=>eG(c),[c]),b=(0,i.Kr)(()=>tv(g,1e3),[g]),v=(0,i.Kr)(()=>x.isValid&&x.pretty?x.pretty:g,[x,g]),k=(0,i.Kr)(()=>(0,e3.rw)(g),[g]),y=(0,i.Kr)(()=>g.trim().startsWith("{")||g.trim().startsWith("[")?"json":"javascript",[g]),w=(0,i.Kr)(()=>x.isValid&&x.pretty?tv(x.pretty,1e3):null,[x]),N=(0,e8.w)(),Y=(0,i.Kr)(()=>o?(0,e3.wY)(o,"bash"):"",[o,N]),F=(0,i.Kr)(()=>k?(0,e3.wY)(b.text,y):"",[k,b,y,N]);return(0,r.FD)("div",{className:"space-y-2",children:[o&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/60 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1",children:[(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"})]}),(0,r.Y)("span",{className:"font-mono text-[10px] font-semibold text-ink/50",children:"bash"}),p&&(0,r.Y)("span",{className:"truncate font-mono text-[9.5px] text-ink/40",title:p,children:p})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[void 0!==u&&(0,r.FD)("span",{className:`rounded-full px-1.5 py-0.2 font-mono text-[9px] font-semibold ${0===u?"bg-success/10 text-success":"bg-error/10 text-error"}`,children:["exit ",u]}),h&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/45",children:[(0,r.Y)(tz.A,{size:10}),(0,r.Y)("span",{children:h})]}),(0,r.Y)(e$,{text:o,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy command",label:"Copy"})]})]}),(0,r.FD)("div",{className:"flex items-start gap-2.5 px-3 py-2 font-mono text-[11.5px] leading-relaxed",children:[(0,r.Y)("span",{className:"select-none font-bold text-ink/40",children:"$"}),(0,r.Y)("pre",{className:"min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all text-ink/90 select-text",dangerouslySetInnerHTML:{__html:Y}})]})]}),f?(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-dashed border-ink/15 bg-canvas/30 px-3 py-2 font-mono text-[11px] text-ink/50",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(D.A,{size:12,className:"text-success"}),(0,r.Y)("span",{children:"Command executed successfully with no output"})]}),h&&(0,r.FD)("span",{className:"text-[10px] text-ink/40",children:["Wall time: ",h]})]}):x.isValid&&x.pretty?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),x.linesCount&&x.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[x.linesCount," lines"]})]}),(0,r.Y)(e$,{text:x.isValid&&x.pretty?x.pretty:c,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),w&&w.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",w.skipped," earlier lines hidden"]}),(0,r.Y)(tr,{jsonString:w?w.text:x.pretty,maxHeightClass:"max-h-72",showHeader:!1})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)(e$,{text:v,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),b.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-y-auto overscroll-contain p-3 font-mono text-[11px] leading-relaxed select-text",children:k?(0,r.Y)("pre",{className:"overflow-x-auto whitespace-pre text-ink/85 leading-relaxed",dangerouslySetInnerHTML:{__html:F}}):b.text.split("\n").map((e,t)=>{let n=e.includes("✓")||e.includes("built in")||e.includes("ready: 0 errors"),i=e.includes("Error:")||e.includes("error:")||e.includes("FAILED"),s=e.includes("warning:")||e.includes("warn:");return(0,r.Y)("div",{className:`whitespace-pre-wrap break-words ${n?"text-success font-medium":i?"text-error font-medium":s?"text-warning font-medium":"text-ink/80"}`,children:e||" "},t)})})]})]})}var tK=n("W0"),tU=n("jx"),tB=n("Nf");function tq(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=t.output||("string"==typeof a.displayContent?a.displayContent:""),o=function(e){let t=e.input;if(t&&"object"==typeof t){if("string"==typeof t.pattern)return t.pattern;if("string"==typeof t.path)return t.path;if("string"==typeof t.glob)return t.glob;if("string"==typeof t.query)return t.query;if("string"==typeof t.regex)return t.regex;if("string"==typeof t.search)return t.search;if("string"==typeof t.text)return t.text}return"string"==typeof e.target&&"."!==e.target?e.target:""}(t),c="glob"===t.type||"glob"===t.name,d=(0,i.Kr)(()=>tv(l,1e3),[l]),{files:u,totalMatches:p,isGlobList:m}=(0,i.Kr)(()=>(function(e){let t=e.split(/\r?\n/),n=[],r=[],i=null,s=!0;for(let e of t){let t=e.trimEnd();if(!t||t.startsWith("[")&&t.endsWith("]")||/^Showing files \d+/i.test(t)||/^Found \d+ matches/i.test(t))continue;let a=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+)):(\d+)(?::\d+)?:(.*)$/);if(a){s=!1;let e=a[1].trim(),t=parseInt(a[2],10)||1,r=a[3],l=n.find(t=>t.path===e);l||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),l={path:e,lines:[],matchCount:0},n.push(l),i=l),l.lines.push({lineNum:t,text:r,isMatch:!0}),l.matchCount++;continue}let l=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+))-(\d+)-(.*)$/);if(l){s=!1;let e=l[1].trim(),t=parseInt(l[2],10)||1,r=l[3],a=n.find(t=>t.path===e);a||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),a={path:e,lines:[],matchCount:0},n.push(a),i=a),a.lines.push({lineNum:t,text:r,isMatch:!1});continue}let o=t.match(/^(#{1,6})\s+(.+)$/);if(o){let e=o[1].length,t=o[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let e=r.filter(Boolean).join("");i={path:e?`${e.replace(/\/+$/,"")}/${t}`:t,lines:[],matchCount:0}}continue}let c=t.match(/^(\*?)(\s*\d+)[|:\u2502](.*)$/);if(c){s=!1;let e="*"===c[1],t=parseInt(c[2].trim(),10)||1,r=c[3];i||(i={path:"Results",lines:[],matchCount:0},n.push(i)),i.lines.push({lineNum:t,text:r,isMatch:e}),e&&i.matchCount++;continue}if(!t.startsWith("#")&&!c){(t.includes("|")||t.includes(":")||t.includes("│"))&&(s=!1);let e=r.filter(Boolean).join(""),i=e?`${e.replace(/\/+$/,"")}/${t}`:t;n.push({path:i,lines:[],matchCount:1})}}i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let a=n.reduce((e,t)=>e+(t.matchCount||t.lines.length||1),0);return{files:n,totalMatches:a,isGlobList:s}})(d.text),[d.text]),h=(0,i.Kr)(()=>{if(!n)return u;let e=n.toLowerCase();return u.map(t=>{let n=t.path.toLowerCase().includes(e),r=t.lines.filter(t=>t.text.toLowerCase().includes(e));return n?t:r.length>0?{...t,lines:r}:null}).filter(e=>null!==e)},[u,n]),f=(0,e8.w)(),x=(0,i.Kr)(()=>h.map(e=>{let t=(0,e3.sQ)(e.path);return(0,e3.O9)(e.lines.map(e=>e.text).join("\n"),t)}),[h,f]);return l||0!==u.length?(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-ink/5 text-ink/60",children:c||m?(0,r.Y)(tK.A,{size:12}):(0,r.Y)(tU.A,{size:12})}),(0,r.Y)("span",{className:"font-semibold text-ink",children:c||m?"Files Found":"Search Matches"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/60",children:[p," ",1===p?"match":"matches"]}),u.length>1&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:["in ",u.length," ",1===u.length?"file":"files"]}),o&&(0,r.FD)("span",{className:"rounded border border-ink/10 bg-canvas px-1.5 py-0.5 font-mono text-[10px] text-ink/75",children:['"',o,'"']})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[u.length>4&&(0,r.Y)("input",{type:"text",placeholder:"Filter paths...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-28 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink placeholder:text-ink/30 focus:border-ink/30 focus:outline-none"}),(0,r.Y)(e$,{text:l,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),d.skipped>0&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:["… ",d.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"max-h-80 space-y-2 overflow-y-auto overscroll-contain pr-0.5",children:[h.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(eE.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink/85",children:e.path})]}),e.matchCount>0&&!m&&(0,r.FD)("span",{className:"ml-2 shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/50",children:[e.matchCount," ",1===e.matchCount?"hit":"hits"]})]}),e.lines.length>0&&(0,r.Y)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,r.Y)("div",{className:"w-max min-w-full divide-y divide-ink/[0.04] font-mono text-[11px] leading-relaxed select-text",children:e.lines.map((e,n)=>(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1 transition-colors ${e.isMatch?"bg-warning/[0.08] text-ink":"bg-paper text-ink/60 hover:bg-ink/[0.02]"}`,children:[(0,r.FD)("span",{className:`sticky left-0 z-10 flex w-9 shrink-0 select-none items-center justify-end bg-inherit font-mono text-[10px] ${e.isMatch?"font-semibold text-warning-dark dark:text-warning":"text-ink/30"}`,children:[e.isMatch&&(0,r.Y)(tB.A,{size:10,className:"mr-0.5 text-warning"}),e.lineNum]}),(0,r.Y)("pre",{className:"shiki whitespace-pre font-mono",dangerouslySetInnerHTML:{__html:x[t]?.[n]||"&nbsp;"}})]},n))})})]},t)),0===h.length&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 p-4 text-center font-mono text-[11px] text-ink/40",children:['No results match filter "',n,'"']})]})]}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[c?(0,r.Y)(tK.A,{size:13,className:"shrink-0"}):(0,r.Y)(tU.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",c?"files":"matches"," found",o?` for "${o}"`:""]})]})}var tH=n("B5"),tG=n("gk");function tV(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"high"===t||"critical"===t||"error"===t?"high":"medium"===t||"warning"===t?"medium":"low"===t?"low":"info"}let tZ={high:"bg-error/10 text-error",medium:"bg-warning/10 text-warning",low:"bg-ink/8 text-ink/60",info:"bg-ink/5 text-ink/50"};function tQ(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.findings)?n.findings:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.findings))return t.findings;if(Array.isArray(t.vulnerabilities))return t.vulnerabilities;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");if(0===i.length)return t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-success/20 bg-success/[0.04] px-3 py-2.5 text-[11.5px] text-success",children:[(0,r.Y)(tH.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No issues found"})]});let s=function(e){let t={high:0,medium:0,low:0,info:0};for(let n of e)t[tV(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Findings"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.high>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.high," high"]}),s.medium>0&&(0,r.FD)("span",{className:"rounded-full bg-warning/10 px-1.5 py-px text-warning",children:[s.medium," med"]}),s.low>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/55",children:[s.low," low"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=tV(e),i="string"==typeof e.message?e.message:"",s="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",a="number"==typeof e.line?e.line:void 0,l="string"==typeof e.rule?e.rule:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(tG.A,{size:11,className:`mt-0.5 shrink-0 ${"high"===n?"text-error":"medium"===n?"text-warning":"text-ink/40"}`}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[(0,r.Y)("span",{className:`mr-1.5 rounded-full px-1.5 py-px font-mono text-[9px] ${tZ[n]}`,children:n}),s&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[s,void 0!==a?`:${a}`:"",": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),l&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",l,")"]})]})]},t)})})]})}var tX=n("zH"),t0=n("cQ");let t1={running:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",failed:"bg-error/10 text-error",idle:"bg-ink/5 text-ink/45"};function t5(e){let{tool:t}=e,n=t.details??{},s=Array.isArray(n.jobs)?n.jobs:Array.isArray(n.items)?n.items:[],a=t.input,l="object"==typeof a&&null!==a?a:void 0,o=t.output||"";if(l?.op==="wait"){let e=Array.isArray(l.ids)?l.ids:[],t="string"==typeof l.name?l.name:void 0,n="string"==typeof l.for?l.for:void 0,i="number"==typeof l.timeout?`${l.timeout}s`:"number"==typeof l.timeoutMs?`${Math.round(l.timeoutMs/1e3)}s`:void 0;return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tX.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:t?`Hub Wait: ${t}`:"Hub Wait"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?`wait (${n})`:"job wait"})]}),i&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:["timeout: ",i]})]}),e.length>0&&(0,r.FD)("div",{className:"pt-1",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Waiting for Job IDs"}),(0,r.Y)("div",{className:"mt-1 flex flex-wrap gap-1.5 font-mono text-[10.5px]",children:e.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/80",children:e},t))})]}),o&&(0,r.Y)(tk,{text:o})]})}if(l?.op==="logs"){let e="string"==typeof l.name?l.name:"Process";return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.Y)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eJ.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:e}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"logs"})]})}),(0,r.Y)("div",{className:"rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/85 whitespace-pre-wrap",children:o||"// No log output"})]})}let c=(0,i.Kr)(()=>{let e="string"==typeof l?.op?l.op.toLowerCase():"",t=["start","stop","restart","status"].includes(e),n=o.includes("pid=");if(!t&&!n)return null;let r=l?.name||"Service",i=l?.application,s=Array.isArray(l?.args)?l.args.join(" "):"",a=i?`${i} ${s}`.trim():s,c=l?.ready?.port,d=o.match(/pid=(\d+)/i),u=o.match(/uptime=([^\s]+)/i),p=o.match(/restarts=(\d+)/i),m=o.toLowerCase().includes("ready")||o.toLowerCase().includes("started")||o.toLowerCase().includes("running");return{op:e||"process",name:r,cmd:a,port:c,pid:d?d[1]:void 0,uptime:u?u[1]:void 0,restarts:p?p[1]:void 0,isReady:m,outputLines:o.split(/\r?\n/).filter(Boolean)}},[l,o]);return c?(0,r.Y)("div",{className:"space-y-2",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eJ.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:c.name}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] uppercase tracking-wider text-ink/50",children:c.op})]}),c.isReady&&(0,r.FD)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-semibold text-success",children:[(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-success animate-pulse"}),"Active"]})]}),(0,r.FD)("div",{className:"divide-y divide-ink/[0.04] p-3 text-[11px]",children:[c.cmd&&(0,r.FD)("div",{className:"flex items-center justify-between py-1 font-mono",children:[(0,r.Y)("span",{className:"text-ink/45",children:"Command"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/85",children:c.cmd})]}),(0,r.FD)("div",{className:"flex flex-wrap items-center gap-4 py-1.5 font-mono text-[10.5px]",children:[c.port&&(0,r.FD)("span",{className:"text-ink/60",children:["Port: ",(0,r.Y)("strong",{className:"text-ink",children:c.port})]}),c.pid&&(0,r.FD)("span",{className:"text-ink/60",children:["PID: ",(0,r.Y)("strong",{className:"text-ink",children:c.pid})]}),c.uptime&&(0,r.FD)("span",{className:"text-ink/60",children:["Uptime: ",(0,r.Y)("strong",{className:"text-ink",children:c.uptime})]})]}),c.outputLines.length>0&&(0,r.FD)("div",{className:"pt-2",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Log Output"}),(0,r.Y)("div",{className:"mt-1 rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/75",children:c.outputLines.map((e,t)=>(0,r.Y)("div",{children:e},t))})]})]})]})}):0===s.length?o?(0,r.Y)(tk,{text:o}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(t0.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No hub activities"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Hub Jobs"}),(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:s.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:s.map((e,t)=>{let n,i="running"===(n="string"==typeof e.status?e.status.toLowerCase():"string"==typeof e.state?e.state.toLowerCase():"")||"started"===n||"pending"===n?"running":"done"===n||"completed"===n||"success"===n?"done":"failed"===n||"error"===n?"failed":"idle",s="string"==typeof e.id?e.id:"string"==typeof e.name?e.name:`job-${t}`,a="string"==typeof e.label?e.label:"string"==typeof e.task?e.task:"string"==typeof e.message?e.message:"",l="string"==typeof e.type?e.type:void 0,o="number"==typeof e.durationMs?`${(e.durationMs/1e3).toFixed(1)}s`:void 0,c="string"==typeof e.resolvedModel?e.resolvedModel:void 0;return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px]",children:["running"===i?(0,r.Y)(tX.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):"done"===i?(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-success"}):(0,r.Y)(t$.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/80",children:s}),l&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/45",children:l}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/85",children:a}),c&&(0,r.Y)("span",{className:"hidden sm:inline-block font-mono text-[9px] text-ink/40 truncate max-w-[120px]",children:c}),o&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:o}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${t1[i]}`,children:i})]},t)})})]}),o&&(0,r.Y)(tk,{text:o})]})}var t2=n("jI"),t4=n("rY"),t3=n("Os");function t8(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.notes)?n.notes:[],s="new_context"===t.type;return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[s?(0,r.Y)(t2.A,{size:13,className:"shrink-0"}):(0,r.Y)(t4.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",s?"notes created":"notes"]})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"New Context":"Notes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.title&&e.title?e.title:"string"==typeof e.text&&e.text?e.text:"string"==typeof e.content&&e.content?e.content:"string"==typeof e.note?e.note:"";return n?(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[s?(0,r.Y)(t3.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(t4.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n})]},"string"==typeof e.id?e.id:`note-${t}`):null})})]})}var t6=n("YO"),t9=n("Y0"),t7=n("z9");let ne={memory_edit:{label:"Memory Edit",icon:(0,r.Y)(eB.A,{size:11})},retain:{label:"Retained",icon:(0,r.Y)(t6.A,{size:11})},recall:{label:"Recalled",icon:(0,r.Y)(K.A,{size:11})},reflect:{label:"Reflections",icon:(0,r.Y)(K.A,{size:11})},learn:{label:"Learned",icon:(0,r.Y)(t9.A,{size:11})}};function nt(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.memories))return t.memories;if(Array.isArray(t.results))return t.results}}catch{}return[]}(t.output??""),s=ne[t.type]??{label:"Memory",icon:(0,r.Y)(K.A,{size:11})};return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(t7.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No memories"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s.label}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.text&&e.text?e.text:"string"==typeof e.content?e.content:"";if(!n)return null;let i="number"==typeof e.score&&Number.isFinite(e.score)?e.score:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"mt-0.5 shrink-0 text-ink/40",children:s.icon}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n}),void 0!==i&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[Math.round(100*i),"%"]})]},"string"==typeof e.id?e.id:`mem-${t}`)})})]})}var nn=n("ND"),nr=n("u8");function ni(e){let t="string"==typeof e.state?e.state.toLowerCase():"";return"attached"===t||"running"===t?t:"detached"===t?"detached":"stopped"}let ns={attached:"bg-success/10 text-success",running:"bg-ink/8 text-ink/60",stopped:"bg-ink/5 text-ink/45",detached:"bg-error/10 text-error"};function na(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[];if(0===i.length)return t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(nn.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No debug session"})]});let s=function(e){let t={attached:0,running:0,stopped:0,detached:0};for(let n of e)t[ni(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Debug Session"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.attached>0&&(0,r.FD)("span",{className:"rounded-full bg-success/10 px-1.5 py-px text-success",children:[s.attached," attached"]}),s.running>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/60",children:[s.running," run"]}),s.detached>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.detached," detach"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=ni(e),i="string"==typeof e.target&&e.target?e.target:"number"==typeof e.pid?`pid ${e.pid}`:"string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["attached"===n?(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-success"}):"running"===n?(0,r.Y)(nr.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):(0,r.Y)(tt.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/75",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${ns[n]}`,children:n})]},`${i}-${t}`)})})]})}var nl=n("vBE"),no=n("qd"),nc=n("Sy"),nd=n("oS");let nu={active:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",paused:"bg-warning/10 text-warning"};function np(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[],s="yield"===t.type||"yield"===t.name,a="error"===t.status;if(s){let e=function(e){let t=(0,nd.u)(e.details)?e.details:void 0,n=(0,nd.u)(e.input)?e.input:void 0,r=(t&&(0,nd.u)(t.data)?t.data:void 0)??(n&&(0,nd.u)(n.data)?n.data:void 0)??t??n;if(!r)return null;let i="string"==typeof r.summary?r.summary:void 0,s="string"==typeof r.report?r.report:void 0,a="string"==typeof r.architecture?r.architecture:void 0,l=Array.isArray(r.files)?r.files:void 0,o=[];if(l)for(let e of l)"string"==typeof e&&e?o.push(e):(0,nd.u)(e)&&"string"==typeof e.path&&o.push({path:e.path,description:"string"==typeof e.description?e.description:void 0});let c="string"==typeof t?.status?t.status:"string"==typeof r.status?r.status:void 0,d="string"==typeof r.error?r.error:null;return i||s||a||0!==o.length||d?{summary:i,report:s,architecture:a,files:o.length>0?o:void 0,status:c,error:d}:null}(t);if(e)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper text-[12px] text-ink select-text",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:`flex h-5 w-5 items-center justify-center rounded-md ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:a||e.error?(0,r.Y)(tw.A,{size:12}):(0,r.Y)(e9.A,{size:12})}),(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:a||e.error?"Yield Error":"Yield Result"})]}),(e.status||(a?"error":"success"))&&(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-medium uppercase ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.status||(a?"failed":"success")})]}),(0,r.FD)("div",{className:"space-y-2.5 p-3",children:[(e.error||a&&t.output)&&(0,r.FD)("div",{className:"flex items-start gap-2 rounded-md bg-error/10 p-2.5 text-error text-[11.5px]",children:[(0,r.Y)(tw.A,{size:13,className:"shrink-0 mt-0.5"}),(0,r.Y)("span",{className:"font-mono leading-relaxed",children:e.error||t.output})]}),e.summary&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Summary"}),(0,r.Y)("p",{className:"mt-0.5 font-sans text-[12px] text-ink font-medium leading-relaxed",children:e.summary})]}),e.report&&e.report!==e.summary&&(0,r.FD)("div",{className:"rounded-md border border-ink/8 bg-canvas/30 p-2.5",children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Report"}),(0,r.Y)("div",{className:"mt-1 text-[11.5px] text-ink/85 leading-relaxed",children:(0,r.Y)(eS.T,{content:e.report})})]}),e.architecture&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Evidence / Architecture"}),(0,r.Y)("div",{className:"mt-0.5 text-[11px] text-ink/75 leading-relaxed bg-ink/[0.03] p-2 rounded border border-ink/6",children:(0,r.Y)(eS.T,{content:e.architecture})})]}),e.files&&e.files.length>0&&(0,r.FD)("div",{children:[(0,r.FD)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:["Files Inspected (",e.files.length,")"]}),(0,r.Y)("div",{className:"mt-1 grid grid-cols-1 gap-1 sm:grid-cols-2",children:e.files.map((e,t)=>{let n="string"==typeof e?e:e.path,i="string"==typeof e?void 0:e.description;return(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5",children:[(0,r.FD)("span",{className:"inline-flex items-center gap-1 font-mono text-[10.5px] font-medium text-ink truncate",children:[(0,r.Y)(eE.A,{size:10,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:n})]}),i&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight mt-0.5 truncate",children:i})]},t)})})]})]})]})}return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tt.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:s?"No yield":"No goals"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"Yield":"Goals"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.title&&e.title?e.title:"string"==typeof e.description?e.description:"";if(!i)return null;let a="number"==typeof e.progress&&Number.isFinite(e.progress)?e.progress:void 0,l="done"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"completed"===n?"done":"paused"===n||"yielded"===n?"paused":"active";return(0,r.FD)("div",{className:"px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-start gap-2 text-[11.5px]",children:[s?(0,r.Y)(nl.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(no.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${nu[l]}`,children:l})]}),void 0!==a&&(0,r.FD)("div",{className:"mt-1.5 flex items-center gap-1.5 pl-[18px]",children:[(0,r.Y)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-ink/60 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,Math.round(100*a)))}%`}})}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-0.5 font-mono text-[9px] text-ink/45",children:[(0,r.Y)(nc.A,{size:8}),Math.round(100*a),"%"]})]})]},"string"==typeof e.id?e.id:`goal-${t}`)})})]})}var nm=n("fj"),nh=n("qw");function nf(e){let{tool:t}=e,n=t.details??{},s=n.xdev??{},a=s.inner??{},l=s.args??{},o=t.output??"",c=!1===a.applied||o.toLowerCase().includes("staged as a proposal")||o.toLowerCase().includes("files not modified yet"),d=Array.isArray(l.ops)?l.ops:[],u=Array.isArray(l.paths)?l.paths:a.scopePath?[a.scopePath]:[],p=a.displayContent||(o.includes("-")&&o.includes("+")?o:""),m=p?p.split(/\r?\n/).filter(e=>!e.startsWith("Staged as a proposal")&&!!e.trim()):[],h=Array.isArray(n.changes)?n.changes:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.changes))return t.changes;if(Array.isArray(t.edits))return t.edits}}catch{}return[]}(o),f=(0,e8.w)(),x=(0,e3.sQ)(u[0]),g=(0,i.Kr)(()=>{let e=m.map(e=>e.startsWith("+")||e.startsWith("-")||e.startsWith(" ")?e.slice(1):e);return(0,e3.O9)(e.join("\n"),x)},[m,x,f]);if(c||d.length>0||m.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(nm.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:"AST Edit"}),u.length>0&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/50 truncate max-w-[200px]",children:u[0]})]}),(0,r.FD)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-mono text-[9px] font-semibold ${c?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:[c?(0,r.Y)(tz.A,{size:10}):(0,r.Y)(e9.A,{size:10}),c?"STAGED PROPOSAL":"APPLIED"]})]}),d.length>0&&(0,r.FD)("div",{className:"border-b border-ink/6 p-2.5 bg-canvas/20",children:[(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40",children:"Pattern Transformation"}),(0,r.Y)("div",{className:"mt-1 space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded border border-ink/6 bg-paper px-2 py-1 font-mono text-[10.5px]",children:[(0,r.Y)("span",{className:"text-error/90 line-through truncate",children:e.pat}),(0,r.Y)(nh.A,{size:10,className:"shrink-0 text-ink/35"}),(0,r.Y)("span",{className:"text-success/90 font-medium truncate",children:e.out||"/* removed */"})]},t))})]}),m.length>0&&(0,r.Y)("div",{className:"p-2.5 font-mono text-[10.5px] leading-relaxed bg-canvas/30 space-y-0.5",children:m.map((e,t)=>{let n=e.startsWith("-"),i=e.startsWith("+"),s=g[t]||"";return(0,r.FD)("div",{className:`rounded px-1.5 py-0.5 ${n?"bg-error/10 text-error font-medium":i?"bg-success/10 text-success font-medium":"text-ink/70"}`,children:[(n||i)&&e[0],s?(0,r.Y)("span",{className:"shiki",dangerouslySetInnerHTML:{__html:s}}):n||i?e.slice(1):e]},t)})}),c&&(0,r.FD)("div",{className:"border-t border-ink/6 bg-paper px-3 py-1.5 text-[10px] text-ink/50",children:["Proposal staged in memory. Apply with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://resolve"})," or discard with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://reject"}),"."]})]})});if(h.length>0)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"AST Changes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:h.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:h.map((e,t)=>{let n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="string"==typeof e.message?e.message:"",s="string"==typeof e.nodeKind?e.nodeKind:"",a="number"==typeof e.changes?e.changes:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(nm.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[n&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[n,": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),s&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",s,")"]})]}),void 0!==a&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[a," changes"]})]},t)})})]});let b=o.split(/\r?\n/).filter(Boolean);return 0===b.length?null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40 select-text",children:b.map((e,t)=>(0,r.Y)("li",{className:"px-2.5 py-1.5 font-mono text-[11px] break-words text-ink/75",children:e},t))})}function nx(e){let{tool:t}=e,n=(t.details??{}).xdev??{},i=n.inner??{},s="object"==typeof t.input&&null!==t.input?t.input:void 0,a="reject"===t.name||t.target?.includes("reject")||"reject"===n.tool||"reject"===i.action||"discard"===i.action,l=i.reason||n.args?.reason||("string"==typeof s?.content?s.content:"")||("string"==typeof t.input?t.input:""),o=i.sourceToolName||"ast_edit",c=i.label||t.output||(a?"Proposal discarded":"Proposal applied"),d=Array.isArray(i.sourceResultDetails?.files)?i.sourceResultDetails.files:[],u=i.sourceResultDetails?.totalReplacements??i.totalReplacements;return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2 border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[a?(0,r.Y)(e7.A,{size:14,className:"text-warning shrink-0"}):(0,r.Y)(e9.A,{size:14,className:"text-success shrink-0"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:a?"Proposal Discarded":"Proposal Applied"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:o})]}),(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-semibold ${a?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:a?"REJECTED":"RESOLVED"})]}),l&&(0,r.FD)("div",{className:"pt-2.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Reason"}),(0,r.FD)("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink/85 italic",children:["“",l,"”"]})]}),c&&(0,r.Y)("div",{className:"mt-2 text-[11.5px] font-medium text-ink/80",children:c}),d.length>0&&(0,r.FD)("div",{className:"mt-2.5 space-y-1 border-t border-ink/6 pt-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.FD)("span",{children:["Touched Files (",d.length,")"]}),"number"==typeof u&&(0,r.FD)("span",{children:[u," replacement",1===u?"":"s"]})]}),(0,r.Y)("div",{className:"space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10.5px] text-ink/70",children:[(0,r.Y)(eE.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate",children:e})]},t))})]})]})})}var ng=n("xn"),nb=n("JH");let nv={enabled:"bg-success/10 text-success",installed:"bg-ink/8 text-ink/60",disabled:"bg-ink/5 text-ink/45",removed:"bg-error/10 text-error"};function nk(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.skills)?n.skills:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.skills))return t.skills;if(Array.isArray(t.items))return t.items}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(tk,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Skills"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.name?e.name:"string"==typeof e.slug?e.slug:"";if(!i)return null;let s="enabled"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"installed"===n?n:"removed"===n||"uninstalled"===n||"deleted"===n?"removed":"disabled",a="string"==typeof e.scope?e.scope:void 0,l="string"==typeof e.version?e.version:void 0,o="string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["removed"===s?(0,r.Y)(ng.A,{size:11,className:"shrink-0 text-error"}):(0,r.Y)(nb.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/70",children:i}),a&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:a}),l&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:["v",l]}),o&&(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/65",children:o}),(0,r.Y)("span",{className:`ml-auto shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${nv[s]}`,children:s})]},t)})})]})}function ny(e){return"string"==typeof e.path?e.path:"string"==typeof e.name?e.name:""}function nw(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=Array.isArray(a.results)?a.results:[],o=(0,i.Kr)(()=>{if(l.length>0)return l;if(t.output)try{let e=JSON.parse(t.output);if(Array.isArray(e))return e;if(e&&"object"==typeof e){if(Array.isArray(e.results))return e.results;if(Array.isArray(e.items))return e.items;if(Array.isArray(e.files))return e.files}}catch{}return(t.output??"").split(/\r?\n/).filter(Boolean).map(e=>{let t=e.endsWith("/");return{path:e,type:t?"dir":"file"}})},[l,t.output]),c=(0,i.Kr)(()=>{if(!n)return o;let e=n.toLowerCase();return o.filter(t=>ny(t).toLowerCase().includes(e))},[o,n]);return 0===o.length?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tK.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No filesystem matches found"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tK.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Filesystem Search"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[9.5px] text-ink/50",children:[o.length," ",1===o.length?"entry":"entries"]})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[o.length>5&&(0,r.Y)("input",{type:"text",placeholder:"Filter...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-24 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink focus:outline-none"}),(0,r.Y)(e$,{text:o.map(e=>ny(e)).join("\n"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),(0,r.Y)("div",{className:"max-h-64 divide-y divide-ink/6 overflow-y-auto rounded-lg border border-ink/8 bg-paper",children:c.map((e,t)=>{let n,i=ny(e);if(!i)return null;let s="file"===(n="string"==typeof e.type?e.type.toLowerCase():"")||"directory"===n||"dir"===n?"directory"===n||"dir"===n?"dir":"file":"unknown",a="number"==typeof e.size&&e.size>0?(0,ti.z3)(e.size):"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px] transition-colors hover:bg-ink/[0.02]",children:["dir"===s?(0,r.Y)(N.A,{size:12,className:"shrink-0 text-ink/50"}):(0,r.Y)(ex.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-ink/80",children:i}),"unknown"!==s&&(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider ${"dir"===s?"bg-ink/8 text-ink/60":"bg-ink/5 text-ink/45"}`,children:s}),a&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:a})]},t)})})]})}function nN(e,t){let n=e[t];return n&&n.length>0?n[n.length-1]:null}function nY(e){return`ompchamber.ask-draft:${e}`}var nD=n("DTR");let nF=/ \(recommended\)$/i,nA=/\bdone\b/i;function nC(e){let{frame:t,multi:n,selected:s,onAnswer:a,onToggle:l,onRespond:o}=e,[d,u]=(0,i.J0)("");if((0,i.vJ)(()=>{u("editor"===t.method?t.prefill??"":"")},[t.id,t.method,t.prefill]),"confirm"===t.method)return(0,r.FD)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.FD)("button",{type:"button",onClick:()=>o({confirmed:!0}),className:"flex cursor-pointer items-center gap-1.5 rounded-md bg-ink px-3 py-1 text-[11.5px] font-semibold text-paper transition-opacity hover:opacity-90",children:[(0,r.Y)(D.A,{size:11}),(0,r.Y)("span",{children:"Confirm"})]}),(0,r.Y)("button",{type:"button",onClick:()=>o({confirmed:!1}),className:"cursor-pointer rounded-md border border-ink/15 px-3 py-1 text-[11.5px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:text-ink",children:"Decline"})]});if("input"===t.method||"editor"===t.method)return(0,r.FD)("div",{className:"mt-2 space-y-1.5",children:[t.title&&(0,r.Y)("div",{className:"text-[10.5px] text-ink/45",children:t.title}),"editor"===t.method?(0,r.Y)("textarea",{autoFocus:!0,value:d,onChange:e=>u(e.currentTarget.value),rows:4,placeholder:t.placeholder||"Type your answer…",className:"w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 font-mono text-[11.5px] leading-relaxed text-ink outline-none focus:border-ink"}):(0,r.Y)("input",{autoFocus:!0,value:d,placeholder:t.placeholder||"Type your answer…",onChange:e=>u(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),o({value:d}))},className:"w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 text-[11.5px] text-ink outline-none focus:border-ink"}),(0,r.FD)("button",{type:"button",onClick:()=>o({value:d}),className:"flex cursor-pointer items-center gap-1.5 rounded-md bg-ink px-3 py-1 text-[11.5px] font-semibold text-paper transition-opacity hover:opacity-90",children:[(0,r.Y)("span",{children:"Submit"}),(0,r.Y)(nD.A,{size:11,className:"opacity-70"})]})]});let p=t.options??[],m=t.optionDetails??[];return"select"!==t.method||0===p.length?null:(0,r.FD)("div",{className:"mt-2 space-y-1",role:n?"group":"radiogroup",children:[p.map((e,t)=>{if(!n&&c.test(e.trim()))return null;let i=m[t]?.description,d=n&&s.includes(e),u=n&&nA.test(e);return(0,r.FD)("button",{type:"button",onClick:()=>n?u?o({value:e}):l(e):a(e),className:`flex w-full cursor-pointer items-start gap-2 rounded-md border px-2.5 py-1.5 text-left text-[11.5px] transition-colors ${d?"border-ink/30 bg-ink/5 text-ink":u?"border-ink/20 bg-canvas/60 font-medium text-ink hover:border-ink/40":"border-ink/8 bg-canvas/30 text-ink/80 hover:border-ink/25 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)("span",{className:`mt-1 h-3 w-3 shrink-0 ${n?"rounded-[3px]":"rounded-full"} border ${d?"border-ink bg-ink":"border-ink/30"}`}),(0,r.FD)("span",{className:"min-w-0 flex-1",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 font-medium",children:[(0,r.Y)("span",{className:"truncate",children:e}),nF.test(e)&&!n&&(0,r.Y)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] uppercase tracking-wider text-ink/45",children:"Suggested"})]}),i&&(0,r.Y)("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-ink/50",children:i})]})]},e)}),!n&&(0,r.Y)("input",{value:d,placeholder:"Other — type your own answer…",onChange:e=>u(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&d.trim()&&(e.preventDefault(),a(d.trim()))},className:"w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 text-[11.5px] text-ink outline-none focus:border-ink"})]})}function nS(e){let t,{index:n,total:i,question:s,frames:a,recorded:l,draft:o,passed:c,multiSelected:d,onAnswer:u,onToggle:p,onRespond:m}=e,h=a.length>0?a[a.length-1]:null,f=l?(t=[...l.selectedOptions],l.customInput&&t.push(l.customInput),t):o?[o]:d,x=!!h&&!l&&(s.multi||!o);return(0,r.Y)("div",{className:"rounded-lg border border-ink/10 bg-paper p-2.5 shadow-xs",children:(0,r.FD)("div",{className:"flex items-start gap-2",children:[(0,r.Y)("span",{className:"mt-px flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] font-semibold text-ink/60",children:n+1}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40",children:s.header??`Question ${n+1}`}),s.multi&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[8.5px] text-ink/45",children:"multi"}),i>1&&(0,r.FD)("span",{className:"ml-auto font-mono text-[9px] text-ink/35",children:[n+1,"/",i]})]}),(0,r.Y)("div",{className:"mt-1 text-[12.5px] leading-relaxed text-ink/90 select-text",children:(0,r.Y)(eS.T,{content:s.question})}),x&&h&&(0,r.Y)(nC,{frame:h,multi:s.multi,selected:d,onAnswer:u,onToggle:p,onRespond:m}),f.length>0&&(0,r.FD)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-success"}),f.map(e=>(0,r.Y)("span",{className:"rounded-md border border-ink/12 bg-canvas/40 px-2 py-0.5 text-[11.5px] font-medium text-ink select-text",children:e},e)),l?.timedOut&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:"auto-selected on timeout"})]}),!x&&0===f.length&&c&&(0,r.FD)("div",{className:"mt-2 flex items-center gap-1.5 text-[10.5px] text-ink/45",children:[(0,r.Y)(e9.A,{size:11,className:"shrink-0 text-ink/35"}),(0,r.Y)("span",{children:"Answered earlier in this run."})]}),!x&&0===f.length&&!c&&(0,r.FD)("div",{className:"mt-2 space-y-1 border-t border-ink/6 pt-2",children:[s.options.map((e,t)=>(0,r.FD)("div",{className:"flex items-start gap-2 px-0.5 text-[11.5px] text-ink/45",children:[(0,r.Y)("span",{className:"mt-1 h-3 w-3 shrink-0 rounded-full border border-ink/20"}),(0,r.FD)("span",{className:"min-w-0 flex-1",children:[(0,r.FD)("span",{className:"block truncate",children:[e.label,s.recommended===t&&(0,r.Y)("span",{className:"ml-1.5 font-mono text-[9px] uppercase tracking-wider text-ink/35",children:"suggested"})]}),e.description&&(0,r.Y)("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-ink/35",children:e.description})]})]},e.label)),(0,r.FD)("div",{className:"flex items-center gap-1.5 pt-0.5 text-[10.5px] text-ink/40",children:[(0,r.Y)(tz.A,{size:10,className:"shrink-0"}),(0,r.Y)("span",{children:"Waiting for the previous answer…"})]})]})]})]})})}let nT=[],nz=[],n$=[];function nj(e){let{tool:t}=e,n=h(t),s=function(e,t){let n=t.map(()=>null);if(0===t.length)return n;let r=e.details??{},i=Array.isArray(r.results)?r.results:null;if(i){for(let e=0;e<n.length;e+=1){let t=i[e];t&&"object"==typeof t&&(n[e]=f(t))}return n}return void 0!==r.selectedOptions||"string"==typeof r.customInput?(n[0]=f(r),n):"error"===e.status||"aborted"===e.status||e.isError?n:function(e,t){let n=t.map(()=>null),r=e.trim();if(!r)return n;let i=new Map;for(let e of r.split("\n")){let n=x.exec(e.trim());n&&i.set(n[1],v(n[2],t.some(e=>e.multi)))}if(i.size>0){let e=[...i.values()];for(let r=0;r<t.length;r+=1){let s=t[r].id;n[r]=(s?i.get(s):void 0)??e[r]??null}return n}let s=g.exec(r);if(s)return n[0]=v(s[1],t[0].multi),n;let a=b.exec(r);return a?n[0]={selectedOptions:[],customInput:a[1].trim()}:1!==t.length||r.includes("\n")||(n[0]={selectedOptions:[r]}),n}("string"==typeof e.output?e.output:"",t)}(t,n),{framesByTool:l,respond:o}=(0,a.NT)(y),c=l.get(t.id)??nz,{drafts:d,multiSelected:u,commit:p,toggleMulti:m}=function(e){let{toolId:t,questions:n,groups:r,recorded:s,respond:a}=e,[l,o]=(0,i.J0)(()=>(function(e){try{let t=sessionStorage.getItem(nY(e));return t?JSON.parse(t):{}}catch{return{}}})(t)),[c,d]=(0,i.J0)({}),u=(0,i.li)(new Set);return(0,i.vJ)(()=>{for(let e=0;e<n.length;e+=1){if(s[e]||n[e].multi)continue;let t=l[e];if(!t)continue;let i=nN(r,e);!i||"select"!==i.method||u.current.has(i.id)||(u.current.add(i.id),a(i,{value:t}))}},[n,r,l,s,a]),(0,i.vJ)(()=>{try{sessionStorage.setItem(nY(t),JSON.stringify(l))}catch{}},[t,l]),{drafts:l,multiSelected:c,commit:(0,i.hb)((e,t)=>{o(n=>n[e]===t?n:{...n,[e]:t})},[]),toggleMulti:(0,i.hb)((e,t)=>{let n=nN(r,e);!n||u.current.has(n.id)||(u.current.add(n.id),a(n,{value:t}),d(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}}))},[r,a])}}({toolId:t.id,questions:n,groups:c,recorded:s,respond:o});if(0===n.length)return t.output?(0,r.Y)(tk,{text:t.output}):null;let k=c.some((e,t)=>e.length>0&&!s[t]),w=c.findIndex(e=>e.length>0);return(0,r.FD)("div",{className:"space-y-2",children:[k&&(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[10.5px] text-ink/50",children:[(0,r.Y)(e_.A,{size:11,className:"shrink-0"}),(0,r.Y)("span",{children:"Input needed — the agent is blocked until you answer."})]}),n.map((e,t)=>(0,r.Y)(nS,{index:t,total:n.length,question:e,frames:c[t]??nT,recorded:s[t]??null,draft:d[t],passed:-1!==w&&t<w,multiSelected:u[t]??n$,onAnswer:e=>p(t,e),onToggle:e=>m(t,e),onRespond:e=>{let n=nN(c,t);n&&o(n,e)}},e.id??t)),("error"===t.status||"aborted"===t.status)&&t.output&&(0,r.FD)("div",{className:"flex items-start gap-2 rounded-md border border-ink/8 bg-ink/[0.02] px-2.5 py-1.5 text-[10.5px] text-ink/60",children:[(0,r.Y)(e7.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"font-mono select-text",children:t.output})]})]})}function nL(e){let{tool:t}=e,n=t.input,i="object"==typeof n&&null!==n?n:void 0,s="string"==typeof i?.thought?i.thought:"string"==typeof i?.reasoning?i.reasoning:"string"==typeof i?.notes?i.notes:"string"==typeof n?n:t.output||t.detail||"";return s?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(eC.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Internal Reasoning"})]}),(0,r.Y)(e$,{text:s,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),(0,r.Y)("div",{className:"max-h-64 overflow-y-auto p-3 text-[11.5px] leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eS.T,{content:s})})]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 p-3 font-mono text-[11px] text-ink/40",children:"No thought details recorded."})}var nM=n("Y");function nP(e){let{tool:t,targetFilePath:n,output:s}=e,[a,l]=(0,i.J0)(null),[o,c]=(0,i.J0)(!1),d=tN(t?.input),u=n||d||t?.target||"",p=u.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");(0,i.vJ)(()=>{!p||s||null!==a||o||(c(!0),fetch(`/api/fs/read?path=${encodeURIComponent(p)}`).then(e=>e.json()).then(e=>{l(e&&void 0!==e.content?e.content:`// Loaded file: ${p}`)}).catch(()=>{l(`// Loaded file: ${p}`)}).finally(()=>{c(!1)}))},[p,s,a,o]);let m=t?.details??{},h=s||("object"==typeof m?.displayContent&&"string"==typeof m.displayContent?.text?m.displayContent.text:"")||a||"",f=(0,i.Kr)(()=>(function(e){let t,n=e.split(/\r?\n/).filter(Boolean);if(0===n.length)return{isDirectory:!1,entries:[]};let r=n[0].trim(),i=n.some(e=>e.trimStart().startsWith("- ")||e.trimStart().startsWith("├──")||e.trimStart().startsWith("└──"));if("."!==r&&!i)return{isDirectory:!1,entries:[]};let s=[];for(let e of n){if(e.startsWith("[")&&e.endsWith("]")){t=e.slice(1,-1);continue}if("."===e.trim()){s.push({indent:0,isDir:!0,name:"."});continue}let n=e.match(/^(\s*)-\s+([^\s]+)\s*(.*)$/);if(n){let e,t,r=Math.floor(n[1].length/2),i=n[2],a=n[3].trim(),l=i.endsWith("/"),o=l?i.slice(0,-1):i,c=a.split(/\s{2,}|\t+/).filter(Boolean);2===c.length?(e=c[0],t=c[1]):1===c.length&&(c[0].endsWith("ago")?t=c[0]:e=c[0]),s.push({indent:r,isDir:l,name:o,size:e,time:t})}}return{isDirectory:s.length>0,entries:s,notice:t}})(h),[h]),x=(0,i.Kr)(()=>(function(e,t,n){let r=e?.details??{},i=e?.input&&"object"==typeof e.input?e.input:{},s=r.displayContent;if(s&&Array.isArray(s.lineNumbers)&&s.lineNumbers.length>0)return{startLine:"number"==typeof s.startLine?s.startLine:void 0,lineNumbers:s.lineNumbers};if(Array.isArray(r.lineNumbers)&&r.lineNumbers.length>0)return{startLine:"number"==typeof r.startLine?r.startLine:void 0,lineNumbers:r.lineNumbers};if("number"==typeof s?.startLine&&s.startLine>0)return{startLine:s.startLine};if("number"==typeof r.startLine&&r.startLine>0)return{startLine:r.startLine};if("number"==typeof r.start_line&&r.start_line>0)return{startLine:r.start_line};if("number"==typeof r.offset&&r.offset>0)return{startLine:r.offset};let a=r.meta?.truncation?.shownRange?.start??r.truncation?.shownRange?.start??r.meta?.shownRange?.start??r.shownRange?.start;if("number"==typeof a&&a>0)return{startLine:a};let l=i.start_line??i.startLine??i.offset??i.StartLine??i.from;if("number"==typeof l&&l>0)return{startLine:l};if("string"==typeof l&&/^\d+$/.test(l.trim())){let e=parseInt(l.trim(),10);if(e>0)return{startLine:e}}for(let n of["string"==typeof i.path?i.path:"",e?.target||"",e?.title||"",t||""]){let e=n.match(/:(\d+)(?:-\d+)?(?:\s|$)/);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}if(n){let e=n.match(/\[(?:Showing\s+)?lines?\s+(\d+)(?:-\d+)?/i);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}return{}})(t,u,h),[t,u,h]),{displayContent:g,elisionNotices:b}=(0,i.Kr)(()=>{if(f.isDirectory)return{displayContent:h,elisionNotices:[]};let e=h.split(/\r?\n/),t=[],n=[];for(let r of e){let e=r.trim();(e.startsWith("[…")||e.startsWith("[Showing lines ")||e.startsWith("[1 results limit"))&&e.endsWith("]")?t.push(e.slice(1,-1)):n.push(r)}return 0===t.length&&m.summary&&"number"==typeof m.summary.elidedLines&&m.summary.elidedLines>0&&t.push(`…${m.summary.elidedLines}ln elided (${m.summary.lines??n.length} lines shown)`),x.lineNumbers&&n.length>x.lineNumbers.length&&""===n[n.length-1].trim()&&n.pop(),{displayContent:n.join("\n"),elisionNotices:t}},[h,f.isDirectory,x.lineNumbers,m.summary]),v=(0,i.Kr)(()=>f.isDirectory||!g?{lines:[],cleanCode:"",hasLineNumbers:!1}:function(e,t){let n=e.replace(/\r?\n$/,"").split(/\r?\n/);if(0===n.length)return{lines:[],cleanCode:"",hasLineNumbers:!1};let r=[],i=0,s=0;for(let e of n){if(!e.trim()){r.push(null);continue}let t=e.match(/^(\s*(\d+):)/);if(t){let n=parseInt(t[2],10);r.push({lineNum:n,rawLine:e}),i++;continue}let n=e.match(/^(\s*(\d+)\s*[|│][ \t]?)/);if(n){let t=parseInt(n[2],10);r.push({lineNum:t,rawLine:e,pipePrefixLen:n[1].length}),s++;continue}r.push(null)}let a=n.filter(e=>e.trim().length>0),l=s>=2&&s>=.7*a.length,o=!l&&i>=2&&i>=.7*a.length&&(()=>{let e=r.filter(e=>null!==e).map(e=>e.lineNum);for(let t=1;t<e.length;t++)if(e[t]<e[t-1])return!1;return!0})();if(!l&&!o){let e=t?.lineNumbers,r="number"==typeof t?.startLine&&!isNaN(t.startLine)&&t.startLine>0?t.startLine:1;return{lines:n.map((t,n)=>{let i;if(e&&n<e.length){let t=e[n];i=null==t||""===t?"…":t}else i=r+n;return{lineNum:i,code:t}}),cleanCode:n.join("\n"),hasLineNumbers:!!(e&&e.length>0||r>1)}}if(l){let e=r.find(e=>null!==e)?.lineNum??1,t=[];for(let i=0;i<n.length;i++){let s=n[i],a=r[i];s.trim()?a&&void 0!==a.pipePrefixLen?(t.push({lineNum:a.lineNum,code:s.slice(a.pipePrefixLen)}),e=a.lineNum+1):(t.push({lineNum:e,code:s}),e++):(t.push({lineNum:e,code:""}),e++)}return{lines:t,cleanCode:t.map(e=>e.code).join("\n"),hasLineNumbers:!0}}let c=r.filter(e=>null!==e),d=String(Math.max(...c.map(e=>e.lineNum))).length+1,u=c.filter(e=>e.rawLine.length>d);u.length>0&&u.every(e=>" "===e.rawLine[d]||" "===e.rawLine[d])&&d++;let p=c[0]?.lineNum??1,m=[];for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(!t.trim()){m.push({lineNum:p,code:""}),p++;continue}if(i){p=i.lineNum;let e=t.length<=d?"":t.slice(d);m.push({lineNum:i.lineNum,code:e}),p=i.lineNum+1}else m.push({lineNum:p,code:t}),p++}return{lines:m,cleanCode:m.map(e=>e.code).join("\n"),hasLineNumbers:!0}}(g,x),[g,f.isDirectory,x]),k=f.isDirectory,y=(0,e3.sQ)(u),w=f.entries.slice(-1e3),Y=f.entries.length-w.length,D=(0,i.Kr)(()=>tv(v.cleanCode,1e3),[v.cleanCode]),F=D.skipped>0?v.lines.slice(D.skipped):v.lines,A=(0,e8.w)(),C=(0,i.Kr)(()=>D.text?(0,e3.wY)(D.text,y):"",[D,y,A]);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:k?(0,r.Y)(nM.A,{size:12}):(0,r.Y)(eP.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:u||(k?"Directory Listing":"File Content")}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:k?"Directory":y})]}),h&&(0,r.Y)(e$,{text:v.hasLineNumbers?v.cleanCode:h||"",className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),o?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-3 font-mono text-[11px] text-ink/50",children:[(0,r.Y)(e2.A,{size:12,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading file content..."})]}):k?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[Y>0&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(eA.A,{size:11,className:"shrink-0"}),(0,r.FD)("span",{children:["… ",Y," earlier entries hidden"]})]}),(0,r.Y)("div",{className:"max-h-72 divide-y divide-ink/[0.04] overflow-y-auto font-mono text-[11px]",children:w.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-ink/[0.02]",style:{paddingLeft:`${Math.max(12,(e.indent+1)*16)}px`},children:[e.isDir?(0,r.Y)(N.A,{size:12,className:"shrink-0 text-ink/60"}):(0,r.Y)(eE.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{className:`min-w-0 flex-1 truncate ${e.isDir?"font-semibold text-ink":"text-ink/80"}`,children:[e.name,e.isDir&&"/"]}),e.size&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[9.5px] text-ink/40",children:e.size}),e.time&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 font-mono text-[9px] text-ink/45",children:e.time})]},t))}),f.notice&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-t border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(eA.A,{size:11,className:"shrink-0"}),(0,r.Y)("span",{children:f.notice})]})]}):h?(0,r.FD)("div",{className:"space-y-1.5",children:[D.skipped>0&&(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(eA.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{children:["… ",D.skipped," earlier lines hidden"]})]}),(0,r.FD)("div",{className:"relative flex max-h-80 items-start overflow-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.Y)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/90 py-2.5 pl-3 pr-2.5 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/35 backdrop-blur-xs","aria-hidden":"true",children:F.map((e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:e.lineNum},t))}),(0,r.Y)("pre",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 font-mono text-[11px] leading-[20px] whitespace-pre text-ink/85 focus:outline-none",dangerouslySetInnerHTML:{__html:C}})]}),b.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(eA.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{children:e})]},t))]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 px-3 py-3 font-mono text-[11px] text-ink/45",children:"File is ready for inspection."})]})}var nE=n("fQ"),nR=n("BE");function nI(e){let{sections:t}=e,n=(0,e8.w)(),s=(0,i.Kr)(()=>t.map(e=>{let t=(0,e3.sQ)(e.path);return e.ops.map(e=>(0,e3.O9)(e.body.join("\n"),t))}),[t,n]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)("span",{children:"Hashline Patch"}),t[0].tag&&(0,r.FD)("span",{className:"font-mono text-[9px] font-normal tracking-normal text-ink/50",children:["snapshot ",t[0].tag]})]}),(0,r.Y)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:t.map((e,t)=>(0,r.FD)("div",{className:"border-b border-ink/6 last:border-b-0",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-medium text-ink",children:e.path}),e.moveTo&&(0,r.FD)("span",{className:"shrink-0 font-mono text-[10px] text-ink/50",children:["→ ",e.moveTo]}),e.removed&&(0,r.Y)("span",{className:"shrink-0 rounded bg-error/10 px-1.5 font-mono text-[9px] uppercase tracking-wider text-error",children:"Removes file"})]}),(0,r.Y)("div",{className:"overflow-x-auto",children:e.ops.map((e,n)=>(0,r.FD)("div",{children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1",children:[(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 font-mono text-[9px] font-semibold ${"CUT"===e.verb?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.verb}),e.spec&&(0,r.Y)("span",{className:"font-mono text-[10.5px] text-ink/70",children:e.spec})]}),e.body.map((e,i)=>{let a=s[t]?.[n]?.[i]||"";return a?(0,r.Y)("div",{className:"shiki whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed",dangerouslySetInnerHTML:{__html:a}},i):(0,r.Y)("div",{className:"whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed text-success/90",children:e},i)})]},`${e.verb}-${e.spec}-${n}`))})]},e.path))})]})}var nO=n("e");function nJ(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"diff",r=e?e.split(/\r?\n/):[],i=t?t.split(/\r?\n/):[],s=0;for(;s<r.length&&s<i.length&&r[s]===i[s];)s++;let a=0;for(;a<r.length-s&&a<i.length-s&&r[r.length-1-a]===i[i.length-1-a];)a++;let l=r.slice(Math.max(0,s-2),s),o=r.slice(s,r.length-a),c=i.slice(s,i.length-a),d=r.slice(r.length-a,r.length-a+2),u=n||"diff",p=[`--- a/${u}`,`+++ b/${u}`,`@@ -1,${r.length||1} +1,${i.length||1} @@`];for(let e of l)p.push(` ${e}`);for(let e of o)p.push(`-${e}`);for(let e of c)p.push(`+${e}`);for(let e of d)p.push(` ${e}`);return p.join("\n")}function n_(e){let{tool:t}=e,n="write"===t.type||"write"===t.name||"create_file"===t.type,s=t.input,a="object"==typeof s&&null!==s?s:void 0,l=(0,i.Kr)(()=>(0,nO.I)(a),[a]),o=t.target||l?.sections[0].path||a?.path||a?.TargetFile||a?.targetFile||a?.FilePath||a?.filePath||a?.AbsolutePath||a?.absolutePath||("string"==typeof t.details?.path?t.details.path:void 0)||("string"==typeof s&&(s.includes("/")||s.includes("."))?s:void 0)||"",c="string"==typeof a?.content?a.content:"string"==typeof a?.Content?a.Content:void 0,d="string"==typeof a?.old_string?a.old_string:"string"==typeof a?.oldString?a.oldString:"string"==typeof a?.TargetContent?a.TargetContent:"string"==typeof a?.targetContent?a.targetContent:void 0,u="string"==typeof a?.new_string?a.new_string:"string"==typeof a?.newString?a.newString:"string"==typeof a?.ReplacementContent?a.ReplacementContent:"string"==typeof a?.replacementContent?a.replacementContent:void 0,p=Array.isArray(a?.ReplacementChunks)?a.ReplacementChunks:void 0,m=t.diff?.diffText||("string"==typeof t.details?.diff?t.details.diff:void 0)||("string"==typeof t.details?.patch?t.details.patch:void 0),h=(0,i.Kr)(()=>m||(p&&p.length>0?p.map(e=>nJ(e.TargetContent||"",e.ReplacementContent||"",o)).join("\n"):d||u?nJ(d||"",u||"",o):void 0),[m,p,d,u,o]),f=t.output||"",x=(0,e3.sQ)(o),g=(0,i.Kr)(()=>d?tv(d,1e3):null,[d]),b=(0,i.Kr)(()=>u?tv(u,1e3):null,[u]),v=(0,e8.w)(),k=(0,i.Kr)(()=>g?(0,e3.wY)(g.text,x):"",[g,x,v]),y=(0,i.Kr)(()=>b?(0,e3.wY)(b.text,x):"",[b,x,v]),w=(0,i.Kr)(()=>c?c.split("\n").length:0,[c]),N=(0,i.Kr)(()=>c?(0,e3.wY)(c.split("\n").slice(0,80).join("\n"),x):"",[c,x,v]),Y=(0,i.Kr)(()=>tg(f),[f]),D=(0,i.Kr)(()=>tv(Y.content,1e3),[Y]),F=(0,i.Kr)(()=>tb(D.text,Y.format),[D,Y.format]);return(0,r.FD)("div",{className:"space-y-2.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:n?(0,r.Y)(nE.A,{size:12}):(0,r.Y)(nR.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:o||"File modification"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?"Write":"Edit"})]}),(c||u||l)&&(0,r.Y)(e$,{text:l?.text||c||u||f,className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),h&&(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diff Changes"}),(0,r.Y)(e6,{text:h})]}),!h&&l&&(0,r.Y)(nI,{sections:l.sections}),!h&&(d||u)&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Replacement Changes"}),(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[d&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-error/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-error",children:(0,r.Y)("span",{children:"- Original Content"})}),g&&g.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-40 overflow-x-auto font-mono text-[11px] leading-relaxed text-error/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:k}})]}),u&&(0,r.FD)("div",{className:"bg-success/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-success",children:(0,r.Y)("span",{children:"+ Replaced With"})}),b&&b.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-48 overflow-x-auto font-mono text-[11px] leading-relaxed text-success/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:y}})]})]})]}),!h&&!d&&!u&&c&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.FD)("span",{className:"flex items-center gap-1",children:[(0,r.Y)(eP.A,{size:11}),(0,r.Y)("span",{children:"Written File Preview"})]}),(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/50",children:[w," lines · ",(0,ti.z3)(c.length)]})]}),(0,r.FD)("div",{className:"flex max-h-64 items-start overflow-x-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.FD)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/60 py-2.5 pl-2.5 pr-2 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/25","aria-hidden":"true",children:[Array.from({length:Math.min(w,80)},(e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:t+1},t)),w>80&&(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:"…"})]}),(0,r.Y)("div",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 leading-[20px] whitespace-pre text-ink/85",dangerouslySetInnerHTML:{__html:N}})]})]}),f&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 mb-1.5 text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.Y)(nh.A,{size:11,className:"text-success"}),(0,r.Y)("span",{children:"Execution Output"})]}),Y.envelope&&(0,r.Y)(tf,{envelope:Y.envelope}),D.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",D.skipped," earlier lines hidden"]}),(0,r.Y)(eS.T,{content:F,className:"text-[11.5px] text-ink/85"})]})]})}function nW(e){let{value:t}=e;return Array.isArray(t)?(0,r.Y)(nK,{items:t}):(0,nd.u)(t)?(0,r.Y)(nU,{data:t}):"string"==typeof t?t.length>120||t.includes("\n")?(0,r.Y)("div",{className:"prose-content max-h-60 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eS.T,{content:t})}):(0,r.Y)("span",{className:"break-words text-[12px] leading-relaxed text-ink/85",children:t}):(0,r.Y)("span",{className:"font-mono text-[12px] text-ink/85",children:JSON.stringify(t)??""})}function nK(e){let{items:t}=e,n=t.slice(0,50);return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("ol",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map((e,t)=>(0,r.FD)("li",{className:"flex items-start gap-2 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("div",{className:"min-w-0 flex-1",children:(0,r.Y)(nW,{value:e})})]},t))}),t.length>n.length&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",t.length-n.length," more items"]})]})}function nU(e){let{data:t}=e,n=Object.entries(t);return 0===n.length?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-canvas/40 px-2.5 py-2 text-[11px] text-ink/45",children:"Empty object"}):(0,r.Y)("div",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map(e=>{let[t,n]=e,i=Array.isArray(n)?`list \xb7 ${n.length}`:(0,nd.u)(n)?"json":"string"==typeof n?"markdown":typeof n;return(0,r.FD)("div",{className:"px-2.5 py-2",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5",children:[(0,r.Y)(tn.A,{size:10.5,className:"shrink-0 text-ink/45"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",title:t,children:t}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:i})]}),(0,r.Y)(nW,{value:n})]},t)})})}function nB(e){let{tool:t}=e,n="object"==typeof t.input&&null!==t.input?t.input:void 0,s="string"==typeof n?.path?n.path:t.target||"",a="string"==typeof t.name?t.name:"",l=(s?s.replace(/^xd:\/\//,""):a).replace(/^mcp__/,""),o="string"==typeof n?.content?n.content:"",c=(0,i.Kr)(()=>o?(0,e3.Bl)(o):{isValid:!1},[o]),d=c.isValid?c.data:void 0,u=(0,nd.u)(d)||Array.isArray(d),p=(0,i.Kr)(()=>t.output?(0,e3.Bl)(t.output):{isValid:!1},[t.output]),m=p.isValid?p.data:void 0,h=(0,nd.u)(m)||Array.isArray(m);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 rounded-lg border border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)(J.A,{size:12,className:"shrink-0 text-ink/60"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",children:l||"MCP Tool"}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:"MCP"})]}),o&&u?(0,r.Y)(nW,{value:d}):o?(0,r.Y)("div",{className:"prose-content max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eS.T,{content:o})}):null,t.output&&h?(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Result"}),(0,r.Y)(nW,{value:m})]}):t.output?(0,r.Y)(tk,{text:t.output}):null]})}function nq(e){if(e.target)return e.target;if(e.diff?.file)return e.diff.file;if(e.input&&"object"==typeof e.input){let t=e.input;if("string"==typeof t.path)return t.path;if("string"==typeof t.TargetFile)return t.TargetFile;if("string"==typeof t.targetFile)return t.targetFile;if("string"==typeof t.FilePath)return t.FilePath;if("string"==typeof t.filePath)return t.filePath;if("string"==typeof t.AbsolutePath)return t.AbsolutePath;if("string"==typeof t.absolutePath)return t.absolutePath;if("string"==typeof t.file)return t.file;let n=(0,nO.f$)(t);if(n)return n}return"string"==typeof e.details?.path?e.details.path:"string"==typeof e.input&&(e.input.includes(".")||e.input.includes("/"))?e.input:e.detail&&(e.detail.includes(".")||e.detail.includes("/"))?e.detail:void 0}function nH(e){let t=e.details;if(t?.xdev?.tool&&"string"==typeof t.xdev.tool)return t.xdev.tool.toLowerCase();let n=(e.target||"").toLowerCase(),r=tN(e.input)?.toLowerCase()??"",i=n.startsWith("xd://")?n.slice(5):r.startsWith("xd://")?r.slice(5):"";if(i){let e=i.split(/[/?#]/)[0].trim();if(e)return e}let s=(e.name||"").toLowerCase(),a=(e.type||"").toLowerCase(),l=(e.title||"").toLowerCase();if(s&&"tool"!==s&&"custom"!==s)return s;let o=l.split(/[\s—\-:]+/)[0]?.trim();return["grep","glob","read","write","edit","bash","terminal","run_command","todo","eval","hub","lsp","github","task","resolve","reject"].includes(o)?o:a}function nG(e){let{tool:t}=e,n=nH(t);if("read"===n||"read_file"===n||"view_file"===n||"read_file_content"===n){let e=nq(t);return(0,r.Y)(nP,{tool:t,targetFilePath:e,output:t.output||""})}return"edit"===n||"write"===n||"edit_file"===n||"create_file"===n||"write_to_file"===n||"replace_file_content"===n||"multi_edit_file"===n?(0,r.Y)(n_,{tool:t}):"task"===n?(0,r.Y)(to,{tool:t}):"todo"===n?(0,r.Y)(ty,{tool:t}):"grep"===n||"glob"===n||"ast_grep"===n?(0,r.Y)(tq,{tool:t}):"search_fs"===n?(0,r.Y)(nw,{tool:t}):"web_search"===n?(0,r.Y)(tT,{tool:t}):"bash"===n||"terminal"===n||"run_command"===n?(0,r.Y)(tW,{tool:t}):"eval"===n?(0,r.Y)(tj,{tool:t}):"lsp"===n?(0,r.Y)(tF,{tool:t}):"ast_edit"===n?(0,r.Y)(nf,{tool:t}):"resolve"===n||"reject"===n?(0,r.Y)(nx,{tool:t}):"hub"===n?(0,r.Y)(t5,{tool:t}):"github"===n?(0,r.Y)(tE,{tool:t}):"checkpoint"===n||"rewind"===n?(0,r.Y)(t_,{tool:t}):"security_scan"===n?(0,r.Y)(tQ,{tool:t}):"debug"===n?(0,r.Y)(na,{tool:t}):"manage_skill"===n?(0,r.Y)(nk,{tool:t}):"context_notes"===n||"new_context"===n?(0,r.Y)(t8,{tool:t}):"memory_edit"===n||"retain"===n||"recall"===n||"reflect"===n||"learn"===n?(0,r.Y)(nt,{tool:t}):"goal"===n||"yield"===n?(0,r.Y)(np,{tool:t}):"ask"===n?(0,r.Y)(nj,{tool:t}):"think"===n?(0,r.Y)(nL,{tool:t}):n.startsWith("mcp__")||"string"==typeof t.name&&t.name.startsWith("mcp__")?(0,r.Y)(nB,{tool:t}):null}function nV(e){let t="object"==typeof e.input&&null!==e.input?e.input:void 0,n="string"==typeof t?.path?t.path:e.target||"",r=(n.startsWith("xd://")?n.slice(5):"string"==typeof e.name&&e.name.startsWith("mcp__")?e.name:"").split(/[/?#]/)[0].trim();return r.startsWith("mcp__")?r.slice(5):void 0}function nZ(e){let t=e.details?.xdev;return t&&"object"==typeof t?t:void 0}function nQ(e){let{children:t}=e;return(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:t})}let nX=(0,a.ph)(function(e){let t,{tool:n,isOpen:s,onToggle:a,defaultExpanded:l=!1}=e,o=nH(n),c=(0,i.Kr)(()=>null!==nG({tool:n}),[n]),d=n.command?n.command:"string"==typeof n.input?n.input:n.input&&"object"==typeof n.input?JSON.stringify(n.input,null,2):(n.target||n.detail)&&(n.target||n.detail)||"",u=n.output||(n.error?`Error: ${n.error}`:""),p=function(e){if(e.diff?.diffText)return e.diff.diffText;let t=e.details;if(t&&"object"==typeof t){if("string"==typeof t.patch)return t.patch;if("string"==typeof t.diff)return t.diff}}(n),m=(0,i.hb)(()=>{a?.(n.id)},[a,n.id]),f=(0,i.Kr)(()=>!c&&d?(0,e3.Bl)(d):null,[c,d]),x=(0,i.Kr)(()=>{let e=e1(eG(u));return!!(e&&eQ(e.tag))},[u]),g="";if("lsp"===o){g="LSP";let e=nZ(n);e?.args?.action&&(t=`${e.args.action}${e.args.file?` \xb7 ${e.args.file}`:""}`)}else if("ast_edit"===o){g="AST Edit";let e=nZ(n);e?.args?.paths?.[0]&&(t=e.args.paths[0])}else if("resolve"===o)g="Resolve Proposal";else if("reject"===o)g="Reject Proposal";else if("yield"===o)g="error"===n.status?"Yield":u?`Yield - ${u}`:"Yield";else if("todo"===o||"todo"===n.name||"todo"===n.type||n.title&&n.title.toLowerCase().startsWith("todo")){g="Todo";let e=function(e){let t=td(e);if(t.totalTasks>0||t.groups.length>0)return t.summaryText}(n);if(e)t=e;else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/).slice(1).join(" — ").trim();t=e.split(/\s*·\s*/).filter(e=>!/^0\s+(complete|in progress|pending)/i.test(e)).join(" · ")||e}}else if("ask"===o){g="Question";let e=h(n).length;e>0&&(t=`Asked ${e} question${1===e?"":"s"}`)}else if(nV(n)){let e="object"==typeof n.input&&null!==n.input?n.input:void 0;g=th(nV(n));let r=function(e,t){if(e.intent)return e.intent;let n="string"==typeof t?.content?t.content:"",r=n?(0,e3.Bl)(n):{isValid:!1,data:void 0},i=r.isValid?r.data:t;if(i&&"object"==typeof i){let e=["query","q","pattern","pat","name","sql","path","symbol","url","command"].find(e=>"string"==typeof i[e]&&i[e]);if(e)return i[e]}}(n,e);r&&(t=r.length>80?`${r.slice(0,79)}…`:r)}else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/);g=th(e[0].trim()),t=e.slice(1).join(" — ").trim()}else g=n.title?th(n.title):th(o||n.name||"Tool Call");if(("task"===o||"task"===n.name)&&!t){let e="object"==typeof n.input&&null!==n.input?n.input:void 0,r=Array.isArray(e?.tasks)?e.tasks[0]:void 0;r?.name&&(t=`${r.name}${r.agent?` \xb7 ${r.agent}`:""}`)}let b=nq(n),v=t&&!t.startsWith("xd://")?t:b&&!b.startsWith("xd://")?b:t||(n.detail&&!b?n.detail:void 0),k=n.duration||n.time,y=k||x?(0,r.FD)("span",{className:"flex items-center gap-2",children:[k?(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/40",children:k}):null,x&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(eq.A,{size:10})," Reminder"]})]}):null;return(0,r.FD)(e4,{tool:n,icon:n.icon||function(e){switch(e){case"bash":case"terminal":return(0,r.Y)(eM.A,{size:14});case"edit":case"write":case"edit_file":case"create_file":case"ast_edit":return(0,r.Y)(eP.A,{size:14});case"read":case"read_file":case"view_file":return(0,r.Y)(eE.A,{size:14});case"glob":case"grep":case"search_fs":case"ast_grep":return(0,r.Y)($.A,{size:14});case"web_search":return(0,r.Y)(W.A,{size:14});case"todo":case"task":return(0,r.Y)(eR.A,{size:14});case"eval":return(0,r.Y)(eI.A,{size:14});case"lsp":return(0,r.Y)(eO.A,{size:14});case"resolve":case"reject":return(0,r.Y)(D.A,{size:14});case"hub":return(0,r.Y)(eJ.A,{size:14});case"ask":return(0,r.Y)(e_.A,{size:14});case"think":return(0,r.Y)(eC.A,{size:14});case"security_scan":return(0,r.Y)(eW.A,{size:14});case"checkpoint":case"rewind":return(0,r.Y)(eK.A,{size:14});case"github":return(0,r.Y)(eU.A,{size:14});case"memory_edit":case"retain":case"recall":case"reflect":case"learn":return(0,r.Y)(K.A,{size:14});default:if(e.startsWith("mcp__"))return(0,r.Y)(J.A,{size:14});return(0,r.Y)(eB.A,{size:14})}}(o),title:g,subtitle:v,meta:y,isOpen:s,onToggle:a?m:void 0,defaultExpanded:l,alwaysExpanded:c&&("yield"===o||"ask"===o),children:[(0,r.Y)(nG,{tool:n}),!c&&d&&(0,r.FD)("div",{className:"space-y-1.5 code-surface",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(nQ,{children:"Input"}),f?.isValid&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/45",children:"JSON"})]}),(0,r.Y)(e$,{text:f?.isValid&&f.pretty?f.pretty:d,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),f?.isValid&&f.pretty?(0,r.Y)(tr,{jsonString:f.pretty,maxHeightClass:"max-h-60",showHeader:!1}):(0,r.Y)("pre",{className:"overflow-x-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-ink/80 select-text",children:d})]}),!c&&p&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)(nQ,{children:"Diff"}),(0,r.Y)(e6,{text:p})]}),!c&&u&&(0,r.Y)(tk,{text:u})]})});function n0(e){let{tools:t,title:n,defaultExpanded:s=!1}=e,a=(0,i.Kr)(()=>(t||[]).map((e,t)=>(function(e,t){if("id"in e&&e.id)return e;let n=e.title||"",r=n.toLowerCase(),i="terminal";r.includes("shell")||r.includes("command")||r.includes("bun")||r.includes("git")?i="bash":r.includes("edit")||r.includes("write")?i="edit_file":r.includes("read")||r.includes("view")||r.includes("cat")||r.includes("inspect")?i="read_file":(r.includes("search")||r.includes("find")||r.includes("grep"))&&(i="search_fs");let s=n.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()||"tool",a="type"in e&&e.type?e.type:i;return{id:`stable-tool-${t}-${s}`,type:a,title:e.title,duration:e.time,time:e.time,detail:e.detail,target:"target"in e&&e.target?e.target:"read_file"===a||"edit_file"===a||"create_file"===a?e.detail:void 0,command:e.command||("bash"===a?e.detail:void 0),output:e.output,status:e.status||"success",icon:e.icon,diff:"diff"in e?e.diff:void 0,input:"input"in e?e.input:void 0}})(e,t)),[t]),[l,o]=(0,i.J0)(()=>{let e={};return a.forEach((t,n)=>{let r=!eL(t)&&("error"===t.status||s&&0===n);e[t.id]=r}),e}),c=(0,i.hb)(e=>{o(t=>({...t,[e]:!t[e]}))},[]);return a&&0!==a.length?(0,r.FD)("div",{className:"mx-3 space-y-1.5",children:[n&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:n}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),a.map(e=>(0,r.Y)(nX,{tool:e,isOpen:!!l[e.id],onToggle:c},e.id))]}):null}var n1=n("oE"),n5=n("bH"),n2=n("Sb");function n4(e){let{task:t}=e;(0,e8.w)();let n=t.structuredOutput,s=!t.formattedJson&&(0,e3.rw)(t.rawOutput),[a,l]=(0,i.J0)(n||!s?"formatted":"raw");return(0,r.FD)("div",{className:"space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(n||!s)&&(0,r.FD)("button",{type:"button",onClick:()=>l("formatted"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"formatted"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(n5.A,{size:12}),(0,r.Y)("span",{children:n?"Overview":"Markdown"})]}),(0,r.FD)("button",{type:"button",onClick:()=>l("raw"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"raw"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(tu.A,{size:12}),(0,r.Y)("span",{children:t.formattedJson?"Raw JSON":s?"Code":"Raw Text"})]})]}),(0,r.Y)(e$,{text:t.formattedJson||t.rawOutput,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10.5px] font-medium text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:12,title:"Copy payload",resetMs:1800,wrapLabel:!0,copiedLabelClassName:"text-success",label:"Copy"})]}),"formatted"===a&&(n?(0,r.FD)("div",{className:"space-y-3 text-[11.5px]",children:[n.summary&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:[(0,r.Y)(n2.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Summary"})]}),(0,r.Y)("div",{className:"leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:n.summary,className:"text-[11.5px]"})})]}),n.architecture&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(n1.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Architecture"})]}),(0,r.Y)("p",{className:"leading-relaxed text-ink/80",children:n.architecture})]}),Array.isArray(n.files)&&n.files.length>0&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(eP.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Files Inspected"})]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:[n.files.length," items"]})]}),(0,r.Y)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:n.files.map((e,t)=>(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5 transition-colors hover:border-ink/15",children:[(0,r.Y)("span",{className:"font-mono text-[10.5px] font-medium text-ink truncate",children:e.path}),e.description&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight line-clamp-2 mt-0.5",children:e.description})]},t))})]}),n.report&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(eE.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Report"})]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded border border-ink/6 bg-canvas/30 p-2 text-ink/85 scrollbar-overlay-container",children:(0,r.Y)(eS.T,{content:n.report,className:"text-[11.5px] leading-relaxed"})})]})]}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85 max-h-72 overflow-auto scrollbar-overlay-container",children:(0,r.Y)(eS.T,{content:t.rawOutput})})),"raw"===a&&(0,r.Y)("pre",{className:"max-h-64 overflow-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/80 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,e3.wY)(t.formattedJson||t.rawOutput,t.formattedJson?"json":s?"javascript":"markdown")}}),t.outro&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5 text-[11px] text-ink/75",children:[(0,r.FD)("div",{className:"mb-1.5 flex items-center gap-1.5 font-mono text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:[(0,r.Y)(eM.A,{size:11}),(0,r.Y)("span",{children:"Follow-up & Transcript"})]}),(0,r.Y)("div",{className:"text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:t.outro})})]})]})}function n3(e){let{notice:t}=e,[n,s]=(0,i.J0)(!1);(0,e8.w)();let a=(0,i.Kr)(()=>(function(e){let t,n,r;if(!e)return null;let i=e.match(/([\s\S]*?)<task-result\b([^>]*)>([\s\S]*?)<\/task-result>([\s\S]*)/i);if(!i)return null;let s=i[1].trim(),a=i[2],l=i[3].trim(),o=i[4].trim(),c=a.match(/\bid=["']([^"']+)["']/i)?.[1],d=a.match(/\bagent=["']([^"']+)["']/i)?.[1],u=a.match(/\bstatus=["']([^"']+)["']/i)?.[1],p=a.match(/\bduration=["']([^"']+)["']/i)?.[1],m=l.match(/<meta\b([^>]*)\/?>/i);if(m){let e=m[1],n=e.match(/\blines=["']([^"']+)["']/i)?.[1],r=e.match(/\bsize=["']([^"']+)["']/i)?.[1];(n||r)&&(t={lines:n,size:r})}let h="",f=l.match(/<output\b[^>]*>([\s\S]*?)<\/output>/i);if(f)h=f[1].trim();else{let e=l.match(/<preview\b[^>]*>([\s\S]*?)<\/preview>/i),t=e?.[1].trim();h=t||l.replace(/<meta\b[^>]*\/?>(?:\s*<\/meta>)?|<\/?preview\b[^>]*>/gi,"").trim()}if(h.startsWith("{")||h.startsWith("["))try{let e=JSON.parse(h);e&&"object"==typeof e&&!Array.isArray(e)&&(n=e,r=JSON.stringify(e,null,2))}catch{let e=function(e){let t=e;for(let e=0;e<16;e+=1){let{stack:e,inString:n,escaped:r}=function(e){let t=[],n=!1,r=!1;for(let i of e){if(n){r?r=!1:"\\"===i?r=!0:'"'===i&&(n=!1);continue}'"'===i?n=!0:"{"===i||"["===i?t.push("{"===i?"}":"]"):("}"===i||"]"===i)&&t.pop()}return{stack:t,inString:n,escaped:r}}(t),i=t;n&&(r&&(i=i.slice(0,-1)),i+='"'),i=(i=i.replace(/,\s*"[^"]*"\s*:\s*$/,"").replace(/"[^"]*"\s*:\s*$/,"").replace(/,\s*$/,"")+[...e].reverse().join("")).replace(/,\s*(?=[}\]])/g,"");try{return JSON.parse(i),i}catch{let e=t.lastIndexOf(",");if(e<=0)return null;t=t.slice(0,e)}}return null}(h);if(e){let t=JSON.parse(e);t&&"object"==typeof t&&!Array.isArray(t)&&(n=t,r=JSON.stringify(t,null,2),h=e)}}return{intro:s||(c?`Background job ${c} completed`:"System notice"),id:c,agent:d,status:u,duration:p,meta:t,rawOutput:h,formattedJson:r,structuredOutput:n,outro:o||void 0}})(t),[t]),l=(0,i.Kr)(()=>{if(!(/<\/?system-reminder[^>]*>/i.test(t)||t.includes("xd://resolve")||t.includes("`ast_edit` result")))return null;let e=t.replace(/<\/?system-reminder[^>]*>/gi,"").trim();if(!e)return null;let n=(e.split(/\r?\n/).map(e=>e.trim()).find(Boolean)??e).replace(/`([^`]+)`/g,"$1");return{content:e,title:n}},[t]),o=(0,i.Kr)(()=>{let e=t.replace(/<\/?system-notice[^>]*>/gi,"").trim(),n=e.split(/\r?\n/),r=(n.find(e=>e.trim())??"").trim(),i=n.findIndex(e=>e.trim()===r),s=n.slice(i+1).join("\n").trim(),a=(0,e3.rw)(s);return{clean:e,firstLine:r,rest:s,isCode:a}},[t]),c=a?.intro||l?.title||o.firstLine||t,d=c.length>100,u=c.slice(0,100)+(d?"...":""),p=(0,i.Kr)(()=>{if(a)return!0;let e=t.replace(/<\/?(?:system-notice|system-reminder)[^>]*>/gi,"").trim();return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).length>1||e.length>100||c.length>100},[a,t,c]),m=(0,i.Kr)(()=>a?"failed"===a.status||"error"===a.status?{icon:(0,r.Y)(eF.A,{size:13}),badgeClass:"bg-error/10 text-error",label:"Task Result",isError:!0}:{icon:(0,r.Y)(e9.A,{size:13}),badgeClass:"bg-success/10 text-success",label:"Task Result",isError:!1}:l?{icon:(0,r.Y)(eq.A,{size:13}),badgeClass:"bg-warning/10 text-warning",label:"System Reminder",isError:!1}:{icon:(0,r.Y)(eA.A,{size:13}),badgeClass:"bg-info/10 text-info",label:"System Notice",isError:!1},[a,l]);return(0,r.FD)("div",{className:`mx-3 overflow-hidden rounded-xl border border-ink/10 bg-paper text-[12px] text-ink transition-colors ${p?"hover:border-ink/20":""} select-text`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{p&&s(e=>!e)},disabled:!p,"aria-expanded":p?n:void 0,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${p?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg ${m.badgeClass}`,children:m.icon}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:m.label}),a?.agent&&(0,r.FD)("span",{className:"flex items-center gap-1 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/60",children:[(0,r.Y)(O.A,{size:10}),a.agent]}),a?.status&&(0,r.FD)("span",{className:`flex items-center gap-1 rounded px-1.5 py-0.2 font-mono text-[9px] font-semibold uppercase ${m.isError?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:[m.isError?(0,r.Y)(eF.A,{size:10}):(0,r.Y)(e9.A,{size:10}),a.status]}),a?.duration&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(tz.A,{size:9}),a.duration]}),a?.meta?.size&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(n1.A,{size:9}),a.meta.size]})]}),!n&&u&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",title:c,children:u})]}),p&&(0,r.Y)(Y.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${n?"rotate-180":""}`})]}),n&&p&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3.5 py-2.5",children:a?(0,r.Y)(n4,{task:a}):l?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:l.content})}):o.isCode?(0,r.Y)("pre",{className:"max-h-56 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/75 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,e3.wY)(o.rest||o.clean,"javascript")}}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eS.T,{content:o.clean||o.rest})})})]})}function n8(e){return!!(e.preview?.startsWith("data:image/")||e.preview?.startsWith("blob:"))||(e.type?.startsWith("image/")??!1)}function n6(e){let{src:t,name:n,onClose:s}=e,[l,o]=(0,i.J0)(!1);return(0,i.vJ)(()=>{let e=e=>{"Escape"===e.key&&s()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]),(0,a.d5)((0,r.Y)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-ink/80 backdrop-blur-sm",onClick:s,role:"dialog","aria-modal":"true","aria-label":`Preview ${n}`,children:(0,r.FD)("div",{className:"relative max-w-[90vw] max-h-[90vh] flex flex-col items-center",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{type:"button",onClick:s,className:"absolute -top-10 right-0 flex items-center justify-center w-8 h-8 rounded-full bg-paper/10 text-canvas hover:bg-paper/20 transition-colors",title:"Close (Esc)",children:(0,r.Y)(j.A,{size:18})}),(0,r.Y)("img",{src:t,alt:n,onClick:()=>o(e=>!e),title:l?"Zoom out":"Zoom in (click image)",className:`max-w-[90vw] max-h-[85vh] object-contain rounded-md shadow-2xl bg-canvas/5 cursor-zoom-in transition-transform ${l?"scale-150 cursor-zoom-out":"scale-100"}`}),(0,r.Y)("div",{className:"mt-3 max-w-[90vw] truncate text-[11px] font-mono text-canvas/80",children:n})]})}),document.body)}function n9(e){let{attachments:t,className:n="",onOpenFile:s}=e,[a,l]=(0,i.J0)(null);return(0,r.FD)(r.FK,{children:[t.length>0&&(0,r.Y)("div",{className:`flex flex-wrap gap-1.5 pt-2 border-t border-ink/10 ${n}`,children:t.map((e,t)=>(0,r.FD)("button",{type:"button",onClick:()=>{n8(e)&&e.preview?l(e):s?s(e):window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment"}}))},title:n8(e)?"Preview image":"Open in editor",className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-1.5 text-xs font-sans hover:border-ink/40 hover:bg-ink/5 hover:shadow-sm transition-all cursor-pointer group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"attachment preview",className:"w-5 h-5 rounded-sm object-cover mr-1.5 border border-ink/5 group-hover:scale-105 transition-transform"}):(0,r.Y)("div",{className:"w-5 h-5 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(ex.A,{size:11})}),(0,r.Y)("span",{className:"truncate max-w-[100px] font-mono text-[10px] text-ink/80",children:e.name})]},t))}),a&&a.preview&&(0,r.Y)(n6,{src:a.preview,name:a.name??"image",onClose:()=>l(null)})]})}function n7(e){let t=e.match(/^(\s*)([a-zA-Z\u00C0-\u024F])(.*)$/s);return t?t[1]+t[2].toUpperCase()+t[3]:e}let re=/<\/?(?:system-reminder|reminder|system-notice|task-result)\b/i,rt=["model","provider","usage","durationMs","startedAt","completedAt","thinking","toolCalls"];function rn(e){return!("string"!=typeof e?.notice||!e.notice.trim()||re.test(e.notice))&&rt.some(t=>void 0!==e[t]&&null!==e[t])}function rr(e){return"string"==typeof e?.notice&&!!e.notice.trim()&&!rn(e)}function ri(e){return rn(e)?e.notice:"string"==typeof e?.content?e.content:""}let rs=(0,a.ph)(function(e){let{msg:t,isStreaming:n=!1,onUndo:s,onNewChat:a,className:l="",isPrevAssistant:o=!1}=e,c="user"===t.role,d=rr(t),u=d?t.content:ri(t),p=(0,i.Kr)(()=>"string"==typeof u?u.trim():u,[u]),m=(0,i.Kr)(()=>"string"==typeof u?n7(u):u,[u]),h="string"==typeof u&&/[A-Za-z0-9]/.test(u);if(c){let e="agent"===t.attribution;return(0,r.FD)("div",{id:t.id,className:`flex flex-col items-end space-y-1.5 w-full max-w-full ${l}`,children:[(0,r.FD)("div",{className:"bg-paper p-3.5 sm:p-4 rounded-xl border border-ink/15 text-[13px] text-ink shadow-xs max-w-[92%] sm:max-w-[85%] break-words overflow-hidden flex flex-col space-y-2 font-sans select-text mx-3",style:{lineHeight:"var(--markdown-body-line-height)"},children:[e&&(0,r.FD)("div",{className:"flex items-center space-x-1.5 pb-1.5 mb-1 border-b border-ink/10 text-[11px] font-mono text-ink/70",children:[(0,r.Y)(O.A,{size:12,className:"text-ink shrink-0"}),(0,r.Y)("span",{className:"font-semibold text-ink",children:"Subagent Assignment"}),(0,r.Y)("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-ink/5 text-ink/60",children:"Delegated"})]}),(0,r.Y)(eS.T,{content:p}),(0,r.Y)(n9,{attachments:t.attachments||[],onOpenFile:e=>{window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment",content:e.content}}))}})]}),(0,r.FD)("div",{className:"flex items-center space-x-2.5 text-[11px] text-ink/60 px-1 font-mono",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5",children:[e?(0,r.FD)(r.FK,{children:[(0,r.Y)(O.A,{size:11,className:"text-ink/70 shrink-0"}),(0,r.Y)("span",{className:"text-[10px] uppercase font-semibold tracking-wider text-ink/60",children:"Agent"})]}):(0,r.Y)(eN.A,{size:11,className:"text-ink/70 shrink-0"}),tJ(t)&&(0,r.Y)("span",{children:tJ(t)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Undo / Edit message",onClick:()=>{s&&s(t.id,t.content)},children:(0,r.Y)(eY.A,{size:12})}),(0,r.Y)(e$,{text:t.content,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy prompt"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:e=>{e&&e.preventDefault(),a&&a(t.content)},children:(0,r.Y)(eD.A,{size:12})})]})]})]})}let f=t.thinking||(t.monologue?{thought:t.monologue}:void 0),x=t.toolCalls||t.actions,g=t.actions2,b=t.intent?n7(t.intent.replace(/^[.\s]+/,"")):null,v=!!(x&&x.length>0),k=x?.filter(e=>"yield"===e.name||"yield"===e.type).find(e=>"error"!==e.status)?.output,y=b||(k??(x?.length===1?"Tool Execution (1 step)":`Tool Executions (${x?.length} steps)`));return(0,r.Y)("div",{id:t.id,className:`flex flex-col items-start space-y-2 w-full max-w-full transition-all ${n?"pb-10 mb-2":""} ${l}`,children:(0,r.FD)("div",{className:"w-full space-y-2.5 font-sans leading-relaxed",children:[d&&(0,r.Y)(n3,{notice:t.notice}),f&&(0,r.Y)(ej,{thinking:f,defaultExpanded:!1,showSeparator:o}),t.error&&(0,r.FD)("div",{className:"flex items-start space-x-2.5 bg-error/10 border border-error/30 rounded-lg mx-3 px-3.5 py-2.5 text-[12px] text-ink select-text",children:[(0,r.Y)(eF.A,{size:15,className:"text-error flex-shrink-0 mt-0.5"}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 flex-wrap",children:[(0,r.Y)("span",{className:"font-semibold text-error text-[12px] tracking-tight",children:t.error.status?`Error ${t.error.status}`:"Request Failed"}),t.error.stopReason&&(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded",children:t.error.stopReason})]}),t.error.message&&(0,r.FD)("p",{className:"text-ink/80 leading-relaxed text-[12px] font-mono whitespace-pre-wrap break-words",children:[t.error.message.split("\n").map(e=>e.trim()).filter(Boolean)[0],t.error.message.split("\n").map(e=>e.trim()).filter(Boolean).length>1&&(0,r.FD)("span",{className:"relative inline-flex items-center ml-1.5 align-middle group",children:[(0,r.Y)(eA.A,{size:13,className:"text-error/70 hover:text-error cursor-pointer transition-colors"}),(0,r.Y)("span",{className:"pointer-events-none absolute z-50 left-1/2 bottom-full mb-1.5 w-72 -translate-x-1/2 rounded-md bg-ink text-canvas p-2.5 text-[11px] font-mono leading-relaxed whitespace-pre-wrap break-words opacity-0 group-hover:opacity-100 transition-opacity duration-150 shadow-lg",children:t.error.message})]})]})]})]}),h&&(0,r.Y)("div",{className:"text-[13px] text-ink leading-relaxed font-sans bg-transparent px-3 py-1 select-text",children:(0,r.Y)(eS.T,{content:m})}),b&&!v&&(!h||!t.content.toLowerCase().includes(t.intent.toLowerCase().trim()))&&(0,r.Y)("div",{className:`leading-relaxed font-sans px-3 select-text ${h?"text-[12px] text-ink/70 py-0.5":"text-[13px] text-ink py-1"}`,children:b}),v&&(0,r.Y)(n0,{tools:x,title:y,defaultExpanded:!1}),t.systemNote&&(0,r.FD)("div",{className:"text-[12px] text-ink leading-relaxed border-l-2 border-ink/30 bg-paper/60 px-3 py-2 rounded-r-md font-mono break-words whitespace-pre-wrap select-text",children:[(0,r.Y)("span",{className:"text-[10px] text-ink/50 uppercase tracking-wider block mb-0.5 font-sans font-semibold",children:"Diagnostic Note"}),t.systemNote]}),g&&g.length>0&&(0,r.Y)(n0,{tools:g,title:`Follow-up Tools (${g.length})`,defaultExpanded:!0}),!n&&t.summary&&(0,r.FD)("div",{className:"text-[12px] text-ink bg-paper border border-ink/15 rounded-lg p-3 space-y-1 select-text font-sans",children:[(0,r.FD)("div",{className:"font-semibold text-ink flex items-center space-x-1.5 text-[12px]",children:[(0,r.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),(0,r.Y)("span",{children:"Resolution Summary"})]}),(0,r.Y)("p",{className:"text-ink/80 leading-relaxed text-[12px]",children:t.summary})]})]})})});var ra=n("Sjr"),rl=n("Sj"),ro=n("sM"),rc=n("kk");function rd(e){if("number"==typeof e?.startedAt&&Number.isFinite(e.startedAt))return e.startedAt;let t=e?.date||e?.timestamp;if(!t)return null;let n=tO(t);if(null!==n)return n;let r=new Date(t).getTime();return Number.isNaN(r)?null:r}function ru(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.trim())return"";let n=t[e];return n?.trim()?n:e.trim()?e.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function rp(e){let{provider:t,providerNames:n,currentModel:s,dateStr:a,durationMs:l,usage:o,content:c,msgId:d,thinkingLevel:u,onRetry:p,onNewChat:m,isMobile:h=!1}=e,[f,x]=(0,i.J0)(!1),g=()=>{x(!1),p?.(d)},b=()=>{x(!1),m?.(c)};(0,i.vJ)(()=>{if(!f)return;let e=e=>{"Escape"===e.key&&x(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[f]);let v=function(e){if(!Number.isFinite(e)||e<1e3)return;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}(l??0),k=o?.totalTokens??(o?.input??0)+(o?.output??0),y=k>0?`${(0,ti.Rk)(k)??""} tok`:"",w=t?ru(t,n):"",N=o?.cost?.total&&o.cost.total>0?`$${o.cost.total<.01?o.cost.total.toFixed(4):o.cost.total.toFixed(3)}`:"",Y=[];w&&Y.push({key:"provider",content:w}),s&&Y.push({key:"model",content:s,className:"font-semibold text-ink min-w-0 truncate shrink"}),u&&Y.push({key:"thinking",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Thinking level: ${u}`,children:[(0,r.Y)(K.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:u})]})}),a&&Y.push({key:"date",content:a}),v&&Y.push({key:"duration",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Response time: ${v}`,children:[(0,r.Y)(ra.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:v})]})}),y&&Y.push({key:"tokens",content:y,className:"hidden sm:inline",title:o?.cost?.total?`${y} (${N})`:y});let D=[w,s||"Assistant",a||"Just now",y,N].filter(Boolean).join(" • ");return h?(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"w-full flex items-center gap-2 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0 truncate",title:D,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(O.A,{size:10})}),w&&(0,r.Y)("span",{className:"shrink-0 truncate",children:w}),w&&s&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),s&&(0,r.Y)("span",{className:"font-semibold text-ink min-w-0 truncate",children:s}),s&&u&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),u&&(0,r.FD)("span",{className:"shrink-0 inline-flex items-center gap-1 text-ink/60",title:`Thinking level: ${u}`,children:[(0,r.Y)(K.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:u})]})]}),(0,r.Y)("button",{type:"button","aria-label":"More actions","aria-haspopup":"dialog","aria-expanded":f,title:"More actions",onClick:()=>x(!0),className:`ml-auto shrink-0 rounded-md p-2 transition-colors cursor-pointer ${f?"text-ink bg-ink/10":"text-ink/50 hover:bg-ink/5 hover:text-ink"}`,children:(0,r.Y)(rl.A,{size:16})})]}),f&&(0,r.Y)("div",{className:"fixed inset-0 z-[70] flex items-end bg-ink/40 backdrop-blur-[1px] animate-in fade-in duration-150",role:"presentation",onClick:()=>x(!1),children:(0,r.FD)("div",{className:"w-full max-h-[80vh] overflow-y-auto rounded-t-2xl border border-ink/15 bg-paper pb-[max(0.75rem,env(safe-area-inset-bottom,0px))] shadow-2xl animate-in slide-in-from-bottom-4 duration-200",role:"dialog","aria-modal":"true","aria-labelledby":`message-actions-${d}`,onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/10 px-5 py-4",children:[(0,r.Y)("h2",{id:`message-actions-${d}`,className:"text-base font-semibold text-ink",children:"More actions"}),(0,r.Y)("button",{type:"button","aria-label":"Close more actions",title:"Close",onClick:()=>x(!1),className:"rounded-lg p-2 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink cursor-pointer",children:(0,r.Y)(j.A,{size:20})})]}),(a||v||y)&&(0,r.FD)("div",{className:"flex flex-nowrap items-center gap-3 overflow-hidden whitespace-nowrap border-b border-ink/10 px-5 py-3 text-[11px] text-ink/70",children:[a&&(0,r.FD)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(ro.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:a})]}),v&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:"Response time",children:[(0,r.Y)(ra.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:v})]}),y&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:N?`${y} (${N})`:y,children:[(0,r.Y)(rc.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:y})]})]}),(0,r.FD)("div",{className:"p-2",children:[(0,r.Y)(e$,{text:c,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",iconSize:20,iconClassName:"shrink-0 text-ink/55",copiedIconClassName:"shrink-0 text-success",label:"Copy answer",wrapLabel:!0,onClick:()=>x(!1)}),(0,r.FD)("button",{type:"button",onClick:g,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(tR.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Retry response"})]}),(0,r.FD)("button",{type:"button",onClick:b,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(eD.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Start new chat from this answer"})]})]})]})})]}):(0,r.FD)("div",{className:"w-full flex items-center flex-nowrap space-x-2.5 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5 min-w-0 shrink overflow-hidden",title:D,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(O.A,{size:10})}),Y.map((e,t)=>{let{key:n,content:i,className:s,title:a}=e;return(0,r.FD)("span",{className:`inline-flex items-center text-ink/60 ${"model"===n?"min-w-0 shrink":"shrink-0"} whitespace-nowrap ${s??""}`,title:a,children:[t>0&&(0,r.Y)("span",{className:"text-ink/40 mr-1.5",children:"•"}),i]},n)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 shrink-0",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Re-run / Retry generation",onClick:g,children:(0,r.Y)(tR.A,{size:12})}),(0,r.Y)(e$,{text:c,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy response"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:b,children:(0,r.Y)(eD.A,{size:12})})]})]})}function rm(e){let{msg:t,provider:n,providerNames:i,modelName:s,modelNames:a,thinkingLevel:l,durationMs:o,onRetry:c,onNewChat:d,isMobile:u=!1}=e;return(0,r.Y)("div",{className:"mt-2",children:(0,r.Y)(rp,{provider:t.provider||n,providerNames:i,currentModel:(t.model?a?.[t.model]??t.model:"")||s||"",thinkingLevel:t.thinkingLevel??l,dateStr:tJ(t),durationMs:o??t.durationMs,usage:t.usage,content:ri(t),msgId:t.id,onRetry:c,onNewChat:d,isMobile:u})})}let rh=["Synthesizing solution","Evaluating context","Reading workspace","Planning next step","Executing diagnostics","Compiling edge routes"];function rf(e){let{modelName:t,generatingVerb:n,provider:s,providerNames:a}=e,[l,o]=(0,i.J0)(0);(0,i.vJ)(()=>{if(n)return;let e=setInterval(()=>{o(e=>(e+1)%rh.length)},2800);return()=>clearInterval(e)},[n]);let c=n?n.charAt(0).toUpperCase()+n.slice(1):rh[l],d=s?ru(s,a):"";return(0,r.FD)("div",{id:"generating-docked-indicator",className:"w-full flex items-center px-1 py-1 bg-transparent border-0 border-none text-[11px] font-mono select-none animate-in fade-in duration-200",children:[(0,r.Y)("style",{children:`
11
11
  @keyframes bounce-dot {
12
12
  0%, 100% { opacity: 0.2; transform: translateY(0); }
13
13
  50% { opacity: 1; transform: translateY(-15%); }
@@ -15,19 +15,19 @@ ${r}`}function tv(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1
15
15
  .dot-anim-1 { animation: bounce-dot 1.2s infinite both; }
16
16
  .dot-anim-2 { animation: bounce-dot 1.2s infinite both 0.2s; }
17
17
  .dot-anim-3 { animation: bounce-dot 1.2s infinite both 0.4s; }
18
- `}),(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("div",{className:"relative w-4 h-4 rounded flex items-center justify-center shrink-0",children:[(0,r.Y)("div",{className:"absolute -inset-[1.5px] rounded-[5px] animate-spin",style:{background:"conic-gradient(from 0deg, #ff453a, #ff9f0a, #ffd60a, #30d158, #64d2ff, #0a84ff, #bf5af2, #ff375f, #ff453a)",animationDuration:"1.2s"}}),(0,r.Y)("div",{className:"relative w-full h-full rounded-[3px] bg-ink flex items-center justify-center text-canvas z-10 shadow-2xs",children:(0,r.Y)(O.A,{size:10,className:"text-canvas"})})]}),(0,r.FD)("div",{className:"flex items-center space-x-1.5 min-w-0 truncate",children:[d&&(0,r.Y)("span",{className:"text-ink/55 truncate shrink",children:d}),(0,r.Y)("span",{className:"font-semibold text-ink truncate",children:t}),(0,r.Y)("span",{className:"text-ink/40 shrink-0",children:"•"}),(0,r.FD)("span",{className:"text-ink/75 flex items-center space-x-1 shrink-0 font-medium",children:[(0,r.Y)("span",{className:"transition-all duration-300",children:c}),(0,r.FD)("span",{className:"inline-flex tracking-wider text-ink/80 ml-0.5",children:[(0,r.Y)("span",{className:"dot-anim-1 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-2 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-3 inline-block",children:"."})]})]})]})]})]})}function rx(e){let t=e.length-1;for(;t>=0&&rr(e[t]);)t--;return t}function rg(e){let t=Array(e.length),n=-1;for(let r=0;r<e.length;r++)t[r]=n,rr(e[r])||(n=r);return t}function rb(e,t){let n=e.length,r=Array(n).fill(null),i=rx(e),s=-1;for(let a=0;a<n;a++){let l=e[a];if("user"===l.role){s=-1;continue}if(rr(l)||(s=a),a!==n-1&&e[a+1]?.role!=="user"||s<0)continue;let o=e[s];t&&s===i&&"ai"===o.role||(r[a]={msg:o,ownerIndex:s,durationMs:function(e,t){var n;let r=(n=e[t],"number"==typeof n?.completedAt&&Number.isFinite(n.completedAt)?n.completedAt:rd(n));if(null===r)return null;let i=null;for(let n=t-1;n>=0;n--){if(e[n]?.role==="user"){i=rd(e[n]);break}let t=rd(e[n]);null!==t&&(i=t)}return null===i||r<=i?null:r-i}(e,s)??o.durationMs??null})}return r}function rv(e){let{className:t="",folders:n=[],selectedFolderId:s,setSelectedFolderId:a,inputValue:l,setInputValue:o,inputAttachments:c,setInputAttachments:d,onSend:u,isGenerating:p,appSettings:m={},messages:h=[],provider:f,providerNames:x,modelName:g,modelNames:b,rootPath:v,onThinkingLevelChange:k,onModelChange:y,sessionModel:A,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:z,generatingVerb:$,variant:j="desktop"}=e,[L,M]=(0,i.J0)(!1),P=(0,i.li)(null);(0,F.W)(P,()=>M(!1));let E=(0,i.li)(null),R=(0,i.Kr)(()=>n?.find(e=>e.id===s),[n,s]),{streamingIdx:I,footers:O}=(0,i.Kr)(()=>({streamingIdx:rx(h),footers:rb(h,p)}),[h,p]);return(0,i.vJ)(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[h.length]),(0,r.Y)("div",{className:`flex flex-col h-full bg-canvas ${"mobile"===j?"px-3 py-4":"p-8"} ${t}`,style:"mobile"===j?{paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:`mx-auto w-full max-w-[970px] flex flex-col min-h-0 space-y-3 ${h.length>0?"flex-1":"my-auto justify-center"}`,children:[0===h.length&&(0,r.FD)("div",{className:"relative shrink-0",ref:P,children:[(0,r.FD)("button",{type:"button",onClick:()=>M(!L),className:"group flex items-center space-x-1.5 px-1.5 py-1 rounded-md text-xs font-medium text-ink/75 hover:text-ink hover:bg-ink/5 focus-visible:bg-ink/5 transition-all outline-none cursor-pointer select-none",children:[(0,r.Y)(N.A,{size:13,className:"text-ink/50 group-hover:text-ink/80 transition-colors flex-shrink-0"}),(0,r.Y)("span",{className:"flex items-center space-x-1 max-w-[260px] truncate tracking-tight",children:(0,r.Y)("span",{children:R?R.name:"Select Workspace Context"})}),(0,r.Y)(Y.A,{size:13,className:`text-ink/40 group-hover:text-ink/70 flex-shrink-0 transition-transform duration-150 ${L?"rotate-180 text-ink/70":""}`})]}),L&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1.5 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg z-50 flex flex-col overflow-hidden text-xs py-1",children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5",children:"Target Workspace"}),(0,r.Y)("div",{className:"max-h-56 scrollbar-overlay-container scrollbar-overlay-static py-1",children:0===n.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/40 italic",children:"No workspaces available"}):n.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{a(e.id),M(!1)},className:`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors cursor-pointer ${s===e.id?"bg-ink/10 text-ink font-semibold":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 truncate pr-2",children:[(0,r.Y)(N.A,{size:12,className:s===e.id?"text-ink flex-shrink-0":"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"truncate font-medium",children:e.name})]}),s===e.id&&(0,r.Y)(D.A,{size:12,className:"text-ink flex-shrink-0"})]},e.id))})]})]}),h.length>0&&(0,r.Y)("div",{ref:E,className:"flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:h.map((e,t)=>{let n=h[t-1],i=p&&t===I&&"ai"===e.role,s="user"!==e.role&&n&&"user"!==n.role,a=O[t];return(0,r.FD)(w.FK,{children:[(0,r.Y)(rs,{msg:e,isStreaming:i,className:s?"mt-1":"mt-8"}),a&&(0,r.Y)(rm,{msg:a.msg,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:C??void 0,durationMs:a.durationMs})]},e.id)})})}),p&&(0,r.Y)(rf,{modelName:g,generatingVerb:$,provider:f,providerNames:x}),(0,r.Y)(ew,{value:l,onChange:o,rootPath:v,attachments:c,onAttachmentsChange:d,onSend:u,isGenerating:p,disabled:!s,className:"w-full shrink-0",appSettings:m,onThinkingLevelChange:k,onModelChange:y,sessionModel:A,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:z,variant:j})]})})}let rk=[{role:"user",width:"58%",lines:1},{role:"ai",width:"100%",lines:3},{role:"user",width:"40%",lines:1},{role:"ai",width:"92%",lines:2},{role:"user",width:"52%",lines:2},{role:"ai",width:"100%",lines:4}];function ry(e){let{row:t,index:n}=e;return(0,r.Y)("div",{className:`flex ${"user"===t.role?"justify-end":"justify-start"} mb-3`,children:(0,r.Y)("div",{className:"rounded-lg bg-ink/5 border border-ink/5 px-3 py-2 space-y-1.5",style:{width:t.width,maxWidth:"85%"},children:Array.from({length:t.lines},(e,i)=>(0,r.Y)("div",{className:"h-2.5 rounded bg-ink/8 animate-pulse",style:{width:i===t.lines-1?"62%":"100%",animationDelay:`${120*n+60*i}ms`}},i))})})}function rw(){let e=(0,i.Kr)(()=>rk,[]);return(0,r.FD)("div",{"aria-hidden":!0,className:"flex flex-col h-full min-h-0 overflow-hidden",children:[(0,r.Y)("div",{className:"flex-1 min-h-0 overflow-hidden px-3 py-3 pb-8 sm:p-4 sm:pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:e.map((e,t)=>(0,r.Y)(ry,{row:e,index:t},t))})}),(0,r.Y)("div",{className:"flex-shrink-0 px-3 pt-1 pb-3 sm:p-4 sm:pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"rounded-md border border-ink/20 bg-paper p-3 space-y-2",children:[(0,r.Y)("div",{className:"h-9 rounded bg-ink/8 animate-pulse",style:{animationDelay:"720ms"}}),(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.Y)("div",{className:"h-5 w-28 rounded bg-ink/8 animate-pulse",style:{animationDelay:"840ms"}}),(0,r.Y)("div",{className:"h-7 w-7 rounded bg-ink/8 animate-pulse",style:{animationDelay:"960ms"}})]})]})})})]})}function rN(){return(0,r.Y)("div",{className:"flex justify-center py-2",role:"status",children:(0,r.FD)("div",{className:"flex items-center gap-1.5 text-ink/40 text-[11px] font-mono",children:[(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse"}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"150ms"}}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"300ms"}})]})})}function rY(e){let{content:t,isOmpSession:n,undoing:s,onClose:a,onConfirm:l}=e;return(0,i.vJ)(()=>{let e=e=>{"Escape"!==e.key||s||(e.preventDefault(),a())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,s]),(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",onClick:s?void 0:a,role:"dialog","aria-modal":"true","aria-label":"Confirm undo",children:(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-xl shadow-xl w-[min(94vw,420px)] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[(0,r.Y)(eY.A,{size:16,className:"text-ink/70 shrink-0"}),(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"Undo message?"})]}),(0,r.FD)("div",{className:"px-4 py-4 space-y-3",children:[(0,r.Y)("div",{className:"rounded-lg border border-ink/10 bg-canvas/50 px-3 py-2 text-[12px] text-ink/80 leading-relaxed max-h-28 overflow-y-auto scrollbar-overlay-container",children:t||"Empty message or attachment-only prompt"}),(0,r.Y)("p",{className:"text-[11.5px] leading-relaxed text-ink/60",children:n?"The timeline and agent context rewind to before this message. Its reply and everything after it are removed; the text returns to the composer for editing.":"This message and everything after it are removed from the timeline. The text returns to the composer for editing."})]}),(0,r.FD)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[(0,r.Y)("button",{type:"button",onClick:a,disabled:s,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40 disabled:cursor-not-allowed",children:"Cancel"}),(0,r.FD)("button",{type:"button",autoFocus:!s,onClick:l,disabled:s,className:"flex items-center gap-2 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:[s&&(0,r.Y)(e2.A,{size:13,className:"animate-spin shrink-0"}),s?"Rewinding…":"Undo"]})]})]})})}function rD(e){let{initialContent:t,onClose:n,onSend:s,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c}=e,[d,u]=(0,i.J0)(t),[p,m]=(0,i.J0)([]);return(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",children:(0,r.FD)("div",{className:"bg-canvas border border-ink/15 rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10 bg-paper",children:[(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"New Chat"}),(0,r.Y)("button",{onClick:n,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors",children:(0,r.Y)(j.A,{size:14})})]}),(0,r.FD)("div",{className:"p-4 flex-1 scrollbar-overlay-container scrollbar-overlay-static",children:[(0,r.Y)("p",{className:"text-xs text-ink/60 mb-3",children:"Start a new session in this workspace based on the selected message."}),(0,r.Y)(ew,{value:d,onChange:u,attachments:p,onAttachmentsChange:m,onSend:e=>{s(d,e),n()},isGenerating:!1,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c})]})]})})}var rF=n("Kv"),rA=n("M"),rC=n("Uo"),rS=n("T");function rT(e){if("string"==typeof e)return e;if(!Array.isArray(e))return"";let t=[];for(let n of e)(0,nd.u)(n)&&"text"===n.type&&"string"==typeof n.text&&t.push(n.text);return t.join("\n")}function rz(e,t){if(!e)return"";for(let n of t){let t=e[n];if("string"==typeof t)return t}return""}let r$=["command","cmd","CommandLine","commandLine"],rj=["path","TargetFile","targetFile","FilePath","filePath","AbsolutePath","file"],rL=new Set(["aborted","error"]);function rM(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=new Date(e).getTime();return Number.isNaN(t)?void 0:t}}function rP(e){return"string"==typeof e?e:e&&"object"==typeof e?rT(e.content):""}function rE(e){let t,n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("custom"===e.role){if("session_exit"===e.customType)return null;let t=e.content,n=("string"==typeof t?t:Array.isArray(t)?t.map(e=>e&&"object"==typeof e&&"text"===e.type?e.text??"":"").join(""):"").replace(/<\/?system-notice[^>]*>/g,"").trim();return n?{id:"string"==typeof e.id?e.id:`notice-${Date.now()}`,role:"ai",content:"",notice:n}:null}let r=function(e){let t={toolCalls:[],inlineOutputs:new Map,textParts:[]};if("string"==typeof e)return t.textParts.push(e),t;if(!Array.isArray(e))return t;for(let n of e)if((0,nd.u)(n))if("thinking"===n.type)"string"==typeof n.thinking?t.thinking=n.thinking:"string"==typeof n.text&&(t.thinking=n.text);else if("toolCall"===n.type){let e="string"==typeof n.id?n.id:`tool-${Math.random().toString(36).slice(2,10)}`,r="string"==typeof n.name?n.name:"tool",i=n.arguments??n.input,s=(0,nd.u)(i)?i:void 0,a=rz(s,r$),l=rz(s,rj)||(s?(0,nO.f$)(s):void 0),o="string"==typeof s?.i?s.i:void 0,c=a||l;t.toolCalls.push({id:e,name:r,title:c?`${r} — ${c}`:r,intent:o,target:l||void 0,command:a||void 0,input:s&&Object.keys(s).length>0?s:void 0}),o&&!t.intent&&(t.intent=o),t.inlineOutputs.set(e,"")}else if("toolResult"===n.type){let e="string"==typeof n.toolCallId?n.toolCallId:void 0,r="string"==typeof n.text?n.text:"";if(e&&t.inlineOutputs.has(e))t.inlineOutputs.set(e,r);else if(r&&t.toolCalls.length>0){let e=t.toolCalls[t.toolCalls.length-1];t.inlineOutputs.set(e.id,r)}}else"text"===n.type&&"string"==typeof n.text&&t.textParts.push(n.text);return t}(e.content),i="string"==typeof e.id?e.id:`msg-${e.timestamp??Date.now()}-ai`,s="user"===e.role?"user":"ai",a="number"==typeof e.timestamp?tI(e.timestamp):void 0,l="string"==typeof e.attribution?e.attribution:void 0,o=rM(e.timestamp)??rM(e.startedAt),c="number"==typeof e.duration?e.duration:"number"==typeof e.durationMs?e.durationMs:void 0,d=rM(e.completedAt)??(void 0!==o&&void 0!==c?o+c:void 0),u="string"==typeof e.provider?e.provider:void 0,p=-1===(t=r.textParts.findIndex(e=>{let t=e1(e);return void 0!==t&&eQ(t.tag)}))?void 0:t;if("developer"===e.role||"system"===e.role||void 0!==p){let e=void 0!==p?r.textParts[p]:r.textParts.join("\n"),t=void 0!==p?e.trim():e.replace(/<\/?system-reminder[^>]*>/g,"").trim();return t?{id:i,role:"ai",date:a?`Today, ${a}`:void 0,timestamp:a,content:"",notice:t}:null}if("user"===s)return{id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,startedAt:o,content:function(e){let t=e.match(/(?:^|\n{2})\s*Attached file: /);if(!t||void 0===t.index)return e;let n=e.slice(0,t.index),r=e.slice(t.index+t[0].length);return/^[^\n]+\n```[a-z]*\n/.test(r)?n.trim():e}(r.textParts.join("\n")),attribution:l,attachments:(function(e){if(!Array.isArray(e))return[];let t=[],n=0;for(let r of e){if(!(0,nd.u)(r)||"image"!==r.type)continue;let e="string"==typeof r.data?r.data:void 0,i="string"==typeof r.mimeType?r.mimeType:"image/png";if(!e)continue;n+=1;let s=(i.split("/")[1]||"png").replace(/[^a-z0-9]/gi,"")||"png";t.push({id:`att-${n}`,name:`attachment-${n}.${s}`,preview:`data:${i};base64,${e}`,type:i})}return t})(e.content).map(e=>({id:e.id,name:e.name,preview:e.preview,type:e.type}))};let m=r.toolCalls.map(e=>{var t,r;let i,s,a,l;return t=e,r={streaming:n},s=t.input,a=(0,nd.u)(s)?Object.fromEntries(Object.entries(s).filter(e=>{let[t]=e;return"i"!==t})):s,l=r.isError?"error":void 0!==r.output?"success":r.streaming?"running":"success",{id:t.id,type:(i=(t.name||"").toLowerCase()).includes("bash")||i.includes("terminal")||i.includes("shell")||i.includes("run")?"bash":i.includes("write")||i.includes("edit")||i.includes("patch")||i.includes("apply")?"edit_file":i.includes("create")?"create_file":i.includes("read")||i.includes("view")||i.includes("list")?"read_file":i.includes("grep")||i.includes("glob")?"grep":i.includes("search")||i.includes("find")?"search_fs":i.includes("web")||i.includes("fetch")||i.includes("http")?"web_search":i.includes("todo")?"todo":i.includes("task")?"task":i.includes("lsp")?"lsp":i.includes("eval")?"eval":i.includes("github")?"github":i.includes("security")?"security_scan":"custom",name:t.name,title:t.title,intent:t.intent,target:t.target,command:t.command,input:a&&Object.keys(a).length>0?a:void 0,output:r.output,status:l}}),h={id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,attribution:l,model:"string"==typeof e.model?e.model:void 0,provider:u,startedAt:o,completedAt:d,durationMs:c,usage:e.usage&&"object"==typeof e.usage?e.usage:void 0,content:r.textParts.join("\n"),intent:r.intent,thinking:r.thinking?{thought:r.thinking,isGenerating:n}:e.thinking,toolCalls:m.length>0?m:e.toolCalls,summary:"string"==typeof e.summary?e.summary:void 0,error:e.error??function(e){let t;if("string"==typeof(t=e.stopReason)&&rL.has(t)||"number"==typeof e.errorStatus||"string"==typeof e.errorMessage)return{status:"number"==typeof e.errorStatus?e.errorStatus:void 0,id:"number"==typeof e.errorId?e.errorId:void 0,message:"string"==typeof e.errorMessage?e.errorMessage:void 0,stopReason:"string"==typeof e.stopReason?e.stopReason:void 0}}(e)};return h.content||h.thinking||h.toolCalls&&0!==h.toolCalls.length||h.intent||h.error||h.summary||h.notice?h:null}function rR(e,t){let n=[];for(let r of e){if((0,nd.u)(r)){let e="string"==typeof r.type?r.type:"";if("custom"===e||"custom_message"===e){let e="string"==typeof r.customType?r.customType:"";if("session_exit"===e)continue;if("launch-completion"===e||"string"==typeof r.content){let e=("string"==typeof r.content?r.content:"").replace(/<\/?system-notice[^>]*>/g,"").trim();e&&n.push({id:"string"==typeof r.id?r.id:`notice-${Date.now()}`,role:"ai",content:"",notice:e,date:"string"==typeof r.timestamp?new Date(r.timestamp).toISOString():void 0});continue}}if(e&&"message"!==e)continue}let e=function(e){if(!(0,nd.u)(e))return null;let t=(0,nd.u)(e.message)?e.message:null;if(!t)return e;let n={...t};return void 0===n.id&&"string"==typeof e.id&&(n.id=e.id),void 0===n.timestamp&&"number"==typeof e.timestamp&&(n.timestamp=e.timestamp),n}(r);if(!e)continue;if("toolResult"===e.role){let t="string"==typeof e.toolCallId?e.toolCallId:void 0,r=rT(e.content),i=(0,nd.u)(e.details)?e.details:void 0,s=!0===e.isError;for(let a=n.length-1;a>=0;a--){let l=n[a].toolCalls?.find(n=>t?n.id===t:n.name===e.toolName);if(l){r&&(l.output=r),i&&(l.details=i),l.status=s?"error":"success";break}}continue}let i=rE(e,t);i&&n.push(i)}return n}function rI(e,t){if(0===t.length)return e;let n=new Map(e.map((e,t)=>[e.id,t])),r=[...e];for(let e of t){let t=n.get(e.id);void 0===t?(n.set(e.id,r.length),r.push(e)):r[t]=e}return r}function rO(e,t,n){if(!(0,nd.u)(e)||!Array.isArray(e.messages))return null;let r="number"==typeof e.fromByte?e.fromByte:t;return{sessionFile:"string"==typeof e.sessionFile&&e.sessionFile?e.sessionFile:n??"",fromByte:r,nextByte:"number"==typeof e.nextByte?e.nextByte:r,reset:!0===e.reset,messages:e.messages,totalBytes:"number"==typeof e.totalBytes?e.totalBytes:void 0}}async function rJ(e,t,n,r){try{let i=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagent_messages",subagentId:t,...n?{sessionFile:n}:{},fromByte:r})});if(!i.ok)return null;let s=await i.json().catch(()=>null),a=(0,nd.u)(s)&&"data"in s?s.data:s;return rO(a,r,n)}catch{return null}}let r_=new Map;async function rW(e,t,n){let r=`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}?fromByte=${n}`,i=r_.get(r);if(i)return i;let s=()=>{},a=new Promise(e=>{s=()=>{r_.get(r)===a&&r_.delete(r)},(async()=>{try{let t=await fetch(r);if(!t.ok)return e(null);let i=await t.json().catch(()=>null),s=(0,nd.u)(i)&&"page"in i?i.page:i;if(null==s)return e(null);e(rO(s,n,void 0))}catch{e(null)}})()});return a.then(s,s),r_.set(r,a),a}let rK={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function rU(e){return"completed"===e||"failed"===e||"aborted"===e}function rq(e,t){if(!e||e.id!==t.id)return t;let n={...e,...t,agent:"subagent"!==t.agent?t.agent:e.agent,index:e.index>=0?e.index:t.index,status:rU(e.status)&&!rU(t.status)?e.status:t.status},r={...e.progress,...t.progress};return Object.keys(r).length>0?n.progress=r:delete n.progress,n}function rB(e){let[t,n]=(0,i.J0)(void 0),r=(0,i.li)(e);return r.current=e,(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,T.xo)();if(!e)return;let i=r.current(t);void 0!==i&&n(i)}catch{}};t();let i=(0,T.Sy)(t);return()=>{e=!1,i()}},[]),t}function rH(e){if(e.modelList?.length)return Object.fromEntries(e.modelList.map(e=>[e.id,e.name||e.id]))}let rG={started:"running",completed:"done",failed:"failed",aborted:"aborted"};function rV(e){let{sessionId:t,subagent:n,onBack:s,provider:a,providerNames:l,className:o=""}=e,{messages:c,isLoading:d,status:u,isActive:p}=function(e,t,n){let[r,s]=(0,i.J0)([]),[a,l]=(0,i.J0)(t),[o,c]=(0,i.J0)(!1),d=t?.id??null,u=!!(e&&d),p=(0,i.li)(0),m=(0,i.li)(e);m.current=e;let h=(0,i.li)(t);h.current=t;let f=(0,i.li)(n);f.current=n;let x=(0,i.li)(0),g=(0,i.li)(void 0),b=(0,i.li)(!1),v=(0,i.li)(!1),k=(0,i.li)(!1),y=(0,i.li)(null),w=(0,i.li)(()=>{}),N=(0,i.hb)(async()=>{let e=m.current,t=h.current;if(!e||!t||!b.current)return;if(v.current){k.current=!0;return}v.current=!0;let n=p.current;try{let r=await rJ(e,t.id,g.current,x.current);if(n!==p.current||!r)return;g.current=r.sessionFile||g.current;let i=rR(r.messages,!0);r.reset?(s(i),x.current=r.nextByte):(s(e=>rI(e,i)),x.current=Math.max(x.current,r.nextByte))}finally{v.current=!1,k.current&&(k.current=!1,w.current())}},[]);return(0,i.vJ)(()=>{t&&l(e=>rq(e,t))},[t]),(0,i.vJ)(()=>{if(!u)return;let e=e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=e.target instanceof HTMLElement?e.target:null,n=t?.tagName;"INPUT"===n||"TEXTAREA"===n||t?.isContentEditable||f.current()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]),(0,i.vJ)(()=>{if(!e||!d){s([]),l(null),c(!1);return}let t=++p.current,n=h.current,r=()=>t===p.current,i=n?.source==="history";s([]),l(n),c(!0),x.current=0,g.current=n?.sessionFile,b.current=!1;let a=()=>{null===y.current&&(y.current=window.setTimeout(()=>{y.current=null,N()},150))};w.current=a;let o=async()=>{let t=0,a=g.current,o=i||!n?.sessionFile,u=[];for(let n=0;n<20;n++){let n=o?await rW(e,d,t):await rJ(e,d,a,t);if(!r()||!n&&!o&&0===t&&(o=!0,n=await rW(e,d,0),!r()))return;if(!n)break;a=n.sessionFile||a;let i=rR(n.messages,!1);if(u=n.reset?i:rI(u,i),n.nextByte<=t||(t=n.nextByte,void 0!==n.totalBytes&&t>=n.totalBytes))break}r()&&(g.current=a,x.current=t,b.current=!o,s(e=>rI(e,u)),c(!1),o&&l(e=>e&&!rU(e.status)?{...e,status:"completed"}:e))},u=t=>{let n=t.detail;return n&&n.sessionId===e?n:null},m=e=>{let t=u(e);if(!t)return;let n=(0,rS.bH)(t.payload);n&&n.id===d&&(l(e=>rq(e,n)),a())},f=e=>{let t=u(e);if(!t)return;let n=(0,nd.u)(t.payload)?t.payload:null;if(!n)return;let r="string"==typeof n.id?n.id:null;if(r&&r!==d)return;if(!r){let e="number"==typeof n.index?n.index:null;if(null===e||e!==(h.current?.index??-1))return}let i=(0,rS.mq)(n);i&&l(e=>{if(!e||e.id!==d)return e;let t={...e,progress:{...e.progress,...i}};return i.status&&!rU(e.status)&&(t.status=rK[i.status]??e.status),t})},v=e=>{let t=u(e);if(!t)return;let n=(0,nd.u)(t.payload)?t.payload:null;n&&n.id===d&&a()};return i||(window.addEventListener("subagent_lifecycle",m),window.addEventListener("subagent_progress",f),window.addEventListener("subagent_event",v)),o(),()=>{p.current+=1,b.current=!1,null!==y.current&&(window.clearTimeout(y.current),y.current=null),i||(window.removeEventListener("subagent_lifecycle",m),window.removeEventListener("subagent_progress",f),window.removeEventListener("subagent_event",v))}},[e,d,N]),{messages:r,isLoading:o,status:a,isActive:u}}(t,n,s),m=rB(rH)??{},h=(0,i.li)(null),f=u?.status??n?.status??"started",x="started"===f;(0,i.vJ)(()=>{let e=h.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>cancelAnimationFrame(t)},[c.length,x]);let{streamingIdx:g,footers:b,prevNonNoticeIdx:v}=(0,i.Kr)(()=>({streamingIdx:rx(c),footers:rb(c,x),prevNonNoticeIdx:rg(c)}),[c,x]);if(!n||!p)return null;let k=u?.progress??n.progress,y=k?.resolvedModel??n.agent,N=(0,ti.Rk)(k?.tokens),Y=N?`${N} tok`:"",D=u?.task??u?.assignment??u?.description??n.task??n.assignment??n.description,F=D?D.replace(/\$0(\.00*)?/g,"").trim():void 0;return(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas ${o}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2.5 border-b border-ink/15 bg-paper px-3 py-2 flex-shrink-0",children:[(0,r.Y)("button",{type:"button",onClick:s,title:"Back to session",className:"flex items-center justify-center w-7 h-7 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors shrink-0 cursor-pointer",children:(0,r.Y)(rF.A,{size:14})}),(0,r.Y)(rC.l,{status:f,live:x,size:12}),(0,r.Y)(O.A,{size:13,className:"text-ink/60 shrink-0"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.Y)("span",{className:"font-mono text-[12px] font-semibold text-ink truncate",children:u?.agent??n.agent}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:rG[f]})]}),(0,r.Y)("p",{className:"truncate text-[11px] text-ink/55 font-sans",children:F??"Subagent transcript"})]}),Y&&(0,r.Y)("span",{className:"hidden sm:inline shrink-0 font-mono text-[10px] text-ink/45",children:Y})]}),(0,r.Y)("div",{ref:h,className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-overlay-container timeline-scrollbar-visible p-4 pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:d&&0===c.length?(0,r.FD)("div",{className:"flex items-center justify-center gap-2 py-12 text-[11px] font-mono text-ink/50",children:[(0,r.Y)(e2.A,{size:14,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading transcript…"})]}):0===c.length?(0,r.Y)("div",{className:"py-12 text-center text-[11.5px] font-mono text-ink/45",children:"No transcript messages yet."}):c.map((e,t)=>{let n=x&&t===g&&"ai"===e.role,i=v[t],s=i>=0?c[i]:null,o=!!("user"!==e.role&&s&&"user"!==s.role),d=b[t];return(0,r.FD)(w.FK,{children:[(0,r.Y)(rs,{msg:e,isStreaming:n,isPrevAssistant:o,className:rr(e)?"mt-3 mb-1":o?"mt-1":"mt-3"}),d&&(0,r.Y)(rm,{msg:d.msg,provider:a,providerNames:l,modelName:y,modelNames:m,durationMs:d.durationMs})]},e.id)})})}),(0,r.Y)("div",{className:"flex-shrink-0 p-4 pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"flex items-center justify-center gap-2 rounded-lg border border-ink/15 bg-paper px-3 py-2 text-[11px] font-mono text-ink/50 select-none",children:[(0,r.Y)(rA.A,{size:11,className:"text-ink/45"}),(0,r.Y)("span",{children:"Read-only transcript — subagents cannot receive messages"})]})})})]})}var rZ=n("zi");let rQ=(0,a.ph)(function(e){let{messages:t,isGenerating:n,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,onUndo:d,onRetry:u,onNewChat:p,isMobile:m=!1}=e,{streamingIdx:h,footers:f,prevNonNoticeIdx:x}=(0,i.Kr)(()=>({streamingIdx:rx(t),footers:rb(t,n),prevNonNoticeIdx:rg(t)}),[t,n]);return(0,r.Y)(r.FK,{children:t.map((e,i)=>{let g=t[i-1],b=n&&i===h&&"ai"===e.role,v="user"!==e.role&&g&&"user"!==g.role&&!rr(g),k=x[i],y=k>=0?t[k]:null,N=!!("user"!==e.role&&y&&"user"!==y.role),Y=f[i];return(0,r.FD)(w.FK,{children:[(0,r.Y)(rs,{msg:e,isStreaming:b,onUndo:d,onNewChat:p,isPrevAssistant:N,className:rr(e)?"mt-3 mb-1":v?"mt-1":"mt-3"}),Y&&(0,r.Y)(rm,{msg:Y.msg,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,durationMs:Y.durationMs,onRetry:u,onNewChat:p,isMobile:m})]},e.id)})})});function rX(e){let{userMessages:t,onScrollTo:n}=e,[s,a]=(0,i.J0)(null);return 0===t.length?null:(0,r.Y)("div",{className:"absolute right-0.5 top-1/2 -translate-y-1/2 z-20 flex flex-col items-center py-4 w-6",onMouseLeave:()=>a(null),children:t.map((e,t)=>{let i=s===t;return(0,r.FD)("div",{className:"relative flex items-center justify-center w-full py-[3px] cursor-pointer",onMouseEnter:()=>a(t),onClick:()=>n(e.id),children:[(0,r.Y)("button",{className:`block h-px rounded-full transition-all duration-200 ease-out ${(e=>{if(null===s)return"w-3";let t=Math.abs(e-s);return 0===t?"w-6":1===t?"w-4":"w-3"})(t)} ${i?"bg-ink h-[2px]":"bg-ink/25"}`,"aria-label":`Jump to your message #${t+1}`}),(0,r.FD)("div",{className:`absolute right-full mr-3 top-1/2 transform -translate-y-1/2 w-64 p-3 bg-ink text-canvas text-xs rounded-md shadow-lg pointer-events-none transition-opacity duration-200 z-30 ${i?"opacity-100":"opacity-0"}`,children:[(0,r.Y)("div",{className:"line-clamp-3 whitespace-pre-wrap leading-relaxed",children:e.content}),(0,r.Y)("div",{className:"absolute top-1/2 -right-1 transform -translate-y-1/2 w-2 h-2 bg-ink rotate-45"})]})]},`minimap-${e.id}`)})})}function r0(e){let{isMobile:t,userMessages:n,onScrollTo:i,scrollRef:s,contentRef:a,handleScroll:l,isScrolling:o,loadingOlder:c,hasMore:d,loadOlderError:u,loadOlder:p,messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:w,showScrollBottom:N,jumpToBottom:Y}=e;return(0,r.FD)(r.FK,{children:[!t&&(0,r.Y)(rX,{userMessages:n,onScrollTo:i}),(0,r.Y)("div",{ref:s,onScroll:l,className:`flex-1 scrollbar-overlay-container overscroll-contain scroll-smooth overflow-x-hidden ${t?"px-3 py-3 pb-8":"p-4 pb-10"} ${o?"timeline-scrollbar-visible":"timeline-scrollbar-hidden"}`,children:(0,r.FD)("div",{ref:a,className:"mx-auto w-full max-w-[970px]",children:[(c||d||u)&&(0,r.Y)("div",{className:"pb-1",children:c?(0,r.Y)(rN,{}):(0,r.Y)("button",{type:"button",onClick:p,className:`block mx-auto px-3 py-1 rounded-full border text-[11px] font-mono transition-colors ${u?"border-error/40 text-error hover:border-error":"border-ink/15 text-ink/50 hover:text-ink hover:border-ink/30"}`,children:u?"Failed to load — retry":"Load earlier messages"})}),(0,r.Y)(rQ,{messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:w,isMobile:t})]})}),N&&(0,r.Y)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 z-20",children:(0,r.Y)("button",{onClick:()=>Y("smooth"),className:"flex items-center justify-center w-8 h-8 rounded-full border border-ink/20 bg-paper text-ink/60 hover:text-ink hover:bg-ink/5 transition-all shadow-sm",title:"Scroll to bottom",children:(0,r.Y)(rZ.A,{size:16})})})]})}var r1=n("b");let r5={steer:"steer",followup:"follow-up"};function r2(e){let{queue:t,setQueue:n,isSteering:s=!1,onEdit:a,onSendNow:l}=e,o=(0,i.li)(null),c=(0,i.li)(null),d=()=>{if(null===o.current||null===c.current)return;let e=[...t],r=e.splice(o.current,1)[0];e.splice(c.current,0,r),o.current=null,c.current=null,n(e)};if(0===t.length)return null;let u=s?"steer":"followup";return(0,r.Y)("div",{className:"max-h-[150px] scrollbar-overlay-container scrollbar-overlay-static mb-2 space-y-1",children:t.map((e,t)=>(0,r.FD)("div",{draggable:!0,onDragStart:()=>{o.current=t},onDragEnter:()=>{c.current=t},onDragEnd:d,onDragOver:e=>e.preventDefault(),className:"flex items-center gap-2 px-2 py-1.5 bg-paper border border-ink/10 rounded shadow-sm text-xs group hover:border-ink/30 transition-colors",children:[(0,r.Y)("div",{className:"cursor-grab text-ink/40 group-hover:text-ink/80",children:(0,r.Y)(E.A,{size:14})}),(0,r.Y)("span",{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded ${"steer"===u?"bg-error/10 text-error":"bg-ink/10 text-ink/70"}`,children:r5[u]}),(0,r.Y)("div",{className:"flex-1 truncate text-ink/80 pr-2",children:e.text||(e.attachments.length>0?`[${e.attachments.length} attachment${e.attachments.length>1?"s":""}]`:"Empty message")}),l&&"followup"===u&&(0,r.Y)("button",{onClick:()=>l(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Send Now (Steering)",children:(0,r.Y)(C.A,{size:12})}),a&&(0,r.Y)("button",{onClick:()=>a(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Edit",children:(0,r.Y)(r1.A,{size:12})}),(0,r.Y)("button",{onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),className:"text-ink/40 hover:text-error opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove",children:(0,r.Y)(j.A,{size:14})})]},e.id))})}function r4(e){let{isMobile:t,isGenerating:n,modelName:i,generatingVerb:s,provider:a,providerNames:l,messageQueue:o,setMessageQueue:c,onEditQueueItem:d,onSendNowQueueItem:u,steeringQueue:p,setSteeringQueue:m,inputValue:h,setInputValue:f,rootPath:x,attachments:g,setAttachments:b,onSend:v,onStop:k,appSettings:y,onThinkingLevelChange:w,onModelChange:N,accessMode:Y,onAccessModeChange:D,composerModelRef:F,sessionModel:A,sessionThinkingLevel:C,variant:S}=e;return(0,r.Y)("div",{className:`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${t?"px-3 pt-1":"p-4 pt-1"}`,style:t?{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:"mx-auto w-full max-w-[970px]",children:[n&&(0,r.Y)(rf,{modelName:i,generatingVerb:s,provider:a,providerNames:l}),(0,r.Y)(r2,{queue:o,setQueue:c,onEdit:d,onSendNow:u}),(0,r.Y)(r2,{queue:p,setQueue:m,isSteering:!0}),(0,r.Y)(ew,{value:h,onChange:f,rootPath:x,attachments:g,onAttachmentsChange:b,onSend:v,isGenerating:n,onStop:k,appSettings:y,onThinkingLevelChange:w,onModelChange:N,accessMode:Y,onAccessModeChange:D,composerModelRef:F,sessionModel:A,sessionThinkingLevel:C,variant:S})]})})}var r3=n("zG");function r8(e){let t,n=(0,r3.oJ)(e.name)??"",r=r3.YT[n.toLowerCase()]??n.toLowerCase(),i=(t={...(0,nd.u)(e.args)?e.args:(0,nd.u)(e.input)?e.input:{}},e.command&&void 0===(0,r3.oJ)(t.command)&&void 0===(0,r3.oJ)(t.cmd)&&(t.command=e.command),e.target&&void 0===(0,r3.oJ)(t.path)&&(t.path=e.target),t),s=(0,r3.oJ)(e.intent)??(0,r3.Up)(i,["i"]),a=function(e,t){let n=(0,r3.Up)(e,["path","target"])??(0,r3.oJ)(t.target)??(0,r3.oJ)(t.command);if(n&&n.startsWith("xd://"))return n.slice(5).split(/[/?#\s]/)[0]||void 0}(i,e);if(a){let e=a.startsWith("mcp__")?a.slice(5):void 0,t=e?`Running ${e}`:r3.Qq[a]??`Running ${a}`,n=(0,r3.qL)(e??a,function(e){let{path:t,target:n,command:r,i:i,...s}=e,a=e.content;if("string"!=typeof a)return s;try{let e=JSON.parse(a);if((0,nd.u)(e))return{...s,...e}}catch{}let l=a.trim().split("\n",1)[0]?.trim();return l?{...s,prose:l}:s}(i));return n?(0,r3.xv)(`${t} ${n}`):s?(0,r3.xv)(s):(0,r3.xv)(t)}let l=r3.K$[r]??(r?`Running ${r}`:"Working"),o=(0,r3.qL)(r,i);return o?(0,r3.xv)(`${l} ${o}`):s?(0,r3.xv)(s):(0,r3.xv)(l)}var r6=n("K");function r9(e,t,n){var r;for(e.set(t,{...n,output:(r=n.output).length<=2e5?r:`…[truncated]
19
- ${r.slice(-2e5)}`});e.size>200;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}function r7(e,t){e&&e!==t.activityRef.current&&(t.activityRef.current=e,t.callbacksRef.current?.onActivity?.(e))}function ie(e,t){if(!e.toolCalls?.length)return e;let n=e.toolCalls.map(e=>{let n=t.current?.get(e.id);return n?{...e,output:n.output,details:e.details||n.details||void 0,status:n.isError?"error":"success"}:e});return{...e,toolCalls:n}}function it(e,t){let n="string"==typeof e.toolCallId?e.toolCallId:void 0;n&&t.toolResultsRef.current?.set(n,{output:rT(e.content),details:e.details&&"object"==typeof e.details?e.details:void 0})}function ir(e,t){if(!e)return;let n=t.lastToolMessageRef.current;n?.toolCalls?.some(t=>t.id===e)&&t.callbacksRef.current?.onMessageUpdate?.(ie(n,t.toolResultsRef))}var ii=n("Kn"),is=n("g0");let ia={websocket:function(e,t){let n=null,r=null,i=0,s=!1,a=!1,l=()=>{let o=new WebSocket((0,ii.qq)(e));n=o,o.onopen=()=>{a||(i=0,s=!0,t.onOpen())},o.onmessage=e=>{let n;if(!a){try{n=JSON.parse(String(e.data))}catch{return}t.onFrame(n)}},o.onclose=()=>{n=null,a||(t.onClose(),!s||(i+=1)>4||(r=setTimeout(()=>{r=null,a||l()},Math.min(500*2**(i-1),8e3))))}};return l(),{close:()=>{a=!0,null!==r&&(clearTimeout(r),r=null);let e=n;n=null,e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close())}}},sse:function(e,t){let n=new EventSource((0,ii._m)(e)),r=!1;return n.onopen=()=>{r||t.onOpen()},n.onmessage=e=>{let n;if(!r){try{n=JSON.parse(e.data)}catch{return}t.onFrame(n)}},n.onerror=()=>{r||n.readyState===EventSource.CLOSED&&t.onClose()},{close:()=>{r=!0,n.onopen=null,n.onmessage=null,n.onerror=null,n.close()}}}};function il(e,t,n){return fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),...n?{signal:n}:{}})}async function io(e){let t=new AbortController,n=setTimeout(()=>t.abort(),1e4);try{if(await il(e,{type:"abort"},t.signal).then(()=>!0,()=>!1))return;await il(e,{type:"force_reset"}).catch(()=>null)}finally{clearTimeout(n)}}var ic=n("FL");let id="u"<typeof window?i.vJ:i.Nf;var iu=n("G1");async function ip(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a,signal:l}=e,o={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${tI()}`,content:""},c=!1;try{let e=await fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a?.map(e=>({name:e.name||e.file?.name,preview:e.preview}))}),signal:l});if(!e.ok||!e.body)throw Error(`SSE stream connection failed: HTTP ${e.status}`);if(await (0,iu.o)(e,(e,n)=>{try{let r=JSON.parse(n);switch(e){case"init":o.id=r.id||o.id,o.date=r.date||o.date,t.onInit?.(r);break;case"thinking_start":o.thinking={thought:"",isGenerating:!0},t.onThinkingStart?.(r);break;case"thinking_chunk":"object"==typeof o.thinking?o.thinking.thought=(o.thinking.thought||"")+r.delta:o.thinking={thought:r.delta,isGenerating:!0},t.onThinkingChunk?.(r);break;case"thinking_end":o.thinking={thought:r.thought,summary:r.summary,duration:r.duration,isGenerating:!1},t.onThinkingEnd?.(r);break;case"tool_start":o.toolCalls=[...o.toolCalls||[],r],t.onToolStart?.(r);break;case"tool_output_chunk":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,output:(e.output||"")+r.delta}:e),t.onToolOutputChunk?.(r);break;case"tool_end":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,...r}:e),t.onToolEnd?.(r);break;case"content_start":t.onContentStart?.();break;case"content_chunk":o.content=(o.content||"")+r.delta,t.onContentChunk?.(r);break;case"content_end":t.onContentEnd?.();break;case"summary":o.summary=r.summary,t.onSummary?.(r);break;case"done":return r.message&&(o=r.message),c=!0,t.onDone?.(r),!0;case"error":throw Error(r.error||"Stream error")}}catch(e){console.warn("SSE chunk parse error:",e)}},l),l?.aborted)return null;return c||t.onDone?.({message:o}),o}catch(n){if(l?.aborted)return null;return console.warn("Streaming failed, invoking fallback response handler:",n),t.onError?.(n),await im(e,t)}}async function im(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s}=e,a=tI(),l={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${a}`,timestamp:a,thinking:{duration:"1.2s",thought:`1. User prompt: "${r}".
18
+ `}),(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("div",{className:"relative w-4 h-4 rounded flex items-center justify-center shrink-0",children:[(0,r.Y)("div",{className:"absolute -inset-[1.5px] rounded-[5px] animate-spin",style:{background:"conic-gradient(from 0deg, #ff453a, #ff9f0a, #ffd60a, #30d158, #64d2ff, #0a84ff, #bf5af2, #ff375f, #ff453a)",animationDuration:"1.2s"}}),(0,r.Y)("div",{className:"relative w-full h-full rounded-[3px] bg-ink flex items-center justify-center text-canvas z-10 shadow-2xs",children:(0,r.Y)(O.A,{size:10,className:"text-canvas"})})]}),(0,r.FD)("div",{className:"flex items-center space-x-1.5 min-w-0 truncate",children:[d&&(0,r.Y)("span",{className:"text-ink/55 truncate shrink",children:d}),(0,r.Y)("span",{className:"font-semibold text-ink truncate",children:t}),(0,r.Y)("span",{className:"text-ink/40 shrink-0",children:"•"}),(0,r.FD)("span",{className:"text-ink/75 flex items-center space-x-1 shrink-0 font-medium",children:[(0,r.Y)("span",{className:"transition-all duration-300",children:c}),(0,r.FD)("span",{className:"inline-flex tracking-wider text-ink/80 ml-0.5",children:[(0,r.Y)("span",{className:"dot-anim-1 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-2 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-3 inline-block",children:"."})]})]})]})]})]})}function rx(e){let t=e.length-1;for(;t>=0&&rr(e[t]);)t--;return t}function rg(e){let t=Array(e.length),n=-1;for(let r=0;r<e.length;r++)t[r]=n,rr(e[r])||(n=r);return t}function rb(e,t){let n=e.length,r=Array(n).fill(null),i=rx(e),s=-1;for(let a=0;a<n;a++){let l=e[a];if("user"===l.role){s=-1;continue}if(rr(l)||(s=a),a!==n-1&&e[a+1]?.role!=="user"||s<0)continue;let o=e[s];t&&s===i&&"ai"===o.role||(r[a]={msg:o,ownerIndex:s,durationMs:function(e,t){var n;let r=(n=e[t],"number"==typeof n?.completedAt&&Number.isFinite(n.completedAt)?n.completedAt:rd(n));if(null===r)return null;let i=null;for(let n=t-1;n>=0;n--){if(e[n]?.role==="user"){i=rd(e[n]);break}let t=rd(e[n]);null!==t&&(i=t)}return null===i||r<=i?null:r-i}(e,s)??o.durationMs??null})}return r}function rv(e){let{className:t="",folders:n=[],selectedFolderId:s,setSelectedFolderId:a,inputValue:l,setInputValue:o,inputAttachments:c,setInputAttachments:d,onSend:u,isGenerating:p,appSettings:m={},messages:h=[],provider:f,providerNames:x,modelName:g,modelNames:b,rootPath:v,onThinkingLevelChange:k,onModelChange:y,sessionModel:A,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:z,generatingVerb:$,variant:j="desktop"}=e,[L,M]=(0,i.J0)(!1),P=(0,i.li)(null);(0,F.W)(P,()=>M(!1));let E=(0,i.li)(null),R=(0,i.Kr)(()=>n?.find(e=>e.id===s),[n,s]),{streamingIdx:I,footers:O}=(0,i.Kr)(()=>({streamingIdx:rx(h),footers:rb(h,p)}),[h,p]);return(0,i.vJ)(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[h.length]),(0,r.Y)("div",{className:`flex flex-col h-full bg-canvas ${"mobile"===j?"px-3 py-4":"p-8"} ${t}`,style:"mobile"===j?{paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:`mx-auto w-full max-w-[970px] flex flex-col min-h-0 space-y-3 ${h.length>0?"flex-1":"my-auto justify-center"}`,children:[0===h.length&&(0,r.FD)("div",{className:"relative shrink-0",ref:P,children:[(0,r.FD)("button",{type:"button",onClick:()=>M(!L),className:"group flex items-center space-x-1.5 px-1.5 py-1 rounded-md text-xs font-medium text-ink/75 hover:text-ink hover:bg-ink/5 focus-visible:bg-ink/5 transition-all outline-none cursor-pointer select-none",children:[(0,r.Y)(N.A,{size:13,className:"text-ink/50 group-hover:text-ink/80 transition-colors flex-shrink-0"}),(0,r.Y)("span",{className:"flex items-center space-x-1 max-w-[260px] truncate tracking-tight",children:(0,r.Y)("span",{children:R?R.name:"Select Workspace Context"})}),(0,r.Y)(Y.A,{size:13,className:`text-ink/40 group-hover:text-ink/70 flex-shrink-0 transition-transform duration-150 ${L?"rotate-180 text-ink/70":""}`})]}),L&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1.5 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg z-50 flex flex-col overflow-hidden text-xs py-1",children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5",children:"Target Workspace"}),(0,r.Y)("div",{className:"max-h-56 scrollbar-overlay-container scrollbar-overlay-static py-1",children:0===n.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/40 italic",children:"No workspaces available"}):n.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{a(e.id),M(!1)},className:`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors cursor-pointer ${s===e.id?"bg-ink/10 text-ink font-semibold":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 truncate pr-2",children:[(0,r.Y)(N.A,{size:12,className:s===e.id?"text-ink flex-shrink-0":"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"truncate font-medium",children:e.name})]}),s===e.id&&(0,r.Y)(D.A,{size:12,className:"text-ink flex-shrink-0"})]},e.id))})]})]}),h.length>0&&(0,r.Y)("div",{ref:E,className:"flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:h.map((e,t)=>{let n=h[t-1],i=p&&t===I&&"ai"===e.role,s="user"!==e.role&&n&&"user"!==n.role,a=O[t];return(0,r.FD)(w.FK,{children:[(0,r.Y)(rs,{msg:e,isStreaming:i,className:s?"mt-1":"mt-8"}),a&&(0,r.Y)(rm,{msg:a.msg,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:C??void 0,durationMs:a.durationMs})]},e.id)})})}),p&&(0,r.Y)(rf,{modelName:g,generatingVerb:$,provider:f,providerNames:x}),(0,r.Y)(ew,{value:l,onChange:o,rootPath:v,attachments:c,onAttachmentsChange:d,onSend:u,isGenerating:p,disabled:!s,className:"w-full shrink-0",appSettings:m,onThinkingLevelChange:k,onModelChange:y,sessionModel:A,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:z,variant:j})]})})}let rk=[{role:"user",width:"58%",lines:1},{role:"ai",width:"100%",lines:3},{role:"user",width:"40%",lines:1},{role:"ai",width:"92%",lines:2},{role:"user",width:"52%",lines:2},{role:"ai",width:"100%",lines:4}];function ry(e){let{row:t,index:n}=e;return(0,r.Y)("div",{className:`flex ${"user"===t.role?"justify-end":"justify-start"} mb-3`,children:(0,r.Y)("div",{className:"rounded-lg bg-ink/5 border border-ink/5 px-3 py-2 space-y-1.5",style:{width:t.width,maxWidth:"85%"},children:Array.from({length:t.lines},(e,i)=>(0,r.Y)("div",{className:"h-2.5 rounded bg-ink/8 animate-pulse",style:{width:i===t.lines-1?"62%":"100%",animationDelay:`${120*n+60*i}ms`}},i))})})}function rw(){let e=(0,i.Kr)(()=>rk,[]);return(0,r.FD)("div",{"aria-hidden":!0,className:"flex flex-col h-full min-h-0 overflow-hidden",children:[(0,r.Y)("div",{className:"flex-1 min-h-0 overflow-hidden px-3 py-3 pb-8 sm:p-4 sm:pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:e.map((e,t)=>(0,r.Y)(ry,{row:e,index:t},t))})}),(0,r.Y)("div",{className:"flex-shrink-0 px-3 pt-1 pb-3 sm:p-4 sm:pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"rounded-md border border-ink/20 bg-paper p-3 space-y-2",children:[(0,r.Y)("div",{className:"h-9 rounded bg-ink/8 animate-pulse",style:{animationDelay:"720ms"}}),(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.Y)("div",{className:"h-5 w-28 rounded bg-ink/8 animate-pulse",style:{animationDelay:"840ms"}}),(0,r.Y)("div",{className:"h-7 w-7 rounded bg-ink/8 animate-pulse",style:{animationDelay:"960ms"}})]})]})})})]})}function rN(){return(0,r.Y)("div",{className:"flex justify-center py-2",role:"status",children:(0,r.FD)("div",{className:"flex items-center gap-1.5 text-ink/40 text-[11px] font-mono",children:[(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse"}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"150ms"}}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"300ms"}})]})})}function rY(e){let{content:t,isOmpSession:n,undoing:s,onClose:a,onConfirm:l}=e;return(0,i.vJ)(()=>{let e=e=>{"Escape"!==e.key||s||(e.preventDefault(),a())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,s]),(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",onClick:s?void 0:a,role:"dialog","aria-modal":"true","aria-label":"Confirm undo",children:(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-xl shadow-xl w-[min(94vw,420px)] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[(0,r.Y)(eY.A,{size:16,className:"text-ink/70 shrink-0"}),(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"Undo message?"})]}),(0,r.FD)("div",{className:"px-4 py-4 space-y-3",children:[(0,r.Y)("div",{className:"rounded-lg border border-ink/10 bg-canvas/50 px-3 py-2 text-[12px] text-ink/80 leading-relaxed max-h-28 overflow-y-auto scrollbar-overlay-container",children:t||"Empty message or attachment-only prompt"}),(0,r.Y)("p",{className:"text-[11.5px] leading-relaxed text-ink/60",children:n?"The timeline and agent context rewind to before this message. Its reply and everything after it are removed; the text returns to the composer for editing.":"This message and everything after it are removed from the timeline. The text returns to the composer for editing."})]}),(0,r.FD)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[(0,r.Y)("button",{type:"button",onClick:a,disabled:s,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40 disabled:cursor-not-allowed",children:"Cancel"}),(0,r.FD)("button",{type:"button",autoFocus:!s,onClick:l,disabled:s,className:"flex items-center gap-2 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:[s&&(0,r.Y)(e2.A,{size:13,className:"animate-spin shrink-0"}),s?"Rewinding…":"Undo"]})]})]})})}function rD(e){let{initialContent:t,onClose:n,onSend:s,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c}=e,[d,u]=(0,i.J0)(t),[p,m]=(0,i.J0)([]);return(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",children:(0,r.FD)("div",{className:"bg-canvas border border-ink/15 rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10 bg-paper",children:[(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"New Chat"}),(0,r.Y)("button",{onClick:n,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors",children:(0,r.Y)(j.A,{size:14})})]}),(0,r.FD)("div",{className:"p-4 flex-1 scrollbar-overlay-container scrollbar-overlay-static",children:[(0,r.Y)("p",{className:"text-xs text-ink/60 mb-3",children:"Start a new session in this workspace based on the selected message."}),(0,r.Y)(ew,{value:d,onChange:u,attachments:p,onAttachmentsChange:m,onSend:e=>{s(d,e),n()},isGenerating:!1,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c})]})]})})}var rF=n("Kv"),rA=n("M"),rC=n("Uo"),rS=n("T");function rT(e){if("string"==typeof e)return e;if(!Array.isArray(e))return"";let t=[];for(let n of e)(0,nd.u)(n)&&"text"===n.type&&"string"==typeof n.text&&t.push(n.text);return t.join("\n")}function rz(e,t){if(!e)return"";for(let n of t){let t=e[n];if("string"==typeof t)return t}return""}let r$=["command","cmd","CommandLine","commandLine"],rj=["path","TargetFile","targetFile","FilePath","filePath","AbsolutePath","file"],rL=new Set(["aborted","error"]);function rM(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=new Date(e).getTime();return Number.isNaN(t)?void 0:t}}function rP(e){return"string"==typeof e?e:e&&"object"==typeof e?rT(e.content):""}function rE(e){let t,n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("custom"===e.role){if("session_exit"===e.customType)return null;let t=e.content,n=("string"==typeof t?t:Array.isArray(t)?t.map(e=>e&&"object"==typeof e&&"text"===e.type?e.text??"":"").join(""):"").replace(/<\/?system-notice[^>]*>/g,"").trim();return n?{id:"string"==typeof e.id?e.id:`notice-${Date.now()}`,role:"ai",content:"",notice:n}:null}let r=function(e){let t={toolCalls:[],inlineOutputs:new Map,textParts:[]};if("string"==typeof e)return t.textParts.push(e),t;if(!Array.isArray(e))return t;for(let n of e)if((0,nd.u)(n))if("thinking"===n.type)"string"==typeof n.thinking?t.thinking=n.thinking:"string"==typeof n.text&&(t.thinking=n.text);else if("toolCall"===n.type){let e="string"==typeof n.id?n.id:`tool-${Math.random().toString(36).slice(2,10)}`,r="string"==typeof n.name?n.name:"tool",i=n.arguments??n.input,s=(0,nd.u)(i)?i:void 0,a=rz(s,r$),l=rz(s,rj)||(s?(0,nO.f$)(s):void 0),o="string"==typeof s?.i?s.i:void 0,c=a||l;t.toolCalls.push({id:e,name:r,title:c?`${r} — ${c}`:r,intent:o,target:l||void 0,command:a||void 0,input:s&&Object.keys(s).length>0?s:void 0}),o&&!t.intent&&(t.intent=o),t.inlineOutputs.set(e,"")}else if("toolResult"===n.type){let e="string"==typeof n.toolCallId?n.toolCallId:void 0,r="string"==typeof n.text?n.text:"";if(e&&t.inlineOutputs.has(e))t.inlineOutputs.set(e,r);else if(r&&t.toolCalls.length>0){let e=t.toolCalls[t.toolCalls.length-1];t.inlineOutputs.set(e.id,r)}}else"text"===n.type&&"string"==typeof n.text&&t.textParts.push(n.text);return t}(e.content),i="string"==typeof e.id?e.id:`msg-${e.timestamp??Date.now()}-ai`,s="user"===e.role?"user":"ai",a="number"==typeof e.timestamp?tI(e.timestamp):void 0,l="string"==typeof e.attribution?e.attribution:void 0,o=rM(e.timestamp)??rM(e.startedAt),c="number"==typeof e.duration?e.duration:"number"==typeof e.durationMs?e.durationMs:void 0,d=rM(e.completedAt)??(void 0!==o&&void 0!==c?o+c:void 0),u="string"==typeof e.provider?e.provider:void 0,p=-1===(t=r.textParts.findIndex(e=>{let t=e1(e);return void 0!==t&&eQ(t.tag)}))?void 0:t;if("developer"===e.role||"system"===e.role||void 0!==p){let e=void 0!==p?r.textParts[p]:r.textParts.join("\n"),t=void 0!==p?e.trim():e.replace(/<\/?system-reminder[^>]*>/g,"").trim();return t?{id:i,role:"ai",date:a?`Today, ${a}`:void 0,timestamp:a,content:"",notice:t}:null}if("user"===s)return{id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,startedAt:o,content:function(e){let t=e.match(/(?:^|\n{2})\s*Attached file: /);if(!t||void 0===t.index)return e;let n=e.slice(0,t.index),r=e.slice(t.index+t[0].length);return/^[^\n]+\n```[a-z]*\n/.test(r)?n.trim():e}(r.textParts.join("\n")),attribution:l,attachments:(function(e){if(!Array.isArray(e))return[];let t=[],n=0;for(let r of e){if(!(0,nd.u)(r)||"image"!==r.type)continue;let e="string"==typeof r.data?r.data:void 0,i="string"==typeof r.mimeType?r.mimeType:"image/png";if(!e)continue;n+=1;let s=(i.split("/")[1]||"png").replace(/[^a-z0-9]/gi,"")||"png";t.push({id:`att-${n}`,name:`attachment-${n}.${s}`,preview:`data:${i};base64,${e}`,type:i})}return t})(e.content).map(e=>({id:e.id,name:e.name,preview:e.preview,type:e.type}))};let m=r.toolCalls.map(e=>{var t,r;let i,s,a,l;return t=e,r={streaming:n},s=t.input,a=(0,nd.u)(s)?Object.fromEntries(Object.entries(s).filter(e=>{let[t]=e;return"i"!==t})):s,l=r.isError?"error":void 0!==r.output?"success":r.streaming?"running":"success",{id:t.id,type:(i=(t.name||"").toLowerCase()).includes("bash")||i.includes("terminal")||i.includes("shell")||i.includes("run")?"bash":i.includes("write")||i.includes("edit")||i.includes("patch")||i.includes("apply")?"edit_file":i.includes("create")?"create_file":i.includes("read")||i.includes("view")||i.includes("list")?"read_file":i.includes("grep")||i.includes("glob")?"grep":i.includes("search")||i.includes("find")?"search_fs":i.includes("web")||i.includes("fetch")||i.includes("http")?"web_search":i.includes("todo")?"todo":i.includes("task")?"task":i.includes("lsp")?"lsp":i.includes("eval")?"eval":i.includes("github")?"github":i.includes("security")?"security_scan":"custom",name:t.name,title:t.title,intent:t.intent,target:t.target,command:t.command,input:a&&Object.keys(a).length>0?a:void 0,output:r.output,status:l}}),h={id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,attribution:l,model:"string"==typeof e.model?e.model:void 0,provider:u,startedAt:o,completedAt:d,durationMs:c,usage:e.usage&&"object"==typeof e.usage?e.usage:void 0,content:r.textParts.join("\n"),intent:r.intent,thinking:r.thinking?{thought:r.thinking,isGenerating:n}:e.thinking,toolCalls:m.length>0?m:e.toolCalls,summary:"string"==typeof e.summary?e.summary:void 0,error:e.error??function(e){let t;if("string"==typeof(t=e.stopReason)&&rL.has(t)||"number"==typeof e.errorStatus||"string"==typeof e.errorMessage)return{status:"number"==typeof e.errorStatus?e.errorStatus:void 0,id:"number"==typeof e.errorId?e.errorId:void 0,message:"string"==typeof e.errorMessage?e.errorMessage:void 0,stopReason:"string"==typeof e.stopReason?e.stopReason:void 0}}(e)};return h.content||h.thinking||h.toolCalls&&0!==h.toolCalls.length||h.intent||h.error||h.summary||h.notice?h:null}function rR(e,t){let n=[];for(let r of e){if((0,nd.u)(r)){let e="string"==typeof r.type?r.type:"";if("custom"===e||"custom_message"===e){let e="string"==typeof r.customType?r.customType:"";if("session_exit"===e)continue;if("launch-completion"===e||"string"==typeof r.content){let e=("string"==typeof r.content?r.content:"").replace(/<\/?system-notice[^>]*>/g,"").trim();e&&n.push({id:"string"==typeof r.id?r.id:`notice-${Date.now()}`,role:"ai",content:"",notice:e,date:"string"==typeof r.timestamp?new Date(r.timestamp).toISOString():void 0});continue}}if(e&&"message"!==e)continue}let e=function(e){if(!(0,nd.u)(e))return null;let t=(0,nd.u)(e.message)?e.message:null;if(!t)return e;let n={...t};return void 0===n.id&&"string"==typeof e.id&&(n.id=e.id),void 0===n.timestamp&&"number"==typeof e.timestamp&&(n.timestamp=e.timestamp),n}(r);if(!e)continue;if("toolResult"===e.role){let t="string"==typeof e.toolCallId?e.toolCallId:void 0,r=rT(e.content),i=(0,nd.u)(e.details)?e.details:void 0,s=!0===e.isError;for(let a=n.length-1;a>=0;a--){let l=n[a].toolCalls?.find(n=>t?n.id===t:n.name===e.toolName);if(l){r&&(l.output=r),i&&(l.details=i),l.status=s?"error":"success";break}}continue}let i=rE(e,t);i&&n.push(i)}return n}function rI(e,t){if(0===t.length)return e;let n=new Map(e.map((e,t)=>[e.id,t])),r=[...e];for(let e of t){let t=n.get(e.id);void 0===t?(n.set(e.id,r.length),r.push(e)):r[t]=e}return r}function rO(e,t,n){if(!(0,nd.u)(e)||!Array.isArray(e.messages))return null;let r="number"==typeof e.fromByte?e.fromByte:t;return{sessionFile:"string"==typeof e.sessionFile&&e.sessionFile?e.sessionFile:n??"",fromByte:r,nextByte:"number"==typeof e.nextByte?e.nextByte:r,reset:!0===e.reset,messages:e.messages,totalBytes:"number"==typeof e.totalBytes?e.totalBytes:void 0}}async function rJ(e,t,n,r){try{let i=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagent_messages",subagentId:t,...n?{sessionFile:n}:{},fromByte:r})});if(!i.ok)return null;let s=await i.json().catch(()=>null),a=(0,nd.u)(s)&&"data"in s?s.data:s;return rO(a,r,n)}catch{return null}}let r_=new Map;async function rW(e,t,n){let r=`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}?fromByte=${n}`,i=r_.get(r);if(i)return i;let s=()=>{},a=new Promise(e=>{s=()=>{r_.get(r)===a&&r_.delete(r)},(async()=>{try{let t=await fetch(r);if(!t.ok)return e(null);let i=await t.json().catch(()=>null),s=(0,nd.u)(i)&&"page"in i?i.page:i;if(null==s)return e(null);e(rO(s,n,void 0))}catch{e(null)}})()});return a.then(s,s),r_.set(r,a),a}let rK={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function rU(e){return"completed"===e||"failed"===e||"aborted"===e}function rB(e,t){if(!e||e.id!==t.id)return t;let n={...e,...t,agent:"subagent"!==t.agent?t.agent:e.agent,index:e.index>=0?e.index:t.index,status:rU(e.status)&&!rU(t.status)?e.status:t.status},r={...e.progress,...t.progress};return Object.keys(r).length>0?n.progress=r:delete n.progress,n}function rq(e){let[t,n]=(0,i.J0)(void 0),r=(0,i.li)(e);return r.current=e,(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,T.xo)();if(!e)return;let i=r.current(t);void 0!==i&&n(i)}catch{}};t();let i=(0,T.Sy)(t);return()=>{e=!1,i()}},[]),t}function rH(e){if(e.modelList?.length)return Object.fromEntries(e.modelList.map(e=>[e.id,e.name||e.id]))}let rG={started:"running",completed:"done",failed:"failed",aborted:"aborted"};function rV(e){let{sessionId:t,subagent:n,onBack:s,provider:a,providerNames:l,className:o=""}=e,{messages:c,isLoading:d,status:u,isActive:p}=function(e,t,n){let[r,s]=(0,i.J0)([]),[a,l]=(0,i.J0)(t),[o,c]=(0,i.J0)(!1),d=t?.id??null,u=!!(e&&d),p=(0,i.li)(0),m=(0,i.li)(e);m.current=e;let h=(0,i.li)(t);h.current=t;let f=(0,i.li)(n);f.current=n;let x=(0,i.li)(0),g=(0,i.li)(void 0),b=(0,i.li)(!1),v=(0,i.li)(!1),k=(0,i.li)(!1),y=(0,i.li)(null),w=(0,i.li)(()=>{}),N=(0,i.hb)(async()=>{let e=m.current,t=h.current;if(!e||!t||!b.current)return;if(v.current){k.current=!0;return}v.current=!0;let n=p.current;try{let r=await rJ(e,t.id,g.current,x.current);if(n!==p.current||!r)return;g.current=r.sessionFile||g.current;let i=rR(r.messages,!0);r.reset?(s(i),x.current=r.nextByte):(s(e=>rI(e,i)),x.current=Math.max(x.current,r.nextByte))}finally{v.current=!1,k.current&&(k.current=!1,w.current())}},[]);return(0,i.vJ)(()=>{t&&l(e=>rB(e,t))},[t]),(0,i.vJ)(()=>{if(!u)return;let e=e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=e.target instanceof HTMLElement?e.target:null,n=t?.tagName;"INPUT"===n||"TEXTAREA"===n||t?.isContentEditable||f.current()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]),(0,i.vJ)(()=>{if(!e||!d){s([]),l(null),c(!1);return}let t=++p.current,n=h.current,r=()=>t===p.current,i=n?.source==="history";s([]),l(n),c(!0),x.current=0,g.current=n?.sessionFile,b.current=!1;let a=()=>{null===y.current&&(y.current=window.setTimeout(()=>{y.current=null,N()},150))};w.current=a;let o=async()=>{let t=0,a=g.current,o=i||!n?.sessionFile,u=[];for(let n=0;n<20;n++){let n=o?await rW(e,d,t):await rJ(e,d,a,t);if(!r()||!n&&!o&&0===t&&(o=!0,n=await rW(e,d,0),!r()))return;if(!n)break;a=n.sessionFile||a;let i=rR(n.messages,!1);if(u=n.reset?i:rI(u,i),n.nextByte<=t||(t=n.nextByte,void 0!==n.totalBytes&&t>=n.totalBytes))break}r()&&(g.current=a,x.current=t,b.current=!o,s(e=>rI(e,u)),c(!1),o&&l(e=>e&&!rU(e.status)?{...e,status:"completed"}:e))},u=t=>{let n=t.detail;return n&&n.sessionId===e?n:null},m=e=>{let t=u(e);if(!t)return;let n=(0,rS.bH)(t.payload);n&&n.id===d&&(l(e=>rB(e,n)),a())},f=e=>{let t=u(e);if(!t)return;let n=(0,nd.u)(t.payload)?t.payload:null;if(!n)return;let r="string"==typeof n.id?n.id:null;if(r&&r!==d)return;if(!r){let e="number"==typeof n.index?n.index:null;if(null===e||e!==(h.current?.index??-1))return}let i=(0,rS.mq)(n);i&&l(e=>{if(!e||e.id!==d)return e;let t={...e,progress:{...e.progress,...i}};return i.status&&!rU(e.status)&&(t.status=rK[i.status]??e.status),t})},v=e=>{let t=u(e);if(!t)return;let n=(0,nd.u)(t.payload)?t.payload:null;n&&n.id===d&&a()};return i||(window.addEventListener("subagent_lifecycle",m),window.addEventListener("subagent_progress",f),window.addEventListener("subagent_event",v)),o(),()=>{p.current+=1,b.current=!1,null!==y.current&&(window.clearTimeout(y.current),y.current=null),i||(window.removeEventListener("subagent_lifecycle",m),window.removeEventListener("subagent_progress",f),window.removeEventListener("subagent_event",v))}},[e,d,N]),{messages:r,isLoading:o,status:a,isActive:u}}(t,n,s),m=rq(rH)??{},h=(0,i.li)(null),f=u?.status??n?.status??"started",x="started"===f;(0,i.vJ)(()=>{let e=h.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>cancelAnimationFrame(t)},[c.length,x]);let{streamingIdx:g,footers:b,prevNonNoticeIdx:v}=(0,i.Kr)(()=>({streamingIdx:rx(c),footers:rb(c,x),prevNonNoticeIdx:rg(c)}),[c,x]);if(!n||!p)return null;let k=u?.progress??n.progress,y=k?.resolvedModel??n.agent,N=(0,ti.Rk)(k?.tokens),Y=N?`${N} tok`:"",D=u?.task??u?.assignment??u?.description??n.task??n.assignment??n.description,F=D?D.replace(/\$0(\.00*)?/g,"").trim():void 0;return(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas ${o}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2.5 border-b border-ink/15 bg-paper px-3 py-2 flex-shrink-0",children:[(0,r.Y)("button",{type:"button",onClick:s,title:"Back to session",className:"flex items-center justify-center w-7 h-7 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors shrink-0 cursor-pointer",children:(0,r.Y)(rF.A,{size:14})}),(0,r.Y)(rC.l,{status:f,live:x,size:12}),(0,r.Y)(O.A,{size:13,className:"text-ink/60 shrink-0"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.Y)("span",{className:"font-mono text-[12px] font-semibold text-ink truncate",children:u?.agent??n.agent}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:rG[f]})]}),(0,r.Y)("p",{className:"truncate text-[11px] text-ink/55 font-sans",children:F??"Subagent transcript"})]}),Y&&(0,r.Y)("span",{className:"hidden sm:inline shrink-0 font-mono text-[10px] text-ink/45",children:Y})]}),(0,r.Y)("div",{ref:h,className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-overlay-container timeline-scrollbar-visible p-4 pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:d&&0===c.length?(0,r.FD)("div",{className:"flex items-center justify-center gap-2 py-12 text-[11px] font-mono text-ink/50",children:[(0,r.Y)(e2.A,{size:14,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading transcript…"})]}):0===c.length?(0,r.Y)("div",{className:"py-12 text-center text-[11.5px] font-mono text-ink/45",children:"No transcript messages yet."}):c.map((e,t)=>{let n=x&&t===g&&"ai"===e.role,i=v[t],s=i>=0?c[i]:null,o=!!("user"!==e.role&&s&&"user"!==s.role),d=b[t];return(0,r.FD)(w.FK,{children:[(0,r.Y)(rs,{msg:e,isStreaming:n,isPrevAssistant:o,className:rr(e)?"mt-3 mb-1":o?"mt-1":"mt-3"}),d&&(0,r.Y)(rm,{msg:d.msg,provider:a,providerNames:l,modelName:y,modelNames:m,durationMs:d.durationMs})]},e.id)})})}),(0,r.Y)("div",{className:"flex-shrink-0 p-4 pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"flex items-center justify-center gap-2 rounded-lg border border-ink/15 bg-paper px-3 py-2 text-[11px] font-mono text-ink/50 select-none",children:[(0,r.Y)(rA.A,{size:11,className:"text-ink/45"}),(0,r.Y)("span",{children:"Read-only transcript — subagents cannot receive messages"})]})})})]})}var rZ=n("zi");let rQ=(0,a.ph)(function(e){let{messages:t,isGenerating:n,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,onUndo:d,onRetry:u,onNewChat:p,isMobile:m=!1}=e,{streamingIdx:h,footers:f,prevNonNoticeIdx:x}=(0,i.Kr)(()=>({streamingIdx:rx(t),footers:rb(t,n),prevNonNoticeIdx:rg(t)}),[t,n]);return(0,r.Y)(r.FK,{children:t.map((e,i)=>{let g=t[i-1],b=n&&i===h&&"ai"===e.role,v="user"!==e.role&&g&&"user"!==g.role&&!rr(g),k=x[i],y=k>=0?t[k]:null,N=!!("user"!==e.role&&y&&"user"!==y.role),Y=f[i];return(0,r.FD)(w.FK,{children:[(0,r.Y)(rs,{msg:e,isStreaming:b,onUndo:d,onNewChat:p,isPrevAssistant:N,className:rr(e)?"mt-3 mb-1":v?"mt-1":"mt-3"}),Y&&(0,r.Y)(rm,{msg:Y.msg,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,durationMs:Y.durationMs,onRetry:u,onNewChat:p,isMobile:m})]},e.id)})})});function rX(e){let{userMessages:t,onScrollTo:n}=e,[s,a]=(0,i.J0)(null);return 0===t.length?null:(0,r.Y)("div",{className:"absolute right-0.5 top-1/2 -translate-y-1/2 z-20 flex flex-col items-center py-4 w-6",onMouseLeave:()=>a(null),children:t.map((e,t)=>{let i=s===t;return(0,r.FD)("div",{className:"relative flex items-center justify-center w-full py-[3px] cursor-pointer",onMouseEnter:()=>a(t),onClick:()=>n(e.id),children:[(0,r.Y)("button",{className:`block h-px rounded-full transition-all duration-200 ease-out ${(e=>{if(null===s)return"w-3";let t=Math.abs(e-s);return 0===t?"w-6":1===t?"w-4":"w-3"})(t)} ${i?"bg-ink h-[2px]":"bg-ink/25"}`,"aria-label":`Jump to your message #${t+1}`}),(0,r.FD)("div",{className:`absolute right-full mr-3 top-1/2 transform -translate-y-1/2 w-64 p-3 bg-ink text-canvas text-xs rounded-md shadow-lg pointer-events-none transition-opacity duration-200 z-30 ${i?"opacity-100":"opacity-0"}`,children:[(0,r.Y)("div",{className:"line-clamp-3 whitespace-pre-wrap leading-relaxed",children:e.content}),(0,r.Y)("div",{className:"absolute top-1/2 -right-1 transform -translate-y-1/2 w-2 h-2 bg-ink rotate-45"})]})]},`minimap-${e.id}`)})})}function r0(e){let{isMobile:t,userMessages:n,onScrollTo:i,scrollRef:s,contentRef:a,handleScroll:l,isScrolling:o,loadingOlder:c,hasMore:d,loadOlderError:u,loadOlder:p,messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:w,showScrollBottom:N,jumpToBottom:Y}=e;return(0,r.FD)(r.FK,{children:[!t&&(0,r.Y)(rX,{userMessages:n,onScrollTo:i}),(0,r.Y)("div",{ref:s,onScroll:l,className:`flex-1 scrollbar-overlay-container overscroll-contain scroll-smooth overflow-x-hidden ${t?"px-3 py-3 pb-8":"p-4 pb-10"} ${o?"timeline-scrollbar-visible":"timeline-scrollbar-hidden"}`,children:(0,r.FD)("div",{ref:a,className:"mx-auto w-full max-w-[970px]",children:[(c||d||u)&&(0,r.Y)("div",{className:"pb-1",children:c?(0,r.Y)(rN,{}):(0,r.Y)("button",{type:"button",onClick:p,className:`block mx-auto px-3 py-1 rounded-full border text-[11px] font-mono transition-colors ${u?"border-error/40 text-error hover:border-error":"border-ink/15 text-ink/50 hover:text-ink hover:border-ink/30"}`,children:u?"Failed to load — retry":"Load earlier messages"})}),(0,r.Y)(rQ,{messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:w,isMobile:t})]})}),N&&(0,r.Y)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 z-20",children:(0,r.Y)("button",{onClick:()=>Y("smooth"),className:"flex items-center justify-center w-8 h-8 rounded-full border border-ink/20 bg-paper text-ink/60 hover:text-ink hover:bg-ink/5 transition-all shadow-sm",title:"Scroll to bottom",children:(0,r.Y)(rZ.A,{size:16})})})]})}var r1=n("b");let r5={steer:"steer",followup:"follow-up"};function r2(e){let{queue:t,onReorder:n,onRemove:s,isSteering:a=!1,onEdit:l,onSendNow:o}=e,c=(0,i.li)(null),d=(0,i.li)(null),u=()=>{if(null===c.current||null===d.current)return;let e=t.map(e=>e.id),r=e.splice(c.current,1)[0];e.splice(d.current,0,r),c.current=null,d.current=null,n?.(e)};if(0===t.length)return null;let p=a?"steer":"followup";return(0,r.Y)("div",{className:"max-h-[150px] scrollbar-overlay-container scrollbar-overlay-static mb-2 space-y-1",children:t.map((e,t)=>(0,r.FD)("div",{draggable:!0,onDragStart:()=>{c.current=t},onDragEnter:()=>{d.current=t},onDragEnd:u,onDragOver:e=>e.preventDefault(),className:"flex items-center gap-2 px-2 py-1.5 bg-paper border border-ink/10 rounded shadow-sm text-xs group hover:border-ink/30 transition-colors",children:[(0,r.Y)("div",{className:"cursor-grab text-ink/40 group-hover:text-ink/80",children:(0,r.Y)(E.A,{size:14})}),(0,r.Y)("span",{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded ${"steer"===p?"bg-error/10 text-error":"bg-ink/10 text-ink/70"}`,children:r5[p]}),(0,r.Y)("div",{className:"flex-1 truncate text-ink/80 pr-2",children:e.text||(e.attachments.length>0?`[${e.attachments.length} attachment${e.attachments.length>1?"s":""}]`:"Empty message")}),o&&"followup"===p&&(0,r.Y)("button",{onClick:()=>o(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Send Now (Steering)",children:(0,r.Y)(C.A,{size:12})}),l&&(0,r.Y)("button",{onClick:()=>l(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Edit",children:(0,r.Y)(r1.A,{size:12})}),s&&(0,r.Y)("button",{onClick:()=>s(e.id),className:"text-ink/40 hover:text-error opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove",children:(0,r.Y)(j.A,{size:14})})]},e.id))})}function r4(e){let{isMobile:t,isGenerating:n,modelName:i,generatingVerb:s,provider:a,providerNames:l,messageQueue:o,onRemoveQueueItem:c,onReorderQueue:d,onEditQueueItem:u,onSendNowQueueItem:p,steeringQueue:m,setSteeringQueue:h,inputValue:f,setInputValue:x,rootPath:g,attachments:b,setAttachments:v,onSend:k,onStop:y,appSettings:w,onThinkingLevelChange:N,onModelChange:Y,accessMode:D,onAccessModeChange:F,composerModelRef:A,sessionModel:C,sessionThinkingLevel:S,variant:T}=e;return(0,r.Y)("div",{className:`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${t?"px-3 pt-1":"p-4 pt-1"}`,style:t?{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:"mx-auto w-full max-w-[970px]",children:[n&&(0,r.Y)(rf,{modelName:i,generatingVerb:s,provider:a,providerNames:l}),(0,r.Y)(r2,{queue:o,onRemove:c,onReorder:d,onEdit:u,onSendNow:p}),(0,r.Y)(r2,{queue:m,onRemove:e=>h(t=>t.filter(t=>t.id!==e)),onReorder:e=>h(t=>{let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>n.get(e)).filter(e=>!!e)}),isSteering:!0}),(0,r.Y)(ew,{value:f,onChange:x,rootPath:g,attachments:b,onAttachmentsChange:v,onSend:k,isGenerating:n,onStop:y,appSettings:w,onThinkingLevelChange:N,onModelChange:Y,accessMode:D,onAccessModeChange:F,composerModelRef:A,sessionModel:C,sessionThinkingLevel:S,variant:T})]})})}var r3=n("zG");function r8(e){let t,n=(0,r3.oJ)(e.name)??"",r=r3.YT[n.toLowerCase()]??n.toLowerCase(),i=(t={...(0,nd.u)(e.args)?e.args:(0,nd.u)(e.input)?e.input:{}},e.command&&void 0===(0,r3.oJ)(t.command)&&void 0===(0,r3.oJ)(t.cmd)&&(t.command=e.command),e.target&&void 0===(0,r3.oJ)(t.path)&&(t.path=e.target),t),s=(0,r3.oJ)(e.intent)??(0,r3.Up)(i,["i"]),a=function(e,t){let n=(0,r3.Up)(e,["path","target"])??(0,r3.oJ)(t.target)??(0,r3.oJ)(t.command);if(n&&n.startsWith("xd://"))return n.slice(5).split(/[/?#\s]/)[0]||void 0}(i,e);if(a){let e=a.startsWith("mcp__")?a.slice(5):void 0,t=e?`Running ${e}`:r3.Qq[a]??`Running ${a}`,n=(0,r3.qL)(e??a,function(e){let{path:t,target:n,command:r,i:i,...s}=e,a=e.content;if("string"!=typeof a)return s;try{let e=JSON.parse(a);if((0,nd.u)(e))return{...s,...e}}catch{}let l=a.trim().split("\n",1)[0]?.trim();return l?{...s,prose:l}:s}(i));return n?(0,r3.xv)(`${t} ${n}`):s?(0,r3.xv)(s):(0,r3.xv)(t)}let l=r3.K$[r]??(r?`Running ${r}`:"Working"),o=(0,r3.qL)(r,i);return o?(0,r3.xv)(`${l} ${o}`):s?(0,r3.xv)(s):(0,r3.xv)(l)}var r6=n("K");function r9(e,t,n){var r;for(e.set(t,{...n,output:(r=n.output).length<=2e5?r:`…[truncated]
19
+ ${r.slice(-2e5)}`});e.size>200;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}function r7(e,t){e&&e!==t.activityRef.current&&(t.activityRef.current=e,t.callbacksRef.current?.onActivity?.(e))}function ie(e,t){if(!e.toolCalls?.length)return e;let n=e.toolCalls.map(e=>{let n=t.current?.get(e.id);return n?{...e,output:n.output,details:e.details||n.details||void 0,status:n.isError?"error":"success"}:e});return{...e,toolCalls:n}}function it(e,t){let n="string"==typeof e.toolCallId?e.toolCallId:void 0;n&&t.toolResultsRef.current?.set(n,{output:rT(e.content),details:e.details&&"object"==typeof e.details?e.details:void 0})}function ir(e,t){if(!e)return;let n=t.lastToolMessageRef.current;n?.toolCalls?.some(t=>t.id===e)&&t.callbacksRef.current?.onMessageUpdate?.(ie(n,t.toolResultsRef))}var ii=n("Kn"),is=n("g0");let ia={websocket:function(e,t){let n=null,r=null,i=0,s=!1,a=!1,l=()=>{let o=new WebSocket((0,ii.qq)(e));n=o,o.onopen=()=>{a||(i=0,s=!0,t.onOpen())},o.onmessage=e=>{let n;if(!a){try{n=JSON.parse(String(e.data))}catch{return}t.onFrame(n)}},o.onclose=()=>{n=null,a||(t.onClose(),!s||(i+=1)>4||(r=setTimeout(()=>{r=null,a||l()},Math.min(500*2**(i-1),8e3))))}};return l(),{close:()=>{a=!0,null!==r&&(clearTimeout(r),r=null);let e=n;n=null,e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close())}}},sse:function(e,t){let n=new EventSource((0,ii._m)(e)),r=!1;return n.onopen=()=>{r||t.onOpen()},n.onmessage=e=>{let n;if(!r){try{n=JSON.parse(e.data)}catch{return}t.onFrame(n)}},n.onerror=()=>{r||n.readyState===EventSource.CLOSED&&t.onClose()},{close:()=>{r=!0,n.onopen=null,n.onmessage=null,n.onerror=null,n.close()}}}};function il(e,t,n){return fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),...n?{signal:n}:{}})}async function io(e){let t=new AbortController,n=setTimeout(()=>t.abort(),1e4);try{if(await il(e,{type:"abort"},t.signal).then(()=>!0,()=>!1))return;await il(e,{type:"force_reset"}).catch(()=>null)}finally{clearTimeout(n)}}var ic=n("FL");function id(e){return`/api/sessions/${encodeURIComponent(e)}/queue`}async function iu(e){if(!e.ok)return null;let t=await e.json().catch(()=>null);return Array.isArray(t?.queue)?t.queue:null}let ip="u"<typeof window?i.vJ:i.Nf;var im=n("G1");async function ih(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a,signal:l}=e,o={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${tI()}`,content:""},c=!1;try{let e=await fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a?.map(e=>({name:e.name||e.file?.name,preview:e.preview}))}),signal:l});if(!e.ok||!e.body)throw Error(`SSE stream connection failed: HTTP ${e.status}`);if(await (0,im.o)(e,(e,n)=>{try{let r=JSON.parse(n);switch(e){case"init":o.id=r.id||o.id,o.date=r.date||o.date,t.onInit?.(r);break;case"thinking_start":o.thinking={thought:"",isGenerating:!0},t.onThinkingStart?.(r);break;case"thinking_chunk":"object"==typeof o.thinking?o.thinking.thought=(o.thinking.thought||"")+r.delta:o.thinking={thought:r.delta,isGenerating:!0},t.onThinkingChunk?.(r);break;case"thinking_end":o.thinking={thought:r.thought,summary:r.summary,duration:r.duration,isGenerating:!1},t.onThinkingEnd?.(r);break;case"tool_start":o.toolCalls=[...o.toolCalls||[],r],t.onToolStart?.(r);break;case"tool_output_chunk":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,output:(e.output||"")+r.delta}:e),t.onToolOutputChunk?.(r);break;case"tool_end":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,...r}:e),t.onToolEnd?.(r);break;case"content_start":t.onContentStart?.();break;case"content_chunk":o.content=(o.content||"")+r.delta,t.onContentChunk?.(r);break;case"content_end":t.onContentEnd?.();break;case"summary":o.summary=r.summary,t.onSummary?.(r);break;case"done":return r.message&&(o=r.message),c=!0,t.onDone?.(r),!0;case"error":throw Error(r.error||"Stream error")}}catch(e){console.warn("SSE chunk parse error:",e)}},l),l?.aborted)return null;return c||t.onDone?.({message:o}),o}catch(n){if(l?.aborted)return null;return console.warn("Streaming failed, invoking fallback response handler:",n),t.onError?.(n),await ix(e,t)}}async function ix(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s}=e,a=tI(),l={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${a}`,timestamp:a,thinking:{duration:"1.2s",thought:`1. User prompt: "${r}".
20
20
  2. Target workspace: ${s||"Workspace"}.
21
21
  3. Fallback resolution complete.`,summary:"Execute workspace diagnostics and fallback resolution."},toolCalls:[{id:`tc-${Date.now()}-fallback`,type:"bash",title:"Diagnostic Command",target:"bun --version",command:"bun --version",output:"Bun v1.2.4 (fallback mode)",status:"success",duration:"35ms"}],content:`I've processed your request: **"${r||"Workspace status"}"**.
22
22
 
23
23
  - **Target Workspace**: \`${s||"Workspace"}\`
24
24
  - **Runtime**: Bun v1.2.4 with remisJS edge adapter
25
- - **Status**: Ready.`,summary:"Execution completed via fallback adapter."};t.onInit?.({id:l.id,role:"ai",date:l.date,model:i}),t.onThinkingEnd?.(l.thinking),t.onContentChunk?.({delta:l.content}),t.onSummary?.({summary:l.summary||""}),t.onDone?.({message:l});try{await fetch(`/api/chat/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:l})})}catch{}return l}let ih={txt:!0,text:!0,md:!0,markdown:!0,mdx:!0};function ix(e){return e.toLowerCase().replace(/\\/g,"/").split("/").pop()?.split(".").pop()??""}function ig(e){return"text/plain"===e.type||"text/markdown"===e.type||!0===ih[ix(e.name)]}let ib=/(^|[\s([{])@"file:([^"]+)"/g,iv=/(^|[\s([{])@file:(\S+)/g,ik=/(^|[\s([{])@("([^"]+)"|'([^']+)'|(\S+))/g,iy=/[.,;:!?)\]}]+$/;async function iw(e,t){let n=e;try{let t=await (0,eu.O7)();t.length>0&&(n=function(e,t){let n=function(e,t){let n=new Set(t.map(e=>e.toLowerCase())),r=[];for(let t of e.matchAll(ik)){let e=t.index+t[1].length,i=t[3]??t[4];if(void 0!==i){if(!n.has(i.toLowerCase()))continue;r.push({name:i,start:e,end:e+1+(t[2]??"").length});continue}let s=(t[5]??"").replace(iy,"");n.has(s.toLowerCase())&&r.push({name:s,start:e,end:e+1+s.length})}return r}(e,t);if(0===n.length)return{text:e,agents:[]};let r=[],i=new Set;for(let e of n){let t=e.name.toLowerCase();i.has(t)||(i.add(t),r.push(e.name))}let s=e;for(let e=n.length-1;e>=0;e--){let t=n[e];s=s.slice(0,t.start)+s.slice(t.end)}return""===(s=s.replace(/[ \t]+/g," ").replace(/\n{2,}/g,"\n").trim())?{text:e,agents:r}:{text:`Use the task tool to delegate this request to the following oh-my-pi subagent(s): ${r.map(e=>`\`${e}\``).join(", ")} (agent id: ${r.join(", ")}).
25
+ - **Status**: Ready.`,summary:"Execution completed via fallback adapter."};t.onInit?.({id:l.id,role:"ai",date:l.date,model:i}),t.onThinkingEnd?.(l.thinking),t.onContentChunk?.({delta:l.content}),t.onSummary?.({summary:l.summary||""}),t.onDone?.({message:l});try{await fetch(`/api/chat/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:l})})}catch{}return l}let ig={txt:!0,text:!0,md:!0,markdown:!0,mdx:!0};function ib(e){return e.toLowerCase().replace(/\\/g,"/").split("/").pop()?.split(".").pop()??""}function iv(e){return"text/plain"===e.type||"text/markdown"===e.type||!0===ig[ib(e.name)]}let ik=/(^|[\s([{])@"file:([^"]+)"/g,iy=/(^|[\s([{])@file:(\S+)/g,iw=/(^|[\s([{])@("([^"]+)"|'([^']+)'|(\S+))/g,iN=/[.,;:!?)\]}]+$/;async function iY(e,t){let n=e;try{let t=await (0,eu.O7)();t.length>0&&(n=function(e,t){let n=function(e,t){let n=new Set(t.map(e=>e.toLowerCase())),r=[];for(let t of e.matchAll(iw)){let e=t.index+t[1].length,i=t[3]??t[4];if(void 0!==i){if(!n.has(i.toLowerCase()))continue;r.push({name:i,start:e,end:e+1+(t[2]??"").length});continue}let s=(t[5]??"").replace(iN,"");n.has(s.toLowerCase())&&r.push({name:s,start:e,end:e+1+s.length})}return r}(e,t);if(0===n.length)return{text:e,agents:[]};let r=[],i=new Set;for(let e of n){let t=e.name.toLowerCase();i.has(t)||(i.add(t),r.push(e.name))}let s=e;for(let e=n.length-1;e>=0;e--){let t=n[e];s=s.slice(0,t.start)+s.slice(t.end)}return""===(s=s.replace(/[ \t]+/g," ").replace(/\n{2,}/g,"\n").trim())?{text:e,agents:r}:{text:`Use the task tool to delegate this request to the following oh-my-pi subagent(s): ${r.map(e=>`\`${e}\``).join(", ")} (agent id: ${r.join(", ")}).
26
26
 
27
- ${s}`,agents:r}}(e,t).text)}catch{}var r=n.replace(ib,'$1@"$2"').replace(iv,"$1@$2");if(0===t.length)return r;let i=t.map(e=>{var t;let n,r,i=(t=e.content,n=t.match(/`+/g)?.reduce((e,t)=>Math.max(e,t.length),0)??0,"`".repeat(Math.max(3,n+1)));return`Attached file: ${e.name}
28
- ${i}${"md"===(r=ix(e.name))||"markdown"===r||"mdx"===r?"markdown":"text"}
27
+ ${s}`,agents:r}}(e,t).text)}catch{}var r=n.replace(ik,'$1@"$2"').replace(iy,"$1@$2");if(0===t.length)return r;let i=t.map(e=>{var t;let n,r,i=(t=e.content,n=t.match(/`+/g)?.reduce((e,t)=>Math.max(e,t.length),0)??0,"`".repeat(Math.max(3,n+1)));return`Attached file: ${e.name}
28
+ ${i}${"md"===(r=ib(e.name))||"markdown"===r||"mdx"===r?"markdown":"text"}
29
29
  ${e.content}
30
- ${i}`});return[r.trim(),...i].filter(Boolean).join("\n\n")}var iN=n("ng");function iY(e,t){let n=null,r=0,i=[],s=()=>{n=null;let r=i;if(i=[],r.length){for(let t of r)e(t.updater);t?.()}},a=()=>{r+=1,null!==n&&cancelAnimationFrame(n),n=null};return{queue(e,t){let a=void 0===t?-1:i.findIndex(e=>e.key===t);-1!==a?i[a]={key:t,updater:e}:i.push({key:t,updater:e}),(()=>{if(null!==n)return;let e=++r;n=requestAnimationFrame(()=>{e===r&&s()})})()},flush(){a(),s()},cancel(){a(),i=[]}}}let iD=[250,250,500,500,1e3,1e3,2e3,2e3,2e3,2e3,2e3,2e3];var iF=n("Fb");function iA(e,t){let n=e[t];return"string"==typeof n?n:void 0}let iC=()=>{},iS=()=>{},iT=iY(e=>iC(e),()=>iS());function iz(){iT.cancel()}var i$=n("So"),ij=n("Np"),iL=n("B");function iM(e){var t;return t=e.connectedProviders,t?.length?Object.fromEntries(t.filter(e=>e.name?.trim()).map(e=>[e.id,e.name])):{}}var iP=n("oZ"),iE=n("wu"),iR=n("Gb"),iI=n("A9");function iO(e){let{className:t="",appSettings:n={},onSessionTitle:a,variant:l="desktop"}=e,{folders:c}=(0,iI.k)(),d="mobile"===l,{sessionId:u,selectedFolderId:m,setSelectedFolderId:f,sessionData:x,localMessages:g,isGenerating:b,hasMore:v,loadingOlder:k,loadOlderError:w,sessionLoading:N,loadOlder:Y,generatingVerb:D,messageQueue:F,setMessageQueue:A,steeringQueue:C,setSteeringQueue:S,inputValue:T,setInputValue:z,inputAttachments:$,setInputAttachments:j,scrollRef:L,contentRef:M,showScrollBottom:P,isScrolling:E,handleScroll:R,jumpToBottom:I,handleSend:O,handleEditQueueItem:J,handleSendNowQueueItem:_,handleUndo:W,handleRetry:K,submitNewChat:U,stopGenerating:q,handleThinkingLevelChange:B,handleModelChange:H,accessMode:G,handleAccessModeChange:V,composerModelRef:Z,extensionDialogs:Q,resolveExtensionDialog:X,respondToExtensionUi:ee}=function(){let e,{folders:t=[],appSettings:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[r,a]=(0,s.o)(),l=r.get("sessionId"),o=r.get("folderId"),[c,d]=(0,i.J0)(null);(0,i.vJ)(()=>{d(o?parseInt(o,10):null)},[o]);let u=(0,i.hb)(e=>{d(e),a(t=>(e?t.set("folderId",String(e)):t.delete("folderId"),t),{replace:!0})},[a]),p=(0,i.li)(()=>{}),{scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,i.li)(e.onScrollTop);t.current=e.onScrollTop??t.current;let n=(0,i.li)(null),[r,s]=(0,i.J0)(null),[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(!1),d=(0,i.li)(null),u=(0,i.li)(!0),p=(0,i.li)(0),m=(0,i.hb)(e=>{s(e)},[]),h=(0,i.hb)(()=>{let e=n.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight>=100)},[]),f=(0,i.hb)(()=>{let e=n.current;e&&(e.scrollTop<p.current-1&&(u.current=!1),e.scrollHeight-e.scrollTop-e.clientHeight<100&&(u.current=!0),p.current=e.scrollTop,e.scrollTop<=40&&t.current?.()),h(),c(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),600)},[h]),x=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;!t||u.current&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),g=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;t&&(u.current=!0,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]);return(0,i.vJ)(()=>{if(h(),"u"<typeof ResizeObserver)return;let e=n.current,t=new ResizeObserver(h);return e&&t.observe(e),r&&t.observe(r),()=>t.disconnect()},[r,h]),(0,i.vJ)(()=>()=>{d.current&&clearTimeout(d.current)},[]),{scrollRef:n,contentRef:m,showScrollBottom:a,isScrolling:o,followRef:u,handleScroll:f,scrollToBottom:x,jumpToBottom:g}}({onScrollTop:()=>p.current()}),[k,y]=(0,ic.bL)("chat.draft","");(e=(0,i.li)(y)).current=y,(0,i.vJ)(()=>{let t=t=>{let n=t instanceof CustomEvent?t.detail:null;if(!(0,nd.u)(n))return;let r=iA(n,"url");if(!r)return;let i=iA(n,"title");e.current(e=>{let t=e&&!e.endsWith("\n")?"\n\n":e?"\n":"",n=i?`
30
+ ${i}`});return[r.trim(),...i].filter(Boolean).join("\n\n")}var iD=n("ng");function iF(e,t){let n=null,r=0,i=[],s=()=>{n=null;let r=i;if(i=[],r.length){for(let t of r)e(t.updater);t?.()}},a=()=>{r+=1,null!==n&&cancelAnimationFrame(n),n=null};return{queue(e,t){let a=void 0===t?-1:i.findIndex(e=>e.key===t);-1!==a?i[a]={key:t,updater:e}:i.push({key:t,updater:e}),(()=>{if(null!==n)return;let e=++r;n=requestAnimationFrame(()=>{e===r&&s()})})()},flush(){a(),s()},cancel(){a(),i=[]}}}let iA=[250,250,500,500,1e3,1e3,2e3,2e3,2e3,2e3,2e3,2e3];var iC=n("Fb");function iS(e,t){let n=e[t];return"string"==typeof n?n:void 0}let iT=()=>{},iz=()=>{},i$=iF(e=>iT(e),()=>iz());function ij(){i$.flush(),i$.cancel()}function iL(){i$.cancel()}var iM=n("So"),iP=n("Np"),iE=n("B");function iR(e){var t;return t=e.connectedProviders,t?.length?Object.fromEntries(t.filter(e=>e.name?.trim()).map(e=>[e.id,e.name])):{}}var iI=n("oZ"),iO=n("wu"),iJ=n("Gb"),i_=n("A9");function iW(e){let{className:t="",appSettings:n={},onSessionTitle:a,variant:l="desktop"}=e,{folders:c}=(0,i_.k)(),d="mobile"===l,{sessionId:u,selectedFolderId:m,setSelectedFolderId:f,sessionData:x,localMessages:g,isGenerating:b,hasMore:v,loadingOlder:k,loadOlderError:w,sessionLoading:N,loadOlder:Y,generatingVerb:D,messageQueue:F,removeMessage:A,reorderMessages:C,steeringQueue:S,setSteeringQueue:T,inputValue:z,setInputValue:$,inputAttachments:j,setInputAttachments:L,scrollRef:M,contentRef:P,showScrollBottom:E,isScrolling:R,handleScroll:I,jumpToBottom:O,handleSend:J,handleEditQueueItem:_,handleSendNowQueueItem:W,handleUndo:K,handleRetry:U,submitNewChat:B,stopGenerating:q,handleThinkingLevelChange:H,handleModelChange:G,accessMode:V,handleAccessModeChange:Z,composerModelRef:Q,extensionDialogs:X,resolveExtensionDialog:ee,respondToExtensionUi:et}=function(){let e,{folders:t=[],appSettings:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[r,a]=(0,s.o)(),l=r.get("sessionId"),o=r.get("folderId"),[c,d]=(0,i.J0)(null);(0,i.vJ)(()=>{d(o?parseInt(o,10):null)},[o]);let u=(0,i.hb)(e=>{d(e),a(t=>(e?t.set("folderId",String(e)):t.delete("folderId"),t),{replace:!0})},[a]),p=(0,i.li)(()=>{}),{scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,i.li)(e.onScrollTop);t.current=e.onScrollTop??t.current;let n=(0,i.li)(null),[r,s]=(0,i.J0)(null),[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(!1),d=(0,i.li)(null),u=(0,i.li)(!0),p=(0,i.li)(0),m=(0,i.hb)(e=>{s(e)},[]),h=(0,i.hb)(()=>{let e=n.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight>=100)},[]),f=(0,i.hb)(()=>{let e=n.current;e&&(e.scrollTop<p.current-1&&(u.current=!1),e.scrollHeight-e.scrollTop-e.clientHeight<100&&(u.current=!0),p.current=e.scrollTop,e.scrollTop<=40&&t.current?.()),h(),c(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),600)},[h]),x=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;!t||u.current&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),g=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;t&&(u.current=!0,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]);return(0,i.vJ)(()=>{if(h(),"u"<typeof ResizeObserver)return;let e=n.current,t=new ResizeObserver(h);return e&&t.observe(e),r&&t.observe(r),()=>t.disconnect()},[r,h]),(0,i.vJ)(()=>()=>{d.current&&clearTimeout(d.current)},[]),{scrollRef:n,contentRef:m,showScrollBottom:a,isScrolling:o,followRef:u,handleScroll:f,scrollToBottom:x,jumpToBottom:g}}({onScrollTop:()=>p.current()}),[k,y]=(0,ic.bL)("chat.draft","");(e=(0,i.li)(y)).current=y,(0,i.vJ)(()=>{let t=t=>{let n=t instanceof CustomEvent?t.detail:null;if(!(0,nd.u)(n))return;let r=iS(n,"url");if(!r)return;let i=iS(n,"title");e.current(e=>{let t=e&&!e.endsWith("\n")?"\n\n":e?"\n":"",n=i?`
31
31
  Judul: ${i}`:"";return`${e}${t}[Konteks halaman browser]
32
32
  URL: ${r}${n}
33
- (Lanjutkan dari halaman ini.)`})};return window.addEventListener(iF.j,t),()=>window.removeEventListener(iF.j,t)},[]);let[w,N]=(0,ic.bL)("chat.draftAttachments",[]),[Y,D]=(0,i.J0)([]),F=!!l?.startsWith("new-");!function(e){let{sessionId:t,messages:n,scrollRef:r,scrollToBottom:s,enabled:a}=e,l=(0,i.li)(null),o=(0,i.li)(null);id(()=>{if(l.current!==t){l.current=t,o.current=null;return}a&&t&&0!==n.length&&o.current!==t&&r.current&&(o.current=t,s("instant"))},[t,n,a,r,s])}({sessionId:l,messages:Y,scrollRef:m,scrollToBottom:b,enabled:!F});let[A,C]=(0,i.J0)(!1),S=(0,i.li)(!1),T=(0,i.li)([]);T.current=Y;let[z,$]=(0,i.J0)(""),j=(0,i.li)(null),L=(0,i.li)(l);L.current=l;let M=(0,i.hb)(e=>{S.current=e,C(e)},[]),P=(0,i.li)(!1),E=(0,i.li)(null),R=(0,i.li)(!1),I=(0,i.li)(null),O=(0,i.li)([]),J=!!l&&!String(l).startsWith("new-")&&Number.isNaN(Number(l)),_=(0,i.li)(null),{sessionData:W,adoptedSessionIdRef:K,refreshSessionMeta:U,seedSession:q,hasMore:B,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z}=function(e){let{sessionId:t,setLocalMessages:n,setGenerating:r,isGeneratingRef:s,aiPlaceholderIdRef:a,localMessagesRef:l,optimisticUserIdRef:o,cancelStreamingCoalescer:c,metaRefreshedRef:d,scrollRef:u}=e,[p,m]=(0,i.J0)(null),[h,f]=(0,i.J0)(!1),x=(0,i.li)(null),g=(0,i.li)(null),b=(0,i.li)(null),v=(0,i.li)(null),k=(0,i.hb)(e=>{e.model&&"object"==typeof e.model&&(b.current=e.model);let t=e.model??(s.current?b.current??void 0:void 0),n=e.thinkingLevel??v.current??void 0;m({...e,model:t,thinkingLevel:n})},[]),y=(0,i.li)(t);y.current=t;let{hasMore:w,loadingOlder:N,loadOlderError:Y,loadOlder:D,resetPages:F,applyWindow:A}=function(e){let{sessionId:t,sessionIdRef:n,setLocalMessages:r,scrollRef:s}=e,[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(0),[d,u]=(0,i.J0)(!1),[p,m]=(0,i.J0)(!1),[h,f]=(0,i.J0)(0),x=(0,i.li)(!1),g=(0,i.li)(null),b=(0,i.hb)(()=>{l(!1),c(0),x.current=!1,u(!1),m(!1)},[]),v=(0,i.hb)((e,t)=>{"boolean"==typeof e&&l(e),"number"==typeof t&&c(t)},[]),k=(0,i.hb)(()=>{if(!t||t.startsWith("new-")||!a||x.current)return;x.current=!0,u(!0),m(!1);let e=s?.current;e&&(g.current={prevHeight:e.scrollHeight,prevTop:e.scrollTop}),fetch(`/api/chat/${t}?before=${o}`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{if(n.current!==t)return;let i=e.session?.messages??[];if(v(e.hasMore,e.oldestIndex),0===i.length){g.current=null;return}r(e=>[...i,...e]),f(e=>e+1)}).catch(()=>{n.current===t&&m(!0)}).finally(()=>{x.current=!1,u(!1)})},[t,n,a,o,s,r,v]);return(0,i.Nf)(()=>{let e=g.current;if(!e)return;let t=s?.current;if(!t)return;g.current=null;let n=t.scrollHeight-e.prevHeight;n>0&&(t.scrollTop=e.prevTop+n)},[h,s]),{hasMore:a,loadingOlder:d,loadOlderError:p,loadOlder:k,resetPages:b,applyWindow:v}}({sessionId:t,sessionIdRef:y,setLocalMessages:n,scrollRef:u}),C=(0,i.hb)(e=>{let t=()=>y.current===e||g.current===e;if(!t())return;let n=0,r=()=>{t()&&fetch(`/api/chat/${encodeURIComponent(e)}`).then(e=>e.json()).then(i=>{if(!i?.session||!t())return;if(k(i.session),(i.session.messages?.length??0)>0)return void window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}));let s=iD[n];n+=1,void 0!==s&&setTimeout(r,s)}).catch(()=>{})};r()},[k]),S=(0,i.hb)(e=>{e.model&&(b.current=e.model),e.thinkingLevel&&(v.current=e.thinkingLevel),m(t=>({...t??{},...e.model?{model:e.model}:{},...e.thinkingLevel?{thinkingLevel:e.thinkingLevel}:{}}))},[]),T=(0,i.hb)(()=>s.current&&!!a.current,[a]);return(0,i.vJ)(()=>{let e=!0;if(f(!0),t!==x.current){let e=t&&!t.startsWith("new-")&&x.current?.startsWith("new-"),i=s.current&&g.current===t;e||i||(n([]),r(!1),g.current=null,b.current=null,m(null),v.current=null,a.current=null,o.current=null,c()),F(),d.current=null,x.current=t}return t?fetch(`/api/chat/${t}`).then(e=>e.json()).then(r=>{if(e)if(f(!1),r?.session){k(r.session);let e=r.session.messages||[],i=T();if(e.length>0&&!i)if(s.current){let t=e.map(e=>e.id);n([...e,...l.current.filter(e=>!t.includes(e.id))])}else n(e);else t.startsWith("new-")||i||n([]);A(r.hasMore,r.oldestIndex)}else m(null),T()||n([])}).catch(t=>{console.error("Error loading session from API:",t),e&&f(!1),e&&!T()&&(m(null),n([]))}):(m(null),n([])),()=>{e=!1}},[t,k,T,n,r]),{sessionData:p,hasMore:w,loadingOlder:N,loadOlderError:Y,sessionLoading:h,loadOlder:D,adoptedSessionIdRef:g,refreshSessionMeta:C,seedSession:S}}({sessionId:l,setLocalMessages:D,setGenerating:M,isGeneratingRef:S,aiPlaceholderIdRef:_,localMessagesRef:T,optimisticUserIdRef:I,cancelStreamingCoalescer:iz,metaRefreshedRef:E,scrollRef:m});p.current=Z;let Q=(0,i.li)(null),X=(0,i.li)(null),ee=(0,i.li)(null),[et,en]=(0,i.J0)(()=>{var e,t;return"string"==typeof(t=e=n.omp_access_mode)&&ei.some(e=>e===t)?e:"always-ask"}),er=(0,i.li)(et);er.current=et;let es=(0,i.hb)(e=>{en(e),er.current=e,(0,i$.cz)("omp_access_mode",e)},[]),ea=(0,i.hb)(e=>{l&&fetch(`/api/chat/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e})}).catch(e=>console.error("Error persisting messages via API:",e))},[l]),{messageQueue:el,setMessageQueue:eo,steeringQueue:ec,setSteeringQueue:ed,removeDeliveredFromQueue:eu}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,ic.bL)("chat.steeringQueue",[]),a=(0,i.li)(0);(0,i.vJ)(()=>{if(!e)return void n([]);let t=++a.current,r=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/queue`).then(e=>e.ok?e.json():{queue:[]}).then(e=>{r||a.current!==t||n(Array.isArray(e.queue)?e.queue:[])}).catch(()=>{}),()=>{r=!0}},[e]);let l=(0,i.hb)(t=>{e&&fetch(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({queue:t})}).catch(console.error)},[e]),o=(0,i.hb)(e=>{n(t=>{let n="function"==typeof e?e(t):e;return l(n),n})},[l]),c=(0,i.hb)(e=>{let t=t=>t.some(t=>t.text===e);s(n=>t(n)?n.filter(t=>t.text!==e):n),o(n=>t(n)?n.filter(t=>t.text!==e):n)},[s,o]);return{messageQueue:t,setMessageQueue:o,steeringQueue:r,setSteeringQueue:s,removeDeliveredFromQueue:c}}(l),{pending:ep,enqueue:em,resolve:eh,withdraw:ef}=function(e){let[t,n]=(0,i.J0)([]);(0,i.vJ)(()=>{n([])},[e]);let r=(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]);return{pending:t,enqueue:r,resolve:(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e)?t.filter(t=>t.id!==e):t)},[]),withdraw:(0,i.hb)(e=>{n(t=>t.filter(t=>t.id!==e))},[])}}(l),ex=function(e,t,n){let[r,s]=(0,i.J0)({isGenerating:!1,connected:!1,error:null}),a=(0,i.li)(t);a.current=t;let l=(0,i.li)(e);l.current=e;let o=(0,i.li)(new Map),c=(0,i.li)(null),d=(0,i.li)(!1),u=(0,i.li)(""),p=(0,i.li)(void 0),m=(0,i.li)(new Set),{connect:h,disconnect:f}=function(e){let{setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c,transport:d}=e,u=(0,i.li)(null);(0,i.vJ)(()=>((0,is.dX)({transport:d,connected:!1}),()=>(0,is.dX)({transport:d,connected:!1})),[d]);let p=(0,i.hb)(()=>{let e=u.current;u.current=null,e?.close(),t(e=>({...e,connected:!1})),(0,is.dX)({transport:d,connected:!1})},[t,d]);return{connect:(0,i.hb)(e=>{p(),u.current=ia[d](e,{onOpen:()=>{t(e=>({...e,connected:!0})),(0,is.dX)({transport:d,connected:!0}),n.current?.onConnected?.()},onFrame:i=>{!function(e,t){let n=t.callbacksRef.current;switch(e.type){case"agent_start":t.setState(e=>({...e,isGenerating:!0,error:null})),t.toolResultsRef.current?.clear(),t.fileMutatingCallsRef.current?.clear(),t.lastToolMessageRef.current=null,t.interruptPendingRef.current=!1,t.currentThinkingLevelRef.current=void 0,r7(r3.n1.thinking,t),n?.onAgentStart?.();break;case"message_start":case"message_update":{let r=e.message;if(!r)break;if("toolResult"===r.role){it(r,t),r7(r3.n1.thinking,t);break}r7(function(e){if(!(0,nd.u)(e))return;let t=(0,r3.oJ)(e.type);if(t){if(t.startsWith("thinking"))return r3.n1.thinking;if(t.startsWith("text"))return r3.n1.writing;if("toolcall_start"===t||"toolcall_delta"===t){let t=function(e){let t=e.partial;if(!(0,nd.u)(t))return;let n=t.content;if(!Array.isArray(n))return;let r="number"==typeof e.contentIndex?e.contentIndex:n.length-1,i=n[r];if((0,nd.u)(i)&&"toolCall"===i.type)return i}(e);if(!t)return;return r8({name:(0,r3.oJ)(t.name),args:t.arguments})}if("toolcall_end"===t){let t=e.toolCall;if(!(0,nd.u)(t))return;return r8({name:(0,r3.oJ)(t.name),args:t.arguments})}}}(e.assistantMessageEvent),t);let i=rE(r);i&&("user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current),n?.onMessageUpdate?.(i));break}case"message_end":{let r=e.message;if(!r)break;if("toolResult"===r.role){it(r,t);break}if("custom"===r.role)break;if("user"===r.role){let e=rT(r.content);e&&n?.onQueuedMessageDelivered?.(e);break}let i=rE(r,!1);if(!i)break;"user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current);let s=ie(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s);break}case"tool_execution_start":{let r="string"==typeof e.toolCallId?e.toolCallId:void 0;r7(r8({name:"string"==typeof e.toolName?e.toolName:void 0,args:e.args,intent:"string"==typeof e.intent?e.intent:void 0}),t),r&&t.toolResultsRef.current?.set(r,{output:""}),r&&(0,r6.Y)({toolName:e.toolName,args:e.args})&&t.fileMutatingCallsRef.current?.add(r);let i=t.lastToolMessageRef.current;i?.toolCalls?.some(e=>e.id===r)&&(t.lastToolMessageRef.current={...i,toolCalls:i.toolCalls.map(e=>({...e,status:"running"}))},n?.onMessageUpdate?.(t.lastToolMessageRef.current));break}case"tool_execution_update":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0,r=rP(e.partialResult);if(!n||!r)break;let i=t.toolResultsRef.current?.get(n)?.output??"",s=t.toolResultsRef.current;s&&r9(s,n,{output:i+r}),ir(n,t);break}case"tool_execution_end":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0;if(!n)break;r7(r3.n1.thinking,t);let r=t.toolResultsRef.current;r&&r9(r,n,{output:rP(e.result),isError:!0===e.isError,details:e.details&&"object"==typeof e.details?e.details:void 0}),ir(n,t),"u">typeof window&&t.fileMutatingCallsRef.current?.delete(n)&&window.dispatchEvent(new CustomEvent(r6.s,{detail:{sessionId:t.sessionId}}));break}case"agent_end":{t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="";let r=function(e,t,n){let r;if(!1===e.isTerminal)return{};let i=e.messages;if(!Array.isArray(i))return{};for(let e of i){if(!e||"object"!=typeof e||Array.isArray(e)||"assistant"!==e.role||"aborted"!==e.stopReason&&"error"!==e.stopReason)continue;let i=rE(e,!1);if(!i)continue;let s=ie(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s),"string"==typeof e.errorMessage&&(r=e.errorMessage)}return{errorMessage:r}}(e,t,n??void 0);if(t.interruptPendingRef.current){t.interruptPendingRef.current=!1;break}n?.onAgentEnd?.({errorMessage:r.errorMessage??("string"==typeof e.errorMessage?e.errorMessage:void 0),message:"string"==typeof e.message?e.message:void 0});break}case"prompt_error":{let r="string"==typeof e.errorMessage?e.errorMessage:"Prompt failed";t.setState(e=>({...e,isGenerating:!1,error:r})),t.interruptPendingRef.current=!1,t.activityRef.current="",n?.onPromptError?.(r);break}case"notice":n?.onNotice?.("string"==typeof e.level?e.level:"info","string"==typeof e.message?e.message:"");break;case"extension_ui_request":n?.onExtensionUiRequest?.(e);break;case"subagent_lifecycle":case"subagent_progress":case"subagent_event":{let n=e.payload;if(null==n||"object"!=typeof n)break;window.dispatchEvent(new CustomEvent(e.type,{detail:{sessionId:t.sessionId,payload:n}}));break}case"model_changed":n?.onModelChanged?.();break;case"thinking_level_changed":var r;t.currentThinkingLevelRef.current="string"==typeof(r=e.thinkingLevel)&&r.trim()?r.trim():"off"}}(i,{sessionId:e,setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c})},onClose:()=>{t(e=>({...e,connected:!1})),(0,is.dX)({transport:d,connected:!1})}})},[p,t,n,r,s,a,l,o,c,d]),disconnect:p}}({setState:s,callbacksRef:a,toolResultsRef:o,lastToolMessageRef:c,interruptPendingRef:d,activityRef:u,currentThinkingLevelRef:p,fileMutatingCallsRef:m,transport:n});(0,i.vJ)(()=>{if(!e)return;o.current.clear(),m.current.clear(),c.current=null,u.current="";let t=!1;return fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(n=>{if(t||!n?.running)return;let r=n.state;for(let t of((n.busy||r?.isStreaming||r?.isPromptRunning)&&(h(e),a.current.onResumeStream?.()),n.pendingUiRequests??[]))a.current.onExtensionUiRequest?.(t)}).catch(()=>{}),()=>{t=!0,f()}},[e,f,h]);let{sendPrompt:x,sendNewPrompt:g}=function(e){let{sessionIdRef:t,connect:n,setState:r}=e;return{sendPrompt:(0,i.hb)(async(e,i,s)=>{let a=t.current;if(!a)return!1;r(e=>({...e,isGenerating:!0,error:null}));try{(await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_state",...s?.accessMode?{accessMode:s.accessMode}:{}})})).ok&&n(a);let t=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await t.json().catch(()=>({}));if(!t.ok||l.error)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${t.status}`})),!1;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:a}})),!0}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[n,t,r]),sendNewPrompt:(0,i.hb)(async(e,t,i,s)=>{r(e=>({...e,isGenerating:!0,error:null}));try{let a=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"ensure_session",cwd:t,...s?.model?s.model:{},...s?.thinkingLevel?{thinkingLevel:s.thinkingLevel}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await a.json().catch(()=>({}));if(!a.ok||!l.sessionId)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${a.status}`})),null;let o=l.sessionId;n(o);let c=await fetch(`/api/agent/${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{}})}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)return r(e=>({...e,isGenerating:!1,error:d.error??`HTTP ${c.status}`})),null;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:o}})),{sessionId:o,model:l.model??null}}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),null}},[n,r])}}({sessionIdRef:l,connect:h,setState:s}),b=(0,i.hb)(async()=>{let e=l.current;e&&(d.current=!1,await io(e),s(e=>({...e,isGenerating:!1})))},[]),v=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;d.current=!0,s(e=>({...e,isGenerating:!0,error:null}));try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"abort_and_prompt",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return d.current=!1,s(e=>({...e,isGenerating:!1,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return d.current=!1,s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[]),k=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"follow_up",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return s(e=>({...e,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return s(t=>({...t,error:e instanceof Error?e.message:String(e)})),!1}},[]),y=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_model",provider:e,modelId:t})})}catch{}},[]),w=(0,i.hb)(async e=>{let t=l.current;if(t)try{await fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_thinking_level",level:e})})}catch{}},[]),N=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e.id,...t})})}catch{}},[]);return{...r,sendPrompt:x,sendNewPrompt:g,sendInterruptAndReply:v,sendFollowUp:k,abort:b,setModel:y,setThinkingLevel:w,respondToExtensionUi:N,disconnect:f}}(J?l:null,function(e){let{removeDeliveredFromQueue:t,setGenerating:n,setGeneratingVerb:r,scrollToBottom:i,adoptedSessionIdRef:s,sessionIdRef:a,metaRefreshedRef:l,firstAssistantRef:o,refreshSessionMeta:c,setLocalMessages:d,aiPlaceholderIdRef:u,optimisticUserIdRef:p,pendingUserDisplaysRef:m,persistMessages:h,abortControllerRef:f,appSettings:x,enqueueExtensionDialog:g,withdrawExtensionDialog:b}=e;return iC=d,iS=()=>i("smooth"),{onQueuedMessageDelivered:e=>{t(e)},onAgentStart:()=>{n(!0),r(r3.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&(window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),l.current!==e&&(l.current=e,setTimeout(()=>c(e),100)))},onResumeStream:()=>{n(!0),r(r3.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onActivity:e=>{r(e)},onMessageUpdate:e=>{"user"===e.role||rr(e)||(p.current=null),iT.queue(t=>{let n=u.current;if(rr(e)){if(t.some(t=>t.id===e.id))return t;if(n&&t.some(e=>e.id===n)){let r=t.findIndex(e=>e.id===n);return[...t.slice(0,r),e,...t.slice(r)]}return[...t,e]}if("user"===e.role){if(t.some(t=>t.id===e.id))return t;let r=p.current;if(r){let n=t.findIndex(e=>e.id===r);if(-1!==n){let r={...e,id:e.id,content:t[n].content,date:t[n].date,attachments:e.attachments?.length?e.attachments:t[n].attachments};return[...t.slice(0,n),r,...t.slice(n+1)]}}let i=m.current.find(t=>e.content===t.sent||e.content.startsWith(t.sent)||t.sent.startsWith(e.content)),s=i?{...e,content:i.display}:e;if(n&&t.some(e=>e.id===n)){let e=t.findIndex(e=>e.id===n);return[...t.slice(0,e),s,...t.slice(e)]}return[...t,s]}if(n&&t.some(e=>e.id===n))return t.map(t=>t.id===n?e:t);let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]},e.id)},onMessageEnd:e=>{if("ai"===e.role&&!rr(e)&&!o.current){o.current=!0;let e=s.current??a.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))}iT.flush(),"user"!==e.role&&(p.current=null),d(t=>{let n,r=u.current;if("user"===e.role){let n,i=p.current;if(t.some(t=>t.id===e.id))n=t.map(t=>t.id===e.id?e:t);else if(i&&t.some(e=>e.id===i))n=t.map(t=>t.id===i?{...e,id:e.id,content:t.content,date:t.date,attachments:e.attachments?.length?e.attachments:t.attachments}:t);else if(r&&t.some(e=>e.id===r)){let i=t.findIndex(e=>e.id===r);n=[...t.slice(0,i),e,...t.slice(i)]}else n=[...t,e];return h(n),n}if(r&&t.some(e=>e.id===r))n=t.map(t=>t.id===r?e:t);else{let r=t.findIndex(t=>t.id===e.id);n=-1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]}return u.current=null,h(n),n})},onAgentEnd:()=>{iT.flush(),iT.cancel(),n(!1),f.current=null,p.current=null,m.current=[],(0,iN.s4)(x),setTimeout(()=>i("smooth"),50);let e=s.current??a.current;e&&c(e)},onModelChanged:()=>{let e=s.current??a.current;e&&setTimeout(()=>c(e),150)},onPromptError:e=>{n(!1),f.current=null,console.error("OMP prompt error:",e)},onNotice:(e,t)=>{console.info("OMP notice:",t)},onExtensionUiRequest:e=>{"select"===e.method||"confirm"===e.method||"input"===e.method||"editor"===e.method?g(e):"cancel"===e.method&&b(e.targetId)}}}({removeDeliveredFromQueue:eu,setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,adoptedSessionIdRef:K,sessionIdRef:L,metaRefreshedRef:E,firstAssistantRef:R,refreshSessionMeta:U,setLocalMessages:D,aiPlaceholderIdRef:_,optimisticUserIdRef:I,pendingUserDisplaysRef:O,persistMessages:ea,abortControllerRef:j,appSettings:n,enqueueExtensionDialog:em,withdrawExtensionDialog:ef}),(0,ii.ul)(n)),{steerOmpAgent:eg,executeSend:eb}=function(e){let{folders:t,selectedFolderId:n,sessionId:r,isOmpSession:s,appSettings:a,ompAgent:l,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,scrollToBottom:p,jumpToBottom:m,aiPlaceholderIdRef:h,adoptedSessionIdRef:f,optimisticUserIdRef:x,pendingUserDisplaysRef:g,seedSession:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,accessModeRef:y,abortControllerRef:w,setInputValue:N,setSearchParams:Y}=e,D=(0,i.hb)(async(e,t)=>{let n=new Map;try{await Promise.all(t.filter(e=>ig(e.file)).map(async e=>{n.set(e.id,await e.file.text())}))}catch{}let r=t.filter(e=>n.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:n.get(e.id),size:e.file.size})),i=await iw(e,r);g.current=[...g.current.slice(-7),{sent:i,display:e}];let s=t.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type}));return{promptText:i,images:s.length?s:void 0}},[]);return{steerOmpAgent:(0,i.hb)(async(e,t)=>{let{promptText:n,images:r}=await D(e,t);await l.sendInterruptAndReply(n,r)||N(e)},[l,D,N]),executeSend:(0,i.hb)(async(e,i,g)=>{let N=g?.model??null,D=N?.accessMode??y.current,F=tI(),A=`msg-${Date.now()}-user`,C=`msg-${Date.now()+1}-ai`,S=new Map;try{await Promise.all(i.filter(e=>ig(e.file)).map(async e=>{S.set(e.id,await e.file.text())}))}catch{}let T=Date.now(),z={id:A,role:"user",date:`Today, ${F}`,startedAt:T,content:e,attachments:i.map(e=>({name:e.file.name,preview:e.dataBase64?`data:${e.file.type};base64,${e.dataBase64}`:e.preview,type:e.file.type,size:e.file.size,content:S.get(e.id)}))},$={id:C,role:"ai",date:`Today, ${F}`,startedAt:T,content:""};if(o(e=>{let t=[...e,z,$];return c(t.filter(e=>e.id!==C)),t}),d(!0),u(r3.n1.thinking),setTimeout(()=>m("smooth"),50),s){h.current=C,x.current=A,N&&(await l.setModel(N.provider,N.modelId),"auto"!==N.thinkingLevel&&await l.setThinkingLevel(N.thinkingLevel));let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>S.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:S.get(e.id),size:e.file.size})),r=await iw(e,n);await l.sendPrompt(r,t.length?t:void 0,{accessMode:D})||(o(e=>e.filter(e=>e.id!==A&&e.id!==C)),h.current=null,x.current=null,d(!1));return}if(!s){let r=t.find(e=>String(e.id)===String(n)),s=r?.project_path||r?.name;if(s){let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>S.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:S.get(e.id),size:e.file.size})),r=await iw(e,n);x.current=A;let a=v.current,o=k.current,c=await l.sendNewPrompt(r,s,t.length?t:void 0,{model:a,thinkingLevel:o,accessMode:y.current});if(c){f.current=c.sessionId,h.current=C,b({model:c.model,thinkingLevel:o}),v.current=null,k.current=null,fetch(`/api/chat/${encodeURIComponent(c.sessionId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[z]})}).catch(e=>console.error("Error persisting spawned user turn:",e)),Y(e=>{let t=new URLSearchParams(e);return t.set("sessionId",c.sessionId),t},{replace:!0});return}}}x.current=null,w.current&&w.current.abort();let j=new AbortController;w.current=j;let L=t.find(e=>String(e.id)===String(n)),M=L?.name||"Workspace";await ip({sessionId:r||`session-${Date.now()}`,prompt:e,workspaceName:M,attachments:i,signal:j.signal},function(e){let{aiPlaceholderId:t,setLocalMessages:n,persistMessages:r,setGenerating:i,setGeneratingVerb:s,abortControllerRef:a,appSettings:l,scrollToBottom:o}=e,c=!1,d=iY(e=>n(e),()=>{c&&(c=!1,o("smooth"))}),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(c=!0),d.queue(e)};return{onInit:e=>{u(n=>n.map(n=>n.id===t?{...n,id:e.id,date:e.date}:n))},onThinkingStart:()=>{s(r3.n1.thinking),u(e=>e.map(e=>e.id===t||"ai"===e.role?{...e,thinking:{thought:"",isGenerating:!0}}:e)),setTimeout(()=>o("smooth"),50)},onThinkingChunk:e=>{u(n=>n.map(r=>{if(r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id){let t="object"==typeof r.thinking&&r.thinking.thought||"";return{...r,thinking:{thought:t+e.delta,isGenerating:!0}}}return r}),!0)},onThinkingEnd:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,thinking:{thought:e.thought,summary:e.summary,duration:e.duration,isGenerating:!1}}:r))},onToolStart:e=>{s(r8({name:e.name??e.type,input:e.input,command:e.command,target:e.target,intent:e.intent})),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:[...r.toolCalls||[],e]}:r)),setTimeout(()=>o("smooth"),50)},onToolOutputChunk:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,output:(t.output||"")+e.delta}:t)}:r),!0)},onToolEnd:e=>{s(r3.n1.thinking),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,...e}:t)}:r))},onContentChunk:e=>{s(r3.n1.writing),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,content:(r.content||"")+e.delta}:r),!0)},onSummary:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,summary:e.summary}:r))},onDone:e=>{d.flush(),n(n=>{let i=n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?e.message:r);return r(i),i}),i(!1),a.current=null,(0,iN.s4)(l),setTimeout(()=>o("smooth"),50)},onError:()=>{i(!1),a.current=null}}}({aiPlaceholderId:C,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,abortControllerRef:w,appSettings:a,scrollToBottom:p}))},[a,t,s,l,n,r,p,m,c,b,v,k,y])}}({folders:t,selectedFolderId:c,sessionId:l,isOmpSession:J,appSettings:n,ompAgent:ex,setLocalMessages:D,persistMessages:ea,setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,jumpToBottom:v,aiPlaceholderIdRef:_,adoptedSessionIdRef:K,optimisticUserIdRef:I,pendingUserDisplaysRef:O,seedSession:q,pendingComposerModelRef:Q,pendingThinkingLevelRef:X,composerModelRef:ee,accessModeRef:er,abortControllerRef:j,setInputValue:y,setSearchParams:a});(0,i.vJ)(()=>{if(!P.current&&!A&&el.length>0){let e=el[0];eo(e=>e.slice(1)),eb(e.text,e.attachments,{model:e.model})}},[A,el,eb,eo]);let{handleSend:ev,handleEditQueueItem:ek,handleSendNowQueueItem:ey,handleUndo:ew,handleRetry:eN,submitNewChat:eY,stopGenerating:eD,handleThinkingLevelChange:eF,handleModelChange:eA}=function(e){let{inputValue:t,setInputValue:n,setInputAttachments:r,isGenerating:s,isOmpSession:a,sessionId:l,appSettings:o,messageQueue:c,setMessageQueue:d,executeSend:u,steerOmpAgent:p,ompAgent:m,abortControllerRef:h,setGenerating:f,stopHoldRef:x,persistMessages:g,setLocalMessages:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,composerModelRef:y,accessModeRef:w,setSearchParams:N}=e,Y=(0,i.hb)(async(e,r)=>{let i=t.trim();if(i||0!==e.length){if(x.current=!1,s){if(r?.steering){n(""),a?await p(i,e):(h.current&&(h.current.abort(),h.current=null),f(!1),u(i,e));return}if("steering"===(o.omp_chamber_settings?.followUpBehavior??o.followUpBehavior??"queue")&&a){n(""),await p(i,e);return}let t=y.current,s={id:`queue-${Date.now()}`,text:i,attachments:e,model:t?{...t,accessMode:w.current}:null};n(""),d(e=>[...e,s]);return}n(""),u(i,e)}},[t,s,u,d,a,o,p,n,h,f,x,y,w]),D=(0,i.hb)(e=>{d(t=>t.filter(t=>t.id!==e.id)),n(e.text),r(e.attachments)},[d,n,r]),F=(0,i.hb)(async e=>{x.current=!1,d(t=>t.filter(t=>t.id!==e.id)),s?a?p(e.text,e.attachments):(h.current&&(h.current.abort(),h.current=null),f(!1),setTimeout(()=>u(e.text,e.attachments,{model:e.model}),0)):u(e.text,e.attachments,{model:e.model})},[s,u,d,a,p,h,f,x]),A=(0,i.hb)(async(e,t)=>{if(s&&(a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1)),t&&n(t),a&&l){if(!(await fetch(`/api/chat/${encodeURIComponent(l)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryId:e})})).ok)return!1;let t=await fetch(`/api/chat/${encodeURIComponent(l)}`).then(e=>e.json()).catch(()=>null),n=t?.session?.messages??[];return n.length>0&&b(n),!0}return b(t=>{let n=t.findIndex(t=>t.id===e),r=-1!==n?t.slice(0,n):t;return g(r),r}),!0},[s,a,l,g,h,f,n,b]),C=(0,i.hb)(e=>{s&&(a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1)),b(t=>{let n=t.findIndex(t=>t.id===e);if(n>0&&"user"===t[n-1].role){let e=t[n-1];setTimeout(()=>{let t=Array.isArray(e.attachments)?e.attachments:[];u(e.content,t)},0);let r=t.slice(0,n-1);return g(r),r}return t})},[s,u,g,a,m,h,f,b]),S=(0,i.hb)((e,t)=>{let n=`new-${Date.now()}`;N(e=>{let t=new URLSearchParams(e);return t.set("sessionId",n),t},{replace:!0}),b([]),setTimeout(()=>{u(e,t)},0)},[N,u,b]),T=(0,i.hb)(()=>(x.current=!0,a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1),c.length),[a,m,h,f,c.length,x]);return{handleSend:Y,handleEditQueueItem:D,handleSendNowQueueItem:F,handleUndo:A,handleRetry:C,submitNewChat:S,stopGenerating:T,handleThinkingLevelChange:(0,i.hb)(e=>{if("auto"!==e){if(!a){k.current=e;return}m.setThinkingLevel(e)}},[a,m,k]),handleModelChange:(0,i.hb)((e,t)=>{if(!a){v.current={provider:e,modelId:t};return}m.setModel(e,t)},[a,m,v])}}({inputValue:k,setInputValue:y,setInputAttachments:N,isGenerating:A,isOmpSession:J,sessionId:l,appSettings:n,messageQueue:el,setMessageQueue:eo,executeSend:eb,steerOmpAgent:eg,ompAgent:ex,abortControllerRef:j,setGenerating:M,stopHoldRef:P,persistMessages:ea,setLocalMessages:D,pendingComposerModelRef:Q,pendingThinkingLevelRef:X,composerModelRef:ee,accessModeRef:er,setSearchParams:a});return{sessionId:l,folderId:o,isOmpSession:J,selectedFolderId:c,setSelectedFolderId:u,sessionData:W,localMessages:Y,isGenerating:A,hasMore:B,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z,generatingVerb:z,messageQueue:el,setMessageQueue:eo,steeringQueue:ec,setSteeringQueue:ed,inputValue:k,setInputValue:y,inputAttachments:w,setInputAttachments:N,scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v,handleSend:ev,handleEditQueueItem:ek,handleSendNowQueueItem:ey,handleUndo:ew,handleRetry:eN,submitNewChat:eY,stopGenerating:eD,handleThinkingLevelChange:eF,handleModelChange:eA,accessMode:et,handleAccessModeChange:es,composerModelRef:ee,extensionDialogs:ep,resolveExtensionDialog:eh,respondToExtensionUi:ex.respondToExtensionUi}}({folders:c,appSettings:n}),{toasts:et,pushToast:en,dismissToast:er}=(0,iP.Y)(),{framesByTool:es,modalRequest:ea}=(0,i.Kr)(()=>(function(e,t){let n=new Map;if(0===t.length)return{framesByTool:n,modalRequest:null};let r=new Map;for(let t of e)for(let e of t.toolCalls??[]){if("ask"!==("string"==typeof e.name&&e.name?e.name:e.type)&&"ask"!==e.title)continue;let t=h(e);t.length>0&&r.set(e.id,t)}let i=new Map,s=new Set,a=null;for(let e of t){let t="string"==typeof e.title?p(e.title):"",n=null;if(t){for(let[e,i]of r)if(i.some(e=>p(e.question)===t)){n=e;break}}n||"confirm"===e.method||(n=a),n&&(s.add(e),a=n,i.set(n,[...i.get(n)??[],e]))}for(let[e,t]of i)n.set(e,function(e,t){let n=e.map(()=>[]);if(0===e.length)return n;let r=e.map(e=>p(e.question)),i=0;for(let e of t){let t="string"==typeof e.title?p(e.title):"",s=r.indexOf(t);s>i?i=s:-1===s&&"select"===e.method&&n[i].some(e=>"select"===e.method)&&i+1<n.length&&(i+=1),n[i].push(e)}return n}(r.get(e)??[],t));return{framesByTool:n,modalRequest:t.find(e=>!s.has(e))??null}})(g,Q),[g,Q]),el=(0,i.hb)((e,t)=>{ee(e,t),X(e.id)},[ee,X]),eo=(0,i.Kr)(()=>({framesByTool:es,respond:el}),[es,el]),[ec,ed]=(0,i.J0)(null),{pendingUndo:eu,undoing:ep,requestUndo:em,closeUndoConfirm:eh,confirmUndo:ef}=function(e){let[t,n]=(0,i.J0)(null),[r,s]=(0,i.J0)(!1),a=(0,i.hb)((e,t)=>{n({id:e,content:t??""})},[]),l=(0,i.hb)(()=>n(null),[]),o=(0,i.hb)(async()=>{!t||r||(s(!0),await e(t.id,t.content)&&n(null),s(!1))},[e,t,r]);return{pendingUndo:t,undoing:r,requestUndo:a,closeUndoConfirm:l,confirmUndo:o}}(W),[ex,eg]=(0,s.o)(),eb=(0,i.hb)(()=>{let e=q();0!==e&&en(`Stopped. ${e} message${e>1?"s":""} still queued — nothing was sent.`,"success",{action:{label:"Send now",onClick:()=>{let e=F[0];e&&_(e)}},duration:8e3})},[q,en,F,_]),{activeSubagent:ev,back:ek}=function(e,t,n){let[r,s]=(0,i.J0)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.detail,r=t?.subagent,i=t?.sessionId;r&&i&&(s(r),n(e=>(e.get("sessionId")===i&&e.get("subagent")===r.id||(e.set("sessionId",i),e.set("subagent",r.id)),e),{replace:!1}))};return window.addEventListener("omp:view-subagent",e),()=>window.removeEventListener("omp:view-subagent",e)},[n]),(0,i.vJ)(()=>{if(!t)return void s(null);if(r?.id===t||!e)return;let n=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`).then(e=>e.ok?e.json():null).then(e=>{if(n||!e?.subagents)return;let r=e.subagents.find(e=>(0,nd.u)(e)&&e.id===t);r&&s((0,iL.Nh)(r))}).catch(()=>{}),()=>{n=!0}},[e,t]),{activeSubagent:r,back:(0,i.hb)(()=>{s(null),n(e=>(e.has("subagent")&&e.delete("subagent"),e),{replace:!0})},[n])}}(u,ex.get("subagent"),eg);!function(e,t,n){let[r,s]=(0,i.J0)(null);(0,i.vJ)(()=>{s(null)},[e]),(0,i.vJ)(()=>{let t=t=>{let n=t.detail;n?.sessionId&&n.title&&String(n.sessionId)===String(e)&&s(n.title)};return window.addEventListener("omp:session-renamed",t),()=>window.removeEventListener("omp:session-renamed",t)},[e]),(0,i.vJ)(()=>{let i=(0,ij.fN)(e)?(0,ij.g2)(e):null;n?.(i??r??t??null)},[e,t,r,n])}(u,x?.title,a);let ey=(0,i.hb)(e=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth",block:"center"})},[]),ew=(0,i.hb)(e=>ed(e),[]),eN=rB(rH)??{},eY=rB(iM)??{},eD=(0,i.Kr)(()=>g.filter(e=>"user"===e.role),[g]),eF="object"==typeof x?.model?x.model.provider:void 0,eA="object"==typeof x?.model?eN[x.model.modelId]??x.model.modelId:x?.model,eC=!!u?.startsWith("new-"),eS=(0,iR.M)(c,u,m),eT=!eC&&N&&0===g.length;return!u||eC?(0,r.Y)(rv,{className:t,folders:c,selectedFolderId:m,setSelectedFolderId:f,rootPath:eS,inputValue:T,setInputValue:z,inputAttachments:$,setInputAttachments:j,onSend:O,isGenerating:b,appSettings:n,messages:g,provider:eF,providerNames:eY,modelName:eA,modelNames:eN,onThinkingLevelChange:B,onModelChange:H,accessMode:G,onAccessModeChange:V,composerModelRef:Z,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,generatingVerb:D,variant:l}):(0,r.Y)(y.Provider,{value:eo,children:(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas relative ${t}`,children:[eT?(0,r.Y)(rw,{}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"relative flex-1 min-h-0 flex flex-col",children:ev?(0,r.Y)(rV,{sessionId:u,subagent:ev,onBack:ek,provider:eF,providerNames:eY}):(0,r.Y)(r0,{isMobile:d,userMessages:eD,onScrollTo:ey,scrollRef:L,contentRef:M,handleScroll:R,isScrolling:E,loadingOlder:k,hasMore:v,loadOlderError:w,loadOlder:Y,messages:g,isGenerating:b,provider:eF,providerNames:eY,modelName:eA,modelNames:eN,thinkingLevel:x?.thinkingLevel,onUndo:em,onRetry:K,onNewChat:ew,showScrollBottom:P,jumpToBottom:I})}),!ev&&(0,r.Y)(r4,{isMobile:d,isGenerating:b,modelName:eA,generatingVerb:D,provider:eF,providerNames:eY,messageQueue:F,setMessageQueue:A,onEditQueueItem:J,onSendNowQueueItem:_,steeringQueue:C,setSteeringQueue:S,inputValue:T,setInputValue:z,rootPath:eS,attachments:$,setAttachments:j,onSend:O,onStop:eb,appSettings:n,onThinkingLevelChange:B,onModelChange:H,accessMode:G,onAccessModeChange:V,composerModelRef:Z,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,variant:l})]}),eu&&(0,r.Y)(rY,{isOmpSession:!!u&&!u.startsWith("new-")&&Number.isNaN(Number(u)),content:eu.content,undoing:ep,onClose:eh,onConfirm:ef}),null!==ec&&(0,r.Y)(rD,{initialContent:ec,onClose:()=>ed(null),onSend:U,appSettings:n,accessMode:G,onAccessModeChange:V,composerModelRef:Z}),ea&&(0,r.Y)(o,{request:ea,onRespond:el}),(0,r.Y)(iE.y,{toasts:et,onDismiss:er})]})})}},A9(e,t,n){n.d(t,{O:()=>d,k:()=>u});var r=n("j"),i=n("H"),s=n("G"),a=n("X"),l=n("Af"),o=n("ng");let c=(0,s.q6)(null);function d(e){var t;let n,{children:s,initialFolders:d=[]}=e,u=(0,a.L)(),[p,m]=(0,i.J0)(!1),h=(0,i.li)(!1),f=(0,i.li)(new Set);(0,i.vJ)(()=>{h.current||(h.current=!0,u.load("/api/sessions/list"))},[]),(0,i.vJ)(()=>{u.data&&m(!0)},[u.data]);let x=(0,i.Kr)(()=>()=>{"idle"===u.state&&u.load("/api/sessions/list")},[u]),g=!!u.data?.folders?.some(e=>e.sessions?.some(e=>"stream"===e.streamStatus));t=u.data?.folders??[],n=(0,i.li)(null),(0,i.vJ)(()=>{let e=new Set;for(let n of t)for(let t of n.sessions??[])t.awaitingInput&&e.add(String(t.id));let r=n.current;if(n.current=e,r){for(let t of e)if(!r.has(t))return void(0,o.Rn)()}},[t]),(0,l.n)(x,!g,3e4);let b=(0,i.hb)(e=>{let t=String(e),n=u.data?.folders?.flatMap(e=>e.sessions??[]).find(e=>String(e.id)===t)?.streamStatus;!n||"stream"===n||f.current.has(t)||(f.current.add(t),fetch(`/api/sessions/${encodeURIComponent(t)}/stream-seen`,{method:"POST"}).then(()=>{"idle"===u.state&&u.load("/api/sessions/list")}).catch(()=>{f.current.delete(t)}))},[u]),v=(0,i.Kr)(()=>{let e=u.data,t=f.current;return{folders:(e?.folders??d).map(e=>t.size?{...e,sessions:(e.sessions??[]).map(e=>t.has(String(e.id))?{...e,streamStatus:void 0}:e)}:e),isMock:e?.isMock??!1,initializing:!p,refresh:x,markSeen:b,hasSeen:e=>t.has(String(e))}},[u.data,d,p,x,b]);return(0,r.Y)(c.Provider,{value:v,children:s})}function u(){let e=(0,i.NT)(c);return e||{folders:[],isMock:!1,initializing:!0,refresh:()=>{},markSeen:()=>{},hasSeen:()=>!1}}},z4(e,t,n){n.d(t,{K:()=>f});var r=n("H"),i=n("s");function s(e){let t=-1/0;for(let n of e.sessions??[]){let e=function(e){if(!e)return 0/0;let t=Date.parse(e);return Number.isFinite(t)?t:0/0}(n.updated_at??n.created_at);e>t&&(t=e)}return t}function a(e){let t=-1/0;for(let n of e.sessions??[]){let e=Number(n.id);Number.isFinite(e)&&e>t&&(t=e)}return t}function l(e){let t=Number(e.id);return Number.isFinite(t)?t:-1/0}function o(e,t){return e===t?0:e>t?-1:1}function c(e,t){return e===t?0:e>t?1:-1}let d=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"];var u=n("Np"),p=n("A9"),m=n("NO"),h=n("So");function f(){let e,t,n,f,x,g,b,v,k,y,w=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},N=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{includePendingSessions:Y=!1,onSelectSession:D,onAfterSelect:F}=N,{folders:A,initializing:C,refresh:S,markSeen:T,hasSeen:z}=(0,p.k)(),[$,j]=(0,i.o)(),L=$.get("sessionId"),M=L?Number.isNaN(Number(L))?L:Number(L):null,P=(0,r.li)(S);P.current=S;let E=(0,r.hb)(()=>P.current(),[]);(e=(0,r.li)(E)).current=E,t=(0,r.li)(void 0),n=(0,r.li)(0),(0,r.vJ)(()=>{let r=()=>{n.current=Date.now(),e.current()},i=()=>{let e=Date.now()-n.current;if(e>=1e3){clearTimeout(t.current),t.current=void 0,r();return}clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,r()},1e3-e)};return window.addEventListener("omp:session-updated",i),()=>{window.removeEventListener("omp:session-updated",i),void 0!==t.current&&(clearTimeout(t.current),t.current=void 0)}},[]),(0,m.sY)("omp:workspace-updated",()=>P.current());let[R,I]=(0,r.J0)(""),[O,J]=(0,r.J0)(!1),[_,W]=(0,r.J0)(!1),[K,U]=(0,r.J0)(()=>{var e;return"string"==typeof(e=w.omp_sidebar_sort)&&d.includes(e)?w.omp_sidebar_sort:"A-Z"}),q=(0,r.li)(null),B=(0,r.hb)(e=>{q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{(0,h.cz)("omp_sidebar_sort",e)},200)},[]);(0,r.vJ)(()=>()=>{q.current&&clearTimeout(q.current)},[]);let H=(0,r.Kr)(()=>(function(e){let t={};for(let n of e)for(let e of n.sessions??[])e.streamStatus&&(t[String(e.id)]=e.streamStatus);return t})(A),[A]);x=null!==(f=null===M?null:String(M))?H[f]:void 0,g=(0,r.li)(null),(b=(0,r.li)(E)).current=E,(v=(0,r.li)(z)).current=z,(0,r.vJ)(()=>{if(!x||"stream"===x||v.current?.(f))return;let e=`${f}:${x}`;g.current!==e&&(g.current=e,fetch(`/api/sessions/${encodeURIComponent(f)}/stream-seen`,{method:"POST"}).then(e=>e.json()).then(e=>{!1===e.deleted&&(g.current=null),b.current()}).catch(()=>{g.current=null}))},[f,x]),(k=(0,r.li)(Object.values(H).includes("stream"))).current=Object.values(H).includes("stream"),(y=(0,r.li)(E)).current=E,(0,r.vJ)(()=>{let e=setInterval(()=>{k.current&&y.current()},8e3);return()=>clearInterval(e)},[]);let G=(0,r.Kr)(()=>{let e=[...A];if(Y){let t=e.some(e=>e.sessions?.some(e=>String(e.id)===String(L))),n=L&&!t?L:null;if(n){let t=$.get("folderId"),r=t?e.find(e=>String(e.id)===String(t)):e[0],i=!!r?.sessions?.some(e=>String(e.id)===String(n));if(r&&!i){let t=(0,u.fd)(n),i=Number.isFinite(t)?new Date(t).toISOString():new Date().toISOString();e=e.map(e=>{if(e.id!==r.id)return e;let t={id:n,folder_id:e.id,title:(0,u.g2)(n),created_at:i,updated_at:i};return{...e,isExpanded:!0,sessions:[t,...e.sessions||[]]}})}}}if(R.trim()){let t=R.toLowerCase();e=Y?e.filter(e=>{let n=e.name.toLowerCase().includes(t),r=e.sessions?.some(e=>e.title.toLowerCase().includes(t));return n||r}).map(e=>{let n=e.sessions?.filter(n=>e.name.toLowerCase().includes(t)||n.title.toLowerCase().includes(t));return{...e,sessions:n,isExpanded:!0}}):e.map(e=>{let n=e.name.toLowerCase().includes(t),r=(e.sessions||[]).filter(e=>e.title.toLowerCase().includes(t));return n?e:{...e,sessions:r}}).filter(e=>e.sessions&&e.sessions.length>0)}return e=[...e].sort((e,t)=>(function(e,t,n){let r=!!e.isPinned;if(r!==!!t.isPinned)return r?-1:1;switch(n){case"Z-A":{let n=t.name.localeCompare(e.name);return 0!==n?n:c(l(e),l(t))}case"LATEST_SESSION":{let n=o(s(e),s(t));if(0!==n)return n;let r=o(a(e),a(t));if(0!==r)return r;let i=o(l(e),l(t));return 0!==i?i:e.name.localeCompare(t.name)}case"LATEST_ADDED":{let n=o(l(e),l(t));return 0!==n?n:e.name.localeCompare(t.name)}default:{let n=e.name.localeCompare(t.name);return 0!==n?n:c(l(e),l(t))}}})(e,t,K))},[A,R,K,L,$,Y]);return{folders:A,initializing:C,refresh:E,activeSessionId:M,sessionParam:L,searchQuery:R,setSearchQuery:I,showArchived:O,setShowArchived:J,optionsOpen:_,setOptionsOpen:W,sortOption:K,handleSortChange:e=>{U(e),W(!1),B(e)},processedFolders:G,sessionStatus:H,handleSelectSession:e=>{T(e),D?D(e):j(t=>(t.set("sessionId",e.toString()),t.has("subagent")&&t.delete("subagent"),t),{replace:!0}),F?.()}}}},FE(e,t,n){var r=n("H"),i=n("g0");function s(){let[e,t]=(0,r.J0)(i.aK);return(0,r.vJ)(()=>{let e=e=>{let n=e.detail;n&&t({transport:n.transport,connected:n.connected})};return window.addEventListener(i.rt,e),t((0,i.aK)()),()=>window.removeEventListener(i.rt,e)},[]),e}n.d(t,{H:()=>s})},pH(e,t,n){async function r(e){if(!e)return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch(e){}try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}catch(e){return console.error("Failed to copy text: ",e),!1}}n.d(t,{l:()=>r})},P6(e,t,n){var r=n("H");function i(e,t){let[n,i]=(0,r.J0)(!1),[s,a]=(0,r.J0)(e),l=(0,r.li)(null),o=(0,r.li)(!1);(0,r.vJ)(()=>{n&&l.current?.select()},[n]);let c=()=>{let n=s.trim();i(!1),n&&n!==e&&t?.(n)},d=()=>{o.current=!0,i(!1)};return{isEditing:n,draft:s,setDraft:a,inputRef:l,startRename:()=>{o.current=!1,a(e),i(!0)},commitRename:c,cancelRename:d,handleKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),c()):"Escape"===e.key&&(e.preventDefault(),d())},handleBlur:()=>{if(o.current){o.current=!1;return}c()}}}n.d(t,{B:()=>i})},ng(e,t,n){n("H");var r=n("So");function i(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type="sine",r.frequency.setValueAtTime(587.33,n),r.frequency.exponentialRampToValueAtTime(880,n+.1),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.14,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.32),r.connect(i),i.connect(t.destination),r.start(n),r.stop(n+.32);let s=t.createOscillator(),a=t.createGain();s.type="sine",s.frequency.setValueAtTime(880,n+.06),s.frequency.exponentialRampToValueAtTime(1174.66,n+.18),a.gain.setValueAtTime(0,n+.06),a.gain.linearRampToValueAtTime(.1,n+.08),a.gain.exponentialRampToValueAtTime(1e-4,n+.42),s.connect(a),a.connect(t.destination),s.start(n+.06),s.stop(n+.42),setTimeout(()=>{try{t.close()}catch{}},550)}catch(e){console.warn("Unable to play notification audio chime:",e)}}function s(e){if("u"<typeof window)return!0;let t=(0,r.BF)(["chatCompletionSound","soundAlerts"],e);return void 0===t||!!t}function a(e){s(e)&&i()}function l(){s()&&function(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime;for(let e of[{at:0,frequency:880,duration:.18,peak:.11},{at:.16,frequency:659.25,duration:.46,peak:.13}]){let r=t.createOscillator(),i=t.createGain();r.type="triangle",r.frequency.setValueAtTime(e.frequency,n+e.at),i.gain.setValueAtTime(0,n+e.at),i.gain.linearRampToValueAtTime(e.peak,n+e.at+.015),i.gain.exponentialRampToValueAtTime(1e-4,n+e.at+e.duration),r.connect(i),i.connect(t.destination),r.start(n+e.at),r.stop(n+e.at+e.duration)}setTimeout(()=>{try{t.close()}catch{}},800)}catch(e){console.warn("Unable to play input-required audio cue:",e)}}()}n.d(t,{$E:()=>i,Rn:()=>l,s4:()=>a})},oj(e,t,n){var r=n("H");function i(e,t){(0,r.vJ)(()=>{let n=n=>{!e.current||e.current.contains(n.target)||t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}n.d(t,{W:()=>i})},jo(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,[t,n]=(0,r.J0)(!1),i=(0,r.li)(null),s=(0,r.hb)(()=>{n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),e)},[e]);return(0,r.vJ)(()=>()=>{i.current&&clearTimeout(i.current)},[]),{isScrolling:t,handleScroll:s}}function s(e){return e?"scrollbar-overlay-scrolling":"scrollbar-overlay"}n.d(t,{K:()=>i,p:()=>s})},NR(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:7,[n,i]=(0,r.J0)(e);return{visibleCount:n,showMore:(0,r.hb)(()=>i(e=>e+t),[t])}}n.d(t,{y:()=>i})},Po(e,t,n){var r=n("H"),i=n("eh");function s(){let[e,t]=(0,r.J0)(()=>(0,i.nv)());return(0,r.vJ)(()=>{let e=(0,i.Eu)(()=>t(!0)),n=(0,i.LT)(()=>t(!0));return()=>{e(),n()}},[]),e}n.d(t,{w:()=>s})},oZ(e,t,n){var r=n("H");function i(){let[e,t]=(0,r.J0)([]),n=(0,r.li)(0);return{toasts:e,pushToast:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error",i=arguments.length>2?arguments[2]:void 0;n.current+=1,t(t=>[...t,{id:n.current,message:e,type:r,...i}])},dismissToast:e=>{t(t=>t.filter(t=>t.id!==e))}}}n.d(t,{Y:()=>i})},DO(e,t,n){var r=n("H");function i(e,t){return"object"!=typeof e||null===e?t:"error"in e&&"string"==typeof e.error?e.error:"message"in e&&"string"==typeof e.message?e.message:t}function s(){let[e,t]=(0,r.J0)(null),[n,s]=(0,r.J0)(!1),[a,l]=(0,r.J0)(null),[o,c]=(0,r.J0)(null),d=(0,r.li)(null),u=(0,r.li)(!1),p=(0,r.hb)(()=>{if(d.current)return d.current;let e=(async()=>{s(!0),c(null);try{let e=await fetch("/api/updates/check"),n=await e.json();if(!e.ok)throw Error(i(n,`Update check failed (HTTP ${e.status})`));t(n)}catch(e){c(e instanceof Error?e.message:"Unable to check for updates.")}finally{s(!1),d.current=null}})();return d.current=e,e},[]),m=(0,r.hb)(async e=>{l(e),c(null);try{let t=await fetch("/api/updates/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:e})}),n=await t.json();if("object"!=typeof n||null===n||!("success"in n)||"boolean"!=typeof n.success||!("target"in n)||"ompchamber"!==n.target&&"omp"!==n.target||!("manual"in n)||"boolean"!=typeof n.manual||!("message"in n)||"string"!=typeof n.message)throw Error(i(n,`Update failed (HTTP ${t.status})`));return await p(),n}catch(e){return c(e instanceof Error?e.message:"Unable to apply the update."),null}finally{l(null)}},[p]);return(0,r.vJ)(()=>{u.current||(u.current=!0,p())},[]),{info:e,checking:n,applying:a,error:o,hasUpdate:!!(e?.ompchamber.updateAvailable||e?.omp.updateAvailable),check:p,apply:m}}n.d(t,{M:()=>s})},c(e,t,n){var r=n("H");function i(e,t){let{enabled:n,intervalMs:i,guardInFlight:s=!1}=t,a=(0,r.li)(e);a.current=e,(0,r.vJ)(()=>{if(!n||i<=0)return;let e="u"<typeof document||"visible"===document.visibilityState,t=!1,r=()=>{if(!s)return void a.current();if(t)return;let e=a.current();if(!e||"function"!=typeof e.then)return;t=!0;let n=()=>{t=!1};Promise.resolve(e).then(n,n)},l=setInterval(()=>{e&&r()},i),o=()=>{let t="visible"===document.visibilityState;t&&!e&&r(),e=t};return document.addEventListener("visibilitychange",o),()=>{clearInterval(l),document.removeEventListener("visibilitychange",o)}},[n,i,s])}n.d(t,{t:()=>i})},NO(e,t,n){var r=n("H");function i(e,t,n,i){let s=(0,r.li)(n);s.current=n,(0,r.vJ)(()=>{let n=e=>s.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[e,t,i])}function s(e,t,n){i(window,e,t,n)}function a(e,t,n){i(document,e,t,n)}function l(e,t,n){i(window,e,t,n)}n.d(t,{MN:()=>s,sY:()=>l,zo:()=>a})},so(e,t,n){var r=n("H"),i=n("LQ"),s=n("c"),a=n("NO");function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,l=!(arguments.length>3)||void 0===arguments[3]||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,[c,d]=(0,r.J0)([]),[u,p]=(0,r.J0)(!1),m=(0,r.hb)(()=>{if(!l)return;p(!0);let n=new URLSearchParams;e&&n.set("root",e),t&&"."!==t&&n.set("repo",t),n.set("t",String(Date.now())),fetch(`/api/fs/git?${n.toString()}`).then(e=>e.json()).then(e=>{Array.isArray(e.changes)?d(e.changes):d([])}).catch(()=>d([])).finally(()=>p(!1))},[l,e,t]);(0,r.vJ)(()=>{m()},[m,n]),(0,s.t)(m,{enabled:l,intervalMs:o}),(0,a.MN)("focus",()=>{l&&m()}),(0,a.zo)("visibilitychange",()=>{l&&m()});let h=(0,r.li)(void 0),f=(0,r.hb)(()=>{l&&void 0===h.current&&(h.current=setTimeout(()=>{h.current=void 0,m()},1e3))},[l,m]);(0,r.vJ)(()=>()=>{void 0!==h.current&&clearTimeout(h.current)},[]),(0,a.sY)("omp:session-updated",f),(0,a.sY)("omp:workspace-updated",f);let{fileMap:x,folderMap:g}=(0,r.Kr)(()=>(0,i._)(c),[c]);return{changes:c,fileMap:x,folderMap:g,isLoading:u,refreshGitStatus:m}}n.d(t,{e:()=>l})},Af(e,t,n){var r=n("H"),i=n("K"),s=n("c");function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;(0,s.t)(e,{enabled:t,intervalMs:n,guardInFlight:!0})}function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,s=(0,r.li)(e);s.current=e,(0,r.vJ)(()=>{let e;if(!t)return;let r=()=>{clearTimeout(e),e=window.setTimeout(()=>{e=void 0,("u"<typeof document||"visible"===document.visibilityState)&&s.current()},n)};return window.addEventListener(i.s,r),()=>{window.removeEventListener(i.s,r),clearTimeout(e)}},[t,n])}n.d(t,{n:()=>a,w:()=>l})},As(e,t,n){var r=n("H");let i=(0,n("G").q6)(null);function s(){let e=(0,r.NT)(i);if(!e)throw Error("useSessionState used outside SessionStateProvider");return e}n.d(t,{O:()=>s},{b:i})},FL(e,t,n){var r=n("H"),i=n("SS"),s=n("As");function a(e,t){let{sessionId:n,ready:a}=(0,s.O)(),l=(0,i.WV)(n,e),[o,c]=(0,r.J0)(void 0===l?t:l),d=(0,r.li)(n);(0,r.vJ)(()=>{if(d.current!==n&&(d.current=n),!a)return;let r=(0,i.WV)(n,e);c(void 0===r?t:r)},[n,a,e]);let u=t=>{let r="function"==typeof t?t((0,i.WV)(n,e)??o):t;c(r),(0,i.qI)(n,e,r)};return a||void 0===l||l===o?[o,u,a]:[l,u,a]}function l(){let{sessionId:e,ready:t}=(0,s.O)();return{sessionId:e,ready:t,read:(t,n)=>{let r=(0,i.WV)(e,t);return void 0===r?n:r},hydrate:t=>(0,i.E9)(e,t)}}n.d(t,{bL:()=>a,p0:()=>l},{LO:a})},U(e,t,n){var r=n("H"),i=n("X");function s(e,t){let[n,s]=(0,r.J0)(!1),a=(0,i.L)(),l=(0,i.L)(),o=(0,i.L)();return(0,r.vJ)(()=>{(a.data?.success||l.data?.success)&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[l.data,a.data]),{confirmDelete:n,requestDelete:()=>s(!0),cancelDelete:()=>s(!1),handlePin:()=>{"number"==typeof e.id&&(a.submit({isPinned:String(!e.isPinned)},{method:"POST",action:`/api/folders/${e.id}/pin`}),t())},handleDelete:()=>{"number"==typeof e.id&&(l.submit({},{method:"POST",action:`/api/folders/${e.id}/delete`}),s(!1),t())},handleArchive:e=>{let n=1!==e.is_archived;o.submit({archived:String(n)},{method:"POST",action:`/api/sessions/${e.id}/archive`}),t()},handleRename:async(e,n)=>{try{let t=new FormData;if(t.set("name",n),!(await fetch(`/api/sessions/${encodeURIComponent(String(e.id))}/rename`,{method:"POST",body:t})).ok)return}catch{return}window.dispatchEvent(new CustomEvent("omp:session-renamed",{detail:{sessionId:String(e.id),title:n}})),t()}}}n.d(t,{C:()=>s})},X(e,t,n){var r=n("H");async function i(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function s(){let[e,t]=(0,r.J0)(void 0),[n,s]=(0,r.J0)("idle"),a=(0,r.li)(!0),l=(0,r.li)(null);(0,r.vJ)(()=>(a.current=!0,()=>{a.current=!1,l.current?.abort(),l.current=null}),[]);let o=(0,r.hb)(async(e,n,r)=>{l.current?.abort();let o=new AbortController;l.current=o,s(r);try{let r=await fetch(e,{...n,signal:o.signal}),s=await i(r);a.current&&l.current===o&&t(s)}catch{}finally{a.current&&l.current===o&&(l.current=null,s("idle"))}},[]);return{data:e,state:n,load:(0,r.hb)(e=>o(e,{method:"GET"},"loading"),[o]),submit:(0,r.hb)((e,t)=>o(t.action,{method:(t.method??"POST").toUpperCase(),body:function(e){if(e instanceof FormData)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t}(e),headers:e instanceof FormData?void 0:{"content-type":"application/x-www-form-urlencoded"}},"submitting"),[o])}}n.d(t,{L:()=>s})},s(e,t,n){var r=n("G");let i=new Set,s="u"<typeof window?"":window.location.search;function a(){for(let e of i)e()}function l(e){return i.add(e),()=>i.delete(e)}function o(e){if("string"==typeof e)return e.startsWith("?")?e:`?${e}`;if(e instanceof URLSearchParams)return e.toString()?`?${e.toString()}`:"";let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t.toString()?`?${t.toString()}`:""}function c(){return s}function d(){let e=(0,r.rz)(l,c),t=(0,r.hb)((e,t)=>{var n;let r=(n=new URLSearchParams(s),"function"==typeof e?o(e(new URLSearchParams(n))):o(e)),i=`${window.location.pathname}${r}${window.location.hash}`;t?.replace?window.history.replaceState(null,"",i):window.history.pushState(null,"",i),s=r,a()},[]);return[new URLSearchParams(e),t]}"u">typeof window&&window.addEventListener("popstate",function(){let e="u"<typeof window?"":window.location.search;e!==s&&(s=e,a())}),n.d(t,{o:()=>d})},l(e,t,n){var r=n("j"),i=n("v"),s=n("H"),a=n("G"),l=n("s");function o(e,t,n){return Math.min(Math.max(e,t),n)}function c(e,t){return"number"==typeof e?e:"string"==typeof e&&parseFloat(e)||t}let d=(0,a.q6)(null);function u(e){let{orientation:t,id:n,groupRef:i,onLayoutChanged:l,className:c,children:u}=e,p=(0,s.li)(new Map),m=(0,s.li)(l??null);m.current=l??null;let h=(0,a.Kr)(()=>({orientation:t,panels:p,onLayoutChanged:m}),[t]);return(0,a.vJ)(()=>{if(i)return i.current={setLayout:e=>{for(let[t,n]of Object.entries(e)){let e=p.current.get(t);e&&!e.isFiller&&"number"==typeof n&&e.setSize(o(n,e.minSize,e.maxSize))}m.current?.((()=>{let e={};for(let[t,n]of p.current){let r=n.getSize();null!=r&&(e[t]=r)}return e})(),{isUserInteraction:!1})}},()=>{i.current=null}},[i]),(0,r.Y)(d.Provider,{value:h,children:(0,r.Y)("div",{"data-panel-group":"","data-panel-group-id":n,className:c,style:{display:"flex",flex:"1 1 0%",flexDirection:"horizontal"===t?"row":"column",minWidth:0,minHeight:0},children:u})})}function p(e){let{id:t,panelRef:n,defaultSize:i,minSize:s=0,maxSize:l,filler:u=!1,className:p,style:m,children:h}=e,f=(0,a.NT)(d);if(!f)throw Error(`<Panel id="${t}"> must be rendered inside a <Group>`);let{orientation:x,panels:g}=f,b=c(s,0),v=null!=l?c(l,Number.MAX_SAFE_INTEGER):Number.MAX_SAFE_INTEGER,k=(0,a.li)(null),[y,w]=(0,a.J0)(()=>u?null:o(c(i,b),b,v)),N=(0,a.li)(y);N.current=y,(0,a.vJ)(()=>(g.current.set(t,{id:t,isFiller:u,minSize:b,maxSize:v,setSize:e=>w(e),getSize:()=>N.current}),()=>{g.current.delete(t)}),[t]),(0,a.vJ)(()=>{let e=g.current.get(t);e&&(e.minSize=b,e.maxSize=v)}),(0,a.vJ)(()=>{if(n)return n.current={resize:e=>{w(o(e,b,v))},getSize:()=>{let e=N.current;return null!=e?{inPixels:e}:null}},()=>{n.current=null}},[n,b,v]);let Y=u?{flex:"1 1 0%",minWidth:"horizontal"===x?b:0,minHeight:"horizontal"===x?0:b,overflow:"hidden",position:"relative"}:{flex:"0 1 auto",width:"horizontal"===x?y??void 0:void 0,height:"horizontal"===x?void 0:y??void 0,minWidth:"horizontal"===x?b:void 0,minHeight:"horizontal"===x?void 0:b,maxWidth:null!=l?v:void 0,overflow:"hidden",position:"relative"};return(0,r.Y)("div",{ref:k,"data-panel":"","data-panel-id":t,className:p,style:{...Y,...m},children:h})}function m(e){let{className:t,style:n,children:i}=e,s=(0,a.NT)(d),[l,c]=(0,a.J0)(!1),u=(0,a.li)(null),p=(0,a.li)(null);if((0,a.vJ)(()=>()=>p.current?.(),[]),!s)throw Error("<Separator> must be rendered inside a <Group>");let{orientation:m,panels:h,onLayoutChanged:f}=s;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{ref:u,"data-separator":"",role:"separator","aria-orientation":"horizontal"===m?"vertical":"horizontal",className:t,style:n,onPointerDown:e=>{let t=u.current;if(!t||0!==e.button)return;let n=t.previousElementSibling,r=t.nextElementSibling,i=n?.getAttribute("data-panel-id"),s=r?.getAttribute("data-panel-id"),a=i?h.current.get(i):void 0,l=s?h.current.get(s):void 0;if(!a||!l||!n||!r)return;e.preventDefault(),c(!0);let d="horizontal"===m?e.clientX:e.clientY,x=e=>"horizontal"===m?e.getBoundingClientRect().width:e.getBoundingClientRect().height,g=x(n),b=x(r),v=e=>{var t,n;let r="horizontal"===m?e.clientX:e.clientY,i=(t={size:g,min:a.minSize,max:a.maxSize},n={size:b,min:l.minSize,max:l.maxSize},o(r-d,Math.max(t.min-t.size,n.size-n.max),Math.min(t.max-t.size,n.size-n.min)));a.setSize(o(g+i,a.minSize,a.maxSize)),l.isFiller||l.setSize(o(b-i,l.minSize,l.maxSize))},k=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),p.current=null,c(!1);let e={};for(let[t,n]of h.current){let r=n.getSize();null!=r&&(e[t]=r)}f.current?.(e,{isUserInteraction:!0})},y=()=>k();window.addEventListener("pointermove",v),window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),p.current=k},onDragStart:e=>e.preventDefault(),children:i}),l&&(0,r.Y)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"horizontal"===m?"col-resize":"row-resize"}})]})}var h=n("g"),f=n("r");function x(e){let{onNewSession:t}=e;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"h-12 flex-shrink-0 flex items-center px-4 border-b border-ink/10 titlebar-drag-region select-none",style:{paddingLeft:"max(1rem, env(titlebar-area-x, 0px))"},children:(0,r.FD)("span",{className:"font-bold text-sm tracking-tight flex items-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]})}),(0,r.Y)("div",{className:"px-3 pt-3 titlebar-no-drag",children:(0,r.FD)("button",{onClick:t,className:"w-full flex items-center justify-center space-x-2 py-2 bg-ink text-canvas rounded text-xs font-semibold hover:bg-ink/90 transition-colors cursor-pointer",children:[(0,r.Y)(f.A,{size:14}),(0,r.Y)("span",{children:"New Session"})]})})]})}var g=n("D"),b=n("O"),v=n("n"),k=n("t3"),y=n("p7"),w=n("Sj"),N=n("x"),Y=n("S"),D=n("E");function F(e){let{isSearchVisible:t,searchQuery:n,showArchived:i,optionsOpen:s,sortOption:a,onToggleSearch:l,onSearchChange:o,onToggleArchived:c,onHideArchived:d,onToggleOptions:u,onCloseOptions:p,onSortChange:m,onNewWorkspace:h,onScheduler:f,onRefresh:x,onClose:F}=e;return(0,r.FD)("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between px-1 text-ink/60",children:[(0,r.FD)("div",{className:"flex space-x-3 items-center",children:[(0,r.Y)(g.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:h}),(0,r.Y)(b.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:f}),(0,r.Y)("span",{title:"Refresh sessions",onClick:x,className:"inline-flex cursor-pointer",children:(0,r.Y)(v.A,{size:14,className:"hover:text-ink"})})]}),(0,r.FD)("div",{className:"flex space-x-3 items-center relative",children:[(0,r.Y)(k.A,{size:14,className:`cursor-pointer transition-colors ${t?"text-ink":"hover:text-ink"}`,onClick:l}),(0,r.Y)("span",{title:i?"Hide Archive":"Show Archive",onClick:c,className:"inline-flex cursor-pointer",children:(0,r.Y)(y.A,{size:14,className:`transition-colors ${i?"text-ink":"hover:text-ink"}`})}),(0,r.FD)("div",{className:"relative",children:[(0,r.Y)(w.A,{size:14,className:`cursor-pointer transition-colors ${s?"text-ink":"hover:text-ink"}`,onClick:u}),s&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",onMouseLeave:p,children:(0,r.Y)(D.i,{variant:"desktop",sortOption:a,onSortChange:m})})]}),(0,r.Y)(N.A,{size:14,className:"hover:text-ink cursor-pointer ml-1",onClick:F})]})]}),t&&(0,r.Y)("div",{className:"pt-1",children:(0,r.Y)("input",{type:"text",placeholder:"Search workspaces & sessions...",value:n,onChange:e=>o(e.currentTarget.value),autoFocus:!0,className:"w-full bg-ink/5 border border-ink/10 rounded px-2.5 py-1.5 outline-none focus:border-ink/30 text-xs text-ink placeholder-ink/40 transition-colors"})}),i&&(0,r.FD)("div",{className:"flex items-center justify-between bg-amber-500/10 border border-amber-500/20 text-amber-900 rounded px-2.5 py-1.5 text-[10px] font-medium",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:[(0,r.Y)(y.A,{size:10}),(0,r.Y)("span",{children:"Showing Archived"})]}),(0,r.Y)("button",{className:"hover:text-amber-950",onClick:d,children:(0,r.Y)(Y.A,{size:10})})]})]})}var A=n("vB"),C=n("wU");function S(e){let{onSettings:t,onInfo:n,updateAvailable:i,onUpdateClick:s}=e;return(0,r.FD)("div",{className:"p-3 border-t border-ink/10 flex items-center justify-between text-ink/60 shrink-0",children:[(0,r.FD)("div",{className:"flex space-x-3",children:[(0,r.Y)(A.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:t}),(0,r.Y)(C.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:n})]}),i&&(0,r.Y)("button",{type:"button",onClick:s,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})}var T=n("a"),z=n("X"),$=n("oj"),j=n("NR"),L=n("U"),M=n("Go"),P=n("Nf"),E=n("WO"),R=n("t"),I=n("z"),O=n("b"),J=n("HZ"),_=n("P6");function W(e){let{title:t,isActive:n=!1,isArchived:i=!1,status:s,awaitingInput:a=!1,onClick:l,onArchive:o,onRename:c,expandable:d=!1,isExpanded:u=!1,hasSubagents:p=!1,onToggleExpand:m}=e,h=!!(d&&p&&m),{isEditing:f,draft:x,setDraft:g,inputRef:b,startRename:v,handleKeyDown:k,handleBlur:w}=(0,_.B)(t,c);return(0,r.FD)("div",{onClick:f?void 0:l,className:`group/item relative flex items-center w-full rounded-lg px-2 py-1.5 cursor-pointer text-xs transition-colors select-none ${n?"bg-ink/10 font-medium text-ink":"text-ink/75 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.FD)("span",{className:"relative w-4 h-4 shrink-0",children:[h&&m&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),m(e)},title:u?"Collapse subagents":"Expand subagents","aria-expanded":u,className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer text-ink/40 transition-opacity hover:text-ink ${u?"":"pointer-events-none opacity-0 group-hover/item:pointer-events-auto group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:u?(0,r.Y)(M.A,{size:13,className:"text-ink/70"}):(0,r.Y)(P.A,{size:13})}),(a||s)&&!(h&&u)&&(0,r.Y)("span",{className:`absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${h?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:a?(0,r.Y)(E.A,{size:12,className:"animate-pulse text-ink/80"}):"stream"===s?(0,r.Y)(R.A,{size:12,className:"animate-spin"}):(0,r.Y)(I.A,{size:12})})]}),(0,r.Y)("span",{className:"w-2 shrink-0"}),f?(0,r.Y)("input",{ref:b,autoFocus:!0,value:x,onChange:e=>g(e.currentTarget.value),onClick:e=>e.stopPropagation(),onKeyDown:k,onBlur:w,className:"flex-1 min-w-0 bg-paper border border-ink/25 rounded px-1 py-0.5 text-xs text-ink outline-none focus:border-ink/50"}):(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:t.charAt(0).toUpperCase()+t.slice(1)}),!f&&(c||o)&&(0,r.FD)("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2 flex items-center gap-0.5 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[c&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),v()},title:"Rename session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:(0,r.Y)(O.A,{size:12})}),o&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),o()},title:i?"Unarchive session":"Archive session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:i?(0,r.Y)(J.A,{size:12}):(0,r.Y)(y.A,{size:12})})]})]})}var K=n("Uo"),U=n("oS"),q=n("B"),B=n("T");let H={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function G(e){let{sessionId:t,isActiveSession:n}=e,[i]=(0,l.o)(),a=i.get("subagent"),[o,c]=(0,s.J0)([]),[d,u]=(0,s.J0)(!1);(0,s.vJ)(()=>{let e=!1,n=String(t);return c([]),u(!0),(0,q.wv)(n).then(t=>{if(e||!t)return;let n=t.map(q.Nh);c(e=>(0,B.j8)(e,n))}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t]),(0,s.vJ)(()=>{if(!n)return;let e=!1,r=String(t),i=Date.now(),s=e=>{let t=e.detail;return t&&t.sessionId===r?t:null},a=e=>{let t=(0,B.bH)(s(e)?.payload);t&&c(e=>(0,B.j8)(e,[t]))},l=e=>{let t=function(e){let t=(0,B.mq)(e);if(!(0,U.u)(e)||!(0,U.u)(e.progress))return t;let n=(0,B.mq)(e.progress);return n?{...n,id:n.id??t?.id,index:n.index??t?.index}:t}(s(e)?.payload);t&&c(e=>e.map(e=>{if(void 0!==t.id){if(e.id!==t.id)return e}else if(void 0===t.index||t.index<0||e.index!==t.index)return e;let n=t.status&&"started"===e.status?H[t.status]??e.status:e.status;return{...e,status:n,progress:{...e.progress,...t},lastUpdate:Date.now()}}))};return window.addEventListener("subagent_lifecycle",a),window.addEventListener("subagent_progress",l),fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then(e=>e.ok?e.json():null).then(t=>{if(e||!(0,U.u)(t))return;let n="data"in t?t.data:t;c(e=>(0,B.j8)(e,(0,B.vG)(n),i))}).catch(()=>{}),()=>{e=!0,window.removeEventListener("subagent_lifecycle",a),window.removeEventListener("subagent_progress",l)}},[n,t]);let p=d?"Loading subagents…":0===o.length?"No subagent activity":null;return(0,r.Y)("div",{className:"pl-6 pr-0 space-y-0.5 py-0.5",children:p?(0,r.FD)("div",{className:"px-2 py-1 text-xs italic text-ink/40 flex items-center",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate",children:p})]}):o.map(e=>{let i=e.task??e.description??e.assignment??e.agent??"",s=e.id===a;return(0,r.FD)("button",{type:"button",title:i,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:String(t),subagent:e}})),className:`w-full flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${s?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:(0,r.Y)(K.l,{status:e.status,live:n&&"started"===e.status,size:11})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:i})]},e.id)})})}var V=n("C4"),Z=n("So");let Q="omp_sidebar_expanded_sessions";var X=n("A"),ee=n("A9");function et(e){let{folder:t,activeSessionId:n,onSelectSession:i,onNewSessionForFolder:a,forceExpanded:o=!1,showArchived:c=!1,sessionStatus:d={}}=e,[u,p]=(0,s.J0)(t.isExpanded||!1),[m,h]=(0,s.J0)(!1),{visibleCount:x,showMore:g}=(0,j.y)(),[b]=(0,l.o)(),v=b.get("subagent"),k=b.get("sessionId"),[y,N]=(0,s.J0)(()=>new Set);(0,s.vJ)(()=>{let e,t=Array.isArray(e=(0,Z.BF)(Q))?new Set(e.filter(e=>"string"==typeof e)):new Set;t&&t.size>0&&N(t)},[]),(0,s.vJ)(()=>{"boolean"==typeof t.isExpanded&&p(t.isExpanded)},[t.isExpanded]),(0,s.vJ)(()=>{v&&k&&N(e=>{if(e.has(k))return e;let t=new Set(e);return t.add(k),t})},[v,k]);let Y=(0,s.li)(null),{refresh:D}=(0,ee.k)(),F=(0,z.L)(),{confirmDelete:A,requestDelete:C,cancelDelete:S,handlePin:M,handleDelete:P,handleArchive:E,handleRename:R}=(0,L.C)(t,D);(0,s.vJ)(()=>{F.data?.success&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[F.data]),(0,$.W)(Y,()=>{h(!1),S()});let I=t.sessions,O=(0,X.x)(t.icon),J=(I||[]).filter(e=>c?1===e.is_archived:1!==e.is_archived),_=J.slice(0,x),K=J.length>x;return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.FD)("div",{className:"group flex items-center justify-between h-7 text-xs font-semibold text-ink px-2 hover:bg-ink/5 rounded-md transition-colors select-none",children:[(0,r.FD)("div",{className:"flex-1 h-full flex items-center cursor-pointer min-w-0",onClick:()=>{let e=!u;p(e),"number"==typeof t.id&&F.submit({isExpanded:String(e)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:t.customIconUrl?(0,r.Y)("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain shrink-0",referrerPolicy:"no-referrer"}):(0,r.Y)(O,{size:15,className:"text-ink/75",style:{color:t.accentColor||void 0}})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),t.isPinned&&(0,r.Y)(T.A,{size:11,className:"text-ink/60 shrink-0 mr-1.5"}),(0,r.Y)("span",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})]}),(0,r.FD)("div",{className:`items-center space-x-0.5 pl-1 ${m?"flex":"hidden group-hover:flex"}`,children:[(0,r.Y)("button",{type:"button",title:"New Session",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),a(t.id)},children:(0,r.Y)(f.A,{size:12})}),(0,r.FD)("div",{className:"relative flex items-center",ref:Y,children:[(0,r.Y)("button",{type:"button",title:"Workspace Options",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),h(!m)},children:(0,r.Y)(w.A,{size:12})}),m&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 text-xs",children:(0,r.Y)(V.t,{variant:"desktop",isPinned:t.isPinned,confirmDelete:A,onPin:()=>{M(),h(!1)},onDelete:()=>{P(),h(!1)},onRequestDelete:C,onCancelDelete:S})})]})]})]}),(o||u)&&(0,r.FD)("div",{className:"space-y-0.5",children:[_.map(e=>{let t=String(e.id),s=null!==n?String(n)===t:1===e.is_active,a=s&&k===t&&!!v,l=null!==n&&t===String(n),o=!!e.hasSubagents,c=o&&y.has(t);return(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.Y)(W,{title:e.title,isActive:s&&!a,isArchived:1===e.is_archived,status:d[t],awaitingInput:!!e.awaitingInput,onClick:()=>i(e.id),onArchive:()=>E(e),onRename:String(e.id).startsWith("new-")?void 0:t=>void R(e,t),expandable:o,hasSubagents:o,isExpanded:c,onToggleExpand:()=>{N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),(0,Z.cz)(Q,[...n].slice(-50)),n})}}),o&&c&&(0,r.Y)(G,{sessionId:e.id,isActiveSession:l})]},e.id)}),K&&!o&&(0,r.FD)("button",{type:"button",onClick:g,className:"flex items-center text-xs text-ink/45 hover:text-ink/80 w-full text-left py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"truncate leading-snug",children:"Show more sessions"})]}),0===J.length&&(0,r.Y)("div",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:c?"No archived sessions.":"No sessions."})]})]})}var en=n("jo");function er(e){let{folders:t,activeSessionId:n,searchQuery:i,showArchived:s,sessionStatus:a,isScrolling:l,onScroll:o,onSelectSession:c,onNewSessionForFolder:d}=e;return(0,r.Y)("div",{onScroll:o,className:`flex-1 scrollbar-overlay-container p-2 space-y-4 ${(0,en.p)(l)}`,children:0===t.length?(0,r.Y)("div",{className:"text-center py-8 text-xs text-ink/40",children:i?"No results found.":"No workspaces available."}):t.map(e=>(0,r.Y)(et,{folder:e,activeSessionId:n,onSelectSession:c,onNewSessionForFolder:d,forceExpanded:!!i,showArchived:s,sessionStatus:a},e.id))})}let ei=[3,2];function es(){return(0,r.Y)("div",{className:"flex-1 p-2 space-y-4","aria-hidden":"true",children:ei.map((e,t)=>(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,r.Y)("span",{className:"w-3.5 h-3.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded px-2 py-1.5",children:[(0,r.Y)("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-t%3*12}%`}})]},t))]},t))})}var ea=n("wu"),el=n("wm"),eo=n("oZ"),ec=n("DO"),ed=n("z4");function eu(e){let{className:t="",onClose:n,appSettings:i={}}=e,{folders:a,initializing:o,refresh:c,activeSessionId:d,sessionParam:u,searchQuery:p,setSearchQuery:m,showArchived:f,setShowArchived:g,optionsOpen:b,setOptionsOpen:v,sortOption:k,handleSortChange:y,processedFolders:w,sessionStatus:N,handleSelectSession:Y}=(0,ed.K)(i,{includePendingSessions:!0}),[,D]=(0,l.o)(),[A,C]=(0,s.J0)(!1),[T,z]=(0,s.J0)(!1),[$,j]=(0,s.J0)(!1),[L,M]=(0,s.J0)(!1),P=(0,ec.M)(),{toasts:E,pushToast:R,dismissToast:I}=(0,eo.Y)(),[O,J]=(0,s.J0)(!1),{isScrolling:_,handleScroll:W}=(0,en.K)(),K=e=>{let t=(0,el.l)(a,u,e);t&&(0,el.r)(t,i.omp_access_mode)};return(0,r.FD)(r.FK,{children:[(0,r.FD)("aside",{className:`flex flex-col bg-paper h-full ${t}`,children:[(0,r.Y)(x,{onNewSession:()=>{K(),D(e=>{let t=e.get("sessionId"),n=new URLSearchParams(e);if(n.set("sessionId",`new-${Date.now()}`),t){let e=a.find(e=>e.sessions?.some(e=>String(e.id)===String(t)));e&&n.set("folderId",e.id.toString())}else n.delete("folderId");return n},{replace:!0})}}),(0,r.Y)(F,{isSearchVisible:O,searchQuery:p,showArchived:f,optionsOpen:b,sortOption:k,onToggleSearch:()=>J(!O),onSearchChange:m,onToggleArchived:()=>g(!f),onHideArchived:()=>g(!1),onToggleOptions:()=>v(!b),onCloseOptions:()=>v(!1),onSortChange:y,onNewWorkspace:()=>j(!0),onScheduler:()=>M(!0),onRefresh:c,onClose:n}),o?(0,r.Y)(es,{}):(0,r.Y)(er,{folders:w,activeSessionId:d,searchQuery:p,showArchived:f,sessionStatus:N,isScrolling:_,onScroll:W,onSelectSession:Y,onNewSessionForFolder:e=>{K(e),D(t=>{let n=new URLSearchParams(t);return n.set("sessionId",`new-${Date.now()}`),n.set("folderId",e.toString()),n},{replace:!0})}}),(0,r.Y)(S,{onSettings:()=>C(!0),onInfo:()=>z(!0),updateAvailable:P.hasUpdate,onUpdateClick:()=>{z(!0),P.check()}})]}),(0,r.Y)(h.bB,{isOpen:A,onClose:()=>C(!1),appSettings:i}),(0,r.Y)(h.VT,{isOpen:T,onClose:()=>z(!1),updates:P,onToast:R}),(0,r.Y)(h.xV,{isOpen:$,onClose:()=>j(!1),onCreate:async e=>{let{name:t,path:n}=e,r=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,path:n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i.success)throw Error(i.error||`HTTP ${r.status}`);window.location.reload()}}),(0,r.Y)(h.Lo,{isOpen:L,onClose:()=>M(!1)}),(0,r.Y)(ea.y,{toasts:E,onDismiss:I})]})}var ep=n("ET"),em=n("u"),eh=n("zI"),ef=n("Gb"),ex=n("FL"),eg=n("As"),eb=n("NO"),ev=n("f"),ek=n("b5"),ey=n("Pf"),ew=n("se"),eN=n("tC");let eY=()=>{let{isInstallable:e,isInstalled:t,isIOS:n,install:i}=function(){let[e,t]=(0,s.J0)(null),[n,r]=(0,s.J0)(!1),[i,a]=(0,s.J0)(!1);(0,s.vJ)(()=>{r(window.matchMedia("(display-mode: standalone)").matches||!0===window.navigator.standalone);let e=window.navigator.userAgent.toLowerCase();a(/iphone|ipad|ipod/.test(e));let n=e=>{e.preventDefault(),t(e)},i=()=>{r(!0),t(null)};return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",i),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",i)}},[]);let l=async()=>{if(!e)return!1;await e.prompt();let{outcome:n}=await e.userChoice;return"accepted"===n&&(r(!0),t(null),!0)};return{isInstallable:!!e,isInstalled:n,isIOS:i,install:l}}(),[a,l]=(0,s.J0)(!1);return t?null:e?(0,r.Y)("button",{onClick:i,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install OMPChamber",children:(0,r.Y)(eN.A,{size:16})}):n?(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{onClick:()=>l(!0),className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install on iOS",children:(0,r.Y)(eN.A,{size:16})}),a&&(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20 p-4",children:(0,r.FD)("div",{className:"w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink",children:[(0,r.Y)("h3",{className:"text-sm font-semibold",children:"Install on iPhone / iPad"}),(0,r.FD)("p",{className:"mt-2 text-xs opacity-80",children:["1. Tap the ",(0,r.Y)("strong",{children:"Share"})," button in Safari toolbar.",(0,r.Y)("br",{}),"2. Scroll down and tap ",(0,r.Y)("strong",{children:"Add to Home Screen"}),"."]}),(0,r.Y)("button",{onClick:()=>l(!1),className:"mt-4 w-full rounded bg-ink text-canvas py-2 text-xs font-semibold hover:bg-ink/90",children:"Close"})]})})]}):null};var eD=n("R2");function eF(e){let{sessionTitle:t,showLeftPanel:n,showEditor:i,showRightPanel:s,streamStatus:a,onSwitchToMobile:l,onToggleEditor:o,onToggleRightPanel:c}=e;return(0,r.FD)("header",{className:"h-12 flex-shrink-0 border-b border-ink/10 bg-paper flex items-center justify-between pr-4 z-20 titlebar-drag-region select-none",style:{paddingLeft:n?void 0:"max(1rem, env(titlebar-area-x, 0px))",paddingRight:"max(1rem, calc(100vw - env(titlebar-area-width, 100vw)))"},children:[(0,r.FD)("div",{className:"flex items-center space-x-2 px-4 min-w-0",children:[!n&&(0,r.FD)(r.FK,{children:[(0,r.FD)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center flex-shrink-0",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]}),t&&(0,r.Y)("span",{className:"text-ink/30 text-xs select-none flex-shrink-0",children:"/"})]}),t&&(0,r.FD)("div",{className:"flex items-center space-x-2 titlebar-no-drag",children:[(0,r.Y)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center",children:(0,r.Y)("span",{className:"font-semibold text-xs text-ink truncate",children:t.charAt(0).toUpperCase()+t.slice(1)})}),(0,r.Y)(w.A,{size:14,className:"text-ink/40 hover:text-ink cursor-pointer flex-shrink-0"})]})]}),(0,r.Y)("div",{className:"flex items-center space-x-3 titlebar-no-drag",children:(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)(eD.c,{status:a}),l&&(0,r.Y)("button",{type:"button",onClick:l,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer",title:"Switch to Mobile View",children:(0,r.Y)(ev.A,{size:16})}),(0,r.Y)(eY,{}),(0,r.Y)("button",{type:"button",onClick:o,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${i?"text-ink":"text-ink/40"}`,title:"Toggle Editor Layout",children:(0,r.Y)(ek.A,{size:16})}),(0,r.Y)("button",{type:"button",onClick:c,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${s?"text-ink":"text-ink/40"}`,title:"Toggle Right Panel",children:s?(0,r.Y)(ey.A,{size:16}):(0,r.Y)(ew.A,{size:16})})]})})]})}var eA=n("d"),eC=n("nG"),eS=n("oE"),eT=n("Asb"),ez=n("vZ"),e$=n("N"),ej=n("Oj"),eL=n("lW"),eM=n("SJ"),eP=n("so");let eE={context:{title:"Context & Telemetry",icon:(0,r.Y)(eS.A,{size:16})},files:{title:"Files",icon:(0,r.Y)(eT.A,{size:16})},search:{title:"Search",icon:(0,r.Y)(k.A,{size:16})},git:{title:"Source Control",icon:(0,r.Y)(ez.A,{size:16})},terminal:{title:"Terminal (Bun)",icon:(0,r.Y)(e$.A,{size:16})},"user-browser":{title:"Browser (Anda)",icon:(0,r.Y)(ej.A,{size:16})},browser:{title:"Browser Agent",icon:(0,r.Y)(eL.A,{size:16})},usage:{title:"Usage",icon:(0,r.Y)(eM.A,{size:16})}};function eR(e){let{activePanel:t,onChangePanel:n,isPanelOpen:i,hasActiveContext:s,activeProjectPath:a,refreshKey:l}=e,{changes:o}=(0,eP.e)(a??void 0,".",l,s,15e3),c=o.length>0;return(0,r.FD)("nav",{className:"w-12 flex-shrink-0 border-l border-ink/10 bg-paper flex flex-col items-center py-3 space-y-2 z-10",children:[(0,r.Y)("div",{className:"flex flex-col items-center space-y-1 w-full",children:ep.G7.map(e=>{let s=i&&t===e;return(0,r.FD)("button",{className:`relative w-full h-10 flex items-center justify-center transition-colors border-l-2 ${s?"text-ink border-ink bg-ink/5":"text-ink/40 border-transparent hover:text-ink hover:bg-ink/5"}`,onClick:()=>n(e),title:eE[e].title,children:[eE[e].icon,"git"===e&&c&&(0,r.Y)("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-info",title:"Ada perubahan git"})]},e)})}),(0,r.Y)("div",{className:"flex-1"})]})}function eI(){return(0,r.Y)(m,{className:"relative w-1 outline-none group flex justify-center cursor-col-resize z-10",children:(0,r.Y)("div",{className:"h-full w-[1px] bg-ink/10 group-hover:bg-ink/40 group-active:bg-ink/60 group-hover:w-0.5 transition-all"})})}let eO={left:268,editor:600,diff:720};function eJ(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):void 0}let e_=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("nam"),n.e("q")]).then(n.bind(n,"o3")).then(e=>({default:e.Editor})));function eW(e){let{children:t}=e;return(0,r.Y)(a.tY,{fallback:(0,r.Y)("div",{className:"w-full h-full flex items-center justify-center text-ink/40 text-xs",children:"Loading…"}),children:t})}function eK(e){let{appSettings:t,showEditor:n,editorPanelRef:i,showRightPanel:a,activeRightPanel:l,rightPanelRef:o,panelWidths:c,editorWidthMode:d,hasActiveContext:m,activeProjectPath:h,openedFiles:f,activeFileId:x,refreshKey:g,onSetActiveFileId:b,onCloseFile:v,onOpenFile:k,onRefreshWorkspace:y,onChangeRightPanel:w,onToggleRightPanel:N,onSessionTitle:Y,onPanelWidths:D}=e;(0,s.li)(c).current=c;let F=(0,s.Kr)(()=>({}),[]),A=(0,s.Kr)(()=>ep.G7.map(e=>({view:e,Comp:(0,eC.SU)(F,e)})),[F]);return(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-layout",onLayoutChanged:()=>{let e,t,n;D((e={},t=i.current?.getSize()?.inPixels,n=o.current?.getSize()?.inPixels,null!=t&&t>0&&(e[d]=Math.round(t)),null!=n&&n>0&&(e.right={[l]:Math.round(n)}),e))},children:[(0,r.Y)(p,{id:"center-panel",filler:!0,minSize:420,children:(0,r.Y)(eA.E,{className:"w-full h-full",appSettings:t,onSessionTitle:Y})}),n&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eI,{}),(0,r.Y)(p,{panelRef:i,id:"editor-panel",defaultSize:c[d]??eO[d],minSize:300,maxSize:1200,children:(0,r.Y)(eW,{children:(0,r.Y)(e_,{className:"w-full h-full",openedFiles:f,activeFileId:x,onSelectFile:b,onCloseFile:v,refreshKey:g,onFileSaved:y})})})]}),a&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eI,{}),(0,r.Y)(p,{panelRef:o,id:"right-panel",defaultSize:c.right?.[l]??ep.qv[l],minSize:ep.lw[l],maxSize:1200,collapsible:!0,children:(0,r.Y)(eW,{children:A.map(e=>{let{view:t,Comp:n}=e,i=l===t;return(0,r.Y)("div",{className:i?"w-full h-full":"hidden",children:(0,r.Y)(n,{className:"w-full h-full",enabled:"terminal"===t?m:m&&i,active:i,refreshKey:g,rootPath:h??void 0,onRefresh:y,onOpenFile:k,onClose:N})},t)})})})]})]}),(0,r.Y)(eR,{activePanel:l,onChangePanel:w,isPanelOpen:a,hasActiveContext:m,activeProjectPath:h,refreshKey:g})]})}var eU=n("FE");function eq(e,t){null!=t&&e.current?.resize(t)}function eB(e){let{sessionId:t,onSwitchToMobile:n,appSettings:i={}}=e,{folders:a}=(0,ee.k)(),[o,c]=(0,ex.bL)("layout.showRightPanel",i.showRightPanel??!0),[d,m]=(0,ex.bL)("layout.activeRightPanel",i.activeRightPanel??"files"),[h,f]=(0,s.J0)(i.showLeftPanel??!0),{widths:x,widthsRef:g,commitWidths:b}=function(e,t){let[n,r]=(0,s.J0)(()=>(function(e,t){if(!e||"object"!=typeof e)return{};let n={};for(let t of["left","editor","diff"]){let r=eJ(e[t]);void 0!==r&&(n[t]=r)}let r={};if(e.right&&"object"==typeof e.right)for(let[t,n]of Object.entries(e.right)){if(!(0,ep.ls)(t))continue;let e=eJ(n);void 0!==e&&(r[t]=e)}else{let n=eJ(e.right);void 0!==n&&(r[t]=n)}return Object.keys(r).length>0&&(n.right=r),n})(e.desktopLayoutSizes,t)),i=(0,s.li)(n),a=(0,s.li)(void 0),l=(0,s.hb)(()=>{clearTimeout(a.current),a.current=void 0,(0,Z.cz)("desktopLayoutSizes",i.current)},[]),o=(0,s.hb)(e=>{var t;let n,s=(t=i.current,n={...t,...e},e.right&&(n.right={...t.right,...e.right}),n);i.current=s,r(s),clearTimeout(a.current),a.current=window.setTimeout(l,500)},[l]);return(0,s.vJ)(()=>()=>{void 0!==a.current&&l()},[l]),{widths:n,widthsRef:i,commitWidths:o}}(i,d),v=(0,s.li)(null),k=(0,s.li)(null),y=(0,s.li)(null),[w,N]=(0,s.J0)(i.userToggledEditor??null),[Y]=(0,l.o)(),D=Y.get("folderId"),F=(0,s.Kr)(()=>{let e=(0,ef.t)(a,t||"").folder;return e||(D?a.find(e=>String(e.id)===String(D))??null:null)},[a,t,D]),A=F?.project_path??null,C=!!F,{openedFiles:S,activeFileId:T,setActiveFileId:z,handleOpenFile:$,handleCloseFile:j}=function(e,t,n){let[r,i]=(0,ex.bL)("layout.openedFiles",[]),[a,l]=(0,ex.bL)("layout.activeFileId",null),o=(0,s.li)(void 0),{ready:c}=(0,eg.O)(),d=(0,s.li)(void 0);(0,s.vJ)(()=>{o.current===e||(o.current=e,c&&d.current!==e&&(d.current=e,i([]),l(null)))},[e,t,c,i,l]);let u=(0,s.hb)(t=>{let r={...t,root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===r.id||!e.isDiff&&e.path&&r.path&&e.path===r.path);return t?(l(t.id),e):[...e,r]}),l(r.id),n?.()},[e,n,i,l]),p=(0,s.hb)(t=>{let r=t.file.replace(/^\/+/,""),s=r.split("/").pop()||r,a=!!t.staged,o=`diff-${a?"staged":"working"}-${r}`,c={id:o,name:`${s} (Diff)`,path:r,isDiff:!0,diffStatus:t.status||"M",diffStaged:a,repo:t.repo||".",root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===o||e.isDiff&&e.path===r&&e.diffStaged===a);return t?(l(t.id),e):[...e,c]}),l(o),n?.()},[e,n,i,l]),m=(0,s.hb)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return a===e&&l(n.length>0?n[n.length-1].id:null),n})},[a,i,l]);return(0,eb.sY)("omp:open-file",e=>{if(!e.detail||!e.detail.path)return;let t=e.detail.path.replace(/^\/+/,""),n=e.detail.name||t.split("/").pop()||"file",r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e)|0;u({id:e.detail.id||Math.abs(r)||Date.now(),name:n,path:t,content:e.detail.content})}),(0,eb.sY)("omp:open-diff",e=>{e.detail&&e.detail.file&&p(e.detail)}),{openedFiles:r,activeFileId:a,setActiveFileId:l,handleOpenFile:u,handleOpenDiff:p,handleCloseFile:m}}(A,t||"",(0,s.hb)(()=>{N(!0),P("userToggledEditor",!0)},[])),L=S.length>0&&(w??!0),M=(0,s.Kr)(()=>S.find(e=>String(e.id)===String(T))?.isDiff?"diff":"editor",[S,T]),P=(e,t)=>{(0,Z.cz)(e,t)};(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{let e=g.current;e&&eq(y,e.left)});return()=>cancelAnimationFrame(e)},[h,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eq(k,g.current?.right?.[d]??ep.qv[d])});return()=>cancelAnimationFrame(e)},[o,d,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eq(v,g.current?.[M]??eO[M])});return()=>cancelAnimationFrame(e)},[L,M,g]);let[E,R]=(0,s.J0)(!1),[I,O]=(0,s.J0)("appearance"),[J,_]=(0,s.J0)(!1),[W,K]=(0,s.J0)(0),[U,q]=(0,s.J0)(null),B=(0,eU.H)();(0,eb.MN)("keydown",e=>{(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),O("appearance"),_(!1),R(e=>!e))}),(0,eb.sY)("omp:open-settings",e=>{e.detail?.category?O(e.detail.category):O("appearance"),_(!!e.detail?.autoOpenAdd),R(!0)});let H=e=>{f(e),P("showLeftPanel",e)},G=()=>{let e=!o;c(e),P("showRightPanel",e)};return(0,r.FD)("div",{className:"flex flex-col h-screen w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas",children:[(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[!h&&(0,r.FD)("div",{className:"w-12 h-full bg-paper border-r border-ink/10 flex flex-col items-center py-3 flex-shrink-0 cursor-pointer hover:bg-ink/5 transition-colors titlebar-no-drag",style:{paddingTop:"max(0.75rem, env(titlebar-area-height, 0px))"},onClick:()=>H(!0),title:"Expand Sidebar",children:[(0,r.Y)(eh.A,{size:16,className:"text-ink/60"}),(0,r.Y)("div",{className:"w-[1px] flex-1 bg-ink/10 my-4"})]}),(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-main",onLayoutChanged:()=>{let e=y.current?.getSize()?.inPixels;null!=e&&e>0&&b({left:Math.round(e)})},children:[h&&(0,r.FD)(r.FK,{children:[(0,r.Y)(p,{panelRef:y,id:"left-panel",defaultSize:x.left??eO.left,minSize:200,maxSize:520,collapsible:!0,children:(0,r.Y)(eu,{className:"w-full h-full",onClose:()=>H(!1),appSettings:i})}),(0,r.Y)(eI,{})]}),(0,r.Y)(p,{id:"main-right-stack",filler:!0,minSize:0,children:(0,r.FD)("div",{className:"flex flex-col h-full",children:[(0,r.Y)(eF,{sessionTitle:U,showLeftPanel:h,showEditor:L,showRightPanel:o,streamStatus:B,onSwitchToMobile:n,onToggleEditor:()=>{let e=!L;N(e),P("userToggledEditor",e)},onToggleRightPanel:G}),(0,r.Y)(eK,{appSettings:i,showEditor:L,editorPanelRef:v,showRightPanel:o,activeRightPanel:d,rightPanelRef:k,panelWidths:x,editorWidthMode:M,hasActiveContext:C,activeProjectPath:A,openedFiles:S,activeFileId:T,refreshKey:W,onSetActiveFileId:z,onCloseFile:j,onOpenFile:$,onRefreshWorkspace:()=>K(e=>e+1),onChangeRightPanel:e=>{let t=o,n=d;d===e&&o?t=!1:(n=e,t=!0),c(t),m(n),(0,Z.cz)("showRightPanel",t),(0,Z.cz)("activeRightPanel",n)},onToggleRightPanel:G,onSessionTitle:q,onPanelWidths:b})]})})]})]}),(0,r.Y)(em.b,{isOpen:E,onClose:()=>{R(!1),_(!1)},initialCategory:I,autoOpenAddProvider:J,appSettings:i})]})}var eH=n("SS");function eG(e){let{sessionId:t,children:n}=e,i=t||"1",[a,l]=(0,s.J0)(!1),o=(0,s.li)(null);(0,s.vJ)(()=>{let e=o.current;if(o.current=i,e!==i){if((0,eH.Y1)(i),e&&e.startsWith("new-")&&!i.startsWith("new-")){(0,eH.vy)(e,i),l(!0);return}if(i.startsWith("new-")){(0,eH.l5)(i),l(!0);return}l(!1),(0,eH.D4)(e).then(()=>(0,eH.L6)(i)).then(()=>{o.current===i&&l(!0)})}},[i]);let c=(0,s.Kr)(()=>({sessionId:i,ready:a}),[i,a]);return(0,r.Y)(eg.b.Provider,{value:c,children:n})}let eV=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("nam"),n.e("g")]).then(n.bind(n,"Wh")).then(e=>({default:e.MobileLayoutWrapper})));var eZ=n("eh");let eQ=document.getElementById("app"),eX=window.__OMP_BOOTSTRAP__;(0,Z.x9)(eX?.appSettings),(0,eZ.iv)(),eQ&&(0,i.Qv)((0,r.Y)(function(e){let{initialIsMobile:t=!1,appSettings:n={}}=e,[i]=(0,l.o)(),o=i.get("sessionId")||"1",[c,d]=(0,s.J0)(t),u=(0,s.li)(!1);return((0,s.vJ)(()=>{let e=()=>{let e=window.innerWidth<768,t=window.matchMedia("(pointer: coarse)").matches,n=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),r=t&&window.innerHeight<550&&window.innerWidth<1024;return e||n||r};u.current||d(e());let t=()=>{u.current||d(e())};return window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[]),c)?(0,r.Y)(eG,{sessionId:o,children:(0,r.Y)(ee.O,{children:(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(eV,{onDesktopToggle:()=>{u.current=!0,d(!1)},appSettings:n})})})}):(0,r.Y)(eG,{sessionId:o,children:(0,r.Y)(ee.O,{children:(0,r.Y)(eB,{sessionId:o,onSwitchToMobile:()=>{u.current=!0,d(!0)},appSettings:n})})})},{initialIsMobile:eX?.initialIsMobile,appSettings:eX?.appSettings}),eQ)},Fb(e,t,n){let r="omp:browser-include-page";function i(e){"u">typeof window&&window.dispatchEvent(new CustomEvent(r,{detail:e}))}n.d(t,{q:()=>i},{j:r})},ns(e,t,n){let r="agent",i="command",s=new Map,a=new Map;async function l(e){let t=await fetch(e);if(!t.ok)throw Error(`GET ${e} failed: ${t.status}`);let n=await t.json();if(!n||"object"!=typeof n)throw Error(`GET ${e} returned malformed JSON`);return n}async function o(){let e=s.get(r);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(r);if(t)return t;let n=(async()=>{try{let e=(await l("/api/settings/agents")).agents.map(e=>({id:`agent-${e.name}`,name:e.name,description:e.description,kind:"agent",source:"agent",token:`@${e.name}`}));return s.set(r,{data:e,expiresAt:Date.now()+3e5}),e}finally{a.delete(r)}})();return a.set(r,n),n}async function c(e){let t,n=(t=e??"",`file::${t}`),r=s.get(n);if(r&&r.expiresAt>Date.now())return r.data;let i=a.get(n);if(i)return i;let o=(async()=>{try{let t=e?`?root=${encodeURIComponent(e)}`:"",r=await l(`/api/fs/list${t}`),i=(Array.isArray(r.files)?r.files:[]).map(e=>({id:`file-${e.path}`,name:e.path,description:"",kind:"file",source:"file",token:/\s/.test(e.path)?`@"file:${e.path}"`:`@file:${e.path}`,path:e.path}));return s.set(n,{data:i,expiresAt:Date.now()+3e5}),i}catch{return[]}finally{a.delete(n)}})();return a.set(n,o),o}async function d(){let e=s.get(i);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(i);if(t)return t;let n=(async()=>{try{let[e,t]=await Promise.all([l("/api/settings/commands"),l("/api/settings/skills")]),n=function(e,t){let n=[],r=new Set;for(let t of e){let e=t.name.toLowerCase();r.has(e)||(r.add(e),n.push({id:`command-${t.name}`,name:t.name,description:t.description,kind:"command",source:"command",token:`/${t.name}`}))}for(let e of t){let t=e.name.toLowerCase(),i=`skill:${t}`;r.has(t)||r.has(i)||(r.add(i),n.push({id:`skill-${e.name}`,name:e.name,description:e.description,kind:"command",source:"skill",token:`/skill:${e.name}`}))}return n}(e.commands,t.skills);return s.set(i,{data:n,expiresAt:Date.now()+3e5}),n}finally{a.delete(i)}})();return a.set(i,n),n}function u(e,t){return"mention"===e?Promise.all([o(),c(t??null)]).then(e=>{let[t,n]=e;return[...t,...n]}):d()}async function p(){try{return(await o()).map(e=>e.name)}catch{return[]}}function m(e){if(e){s.delete(e),a.delete(e);return}s.clear(),a.clear()}n.d(t,{O7:()=>p,SA:()=>m,bF:()=>u})},K(e,t,n){var r=n("oS"),i=n("zG");let s={edit:!0,write:!0,ast_edit:!0,bash:!0};function a(e){let t="string"==typeof e.toolName?e.toolName.toLowerCase():"",n=i.YT[t]??t;if(!s[n])return!1;let a=(0,r.u)(e.args)?e.args:{},l=(0,i.oJ)(a.path)??(0,i.oJ)(a.target);return!("write"===n&&"string"==typeof l&&l.startsWith("xd://"))}n.d(t,{Y:()=>a},{s:"omp:files-mutated"})},g0(e,t,n){var r=n("Kn");let i="omp:stream-status",s={transport:(0,r.ul)(),connected:!1};function a(){return s}function l(e){e.transport===s.transport&&e.connected===s.connected||(s=e,"u">typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:e})))}n.d(t,{aK:()=>a,dX:()=>l},{rt:i})},Kn(e,t,n){var r=n("So");function i(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/agent/${encodeURIComponent(e)}/ws`}function s(e){return`/api/agent/${encodeURIComponent(e)}/events`}function a(e){let t=(0,r.BF)("streamTransport",e);return"sse"===t||"websocket"===t?t:"websocket"}n.d(t,{_m:()=>s,qq:()=>i,ul:()=>a})},G1(e,t,n){function r(e,t){let n=function(e){let t=e.trim();if(!t)return null;let n="message",r=[];for(let e of t.split("\n"))!e.startsWith(":")&&(e.startsWith("event:")?n=e.replace(/^event:\s*/,"").trim():e.startsWith("data:")&&r.push(e.replace(/^data:\s*/,"")));return 0===r.length?null:{event:n,data:r.join("\n")}}(e);return!!n&&!0===t(n.event,n.data)}async function i(e,t,n){let i=e.body?.getReader();if(!i)return;let s=new TextDecoder("utf-8"),a="";try{for(;;){if(n?.aborted){try{await i.cancel()}catch{}return}let{done:e,value:l}=await i.read();if(e)break;let o=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=o.pop()??"",o))if(r(e,t))return}a&&r(a,t)}finally{try{i.releaseLock()}catch{}}}n.d(t,{o:()=>i})},zG(e,t,n){var r=n("oS"),i=n("e");function s(e){if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0}function a(e,t){for(let n of t){let t=e[n],r=s(t);if(r)return r;if(Array.isArray(t)){let e=t.find(e=>void 0!==s(e));if(void 0!==e)return s(e)}}}function l(e){return e.length<=72?e:`${e.slice(0,71)}…`}function o(e){if(e)return/^["'`]/.test(e)?e:`"${e}"`}function c(e,t){switch(e){case"read":case"write":case"edit":return a(t,["path","file","AbsolutePath","TargetFile"])??(0,i.f$)(t);case"ast_edit":return a(t,["paths","path"]);case"ast_grep":{let e=o(a(t,["pat"]));return e?`for ${e}`:void 0}case"bash":return a(t,["command","cmd","CommandLine"]);case"grep":{let e=a(t,["pattern"]),n=a(t,["path","paths"]);if(!e)return n;return n?`for ${o(e)} in ${n}`:`for ${o(e)}`}case"glob":return a(t,["path","pattern"]);case"web_search":{let e=o(a(t,["query"]));return e?`for ${e}`:void 0}case"task":let n,l,c,d;return n=s(t.name),l=(Array.isArray(t.tasks)?t.tasks:[]).find(r.u),c=n??(l?s(l.name):void 0),d=s(t.agent)??(l?s(l.agent):void 0),c&&d?`to ${c} (${d})`:c?`to ${c}`:d?`to ${d}`:void 0;case"hub":return[a(t,["op"]),a(t,["name"])].filter(Boolean).join(" ")||void 0;case"todo":{let e=a(t,["op"]);return e?`\xb7 ${e}`:void 0}case"eval":{let e=a(t,["language"]);return e?`in ${e}`:void 0}case"lsp":return[a(t,["action"]),a(t,["symbol","file"])].filter(Boolean).join(" ")||void 0;case"debug":return a(t,["action","program"]);case"github":return[a(t,["op"]),a(t,["repo","pr","query"])].filter(Boolean).join(" ")||void 0;case"ask":let u=(Array.isArray(t.questions)?t.questions:[]).find(r.u);if(u)return s(u.header)??s(u.question);return;case"checkpoint":return a(t,["goal"]);case"manage_skill":return a(t,["name"]);case"recall":return o(a(t,["query"]));case"reflect":{let e=o(a(t,["query"]));return e?`on ${e}`:void 0}case"security_scan":return a(t,["target_kind","include_paths"]);case"retain":let p;return(p=(Array.isArray(t.items)?t.items:[]).find(r.u))?o(s(p.content)):void 0;default:return a(t,["path","command","query","pattern","name","target","prose"])}}n.d(t,{Up:()=>a,oJ:()=>s,qL:()=>c,xv:()=>l},{K$:{read:"Reading",write:"Writing",edit:"Editing",ast_edit:"Rewriting AST",ast_grep:"Searching AST",bash:"Running",grep:"Searching",glob:"Finding",task:"Delegating",todo:"Updating plan",hub:"Hub",eval:"Running code",lsp:"Running LSP",debug:"Debugging",github:"GitHub",web_search:"Searching the web",ask:"Asking you",checkpoint:"Checkpointing",rewind:"Rewinding",context_notes:"Updating context notes",new_context:"Starting a fresh context",security_scan:"Scanning for vulnerabilities",manage_skill:"Updating skill",learn:"Recording a lesson",retain:"Retaining memory",recall:"Recalling memory",reflect:"Reflecting",think:"Thinking",yield:"Wrapping up",goal:"Tracking goal"},Qq:{lsp:"Running LSP",ast_edit:"Rewriting AST",ast_grep:"Searching AST",resolve:"Applying edit proposal",reject:"Discarding edit proposal",report_issue:"Reporting tool issue",debug:"Debugging",browser:"Driving the browser"},YT:{read_file:"read",view_file:"read",read_file_content:"read",edit_file:"edit",replace_file_content:"edit",multi_edit_file:"edit",write_to_file:"write",create_file:"write",search_fs:"grep",terminal:"bash",run_command:"bash"},n1:{thinking:"Thinking",writing:"Writing response"}})},pm(e,t,n){var r=n("U8");function i(e){return(0,r.Rk)(e)}n.d(t,{F:()=>i})},eh(e,t,n){n.d(t,{iv:()=>w,tn:()=>v,F:()=>D,nv:()=>N,LT:()=>A,Eu:()=>Y,sT:()=>F});var r=n("CU"),i=n("he"),s=n("h3"),a=n("g1");let l={typescript:()=>n.e("zn").then(n.bind(n,"tt")),tsx:()=>n.e("ta").then(n.bind(n,"Xl")),javascript:()=>n.e("jsc").then(n.bind(n,"lK")),jsx:()=>n.e("px").then(n.bind(n,"rz")),json:()=>n.e("zj").then(n.bind(n,"BB")),markdown:()=>n.e("2v").then(n.bind(n,"sN")),css:()=>n.e("n").then(n.bind(n,"d2")),bash:()=>Promise.all([n.e(2),n.e(6)]).then(n.bind(n,"ks")),diff:()=>n.e("0w").then(n.bind(n,"SP")),yaml:()=>n.e("ho").then(n.bind(n,"n1")),html:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa")]).then(n.bind(n,"w1")),python:()=>n.e("jd").then(n.bind(n,"hE")),go:()=>n.e("cf").then(n.bind(n,"K1")),rust:()=>n.e("hk").then(n.bind(n,"nb")),sql:()=>n.e("r").then(n.bind(n,"le")),toml:()=>n.e("x0").then(n.bind(n,"DJ")),java:()=>n.e("f8").then(n.bind(n,"lj")),c:()=>n.e("4e").then(n.bind(n,"Gd")),cpp:()=>Promise.all([n.e("4e"),n.e("y6")]).then(n.bind(n,"gB")),csharp:()=>n.e("4k").then(n.bind(n,"Ku")),ruby:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("4e"),n.e("f8"),n.e("r"),n.e("ta"),n.e("y6"),n.e("px"),n.e(2),n.e("yv"),n.e("ct")]).then(n.bind(n,"eV")),php:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e(4)]).then(n.bind(n,"eZ")),kotlin:()=>n.e("7l").then(n.bind(n,"hR")),swift:()=>n.e(0).then(n.bind(n,"ep")),scala:()=>n.e("js").then(n.bind(n,"h3S")),lua:()=>Promise.all([n.e("4e"),n.e("hd")]).then(n.bind(n,"rF")),perl:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e("i")]).then(n.bind(n,"cr")),dockerfile:()=>n.e("b").then(n.bind(n,"BZ")),ini:()=>n.e("3p").then(n.bind(n,"BD")),properties:()=>n.e("1b").then(n.bind(n,"LU")),zig:()=>n.e("3u").then(n.bind(n,"p9")),elixir:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("jll")]).then(n.bind(n,"xu")),dart:()=>n.e("4q").then(n.bind(n,"Cu")),ocaml:()=>n.e("8j").then(n.bind(n,"uA")),haskell:()=>n.e("a").then(n.bind(n,"IX")),nix:()=>n.e("p").then(n.bind(n,"jG")),hcl:()=>n.e("yq").then(n.bind(n,"ka")),graphql:()=>Promise.all([n.e("jsc"),n.e("zn"),n.e("ta"),n.e("px"),n.e("yv")]).then(n.bind(n,"ok")),solidity:()=>n.e("w").then(n.bind(n,"me")),r:()=>n.e(37).then(n.bind(n,"pO")),julia:()=>Promise.all([n.e("jsc"),n.e("4e"),n.e("r"),n.e("y6"),n.e("jd"),n.e("t9")]).then(n.bind(n,"zu")),erlang:()=>Promise.all([n.e("2v"),n.e("y")]).then(n.bind(n,"EY")),clojure:()=>n.e("3d").then(n.bind(n,"lF")),scheme:()=>n.e("az").then(n.bind(n,"wE")),racket:()=>n.e(8).then(n.bind(n,"aB")),protobuf:()=>n.e("1p").then(n.bind(n,"bT")),makefile:()=>n.e("d").then(n.bind(n,"nt")),powershell:()=>n.e("j").then(n.bind(n,"dQ")),json5:()=>n.e("bq").then(n.bind(n,"VH")),less:()=>n.e("c").then(n.bind(n,"i")),scss:()=>Promise.all([n.e("n"),n.e("x")]).then(n.bind(n,"DD")),sass:()=>n.e("zo").then(n.bind(n,"Bc")),stylus:()=>n.e("ky").then(n.bind(n,"uc")),"objective-c":()=>n.e(7).then(n.bind(n,"BG")),groovy:()=>n.e("7e").then(n.bind(n,"tf")),vue:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("zx")]).then(n.bind(n,"Z")),svelte:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("dp")]).then(n.bind(n,"jIY")),astro:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("ta"),n.e("o")]).then(n.bind(n,"CuL")),xml:()=>Promise.all([n.e("f8"),n.e("da")]).then(n.bind(n,"rDW"))},o=["typescript","tsx","javascript","jsx","json","bash","python","markdown","yaml","diff"],c=new Map,d=new Set,u=new Set,p={text:!0,plain:!0,plaintext:!0,txt:!0,ansi:!0,none:!0};function m(e){return!0===p[e]||d.has(e)}function h(e,t){if(m(t))return Promise.resolve();let n=c.get(t);if(n)return n;let r=l[t];if(!r)return Promise.resolve();let i=e.loadLanguage(r).then(()=>{for(let e of(d.add(t),u))e()}).catch(()=>{}).finally(()=>{c.delete(t)});return c.set(t,i),i}async function f(e,t){await Promise.all(t.map(t=>h(e,t)))}let x=null,g=!1,b=new Set;function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function k(){if("u"<typeof window)return null;try{let e=await (0,r.tz)({themes:[s.A,a.A],langs:[],engine:(0,i.l)({forgiving:!0})});x=e,g=!0;let t=[...b];for(let e of(b.clear(),t))try{e()}catch{}return f(e,o),e}catch(e){return console.error("[shiki] highlighter boot failed",e),null}}let y=null;function w(){return y||(y=k()),y}function N(){return g}function Y(e){return g?(e(),()=>{}):(b.add(e),()=>{b.delete(e)})}function D(){return g?x:null}function F(e){return!!x&&(h(x,e),m(e))}let A=function(e){return u.add(e),()=>{u.delete(e)}}},DU(e,t,n){n.d(t,{sQ:()=>s,wY:()=>o,PH:()=>c,O9:()=>d,rw:()=>a,Bl:()=>function e(t){if(null==t)return{isValid:!1};if("object"==typeof t)try{let e=JSON.stringify(t,null,2),n=e.split("\n").length;return{isValid:!0,data:t,pretty:e,linesCount:n}}catch{return{isValid:!1}}if("string"!=typeof t)return{isValid:!1};let n=t.trim();if(!n)return{isValid:!1};let r=n.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);r&&(n=r[1].trim());let i=n.match(/^(?:user\s+(?:selected|responded|answered|response)|response|result|output):\s*([\s\S]+)$/i);if(i){let e=i[1].trim();(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&(n=e)}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))try{let t=JSON.parse(n);if("object"==typeof t&&null!==t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}if("string"==typeof t){let n=e(t);if(n.isValid)return n}}catch{}if(n.startsWith("{")||n.startsWith("["))try{let e=JSON.parse(n);if(null!==e&&"object"==typeof e){let t=JSON.stringify(e,null,2),n=t.split("\n").length;return{isValid:!0,data:e,pretty:t,linesCount:n}}}catch{}let s=n.indexOf("{"),a=n.lastIndexOf("}");if(-1!==s&&a>s){let e=n.slice(s,a+1);try{let t=JSON.parse(e);if(null!==t&&"object"==typeof t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}let l=n.indexOf("["),o=n.lastIndexOf("]");if(-1!==l&&o>l){let e=n.slice(l,o+1);try{let t=JSON.parse(e);if(Array.isArray(t)){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}return{isValid:!1}}});var r=n("eh");let i={light:"one-light",dark:"one-dark-pro"};function s(e){if(!e)return"javascript";let t=e.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");switch(t.split(".").pop()?.toLowerCase()){case"ts":return"typescript";case"tsx":return"tsx";case"js":case"mjs":case"cjs":default:return"javascript";case"jsx":return"jsx";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"sh":case"bash":case"zsh":case"env":return"bash";case"diff":case"patch":return"diff";case"yaml":case"yml":return"yaml";case"html":return"html";case"svg":case"xml":return"xml";case"py":return"python";case"go":return"go";case"rs":return"rust";case"sql":return"sql";case"toml":return"toml";case"java":return"java";case"c":case"h":return"c";case"cpp":case"cc":case"hpp":return"cpp";case"cs":return"csharp";case"rb":return"ruby";case"php":return"php";case"kt":case"kts":return"kotlin";case"swift":return"swift";case"scala":return"scala";case"lua":return"lua";case"pl":return"perl";case"dockerfile":return"dockerfile";case"ini":case"cfg":case"conf":return"ini";case"properties":return"properties";case"zig":return"zig";case"ex":case"exs":return"elixir";case"dart":return"dart";case"ml":case"mli":return"ocaml";case"hs":return"haskell";case"nix":return"nix";case"tf":case"tfvars":case"hcl":return"hcl";case"graphql":case"gql":return"graphql";case"sol":return"solidity";case"r":return"r";case"jl":return"julia";case"erl":return"erlang";case"clj":case"cljs":case"cljc":case"edn":return"clojure";case"scm":case"ss":return"scheme";case"rkt":return"racket";case"proto":return"protobuf";case"makefile":case"mk":return"makefile";case"ps1":case"psm1":return"powershell";case"json5":return"json5";case"less":return"less";case"scss":return"scss";case"sass":return"sass";case"styl":return"stylus";case"vue":return"vue";case"svelte":return"svelte";case"astro":return"astro";case"mm":case"m":return"objective-c";case"groovy":case"gvy":case"gradle":return"groovy"}}function a(e){if(!e||e.length<5)return!1;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),!0}catch{}return[/^(?:import|export)\s+.+from\s+['"][^'"]+['"]/m,/^(?:const|let|var|function|class|interface|type|enum)\s+[A-Za-z0-9_$]+/m,/(?:=>|\bconsole\.(?:log|error|warn)|return\s+|async\s+function)/,/^\s*\d+:\s*(?:import|const|let|function|\/\/|\/\*|<|[A-Za-z])/m,/^\s*\[[A-Za-z0-9_./-]+\.[a-zA-Z0-9]+\]\s*\n\d+:/m].some(e=>e.test(t))}function l(e,t){return(0,r.sT)(t)||e.getLoadedLanguages().includes(t)?t:"javascript"}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript";if(!e)return"";let n=(0,r.F)();if(!n)return(0,r.tn)(e);let s=l(n,t);try{return`<span class="shiki">${n.codeToHtml(e,{lang:s,themes:i,defaultColor:!1,structure:"inline"})}</span>`}catch{return(0,r.tn)(e)}}function c(e){return o(e,"json")}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=e.split("\n");if(!e)return s;let a=(0,r.F)();if(!a)return s.map(r.tn);let o=l(a,t);try{let{tokens:t}=a.codeToTokens(e,{lang:o,themes:i,defaultColor:!1,tokenizeMaxLineLength:n.maxLineLength??0});if(t.length!==s.length)return s.map(r.tn);return t.map(e=>e.map(e=>{let t=(0,r.tn)(e.content);if(!e.htmlStyle)return t;let n=Object.entries(e.htmlStyle).map(e=>{let[t,n]=e;return`${t}:${n}`}).join(";");return n?`<span style="${n}">${t}</span>`:t}).join(""))}catch{return s.map(r.tn)}}},U8(e,t,n){function r(e){if(null!=e){if("string"==typeof e)return e;if(Number.isFinite(e)&&!(e<=0)){if(e>=1e6){let t=e/1e6;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return`${Number.isInteger(t)?t:t.toFixed(1)}K`}return String(e)}}}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return"number"!=typeof e||!Number.isFinite(e)||e<=0?"":`$${e.toFixed(t)}`}function s(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":`$${e.toFixed(2)}`}n.d(t,{$g:()=>a,BD:()=>i,Rk:()=>r,z3:()=>s})},LQ(e,t,n){function r(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25",a=(e||"").trim().toUpperCase();if(t){let e=a[0]||"M";"A"===e?(n="A",r="Added (Staged)",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted (Staged)",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed (Staged)",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified (Staged)",i="text-info",s="bg-info/10 text-info border-info/25")}else if("??"===a||"?"===a||"U"===a||"UNTRACKED"===a)n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25";else{let e=a[1]||a[0]||"M";"A"===e?(n="A",r="Added",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25")}return{charStatus:n,label:r,colorClass:i,badgeBgClass:s,isStaged:t}}function i(e){let t=new Map,n=new Map;if(!Array.isArray(e))return{fileMap:t,folderMap:n};for(let r of e){if(!r||!r.file)continue;let e=r.file.replace(/^\/+/,"");t.set(e,r);let i=e.split("/");i.pop();let s="";for(let e of i){s=s?`${s}/${e}`:e;let t=n.get(s)||{count:0,hasModified:!1,hasUntracked:!1,hasStaged:!1,hasDeleted:!1,colorClass:"text-info"};t.count+=1,(r.staged||r.status&&" "!==r.status[0]&&"?"!==r.status[0])&&(t.hasStaged=!0),"??"===r.status?t.hasUntracked=!0:r.status?.includes("D")?t.hasDeleted=!0:t.hasModified=!0,t.hasModified||t.hasStaged?t.colorClass="text-info":t.hasUntracked?t.colorClass="text-success":t.hasDeleted&&(t.colorClass="text-error"),n.set(s,t)}}return{fileMap:t,folderMap:n}}n.d(t,{R:()=>r,_:()=>i})},W9(e,t,n){let r=null,i=null;function s(){return i&&i.expiresAt>Date.now()?Promise.resolve(i.data):r||(r=fetch("/api/models").then(e=>e.ok?e.json():Promise.reject(Error(`GET /api/models failed: ${e.status}`))).then(e=>(i={data:e,expiresAt:Date.now()+6e4},e)).finally(()=>{r=null}))}function a(){i=null}function l(){i=null,window.dispatchEvent(new CustomEvent("omp:models-updated"))}function o(e){return window.addEventListener("omp:models-updated",e),()=>window.removeEventListener("omp:models-updated",e)}n.d(t,{$P:()=>l,Sy:()=>o,kn:()=>a,xo:()=>s})},Np(e,t,n){let r="new-";function i(e){return String(e).padStart(2,"0")}function s(e){return!!e?.startsWith(r)}function a(e){return e?.startsWith(r)?Number(e.slice(r.length)):0/0}function l(e){let t=a(e);return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return Number.isNaN(e.getTime())?"New Session":`New Session - ${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}T${i(e.getHours())}:${i(e.getMinutes())}:${i(e.getSeconds())}`}(Number.isFinite(t)?new Date(t):new Date)}n.d(t,{fN:()=>s,fd:()=>a,g2:()=>l})},e(e,t,n){let r=["input","_input","patch"],i=/#([0-9a-fA-F]{4})$/,s=/^(PUT|CUT)\b/;function a(e){let t=e[0];return e.length>=2&&('"'===t||"'"===t)&&t===e[e.length-1]?e.slice(1,-1):e}function l(e){if(e)for(let t of r){let n=e[t];if("string"!=typeof n)continue;let r=function(e){let t,n=[];for(let r of e.replace(/^\uFEFF/,"").split("\n")){let e=r.endsWith("\r")?r.slice(0,-1):r,l=function(e){let t=e.trimEnd();if(!t.startsWith("["))return;let n=(t.endsWith("]")?t.slice(1,-1):t.slice(1)).trim(),r=i.exec(n),s=a((r?n.slice(0,r.index):n).trim());return s?{path:s,tag:r?.[1]}:void 0}(e);if(l){t={path:l.path,tag:l.tag,removed:!1,ops:[]},n.push(t);continue}if(!t)continue;let o=e.trim();if("REM"===o){t.removed=!0;continue}if(o.startsWith("MV ")){t.moveTo=a(o.slice(3).trim())||void 0;continue}if(s.test(o)){t.ops.push({verb:o.slice(0,3),spec:o.slice(3).trim().replace(/:$/,""),body:[]});continue}let c=t.ops[t.ops.length-1];c&&e.startsWith("+")&&c.body.push(e)}return n}(n);if(r.length>0)return{text:n,sections:r}}}function o(e){return l(e)?.sections[0].path}n.d(t,{I:()=>l,f$:()=>o})},wm(e,t,n){function r(e,t){e&&fetch("/api/agent/prewarm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,...t?{accessMode:t}:{}})}).catch(()=>{})}function i(e,t,n){let r=void 0!==n?e.find(e=>String(e.id)===String(n)):e.find(e=>e.sessions?.some(e=>String(e.id)===String(t)))??e.find(e=>!!e.project_path);return r?.project_path||r?.name||null}n.d(t,{l:()=>i,r:()=>r})},B(e,t,n){var r=n("oS");function i(e){return(0,r.u)(e)&&"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.agent&&e.agent.length>0&&"string"==typeof e.status&&"number"==typeof e.index}async function s(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`);if(!t.ok)return null;let n=await t.json().catch(()=>null);if(!(0,r.u)(n))return null;let s=(0,r.u)(n.data)?n.data:n;if(!Array.isArray(s.subagents))return null;return s.subagents.filter(i)}catch{return null}}function a(e){let t={...e,source:"history",lastUpdate:0},n={};return void 0!==e.lastIntent&&(n.lastIntent=e.lastIntent),void 0!==e.toolCount&&(n.toolCount=e.toolCount),void 0!==e.requests&&(n.requests=e.requests),void 0!==e.tokens&&(n.tokens=e.tokens),void 0!==e.contextTokens&&(n.contextTokens=e.contextTokens),void 0!==e.contextWindow&&(n.contextWindow=e.contextWindow),void 0!==e.cost&&(n.cost=e.cost),void 0!==e.durationMs&&(n.durationMs=e.durationMs),void 0!==e.resolvedModel&&(n.resolvedModel=e.resolvedModel),Object.keys(n).length>0&&(t.progress=n),t}n.d(t,{Nh:()=>a,wv:()=>s})},T(e,t,n){var r=n("oS");function i(e){return"string"==typeof e&&e.length>0?e:void 0}function s(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function a(e){return"bundled"===e||"user"===e||"project"===e?e:void 0}function l(e){var t;if(!(0,r.u)(e))return;let n={},l=s(e.index);void 0!==l&&(n.index=l);let o=i(e.id);void 0!==o&&(n.id=o);let c=i(e.agent);void 0!==c&&(n.agent=c);let d=a(e.agentSource);void 0!==d&&(n.agentSource=d);let u="pending"===(t=e.status)||"running"===t||"completed"===t||"failed"===t||"aborted"===t?t:void 0;void 0!==u&&(n.status=u);let p=i(e.task);void 0!==p&&(n.task=p);let m=i(e.assignment);void 0!==m&&(n.assignment=m);let h=i(e.description);void 0!==h&&(n.description=h);let f=i(e.lastIntent);void 0!==f&&(n.lastIntent=f);let x=i(e.currentTool);void 0!==x&&(n.currentTool=x);let g=i(e.currentToolArgs);void 0!==g&&(n.currentToolArgs=g);let b=s(e.currentToolStartMs);void 0!==b&&(n.currentToolStartMs=b),Array.isArray(e.recentTools)&&(n.recentTools=e.recentTools),Array.isArray(e.recentOutput)&&(n.recentOutput=e.recentOutput.filter(e=>"string"==typeof e));let v=s(e.toolCount);void 0!==v&&(n.toolCount=v);let k=s(e.requests);void 0!==k&&(n.requests=k);let y=s(e.tokens);void 0!==y&&(n.tokens=y);let w=s(e.contextTokens);void 0!==w&&(n.contextTokens=w);let N=s(e.contextWindow);void 0!==N&&(n.contextWindow=N);let Y=s(e.cost);void 0!==Y&&(n.cost=Y);let D=s(e.durationMs);void 0!==D&&(n.durationMs=D),("string"==typeof e.modelOverride||Array.isArray(e.modelOverride)&&e.modelOverride.every(e=>"string"==typeof e))&&(n.modelOverride=e.modelOverride);let F=i(e.modelRole);void 0!==F&&(n.modelRole=F);let A=i(e.resolvedModel);if(void 0!==A&&(n.resolvedModel=A),"boolean"==typeof e.resolvedModelIsFallback&&(n.resolvedModelIsFallback=e.resolvedModelIsFallback),(0,r.u)(e.retryState)){let t=s(e.retryState.attempt),r=s(e.retryState.maxAttempts),a=s(e.retryState.delayMs),l=i(e.retryState.errorMessage),o=s(e.retryState.startedAtMs);void 0!==t&&void 0!==r&&void 0!==a&&void 0!==l&&void 0!==o&&(n.retryState={attempt:t,maxAttempts:r,delayMs:a,errorMessage:l,startedAtMs:o})}if((0,r.u)(e.retryFailure)){let t=s(e.retryFailure.attempt),r=i(e.retryFailure.errorMessage);void 0!==t&&void 0!==r&&(n.retryFailure={attempt:t,errorMessage:r})}return void 0!==e.inflightTaskDetails&&(n.inflightTaskDetails=e.inflightTaskDetails),(0,r.u)(e.extractedToolData)&&(n.extractedToolData=e.extractedToolData),Object.keys(n).length>0?n:void 0}function o(e){if(!(0,r.u)(e))return;let t=i(e.id),n=i(e.status);if(!t||!n||"started"!==n&&"completed"!==n&&"failed"!==n&&"aborted"!==n)return;let l={id:t,agent:i(e.agent)??"subagent",status:n,index:s(e.index)??-1,lastUpdate:Date.now(),source:"live"},o=a(e.agentSource);void 0!==o&&(l.agentSource=o);let c=i(e.description);void 0!==c&&(l.description=c);let d=i(e.sessionFile);void 0!==d&&(l.sessionFile=d);let u=i(e.parentToolCallId);return void 0!==u&&(l.parentToolCallId=u),"boolean"==typeof e.detached&&(l.detached=e.detached),l}function c(e){if(!(0,r.u)(e))return[];let t=e.subagents;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=function(e){let t;if(!(0,r.u)(e))return;let n=i(e.id),o=i(e.agent);if(!n||!o)return;if("started"===e.status||"completed"===e.status||"failed"===e.status||"aborted"===e.status)t=e.status;else{if("pending"!==e.status&&"running"!==e.status)return;t="started"}let c={id:n,agent:o,status:t,index:s(e.index)??-1,source:"live"},d=a(e.agentSource);void 0!==d&&(c.agentSource=d);let u=i(e.description);void 0!==u&&(c.description=u);let p=i(e.task);void 0!==p&&(c.task=p);let m=i(e.assignment);void 0!==m&&(c.assignment=m);let h=i(e.sessionFile);void 0!==h&&(c.sessionFile=h);let f=i(e.parentToolCallId);void 0!==f&&(c.parentToolCallId=f),c.lastUpdate=s(e.lastUpdate)??Date.now();let x=l(e.progress);return void 0!==x&&(c.progress=x),c}(e);t&&n.push(t)}return n}function d(e,t){return(e.batchSeq??Number.MAX_SAFE_INTEGER)-(t.batchSeq??Number.MAX_SAFE_INTEGER)||e.index-t.index||e.id.localeCompare(t.id)}function u(e,t,n){let r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.id);if(!t){r.set(e.id,e);continue}let i=t.batchSeq??e.batchSeq;if(void 0!==n&&(t.lastUpdate??0)>=n||"history"===e.source&&"history"!==t.source){i!==t.batchSeq&&r.set(e.id,{...t,batchSeq:i});continue}if("history"!==e.source&&"history"===t.source){r.set(e.id,{...e,batchSeq:i});continue}r.set(e.id,{...t,...e,batchSeq:i})}return[...r.values()].sort(d)}n.d(t,{bH:()=>o,j8:()=>u,mq:()=>l,vG:()=>c})},So(e,t,n){let r="omp_chamber_settings",i=null,s={};function a(e){s={...e?.[r]??{}};let t={...e??{}};delete t[r],i={...t,...s}}function l(e){return i||a(e),i??{}}function o(e,t){let n=Array.isArray(e)?e:[e],r=l(t);for(let e of n)if(void 0!==r[e])return r[e]}function c(e,t){return l(t),{...e,...s}}function d(e,t){i={...l(),[e]:t},p({[e]:t})}function u(e){s={...s,...e},i={...l(),...e},p({[r]:s})}function p(e){fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}n.d(t,{BF:()=>o,cm:()=>c,cz:()=>d,l1:()=>u,x9:()=>a})},oS(e,t,n){function r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}n.d(t,{u:()=>r})},Gb(e,t,n){function r(e,t){if(!t)return{folder:null,projectPath:null};for(let n of e)if((n.sessions||[]).some(e=>String(e.id)===String(t)))return{folder:n,projectPath:n.project_path??null};return{folder:null,projectPath:null}}function i(e,t,n){let i=r(e,t).folder,s=null!=n?e.find(e=>String(e.id)===String(n))??null:null;return(i??s)?.project_path??null}n.d(t,{M:()=>i,t:()=>r})},A(e,t,n){var r=n("g6"),i=n("AB"),s=n("N"),a=n("h"),l=n("al"),o=n("nv"),c=n("nT"),d=n("w"),u=n("Oj"),p=n("Gh"),m=n("R"),h=n("HJ"),f=n("DK"),x=n("f"),g=n("z9"),b=n("Fx"),v=n("F9"),k=n("bt"),y=n("YO"),w=n("by");let N={default:r.A,code:i.A,terminal:s.A,rocket:a.A,flask:l.A,gamepad:o.A,briefcase:c.A,home:d.A,globe:u.A,leaf:p.A,shield:m.A,palette:h.A,server:f.A,smartphone:x.A,database:g.A,lightbulb:b.A,music:v.A,camera:k.A,book:y.A,heart:w.A};function Y(e){return N[e||"default"]||r.A}n.d(t,{x:()=>Y})},ET(e,t,n){let r=["context","files","search","git","terminal","user-browser","browser","usage"];function i(e){return"string"==typeof e&&r.includes(e)}n.d(t,{ls:()=>i},{G7:r,lw:{files:200,search:200,git:260,terminal:320,context:420,"user-browser":320,browser:320,usage:420},qv:{files:268,search:268,git:268,terminal:640,context:536,"user-browser":804,browser:804,usage:536}})},SS(e,t,n){let r=new Map,i=new Map,s=new Set,a=new Map,l=new Map;function o(e){let t=r.get(e);void 0!==t&&(r.delete(e),r.set(e,t)),i.set(e,Date.now())}function c(e){let t=Date.now(),n=e=>{r.delete(e),s.delete(e),a.delete(e),i.delete(e);let t=l.get(e);t&&(clearTimeout(t),l.delete(e))};for(let[r,s]of i)!(t-s<=6e5)&&r!==e&&(a.get(r)||n(r));for(;r.size>10;){let t=!1;for(let i of r.keys())if(i!==e&&!a.get(i)){n(i),t=!0;break}if(!t)break}}function d(e,t){if(e)return o(e),r.get(e)?.[t]}function u(e,t,n){if(!e)return;let i=r.get(e)??{};i[t]=n,r.set(e,i),o(e),a.set(e,!0),p(e),c(e)}function p(e){let t=l.get(e);t&&clearTimeout(t),l.set(e,setTimeout(()=>{l.delete(e),m(e)},600))}async function m(e){if("u"<typeof window||!e||!a.get(e))return;a.set(e,!1);let t=r.get(e)??{};try{await fetch(`/api/sessions/${encodeURIComponent(e)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:t})})}catch(t){console.warn("session-state persist failed:",t),a.set(e,!0)}}function h(e){if(!e||"u"<typeof window)return Promise.resolve();let t=l.get(e);return t&&(clearTimeout(t),l.delete(e)),m(e)}async function f(e){if(e){if("u"<typeof window)return void s.add(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(t.ok){let n=await t.json(),i=n.state&&"object"==typeof n.state?n.state:{},s=r.get(e)??{},l=!0===a.get(e)?{...i,...s}:i;r.set(e,l),o(e)}}catch(e){console.warn("session-state load failed:",e)}s.add(e),c(e)}}function x(e,t){e&&(r.set(e,{...r.get(e)??{},...t}),o(e),s.add(e),c(e))}function g(e){e&&s.add(e)}function b(e){e&&i.set(e,Date.now())}function v(e){return i.get(e)}function k(e,t){let n=r.get(e);n&&r.set(t,{...n,...r.get(t)??{}}),o(t),s.add(t),a.set(t,!0),p(t),r.delete(e),s.delete(e),a.delete(e),i.delete(e),c(t)}n.d(t,{D4:()=>h,E9:()=>x,L6:()=>f,R7:()=>v,WV:()=>d,Y1:()=>b,l5:()=>g,qI:()=>u,vy:()=>k})},P(e){e.exports={rE:"0.8.0"}}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.d=(e,t,n)=>{var r=(t,n)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[n]:t[r]})};r(t,"get"),r(n,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,n)=>(l.f[n](e,t),t),[])),l.u=e=>"static/js/async/"+(121===e?"katex-vendor":e)+"."+({0:"8e59f2eb5b","0k":"5852e6b4fa","0w":"9ed36d5860",1:"f387c12b63",12:"d091f91c99",121:"de6a87c308",13:"8f810a8a6c",19:"6fe909d55a","1b":"23f1141a38","1k":"5974df3b87","1p":"0d5cddda96",2:"b589f1733b","2v":"96165101de",3:"0cacc08423",37:"b28b2f61cd","3d":"5085fb913f","3j":"357c80ff38","3p":"bcf32a0983","3r":"3a69e98ee0","3u":"1228460e2a","3y":"71f2ccf3b6",4:"9442eeb472","4e":"678285ca55","4k":"33a0c7eeb4","4q":"aad20dab25",5:"ebaf8b89cc",51:"95bcae98af","5b":"0d6ae50fe8","5bh":"8b2363424f","5j":"d6407c4248","5o":"88316d4460",6:"f034c9b528",66:"5dfa29f957","6o":"5b1a06a382",7:"e4a9288dd0",73:"308dff4da8","7e":"a1cc9bfd88","7g":"a7814350c3","7l":"7a6a377ecc",8:"5067439d8c","8j":"ea110663fb",a:"bce4542392",aa:"65d3852576",az:"d656062b0f",b:"b4f6f06515",bi:"09688ba75c",bq:"586bc738d1",c:"797d933882",c0:"0af1e640d3",ca:"8a52cfd447",cf:"d34fff5d67",ct:"b74928f7a3",cx:"ca5feec570",d:"a5fc8fe1b3",da:"f62c70f6c8",dc:"856fda6560",dp:"1725d6432c",e:"93214d622b",f:"ab50467719",f8:"bbf0dbae70",g:"d1c2fe09aa",h:"4e790471e4",h1:"e8d5aa8e80",h3:"216e9798ab",hd:"0da931b622",hk:"ba7fb04d41",hn:"b645041e00",ho:"475a5e1ae4",hp:"e9fe2e395a",hs:"6d480d0ded",i:"7c148e8440",id:"573df20f29",j:"ab925882d8",jd:"63886a1f09",jg:"d86ebd4013",jl:"874d352278",jll:"11313b455a",js:"67182759ef",jsc:"23b70d6f40",jse:"334588ff5d",jz:"72eb929106",k:"7466330d1a",ka:"c1990ecaa3",ku:"29c8a59d0c",ky:"8dab1dade0",l:"12dd34e1be",l9:"949710adaf",ls:"9d9a01026c",m:"0896dab823",ma:"2c261b04dd",me:"8ace414f80",mt:"0352e976d8",n:"a9f1c51701",na:"a36cd532d6",nam:"b5663e919f",nk:"fc7e58325e",o:"36353dfb88",oc:"9c060c9779",og:"634fba99ac",p:"48ecfcd14e",px:"783b6f91f2",q:"23af2a358f",q5:"e683f7c26e",qs:"2a9ddb3c72",r:"51010ad87c",rd:"cb6bf495bb",s:"222ee974f6",sy:"d16be843a7",t:"4dca0e2ba8",t9:"d44f57d518",ta:"973534bbec",tr:"e878658140",u:"0871ac5b22",ud:"3065bfee31",uf:"46ad6209fa",up:"ea990da0ff",uw:"8890abbabc",v:"7d28d3c241",vp:"9b13bf8610",vt:"42416b707d",w:"08ac210f60",wt:"ad92393a90",x:"563f72ca6b",x0:"475516418f",x1:"da8687159b",x4:"69ec69c61b",xl:"a3c562a58c",xn:"6360379f71",xnl:"feb0021e50",y:"1a9ed7a5d8",y6:"43c57defe4",yb:"8c1342401d",ybq:"4491f2f2dc",yg:"35bebd6d0c",yq:"917ddd7ba2",ys:"00687cf82d",yv:"2fa22f009a",z:"56f61a4374",zi:"5fdb07b86a",zj:"654f37e8ff",zn:"966d6f1cc6",zo:"26213b40c0",zx:"e9f4105e00"})[e]+".js",l.miniCssF=e=>""+e+".css",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},l.l=function(t,n,r,i){if(e[t])return void e[t].push(n);if(void 0!==r)for(var s,a,o=document.getElementsByTagName("script"),c=0;c<o.length;c++){var d=o[c];if(d.getAttribute("src")==t||d.getAttribute("data-rspack")=="ompchamber:"+r){s=d;break}}s||(a=!0,(s=document.createElement("script")).timeout=120,l.nc&&s.setAttribute("nonce",l.nc),s.setAttribute("data-rspack","ompchamber:"+r),s.src=t),e[t]=[n];var u=function(n,r){s.onerror=s.onload=null,clearTimeout(p);var i=e[t];if(delete e[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach(function(e){return e(r)}),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),a&&document.head.appendChild(s)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t=[],l.O=(e,n,r,i)=>{if(n){i=i||0;for(var s=t.length;s>0&&t[s-1][2]>i;s--)t[s]=t[s-1];t[s]=[n,r,i];return}for(var a=1/0,s=0;s<t.length;s++){for(var[n,r,i]=t[s],o=!0,c=0;c<n.length;c++)(!1&i||a>=i)&&Object.keys(l.O).every(e=>l.O[e](n[c]))?n.splice(c--,1):(o=!1,i<a&&(a=i));if(o){t.splice(s--,1);var d=r();void 0!==d&&(e=d)}}return e},l.p="/",n={qz:0},l.f.j=function(e,t){var r=l.o(n,e)?n[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var i=new Promise((t,i)=>r=n[e]=[t,i]);t.push(r[2]=i);var s=l.p+l.u(e),a=Error();l.l(s,function(t){if(l.o(n,e)&&(0!==(r=n[e])&&(n[e]=void 0),r)){var i=t&&("load"===t.type?"missing":t.type),s=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+s+")",a.name="ChunkLoadError",a.type=i,a.request=s,r[1](a)}},"chunk-"+e,e)}},l.O.j=e=>0===n[e],r=(e,t)=>{var r,i,[s,a,o]=t,c=0;if(s.some(e=>0!==n[e])){for(r in a)l.o(a,r)&&(l.m[r]=a[r]);if(o)var d=o(l)}for(e&&e(t);c<s.length;c++)i=s[c],l.o(n,i)&&n[i]&&n[i][0](),n[i]=0;return l.O(d)},(i=self.rspackChunkompchamber=self.rspackChunkompchamber||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var o=l.O(void 0,["a3","9","jp"],()=>l("l"));o=l.O(o)})();
33
+ (Lanjutkan dari halaman ini.)`})};return window.addEventListener(iC.j,t),()=>window.removeEventListener(iC.j,t)},[]);let[w,N]=(0,ic.bL)("chat.draftAttachments",[]),[Y,D]=(0,i.J0)([]),F=!!l?.startsWith("new-");!function(e){let{sessionId:t,messages:n,scrollRef:r,scrollToBottom:s,enabled:a}=e,l=(0,i.li)(null),o=(0,i.li)(null);ip(()=>{if(l.current!==t){l.current=t,o.current=null;return}a&&t&&0!==n.length&&o.current!==t&&r.current&&(o.current=t,s("instant"))},[t,n,a,r,s])}({sessionId:l,messages:Y,scrollRef:m,scrollToBottom:b,enabled:!F});let[A,C]=(0,i.J0)(!1),S=(0,i.li)(!1),T=(0,i.li)([]);T.current=Y;let[z,$]=(0,i.J0)(""),j=(0,i.li)(null),L=(0,i.li)(l);L.current=l;let M=(0,i.hb)(e=>{S.current=e,C(e)},[]),P=(0,i.li)(!1),E=(0,i.li)(null),R=(0,i.li)(!1),I=(0,i.li)(null),O=(0,i.li)([]),J=!!l&&!String(l).startsWith("new-")&&Number.isNaN(Number(l)),_=(0,i.li)(null),{sessionData:W,adoptedSessionIdRef:K,refreshSessionMeta:U,seedSession:B,hasMore:q,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z}=function(e){let{sessionId:t,setLocalMessages:n,setGenerating:r,isGeneratingRef:s,aiPlaceholderIdRef:a,localMessagesRef:l,optimisticUserIdRef:o,cancelStreamingCoalescer:c,metaRefreshedRef:d,scrollRef:u}=e,[p,m]=(0,i.J0)(null),[h,f]=(0,i.J0)(!1),x=(0,i.li)(null),g=(0,i.li)(null),b=(0,i.li)(null),v=(0,i.li)(null),k=(0,i.hb)(e=>{e.model&&"object"==typeof e.model&&(b.current=e.model);let t=e.model??(s.current?b.current??void 0:void 0),n=e.thinkingLevel??v.current??void 0;m({...e,model:t,thinkingLevel:n})},[]),y=(0,i.li)(t);y.current=t;let{hasMore:w,loadingOlder:N,loadOlderError:Y,loadOlder:D,resetPages:F,applyWindow:A}=function(e){let{sessionId:t,sessionIdRef:n,setLocalMessages:r,scrollRef:s}=e,[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(0),[d,u]=(0,i.J0)(!1),[p,m]=(0,i.J0)(!1),[h,f]=(0,i.J0)(0),x=(0,i.li)(!1),g=(0,i.li)(null),b=(0,i.hb)(()=>{l(!1),c(0),x.current=!1,u(!1),m(!1)},[]),v=(0,i.hb)((e,t)=>{"boolean"==typeof e&&l(e),"number"==typeof t&&c(t)},[]),k=(0,i.hb)(()=>{if(!t||t.startsWith("new-")||!a||x.current)return;x.current=!0,u(!0),m(!1);let e=s?.current;e&&(g.current={prevHeight:e.scrollHeight,prevTop:e.scrollTop}),fetch(`/api/chat/${t}?before=${o}`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{if(n.current!==t)return;let i=e.session?.messages??[];if(v(e.hasMore,e.oldestIndex),0===i.length){g.current=null;return}r(e=>[...i,...e]),f(e=>e+1)}).catch(()=>{n.current===t&&m(!0)}).finally(()=>{x.current=!1,u(!1)})},[t,n,a,o,s,r,v]);return(0,i.Nf)(()=>{let e=g.current;if(!e)return;let t=s?.current;if(!t)return;g.current=null;let n=t.scrollHeight-e.prevHeight;n>0&&(t.scrollTop=e.prevTop+n)},[h,s]),{hasMore:a,loadingOlder:d,loadOlderError:p,loadOlder:k,resetPages:b,applyWindow:v}}({sessionId:t,sessionIdRef:y,setLocalMessages:n,scrollRef:u}),C=(0,i.hb)(e=>{let t=()=>y.current===e||g.current===e;if(!t())return;let n=0,r=()=>{t()&&fetch(`/api/chat/${encodeURIComponent(e)}`).then(e=>e.json()).then(i=>{if(!i?.session||!t())return;if(k(i.session),(i.session.messages?.length??0)>0)return void window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}));let s=iA[n];n+=1,void 0!==s&&setTimeout(r,s)}).catch(()=>{})};r()},[k]),S=(0,i.hb)(e=>{e.model&&(b.current=e.model),e.thinkingLevel&&(v.current=e.thinkingLevel),m(t=>({...t??{},...e.model?{model:e.model}:{},...e.thinkingLevel?{thinkingLevel:e.thinkingLevel}:{}}))},[]),T=(0,i.hb)(()=>s.current&&!!a.current,[a]);return(0,i.vJ)(()=>{let e=!0;if(f(!0),t!==x.current){let e=t&&!t.startsWith("new-")&&x.current?.startsWith("new-"),i=s.current&&g.current===t;e||i||(n([]),r(!1),g.current=null,b.current=null,m(null),v.current=null,a.current=null,o.current=null,c()),F(),d.current=null,x.current=t}return t?fetch(`/api/chat/${t}`).then(e=>e.json()).then(r=>{if(e)if(f(!1),r?.session){k(r.session);let e=r.session.messages||[],i=T();if(e.length>0&&!i)if(s.current){let t=e.map(e=>e.id);n([...e,...l.current.filter(e=>!t.includes(e.id))])}else n(e);else t.startsWith("new-")||i||n([]);A(r.hasMore,r.oldestIndex)}else m(null),T()||n([])}).catch(t=>{console.error("Error loading session from API:",t),e&&f(!1),e&&!T()&&(m(null),n([]))}):(m(null),n([])),()=>{e=!1}},[t,k,T,n,r]),{sessionData:p,hasMore:w,loadingOlder:N,loadOlderError:Y,sessionLoading:h,loadOlder:D,adoptedSessionIdRef:g,refreshSessionMeta:C,seedSession:S}}({sessionId:l,setLocalMessages:D,setGenerating:M,isGeneratingRef:S,aiPlaceholderIdRef:_,localMessagesRef:T,optimisticUserIdRef:I,cancelStreamingCoalescer:iL,metaRefreshedRef:E,scrollRef:m});p.current=Z;let Q=(0,i.li)(null),X=(0,i.li)(null),ee=(0,i.li)(null),[et,en]=(0,i.J0)(()=>{var e,t;return"string"==typeof(t=e=n.omp_access_mode)&&ei.some(e=>e===t)?e:"always-ask"}),er=(0,i.li)(et);er.current=et;let es=(0,i.hb)(e=>{en(e),er.current=e,(0,iM.cz)("omp_access_mode",e)},[]),ea=(0,i.hb)(e=>{l&&fetch(`/api/chat/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e})}).catch(e=>console.error("Error persisting messages via API:",e))},[l]),{messageQueue:el,enqueueMessage:eo,removeMessage:ec,reorderMessages:ed,steeringQueue:eu,setSteeringQueue:ep}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,ic.bL)("chat.steeringQueue",[]),a=(0,i.li)(0),l=(0,i.li)(!1),o=(0,i.hb)(()=>{if(!e)return void n([]);let t=++a.current;fetch(id(e)).then(e=>iu(e)).then(e=>{l.current||a.current!==t||n(e??[])}).catch(()=>{})},[e]);(0,i.vJ)(()=>{l.current=!1,o();let e=()=>o();return window.addEventListener("focus",e),()=>{l.current=!0,window.removeEventListener("focus",e)}},[o]),(0,i.vJ)(()=>{e&&0!==t.length&&fetch(`${id(e)}/deliver`,{method:"POST"}).catch(()=>{})},[e,t.length>0]);let c=(0,i.hb)(t=>{if(!e)return;let r={...t,id:`queue-${Date.now()}`};n(e=>[...e,r]),fetch(id(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(e=>iu(e)).then(e=>{e&&n(e)}).catch(()=>{})},[e]),d=(0,i.hb)((t,r)=>{e&&fetch(`${id(e)}/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r})}).then(e=>iu(e)).then(e=>{e&&n(e)}).catch(()=>{})},[e]);return{messageQueue:t,enqueueMessage:c,editMessageText:d,removeMessage:(0,i.hb)(t=>{e&&(n(e=>e.filter(e=>e.id!==t)),fetch(`${id(e)}/${encodeURIComponent(t)}`,{method:"DELETE"}).then(e=>iu(e)).then(e=>{e&&n(e)}).catch(()=>{}))},[e]),reorderMessages:(0,i.hb)(t=>{e&&(n(e=>{let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>n.get(e)).filter(e=>!!e)}),fetch(id(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderedIds:t})}).then(e=>iu(e)).then(e=>{e&&n(e)}).catch(()=>{}))},[e]),refresh:o,steeringQueue:r,setSteeringQueue:s}}(l),{pending:em,enqueue:eh,resolve:ef,withdraw:ex}=function(e){let[t,n]=(0,i.J0)([]);(0,i.vJ)(()=>{n([])},[e]);let r=(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]);return{pending:t,enqueue:r,resolve:(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e)?t.filter(t=>t.id!==e):t)},[]),withdraw:(0,i.hb)(e=>{n(t=>t.filter(t=>t.id!==e))},[])}}(l),eg=function(e,t,n){let[r,s]=(0,i.J0)({isGenerating:!1,connected:!1,error:null}),a=(0,i.li)(t);a.current=t;let l=(0,i.li)(e);l.current=e;let o=(0,i.li)(new Map),c=(0,i.li)(null),d=(0,i.li)(!1),u=(0,i.li)(""),p=(0,i.li)(void 0),m=(0,i.li)(new Set),{connect:h,disconnect:f}=function(e){let{setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c,transport:d}=e,u=(0,i.li)(null);(0,i.vJ)(()=>((0,is.dX)({transport:d,connected:!1}),()=>(0,is.dX)({transport:d,connected:!1})),[d]);let p=(0,i.hb)(()=>{let e=u.current;u.current=null,e?.close(),t(e=>({...e,connected:!1})),(0,is.dX)({transport:d,connected:!1})},[t,d]);return{connect:(0,i.hb)(e=>{p(),u.current=ia[d](e,{onOpen:()=>{t(e=>({...e,connected:!0})),(0,is.dX)({transport:d,connected:!0}),n.current?.onConnected?.()},onFrame:i=>{!function(e,t){let n=t.callbacksRef.current;switch(e.type){case"agent_start":t.setState(e=>({...e,isGenerating:!0,error:null})),t.toolResultsRef.current?.clear(),t.fileMutatingCallsRef.current?.clear(),t.lastToolMessageRef.current=null,t.interruptPendingRef.current=!1,t.currentThinkingLevelRef.current=void 0,r7(r3.n1.thinking,t),n?.onAgentStart?.();break;case"turn_start":r7(r3.n1.thinking,t),n?.onTurnStart?.();break;case"message_start":case"message_update":{let r=e.message;if(!r)break;if("toolResult"===r.role){it(r,t),r7(r3.n1.thinking,t);break}r7(function(e){if(!(0,nd.u)(e))return;let t=(0,r3.oJ)(e.type);if(t){if(t.startsWith("thinking"))return r3.n1.thinking;if(t.startsWith("text"))return r3.n1.writing;if("toolcall_start"===t||"toolcall_delta"===t){let t=function(e){let t=e.partial;if(!(0,nd.u)(t))return;let n=t.content;if(!Array.isArray(n))return;let r="number"==typeof e.contentIndex?e.contentIndex:n.length-1,i=n[r];if((0,nd.u)(i)&&"toolCall"===i.type)return i}(e);if(!t)return;return r8({name:(0,r3.oJ)(t.name),args:t.arguments})}if("toolcall_end"===t){let t=e.toolCall;if(!(0,nd.u)(t))return;return r8({name:(0,r3.oJ)(t.name),args:t.arguments})}}}(e.assistantMessageEvent),t),"message_start"===e.type&&n?.onTurnStart?.();let i=rE(r);i&&("user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current),n?.onMessageUpdate?.(i));break}case"message_end":{let r=e.message;if(!r)break;if("toolResult"===r.role){it(r,t);break}if("custom"===r.role)break;if("user"===r.role){let e=rT(r.content);e&&n?.onQueuedMessageDelivered?.(e);break}let i=rE(r,!1);if(!i)break;"user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current);let s=ie(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s);break}case"tool_execution_start":{let r="string"==typeof e.toolCallId?e.toolCallId:void 0;r7(r8({name:"string"==typeof e.toolName?e.toolName:void 0,args:e.args,intent:"string"==typeof e.intent?e.intent:void 0}),t),r&&t.toolResultsRef.current?.set(r,{output:""}),r&&(0,r6.Y)({toolName:e.toolName,args:e.args})&&t.fileMutatingCallsRef.current?.add(r);let i=t.lastToolMessageRef.current;i?.toolCalls?.some(e=>e.id===r)&&(t.lastToolMessageRef.current={...i,toolCalls:i.toolCalls.map(e=>({...e,status:"running"}))},n?.onMessageUpdate?.(t.lastToolMessageRef.current));break}case"tool_execution_update":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0,r=rP(e.partialResult);if(!n||!r)break;let i=t.toolResultsRef.current?.get(n)?.output??"",s=t.toolResultsRef.current;s&&r9(s,n,{output:i+r}),ir(n,t);break}case"tool_execution_end":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0;if(!n)break;r7(r3.n1.thinking,t);let r=t.toolResultsRef.current;r&&r9(r,n,{output:rP(e.result),isError:!0===e.isError,details:e.details&&"object"==typeof e.details?e.details:void 0}),ir(n,t),"u">typeof window&&t.fileMutatingCallsRef.current?.delete(n)&&window.dispatchEvent(new CustomEvent(r6.s,{detail:{sessionId:t.sessionId}}));break}case"agent_end":{t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="";let r=function(e,t,n){let r;if(!1===e.isTerminal)return{};let i=e.messages;if(!Array.isArray(i))return{};for(let e of i){if(!e||"object"!=typeof e||Array.isArray(e)||"assistant"!==e.role||"aborted"!==e.stopReason&&"error"!==e.stopReason)continue;let i=rE(e,!1);if(!i)continue;let s=ie(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s),"string"==typeof e.errorMessage&&(r=e.errorMessage)}return{errorMessage:r}}(e,t,n??void 0);if(t.interruptPendingRef.current){t.interruptPendingRef.current=!1;break}n?.onAgentEnd?.({errorMessage:r.errorMessage??("string"==typeof e.errorMessage?e.errorMessage:void 0),message:"string"==typeof e.message?e.message:void 0});break}case"prompt_error":{let r="string"==typeof e.errorMessage?e.errorMessage:"Prompt failed";t.setState(e=>({...e,isGenerating:!1,error:r})),t.interruptPendingRef.current=!1,t.activityRef.current="",n?.onPromptError?.(r);break}case"prompt_result":!1===e.agentInvoked&&(t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="",n?.onPromptSettled?.());break;case"command_output":{let t="string"==typeof e.text?e.text.trim():"";t&&n?.onCommandOutput?.(t);break}case"notice":n?.onNotice?.("string"==typeof e.level?e.level:"info","string"==typeof e.message?e.message:"");break;case"extension_ui_request":n?.onExtensionUiRequest?.(e);break;case"subagent_lifecycle":case"subagent_progress":case"subagent_event":{let n=e.payload;if(null==n||"object"!=typeof n)break;window.dispatchEvent(new CustomEvent(e.type,{detail:{sessionId:t.sessionId,payload:n}}));break}case"model_changed":n?.onModelChanged?.();break;case"thinking_level_changed":var r;t.currentThinkingLevelRef.current="string"==typeof(r=e.thinkingLevel)&&r.trim()?r.trim():"off"}}(i,{sessionId:e,setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c})},onClose:()=>{t(e=>({...e,connected:!1})),(0,is.dX)({transport:d,connected:!1})}})},[p,t,n,r,s,a,l,o,c,d]),disconnect:p}}({setState:s,callbacksRef:a,toolResultsRef:o,lastToolMessageRef:c,interruptPendingRef:d,activityRef:u,currentThinkingLevelRef:p,fileMutatingCallsRef:m,transport:n});(0,i.vJ)(()=>{if(!e)return;o.current.clear(),m.current.clear(),c.current=null,u.current="";let t=!1;return fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(n=>{if(t||!n?.running)return;let r=n.state;for(let t of((n.busy||r?.isStreaming||r?.isPromptRunning)&&(h(e),a.current.onResumeStream?.()),n.pendingUiRequests??[]))a.current.onExtensionUiRequest?.(t)}).catch(()=>{}),()=>{t=!0,f()}},[e,f,h]);let{sendPrompt:x,sendNewPrompt:g}=function(e){let{sessionIdRef:t,connect:n,setState:r}=e;return{sendPrompt:(0,i.hb)(async(e,i,s)=>{let a=t.current;if(!a)return!1;r(e=>({...e,isGenerating:!0,error:null}));try{(await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_state",...s?.accessMode?{accessMode:s.accessMode}:{}})})).ok&&n(a);let t=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await t.json().catch(()=>({}));if(!t.ok||l.error)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${t.status}`})),!1;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:a}})),!0}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[n,t,r]),sendNewPrompt:(0,i.hb)(async(e,t,i,s)=>{r(e=>({...e,isGenerating:!0,error:null}));try{let a=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"ensure_session",cwd:t,...s?.model?s.model:{},...s?.thinkingLevel?{thinkingLevel:s.thinkingLevel}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await a.json().catch(()=>({}));if(!a.ok||!l.sessionId)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${a.status}`})),null;let o=l.sessionId;n(o);let c=await fetch(`/api/agent/${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{}})}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)return r(e=>({...e,isGenerating:!1,error:d.error??`HTTP ${c.status}`})),null;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:o}})),{sessionId:o,model:l.model??null}}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),null}},[n,r])}}({sessionIdRef:l,connect:h,setState:s}),b=(0,i.hb)(async()=>{let e=l.current;e&&(d.current=!1,await io(e),s(e=>({...e,isGenerating:!1})))},[]),v=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;d.current=!0,s(e=>({...e,isGenerating:!0,error:null}));try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"abort_and_prompt",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return d.current=!1,s(e=>({...e,isGenerating:!1,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return d.current=!1,s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[]),k=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"follow_up",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return s(e=>({...e,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return s(t=>({...t,error:e instanceof Error?e.message:String(e)})),!1}},[]),y=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_model",provider:e,modelId:t})})}catch{}},[]),w=(0,i.hb)(async e=>{let t=l.current;if(t)try{await fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_thinking_level",level:e})})}catch{}},[]),N=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e.id,...t})})}catch{}},[]);return{...r,sendPrompt:x,sendNewPrompt:g,sendInterruptAndReply:v,sendFollowUp:k,abort:b,setModel:y,setThinkingLevel:w,respondToExtensionUi:N,disconnect:f}}(J?l:null,function(e){let{setGenerating:t,setGeneratingVerb:n,scrollToBottom:r,adoptedSessionIdRef:i,sessionIdRef:s,metaRefreshedRef:a,firstAssistantRef:l,refreshSessionMeta:o,setLocalMessages:c,aiPlaceholderIdRef:d,optimisticUserIdRef:u,pendingUserDisplaysRef:p,persistMessages:m,abortControllerRef:h,appSettings:f,enqueueExtensionDialog:x,withdrawExtensionDialog:g}=e;return iT=c,iz=()=>r("smooth"),{onAgentStart:()=>{t(!0),n(r3.n1.thinking),setTimeout(()=>r("smooth"),50),l.current=!1;let e=i.current??s.current;e&&(window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),a.current!==e&&(a.current=e,setTimeout(()=>o(e),100)))},onTurnStart:()=>{let e=i.current??s.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onResumeStream:()=>{t(!0),n(r3.n1.thinking),setTimeout(()=>r("smooth"),50),l.current=!1;let e=i.current??s.current;e&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onActivity:e=>{n(e)},onMessageUpdate:e=>{"user"===e.role||rr(e)||(u.current=null),i$.queue(t=>{let n=d.current;if(rr(e)){if(t.some(t=>t.id===e.id))return t;if(n&&t.some(e=>e.id===n)){let r=t.findIndex(e=>e.id===n);return[...t.slice(0,r),e,...t.slice(r)]}return[...t,e]}if("user"===e.role){if(t.some(t=>t.id===e.id))return t;let r=u.current;if(r){let n=t.findIndex(e=>e.id===r);if(-1!==n){let r={...e,id:e.id,content:t[n].content,date:t[n].date,attachments:e.attachments?.length?e.attachments:t[n].attachments};return[...t.slice(0,n),r,...t.slice(n+1)]}}let i=p.current.find(t=>e.content===t.sent||e.content.startsWith(t.sent)||t.sent.startsWith(e.content)),s=i?{...e,content:i.display}:e;if(n&&t.some(e=>e.id===n)){let e=t.findIndex(e=>e.id===n);return[...t.slice(0,e),s,...t.slice(e)]}return[...t,s]}if(n&&t.some(e=>e.id===n))return t.map(t=>t.id===n?e:t);let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]},e.id)},onMessageEnd:e=>{if("ai"===e.role&&!rr(e)&&!l.current){l.current=!0;let e=i.current??s.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))}i$.flush(),"user"!==e.role&&(u.current=null),c(t=>{let n,r=d.current;if("user"===e.role){let n,i=u.current;if(t.some(t=>t.id===e.id))n=t.map(t=>t.id===e.id?e:t);else if(i&&t.some(e=>e.id===i))n=t.map(t=>t.id===i?{...e,id:e.id,content:t.content,date:t.date,attachments:e.attachments?.length?e.attachments:t.attachments}:t);else if(r&&t.some(e=>e.id===r)){let i=t.findIndex(e=>e.id===r);n=[...t.slice(0,i),e,...t.slice(i)]}else n=[...t,e];return m(n),n}if(r&&t.some(e=>e.id===r))n=t.map(t=>t.id===r?e:t);else{let r=t.findIndex(t=>t.id===e.id);n=-1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]}return d.current=null,m(n),n})},onAgentEnd:()=>{ij(),t(!1),h.current=null,u.current=null,p.current=[],(0,iD.s4)(f),setTimeout(()=>r("smooth"),50);let e=i.current??s.current;e&&o(e)},onModelChanged:()=>{let e=i.current??s.current;e&&setTimeout(()=>o(e),150)},onPromptError:e=>{t(!1),h.current=null,console.error("OMP prompt error:",e)},onPromptSettled:()=>{ij(),t(!1),h.current=null,u.current=null;let e=d.current;d.current=null,e&&c(t=>t.some(t=>t.id===e)?t.filter(t=>t.id!==e):t)},onCommandOutput:e=>{let t={id:`cmdout-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,role:"ai",content:"",notice:e};c(n=>{let r=d.current;if(r){let e=n.findIndex(e=>e.id===r);if(-1!==e)return[...n.slice(0,e),t,...n.slice(e)]}return n.some(t=>t.notice===e)?n:[...n,t]})},onNotice:(e,t)=>{console.info("OMP notice:",t)},onExtensionUiRequest:e=>{"select"===e.method||"confirm"===e.method||"input"===e.method||"editor"===e.method?x(e):"cancel"===e.method&&g(e.targetId)}}}({setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,adoptedSessionIdRef:K,sessionIdRef:L,metaRefreshedRef:E,firstAssistantRef:R,refreshSessionMeta:U,setLocalMessages:D,aiPlaceholderIdRef:_,optimisticUserIdRef:I,pendingUserDisplaysRef:O,persistMessages:ea,abortControllerRef:j,appSettings:n,enqueueExtensionDialog:eh,withdrawExtensionDialog:ex}),(0,ii.ul)(n)),{steerOmpAgent:eb,executeSend:ev}=function(e){let{folders:t,selectedFolderId:n,sessionId:r,isOmpSession:s,appSettings:a,ompAgent:l,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,scrollToBottom:p,jumpToBottom:m,aiPlaceholderIdRef:h,adoptedSessionIdRef:f,optimisticUserIdRef:x,pendingUserDisplaysRef:g,seedSession:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,accessModeRef:y,abortControllerRef:w,setInputValue:N,setSearchParams:Y}=e,D=(0,i.hb)(async(e,t)=>{let n=new Map;try{await Promise.all(t.filter(e=>iv(e.file)).map(async e=>{n.set(e.id,await e.file.text())}))}catch{}let r=t.filter(e=>n.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:n.get(e.id),size:e.file.size})),i=await iY(e,r);g.current=[...g.current.slice(-7),{sent:i,display:e}];let s=t.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type}));return{promptText:i,images:s.length?s:void 0}},[]);return{steerOmpAgent:(0,i.hb)(async(e,t)=>{let{promptText:n,images:r}=await D(e,t);await l.sendInterruptAndReply(n,r)||N(e)},[l,D,N]),executeSend:(0,i.hb)(async(e,i,g)=>{let N=g?.model??null,D=N?.accessMode??y.current,F=tI(),A=`msg-${Date.now()}-user`,C=`msg-${Date.now()+1}-ai`,S=new Map;try{await Promise.all(i.filter(e=>iv(e.file)).map(async e=>{S.set(e.id,await e.file.text())}))}catch{}let T=Date.now(),z={id:A,role:"user",date:`Today, ${F}`,startedAt:T,content:e,attachments:i.map(e=>({name:e.file.name,preview:e.dataBase64?`data:${e.file.type};base64,${e.dataBase64}`:e.preview,type:e.file.type,size:e.file.size,content:S.get(e.id)}))},$={id:C,role:"ai",date:`Today, ${F}`,startedAt:T,content:""};if(o(e=>{let t=[...e,z,$];return c(t.filter(e=>e.id!==C)),t}),d(!0),u(r3.n1.thinking),setTimeout(()=>m("smooth"),50),s){h.current=C,x.current=A,N&&(await l.setModel(N.provider,N.modelId),"auto"!==N.thinkingLevel&&await l.setThinkingLevel(N.thinkingLevel));let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>S.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:S.get(e.id),size:e.file.size})),r=await iY(e,n);await l.sendPrompt(r,t.length?t:void 0,{accessMode:D})||(o(e=>e.filter(e=>e.id!==A&&e.id!==C)),h.current=null,x.current=null,d(!1));return}if(!s){let r=t.find(e=>String(e.id)===String(n)),s=r?.project_path||r?.name;if(s){let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>S.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:S.get(e.id),size:e.file.size})),r=await iY(e,n);x.current=A;let a=v.current,o=k.current,c=await l.sendNewPrompt(r,s,t.length?t:void 0,{model:a,thinkingLevel:o,accessMode:y.current});if(c){f.current=c.sessionId,h.current=C,b({model:c.model,thinkingLevel:o}),v.current=null,k.current=null,fetch(`/api/chat/${encodeURIComponent(c.sessionId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[z]})}).catch(e=>console.error("Error persisting spawned user turn:",e)),Y(e=>{let t=new URLSearchParams(e);return t.set("sessionId",c.sessionId),t},{replace:!0});return}}}x.current=null,w.current&&w.current.abort();let j=new AbortController;w.current=j;let L=t.find(e=>String(e.id)===String(n)),M=L?.name||"Workspace";await ih({sessionId:r||`session-${Date.now()}`,prompt:e,workspaceName:M,attachments:i,signal:j.signal},function(e){let{aiPlaceholderId:t,setLocalMessages:n,persistMessages:r,setGenerating:i,setGeneratingVerb:s,abortControllerRef:a,appSettings:l,scrollToBottom:o}=e,c=!1,d=iF(e=>n(e),()=>{c&&(c=!1,o("smooth"))}),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(c=!0),d.queue(e)};return{onInit:e=>{u(n=>n.map(n=>n.id===t?{...n,id:e.id,date:e.date}:n))},onThinkingStart:()=>{s(r3.n1.thinking),u(e=>e.map(e=>e.id===t||"ai"===e.role?{...e,thinking:{thought:"",isGenerating:!0}}:e)),setTimeout(()=>o("smooth"),50)},onThinkingChunk:e=>{u(n=>n.map(r=>{if(r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id){let t="object"==typeof r.thinking&&r.thinking.thought||"";return{...r,thinking:{thought:t+e.delta,isGenerating:!0}}}return r}),!0)},onThinkingEnd:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,thinking:{thought:e.thought,summary:e.summary,duration:e.duration,isGenerating:!1}}:r))},onToolStart:e=>{s(r8({name:e.name??e.type,input:e.input,command:e.command,target:e.target,intent:e.intent})),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:[...r.toolCalls||[],e]}:r)),setTimeout(()=>o("smooth"),50)},onToolOutputChunk:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,output:(t.output||"")+e.delta}:t)}:r),!0)},onToolEnd:e=>{s(r3.n1.thinking),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,...e}:t)}:r))},onContentChunk:e=>{s(r3.n1.writing),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,content:(r.content||"")+e.delta}:r),!0)},onSummary:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,summary:e.summary}:r))},onDone:e=>{d.flush(),n(n=>{let i=n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?e.message:r);return r(i),i}),i(!1),a.current=null,(0,iD.s4)(l),setTimeout(()=>o("smooth"),50)},onError:()=>{i(!1),a.current=null}}}({aiPlaceholderId:C,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,abortControllerRef:w,appSettings:a,scrollToBottom:p}))},[a,t,s,l,n,r,p,m,c,b,v,k,y])}}({folders:t,selectedFolderId:c,sessionId:l,isOmpSession:J,appSettings:n,ompAgent:eg,setLocalMessages:D,persistMessages:ea,setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,jumpToBottom:v,aiPlaceholderIdRef:_,adoptedSessionIdRef:K,optimisticUserIdRef:I,pendingUserDisplaysRef:O,seedSession:B,pendingComposerModelRef:Q,pendingThinkingLevelRef:X,composerModelRef:ee,accessModeRef:er,abortControllerRef:j,setInputValue:y,setSearchParams:a}),{handleSend:ek,handleEditQueueItem:ey,handleSendNowQueueItem:ew,handleUndo:eN,handleRetry:eY,submitNewChat:eD,stopGenerating:eF,handleThinkingLevelChange:eA,handleModelChange:eC}=function(e){let{inputValue:t,setInputValue:n,setInputAttachments:r,isGenerating:s,isOmpSession:a,sessionId:l,appSettings:o,messageQueue:c,enqueueMessage:d,removeMessage:u,executeSend:p,steerOmpAgent:m,ompAgent:h,abortControllerRef:f,setGenerating:x,stopHoldRef:g,persistMessages:b,setLocalMessages:v,pendingComposerModelRef:k,pendingThinkingLevelRef:y,composerModelRef:w,accessModeRef:N,setSearchParams:Y}=e,D=(0,i.hb)(async(e,r)=>{let i=t.trim();if(i||0!==e.length){if(g.current=!1,s){if(r?.steering){n(""),a?await m(i,e):(f.current&&(f.current.abort(),f.current=null),x(!1),p(i,e));return}if("steering"===(o.omp_chamber_settings?.followUpBehavior??o.followUpBehavior??"queue")&&a){n(""),await m(i,e);return}let t=w.current,s=t?{...t,accessMode:N.current}:null;n(""),d({text:i,attachments:e,model:s});return}n(""),p(i,e)}},[t,s,p,d,a,o,m,n,f,x,g,w,N]),F=(0,i.hb)(e=>{n(e.text),r(e.attachments),u(e.id)},[u,n,r]),A=(0,i.hb)(async e=>{g.current=!1,u(e.id),s?a?m(e.text,e.attachments):(f.current&&(f.current.abort(),f.current=null),x(!1),setTimeout(()=>p(e.text,e.attachments,{model:e.model}),0)):p(e.text,e.attachments,{model:e.model})},[s,p,u,a,m,f,x,g]),C=(0,i.hb)(async(e,t)=>{if(s&&(a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1)),t&&n(t),a&&l){if(!(await fetch(`/api/chat/${encodeURIComponent(l)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryId:e})})).ok)return!1;let t=await fetch(`/api/chat/${encodeURIComponent(l)}`).then(e=>e.json()).catch(()=>null),n=t?.session?.messages??[];return n.length>0&&v(n),!0}return v(t=>{let n=t.findIndex(t=>t.id===e),r=-1!==n?t.slice(0,n):t;return b(r),r}),!0},[s,a,l,b,f,x,n,v]),S=(0,i.hb)(e=>{s&&(a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1)),v(t=>{let n=t.findIndex(t=>t.id===e);if(n>0&&"user"===t[n-1].role){let e=t[n-1];setTimeout(()=>{let t=Array.isArray(e.attachments)?e.attachments:[];p(e.content,t)},0);let r=t.slice(0,n-1);return b(r),r}return t})},[s,p,b,a,h,f,x,v]),T=(0,i.hb)((e,t)=>{let n=`new-${Date.now()}`;Y(e=>{let t=new URLSearchParams(e);return t.set("sessionId",n),t},{replace:!0}),v([]),setTimeout(()=>{p(e,t)},0)},[Y,p,v]),z=(0,i.hb)(()=>(g.current=!0,a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1),c.length),[a,h,f,x,c.length,g]);return{handleSend:D,handleEditQueueItem:F,handleSendNowQueueItem:A,handleUndo:C,handleRetry:S,submitNewChat:T,stopGenerating:z,handleThinkingLevelChange:(0,i.hb)(e=>{if("auto"!==e){if(!a){y.current=e;return}h.setThinkingLevel(e)}},[a,h,y]),handleModelChange:(0,i.hb)((e,t)=>{if(!a){k.current={provider:e,modelId:t};return}h.setModel(e,t)},[a,h,k])}}({inputValue:k,setInputValue:y,setInputAttachments:N,isGenerating:A,isOmpSession:J,sessionId:l,appSettings:n,messageQueue:el,enqueueMessage:eo,removeMessage:ec,executeSend:ev,steerOmpAgent:eb,ompAgent:eg,abortControllerRef:j,setGenerating:M,stopHoldRef:P,persistMessages:ea,setLocalMessages:D,pendingComposerModelRef:Q,pendingThinkingLevelRef:X,composerModelRef:ee,accessModeRef:er,setSearchParams:a});return{sessionId:l,folderId:o,isOmpSession:J,selectedFolderId:c,setSelectedFolderId:u,sessionData:W,localMessages:Y,isGenerating:A,hasMore:q,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z,generatingVerb:z,messageQueue:el,removeMessage:ec,reorderMessages:ed,steeringQueue:eu,setSteeringQueue:ep,inputValue:k,setInputValue:y,inputAttachments:w,setInputAttachments:N,scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v,handleSend:ek,handleEditQueueItem:ey,handleSendNowQueueItem:ew,handleUndo:eN,handleRetry:eY,submitNewChat:eD,stopGenerating:eF,handleThinkingLevelChange:eA,handleModelChange:eC,accessMode:et,handleAccessModeChange:es,composerModelRef:ee,extensionDialogs:em,resolveExtensionDialog:ef,respondToExtensionUi:eg.respondToExtensionUi}}({folders:c,appSettings:n}),{toasts:en,pushToast:er,dismissToast:es}=(0,iI.Y)(),{framesByTool:ea,modalRequest:el}=(0,i.Kr)(()=>(function(e,t){let n=new Map;if(0===t.length)return{framesByTool:n,modalRequest:null};let r=new Map;for(let t of e)for(let e of t.toolCalls??[]){if("ask"!==("string"==typeof e.name&&e.name?e.name:e.type)&&"ask"!==e.title)continue;let t=h(e);t.length>0&&r.set(e.id,t)}let i=new Map,s=new Set,a=null;for(let e of t){let t="string"==typeof e.title?p(e.title):"",n=null;if(t){for(let[e,i]of r)if(i.some(e=>p(e.question)===t)){n=e;break}}n||"confirm"===e.method||(n=a),n&&(s.add(e),a=n,i.set(n,[...i.get(n)??[],e]))}for(let[e,t]of i)n.set(e,function(e,t){let n=e.map(()=>[]);if(0===e.length)return n;let r=e.map(e=>p(e.question)),i=0;for(let e of t){let t="string"==typeof e.title?p(e.title):"",s=r.indexOf(t);s>i?i=s:-1===s&&"select"===e.method&&n[i].some(e=>"select"===e.method)&&i+1<n.length&&(i+=1),n[i].push(e)}return n}(r.get(e)??[],t));return{framesByTool:n,modalRequest:t.find(e=>!s.has(e))??null}})(g,X),[g,X]),eo=(0,i.hb)((e,t)=>{et(e,t),ee(e.id)},[et,ee]),ec=(0,i.Kr)(()=>({framesByTool:ea,respond:eo}),[ea,eo]),[ed,eu]=(0,i.J0)(null),{pendingUndo:ep,undoing:em,requestUndo:eh,closeUndoConfirm:ef,confirmUndo:ex}=function(e){let[t,n]=(0,i.J0)(null),[r,s]=(0,i.J0)(!1),a=(0,i.hb)((e,t)=>{n({id:e,content:t??""})},[]),l=(0,i.hb)(()=>n(null),[]),o=(0,i.hb)(async()=>{!t||r||(s(!0),await e(t.id,t.content)&&n(null),s(!1))},[e,t,r]);return{pendingUndo:t,undoing:r,requestUndo:a,closeUndoConfirm:l,confirmUndo:o}}(K),[eg,eb]=(0,s.o)(),ev=(0,i.hb)(()=>{let e=q();0!==e&&er(`Stopped. ${e} message${e>1?"s":""} still queued — nothing was sent.`,"success",{action:{label:"Send now",onClick:()=>{let e=F[0];e&&W(e)}},duration:8e3})},[q,er,F,W]),{activeSubagent:ek,back:ey}=function(e,t,n){let[r,s]=(0,i.J0)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.detail,r=t?.subagent,i=t?.sessionId;r&&i&&(s(r),n(e=>(e.get("sessionId")===i&&e.get("subagent")===r.id||(e.set("sessionId",i),e.set("subagent",r.id)),e),{replace:!1}))};return window.addEventListener("omp:view-subagent",e),()=>window.removeEventListener("omp:view-subagent",e)},[n]),(0,i.vJ)(()=>{if(!t)return void s(null);if(r?.id===t||!e)return;let n=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`).then(e=>e.ok?e.json():null).then(e=>{if(n||!e?.subagents)return;let r=e.subagents.find(e=>(0,nd.u)(e)&&e.id===t);r&&s((0,iE.Nh)(r))}).catch(()=>{}),()=>{n=!0}},[e,t]),{activeSubagent:r,back:(0,i.hb)(()=>{s(null),n(e=>(e.has("subagent")&&e.delete("subagent"),e),{replace:!0})},[n])}}(u,eg.get("subagent"),eb);!function(e,t,n){let[r,s]=(0,i.J0)(null);(0,i.vJ)(()=>{s(null)},[e]),(0,i.vJ)(()=>{let t=t=>{let n=t.detail;n?.sessionId&&n.title&&String(n.sessionId)===String(e)&&s(n.title)};return window.addEventListener("omp:session-renamed",t),()=>window.removeEventListener("omp:session-renamed",t)},[e]),(0,i.vJ)(()=>{let i=(0,iP.fN)(e)?(0,iP.g2)(e):null;n?.(i??r??t??null)},[e,t,r,n])}(u,x?.title,a);let ew=(0,i.hb)(e=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth",block:"center"})},[]),eN=(0,i.hb)(e=>eu(e),[]),eY=rq(rH)??{},eD=rq(iR)??{},eF=(0,i.Kr)(()=>g.filter(e=>"user"===e.role),[g]),eA="object"==typeof x?.model?x.model.provider:void 0,eC="object"==typeof x?.model?eY[x.model.modelId]??x.model.modelId:x?.model,eS=!!u?.startsWith("new-"),eT=(0,iJ.M)(c,u,m),ez=!eS&&N&&0===g.length;return!u||eS?(0,r.Y)(rv,{className:t,folders:c,selectedFolderId:m,setSelectedFolderId:f,rootPath:eT,inputValue:z,setInputValue:$,inputAttachments:j,setInputAttachments:L,onSend:J,isGenerating:b,appSettings:n,messages:g,provider:eA,providerNames:eD,modelName:eC,modelNames:eY,onThinkingLevelChange:H,onModelChange:G,accessMode:V,onAccessModeChange:Z,composerModelRef:Q,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,generatingVerb:D,variant:l}):(0,r.Y)(y.Provider,{value:ec,children:(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas relative ${t}`,children:[ez?(0,r.Y)(rw,{}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"relative flex-1 min-h-0 flex flex-col",children:ek?(0,r.Y)(rV,{sessionId:u,subagent:ek,onBack:ey,provider:eA,providerNames:eD}):(0,r.Y)(r0,{isMobile:d,userMessages:eF,onScrollTo:ew,scrollRef:M,contentRef:P,handleScroll:I,isScrolling:R,loadingOlder:k,hasMore:v,loadOlderError:w,loadOlder:Y,messages:g,isGenerating:b,provider:eA,providerNames:eD,modelName:eC,modelNames:eY,thinkingLevel:x?.thinkingLevel,onUndo:eh,onRetry:U,onNewChat:eN,showScrollBottom:E,jumpToBottom:O})}),!ek&&(0,r.Y)(r4,{isMobile:d,isGenerating:b,modelName:eC,generatingVerb:D,provider:eA,providerNames:eD,messageQueue:F,onRemoveQueueItem:A,onReorderQueue:C,onEditQueueItem:_,onSendNowQueueItem:W,steeringQueue:S,setSteeringQueue:T,inputValue:z,setInputValue:$,rootPath:eT,attachments:j,setAttachments:L,onSend:J,onStop:ev,appSettings:n,onThinkingLevelChange:H,onModelChange:G,accessMode:V,onAccessModeChange:Z,composerModelRef:Q,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,variant:l})]}),ep&&(0,r.Y)(rY,{isOmpSession:!!u&&!u.startsWith("new-")&&Number.isNaN(Number(u)),content:ep.content,undoing:em,onClose:ef,onConfirm:ex}),null!==ed&&(0,r.Y)(rD,{initialContent:ed,onClose:()=>eu(null),onSend:B,appSettings:n,accessMode:V,onAccessModeChange:Z,composerModelRef:Q}),el&&(0,r.Y)(o,{request:el,onRespond:eo}),(0,r.Y)(iO.y,{toasts:en,onDismiss:es})]})})}},A9(e,t,n){n.d(t,{O:()=>d,k:()=>u});var r=n("j"),i=n("H"),s=n("G"),a=n("X"),l=n("Af"),o=n("ng");let c=(0,s.q6)(null);function d(e){var t;let n,{children:s,initialFolders:d=[]}=e,u=(0,a.L)(),[p,m]=(0,i.J0)(!1),h=(0,i.li)(!1),f=(0,i.li)(new Set);(0,i.vJ)(()=>{h.current||(h.current=!0,u.load("/api/sessions/list"))},[]),(0,i.vJ)(()=>{u.data&&m(!0)},[u.data]);let x=(0,i.Kr)(()=>()=>{"idle"===u.state&&u.load("/api/sessions/list")},[u]),g=!!u.data?.folders?.some(e=>e.sessions?.some(e=>"stream"===e.streamStatus));t=u.data?.folders??[],n=(0,i.li)(null),(0,i.vJ)(()=>{let e=new Set;for(let n of t)for(let t of n.sessions??[])t.awaitingInput&&e.add(String(t.id));let r=n.current;if(n.current=e,r){for(let t of e)if(!r.has(t))return void(0,o.Rn)()}},[t]),(0,l.n)(x,!g,3e4);let b=(0,i.hb)(e=>{let t=String(e),n=u.data?.folders?.flatMap(e=>e.sessions??[]).find(e=>String(e.id)===t)?.streamStatus;!n||"stream"===n||f.current.has(t)||(f.current.add(t),fetch(`/api/sessions/${encodeURIComponent(t)}/stream-seen`,{method:"POST"}).then(()=>{"idle"===u.state&&u.load("/api/sessions/list")}).catch(()=>{f.current.delete(t)}))},[u]),v=(0,i.Kr)(()=>{let e=u.data,t=f.current;if(t.size&&e?.folders)for(let n of e.folders)for(let e of n.sessions??[])"stream"===e.streamStatus&&t.delete(String(e.id));return{folders:(e?.folders??d).map(e=>t.size?{...e,sessions:(e.sessions??[]).map(e=>t.has(String(e.id))&&e.streamStatus&&"stream"!==e.streamStatus?{...e,streamStatus:void 0}:e)}:e),isMock:e?.isMock??!1,initializing:!p,refresh:x,markSeen:b,hasSeen:e=>t.has(String(e))}},[u.data,d,p,x,b]);return(0,r.Y)(c.Provider,{value:v,children:s})}function u(){let e=(0,i.NT)(c);return e||{folders:[],isMock:!1,initializing:!0,refresh:()=>{},markSeen:()=>{},hasSeen:()=>!1}}},z4(e,t,n){n.d(t,{K:()=>f});var r=n("H"),i=n("s");function s(e){let t=-1/0;for(let n of e.sessions??[]){let e=function(e){if(!e)return 0/0;let t=Date.parse(e);return Number.isFinite(t)?t:0/0}(n.updated_at??n.created_at);e>t&&(t=e)}return t}function a(e){let t=-1/0;for(let n of e.sessions??[]){let e=Number(n.id);Number.isFinite(e)&&e>t&&(t=e)}return t}function l(e){let t=Number(e.id);return Number.isFinite(t)?t:-1/0}function o(e,t){return e===t?0:e>t?-1:1}function c(e,t){return e===t?0:e>t?1:-1}let d=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"];var u=n("Np"),p=n("A9"),m=n("NO"),h=n("So");function f(){let e,t,n,f,x,g,b,v,k,y,w=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},N=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{includePendingSessions:Y=!1,onSelectSession:D,onAfterSelect:F}=N,{folders:A,initializing:C,refresh:S,markSeen:T,hasSeen:z}=(0,p.k)(),[$,j]=(0,i.o)(),L=$.get("sessionId"),M=L?Number.isNaN(Number(L))?L:Number(L):null,P=(0,r.li)(S);P.current=S;let E=(0,r.hb)(()=>P.current(),[]);(e=(0,r.li)(E)).current=E,t=(0,r.li)(void 0),n=(0,r.li)(0),(0,r.vJ)(()=>{let r=()=>{n.current=Date.now(),e.current()},i=()=>{let e=Date.now()-n.current;if(e>=1e3){clearTimeout(t.current),t.current=void 0,r();return}clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,r()},1e3-e)};return window.addEventListener("omp:session-updated",i),()=>{window.removeEventListener("omp:session-updated",i),void 0!==t.current&&(clearTimeout(t.current),t.current=void 0)}},[]),(0,m.sY)("omp:workspace-updated",()=>P.current());let[R,I]=(0,r.J0)(""),[O,J]=(0,r.J0)(!1),[_,W]=(0,r.J0)(!1),[K,U]=(0,r.J0)(()=>{var e;return"string"==typeof(e=w.omp_sidebar_sort)&&d.includes(e)?w.omp_sidebar_sort:"A-Z"}),B=(0,r.li)(null),q=(0,r.hb)(e=>{B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{(0,h.cz)("omp_sidebar_sort",e)},200)},[]);(0,r.vJ)(()=>()=>{B.current&&clearTimeout(B.current)},[]);let H=(0,r.Kr)(()=>(function(e){let t={};for(let n of e)for(let e of n.sessions??[])e.streamStatus&&(t[String(e.id)]=e.streamStatus);return t})(A),[A]);x=null!==(f=null===M?null:String(M))?H[f]:void 0,g=(0,r.li)(null),(b=(0,r.li)(E)).current=E,(v=(0,r.li)(z)).current=z,(0,r.vJ)(()=>{if(!x||"stream"===x||v.current?.(f))return;let e=`${f}:${x}`;g.current!==e&&(g.current=e,fetch(`/api/sessions/${encodeURIComponent(f)}/stream-seen`,{method:"POST"}).then(e=>e.json()).then(e=>{!1===e.deleted&&(g.current=null),b.current()}).catch(()=>{g.current=null}))},[f,x]),(k=(0,r.li)(Object.values(H).includes("stream"))).current=Object.values(H).includes("stream"),(y=(0,r.li)(E)).current=E,(0,r.vJ)(()=>{let e=setInterval(()=>{k.current&&y.current()},8e3);return()=>clearInterval(e)},[]);let G=(0,r.Kr)(()=>{let e=[...A];if(Y){let t=e.some(e=>e.sessions?.some(e=>String(e.id)===String(L))),n=L&&!t?L:null;if(n){let t=$.get("folderId"),r=t?e.find(e=>String(e.id)===String(t)):e[0],i=!!r?.sessions?.some(e=>String(e.id)===String(n));if(r&&!i){let t=(0,u.fd)(n),i=Number.isFinite(t)?new Date(t).toISOString():new Date().toISOString();e=e.map(e=>{if(e.id!==r.id)return e;let t={id:n,folder_id:e.id,title:(0,u.g2)(n),created_at:i,updated_at:i};return{...e,isExpanded:!0,sessions:[t,...e.sessions||[]]}})}}}if(R.trim()){let t=R.toLowerCase();e=Y?e.filter(e=>{let n=e.name.toLowerCase().includes(t),r=e.sessions?.some(e=>e.title.toLowerCase().includes(t));return n||r}).map(e=>{let n=e.sessions?.filter(n=>e.name.toLowerCase().includes(t)||n.title.toLowerCase().includes(t));return{...e,sessions:n,isExpanded:!0}}):e.map(e=>{let n=e.name.toLowerCase().includes(t),r=(e.sessions||[]).filter(e=>e.title.toLowerCase().includes(t));return n?e:{...e,sessions:r}}).filter(e=>e.sessions&&e.sessions.length>0)}return e=[...e].sort((e,t)=>(function(e,t,n){let r=!!e.isPinned;if(r!==!!t.isPinned)return r?-1:1;switch(n){case"Z-A":{let n=t.name.localeCompare(e.name);return 0!==n?n:c(l(e),l(t))}case"LATEST_SESSION":{let n=o(s(e),s(t));if(0!==n)return n;let r=o(a(e),a(t));if(0!==r)return r;let i=o(l(e),l(t));return 0!==i?i:e.name.localeCompare(t.name)}case"LATEST_ADDED":{let n=o(l(e),l(t));return 0!==n?n:e.name.localeCompare(t.name)}default:{let n=e.name.localeCompare(t.name);return 0!==n?n:c(l(e),l(t))}}})(e,t,K))},[A,R,K,L,$,Y]);return{folders:A,initializing:C,refresh:E,activeSessionId:M,sessionParam:L,searchQuery:R,setSearchQuery:I,showArchived:O,setShowArchived:J,optionsOpen:_,setOptionsOpen:W,sortOption:K,handleSortChange:e=>{U(e),W(!1),q(e)},processedFolders:G,sessionStatus:H,handleSelectSession:e=>{T(e),D?D(e):j(t=>(t.set("sessionId",e.toString()),t.has("subagent")&&t.delete("subagent"),t),{replace:!0}),F?.()}}}},FE(e,t,n){var r=n("H"),i=n("g0");function s(){let[e,t]=(0,r.J0)(i.aK);return(0,r.vJ)(()=>{let e=e=>{let n=e.detail;n&&t({transport:n.transport,connected:n.connected})};return window.addEventListener(i.rt,e),t((0,i.aK)()),()=>window.removeEventListener(i.rt,e)},[]),e}n.d(t,{H:()=>s})},pH(e,t,n){async function r(e){if(!e)return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch(e){}try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}catch(e){return console.error("Failed to copy text: ",e),!1}}n.d(t,{l:()=>r})},P6(e,t,n){var r=n("H");function i(e,t){let[n,i]=(0,r.J0)(!1),[s,a]=(0,r.J0)(e),l=(0,r.li)(null),o=(0,r.li)(!1);(0,r.vJ)(()=>{n&&l.current?.select()},[n]);let c=()=>{let n=s.trim();i(!1),n&&n!==e&&t?.(n)},d=()=>{o.current=!0,i(!1)};return{isEditing:n,draft:s,setDraft:a,inputRef:l,startRename:()=>{o.current=!1,a(e),i(!0)},commitRename:c,cancelRename:d,handleKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),c()):"Escape"===e.key&&(e.preventDefault(),d())},handleBlur:()=>{if(o.current){o.current=!1;return}c()}}}n.d(t,{B:()=>i})},ng(e,t,n){n("H");var r=n("So");function i(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type="sine",r.frequency.setValueAtTime(587.33,n),r.frequency.exponentialRampToValueAtTime(880,n+.1),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.14,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.32),r.connect(i),i.connect(t.destination),r.start(n),r.stop(n+.32);let s=t.createOscillator(),a=t.createGain();s.type="sine",s.frequency.setValueAtTime(880,n+.06),s.frequency.exponentialRampToValueAtTime(1174.66,n+.18),a.gain.setValueAtTime(0,n+.06),a.gain.linearRampToValueAtTime(.1,n+.08),a.gain.exponentialRampToValueAtTime(1e-4,n+.42),s.connect(a),a.connect(t.destination),s.start(n+.06),s.stop(n+.42),setTimeout(()=>{try{t.close()}catch{}},550)}catch(e){console.warn("Unable to play notification audio chime:",e)}}function s(e){if("u"<typeof window)return!0;let t=(0,r.BF)(["chatCompletionSound","soundAlerts"],e);return void 0===t||!!t}function a(e){s(e)&&i()}function l(){s()&&function(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime;for(let e of[{at:0,frequency:880,duration:.18,peak:.11},{at:.16,frequency:659.25,duration:.46,peak:.13}]){let r=t.createOscillator(),i=t.createGain();r.type="triangle",r.frequency.setValueAtTime(e.frequency,n+e.at),i.gain.setValueAtTime(0,n+e.at),i.gain.linearRampToValueAtTime(e.peak,n+e.at+.015),i.gain.exponentialRampToValueAtTime(1e-4,n+e.at+e.duration),r.connect(i),i.connect(t.destination),r.start(n+e.at),r.stop(n+e.at+e.duration)}setTimeout(()=>{try{t.close()}catch{}},800)}catch(e){console.warn("Unable to play input-required audio cue:",e)}}()}n.d(t,{$E:()=>i,Rn:()=>l,s4:()=>a})},oj(e,t,n){var r=n("H");function i(e,t){(0,r.vJ)(()=>{let n=n=>{!e.current||e.current.contains(n.target)||t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}n.d(t,{W:()=>i})},jo(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,[t,n]=(0,r.J0)(!1),i=(0,r.li)(null),s=(0,r.hb)(()=>{n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),e)},[e]);return(0,r.vJ)(()=>()=>{i.current&&clearTimeout(i.current)},[]),{isScrolling:t,handleScroll:s}}function s(e){return e?"scrollbar-overlay-scrolling":"scrollbar-overlay"}n.d(t,{K:()=>i,p:()=>s})},NR(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:7,[n,i]=(0,r.J0)(e);return{visibleCount:n,showMore:(0,r.hb)(()=>i(e=>e+t),[t])}}n.d(t,{y:()=>i})},Po(e,t,n){var r=n("H"),i=n("eh");function s(){let[e,t]=(0,r.J0)(()=>(0,i.nv)());return(0,r.vJ)(()=>{let e=(0,i.Eu)(()=>t(!0)),n=(0,i.LT)(()=>t(!0));return()=>{e(),n()}},[]),e}n.d(t,{w:()=>s})},oZ(e,t,n){var r=n("H");function i(){let[e,t]=(0,r.J0)([]),n=(0,r.li)(0);return{toasts:e,pushToast:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error",i=arguments.length>2?arguments[2]:void 0;n.current+=1,t(t=>[...t,{id:n.current,message:e,type:r,...i}])},dismissToast:e=>{t(t=>t.filter(t=>t.id!==e))}}}n.d(t,{Y:()=>i})},DO(e,t,n){var r=n("H");function i(e,t){return"object"!=typeof e||null===e?t:"error"in e&&"string"==typeof e.error?e.error:"message"in e&&"string"==typeof e.message?e.message:t}function s(){let[e,t]=(0,r.J0)(null),[n,s]=(0,r.J0)(!1),[a,l]=(0,r.J0)(null),[o,c]=(0,r.J0)(null),d=(0,r.li)(null),u=(0,r.li)(!1),p=(0,r.hb)(()=>{if(d.current)return d.current;let e=(async()=>{s(!0),c(null);try{let e=await fetch("/api/updates/check"),n=await e.json();if(!e.ok)throw Error(i(n,`Update check failed (HTTP ${e.status})`));t(n)}catch(e){c(e instanceof Error?e.message:"Unable to check for updates.")}finally{s(!1),d.current=null}})();return d.current=e,e},[]),m=(0,r.hb)(async e=>{l(e),c(null);try{let t=await fetch("/api/updates/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:e})}),n=await t.json();if("object"!=typeof n||null===n||!("success"in n)||"boolean"!=typeof n.success||!("target"in n)||"ompchamber"!==n.target&&"omp"!==n.target||!("manual"in n)||"boolean"!=typeof n.manual||!("message"in n)||"string"!=typeof n.message)throw Error(i(n,`Update failed (HTTP ${t.status})`));return await p(),n}catch(e){return c(e instanceof Error?e.message:"Unable to apply the update."),null}finally{l(null)}},[p]);return(0,r.vJ)(()=>{u.current||(u.current=!0,p())},[]),{info:e,checking:n,applying:a,error:o,hasUpdate:!!(e?.ompchamber.updateAvailable||e?.omp.updateAvailable),check:p,apply:m}}n.d(t,{M:()=>s})},c(e,t,n){var r=n("H");function i(e,t){let{enabled:n,intervalMs:i,guardInFlight:s=!1}=t,a=(0,r.li)(e);a.current=e,(0,r.vJ)(()=>{if(!n||i<=0)return;let e="u"<typeof document||"visible"===document.visibilityState,t=!1,r=()=>{if(!s)return void a.current();if(t)return;let e=a.current();if(!e||"function"!=typeof e.then)return;t=!0;let n=()=>{t=!1};Promise.resolve(e).then(n,n)},l=setInterval(()=>{e&&r()},i),o=()=>{let t="visible"===document.visibilityState;t&&!e&&r(),e=t};return document.addEventListener("visibilitychange",o),()=>{clearInterval(l),document.removeEventListener("visibilitychange",o)}},[n,i,s])}n.d(t,{t:()=>i})},NO(e,t,n){var r=n("H");function i(e,t,n,i){let s=(0,r.li)(n);s.current=n,(0,r.vJ)(()=>{let n=e=>s.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[e,t,i])}function s(e,t,n){i(window,e,t,n)}function a(e,t,n){i(document,e,t,n)}function l(e,t,n){i(window,e,t,n)}n.d(t,{MN:()=>s,sY:()=>l,zo:()=>a})},so(e,t,n){var r=n("H"),i=n("LQ"),s=n("c"),a=n("NO");function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,l=!(arguments.length>3)||void 0===arguments[3]||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,[c,d]=(0,r.J0)([]),[u,p]=(0,r.J0)(!1),m=(0,r.hb)(()=>{if(!l)return;p(!0);let n=new URLSearchParams;e&&n.set("root",e),t&&"."!==t&&n.set("repo",t),n.set("t",String(Date.now())),fetch(`/api/fs/git?${n.toString()}`).then(e=>e.json()).then(e=>{Array.isArray(e.changes)?d(e.changes):d([])}).catch(()=>d([])).finally(()=>p(!1))},[l,e,t]);(0,r.vJ)(()=>{m()},[m,n]),(0,s.t)(m,{enabled:l,intervalMs:o}),(0,a.MN)("focus",()=>{l&&m()}),(0,a.zo)("visibilitychange",()=>{l&&m()});let h=(0,r.li)(void 0),f=(0,r.hb)(()=>{l&&void 0===h.current&&(h.current=setTimeout(()=>{h.current=void 0,m()},1e3))},[l,m]);(0,r.vJ)(()=>()=>{void 0!==h.current&&clearTimeout(h.current)},[]),(0,a.sY)("omp:session-updated",f),(0,a.sY)("omp:workspace-updated",f);let{fileMap:x,folderMap:g}=(0,r.Kr)(()=>(0,i._)(c),[c]);return{changes:c,fileMap:x,folderMap:g,isLoading:u,refreshGitStatus:m}}n.d(t,{e:()=>l})},Af(e,t,n){var r=n("H"),i=n("K"),s=n("c");function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;(0,s.t)(e,{enabled:t,intervalMs:n,guardInFlight:!0})}function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,s=(0,r.li)(e);s.current=e,(0,r.vJ)(()=>{let e;if(!t)return;let r=()=>{clearTimeout(e),e=window.setTimeout(()=>{e=void 0,("u"<typeof document||"visible"===document.visibilityState)&&s.current()},n)};return window.addEventListener(i.s,r),()=>{window.removeEventListener(i.s,r),clearTimeout(e)}},[t,n])}n.d(t,{n:()=>a,w:()=>l})},As(e,t,n){var r=n("H");let i=(0,n("G").q6)(null);function s(){let e=(0,r.NT)(i);if(!e)throw Error("useSessionState used outside SessionStateProvider");return e}n.d(t,{O:()=>s},{b:i})},FL(e,t,n){var r=n("H"),i=n("SS"),s=n("As");function a(e,t){let{sessionId:n,ready:a}=(0,s.O)(),l=(0,i.WV)(n,e),[o,c]=(0,r.J0)(void 0===l?t:l),d=(0,r.li)(n);(0,r.vJ)(()=>{if(d.current!==n&&(d.current=n),!a)return;let r=(0,i.WV)(n,e);c(void 0===r?t:r)},[n,a,e]);let u=t=>{let r="function"==typeof t?t((0,i.WV)(n,e)??o):t;c(r),(0,i.qI)(n,e,r)};return a||void 0===l||l===o?[o,u,a]:[l,u,a]}function l(){let{sessionId:e,ready:t}=(0,s.O)();return{sessionId:e,ready:t,read:(t,n)=>{let r=(0,i.WV)(e,t);return void 0===r?n:r},hydrate:t=>(0,i.E9)(e,t)}}n.d(t,{bL:()=>a,p0:()=>l},{LO:a})},U(e,t,n){var r=n("H"),i=n("X");function s(e,t){let[n,s]=(0,r.J0)(!1),a=(0,i.L)(),l=(0,i.L)(),o=(0,i.L)();return(0,r.vJ)(()=>{(a.data?.success||l.data?.success)&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[l.data,a.data]),{confirmDelete:n,requestDelete:()=>s(!0),cancelDelete:()=>s(!1),handlePin:()=>{"number"==typeof e.id&&(a.submit({isPinned:String(!e.isPinned)},{method:"POST",action:`/api/folders/${e.id}/pin`}),t())},handleDelete:()=>{"number"==typeof e.id&&(l.submit({},{method:"POST",action:`/api/folders/${e.id}/delete`}),s(!1),t())},handleArchive:e=>{let n=1!==e.is_archived;o.submit({archived:String(n)},{method:"POST",action:`/api/sessions/${e.id}/archive`}),t()},handleRename:async(e,n)=>{try{let t=new FormData;if(t.set("name",n),!(await fetch(`/api/sessions/${encodeURIComponent(String(e.id))}/rename`,{method:"POST",body:t})).ok)return}catch{return}window.dispatchEvent(new CustomEvent("omp:session-renamed",{detail:{sessionId:String(e.id),title:n}})),t()}}}n.d(t,{C:()=>s})},X(e,t,n){var r=n("H");async function i(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function s(){let[e,t]=(0,r.J0)(void 0),[n,s]=(0,r.J0)("idle"),a=(0,r.li)(!0),l=(0,r.li)(null);(0,r.vJ)(()=>(a.current=!0,()=>{a.current=!1,l.current?.abort(),l.current=null}),[]);let o=(0,r.hb)(async(e,n,r)=>{l.current?.abort();let o=new AbortController;l.current=o,s(r);try{let r=await fetch(e,{...n,signal:o.signal}),s=await i(r);a.current&&l.current===o&&t(s)}catch{}finally{a.current&&l.current===o&&(l.current=null,s("idle"))}},[]);return{data:e,state:n,load:(0,r.hb)(e=>o(e,{method:"GET"},"loading"),[o]),submit:(0,r.hb)((e,t)=>o(t.action,{method:(t.method??"POST").toUpperCase(),body:function(e){if(e instanceof FormData)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t}(e),headers:e instanceof FormData?void 0:{"content-type":"application/x-www-form-urlencoded"}},"submitting"),[o])}}n.d(t,{L:()=>s})},s(e,t,n){var r=n("G");let i=new Set,s="u"<typeof window?"":window.location.search;function a(){for(let e of i)e()}function l(e){return i.add(e),()=>i.delete(e)}function o(e){if("string"==typeof e)return e.startsWith("?")?e:`?${e}`;if(e instanceof URLSearchParams)return e.toString()?`?${e.toString()}`:"";let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t.toString()?`?${t.toString()}`:""}function c(){return s}function d(){let e=(0,r.rz)(l,c),t=(0,r.hb)((e,t)=>{var n;let r=(n=new URLSearchParams(s),"function"==typeof e?o(e(new URLSearchParams(n))):o(e)),i=`${window.location.pathname}${r}${window.location.hash}`;t?.replace?window.history.replaceState(null,"",i):window.history.pushState(null,"",i),s=r,a()},[]);return[new URLSearchParams(e),t]}"u">typeof window&&window.addEventListener("popstate",function(){let e="u"<typeof window?"":window.location.search;e!==s&&(s=e,a())}),n.d(t,{o:()=>d})},l(e,t,n){var r=n("j"),i=n("v"),s=n("H"),a=n("G"),l=n("s");function o(e,t,n){return Math.min(Math.max(e,t),n)}function c(e,t){return"number"==typeof e?e:"string"==typeof e&&parseFloat(e)||t}let d=(0,a.q6)(null);function u(e){let{orientation:t,id:n,groupRef:i,onLayoutChanged:l,className:c,children:u}=e,p=(0,s.li)(new Map),m=(0,s.li)(l??null);m.current=l??null;let h=(0,a.Kr)(()=>({orientation:t,panels:p,onLayoutChanged:m}),[t]);return(0,a.vJ)(()=>{if(i)return i.current={setLayout:e=>{for(let[t,n]of Object.entries(e)){let e=p.current.get(t);e&&!e.isFiller&&"number"==typeof n&&e.setSize(o(n,e.minSize,e.maxSize))}m.current?.((()=>{let e={};for(let[t,n]of p.current){let r=n.getSize();null!=r&&(e[t]=r)}return e})(),{isUserInteraction:!1})}},()=>{i.current=null}},[i]),(0,r.Y)(d.Provider,{value:h,children:(0,r.Y)("div",{"data-panel-group":"","data-panel-group-id":n,className:c,style:{display:"flex",flex:"1 1 0%",flexDirection:"horizontal"===t?"row":"column",minWidth:0,minHeight:0},children:u})})}function p(e){let{id:t,panelRef:n,defaultSize:i,minSize:s=0,maxSize:l,filler:u=!1,className:p,style:m,children:h}=e,f=(0,a.NT)(d);if(!f)throw Error(`<Panel id="${t}"> must be rendered inside a <Group>`);let{orientation:x,panels:g}=f,b=c(s,0),v=null!=l?c(l,Number.MAX_SAFE_INTEGER):Number.MAX_SAFE_INTEGER,k=(0,a.li)(null),[y,w]=(0,a.J0)(()=>u?null:o(c(i,b),b,v)),N=(0,a.li)(y);N.current=y,(0,a.vJ)(()=>(g.current.set(t,{id:t,isFiller:u,minSize:b,maxSize:v,setSize:e=>w(e),getSize:()=>N.current}),()=>{g.current.delete(t)}),[t]),(0,a.vJ)(()=>{let e=g.current.get(t);e&&(e.minSize=b,e.maxSize=v)}),(0,a.vJ)(()=>{if(n)return n.current={resize:e=>{w(o(e,b,v))},getSize:()=>{let e=N.current;return null!=e?{inPixels:e}:null}},()=>{n.current=null}},[n,b,v]);let Y=u?{flex:"1 1 0%",minWidth:"horizontal"===x?b:0,minHeight:"horizontal"===x?0:b,overflow:"hidden",position:"relative"}:{flex:"0 1 auto",width:"horizontal"===x?y??void 0:void 0,height:"horizontal"===x?void 0:y??void 0,minWidth:"horizontal"===x?b:void 0,minHeight:"horizontal"===x?void 0:b,maxWidth:null!=l?v:void 0,overflow:"hidden",position:"relative"};return(0,r.Y)("div",{ref:k,"data-panel":"","data-panel-id":t,className:p,style:{...Y,...m},children:h})}function m(e){let{className:t,style:n,children:i}=e,s=(0,a.NT)(d),[l,c]=(0,a.J0)(!1),u=(0,a.li)(null),p=(0,a.li)(null);if((0,a.vJ)(()=>()=>p.current?.(),[]),!s)throw Error("<Separator> must be rendered inside a <Group>");let{orientation:m,panels:h,onLayoutChanged:f}=s;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{ref:u,"data-separator":"",role:"separator","aria-orientation":"horizontal"===m?"vertical":"horizontal",className:t,style:n,onPointerDown:e=>{let t=u.current;if(!t||0!==e.button)return;let n=t.previousElementSibling,r=t.nextElementSibling,i=n?.getAttribute("data-panel-id"),s=r?.getAttribute("data-panel-id"),a=i?h.current.get(i):void 0,l=s?h.current.get(s):void 0;if(!a||!l||!n||!r)return;e.preventDefault(),c(!0);let d="horizontal"===m?e.clientX:e.clientY,x=e=>"horizontal"===m?e.getBoundingClientRect().width:e.getBoundingClientRect().height,g=x(n),b=x(r),v=e=>{var t,n;let r="horizontal"===m?e.clientX:e.clientY,i=(t={size:g,min:a.minSize,max:a.maxSize},n={size:b,min:l.minSize,max:l.maxSize},o(r-d,Math.max(t.min-t.size,n.size-n.max),Math.min(t.max-t.size,n.size-n.min)));a.setSize(o(g+i,a.minSize,a.maxSize)),l.isFiller||l.setSize(o(b-i,l.minSize,l.maxSize))},k=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),p.current=null,c(!1);let e={};for(let[t,n]of h.current){let r=n.getSize();null!=r&&(e[t]=r)}f.current?.(e,{isUserInteraction:!0})},y=()=>k();window.addEventListener("pointermove",v),window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),p.current=k},onDragStart:e=>e.preventDefault(),children:i}),l&&(0,r.Y)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"horizontal"===m?"col-resize":"row-resize"}})]})}var h=n("g"),f=n("r");function x(e){let{onNewSession:t}=e;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"h-12 flex-shrink-0 flex items-center px-4 border-b border-ink/10 titlebar-drag-region select-none",style:{paddingLeft:"max(1rem, env(titlebar-area-x, 0px))"},children:(0,r.FD)("span",{className:"font-bold text-sm tracking-tight flex items-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]})}),(0,r.Y)("div",{className:"px-3 pt-3 titlebar-no-drag",children:(0,r.FD)("button",{onClick:t,className:"w-full flex items-center justify-center space-x-2 py-2 bg-ink text-canvas rounded text-xs font-semibold hover:bg-ink/90 transition-colors cursor-pointer",children:[(0,r.Y)(f.A,{size:14}),(0,r.Y)("span",{children:"New Session"})]})})]})}var g=n("D"),b=n("O"),v=n("n"),k=n("t3"),y=n("p7"),w=n("Sj"),N=n("x"),Y=n("S"),D=n("E");function F(e){let{isSearchVisible:t,searchQuery:n,showArchived:i,optionsOpen:s,sortOption:a,onToggleSearch:l,onSearchChange:o,onToggleArchived:c,onHideArchived:d,onToggleOptions:u,onCloseOptions:p,onSortChange:m,onNewWorkspace:h,onScheduler:f,onRefresh:x,onClose:F}=e;return(0,r.FD)("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between px-1 text-ink/60",children:[(0,r.FD)("div",{className:"flex space-x-3 items-center",children:[(0,r.Y)(g.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:h}),(0,r.Y)(b.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:f}),(0,r.Y)("span",{title:"Refresh sessions",onClick:x,className:"inline-flex cursor-pointer",children:(0,r.Y)(v.A,{size:14,className:"hover:text-ink"})})]}),(0,r.FD)("div",{className:"flex space-x-3 items-center relative",children:[(0,r.Y)(k.A,{size:14,className:`cursor-pointer transition-colors ${t?"text-ink":"hover:text-ink"}`,onClick:l}),(0,r.Y)("span",{title:i?"Hide Archive":"Show Archive",onClick:c,className:"inline-flex cursor-pointer",children:(0,r.Y)(y.A,{size:14,className:`transition-colors ${i?"text-ink":"hover:text-ink"}`})}),(0,r.FD)("div",{className:"relative",children:[(0,r.Y)(w.A,{size:14,className:`cursor-pointer transition-colors ${s?"text-ink":"hover:text-ink"}`,onClick:u}),s&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",onMouseLeave:p,children:(0,r.Y)(D.i,{variant:"desktop",sortOption:a,onSortChange:m})})]}),(0,r.Y)(N.A,{size:14,className:"hover:text-ink cursor-pointer ml-1",onClick:F})]})]}),t&&(0,r.Y)("div",{className:"pt-1",children:(0,r.Y)("input",{type:"text",placeholder:"Search workspaces & sessions...",value:n,onChange:e=>o(e.currentTarget.value),autoFocus:!0,className:"w-full bg-ink/5 border border-ink/10 rounded px-2.5 py-1.5 outline-none focus:border-ink/30 text-xs text-ink placeholder-ink/40 transition-colors"})}),i&&(0,r.FD)("div",{className:"flex items-center justify-between bg-amber-500/10 border border-amber-500/20 text-amber-900 rounded px-2.5 py-1.5 text-[10px] font-medium",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:[(0,r.Y)(y.A,{size:10}),(0,r.Y)("span",{children:"Showing Archived"})]}),(0,r.Y)("button",{className:"hover:text-amber-950",onClick:d,children:(0,r.Y)(Y.A,{size:10})})]})]})}var A=n("vB"),C=n("wU");function S(e){let{onSettings:t,onInfo:n,updateAvailable:i,onUpdateClick:s}=e;return(0,r.FD)("div",{className:"p-3 border-t border-ink/10 flex items-center justify-between text-ink/60 shrink-0",children:[(0,r.FD)("div",{className:"flex space-x-3",children:[(0,r.Y)(A.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:t}),(0,r.Y)(C.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:n})]}),i&&(0,r.Y)("button",{type:"button",onClick:s,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})}var T=n("a"),z=n("X"),$=n("oj"),j=n("NR"),L=n("U"),M=n("Go"),P=n("Nf"),E=n("WO"),R=n("t"),I=n("z"),O=n("b"),J=n("HZ"),_=n("P6");function W(e){let{title:t,isActive:n=!1,isArchived:i=!1,status:s,awaitingInput:a=!1,onClick:l,onArchive:o,onRename:c,expandable:d=!1,isExpanded:u=!1,hasSubagents:p=!1,onToggleExpand:m}=e,h=!!(d&&p&&m),{isEditing:f,draft:x,setDraft:g,inputRef:b,startRename:v,handleKeyDown:k,handleBlur:w}=(0,_.B)(t,c);return(0,r.FD)("div",{onClick:f?void 0:l,className:`group/item relative flex items-center w-full rounded-lg px-2 py-1.5 cursor-pointer text-xs transition-colors select-none ${n?"bg-ink/10 font-medium text-ink":"text-ink/75 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.FD)("span",{className:"relative w-4 h-4 shrink-0",children:[h&&m&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),m(e)},title:u?"Collapse subagents":"Expand subagents","aria-expanded":u,className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer text-ink/40 transition-opacity hover:text-ink ${u?"":"pointer-events-none opacity-0 group-hover/item:pointer-events-auto group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:u?(0,r.Y)(M.A,{size:13,className:"text-ink/70"}):(0,r.Y)(P.A,{size:13})}),(a||s)&&!(h&&u)&&(0,r.Y)("span",{className:`absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${h?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:a?(0,r.Y)(E.A,{size:12,className:"animate-pulse text-ink/80"}):"stream"===s?(0,r.Y)(R.A,{size:12,className:"animate-spin"}):(0,r.Y)(I.A,{size:12})})]}),(0,r.Y)("span",{className:"w-2 shrink-0"}),f?(0,r.Y)("input",{ref:b,autoFocus:!0,value:x,onChange:e=>g(e.currentTarget.value),onClick:e=>e.stopPropagation(),onKeyDown:k,onBlur:w,className:"flex-1 min-w-0 bg-paper border border-ink/25 rounded px-1 py-0.5 text-xs text-ink outline-none focus:border-ink/50"}):(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:t.charAt(0).toUpperCase()+t.slice(1)}),!f&&(c||o)&&(0,r.FD)("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2 flex items-center gap-0.5 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[c&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),v()},title:"Rename session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:(0,r.Y)(O.A,{size:12})}),o&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),o()},title:i?"Unarchive session":"Archive session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:i?(0,r.Y)(J.A,{size:12}):(0,r.Y)(y.A,{size:12})})]})]})}var K=n("Uo"),U=n("oS"),B=n("B"),q=n("T");let H={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function G(e){let{sessionId:t,isActiveSession:n}=e,[i]=(0,l.o)(),a=i.get("subagent"),[o,c]=(0,s.J0)([]),[d,u]=(0,s.J0)(!1);(0,s.vJ)(()=>{let e=!1,n=String(t);return c([]),u(!0),(0,B.wv)(n).then(t=>{if(e||!t)return;let n=t.map(B.Nh);c(e=>(0,q.j8)(e,n))}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t]),(0,s.vJ)(()=>{if(!n)return;let e=!1,r=String(t),i=Date.now(),s=e=>{let t=e.detail;return t&&t.sessionId===r?t:null},a=e=>{let t=(0,q.bH)(s(e)?.payload);t&&c(e=>(0,q.j8)(e,[t]))},l=e=>{let t=function(e){let t=(0,q.mq)(e);if(!(0,U.u)(e)||!(0,U.u)(e.progress))return t;let n=(0,q.mq)(e.progress);return n?{...n,id:n.id??t?.id,index:n.index??t?.index}:t}(s(e)?.payload);t&&c(e=>e.map(e=>{if(void 0!==t.id){if(e.id!==t.id)return e}else if(void 0===t.index||t.index<0||e.index!==t.index)return e;let n=t.status&&"started"===e.status?H[t.status]??e.status:e.status;return{...e,status:n,progress:{...e.progress,...t},lastUpdate:Date.now()}}))};return window.addEventListener("subagent_lifecycle",a),window.addEventListener("subagent_progress",l),fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then(e=>e.ok?e.json():null).then(t=>{if(e||!(0,U.u)(t))return;let n="data"in t?t.data:t;c(e=>(0,q.j8)(e,(0,q.vG)(n),i))}).catch(()=>{}),()=>{e=!0,window.removeEventListener("subagent_lifecycle",a),window.removeEventListener("subagent_progress",l)}},[n,t]);let p=d?"Loading subagents…":0===o.length?"No subagent activity":null;return(0,r.Y)("div",{className:"pl-6 pr-0 space-y-0.5 py-0.5",children:p?(0,r.FD)("div",{className:"px-2 py-1 text-xs italic text-ink/40 flex items-center",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate",children:p})]}):o.map(e=>{let i=e.task??e.description??e.assignment??e.agent??"",s=e.id===a;return(0,r.FD)("button",{type:"button",title:i,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:String(t),subagent:e}})),className:`w-full flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${s?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:(0,r.Y)(K.l,{status:e.status,live:n&&"started"===e.status,size:11})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:i})]},e.id)})})}var V=n("C4"),Z=n("So");let Q="omp_sidebar_expanded_sessions";var X=n("A"),ee=n("A9");function et(e){let{folder:t,activeSessionId:n,onSelectSession:i,onNewSessionForFolder:a,forceExpanded:o=!1,showArchived:c=!1,sessionStatus:d={}}=e,[u,p]=(0,s.J0)(t.isExpanded||!1),[m,h]=(0,s.J0)(!1),{visibleCount:x,showMore:g}=(0,j.y)(),[b]=(0,l.o)(),v=b.get("subagent"),k=b.get("sessionId"),[y,N]=(0,s.J0)(()=>new Set);(0,s.vJ)(()=>{let e,t=Array.isArray(e=(0,Z.BF)(Q))?new Set(e.filter(e=>"string"==typeof e)):new Set;t&&t.size>0&&N(t)},[]),(0,s.vJ)(()=>{"boolean"==typeof t.isExpanded&&p(t.isExpanded)},[t.isExpanded]),(0,s.vJ)(()=>{v&&k&&N(e=>{if(e.has(k))return e;let t=new Set(e);return t.add(k),t})},[v,k]);let Y=(0,s.li)(null),{refresh:D}=(0,ee.k)(),F=(0,z.L)(),{confirmDelete:A,requestDelete:C,cancelDelete:S,handlePin:M,handleDelete:P,handleArchive:E,handleRename:R}=(0,L.C)(t,D);(0,s.vJ)(()=>{F.data?.success&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[F.data]),(0,$.W)(Y,()=>{h(!1),S()});let I=t.sessions,O=(0,X.x)(t.icon),J=(I||[]).filter(e=>c?1===e.is_archived:1!==e.is_archived),_=J.slice(0,x),K=J.length>x;return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.FD)("div",{className:"group flex items-center justify-between h-7 text-xs font-semibold text-ink px-2 hover:bg-ink/5 rounded-md transition-colors select-none",children:[(0,r.FD)("div",{className:"flex-1 h-full flex items-center cursor-pointer min-w-0",onClick:()=>{let e=!u;p(e),"number"==typeof t.id&&F.submit({isExpanded:String(e)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:t.customIconUrl?(0,r.Y)("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain shrink-0",referrerPolicy:"no-referrer"}):(0,r.Y)(O,{size:15,className:"text-ink/75",style:{color:t.accentColor||void 0}})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),t.isPinned&&(0,r.Y)(T.A,{size:11,className:"text-ink/60 shrink-0 mr-1.5"}),(0,r.Y)("span",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})]}),(0,r.FD)("div",{className:`items-center space-x-0.5 pl-1 ${m?"flex":"hidden group-hover:flex"}`,children:[(0,r.Y)("button",{type:"button",title:"New Session",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),a(t.id)},children:(0,r.Y)(f.A,{size:12})}),(0,r.FD)("div",{className:"relative flex items-center",ref:Y,children:[(0,r.Y)("button",{type:"button",title:"Workspace Options",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),h(!m)},children:(0,r.Y)(w.A,{size:12})}),m&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 text-xs",children:(0,r.Y)(V.t,{variant:"desktop",isPinned:t.isPinned,confirmDelete:A,onPin:()=>{M(),h(!1)},onDelete:()=>{P(),h(!1)},onRequestDelete:C,onCancelDelete:S})})]})]})]}),(o||u)&&(0,r.FD)("div",{className:"space-y-0.5",children:[_.map(e=>{let t=String(e.id),s=null!==n?String(n)===t:1===e.is_active,a=s&&k===t&&!!v,l=null!==n&&t===String(n),o=!!e.hasSubagents,c=o&&y.has(t);return(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.Y)(W,{title:e.title,isActive:s&&!a,isArchived:1===e.is_archived,status:d[t],awaitingInput:!!e.awaitingInput,onClick:()=>i(e.id),onArchive:()=>E(e),onRename:String(e.id).startsWith("new-")?void 0:t=>void R(e,t),expandable:o,hasSubagents:o,isExpanded:c,onToggleExpand:()=>{N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),(0,Z.cz)(Q,[...n].slice(-50)),n})}}),o&&c&&(0,r.Y)(G,{sessionId:e.id,isActiveSession:l})]},e.id)}),K&&!o&&(0,r.FD)("button",{type:"button",onClick:g,className:"flex items-center text-xs text-ink/45 hover:text-ink/80 w-full text-left py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"truncate leading-snug",children:"Show more sessions"})]}),0===J.length&&(0,r.Y)("div",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:c?"No archived sessions.":"No sessions."})]})]})}var en=n("jo");function er(e){let{folders:t,activeSessionId:n,searchQuery:i,showArchived:s,sessionStatus:a,isScrolling:l,onScroll:o,onSelectSession:c,onNewSessionForFolder:d}=e;return(0,r.Y)("div",{onScroll:o,className:`flex-1 scrollbar-overlay-container p-2 space-y-4 ${(0,en.p)(l)}`,children:0===t.length?(0,r.Y)("div",{className:"text-center py-8 text-xs text-ink/40",children:i?"No results found.":"No workspaces available."}):t.map(e=>(0,r.Y)(et,{folder:e,activeSessionId:n,onSelectSession:c,onNewSessionForFolder:d,forceExpanded:!!i,showArchived:s,sessionStatus:a},e.id))})}let ei=[3,2];function es(){return(0,r.Y)("div",{className:"flex-1 p-2 space-y-4","aria-hidden":"true",children:ei.map((e,t)=>(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,r.Y)("span",{className:"w-3.5 h-3.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded px-2 py-1.5",children:[(0,r.Y)("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-t%3*12}%`}})]},t))]},t))})}var ea=n("wu"),el=n("wm"),eo=n("oZ"),ec=n("DO"),ed=n("z4");function eu(e){let{className:t="",onClose:n,appSettings:i={}}=e,{folders:a,initializing:o,refresh:c,activeSessionId:d,sessionParam:u,searchQuery:p,setSearchQuery:m,showArchived:f,setShowArchived:g,optionsOpen:b,setOptionsOpen:v,sortOption:k,handleSortChange:y,processedFolders:w,sessionStatus:N,handleSelectSession:Y}=(0,ed.K)(i,{includePendingSessions:!0}),[,D]=(0,l.o)(),[A,C]=(0,s.J0)(!1),[T,z]=(0,s.J0)(!1),[$,j]=(0,s.J0)(!1),[L,M]=(0,s.J0)(!1),P=(0,ec.M)(),{toasts:E,pushToast:R,dismissToast:I}=(0,eo.Y)(),[O,J]=(0,s.J0)(!1),{isScrolling:_,handleScroll:W}=(0,en.K)(),K=e=>{let t=(0,el.l)(a,u,e);t&&(0,el.r)(t,i.omp_access_mode)};return(0,r.FD)(r.FK,{children:[(0,r.FD)("aside",{className:`flex flex-col bg-paper h-full ${t}`,children:[(0,r.Y)(x,{onNewSession:()=>{K(),D(e=>{let t=e.get("sessionId"),n=new URLSearchParams(e);if(n.set("sessionId",`new-${Date.now()}`),t){let e=a.find(e=>e.sessions?.some(e=>String(e.id)===String(t)));e&&n.set("folderId",e.id.toString())}else n.delete("folderId");return n},{replace:!0})}}),(0,r.Y)(F,{isSearchVisible:O,searchQuery:p,showArchived:f,optionsOpen:b,sortOption:k,onToggleSearch:()=>J(!O),onSearchChange:m,onToggleArchived:()=>g(!f),onHideArchived:()=>g(!1),onToggleOptions:()=>v(!b),onCloseOptions:()=>v(!1),onSortChange:y,onNewWorkspace:()=>j(!0),onScheduler:()=>M(!0),onRefresh:c,onClose:n}),o?(0,r.Y)(es,{}):(0,r.Y)(er,{folders:w,activeSessionId:d,searchQuery:p,showArchived:f,sessionStatus:N,isScrolling:_,onScroll:W,onSelectSession:Y,onNewSessionForFolder:e=>{K(e),D(t=>{let n=new URLSearchParams(t);return n.set("sessionId",`new-${Date.now()}`),n.set("folderId",e.toString()),n},{replace:!0})}}),(0,r.Y)(S,{onSettings:()=>C(!0),onInfo:()=>z(!0),updateAvailable:P.hasUpdate,onUpdateClick:()=>{z(!0),P.check()}})]}),(0,r.Y)(h.bB,{isOpen:A,onClose:()=>C(!1),appSettings:i}),(0,r.Y)(h.VT,{isOpen:T,onClose:()=>z(!1),updates:P,onToast:R}),(0,r.Y)(h.xV,{isOpen:$,onClose:()=>j(!1),onCreate:async e=>{let{name:t,path:n}=e,r=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,path:n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i.success)throw Error(i.error||`HTTP ${r.status}`);window.location.reload()}}),(0,r.Y)(h.Lo,{isOpen:L,onClose:()=>M(!1)}),(0,r.Y)(ea.y,{toasts:E,onDismiss:I})]})}var ep=n("ET"),em=n("u"),eh=n("zI"),ef=n("Gb"),ex=n("FL"),eg=n("As"),eb=n("NO"),ev=n("f"),ek=n("b5"),ey=n("Pf"),ew=n("se"),eN=n("tC");let eY=()=>{let{isInstallable:e,isInstalled:t,isIOS:n,install:i}=function(){let[e,t]=(0,s.J0)(null),[n,r]=(0,s.J0)(!1),[i,a]=(0,s.J0)(!1);(0,s.vJ)(()=>{r(window.matchMedia("(display-mode: standalone)").matches||!0===window.navigator.standalone);let e=window.navigator.userAgent.toLowerCase();a(/iphone|ipad|ipod/.test(e));let n=e=>{e.preventDefault(),t(e)},i=()=>{r(!0),t(null)};return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",i),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",i)}},[]);let l=async()=>{if(!e)return!1;await e.prompt();let{outcome:n}=await e.userChoice;return"accepted"===n&&(r(!0),t(null),!0)};return{isInstallable:!!e,isInstalled:n,isIOS:i,install:l}}(),[a,l]=(0,s.J0)(!1);return t?null:e?(0,r.Y)("button",{onClick:i,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install OMPChamber",children:(0,r.Y)(eN.A,{size:16})}):n?(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{onClick:()=>l(!0),className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install on iOS",children:(0,r.Y)(eN.A,{size:16})}),a&&(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20 p-4",children:(0,r.FD)("div",{className:"w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink",children:[(0,r.Y)("h3",{className:"text-sm font-semibold",children:"Install on iPhone / iPad"}),(0,r.FD)("p",{className:"mt-2 text-xs opacity-80",children:["1. Tap the ",(0,r.Y)("strong",{children:"Share"})," button in Safari toolbar.",(0,r.Y)("br",{}),"2. Scroll down and tap ",(0,r.Y)("strong",{children:"Add to Home Screen"}),"."]}),(0,r.Y)("button",{onClick:()=>l(!1),className:"mt-4 w-full rounded bg-ink text-canvas py-2 text-xs font-semibold hover:bg-ink/90",children:"Close"})]})})]}):null};var eD=n("R2");function eF(e){let{sessionTitle:t,showLeftPanel:n,showEditor:i,showRightPanel:s,streamStatus:a,onSwitchToMobile:l,onToggleEditor:o,onToggleRightPanel:c}=e;return(0,r.FD)("header",{className:"h-12 flex-shrink-0 border-b border-ink/10 bg-paper flex items-center justify-between pr-4 z-20 titlebar-drag-region select-none",style:{paddingLeft:n?void 0:"max(1rem, env(titlebar-area-x, 0px))",paddingRight:"max(1rem, calc(100vw - env(titlebar-area-width, 100vw)))"},children:[(0,r.FD)("div",{className:"flex items-center space-x-2 px-4 min-w-0",children:[!n&&(0,r.FD)(r.FK,{children:[(0,r.FD)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center flex-shrink-0",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]}),t&&(0,r.Y)("span",{className:"text-ink/30 text-xs select-none flex-shrink-0",children:"/"})]}),t&&(0,r.FD)("div",{className:"flex items-center space-x-2 titlebar-no-drag",children:[(0,r.Y)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center",children:(0,r.Y)("span",{className:"font-semibold text-xs text-ink truncate",children:t.charAt(0).toUpperCase()+t.slice(1)})}),(0,r.Y)(w.A,{size:14,className:"text-ink/40 hover:text-ink cursor-pointer flex-shrink-0"})]})]}),(0,r.Y)("div",{className:"flex items-center space-x-3 titlebar-no-drag",children:(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)(eD.c,{status:a}),l&&(0,r.Y)("button",{type:"button",onClick:l,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer",title:"Switch to Mobile View",children:(0,r.Y)(ev.A,{size:16})}),(0,r.Y)(eY,{}),(0,r.Y)("button",{type:"button",onClick:o,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${i?"text-ink":"text-ink/40"}`,title:"Toggle Editor Layout",children:(0,r.Y)(ek.A,{size:16})}),(0,r.Y)("button",{type:"button",onClick:c,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${s?"text-ink":"text-ink/40"}`,title:"Toggle Right Panel",children:s?(0,r.Y)(ey.A,{size:16}):(0,r.Y)(ew.A,{size:16})})]})})]})}var eA=n("d"),eC=n("nG"),eS=n("oE"),eT=n("Asb"),ez=n("vZ"),e$=n("N"),ej=n("Oj"),eL=n("lW"),eM=n("SJ"),eP=n("so");let eE={context:{title:"Context & Telemetry",icon:(0,r.Y)(eS.A,{size:16})},files:{title:"Files",icon:(0,r.Y)(eT.A,{size:16})},search:{title:"Search",icon:(0,r.Y)(k.A,{size:16})},git:{title:"Source Control",icon:(0,r.Y)(ez.A,{size:16})},terminal:{title:"Terminal (Bun)",icon:(0,r.Y)(e$.A,{size:16})},"user-browser":{title:"Browser (Anda)",icon:(0,r.Y)(ej.A,{size:16})},browser:{title:"Browser Agent",icon:(0,r.Y)(eL.A,{size:16})},usage:{title:"Usage",icon:(0,r.Y)(eM.A,{size:16})}};function eR(e){let{activePanel:t,onChangePanel:n,isPanelOpen:i,hasActiveContext:s,activeProjectPath:a,refreshKey:l}=e,{changes:o}=(0,eP.e)(a??void 0,".",l,s,15e3),c=o.length>0;return(0,r.FD)("nav",{className:"w-12 flex-shrink-0 border-l border-ink/10 bg-paper flex flex-col items-center py-3 space-y-2 z-10",children:[(0,r.Y)("div",{className:"flex flex-col items-center space-y-1 w-full",children:ep.G7.map(e=>{let s=i&&t===e;return(0,r.FD)("button",{className:`relative w-full h-10 flex items-center justify-center transition-colors border-l-2 ${s?"text-ink border-ink bg-ink/5":"text-ink/40 border-transparent hover:text-ink hover:bg-ink/5"}`,onClick:()=>n(e),title:eE[e].title,children:[eE[e].icon,"git"===e&&c&&(0,r.Y)("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-info",title:"Ada perubahan git"})]},e)})}),(0,r.Y)("div",{className:"flex-1"})]})}function eI(){return(0,r.Y)(m,{className:"relative w-1 outline-none group flex justify-center cursor-col-resize z-10",children:(0,r.Y)("div",{className:"h-full w-[1px] bg-ink/10 group-hover:bg-ink/40 group-active:bg-ink/60 group-hover:w-0.5 transition-all"})})}let eO={left:268,editor:600,diff:720};function eJ(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):void 0}let e_=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("nam"),n.e("q")]).then(n.bind(n,"o3")).then(e=>({default:e.Editor})));function eW(e){let{children:t}=e;return(0,r.Y)(a.tY,{fallback:(0,r.Y)("div",{className:"w-full h-full flex items-center justify-center text-ink/40 text-xs",children:"Loading…"}),children:t})}function eK(e){let{appSettings:t,showEditor:n,editorPanelRef:i,showRightPanel:a,activeRightPanel:l,rightPanelRef:o,panelWidths:c,editorWidthMode:d,hasActiveContext:m,activeProjectPath:h,openedFiles:f,activeFileId:x,refreshKey:g,onSetActiveFileId:b,onCloseFile:v,onOpenFile:k,onRefreshWorkspace:y,onChangeRightPanel:w,onToggleRightPanel:N,onSessionTitle:Y,onPanelWidths:D}=e;(0,s.li)(c).current=c;let F=(0,s.Kr)(()=>({}),[]),A=(0,s.Kr)(()=>ep.G7.map(e=>({view:e,Comp:(0,eC.SU)(F,e)})),[F]);return(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-layout",onLayoutChanged:()=>{let e,t,n;D((e={},t=i.current?.getSize()?.inPixels,n=o.current?.getSize()?.inPixels,null!=t&&t>0&&(e[d]=Math.round(t)),null!=n&&n>0&&(e.right={[l]:Math.round(n)}),e))},children:[(0,r.Y)(p,{id:"center-panel",filler:!0,minSize:420,children:(0,r.Y)(eA.E,{className:"w-full h-full",appSettings:t,onSessionTitle:Y})}),n&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eI,{}),(0,r.Y)(p,{panelRef:i,id:"editor-panel",defaultSize:c[d]??eO[d],minSize:300,maxSize:1200,children:(0,r.Y)(eW,{children:(0,r.Y)(e_,{className:"w-full h-full",openedFiles:f,activeFileId:x,onSelectFile:b,onCloseFile:v,refreshKey:g,onFileSaved:y})})})]}),a&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eI,{}),(0,r.Y)(p,{panelRef:o,id:"right-panel",defaultSize:c.right?.[l]??ep.qv[l],minSize:ep.lw[l],maxSize:1200,collapsible:!0,children:(0,r.Y)(eW,{children:A.map(e=>{let{view:t,Comp:n}=e,i=l===t;return(0,r.Y)("div",{className:i?"w-full h-full":"hidden",children:(0,r.Y)(n,{className:"w-full h-full",enabled:"terminal"===t?m:m&&i,active:i,refreshKey:g,rootPath:h??void 0,onRefresh:y,onOpenFile:k,onClose:N})},t)})})})]})]}),(0,r.Y)(eR,{activePanel:l,onChangePanel:w,isPanelOpen:a,hasActiveContext:m,activeProjectPath:h,refreshKey:g})]})}var eU=n("FE");function eB(e,t){null!=t&&e.current?.resize(t)}function eq(e){let{sessionId:t,onSwitchToMobile:n,appSettings:i={}}=e,{folders:a}=(0,ee.k)(),[o,c]=(0,ex.bL)("layout.showRightPanel",i.showRightPanel??!0),[d,m]=(0,ex.bL)("layout.activeRightPanel",i.activeRightPanel??"files"),[h,f]=(0,s.J0)(i.showLeftPanel??!0),{widths:x,widthsRef:g,commitWidths:b}=function(e,t){let[n,r]=(0,s.J0)(()=>(function(e,t){if(!e||"object"!=typeof e)return{};let n={};for(let t of["left","editor","diff"]){let r=eJ(e[t]);void 0!==r&&(n[t]=r)}let r={};if(e.right&&"object"==typeof e.right)for(let[t,n]of Object.entries(e.right)){if(!(0,ep.ls)(t))continue;let e=eJ(n);void 0!==e&&(r[t]=e)}else{let n=eJ(e.right);void 0!==n&&(r[t]=n)}return Object.keys(r).length>0&&(n.right=r),n})(e.desktopLayoutSizes,t)),i=(0,s.li)(n),a=(0,s.li)(void 0),l=(0,s.hb)(()=>{clearTimeout(a.current),a.current=void 0,(0,Z.cz)("desktopLayoutSizes",i.current)},[]),o=(0,s.hb)(e=>{var t;let n,s=(t=i.current,n={...t,...e},e.right&&(n.right={...t.right,...e.right}),n);i.current=s,r(s),clearTimeout(a.current),a.current=window.setTimeout(l,500)},[l]);return(0,s.vJ)(()=>()=>{void 0!==a.current&&l()},[l]),{widths:n,widthsRef:i,commitWidths:o}}(i,d),v=(0,s.li)(null),k=(0,s.li)(null),y=(0,s.li)(null),[w,N]=(0,s.J0)(i.userToggledEditor??null),[Y]=(0,l.o)(),D=Y.get("folderId"),F=(0,s.Kr)(()=>{let e=(0,ef.t)(a,t||"").folder;return e||(D?a.find(e=>String(e.id)===String(D))??null:null)},[a,t,D]),A=F?.project_path??null,C=!!F,{openedFiles:S,activeFileId:T,setActiveFileId:z,handleOpenFile:$,handleCloseFile:j}=function(e,t,n){let[r,i]=(0,ex.bL)("layout.openedFiles",[]),[a,l]=(0,ex.bL)("layout.activeFileId",null),o=(0,s.li)(void 0),{ready:c}=(0,eg.O)(),d=(0,s.li)(void 0);(0,s.vJ)(()=>{o.current===e||(o.current=e,c&&d.current!==e&&(d.current=e,i([]),l(null)))},[e,t,c,i,l]);let u=(0,s.hb)(t=>{let r={...t,root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===r.id||!e.isDiff&&e.path&&r.path&&e.path===r.path);return t?(l(t.id),e):[...e,r]}),l(r.id),n?.()},[e,n,i,l]),p=(0,s.hb)(t=>{let r=t.file.replace(/^\/+/,""),s=r.split("/").pop()||r,a=!!t.staged,o=`diff-${a?"staged":"working"}-${r}`,c={id:o,name:`${s} (Diff)`,path:r,isDiff:!0,diffStatus:t.status||"M",diffStaged:a,repo:t.repo||".",root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===o||e.isDiff&&e.path===r&&e.diffStaged===a);return t?(l(t.id),e):[...e,c]}),l(o),n?.()},[e,n,i,l]),m=(0,s.hb)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return a===e&&l(n.length>0?n[n.length-1].id:null),n})},[a,i,l]);return(0,eb.sY)("omp:open-file",e=>{if(!e.detail||!e.detail.path)return;let t=e.detail.path.replace(/^\/+/,""),n=e.detail.name||t.split("/").pop()||"file",r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e)|0;u({id:e.detail.id||Math.abs(r)||Date.now(),name:n,path:t,content:e.detail.content})}),(0,eb.sY)("omp:open-diff",e=>{e.detail&&e.detail.file&&p(e.detail)}),{openedFiles:r,activeFileId:a,setActiveFileId:l,handleOpenFile:u,handleOpenDiff:p,handleCloseFile:m}}(A,t||"",(0,s.hb)(()=>{N(!0),P("userToggledEditor",!0)},[])),L=S.length>0&&(w??!0),M=(0,s.Kr)(()=>S.find(e=>String(e.id)===String(T))?.isDiff?"diff":"editor",[S,T]),P=(e,t)=>{(0,Z.cz)(e,t)};(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{let e=g.current;e&&eB(y,e.left)});return()=>cancelAnimationFrame(e)},[h,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eB(k,g.current?.right?.[d]??ep.qv[d])});return()=>cancelAnimationFrame(e)},[o,d,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eB(v,g.current?.[M]??eO[M])});return()=>cancelAnimationFrame(e)},[L,M,g]);let[E,R]=(0,s.J0)(!1),[I,O]=(0,s.J0)("appearance"),[J,_]=(0,s.J0)(!1),[W,K]=(0,s.J0)(0),[U,B]=(0,s.J0)(null),q=(0,eU.H)();(0,eb.MN)("keydown",e=>{(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),O("appearance"),_(!1),R(e=>!e))}),(0,eb.sY)("omp:open-settings",e=>{e.detail?.category?O(e.detail.category):O("appearance"),_(!!e.detail?.autoOpenAdd),R(!0)});let H=e=>{f(e),P("showLeftPanel",e)},G=()=>{let e=!o;c(e),P("showRightPanel",e)};return(0,r.FD)("div",{className:"flex flex-col h-screen w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas",children:[(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[!h&&(0,r.FD)("div",{className:"w-12 h-full bg-paper border-r border-ink/10 flex flex-col items-center py-3 flex-shrink-0 cursor-pointer hover:bg-ink/5 transition-colors titlebar-no-drag",style:{paddingTop:"max(0.75rem, env(titlebar-area-height, 0px))"},onClick:()=>H(!0),title:"Expand Sidebar",children:[(0,r.Y)(eh.A,{size:16,className:"text-ink/60"}),(0,r.Y)("div",{className:"w-[1px] flex-1 bg-ink/10 my-4"})]}),(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-main",onLayoutChanged:()=>{let e=y.current?.getSize()?.inPixels;null!=e&&e>0&&b({left:Math.round(e)})},children:[h&&(0,r.FD)(r.FK,{children:[(0,r.Y)(p,{panelRef:y,id:"left-panel",defaultSize:x.left??eO.left,minSize:200,maxSize:520,collapsible:!0,children:(0,r.Y)(eu,{className:"w-full h-full",onClose:()=>H(!1),appSettings:i})}),(0,r.Y)(eI,{})]}),(0,r.Y)(p,{id:"main-right-stack",filler:!0,minSize:0,children:(0,r.FD)("div",{className:"flex flex-col h-full",children:[(0,r.Y)(eF,{sessionTitle:U,showLeftPanel:h,showEditor:L,showRightPanel:o,streamStatus:q,onSwitchToMobile:n,onToggleEditor:()=>{let e=!L;N(e),P("userToggledEditor",e)},onToggleRightPanel:G}),(0,r.Y)(eK,{appSettings:i,showEditor:L,editorPanelRef:v,showRightPanel:o,activeRightPanel:d,rightPanelRef:k,panelWidths:x,editorWidthMode:M,hasActiveContext:C,activeProjectPath:A,openedFiles:S,activeFileId:T,refreshKey:W,onSetActiveFileId:z,onCloseFile:j,onOpenFile:$,onRefreshWorkspace:()=>K(e=>e+1),onChangeRightPanel:e=>{let t=o,n=d;d===e&&o?t=!1:(n=e,t=!0),c(t),m(n),(0,Z.cz)("showRightPanel",t),(0,Z.cz)("activeRightPanel",n)},onToggleRightPanel:G,onSessionTitle:B,onPanelWidths:b})]})})]})]}),(0,r.Y)(em.b,{isOpen:E,onClose:()=>{R(!1),_(!1)},initialCategory:I,autoOpenAddProvider:J,appSettings:i})]})}var eH=n("SS");function eG(e){let{sessionId:t,children:n}=e,i=t||"1",[a,l]=(0,s.J0)(!1),o=(0,s.li)(null);(0,s.vJ)(()=>{let e=o.current;if(o.current=i,e!==i){if((0,eH.Y1)(i),e&&e.startsWith("new-")&&!i.startsWith("new-")){(0,eH.vy)(e,i),l(!0);return}if(i.startsWith("new-")){(0,eH.l5)(i),l(!0);return}l(!1),(0,eH.D4)(e).then(()=>(0,eH.L6)(i)).then(()=>{o.current===i&&l(!0)})}},[i]);let c=(0,s.Kr)(()=>({sessionId:i,ready:a}),[i,a]);return(0,r.Y)(eg.b.Provider,{value:c,children:n})}let eV=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("nam"),n.e("g")]).then(n.bind(n,"Wh")).then(e=>({default:e.MobileLayoutWrapper})));var eZ=n("eh");let eQ=document.getElementById("app"),eX=window.__OMP_BOOTSTRAP__;(0,Z.x9)(eX?.appSettings),(0,eZ.iv)(),eQ&&(0,i.Qv)((0,r.Y)(function(e){let{initialIsMobile:t=!1,appSettings:n={}}=e,[i]=(0,l.o)(),o=i.get("sessionId")||"1",[c,d]=(0,s.J0)(t),u=(0,s.li)(!1);return((0,s.vJ)(()=>{let e=()=>{let e=window.innerWidth<768,t=window.matchMedia("(pointer: coarse)").matches,n=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),r=t&&window.innerHeight<550&&window.innerWidth<1024;return e||n||r};u.current||d(e());let t=()=>{u.current||d(e())};return window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[]),c)?(0,r.Y)(eG,{sessionId:o,children:(0,r.Y)(ee.O,{children:(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(eV,{onDesktopToggle:()=>{u.current=!0,d(!1)},appSettings:n})})})}):(0,r.Y)(eG,{sessionId:o,children:(0,r.Y)(ee.O,{children:(0,r.Y)(eq,{sessionId:o,onSwitchToMobile:()=>{u.current=!0,d(!0)},appSettings:n})})})},{initialIsMobile:eX?.initialIsMobile,appSettings:eX?.appSettings}),eQ)},Fb(e,t,n){let r="omp:browser-include-page";function i(e){"u">typeof window&&window.dispatchEvent(new CustomEvent(r,{detail:e}))}n.d(t,{q:()=>i},{j:r})},ns(e,t,n){let r="agent",i="command",s=new Map,a=new Map;async function l(e){let t=await fetch(e);if(!t.ok)throw Error(`GET ${e} failed: ${t.status}`);let n=await t.json();if(!n||"object"!=typeof n)throw Error(`GET ${e} returned malformed JSON`);return n}async function o(){let e=s.get(r);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(r);if(t)return t;let n=(async()=>{try{let e=(await l("/api/settings/agents")).agents.map(e=>({id:`agent-${e.name}`,name:e.name,description:e.description,kind:"agent",source:"agent",token:`@${e.name}`}));return s.set(r,{data:e,expiresAt:Date.now()+3e5}),e}finally{a.delete(r)}})();return a.set(r,n),n}async function c(e){let t,n=(t=e??"",`file::${t}`),r=s.get(n);if(r&&r.expiresAt>Date.now())return r.data;let i=a.get(n);if(i)return i;let o=(async()=>{try{let t=e?`?root=${encodeURIComponent(e)}`:"",r=await l(`/api/fs/list${t}`),i=(Array.isArray(r.files)?r.files:[]).map(e=>({id:`file-${e.path}`,name:e.path,description:"",kind:"file",source:"file",token:/\s/.test(e.path)?`@"file:${e.path}"`:`@file:${e.path}`,path:e.path}));return s.set(n,{data:i,expiresAt:Date.now()+3e5}),i}catch{return[]}finally{a.delete(n)}})();return a.set(n,o),o}async function d(){let e=s.get(i);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(i);if(t)return t;let n=(async()=>{try{let[e,t]=await Promise.all([l("/api/settings/commands"),l("/api/settings/skills")]),n=function(e,t){let n=[],r=new Set;for(let t of e){let e=t.name.toLowerCase();r.has(e)||(r.add(e),n.push({id:`command-${t.name}`,name:t.name,description:t.description,kind:"command",source:"command",token:`/${t.name}`}))}for(let e of t){let t=e.name.toLowerCase(),i=`skill:${t}`;r.has(t)||r.has(i)||(r.add(i),n.push({id:`skill-${e.name}`,name:e.name,description:e.description,kind:"command",source:"skill",token:`/skill:${e.name}`}))}return n}(e.commands,t.skills);return s.set(i,{data:n,expiresAt:Date.now()+3e5}),n}finally{a.delete(i)}})();return a.set(i,n),n}function u(e,t){return"mention"===e?Promise.all([o(),c(t??null)]).then(e=>{let[t,n]=e;return[...t,...n]}):d()}async function p(){try{return(await o()).map(e=>e.name)}catch{return[]}}function m(e){if(e){s.delete(e),a.delete(e);return}s.clear(),a.clear()}n.d(t,{O7:()=>p,SA:()=>m,bF:()=>u})},K(e,t,n){var r=n("oS"),i=n("zG");let s={edit:!0,write:!0,ast_edit:!0,bash:!0};function a(e){let t="string"==typeof e.toolName?e.toolName.toLowerCase():"",n=i.YT[t]??t;if(!s[n])return!1;let a=(0,r.u)(e.args)?e.args:{},l=(0,i.oJ)(a.path)??(0,i.oJ)(a.target);return!("write"===n&&"string"==typeof l&&l.startsWith("xd://"))}n.d(t,{Y:()=>a},{s:"omp:files-mutated"})},g0(e,t,n){var r=n("Kn");let i="omp:stream-status",s={transport:(0,r.ul)(),connected:!1};function a(){return s}function l(e){e.transport===s.transport&&e.connected===s.connected||(s=e,"u">typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:e})))}n.d(t,{aK:()=>a,dX:()=>l},{rt:i})},Kn(e,t,n){var r=n("So");function i(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/agent/${encodeURIComponent(e)}/ws`}function s(e){return`/api/agent/${encodeURIComponent(e)}/events`}function a(e){let t=(0,r.BF)("streamTransport",e);return"sse"===t||"websocket"===t?t:"websocket"}n.d(t,{_m:()=>s,qq:()=>i,ul:()=>a})},G1(e,t,n){function r(e,t){let n=function(e){let t=e.trim();if(!t)return null;let n="message",r=[];for(let e of t.split("\n"))!e.startsWith(":")&&(e.startsWith("event:")?n=e.replace(/^event:\s*/,"").trim():e.startsWith("data:")&&r.push(e.replace(/^data:\s*/,"")));return 0===r.length?null:{event:n,data:r.join("\n")}}(e);return!!n&&!0===t(n.event,n.data)}async function i(e,t,n){let i=e.body?.getReader();if(!i)return;let s=new TextDecoder("utf-8"),a="";try{for(;;){if(n?.aborted){try{await i.cancel()}catch{}return}let{done:e,value:l}=await i.read();if(e)break;let o=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=o.pop()??"",o))if(r(e,t))return}a&&r(a,t)}finally{try{i.releaseLock()}catch{}}}n.d(t,{o:()=>i})},zG(e,t,n){var r=n("oS"),i=n("e");function s(e){if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0}function a(e,t){for(let n of t){let t=e[n],r=s(t);if(r)return r;if(Array.isArray(t)){let e=t.find(e=>void 0!==s(e));if(void 0!==e)return s(e)}}}function l(e){return e.length<=72?e:`${e.slice(0,71)}…`}function o(e){if(e)return/^["'`]/.test(e)?e:`"${e}"`}function c(e,t){switch(e){case"read":case"write":case"edit":return a(t,["path","file","AbsolutePath","TargetFile"])??(0,i.f$)(t);case"ast_edit":return a(t,["paths","path"]);case"ast_grep":{let e=o(a(t,["pat"]));return e?`for ${e}`:void 0}case"bash":return a(t,["command","cmd","CommandLine"]);case"grep":{let e=a(t,["pattern"]),n=a(t,["path","paths"]);if(!e)return n;return n?`for ${o(e)} in ${n}`:`for ${o(e)}`}case"glob":return a(t,["path","pattern"]);case"web_search":{let e=o(a(t,["query"]));return e?`for ${e}`:void 0}case"task":let n,l,c,d;return n=s(t.name),l=(Array.isArray(t.tasks)?t.tasks:[]).find(r.u),c=n??(l?s(l.name):void 0),d=s(t.agent)??(l?s(l.agent):void 0),c&&d?`to ${c} (${d})`:c?`to ${c}`:d?`to ${d}`:void 0;case"hub":return[a(t,["op"]),a(t,["name"])].filter(Boolean).join(" ")||void 0;case"todo":{let e=a(t,["op"]);return e?`\xb7 ${e}`:void 0}case"eval":{let e=a(t,["language"]);return e?`in ${e}`:void 0}case"lsp":return[a(t,["action"]),a(t,["symbol","file"])].filter(Boolean).join(" ")||void 0;case"debug":return a(t,["action","program"]);case"github":return[a(t,["op"]),a(t,["repo","pr","query"])].filter(Boolean).join(" ")||void 0;case"ask":let u=(Array.isArray(t.questions)?t.questions:[]).find(r.u);if(u)return s(u.header)??s(u.question);return;case"checkpoint":return a(t,["goal"]);case"manage_skill":return a(t,["name"]);case"recall":return o(a(t,["query"]));case"reflect":{let e=o(a(t,["query"]));return e?`on ${e}`:void 0}case"security_scan":return a(t,["target_kind","include_paths"]);case"retain":let p;return(p=(Array.isArray(t.items)?t.items:[]).find(r.u))?o(s(p.content)):void 0;default:return a(t,["path","command","query","pattern","name","target","prose"])}}n.d(t,{Up:()=>a,oJ:()=>s,qL:()=>c,xv:()=>l},{K$:{read:"Reading",write:"Writing",edit:"Editing",ast_edit:"Rewriting AST",ast_grep:"Searching AST",bash:"Running",grep:"Searching",glob:"Finding",task:"Delegating",todo:"Updating plan",hub:"Hub",eval:"Running code",lsp:"Running LSP",debug:"Debugging",github:"GitHub",web_search:"Searching the web",ask:"Asking you",checkpoint:"Checkpointing",rewind:"Rewinding",context_notes:"Updating context notes",new_context:"Starting a fresh context",security_scan:"Scanning for vulnerabilities",manage_skill:"Updating skill",learn:"Recording a lesson",retain:"Retaining memory",recall:"Recalling memory",reflect:"Reflecting",think:"Thinking",yield:"Wrapping up",goal:"Tracking goal"},Qq:{lsp:"Running LSP",ast_edit:"Rewriting AST",ast_grep:"Searching AST",resolve:"Applying edit proposal",reject:"Discarding edit proposal",report_issue:"Reporting tool issue",debug:"Debugging",browser:"Driving the browser"},YT:{read_file:"read",view_file:"read",read_file_content:"read",edit_file:"edit",replace_file_content:"edit",multi_edit_file:"edit",write_to_file:"write",create_file:"write",search_fs:"grep",terminal:"bash",run_command:"bash"},n1:{thinking:"Thinking",writing:"Writing response"}})},pm(e,t,n){var r=n("U8");function i(e){return(0,r.Rk)(e)}n.d(t,{F:()=>i})},eh(e,t,n){n.d(t,{iv:()=>w,tn:()=>v,F:()=>D,nv:()=>N,LT:()=>A,Eu:()=>Y,sT:()=>F});var r=n("CU"),i=n("he"),s=n("h3"),a=n("g1");let l={typescript:()=>n.e("zn").then(n.bind(n,"tt")),tsx:()=>n.e("ta").then(n.bind(n,"Xl")),javascript:()=>n.e("jsc").then(n.bind(n,"lK")),jsx:()=>n.e("px").then(n.bind(n,"rz")),json:()=>n.e("zj").then(n.bind(n,"BB")),markdown:()=>n.e("2v").then(n.bind(n,"sN")),css:()=>n.e("n").then(n.bind(n,"d2")),bash:()=>Promise.all([n.e(2),n.e(6)]).then(n.bind(n,"ks")),diff:()=>n.e("0w").then(n.bind(n,"SP")),yaml:()=>n.e("ho").then(n.bind(n,"n1")),html:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa")]).then(n.bind(n,"w1")),python:()=>n.e("jd").then(n.bind(n,"hE")),go:()=>n.e("cf").then(n.bind(n,"K1")),rust:()=>n.e("hk").then(n.bind(n,"nb")),sql:()=>n.e("r").then(n.bind(n,"le")),toml:()=>n.e("x0").then(n.bind(n,"DJ")),java:()=>n.e("f8").then(n.bind(n,"lj")),c:()=>n.e("4e").then(n.bind(n,"Gd")),cpp:()=>Promise.all([n.e("4e"),n.e("y6")]).then(n.bind(n,"gB")),csharp:()=>n.e("4k").then(n.bind(n,"Ku")),ruby:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("4e"),n.e("f8"),n.e("r"),n.e("ta"),n.e("y6"),n.e("px"),n.e(2),n.e("yv"),n.e("ct")]).then(n.bind(n,"eV")),php:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e(4)]).then(n.bind(n,"eZ")),kotlin:()=>n.e("7l").then(n.bind(n,"hR")),swift:()=>n.e(0).then(n.bind(n,"ep")),scala:()=>n.e("js").then(n.bind(n,"h3S")),lua:()=>Promise.all([n.e("4e"),n.e("hd")]).then(n.bind(n,"rF")),perl:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e("i")]).then(n.bind(n,"cr")),dockerfile:()=>n.e("b").then(n.bind(n,"BZ")),ini:()=>n.e("3p").then(n.bind(n,"BD")),properties:()=>n.e("1b").then(n.bind(n,"LU")),zig:()=>n.e("3u").then(n.bind(n,"p9")),elixir:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("jll")]).then(n.bind(n,"xu")),dart:()=>n.e("4q").then(n.bind(n,"Cu")),ocaml:()=>n.e("8j").then(n.bind(n,"uA")),haskell:()=>n.e("a").then(n.bind(n,"IX")),nix:()=>n.e("p").then(n.bind(n,"jG")),hcl:()=>n.e("yq").then(n.bind(n,"ka")),graphql:()=>Promise.all([n.e("jsc"),n.e("zn"),n.e("ta"),n.e("px"),n.e("yv")]).then(n.bind(n,"ok")),solidity:()=>n.e("w").then(n.bind(n,"me")),r:()=>n.e(37).then(n.bind(n,"pO")),julia:()=>Promise.all([n.e("jsc"),n.e("4e"),n.e("r"),n.e("y6"),n.e("jd"),n.e("t9")]).then(n.bind(n,"zu")),erlang:()=>Promise.all([n.e("2v"),n.e("y")]).then(n.bind(n,"EY")),clojure:()=>n.e("3d").then(n.bind(n,"lF")),scheme:()=>n.e("az").then(n.bind(n,"wE")),racket:()=>n.e(8).then(n.bind(n,"aB")),protobuf:()=>n.e("1p").then(n.bind(n,"bT")),makefile:()=>n.e("d").then(n.bind(n,"nt")),powershell:()=>n.e("j").then(n.bind(n,"dQ")),json5:()=>n.e("bq").then(n.bind(n,"VH")),less:()=>n.e("c").then(n.bind(n,"i")),scss:()=>Promise.all([n.e("n"),n.e("x")]).then(n.bind(n,"DD")),sass:()=>n.e("zo").then(n.bind(n,"Bc")),stylus:()=>n.e("ky").then(n.bind(n,"uc")),"objective-c":()=>n.e(7).then(n.bind(n,"BG")),groovy:()=>n.e("7e").then(n.bind(n,"tf")),vue:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("zx")]).then(n.bind(n,"Z")),svelte:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("dp")]).then(n.bind(n,"jIY")),astro:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("ta"),n.e("o")]).then(n.bind(n,"CuL")),xml:()=>Promise.all([n.e("f8"),n.e("da")]).then(n.bind(n,"rDW"))},o=["typescript","tsx","javascript","jsx","json","bash","python","markdown","yaml","diff"],c=new Map,d=new Set,u=new Set,p={text:!0,plain:!0,plaintext:!0,txt:!0,ansi:!0,none:!0};function m(e){return!0===p[e]||d.has(e)}function h(e,t){if(m(t))return Promise.resolve();let n=c.get(t);if(n)return n;let r=l[t];if(!r)return Promise.resolve();let i=e.loadLanguage(r).then(()=>{for(let e of(d.add(t),u))e()}).catch(()=>{}).finally(()=>{c.delete(t)});return c.set(t,i),i}async function f(e,t){await Promise.all(t.map(t=>h(e,t)))}let x=null,g=!1,b=new Set;function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function k(){if("u"<typeof window)return null;try{let e=await (0,r.tz)({themes:[s.A,a.A],langs:[],engine:(0,i.l)({forgiving:!0})});x=e,g=!0;let t=[...b];for(let e of(b.clear(),t))try{e()}catch{}return f(e,o),e}catch(e){return console.error("[shiki] highlighter boot failed",e),null}}let y=null;function w(){return y||(y=k()),y}function N(){return g}function Y(e){return g?(e(),()=>{}):(b.add(e),()=>{b.delete(e)})}function D(){return g?x:null}function F(e){return!!x&&(h(x,e),m(e))}let A=function(e){return u.add(e),()=>{u.delete(e)}}},DU(e,t,n){n.d(t,{sQ:()=>s,wY:()=>o,PH:()=>c,O9:()=>d,rw:()=>a,Bl:()=>function e(t){if(null==t)return{isValid:!1};if("object"==typeof t)try{let e=JSON.stringify(t,null,2),n=e.split("\n").length;return{isValid:!0,data:t,pretty:e,linesCount:n}}catch{return{isValid:!1}}if("string"!=typeof t)return{isValid:!1};let n=t.trim();if(!n)return{isValid:!1};let r=n.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);r&&(n=r[1].trim());let i=n.match(/^(?:user\s+(?:selected|responded|answered|response)|response|result|output):\s*([\s\S]+)$/i);if(i){let e=i[1].trim();(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&(n=e)}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))try{let t=JSON.parse(n);if("object"==typeof t&&null!==t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}if("string"==typeof t){let n=e(t);if(n.isValid)return n}}catch{}if(n.startsWith("{")||n.startsWith("["))try{let e=JSON.parse(n);if(null!==e&&"object"==typeof e){let t=JSON.stringify(e,null,2),n=t.split("\n").length;return{isValid:!0,data:e,pretty:t,linesCount:n}}}catch{}let s=n.indexOf("{"),a=n.lastIndexOf("}");if(-1!==s&&a>s){let e=n.slice(s,a+1);try{let t=JSON.parse(e);if(null!==t&&"object"==typeof t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}let l=n.indexOf("["),o=n.lastIndexOf("]");if(-1!==l&&o>l){let e=n.slice(l,o+1);try{let t=JSON.parse(e);if(Array.isArray(t)){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}return{isValid:!1}}});var r=n("eh");let i={light:"one-light",dark:"one-dark-pro"};function s(e){if(!e)return"javascript";let t=e.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");switch(t.split(".").pop()?.toLowerCase()){case"ts":return"typescript";case"tsx":return"tsx";case"js":case"mjs":case"cjs":default:return"javascript";case"jsx":return"jsx";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"sh":case"bash":case"zsh":case"env":return"bash";case"diff":case"patch":return"diff";case"yaml":case"yml":return"yaml";case"html":return"html";case"svg":case"xml":return"xml";case"py":return"python";case"go":return"go";case"rs":return"rust";case"sql":return"sql";case"toml":return"toml";case"java":return"java";case"c":case"h":return"c";case"cpp":case"cc":case"hpp":return"cpp";case"cs":return"csharp";case"rb":return"ruby";case"php":return"php";case"kt":case"kts":return"kotlin";case"swift":return"swift";case"scala":return"scala";case"lua":return"lua";case"pl":return"perl";case"dockerfile":return"dockerfile";case"ini":case"cfg":case"conf":return"ini";case"properties":return"properties";case"zig":return"zig";case"ex":case"exs":return"elixir";case"dart":return"dart";case"ml":case"mli":return"ocaml";case"hs":return"haskell";case"nix":return"nix";case"tf":case"tfvars":case"hcl":return"hcl";case"graphql":case"gql":return"graphql";case"sol":return"solidity";case"r":return"r";case"jl":return"julia";case"erl":return"erlang";case"clj":case"cljs":case"cljc":case"edn":return"clojure";case"scm":case"ss":return"scheme";case"rkt":return"racket";case"proto":return"protobuf";case"makefile":case"mk":return"makefile";case"ps1":case"psm1":return"powershell";case"json5":return"json5";case"less":return"less";case"scss":return"scss";case"sass":return"sass";case"styl":return"stylus";case"vue":return"vue";case"svelte":return"svelte";case"astro":return"astro";case"mm":case"m":return"objective-c";case"groovy":case"gvy":case"gradle":return"groovy"}}function a(e){if(!e||e.length<5)return!1;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),!0}catch{}return[/^(?:import|export)\s+.+from\s+['"][^'"]+['"]/m,/^(?:const|let|var|function|class|interface|type|enum)\s+[A-Za-z0-9_$]+/m,/(?:=>|\bconsole\.(?:log|error|warn)|return\s+|async\s+function)/,/^\s*\d+:\s*(?:import|const|let|function|\/\/|\/\*|<|[A-Za-z])/m,/^\s*\[[A-Za-z0-9_./-]+\.[a-zA-Z0-9]+\]\s*\n\d+:/m].some(e=>e.test(t))}function l(e,t){return(0,r.sT)(t)||e.getLoadedLanguages().includes(t)?t:"javascript"}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript";if(!e)return"";let n=(0,r.F)();if(!n)return(0,r.tn)(e);let s=l(n,t);try{return`<span class="shiki">${n.codeToHtml(e,{lang:s,themes:i,defaultColor:!1,structure:"inline"})}</span>`}catch{return(0,r.tn)(e)}}function c(e){return o(e,"json")}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=e.split("\n");if(!e)return s;let a=(0,r.F)();if(!a)return s.map(r.tn);let o=l(a,t);try{let{tokens:t}=a.codeToTokens(e,{lang:o,themes:i,defaultColor:!1,tokenizeMaxLineLength:n.maxLineLength??0});if(t.length!==s.length)return s.map(r.tn);return t.map(e=>e.map(e=>{let t=(0,r.tn)(e.content);if(!e.htmlStyle)return t;let n=Object.entries(e.htmlStyle).map(e=>{let[t,n]=e;return`${t}:${n}`}).join(";");return n?`<span style="${n}">${t}</span>`:t}).join(""))}catch{return s.map(r.tn)}}},U8(e,t,n){function r(e){if(null!=e){if("string"==typeof e)return e;if(Number.isFinite(e)&&!(e<=0)){if(e>=1e6){let t=e/1e6;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return`${Number.isInteger(t)?t:t.toFixed(1)}K`}return String(e)}}}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return"number"!=typeof e||!Number.isFinite(e)||e<=0?"":`$${e.toFixed(t)}`}function s(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":`$${e.toFixed(2)}`}n.d(t,{$g:()=>a,BD:()=>i,Rk:()=>r,z3:()=>s})},LQ(e,t,n){function r(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25",a=(e||"").trim().toUpperCase();if(t){let e=a[0]||"M";"A"===e?(n="A",r="Added (Staged)",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted (Staged)",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed (Staged)",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified (Staged)",i="text-info",s="bg-info/10 text-info border-info/25")}else if("??"===a||"?"===a||"U"===a||"UNTRACKED"===a)n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25";else{let e=a[1]||a[0]||"M";"A"===e?(n="A",r="Added",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25")}return{charStatus:n,label:r,colorClass:i,badgeBgClass:s,isStaged:t}}function i(e){let t=new Map,n=new Map;if(!Array.isArray(e))return{fileMap:t,folderMap:n};for(let r of e){if(!r||!r.file)continue;let e=r.file.replace(/^\/+/,"");t.set(e,r);let i=e.split("/");i.pop();let s="";for(let e of i){s=s?`${s}/${e}`:e;let t=n.get(s)||{count:0,hasModified:!1,hasUntracked:!1,hasStaged:!1,hasDeleted:!1,colorClass:"text-info"};t.count+=1,(r.staged||r.status&&" "!==r.status[0]&&"?"!==r.status[0])&&(t.hasStaged=!0),"??"===r.status?t.hasUntracked=!0:r.status?.includes("D")?t.hasDeleted=!0:t.hasModified=!0,t.hasModified||t.hasStaged?t.colorClass="text-info":t.hasUntracked?t.colorClass="text-success":t.hasDeleted&&(t.colorClass="text-error"),n.set(s,t)}}return{fileMap:t,folderMap:n}}n.d(t,{R:()=>r,_:()=>i})},W9(e,t,n){let r=null,i=null;function s(){return i&&i.expiresAt>Date.now()?Promise.resolve(i.data):r||(r=fetch("/api/models").then(e=>e.ok?e.json():Promise.reject(Error(`GET /api/models failed: ${e.status}`))).then(e=>(i={data:e,expiresAt:Date.now()+6e4},e)).finally(()=>{r=null}))}function a(){i=null}function l(){i=null,window.dispatchEvent(new CustomEvent("omp:models-updated"))}function o(e){return window.addEventListener("omp:models-updated",e),()=>window.removeEventListener("omp:models-updated",e)}n.d(t,{$P:()=>l,Sy:()=>o,kn:()=>a,xo:()=>s})},Np(e,t,n){let r="new-";function i(e){return String(e).padStart(2,"0")}function s(e){return!!e?.startsWith(r)}function a(e){return e?.startsWith(r)?Number(e.slice(r.length)):0/0}function l(e){let t=a(e);return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return Number.isNaN(e.getTime())?"New Session":`New Session - ${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}T${i(e.getHours())}:${i(e.getMinutes())}:${i(e.getSeconds())}`}(Number.isFinite(t)?new Date(t):new Date)}n.d(t,{fN:()=>s,fd:()=>a,g2:()=>l})},e(e,t,n){let r=["input","_input","patch"],i=/#([0-9a-fA-F]{4})$/,s=/^(PUT|CUT)\b/;function a(e){let t=e[0];return e.length>=2&&('"'===t||"'"===t)&&t===e[e.length-1]?e.slice(1,-1):e}function l(e){if(e)for(let t of r){let n=e[t];if("string"!=typeof n)continue;let r=function(e){let t,n=[];for(let r of e.replace(/^\uFEFF/,"").split("\n")){let e=r.endsWith("\r")?r.slice(0,-1):r,l=function(e){let t=e.trimEnd();if(!t.startsWith("["))return;let n=(t.endsWith("]")?t.slice(1,-1):t.slice(1)).trim(),r=i.exec(n),s=a((r?n.slice(0,r.index):n).trim());return s?{path:s,tag:r?.[1]}:void 0}(e);if(l){t={path:l.path,tag:l.tag,removed:!1,ops:[]},n.push(t);continue}if(!t)continue;let o=e.trim();if("REM"===o){t.removed=!0;continue}if(o.startsWith("MV ")){t.moveTo=a(o.slice(3).trim())||void 0;continue}if(s.test(o)){t.ops.push({verb:o.slice(0,3),spec:o.slice(3).trim().replace(/:$/,""),body:[]});continue}let c=t.ops[t.ops.length-1];c&&e.startsWith("+")&&c.body.push(e)}return n}(n);if(r.length>0)return{text:n,sections:r}}}function o(e){return l(e)?.sections[0].path}n.d(t,{I:()=>l,f$:()=>o})},wm(e,t,n){function r(e,t){e&&fetch("/api/agent/prewarm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,...t?{accessMode:t}:{}})}).catch(()=>{})}function i(e,t,n){let r=void 0!==n?e.find(e=>String(e.id)===String(n)):e.find(e=>e.sessions?.some(e=>String(e.id)===String(t)))??e.find(e=>!!e.project_path);return r?.project_path||r?.name||null}n.d(t,{l:()=>i,r:()=>r})},B(e,t,n){var r=n("oS");function i(e){return(0,r.u)(e)&&"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.agent&&e.agent.length>0&&"string"==typeof e.status&&"number"==typeof e.index}async function s(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`);if(!t.ok)return null;let n=await t.json().catch(()=>null);if(!(0,r.u)(n))return null;let s=(0,r.u)(n.data)?n.data:n;if(!Array.isArray(s.subagents))return null;return s.subagents.filter(i)}catch{return null}}function a(e){let t={...e,source:"history",lastUpdate:0},n={};return void 0!==e.lastIntent&&(n.lastIntent=e.lastIntent),void 0!==e.toolCount&&(n.toolCount=e.toolCount),void 0!==e.requests&&(n.requests=e.requests),void 0!==e.tokens&&(n.tokens=e.tokens),void 0!==e.contextTokens&&(n.contextTokens=e.contextTokens),void 0!==e.contextWindow&&(n.contextWindow=e.contextWindow),void 0!==e.cost&&(n.cost=e.cost),void 0!==e.durationMs&&(n.durationMs=e.durationMs),void 0!==e.resolvedModel&&(n.resolvedModel=e.resolvedModel),Object.keys(n).length>0&&(t.progress=n),t}n.d(t,{Nh:()=>a,wv:()=>s})},T(e,t,n){var r=n("oS");function i(e){return"string"==typeof e&&e.length>0?e:void 0}function s(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function a(e){return"bundled"===e||"user"===e||"project"===e?e:void 0}function l(e){var t;if(!(0,r.u)(e))return;let n={},l=s(e.index);void 0!==l&&(n.index=l);let o=i(e.id);void 0!==o&&(n.id=o);let c=i(e.agent);void 0!==c&&(n.agent=c);let d=a(e.agentSource);void 0!==d&&(n.agentSource=d);let u="pending"===(t=e.status)||"running"===t||"completed"===t||"failed"===t||"aborted"===t?t:void 0;void 0!==u&&(n.status=u);let p=i(e.task);void 0!==p&&(n.task=p);let m=i(e.assignment);void 0!==m&&(n.assignment=m);let h=i(e.description);void 0!==h&&(n.description=h);let f=i(e.lastIntent);void 0!==f&&(n.lastIntent=f);let x=i(e.currentTool);void 0!==x&&(n.currentTool=x);let g=i(e.currentToolArgs);void 0!==g&&(n.currentToolArgs=g);let b=s(e.currentToolStartMs);void 0!==b&&(n.currentToolStartMs=b),Array.isArray(e.recentTools)&&(n.recentTools=e.recentTools),Array.isArray(e.recentOutput)&&(n.recentOutput=e.recentOutput.filter(e=>"string"==typeof e));let v=s(e.toolCount);void 0!==v&&(n.toolCount=v);let k=s(e.requests);void 0!==k&&(n.requests=k);let y=s(e.tokens);void 0!==y&&(n.tokens=y);let w=s(e.contextTokens);void 0!==w&&(n.contextTokens=w);let N=s(e.contextWindow);void 0!==N&&(n.contextWindow=N);let Y=s(e.cost);void 0!==Y&&(n.cost=Y);let D=s(e.durationMs);void 0!==D&&(n.durationMs=D),("string"==typeof e.modelOverride||Array.isArray(e.modelOverride)&&e.modelOverride.every(e=>"string"==typeof e))&&(n.modelOverride=e.modelOverride);let F=i(e.modelRole);void 0!==F&&(n.modelRole=F);let A=i(e.resolvedModel);if(void 0!==A&&(n.resolvedModel=A),"boolean"==typeof e.resolvedModelIsFallback&&(n.resolvedModelIsFallback=e.resolvedModelIsFallback),(0,r.u)(e.retryState)){let t=s(e.retryState.attempt),r=s(e.retryState.maxAttempts),a=s(e.retryState.delayMs),l=i(e.retryState.errorMessage),o=s(e.retryState.startedAtMs);void 0!==t&&void 0!==r&&void 0!==a&&void 0!==l&&void 0!==o&&(n.retryState={attempt:t,maxAttempts:r,delayMs:a,errorMessage:l,startedAtMs:o})}if((0,r.u)(e.retryFailure)){let t=s(e.retryFailure.attempt),r=i(e.retryFailure.errorMessage);void 0!==t&&void 0!==r&&(n.retryFailure={attempt:t,errorMessage:r})}return void 0!==e.inflightTaskDetails&&(n.inflightTaskDetails=e.inflightTaskDetails),(0,r.u)(e.extractedToolData)&&(n.extractedToolData=e.extractedToolData),Object.keys(n).length>0?n:void 0}function o(e){if(!(0,r.u)(e))return;let t=i(e.id),n=i(e.status);if(!t||!n||"started"!==n&&"completed"!==n&&"failed"!==n&&"aborted"!==n)return;let l={id:t,agent:i(e.agent)??"subagent",status:n,index:s(e.index)??-1,lastUpdate:Date.now(),source:"live"},o=a(e.agentSource);void 0!==o&&(l.agentSource=o);let c=i(e.description);void 0!==c&&(l.description=c);let d=i(e.sessionFile);void 0!==d&&(l.sessionFile=d);let u=i(e.parentToolCallId);return void 0!==u&&(l.parentToolCallId=u),"boolean"==typeof e.detached&&(l.detached=e.detached),l}function c(e){if(!(0,r.u)(e))return[];let t=e.subagents;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=function(e){let t;if(!(0,r.u)(e))return;let n=i(e.id),o=i(e.agent);if(!n||!o)return;if("started"===e.status||"completed"===e.status||"failed"===e.status||"aborted"===e.status)t=e.status;else{if("pending"!==e.status&&"running"!==e.status)return;t="started"}let c={id:n,agent:o,status:t,index:s(e.index)??-1,source:"live"},d=a(e.agentSource);void 0!==d&&(c.agentSource=d);let u=i(e.description);void 0!==u&&(c.description=u);let p=i(e.task);void 0!==p&&(c.task=p);let m=i(e.assignment);void 0!==m&&(c.assignment=m);let h=i(e.sessionFile);void 0!==h&&(c.sessionFile=h);let f=i(e.parentToolCallId);void 0!==f&&(c.parentToolCallId=f),c.lastUpdate=s(e.lastUpdate)??Date.now();let x=l(e.progress);return void 0!==x&&(c.progress=x),c}(e);t&&n.push(t)}return n}function d(e,t){return(e.batchSeq??Number.MAX_SAFE_INTEGER)-(t.batchSeq??Number.MAX_SAFE_INTEGER)||e.index-t.index||e.id.localeCompare(t.id)}function u(e,t,n){let r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.id);if(!t){r.set(e.id,e);continue}let i=t.batchSeq??e.batchSeq;if(void 0!==n&&(t.lastUpdate??0)>=n||"history"===e.source&&"history"!==t.source){i!==t.batchSeq&&r.set(e.id,{...t,batchSeq:i});continue}if("history"!==e.source&&"history"===t.source){r.set(e.id,{...e,batchSeq:i});continue}r.set(e.id,{...t,...e,batchSeq:i})}return[...r.values()].sort(d)}n.d(t,{bH:()=>o,j8:()=>u,mq:()=>l,vG:()=>c})},So(e,t,n){let r="omp_chamber_settings",i=null,s={};function a(e){s={...e?.[r]??{}};let t={...e??{}};delete t[r],i={...t,...s}}function l(e){return i||a(e),i??{}}function o(e,t){let n=Array.isArray(e)?e:[e],r=l(t);for(let e of n)if(void 0!==r[e])return r[e]}function c(e,t){return l(t),{...e,...s}}function d(e,t){i={...l(),[e]:t},p({[e]:t})}function u(e){s={...s,...e},i={...l(),...e},p({[r]:s})}function p(e){fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}n.d(t,{BF:()=>o,cm:()=>c,cz:()=>d,l1:()=>u,x9:()=>a})},oS(e,t,n){function r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}n.d(t,{u:()=>r})},Gb(e,t,n){function r(e,t){if(!t)return{folder:null,projectPath:null};for(let n of e)if((n.sessions||[]).some(e=>String(e.id)===String(t)))return{folder:n,projectPath:n.project_path??null};return{folder:null,projectPath:null}}function i(e,t,n){let i=r(e,t).folder,s=null!=n?e.find(e=>String(e.id)===String(n))??null:null;return(i??s)?.project_path??null}n.d(t,{M:()=>i,t:()=>r})},A(e,t,n){var r=n("g6"),i=n("AB"),s=n("N"),a=n("h"),l=n("al"),o=n("nv"),c=n("nT"),d=n("w"),u=n("Oj"),p=n("Gh"),m=n("R"),h=n("HJ"),f=n("DK"),x=n("f"),g=n("z9"),b=n("Fx"),v=n("F9"),k=n("bt"),y=n("YO"),w=n("by");let N={default:r.A,code:i.A,terminal:s.A,rocket:a.A,flask:l.A,gamepad:o.A,briefcase:c.A,home:d.A,globe:u.A,leaf:p.A,shield:m.A,palette:h.A,server:f.A,smartphone:x.A,database:g.A,lightbulb:b.A,music:v.A,camera:k.A,book:y.A,heart:w.A};function Y(e){return N[e||"default"]||r.A}n.d(t,{x:()=>Y})},ET(e,t,n){let r=["context","files","search","git","terminal","user-browser","browser","usage"];function i(e){return"string"==typeof e&&r.includes(e)}n.d(t,{ls:()=>i},{G7:r,lw:{files:200,search:200,git:260,terminal:320,context:420,"user-browser":320,browser:320,usage:420},qv:{files:268,search:268,git:268,terminal:640,context:536,"user-browser":804,browser:804,usage:536}})},SS(e,t,n){let r=new Map,i=new Map,s=new Set,a=new Map,l=new Map;function o(e){let t=r.get(e);void 0!==t&&(r.delete(e),r.set(e,t)),i.set(e,Date.now())}function c(e){let t=Date.now(),n=e=>{r.delete(e),s.delete(e),a.delete(e),i.delete(e);let t=l.get(e);t&&(clearTimeout(t),l.delete(e))};for(let[r,s]of i)!(t-s<=6e5)&&r!==e&&(a.get(r)||n(r));for(;r.size>10;){let t=!1;for(let i of r.keys())if(i!==e&&!a.get(i)){n(i),t=!0;break}if(!t)break}}function d(e,t){if(e)return o(e),r.get(e)?.[t]}function u(e,t,n){if(!e)return;let i=r.get(e)??{};i[t]=n,r.set(e,i),o(e),a.set(e,!0),p(e),c(e)}function p(e){let t=l.get(e);t&&clearTimeout(t),l.set(e,setTimeout(()=>{l.delete(e),m(e)},600))}async function m(e){if("u"<typeof window||!e||!a.get(e))return;a.set(e,!1);let t=r.get(e)??{};try{await fetch(`/api/sessions/${encodeURIComponent(e)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:t})})}catch(t){console.warn("session-state persist failed:",t),a.set(e,!0)}}function h(e){if(!e||"u"<typeof window)return Promise.resolve();let t=l.get(e);return t&&(clearTimeout(t),l.delete(e)),m(e)}async function f(e){if(e){if("u"<typeof window)return void s.add(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(t.ok){let n=await t.json(),i=n.state&&"object"==typeof n.state?n.state:{},s=r.get(e)??{},l=!0===a.get(e)?{...i,...s}:i;r.set(e,l),o(e)}}catch(e){console.warn("session-state load failed:",e)}s.add(e),c(e)}}function x(e,t){e&&(r.set(e,{...r.get(e)??{},...t}),o(e),s.add(e),c(e))}function g(e){e&&s.add(e)}function b(e){e&&i.set(e,Date.now())}function v(e){return i.get(e)}function k(e,t){let n=r.get(e);n&&r.set(t,{...n,...r.get(t)??{}}),o(t),s.add(t),a.set(t,!0),p(t),r.delete(e),s.delete(e),a.delete(e),i.delete(e),c(t)}n.d(t,{D4:()=>h,E9:()=>x,L6:()=>f,R7:()=>v,WV:()=>d,Y1:()=>b,l5:()=>g,qI:()=>u,vy:()=>k})},P(e){e.exports={rE:"1.0.0"}}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.d=(e,t,n)=>{var r=(t,n)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[n]:t[r]})};r(t,"get"),r(n,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,n)=>(l.f[n](e,t),t),[])),l.u=e=>"static/js/async/"+(121===e?"katex-vendor":e)+"."+({0:"8e59f2eb5b","0k":"5852e6b4fa","0w":"9ed36d5860",1:"f387c12b63",12:"d091f91c99",121:"de6a87c308",13:"8f810a8a6c",19:"6fe909d55a","1b":"23f1141a38","1k":"5974df3b87","1p":"0d5cddda96",2:"b589f1733b","2v":"96165101de",3:"0cacc08423",37:"b28b2f61cd","3d":"5085fb913f","3j":"357c80ff38","3p":"bcf32a0983","3r":"3a69e98ee0","3u":"1228460e2a","3y":"71f2ccf3b6",4:"9442eeb472","4e":"678285ca55","4k":"33a0c7eeb4","4q":"aad20dab25",5:"ebaf8b89cc",51:"95bcae98af","5b":"0d6ae50fe8","5bh":"8b2363424f","5j":"d6407c4248","5o":"88316d4460",6:"f034c9b528",66:"5dfa29f957","6o":"5b1a06a382",7:"e4a9288dd0",73:"308dff4da8","7e":"a1cc9bfd88","7g":"a7814350c3","7l":"7a6a377ecc",8:"5067439d8c","8j":"ea110663fb",a:"bce4542392",aa:"65d3852576",az:"d656062b0f",b:"b4f6f06515",bi:"09688ba75c",bq:"586bc738d1",c:"797d933882",c0:"0af1e640d3",ca:"8a52cfd447",cf:"d34fff5d67",ct:"b74928f7a3",cx:"ca5feec570",d:"a5fc8fe1b3",da:"f62c70f6c8",dc:"856fda6560",dp:"1725d6432c",e:"93214d622b",f:"ab50467719",f8:"bbf0dbae70",g:"a06ca3b3e9",h:"4e790471e4",h1:"e8d5aa8e80",h3:"216e9798ab",hd:"0da931b622",hk:"ba7fb04d41",hn:"b645041e00",ho:"475a5e1ae4",hp:"e9fe2e395a",hs:"6d480d0ded",i:"7c148e8440",id:"573df20f29",j:"ab925882d8",jd:"63886a1f09",jg:"d86ebd4013",jl:"874d352278",jll:"11313b455a",js:"67182759ef",jsc:"23b70d6f40",jse:"334588ff5d",jz:"72eb929106",k:"7466330d1a",ka:"c1990ecaa3",ku:"29c8a59d0c",ky:"8dab1dade0",l:"12dd34e1be",l9:"949710adaf",ls:"9d9a01026c",m:"c038c71b9f",ma:"2c261b04dd",me:"8ace414f80",ms:"98960af4eb",mt:"0352e976d8",n:"a9f1c51701",na:"a36cd532d6",nam:"b5663e919f",nk:"fc7e58325e",o:"36353dfb88",oc:"9c060c9779",og:"634fba99ac",ot:"84c71b308f",p:"48ecfcd14e",px:"783b6f91f2",q:"23af2a358f",q5:"e683f7c26e",qs:"2a9ddb3c72",r:"51010ad87c",rd:"cb6bf495bb",s:"222ee974f6",sy:"d16be843a7",t:"4dca0e2ba8",t9:"d44f57d518",ta:"973534bbec",tr:"e878658140",u:"0871ac5b22",ud:"3065bfee31",uf:"46ad6209fa",up:"ea990da0ff",uw:"8890abbabc",v:"7d28d3c241",vp:"9b13bf8610",vt:"42416b707d",w:"08ac210f60",wt:"ad92393a90",x:"563f72ca6b",x0:"475516418f",x1:"da8687159b",xl:"a3c562a58c",xn:"6360379f71",xnl:"feb0021e50",y:"1a9ed7a5d8",y6:"43c57defe4",yb:"8c1342401d",ybq:"4491f2f2dc",yg:"35bebd6d0c",yq:"917ddd7ba2",ys:"00687cf82d",yv:"2fa22f009a",z:"56f61a4374",zi:"5fdb07b86a",zj:"654f37e8ff",zn:"966d6f1cc6",zo:"26213b40c0",zx:"e9f4105e00"})[e]+".js",l.miniCssF=e=>""+e+".css",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},l.l=function(t,n,r,i){if(e[t])return void e[t].push(n);if(void 0!==r)for(var s,a,o=document.getElementsByTagName("script"),c=0;c<o.length;c++){var d=o[c];if(d.getAttribute("src")==t||d.getAttribute("data-rspack")=="ompchamber:"+r){s=d;break}}s||(a=!0,(s=document.createElement("script")).timeout=120,l.nc&&s.setAttribute("nonce",l.nc),s.setAttribute("data-rspack","ompchamber:"+r),s.src=t),e[t]=[n];var u=function(n,r){s.onerror=s.onload=null,clearTimeout(p);var i=e[t];if(delete e[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach(function(e){return e(r)}),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),a&&document.head.appendChild(s)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t=[],l.O=(e,n,r,i)=>{if(n){i=i||0;for(var s=t.length;s>0&&t[s-1][2]>i;s--)t[s]=t[s-1];t[s]=[n,r,i];return}for(var a=1/0,s=0;s<t.length;s++){for(var[n,r,i]=t[s],o=!0,c=0;c<n.length;c++)(!1&i||a>=i)&&Object.keys(l.O).every(e=>l.O[e](n[c]))?n.splice(c--,1):(o=!1,i<a&&(a=i));if(o){t.splice(s--,1);var d=r();void 0!==d&&(e=d)}}return e},l.p="/",n={qz:0},l.f.j=function(e,t){var r=l.o(n,e)?n[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var i=new Promise((t,i)=>r=n[e]=[t,i]);t.push(r[2]=i);var s=l.p+l.u(e),a=Error();l.l(s,function(t){if(l.o(n,e)&&(0!==(r=n[e])&&(n[e]=void 0),r)){var i=t&&("load"===t.type?"missing":t.type),s=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+s+")",a.name="ChunkLoadError",a.type=i,a.request=s,r[1](a)}},"chunk-"+e,e)}},l.O.j=e=>0===n[e],r=(e,t)=>{var r,i,[s,a,o]=t,c=0;if(s.some(e=>0!==n[e])){for(r in a)l.o(a,r)&&(l.m[r]=a[r]);if(o)var d=o(l)}for(e&&e(t);c<s.length;c++)i=s[c],l.o(n,i)&&n[i]&&n[i][0](),n[i]=0;return l.O(d)},(i=self.rspackChunkompchamber=self.rspackChunkompchamber||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var o=l.O(void 0,["a3","9","jp"],()=>l("l"));o=l.O(o)})();